Skip to content

Constituent- and index-dimensioned fields for read and check physics data#521

Open
jimmielin wants to merge 5 commits into
ESCOMP:developmentfrom
jimmielin:hplin/snapshot_dimensioned_fields
Open

Constituent- and index-dimensioned fields for read and check physics data#521
jimmielin wants to merge 5 commits into
ESCOMP:developmentfrom
jimmielin:hplin/snapshot_dimensioned_fields

Conversation

@jimmielin

@jimmielin jimmielin commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Tag name (required for release branches):
Originator(s): @jimmielin
AI tools used (if applicable; please also add the "AI-generated code" label to the PR):
What: claude-fable:5, claude-opus:4.8
How: drafted the fix

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

  • Allow reading 3-D fields that are constituent-dimensioned (a natural extension of the 2-D variant already existing)
  • Allow reading 2-D fields that are index-dimensioned (e.g., (ncol, 4)) for dust fluxes from coupler
  • Allow checking 2-D and 3-D fields that are constituent-dimensioned

Describe any changes made to build system: autogen changes

Describe any changes made to the namelist:

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

List all files eliminated and why:

List all files added and what they do:

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
  - now call read_indexed_dimensioned_field
  - now allow 3D constituent dimensioned fields

M       src/physics/utils/physics_data.F90
  - now call read_indexed_dimensioned_field
  - now allow 3D constituent dimensioned fields

M       test/unit/python/sample_files/write_init_files/temp_adjust_constituent_dim.F90
M       test/unit/python/sample_files/write_init_files/temp_adjust_constituent_dim.meta
M       test/unit/python/sample_files/write_init_files/simple_reg_constituent_dim.xml
  - add cool_cat_3d_for_each_const to test 3D feature!

M       test/unit/python/test_write_init_files.py
  - update stale comment
  
M       test/unit/python/sample_files/write_init_files/phys_vars_init_check_constituent_dim.F90
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_constituent_dim.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
  - update test sample files: including const_props going further up to accommodate constituent-dimensioned fields

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:

derecho/gnu/aux_sima:

derecho/nvhpc/aux_sima (test is run via Github workflow. Only run the test manually if we need to save new baselines):

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:

write_init_files already emits the generic read_constituent_dimensioned_field
call with a vertical coordinate for (horizontal, vertical, constituent)
registry variables, but the interface only carried the (horizontal,
constituent) specific, so such a variable generated a call with no matching
specific and could not compile.

Add read_constituent_dimensioned_field_3d as a sibling of the 2-D specific.
Each constituent row is read from its own <base_name>_<constituent> file
variable (e.g. aerochem_vmr_bc_a1); rows with no matching file variable are
left at their initial value, since a capture only writes the species the
source model carries.

Standard names are case-insensitive, so the registry lookup compares them
with to_lower: a constituent declared with authored case (e.g. 'CO2') is
normalized to lowercase by capgen on the scheme side, and a case-sensitive
compare would miss the registry row and silently read nothing.
… fields.

Constituent-dimensioned registry variables were skipped entirely by
physics_check_data, so they were silently absent from the check output.

Add check_constituent_dimensioned_field (the (horizontal, vertical,
constituent) specific) and emit the call for such variables, mirroring the
read_constituent_dimensioned_field path; the registry lookup is
case-insensitive for the same reason. Each constituent row is checked against
its own <base_name>_<constituent> file variable; rows with no matching file
variable are skipped. The (horizontal, constituent) case is not implemented
yet and is still skipped.

const_props is hoisted above the suite loop, since the check calls inside the
loop now need it.

The test registry gains a vertically-resolved constituent-dimensioned variable
(cool_cat_3d_for_each_const) exercising both the read and the check path.
…les.

A (horizontal, fixed-size extra dimension) registry variable cannot be
captured as a single snapshot/history variable, so such fields are written out
as numbered per-slice variables (e.g. <base>1 ... <base>N).

Add read_indexed_dimensioned_field, a sibling of
read_constituent_dimensioned_field keyed by slice index instead of constituent
name, and teach write_init_files to emit it for 2-D variables whose second
dimension is neither vertical nor the constituent dimension. The
ic_file_input_names of such variables are therefore name PREFIXES; the slice
index is appended by the reader. physics_check_data skips these variables
(read-only inputs), mirroring the 2-D constituent skip.

The (horizontal, band_number) variable in the bad-vertical-dimension test is
now a supported shape and generates a read call.
…ical dimension.

physics_check_data skipped registry variables with a constituent dimension but
no vertical dimension, because check_constituent_dimensioned_field only
implemented the vertically-resolved case; constituent surface fluxes
(cam_in%cflx) were therefore silently absent from the check output.

Add the (horizontal, constituent) specific, mirroring the vertically-resolved
one the same way the read_constituent_dimensioned_field pair does, and emit the
check call for such variables. Each constituent row is checked against
<base_name>_<constituent> file variables (e.g. cam_in_cflx_dst_a1); rows
without a matching file variable are skipped, since a capture only writes the
species the source model carries.
The routines added by this branch were written before sima0_16_001 and built a
single '<base>_<cname>' candidate per lookup. netCDF variable names are
case-sensitive, while a constituent not enumerated in the registry derives its
name from its standard name and arrives lowercased from capgen, so an uppercase
snapshot field (e.g. aerochem_vmr_CO2) was never matched:

- read_constituent_dimensioned_field_3d: the field fell back to its default
  silently, the failure mode sima0_16_001 fixed for the 2-D analog.
- check_constituent_dimensioned_field_2d/3d: worse - the row is skipped as
  'not on the check file', so a suite can report b4b without ever having
  compared those constituents.

All lookups now go through constituent_dim_file_var_names. file_var_name is
dropped from the two check routines, which report under found_name and so had
no remaining use for it; the read routines still build it for reporting.

read_indexed_dimensioned_field is unaffected: it names slices by integer index.
@jimmielin
jimmielin force-pushed the hplin/snapshot_dimensioned_fields branch from 832125a to 6012e9e Compare July 22, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated code enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant