Add packages for hydrometeors in the init_atmosphere core#1467
Conversation
…module This commit adds a new private subroutine, mpas_split_string_new, to the init_atm_core_interface module. The purpose of this subroutine is essentially the same as the mpas_split_string routine in the mpas_string_utils module, but the maximum length of any substring does not need to be assumed in mpas_split_string_new, whereas the mpas_split_string subroutine requires the caller to declare a pointer to an array of strings of a specific length. Eventually, this routine could be migrated to mpas_string_utils and used as a replacement for mpas_split_string.
This commit defines new packages for hydrometeors, one package per hydrometeor, in the init_atmosphere core, and it provides two means of activating these packages. 1) If the new namelist option config_active_hydrometeors is set to 'detect_automatically', packages will be set up by scanning through the fields in the initial intermediate file, with packages being activated only for those hydrometeors that are present in the file. 2) Alternatively, and to avoid the need to scan through all fields in the initial intermediate file, config_active_hydrometeors may be set to a semicolon-separated list of zero or more hydrometeor names (e.g., 'qc;qr'). Packages for those specified hydrometeors will be active, and the packages for all unspecified hydrometeors will be inactive. A new subroutine, setup_hydrometeor_packages, handles the details of the hydrometeor package setup, and this routine is called from init_atm_setup_packages only if config_init_case is 7 or 9, and if met_stage_out is true.
5df7d3a to
f3b116c
Compare
| <nml_option name="config_active_hydrometeors" type="character" default_value="detect_automatically" | ||
| units="-" | ||
| description="The set of hydrometeor species that are to be processed from input intermediate files when generating ICs and LBCs for real-data simulations." | ||
| possible_values="`detect_automatically', or a semicolon-separated list of hydrometeor names (e.g., `qc;qr'"/> |
There was a problem hiding this comment.
Would it be simpler to use 'auto' instead of 'detect_automatically'?
There was a problem hiding this comment.
Given that this is the default (and therefore, users wouldn't need to type it themselves), I'd lean towards the more verbose of the two options, i.e., detect_automatically.
| ! Arguments | ||
| character(len=*), intent(in) :: string | ||
| character, intent(in) :: delimiter | ||
| character(len=:), dimension(:), allocatable, intent(inout) :: subStrings |
There was a problem hiding this comment.
Could declaring this with intent(out) work instead? I see that the compiler will automatically deallocate an allocatable with intent(out) before entering the routine. https://fortran-lang.org/learn/best_practices/allocatable_arrays/
There was a problem hiding this comment.
Could you do some testing to verify that this works in practice with the GNU, Intel, and NVHPC compilers?
There was a problem hiding this comment.
I'm fine with the PR as it is, and will approve for now. But can check this with various compilers for future reference.
| !> length of the longest substring in the input string. | ||
| ! | ||
| !----------------------------------------------------------------------- | ||
| subroutine mpas_split_string_new(string, delimiter, subStrings) |
There was a problem hiding this comment.
Also wondering if this subroutine might be better placed in some common utils module
|
|
||
| do i = 1, size(hydrometeors) | ||
| select case (trim(hydrometeors(i))) | ||
| case ('qc') |
There was a problem hiding this comment.
This part of the code is case sensitive to the values specified in config_active_hydrometeors. Is that okay?
There was a problem hiding this comment.
I'm fine with keeping this case-sensitive for now.
This PR defines new packages for hydrometeors, one package per hydrometeor, in the
init_atmospherecore, and it provides two means of activating these packages.If the new namelist option
config_active_hydrometeorsis set to'detect_automatically', packages will be set up by scanning through the fields in the initial intermediate file, with packages being activated only for those hydrometeors that are present in the file.Alternatively, and to avoid the need to scan through all fields in the initial intermediate file,
config_active_hydrometeorsmay be set to to a semicolon-separated list of zero or more hydrometeor names (e.g.,'qc;qr'). Packages for those specified hydrometeors will be active, and the packages for all unspecified hydrometeors will be inactive.A new subroutine,
setup_hydrometeor_packages, handles the details of the hydrometeor package setup, and this routine is called frominit_atm_setup_packagesonly ifconfig_init_caseis 7 or 9, and ifmet_stage_outis true.