Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix all namelist group and option names for MPAS dycore #1285

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kuanchihwang
Copy link
Contributor

@kuanchihwang kuanchihwang commented Jan 30, 2025

When MPAS is used as a dynamical core in a host model (e.g., CAM/CAM-SIMA), it needs to share the namelist file with other model components. Therefore, MPAS namelist groups and options may not be easily recognizable at first sight. The solution, which is implemented by this PR, is to add a unique identifier to all MPAS namelist group and option names.

The following transformations are performed for each MPAS namelist group and option name:

  1. Leading config_ is removed recursively from the name. Case-insensitive.
  2. Leading mpas_ is removed recursively from the name. Case-insensitive.
  3. Prepend mpas_ to the name.

As a result, it is now easier to distinguish MPAS namelist groups and options from CAM-SIMA ones. Additionally, the possibility of name collisions with CAM-SIMA ones is also resolved once and for all. Note that only namelist I/O is affected. Internally, MPAS still refers to its namelist options by their original names due to compatibility reasons.

Compared to the implementation in CAM, this PR applies the "name mangling" logic in an algorithmic and predictable way. It works automatically even if there are additions, modifications, or deletions to MPAS namelist groups and options.

The "name mangling" logic is entirely guarded behind the MPAS_CAM_DYCORE macro. For stand-alone MPAS, there is no functional change, which can be confirmed by the parse utility staying bitwise identical. For CAM, it is not affected by this PR because it does not use the code generation functionality of MPAS for namelist reading. For CAM-SIMA, the Fortran include files generated by the parse utility stay the same. Its regression tests all pass, indicating identical model results to the previous baseline.

When MPAS is used as a dynamical core, the following transformations are
performed for each namelist group and option name:

1. Leading `config_` is removed recursively from the name. Case-insensitive.
2. Leading `mpas_` is removed recursively from the name. Case-insensitive.
3. Prepend `mpas_` to the name.

As a result, it is now easier to distinguish MPAS namelist groups and options
from CAM-SIMA ones. Additionally, the possibility of name collisions with
CAM-SIMA ones is also resolved once and for all.

Note that only namelist I/O is affected. Internally, MPAS still refers to its
namelist options by their original names due to compatibility reasons.
@kuanchihwang kuanchihwang force-pushed the staging/dycore-prefix-namelist branch from 183fed2 to 930e9f9 Compare January 31, 2025 18:31
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