Skip to content

Changes to CPLHIST mode for robustness and getting the right default settings for CLM and an updated 1850 ndep file - #403

Open
ekluzek wants to merge 30 commits into
ESCOMP:mainfrom
ekluzek:1850_aero_ndep_ozone
Open

Changes to CPLHIST mode for robustness and getting the right default settings for CLM and an updated 1850 ndep file#403
ekluzek wants to merge 30 commits into
ESCOMP:mainfrom
ekluzek:1850_aero_ndep_ozone

Conversation

@ekluzek

@ekluzek ekluzek commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Description of changes

Work with 1850_clim settings for ndep. As well as some work with CPLHIST options.

Specific notes

Contributors other than yourself, if any: @billsacks

CDEPS Issues Fixed (include github issue #):

Are there dependencies on other component PRs (if so list):

Are changes expected to change answers (bfb, different to roundoff, more substantial): No
This will add some new options, but won't change defaults (which primarily need to be changed in compsets anyway)

Any User Interface Changes (namelist or namelist defaults changes): Yes

Testing performed (e.g. aux_cdeps, CESM prealpha, etc): Have tested a few cases will test aux_cdeps against cesm3_0_beta08 tests

Hashes used for testing:

Definition of done:

  • Finish work on all of the modes
  • Add needed aux_cdeps tests
  • Test against the aux_cdeps cesm3_0_beta09 baseline and make sure identical
  • Test in the context of CTSM and make sure it does everything needed

@ekluzek ekluzek added enhancement New feature or request CESM Only labels Apr 15, 2026
@ekluzek ekluzek added answers are bfb Responsibility: CTSM Responsibility to manage and accomplish this issue is the CTSM Software group labels Apr 15, 2026
@wwieder

wwieder commented May 20, 2026

Copy link
Copy Markdown
Contributor

It's not clear to me if the intent of this PR + #405 are needed for:

  1. CLM to be able to use CPL_HIST output (and therefore lower priority for an alpha tag); or
  2. CESM to write out CPL_HIST files that we'll use for spinup (and therefore a higher priority)?

@billsacks

Copy link
Copy Markdown
Member

It's not clear to me if the intent of this PR + #405 are needed for:

  1. CLM to be able to use CPL_HIST output (and therefore lower priority for an alpha tag); or
  2. CESM to write out CPL_HIST files that we'll use for spinup (and therefore a higher priority)?

It's (1) - to be able to use CPLHIST output.

@wwieder

wwieder commented May 21, 2026

Copy link
Copy Markdown
Contributor

OK, if this is only needed for CTSM to read CPL_HIST data my read is that this PR isn't critical for the next alpha09 tag. What do others think?

@ekluzek ekluzek changed the title 1850 aero ndep ozone 1850 CPLHIST aero ndep ozone Jul 14, 2026
Comment thread datm/cime_config/config_component.xml
@ekluzek ekluzek changed the title 1850 CPLHIST aero ndep ozone 1850 CPLHIST ndep Aug 18, 2026
@ekluzek

ekluzek commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@fischer-ncar I didn't find aux_cdeps baselines for either cesm3_0_alpha09g or cesm3_0_beta09. So I'm going to make my own baseline with the previous CDEPS tag.cd .

@ekluzek

ekluzek commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

The aux_cdeps testlist all passed just now. But, I need to make a new baseline to compare it to the previous version.

@ekluzek

ekluzek commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

I ran aux_cdeps and it passes. And everything is identical to the new baseline I made otehr than the cplhist tests.

 ../../CIME/Tools/compare_test_results -b cesm3_0_alpha09g.cdeps1.0.105 --baseline-root $CPL_BASELINE/ -r . | & grep FAIL
FAIL ERS_Ld5.f10_f10_mt232.1850_DATM%CRUJRA2024b_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.derecho_intel.datm-cplhist_create NLCOMP See ./ERS_Ld5.f10_f10_mt232.1850_DATM%CRUJRA2024b_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.derecho_intel.datm-cplhist_create.GC.cesm3A9gcdeps115cplhistaacd/compare.log.cesm3_0_alpha09g.cdeps1.0.105.20260821_145458
FAIL SMS_Ld5.f10_f10_mt232.1850_DATM%CPLHIST_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.derecho_intel.datm-cplhist NLCOMP See ./SMS_Ld5.f10_f10_mt232.1850_DATM%CPLHIST_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.derecho_intel.datm-cplhist.GC.cesm3A9gcdeps115cplhistaacd/compare.log.cesm3_0_alpha09g.cdeps1.0.105.20260821_145458
FAIL SMS_Ld5.f10_f10_mt232.1850_DATM%CPLHIST_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.derecho_intel.datm-cplhist BASELINE DIFF

The first case cplhist_create is just different in NLCOMP because it was done postrun. So it's actually identical.

The second case shows differences due to NDEP, and using CPRNC by hand I see this...

cases/SMS_Ld5.f10_f10_mt232.1850_DATM%CPLHIST_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.derecho_intel.datm-cplhist.GC.cesm3A9gcdeps115cplhistaacd> grep RMS cprnc.out 
 RMS atmImp_Faxa_ndep1                1.4839E-12            NORMALIZED  4.2846E+00
 RMS atmImp_Faxa_ndep2                2.7585E-12            NORMALIZED  9.0720E+00
tail -13 cprnc.out
SUMMARY of cprnc:
 A total number of     51 fields were compared
          of which      2 had non-zero differences
               and      0 had differences in fill patterns
               and      0 had different dimension sizes
               and      0 had different data types
 A total number of      0 fields could not be analyzed
 A total number of      0 time-varying fields on file 1 were not found on file 2.
 A total number of      0 time-constant fields on file 1 were not found on file 2.
 A total number of      0 time-varying fields on file 2 were not found on file 1.
 A total number of      0 time-constant fields on file 2 were not found on file 1.
  diff_test: the two files seem to be DIFFERENT 

so this is as expected.

@ekluzek

ekluzek commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Note, the new baseline I created was identical to cesm3_0_alpha09f baselines with the exception of the scam test which I assume must be expected.

@ekluzek ekluzek left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Some notes on things I figured out.

Comment thread datm/cime_config/testdefs/testmods_dirs/datm/cplhist/shell_commands Outdated
Comment thread datm/cime_config/config_component.xml Outdated
Comment thread datm/cime_config/config_component.xml
@ekluzek
ekluzek marked this pull request as ready for review August 22, 2026 00:43
@ekluzek

ekluzek commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

I think I have everything in place now, so opening up for review. I'm going to redo the testing. And I'll have some peeps review it as well, before asking for merge.

Comment thread datm/cime_config/config_component.xml Outdated
Comment thread datm/cime_config/testdefs/testmods_dirs/datm/cplhist/shell_commands Outdated

@slevis-lmwg slevis-lmwg left a comment

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.

@ekluzek and I went over this in detail, and I'm approving.
@ekluzek posted some notes.

…IST and CLM, add a note that this needs to be coordinated with the CTSM and MOM env variables
@billsacks
billsacks requested a review from mvertens August 25, 2026 16:12
@billsacks

Copy link
Copy Markdown
Member

@mvertens - I'm adding you as a reviewer mainly to look at whether this will impact anything in NorESM that you want to comment on.

@ekluzek

ekluzek commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

OK, I did the things from the code review from @slevis-lmwg. I'm going to redo testing, and verifty things are expected, and then I'd like to merge it, so I can have a tag for CTSM.

@ekluzek ekluzek changed the title 1850 CPLHIST ndep Changes to CPLHIST mode for robustness and getting the right default settings for CLM and an updated 1850 ndep file Aug 25, 2026
@ekluzek

ekluzek commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

OK, I am sending testing for aux_clm and aux_cdeps and will want to merge once that testing is complete.

@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.

I have a lot of specific comments here, but by and large I really appreciate all of the work you've done to both get cplhist mode working and also to do some cleanup and add some error checking to the datm buildnml! Thank you!!

Comment on lines +5317 to +5318
<var>atmImp_Faxa_ndep1 Faxa_ndep_nhx</var>
<var>atmImp_Faxa_ndep2 Faxa_ndep_noy</var>

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.

I want to confirm this: It looks like the previous version of this was set up for cpl7-based cplhist, so I see the need for this change. It looks like this triggers the cmip6 (as opposed to use_cmip7_ndep) block in the Fortran. It looks like this leads to the following block in datm_pres_ndep_advance:

       ! convert ndep flux to units of kgN/m2/s (input is in gN/m2/s)
       Faxa_ndep(1,:) = strm_Faxa_ndep_nhx(:) / 1000._r8
       Faxa_ndep(2,:) = strm_Faxa_ndep_noy(:) / 1000._r8

Does that look correct - in particular this unit conversion? If not, we'll have to disambiguate these cases.

Comment on lines +4938 to +4944
<!-- Alturnative form to use:
the following stream fields are in units of kg/m2/sec - so need no unit conversion
<var>dry_deposition_NHx_as_N Faxa_ndep_nhx_dry</var>
<var>wet_deposition_NHx_as_N Faxa_ndep_nhx_wet</var>
<var>dry_deposition_NOy_as_N Faxa_ndep_noy_dry</var>
<var>wet_deposition_NOy_as_N Faxa_ndep_noy_wet</var>
-->

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.

It's not clear to me why you have this commented-out alternative block. Is this needed for some files? Can you either clarify in the comment why you might want to switch to this or else just remove it?

Also, spelling error: Alturnative -> Alternative.

Comment thread datm/cime_config/testdefs/testmods_dirs/datm/cplhist/shell_commands Outdated
<file>env_run.xml</file>
<desc>DATM CO2 time series</desc>
<desc>DATM CO2 time series
NOTE: This needs to be coordinated with CCSM_BGC in CMEPS, and wtih either the ocean or land model

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.

Typo: wtih -> with

<value compset="^OMIP_DATM%IAF.*_POP2%[^_]*ECO">omip.iaf</value>
<value compset="^OMIP_DATM%JRA.*_POP2%[^_]*ECO">omip.jra</value>
<value compset="_DATM%CPLHIST">cplhist</value>
<value compset="_DATM%CPLHIST_CLM">cplhist</value>

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.

What is the rationale for this change - i.e., only setting cplhist mode for compsets with CLM?

If this is kept, the regex should be changed to "_DATM%CPLHIST.*_CLM"

Comment thread datm/cime_config/buildnml
# Check that if either PTS_LON/PTS_LAT is set the other is as well
# TODO: NOTE: This should really be in CMEPS
if (scol_lon != missing and scol_lat == missing) or (scol_lon == missing and scol_lat != missing):
expect(False, "If either PTS_LON or PTS_LAT is set, the other must be set as well")

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.

This expect is helpful - thanks! - since it checks consistency of user inputs.

Comment thread datm/cime_config/buildnml
expect(False, "If either PTS_LON or PTS_LAT is set, the other must be set as well")

# Verify that the expected output setting was actually done
expect(config['single_column'] is not None, "single_column should have been set in this subroutine")

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.

It might feel kind of arbitrary, but I also feel like this expect is helpful. It's hard for me to explain my thinking on this one vs. the other ones in _handle_model_grid. Maybe the difference is that this is a single, simple expect that feels like it's doing a bigger job, and also less likely to need changes if you change the production code, partly because the expect is unconditional, so you don't need to replicate logic from earlier in the routine in order to do this expect? But I do acknowledge that this all feels subjective, so I'm open to disagreements with my feelings on where there should / shouldn't be expects.

However: looking at the above logic, it looks like config['single_column'] isn't set if case.get_value('PTS_DOMAINFILE') gives None or an empty string. So maybe you need to add to the logic to make this expect always pass?

Comment thread datm/cime_config/buildnml
Comment on lines +224 to +225
expect(cplhist_case is not None, "DATM_CPLHIST_CASE must be set when using cplhist mode")
expect(cplhist_case != "UNSET", "DATM_CPLHIST_CASE must be set when using cplhist mode")

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.

Minor nitpick: I would rewrite these two separate expect statements into a single expect statement based on cplhist_case is not None and cplhist_case != "UNSET": I find it clearer when reading the code to have a single expect on a variable when possible. (I read the first expect and was initially confused about why you were checking against None rather than UNSET... then realized that you had two expects for this variable.)

I do appreciate the expects ensuring that these various DATM_CPLHIST variables are set when they should be!!

Comment thread datm/cime_config/buildnml
expect(cplhist_case is not None, "DATM_CPLHIST_CASE must be set when using cplhist mode")
expect(cplhist_case != "UNSET", "DATM_CPLHIST_CASE must be set when using cplhist mode")
expect(cplhist_dir is not None, "DATM_CPLHIST_DIR must be set when using cplhist mode")
expect(os.path.isdir(cplhist_dir), "DATM_CPLHIST_DIR {} does not exist".format(cplhist_dir))

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.

Tied in with my comment elsewhere about preferring a default value of UNSET for DATM_CPLHIST_DIR: that would make this error check more straightforward (you could just check to make sure that it isn't still UNSET).

I don't love the check of os.path.isdir here: I appreciate the intent, but it feels too early in the process to check this: I could imagine someone setting up a case and running preview_namelists before setting up the directory structure that actually contains the cplhist forcings. It may be unlikely, but it seems like that should be an acceptable order and we shouldn't force the directory to already exist at preview_namelists time. But I could be convinced otherwise, particularly if we already enforce directory existence at preview_namelists time in other places.

Comment thread datm/cime_config/buildnml
expect(cplhist_dir is not None, "DATM_CPLHIST_DIR must be set when using cplhist mode")
expect(os.path.isdir(cplhist_dir), "DATM_CPLHIST_DIR {} does not exist".format(cplhist_dir))
if cplhist_domain != "null":
expect(os.path.isfile(cplhist_domain), "DATM_CPLHIST_DOMAIN_FILE {} does not exist".format(cplhist_domain))

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.

As with my comment for DATM_CPLHIST_DIR, I feel like preview_namelists might be too early to do this file existence check. Do we do file existence checks elsewhere at preview_namelists time? (If so, then I stand corrected, so ignore this comment.)

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

Labels

answers are bfb CESM Only enhancement New feature or request Responsibility: CTSM Responsibility to manage and accomplish this issue is the CTSM Software group

Projects

Status: In Progress

4 participants