Skip to content

Add packages for hydrometeors in the init_atmosphere core#1467

Open
mgduda wants to merge 2 commits into
MPAS-Dev:developfrom
mgduda:init_atmosphere/hydrometeor_packages
Open

Add packages for hydrometeors in the init_atmosphere core#1467
mgduda wants to merge 2 commits into
MPAS-Dev:developfrom
mgduda:init_atmosphere/hydrometeor_packages

Conversation

@mgduda

@mgduda mgduda commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This PR 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 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.

mgduda added 2 commits June 4, 2026 18:10
…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.
@mgduda mgduda force-pushed the init_atmosphere/hydrometeor_packages branch from 5df7d3a to f3b116c Compare June 8, 2026 22:36
@mgduda mgduda marked this pull request as ready for review June 8, 2026 22:38
@mgduda mgduda requested a review from abishekg7 June 8, 2026 22:38
<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'"/>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be simpler to use 'auto' instead of 'detect_automatically'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do some testing to verify that this works in practice with the GNU, Intel, and NVHPC compilers?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will check

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wondering if this subroutine might be better placed in some common utils module

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message for 3bc08ca does recognize that this routine might ultimately be migrated to the mpas_string_utils module. I'll replace 3bc08ca with a commit that adds this routine directly to mpas_string_utils.F.


do i = 1, size(hydrometeors)
select case (trim(hydrometeors(i)))
case ('qc')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code is case sensitive to the values specified in config_active_hydrometeors. Is that okay?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with keeping this case-sensitive for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants