Skip to content

New med_enthalpy_mod, plus a multi-instance fix for the branch-run pointer check - #716

Merged
billsacks merged 3 commits into
ESCOMP:mainfrom
mvertens:feature/escomp_enthalpy_module
Oct 23, 2026
Merged

billsacks merged 3 commits into
ESCOMP:mainfrom
mvertens:feature/escomp_enthalpy_module

Conversation

@mvertens

Copy link
Copy Markdown
Collaborator

This PR creates a new med_enthalpy_mod, plus a multi-instance fix for the branch-run pointer check.

1. Move enthalpy flux calculations into a new med_enthalpy_mod

The enthalpy flux code was split across med_phases_prep_ocn_mod and med_phases_prep_atm_mod, with shared state duplicated between them. This collects it into a single new module, med_enthalpy_mod.

What was wrong

  • component_computes_enthalpy_flux existed as two independent module variables, one in each prep module, each populated by its own NUOPC_CompAttributeGet call.
  • global_htot_corr and global_hrof_corr lived in med_phases_prep_atm_mod but were computed by routines invoked from med_phases_prep_ocn_mod.
  • Consequently med_phases_prep_ocn_mod had to use med_phases_prep_atm_mod from inside two of its subroutines, giving prep_ocn a dependency on prep_atm purely for enthalpy.

What this does

  • Adds mediator/med_enthalpy_mod.F90 holding all five enthalpy routines and one copy of each shared variable.
  • Drops the prep_ocn -> prep_atm dependency.
  • Adds med_enthalpy_init, which performs the attribute read that was previously duplicated in both prep modules. Called from med_phases_prep_ocn_init and med_phases_prep_atm.

The module is not named med_phases_* because it contains no NUOPC run phases; it follows the med_io_mod / med_methods_mod convention instead.

Interface change

med_phases_prep_atm_mod no longer exports:

  • med_phases_prep_atm_enthalpy_correction
  • med_phases_prep_atm_enthalpy_runoff

These become med_enthalpy_correction and med_enthalpy_runoff in med_enthalpy_mod, alongside med_enthalpy_init, med_enthalpy_med_computation and med_enthalpy_atm_computation. The module
also makes component_computes_enthalpy_flux, global_htot_corr and global_hrof_corr public, as they are now shared rather than private to prep_atm.


2. Fix the branch-run DRV_RESTART_POINTER check for multi-instance cases

The check in cime_config/buildnml constructed the expected pointer name as

"rpointer.cpl.{}-{}".format(RUN_REFDATE, RUN_REFTOD)

Testing

This exact code was tested in noresm using the prealpha test suite and all tests passed and were bit-for-bit

<fill in: which test suite, which machine/compiler, bit-for-bit vs. baseline>

🤖 Generated in collaboration with Claude Code

@mvertens
mvertens requested a review from billsacks October 21, 2026 15:33

@billsacks billsacks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving based on a cursory look at the enthalpy changes and a somewhat more careful look at the buildnml changes for multi-instance branch cases.

@billsacks

Copy link
Copy Markdown
Member

@mvertens - I'm approving this but, given the conservative period we're in with the run-up to the CESM release, I want to get feedback from a few other people about what testing we want to do here before merging.

@billsacks
billsacks merged commit ecc71ef into ESCOMP:main Oct 23, 2026
1 check passed
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