Skip to content

Conversation

mattldawson
Copy link
Collaborator

@mattldawson mattldawson commented Jul 8, 2025

Tag name (required for release branches):
Originator(s): Matt Dawson

Description (include the issue title, and the keyword ['closes', 'fixes', 'resolves'] followed by the issue number):
This PR updates to use a newer version of atmospheric_physics that includes setting the default_value of constituent instances created for chemical species based on data in the MICM species configuration files. The updates to CAM-SIMA remove the hard-coded initial species mixing ratios for Terminator and Chapman mechanisms and instead set the initial mixing ratios for chemical species based on the default_value of the corresponding constituent, which allows any mechanism to be run. This is needed to demonstrate the run-time configurability of the chemical system.

@nusbaume - I wasn't sure if the logic for setting default values for constituents should be restricted to chemical species or not. If it makes sense to set this value for any constituent, I can modify this PR, but would need some guidance on where in the workflow to set the default value to avoid overwriting conditions explicitly set in other parts of the code.

Describe any changes made to build system:
updated commits for atmospheric_physics and cam-sima-chemistry-data repos.

Describe any changes made to the namelist:
none

List any changes to the defaults for the input datasets (e.g. boundary datasets):
none

List all files eliminated and why:
musica_sima_namelist.F90 - no namelist parameters are needed for musica now that CAM-SIMA is not restricted to Terminator and Chapman

List all files added and what they do:
none

List all existing files that have been modified, and describe the changes:
(Helpful git command: git diff --name-status development...<your_branch_name>)

File Description
src/physics/utils/musica_sima_namelist.F90 Removed use of deleted musica namelist module
src/physics/utils/musica_ccpp_dependencies.F90 Replaced hard-coded initial mixing ratios for MICM species with constituent default_value
src/control/runtime_opts.F90 Removed call to musica_ccpp_dependencies_readnl
src/control/cam_comp.F90 Updated set_initial_musica_concentrations call to include properties for accessing default_value
cime_config/atm_musica_config.py Updated CHEMISTRY_DATA_TAG
.gitmodules Updated atmospheric_physics submodule tag

If there are new failures (compared to the test/existing-test-failures.txt file),
have them OK'd by the gatekeeper, note them here, and add them to the file.
If there are baseline differences, include the test and the reason for the
diff. What is the nature of the change? Roundoff?
will add after tests are run

derecho/intel/aux_sima:

derecho/gnu/aux_sima:

If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:
this should only affect chemistry

CAM-SIMA date used for the baseline comparison tests if different than latest:

@mattldawson mattldawson requested a review from Copilot July 8, 2025 19:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces hard-coded initial mixing ratios for chemical species with default values from the updated atmospheric_physics MICM configuration, removes the obsolete MUSICA namelist module, and updates submodule references.

  • Remove musica_sima_namelist and namelist reading/calls
  • Initialize TUV-x species from hard-coded list and MICM species via default_value
  • Update CAM-SIMA init and timestep routines to pass constituent_properties
  • Bump submodule tags for atmospheric_physics and cam-sima-chemistry-data

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/physics/utils/musica_sima_namelist.F90 Deleted obsolete namelist module
src/physics/utils/musica_ccpp_dependencies.F90 Replaced MUSICA species logic with TUV-x array and MICM default_value
src/control/runtime_opts.F90 Removed call to musica_ccpp_dependencies_readnl
src/control/cam_comp.F90 Updated set_initial_musica_concentrations call to include properties
cime_config/atm_musica_config.py Updated CHEMISTRY_DATA_TAG
.gitmodules Updated atmospheric_physics submodule tag
Comments suppressed due to low confidence (3)

src/physics/utils/musica_ccpp_dependencies.F90:157

  • This default_value assignment introduces new behavior for setting initial mixing ratios from MICM species configuration. Consider adding unit tests to verify that default_value is correctly retrieved and applied for all species in micm_species_set.
      call constituent_properties(i_constituent)%default_value( &

src/physics/utils/musica_ccpp_dependencies.F90:51

  • [nitpick] The name tuvx_species may not clearly convey that this array holds initial mixing ratios. Consider renaming to something like initial_tuvx_species or tuvx_initial_species for better clarity.
  type(species_t), allocatable :: tuvx_species(:)

src/physics/utils/musica_ccpp_dependencies.F90:147

  • The use of FILE and LINE macros may not be supported by all Fortran compilers. Consider using a constant subroutine name parameter or the standard mechanisms (e.g., the ISO_FORTRAN_ENV module) to report file and line information.
      call endrun(errmsg, file=__FILE__, line=__LINE__)

Comment on lines +297 to +298
use cam_ccpp_cap, only: cam_constituents_array
use cam_ccpp_cap, only: cam_model_const_properties
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

[nitpick] These two use cam_ccpp_cap statements import symbols from the same module. Consider merging them into a single use cam_ccpp_cap listing both cam_constituents_array and cam_model_const_properties to improve clarity.

Suggested change
use cam_ccpp_cap, only: cam_constituents_array
use cam_ccpp_cap, only: cam_model_const_properties
use cam_ccpp_cap, only: cam_constituents_array, cam_model_const_properties

Copilot uses AI. Check for mistakes.

Copy link
Member

@jimmielin jimmielin left a comment

Choose a reason for hiding this comment

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

Thanks @mattldawson!

Copy link
Collaborator

@boulderdaze boulderdaze left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Thanks @mattldawson! I pushed up one last change to remove the musica_config namelist variable from the definition file (as the namelist reader for it was already removed), but otherwise it looks good to me!

Also I think for now just setting the initial/default values for the chemical species only is fine, as some CAM physics schemes seem to require specialized initialization logic for their relevant constituent variables, and so until that is all sorted out it is probably safest to keep things separate. Thanks for checking though!

@mattldawson mattldawson merged commit 110861e into ESCOMP:development Jul 11, 2025
12 checks passed
@mattldawson mattldawson deleted the develop-allow-runtime-species branch July 11, 2025 13:35
jimmielin added a commit that referenced this pull request Jul 16, 2025
Tag name (required for release branches): sima0_06_001
Originator(s): @jimmielin

Description (include the issue title, and the keyword ['closes',
'fixes', 'resolves'] followed by the issue number):

## Background
Certain fields written in the CAM snapshot (e.g., `cam_in%cflx`) have a
constituent dimension. Reading such snapshot fields is necessary for
testing vertical diffusion which needs this field.

Presently, the registry is configured to accept the definition of fields
with a `number_of_ccpp_constituents` dimension but the initial value
read infrastructure does not accept it with the error: `cflx already has
an initial_value, using it now. It also cannot be read from file: cflx
has unsupported dimension, number_of_ccpp_constituents.`

This PR enables the reading of 2-D variables with the dimension
`horizontal_dimension number_of_ccpp_constituents` with the ability to
trivially expand it to 3-D fields in the future.

## Details
* Because the CAM snapshot output constituent indices do not match the
indices in the SIMA model, companion PR in CAM
(ESCOMP/CAM#1336) will output `cam_in%cflx` as
`cam_in_cflx_<constituent name>` (i.e., `cam_in_cflx_Q`,
`cam_in_cflx_CLDICE`, ...)
* A new interface `read_constituent_dimensioned_field` will read fields
with a constituent dimension, reading variables one-by-one with a name
constructed from a "base name" (`cam_in_cflx`) + "constituent short
name" (`_Q`, `_CLDICE`, ...)
* Because CAM is not aware of standard names, constituent names are
mapped from standard names to short names (Q, CLDICE, ...) through the
registry.xml initial value definitions.
* Unit tests have been updated

Tested by vertical diffusion work in progress code in SIMA.

Describe any changes made to build system:
* `write_init_files.py` updated infrastructure to allow constituent
dimension input

Describe any changes made to the namelist: N/A

List any changes to the defaults for the input datasets (e.g. boundary
datasets):
* Snapshot format update - see ESCOMP/CAM#1336.
This update is backwards compatible.

List all files eliminated and why: N/A

List all files added and what they do:
```
A       test/unit/python/sample_files/phys_vars_init_check_constituent_dim.F90
A       test/unit/python/sample_files/physics_inputs_constituent_dim.F90
A       test/unit/python/sample_files/physics_types_simple_constituent_dim.F90
A       test/unit/python/sample_files/physics_types_simple_constituent_dim.meta
A       test/unit/python/sample_files/write_init_files/phys_vars_init_check_constituent_dim.F90
A       test/unit/python/sample_files/write_init_files/physics_inputs_constituent_dim.F90
A       test/unit/python/sample_files/write_init_files/simple_reg_constituent_dim.xml
A       test/unit/python/sample_files/write_init_files/temp_adjust_constituent_dim.F90
A       test/unit/python/sample_files/write_init_files/temp_adjust_constituent_dim.meta
  - new unit test (test_simple_constituent_dimensioned_var_write_init) for constituent-dimensioned input variable

A       test/unit/python/sample_files/physics_types_simple_initial_value.F90
A       test/unit/python/sample_files/physics_types_simple_initial_value.meta
  - fix missing files from previously introduced test
```

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
development...<your_branch_name>`)
```

M       src/data/write_init_files.py
  - add checks for number_of_ccpp_constituents as alternate last dimension
  - if number_of_ccpp_constituents is a dimension, call read_constituent_dimensioned_field instead of read_field
  - rearrange location of const_props for use by above feature.

M       src/physics/utils/physics_data.F90
  - add interface read_constituent_dimensioned_field to read variables which have number_of_ccpp_constituents as dimension.

M       test/unit/python/test_write_init_files.py
  - new unit test (test_simple_constituent_dimensioned_var_write_init) for constituent-dimensioned input variable

M       test/unit/python/sample_files/write_init_files/physics_inputs_4D.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_bvd.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_cnst.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_ddt.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_ddt2.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_ddt_array.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_host_var.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_initial_value.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_mf.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_no_horiz.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_noreq.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_param.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_protect.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_scalar.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_simple.F90
  - updated sample files due to rearranging of const_props to top of subroutine.

M       test/unit/python/sample_files/write_init_files/simple_build_cache_template.xml
M       test/unit/python/sample_files/write_init_files/simple_reg.xml
  - fix typo and update hash for build cache template.

M       test/unit/python/sample_files/write_init_files/simple_reg_initial_value.xml
  - fix file name in xml.
  - fix allocatable should be allocatable (not pointer) if array has initial_value.
```

If there are new failures (compared to the
`test/existing-test-failures.txt` file),
have them OK'd by the gatekeeper, note them here, and add them to the
file.
If there are baseline differences, include the test and the reason for
the
diff. What is the nature of the change? Roundoff?

derecho/intel/aux_sima: NLFAIL chemistry_nl - making baseline for #405

derecho/gnu/aux_sima: NLFAIL chemistry_nl - making baseline for #405

If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:

CAM-SIMA date used for the baseline comparison tests if different than
latest:

---------

Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants