Skip to content

EAMxx: replace named initial-condition fields with constant_fields/copy_fields arrays - #8807

Draft
bartgol wants to merge 5 commits into
masterfrom
claude/kind-galileo-g9kd5k
Draft

bartgol wants to merge 5 commits into
masterfrom
claude/kind-galileo-g9kd5k

Conversation

@bartgol

@bartgol bartgol commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Replace per-field entries in the EAMxx initial_conditions list with two arrays, constant_fields and copy_fields. Entries can be added or removed with atmchange.


Motivation

Constant initialization of a field needed an individual entry in namelist_defaults_eamxx.xml (e.g. <sfc_alb_dif_vis>0.0</sfc_alb_dif_vis>). Individual params cannot be removed with atmchange, but array entries can.

Design

This is a breaking change. Named fields are no longer supported in initial_conditions. Any testmod or user script doing atmchange initial_conditions::qr=... must switch to the array syntax. The driver now errors on any unrecognized parameter in the list, so stale inputs fail loudly instead of being silently ignored.

  • constant_fields is an array(string) of entries name:value.
    • For vector fields, name:v1;v2;...;vN sets component i to vi. A single value is broadcast to all components.
    • ; is used for the components because , is the array separator. From the shell the argument must be quoted: ./atmchange initial_conditions::constant_fields+="dgnum:1e-7;2e-8;3e-7;4e-8".
  • copy_fields is an array(string) of entries tgt:src. It replaces the old tgt: src string entries. That feature is only used by ad_tests.yaml, but it also needed a home once named entries were removed.
  • Entries matching no field needing init are ignored, as before. A field listed twice, or in both arrays, is an error.
  • Valid initial_conditions parameters are now: filename, topography_filename, constant_fields, copy_fields, perturbed_fields, and the perturbation_* / generate_perturbation_random_seed options.
./atmchange initial_conditions::constant_fields-=tke:0.0
./atmchange initial_conditions::constant_fields+=my_field:1.5

Changes

  • AtmosphereDriver::set_initial_conditions: parse and validate the two arrays. initialize_constant_field now takes std::vector<double>.
  • namelist_defaults_eamxx.xml:
    • The base constant_fields holds all 61 scalar entries plus the vector ones (dgnum, dgnumwet, wetdens).
    • The hgrid/compset-dependent entries (qc, qi, nc, ni, o3_volume_mix_ratio, phis for aquaplanet) are appended via append="last".
    • An empty copy_fields default is added so it can be edited with atmchange.
  • Migrated all 38 hand-written test YAMLs that used named entries. A script checked that every old entry maps to exactly one new entry with the same value (0 mismatches). Descriptive inline unit comments on the wetdep_*/drydep_* entries were dropped.
  • Docs: model_configuration.md and testing_for_development.md.

Testing

The full EAMxx build and tests have not been run, so please run CI, in particular the EAMxx standalone and v1 tests. What I did check:

  • The entry parsing and validation code, extracted into a standalone program, compiles against the real EKAT ParameterList. It gives the expected values, and each error case (unknown param, bad or empty value, duplicate, in both arrays) errors as intended.
  • The real evaluate_selectors on the defaults XML resolves constant_fields correctly for ne4, ne32, ne1024, aquaplanet and conus: 64 base entries, plus 4 / 2 / 1 / 1 conditional entries.
  • atmchange -= and += work on the new arrays.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lk8pmRsy19mr1ZkXWBgV2v

Allow constant initialization of fields via an array of "name:value"
strings, instead of requiring one XML entry per field. Since atmchange
cannot remove individual params but can remove array entries, this lets
users drop a default constant init (or add a new one) without touching
the defaults file.

- AtmosphereDriver::set_initial_conditions parses constant_fields and
  treats each entry like an individual constant IC entry (errors on
  malformed entries, or on duplicates with an individual entry).
- Migrate the scalar, unconditional constant entries in
  namelist_defaults_eamxx.xml to the new array. Vector-valued and
  grid/compset-conditional entries stay as individual entries.
- Exercise the new option in a dynamics_physics test input, and document.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lk8pmRsy19mr1ZkXWBgV2v
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://E3SM-Project.github.io/E3SM/pr-preview/pr-8807/

Built to branch gh-pages at 2026-09-30 23:03 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@bartgol
bartgol requested a review from tcclevenger September 30, 2026 22:32
@bartgol bartgol self-assigned this Sep 30, 2026
@bartgol bartgol added BFB PR leaves answers BFB EAM Fortran-based E3SM Atmosphere Model labels Sep 30, 2026
…ields

Fields can no longer be initialized via individual entries of the
initial_conditions list (they could not be removed with atmchange, and
required a new defaults-XML entry each). Instead:

- constant_fields: array of "name:value" entries; vector fields accept
  "name:v1;v2;...;vN".
- copy_fields: array of "tgt:src" entries (replaces 'tgt: src' strings).
- Any other unrecognized parameter in initial_conditions is now an error.

Defaults XML: all constant entries (including vector ones, dgnum etc.)
now live in constant_fields; grid/compset-dependent ones are appended
via append="last". All hand-written test yamls were migrated (0 semantic
differences), and docs updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lk8pmRsy19mr1ZkXWBgV2v
@bartgol bartgol changed the title Add constant_fields array for constant initialization of EAMxx fields Replace named initial-condition fields with constant_fields/copy_fields arrays in EAMxx Sep 30, 2026
@bartgol bartgol changed the title Replace named initial-condition fields with constant_fields/copy_fields arrays in EAMxx EAMxx: replace named initial-condition fields with constant_fields/copy_fields arrays Sep 30, 2026
bartgol and others added 3 commits September 30, 2026 22:42
- Migrate test yaml entries my first pass missed (keys written as
  'name : value', e.g. pbl_height, phis), merging them into the
  existing constant_fields arrays.
- Integer fields (e.g. sunlit_mask) must be initialized from an int:
  deep_copy of a double is a narrowing conversion and errors out.
  initialize_constant_field now converts integral values for IntType
  fields, and errors on non-integral ones.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lk8pmRsy19mr1ZkXWBgV2v
test_atmchanges_on_arrays relied on the dgnum param, which is now an
entry of initial_conditions::constant_fields. Exercise atmchange on
that array instead (including a vector-valued entry).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lk8pmRsy19mr1ZkXWBgV2v

z_mam4_int : 0.0
constant_fields:
- "pbl_height:0.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this may be confusing to people (due to the quotes) but I think we may be able to avoid it altogether, yaml will still parse them correctly like above as a nested list, but you will need to come up with a better type than type="array(string)" in the xml

bartgol commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

CI status on ac868cd4, for reviewers:

  • gnu / ERS_Ln22…small_kernels--eamxx-output-preset-5 reports NLFAIL (but otherwise OK). The model built and ran, and the failure is the namelist comparison against the master baseline (create_test -c -b master). This is expected for this PR, because it intentionally changes the generated initial_conditions section of scream_input.yaml, so the namelist baselines will need refreshing once it merges. Other model tests in this run should show the same NLFAIL.
  • intel / ERS.ne4pg2_ne4pg2.F2010-SCREAMv1.eamxx-prod reports a plain FAIL (phase RUN). I could not read its TestStatus, because the log artifact is on a host blocked by my sandbox's egress policy. The same test also failed in the run for the unrelated PR New L128 Vertical Grid for v4 #8692 (L128 grid), but I have not confirmed that it fails for the same reason. I could not re-run it, since the workflow run is still in progress. If someone with access can share the TestStatus.log or the atm log for that job, I'll dig in.
  • Passing: linter, docs build, the gnu script and nml tests, and intel-openmp / opt.

Generated by Claude Code

This branch has not been deployed

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

Labels

BFB PR leaves answers BFB EAM Fortran-based E3SM Atmosphere Model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants