Skip to content

Add more infrastructure for water tracers#82

Merged
billsacks merged 18 commits into
ESCOMP:mainfrom
billsacks:water_tracers_part2
May 14, 2026
Merged

Add more infrastructure for water tracers#82
billsacks merged 18 commits into
ESCOMP:mainfrom
billsacks:water_tracers_part2

Conversation

@billsacks
Copy link
Copy Markdown
Member

@billsacks billsacks commented Mar 3, 2026

Add more infrastructure for water tracers, needed by CMEPS.

The biggest addition here is a routine to check tracer ratios against expectations, with associated unit tests.

There are also a few other small additions to shr_wtracers_mod as well as some other additions needed for the unit test build.

Testing done: In the context of cesm3_0_alpha08o, with this branch along with ESCOMP/CMEPS#638, ran CESM prealpha tests on derecho and izumi, and aux_glc tests on derecho, all with baseline comparisons. All failures also failed in the baseline except for SMS_D_Ln9_P1536x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FHIST.derecho_intel.cam-outfrq9s (which seemed to fail due to ESCOMP/CTSM#3772, which is a sporadic issue), and all baseline comparisons passed. (Note: full testing was done before final commits addressing review points; only minimal additional testing was done after those final commits.)

Since this is just used for unit testing, this is a reasonable setting.
This reverts commit 6132245.

This needs to be reverted because I reverted
b441fa6.
The main motivation for this is that we can then avoid a dependency on
shr_string_withoutSuffix in CMEPS by wrapping / stubbing this new
shr_wtracers subroutine.

But this also has the benefit of making the intent more clear for
callers of this (as compared with directly calling
shr_string_withoutSuffix).
Written by Claude Code, reviewed by myself.
Since the naming convention is to have "_wtracers" last, we're also
changing the dimension ordering convention to be consistent with that.
@billsacks billsacks requested a review from nusbaume March 3, 2026 19:41
@billsacks
Copy link
Copy Markdown
Member Author

I think this is basically ready, but I still want to do some more extensive testing, so marking this as a draft.

Comment thread src/water_isotopes/shr_wtracers_mod.F90
By changing a division to a multiplication we can remove the pre-check
for values being 0.

Thanks to Keith Lindsay for the suggestion.
@billsacks billsacks moved this from New to In Progress in Water Isotopes Mar 10, 2026
@billsacks billsacks marked this pull request as ready for review April 17, 2026 17:09
@billsacks
Copy link
Copy Markdown
Member Author

I'm finally(!) returning to this. I have run some testing (noted in my edited top-level comment above) and have looked over the changes once more myself. @nusbaume this is finally ready for your review whenever you get a chance.

Written by Claude, reviewed by myself.
Copy link
Copy Markdown
Contributor

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Thanks for the new routine and tests @billsacks! I have some questions and change requests, but of course please let me know if you disagree with any of them.

Comment thread src/water_isotopes/shr_wtracers_mod.F90
Comment thread src/water_isotopes/shr_wtracers_mod.F90
Comment thread src/water_isotopes/shr_wtracers_mod.F90
Comment thread src/water_isotopes/shr_wtracers_mod.F90
Comment thread src/water_isotopes/shr_wtracers_mod.F90
Comment thread test/unit/shr_wtracers_test/test_shr_wtracers.pf
Comment thread test/unit/shr_wtracers_test/test_shr_wtracers.pf Outdated
Comment thread test/unit/shr_wtracers_test/test_shr_wtracers.pf
@billsacks
Copy link
Copy Markdown
Member Author

@nusbaume - thank you very much for your review, and I'm sorry for my slow reply!

To summarize my response to your comments:

I'll at least make one change you requested: adding more information in shr_sys_abort messages.

There are three changes that you asked about for which I have explained my rationale but am happy to change if you would still prefer to see changes after reading my rationale:

  • Changing to use a protected variable rather than a function for the water_tracers_initialized check
  • Removing the do-nothing setUp in the pFUnit file
  • Using an only clause on the use statement for the module under test (and possibly funit?)

Let me know your thoughts on these. Also happy to discuss in person or on a call if you'd like.

Copy link
Copy Markdown
Contributor

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Thanks for responding to my questions and suggestions @billsacks! Everything looks good to me now.

@billsacks billsacks merged commit f210ab4 into ESCOMP:main May 14, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Water Isotopes May 14, 2026
@billsacks billsacks deleted the water_tracers_part2 branch May 14, 2026 21:46
billsacks added a commit to ESCOMP/CMEPS that referenced this pull request May 15, 2026
Add water tracers

### Description of changes

Core changes needed to add water tracers in CESM, for the sake of water isotopes and other purposes.

Major pieces of this include:
- XML and config variables for defining water tracers
- Addition of all necessary water tracers in esmFldsExchange_cesm_mod and fd_cesm.yaml. These use an ungridded dimension for water tracers.
- Calls to a routine to check that test tracers maintain their initial ratios. This ensures that tracers are being treated the same as their bulk counterparts (in terms of mapping, merging, etc.). 
- Addition of water tracer fields in med_test_comps, so this tracer infrastructure can be verified in an X compset test
- Various other changes to some of the med_test_comps to better exercise CMEPS functionality, especially for the lnd -> glc mapping; also added some fields from GLC and to ROF in med_test_comps: Fgrg_rofi and Fgrg_rofl

Some pieces are not yet implemented:
- Including water tracers in the custom lnd->rof mapping
- Including water tracers/isotopes in atm-ocn flux calculations
- Including water tracers in the budget tables (med_diag_mod)

Depends on ESCOMP/CESM_share#82

### Specific notes

Contributors other than yourself, if any:

CMEPS Issues Fixed (include github issue #):
- Resolves #583 (though this turned out to be much more extensive than simply reviewing and updating what had been in place before)
- Resolves #601 

Are changes expected to change answers? (specify if bfb, different at roundoff, more substantial) Changes answers for X compsets (due to some changed counter logic and maybe other things); should be bit-for-bit for all other compsets

Any User Interface Changes (namelist or namelist defaults changes)? Adds xml and config variables controlling water tracers

### Testing performed
In the context of cesm3_0_alpha08o, with this branch along with ESCOMP/CESM_share#82, ran CESM prealpha tests on derecho and izumi, and aux_glc tests on derecho, all with baseline comparisons. All failures also failed in the baseline except for `SMS_D_Ln9_P1536x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FHIST.derecho_intel.cam-outfrq9s` (which seemed to fail due to ESCOMP/CTSM#3772, which is a sporadic issue), and all baseline comparisons passed. (Note: full testing was done before final commits addressing review points; only minimal additional testing was done after those final commits.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants