Skip to content

implement hist_empty_htapes for mosart #8414

@mahf708

Description

@mahf708

Task: Add an rtmhist_empty_htapes namelist option to MOSART

Goal: Add a namelist flag to MOSART (the river-routing component, components/mosart/) that suppresses the
default history fields, exactly mirroring ELM's existing hist_empty_htapes option. When set to .true., no
history field is added to a tape unless explicitly requested via rtmhist_fincl[1-3]. This lets users
disable MOSART history output entirely (by setting rtmhist_empty_htapes = .true. with no fincl), the same
way hist_empty_htapes = .true. works for ELM.

Background / why: MOSART currently has no equivalent to ELM's hist_empty_htapes. Its history code
(RtmHistFile.F90) is a near-verbatim copy of ELM's histFileMod.F90, so this is essentially porting one line
plus the namelist plumbing. The reference implementation in ELM is at
components/elm/src/main/histFileMod.F90:707 (else if (.not. hist_empty_htapes) then) and its plumbing in
components/elm/src/main/controlMod.F90 (declaration, namelist read, mpi_bcast). Use ELM as the template for
naming and style.

Exact changes required (all in components/mosart/):

  1. src/riverroute/RtmHistFile.F90 — declare the module variable near the other rtmhist_* public namelist
    vars (around lines 44–60, e.g. next to rtmhist_fincl1):
    logical, public :: rtmhist_empty_htapes = .false. ! namelist: flag indicates no default history fields
  2. src/riverroute/RtmHistFile.F90:371 — in subroutine htapes_fieldlist, the masterlist loop currently
    reads:
    else
    ! find index of field in exclude list
    call list_index (fexcl(1,t), mastername, ff)
  3. Change the bare else to:
    else if (.not. rtmhist_empty_htapes) then
  4. (This matches ELM histFileMod.F90:707.)
  5. src/riverroute/RtmMod.F90 — three small additions in the namelist-reading routine:
    - Add rtmhist_empty_htapes to the use RtmHistFile, only: ... import list (around lines 30–32).
    - Add rtmhist_empty_htapes to the namelist /mosart_inparm/ declaration (around lines 271–274).
    - Add an mpi_bcast for it alongside the other rtmhist_* broadcasts (around lines 403–414):
    call mpi_bcast (rtmhist_empty_htapes, 1, MPI_LOGICAL, 0, mpicom_rof, ier)
  6. bld/namelist_files/namelist_definition_mosart.xml — add an entry near the other rtmhist_* entries (lines
    248–335) so the option validates:

    If TRUE, indicates do not output any default history fields. Only fields
    explicitly requested via rtmhist_fincl[1-3] will be written. Mirrors ELM's
    hist_empty_htapes.
5. build-namelist — no change required. rtmhist_fincl1/rtmhist_fexcl1 already flow through user_nl_mosart without an explicit add_default call in bld/build-namelist, so the new entry behaves the same; the Fortran default .false. covers the unset case. (Optional: add .false. to bld/namelist_files/namelist_defaults_mosart.xml for explicitness, but it is not necessary.)

Important correctness note to verify: With rtmhist_empty_htapes = .true. and no fincl, tape 1 ends up with
nflds == 0. In RtmHistFile.F90:418-424, ntapes is computed by scanning from max_tapes down for the first
tape with nflds > 0, so it resolves to 0. The "no empty tapes / no holes" abort loop at RtmHistFile.F90:429
is do t = 1, ntapes, which then no-ops (does not abort). All downstream history loops are also do t = 1,
ntapes, so they no-op. This is the same path ELM relies on when hist_empty_htapes = .true.. Confirm by
reading the history-write and restart-write paths in RtmHistFile.F90 that nothing assumes ntapes >= 1.

Constraints:

  • Match existing code style/indentation in each file. Do not reformat surrounding code.
  • Do not rename or alter the existing rtmhist_* options.
  • Keep the default .false. so existing behavior is unchanged when the option is not set.

Validation:

  • Confirm it compiles (build a case that includes MOSART, e.g. a WCYCL compset).
  • Functional check: in a test case's user_nl_mosart, set rtmhist_empty_htapes = .true. and confirm MOSART
    writes no .mosart.h.nc history files (only restart files), while the run completes normally. Also confirm
    that setting it .true. together with an explicit rtmhist_fincl1 = 'RIVER_DISCHARGE_OVER_LAND_LIQ' produces
    a tape with only that one field.
  • Run an ERS test on a MOSART-active compset to confirm restart behavior is unaffected (MOSART writes its
    own restart/history, so this exercises the ntapes == 0 path across a restart).

Deliverable: Report the diff of all files changed, and the result of the compile + functional checks.

Metadata

Metadata

Assignees

Labels

MOSARTConcerning the MOSART river model
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions