Skip to content

Allow diag_table changes via user_nl_mom, and fix user_nl_mom/MOM_override bugs - #353

Open
alperaltuntas wants to merge 12 commits into
mainfrom
rps_enhancements
Open

alperaltuntas wants to merge 12 commits into
mainfrom
rps_enhancements

Conversation

@alperaltuntas

Copy link
Copy Markdown
Member

Allow changing the diag_table via user_nl_mom, and fix several bugs in how user_nl_mom is read and turned into MOM_override.

diag_table changes are given as diag_table%<stream>%<key> <operator> <value>, e.g.:

    diag_table%h.native%fields += MLD_0125, Kd_heat:Kd_heat_max:max
    diag_table%h.native%fields -= KE
    diag_table%h.sfc%output_freq = 5
    diag_table%h.z%fields = none
    diag_table%h.mine%module = ocean_model_z
    diag_table%h.mine%fields = thetao, so
  • Changes are applied when diag_table.unresolved is generated, so both the unresolved and resolved diag_tables include them.
  • Settings act as if given in the template entry, so derived settings follow (e.g., daily output also starts daily files unless new_file_freq_units is set).
  • Errors out on a missing stream or field, on an added stream without fields, and when combined with a diag_table (or diag_table.unresolved) in SourceMods. All instances in a multi-instance run must have the same diag_table lines.
  • Documented in the user_nl_mom template.

user_nl_mom and MOM_override:

  • Accept full-path parameters, e.g., KPP%N_SMOOTH = 2.
  • Error out when a parameter is set outside the block where MOM_input has it, which MOM6 silently ignores.
  • Validate block structure (mismatched or extra closes, nested blocks, empty names) and recognize comments as MOM6 does (!, //, /* */).
  • Strip whitespace left by inline comments, which produced #override instead of (UNCHANGED).
  • Fix the TypeError on duplicate parameters (supersedes Fix _read_mom input err msg #350).
  • Write MOM_override in one place, with one header.

Other fixes:

  • Templates see MOM6 parameter values as MOM6 reads them: quoted strings no longer crash diag_table generation (e.g., WAVE_METHOD = "SURFACE_BANDS"), and T/.true. are recognized (USE_MARBL_TRACERS = T used to skip marbl_in).
  • input.nml: skip variables whose guards are all false instead of writing None.
  • The parser moved to a CIME-free param_file_reader.py, and tests/doctests.py runs again.

No answer changes for existing configurations.

Testing: ran buildnml for ~1140 variants (12 compsets/grids including MARBL, WW3 and B; all OCN_DIAG_MODE/TEST/sections combinations; run types; multi-instance; SourceMods; testmods; user_nl_mom edge cases) and compared the generated input files against main: they differ only where intended. aux_mom is currently being run.

Co-authored by claude.

@manishvenu

Copy link
Copy Markdown
Collaborator

@AidanJanney, this PR might be of interest to you!

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.

2 participants