Skip to content

ctsm5.4.036: Complete the FATES-CLM nitrogen coupling#3409

Open
slevis-lmwg wants to merge 46 commits intoESCOMP:masterfrom
slevis-lmwg:fates-cn
Open

ctsm5.4.036: Complete the FATES-CLM nitrogen coupling#3409
slevis-lmwg wants to merge 46 commits intoESCOMP:masterfrom
slevis-lmwg:fates-cn

Conversation

@slevis-lmwg
Copy link
Copy Markdown
Contributor

@slevis-lmwg slevis-lmwg commented Aug 11, 2025

Description of changes

For now see the issue #3378

Corresponding mods on the FATES side:
NGEET/fates#1472

Nutrient enabled FATES handbook
FATES CLM N coupling

Specific notes

Contributors other than yourself, if any:
@rgknox @adrifoster @wwieder

CTSM Issues Fixed (include github issue #):
#3378

Are answers expected to change (and if so in what way)?
For non-fates tests expect roundoff diffs due to a change in the order of operations in CNNDynamicsMod.F90 as documented below.

Any User Interface Changes (namelist or namelist defaults changes)?
Yes, see changes to CLMBuildNamelist and namelistdefaults.

Does this create a need to change or add documentation? Did you do so?
Yes, no.

  • Todo: add a modification to the PRT2 test, make sure that prescribed P uptake is set to 10. This will ensure that there are no P limitations in fates, when FATES becomes coupled to CLM's N cycle (in future PR). i:e: fates_cnp_prescribed_puptake=10

Initial testing performed
...with the first two commits in this PR:

PASS ERS_D_Ld30.1x1_brazil.I2000Clm60FatesCrujraRs.derecho_intel.clm-FatesColdPRT2
PASS ERS_D_Ld30.1x1_brazil.I2000Clm60FatesCrujraRs.derecho_intel.clm-FatesCold

Later comments point out that these two tests were inadequate at catching problems, and that I switched to two other tests.

PASS ERS_D_Ld30.1x1_brazil.I2000Clm60FatesCrujraRs.derecho_intel.clm-FatesColdPRT2
FAIL ERS_D_Ld30.1x1_brazil.I2000Clm60FatesCrujraRs.derecho_intel.clm-FatesColdPRT2--clm-mimicsFatesCold--clm-nofireemis
The latter needs "nofireemis" to work with Fates, but it then dumps core in line 1180 SoilBiogeochemDecompCascadeMIMICSMod.F90
...calculating these variables:
nf_soil%decomp_npools_sourcesink_col
nf_soil%fates_litter_flux
@slevis-lmwg slevis-lmwg self-assigned this Aug 11, 2025
@slevis-lmwg slevis-lmwg added enhancement new capability or improved behavior of existing capability investigation Needs to be verified and more investigation into what's going on. science Enhancement to or bug impacting science test: aux_clm Pass aux_clm suite before merging test: fates Pass fates test suite before merging labels Aug 11, 2025
@slevis-lmwg slevis-lmwg linked an issue Aug 11, 2025 that may be closed by this pull request
1 task
@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

slevis-lmwg commented Aug 13, 2025

With the latest commit, I repeated the two earlier tests and added another to check whether answers have changed from the baseline:

PASS ERS_D_Ld30.1x1_brazil.I2000Clm60FatesCrujraRs.derecho_intel.clm-FatesColdPRT2
PASS ERS_D_Ld30.1x1_brazil.I2000Clm60FatesCrujraRs.derecho_intel.clm-FatesCold
FAIL ERP_Ld9.f45_f45_mg37.I2000Clm50FatesRs.derecho_intel.clm-FatesColdAllVars -c /glade/campaign/cgd/tss/ctsm_baselines/ctsm5.3.065

The latter fails in case2, after reading the restart file, with a N balance error.

UPDATE

  • See below for suggestions to resolve FAIL
  • Add new test ERP_Ld9.f45_f45_mg37.I2000Clm50FatesRs.derecho_intel.clm-FatesColdPRT2 (sanity check first that it meets requirements set forth in the fourth checkbox here, which I think means pointing to an alternate fates paramfile)
  • Later comment explains why I decided to revert to preexisting ERS tests and skip adding this ERP test.

Comment thread src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90 Outdated
Comment thread src/soilbiogeochem/SoilBiogeochemCompetitionMod.F90
@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

slevis-lmwg commented Aug 26, 2025

Enabled fixation and ran the same tests:

PASS ERS_D_Ld30.f45_f45_mg37.I2000Clm50FatesCruRsGs.derecho_intel.clm-FatesColdPRT2 -c /glade/campaign/cgd/tss/ctsm_baselines/fates-sci.1.84.0_api.40.0.0-ctsm5.3.066
PASS ERS_D_Ld30.f45_f45_mg37.I2000Clm50FatesCruRsGs.derecho_intel.clm-FatesColdLUH2 -c /glade/campaign/cgd/tss/ctsm_baselines/fates-sci.1.84.0_api.40.0.0-ctsm5.3.066

PRT2 still b4b with the baseline.
LUH2 now DIFF from the baseline.

PASS The same tests with the code change for harvest (same results relative to the baseline).

@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

slevis-lmwg commented Sep 20, 2025

Worked on the next checkbox in the issue (#3378), submitted the same tests, and after some troubleshooting:
PASS PRT2 and b4b with the baseline.
PASS LUH2 and DIFF from the baseline as before.

These variables originate in fates, so this renaming requires the same
renaming in fates; I will open the corresponding PR very soon
@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

slevis-lmwg commented Sep 23, 2025

OK ./build-namelist_test.pl
OK ./run_sys_tests -s fates -c fates-sci.1.84.0_api.40.0.0-ctsm5.3.066/ --skip-generate
REDO ./run_sys_tests -s aux_clm -c ctsm5.3.066 --skip-generate

Notes:

  • Gnu and nvhpc tests needed a bug-fix that intel didn't catch (next commit).
  • Then the fates test-suite worked (I didn't repeat aux_clm for now)
  • Many tests DIFFer from the baseline.
  • The PRT2 test had the expected NLCOMP change, though no DIFFs from the baseline (even after rebuilding/rerunning):
  BASE: suplnitro = 'ALL'
  COMP: suplnitro = 'NONE'

@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

slevis-lmwg commented Sep 23, 2025

Updated the fates paramfile (see next commit) and submitted these two again

./create_test ERS_D_Ld30.f45_f45_mg37.I2000Clm50FatesCruRsGs.derecho_intel.clm-FatesColdLUH2 -c /glade/campaign/cgd/tss/ctsm_baselines/fates-sci.1.84.0_api.40.0.0-ctsm5.3.066
./create_test ERS_D_Ld30.f45_f45_mg37.I2000Clm50FatesCruRsGs.derecho_intel.clm-FatesColdPRT2 -c /glade/campaign/cgd/tss/ctsm_baselines/fates-sci.1.84.0_api.40.0.0-ctsm5.3.066

The first (LUH2) same as before (DIFF from baseline) since nothing changed for it.
The second (ERS_D_Ld30.f45_f45_mg37.I2000Clm50FatesCruRsGs.derecho_intel.clm-FatesColdPRT2.C.20250923_141838_qjxqou) now:

  • DIFF from baseline and
  • FAIL COMPARE_base_rest suggesting variable(s) missing from restart, I suspect

@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

slevis-lmwg commented Apr 14, 2026

@rgknox testing seems satisfactory to me, so this PR and its fates counterpart are ready for your final review, unless you think of anything else that we need to work on here.

@slevis-lmwg slevis-lmwg moved this from Todo to In Progress in LMWG: Sprint Planning Board Apr 14, 2026
@slevis-lmwg slevis-lmwg moved this from In Progress to Todo in LMWG: Sprint Planning Board Apr 14, 2026
@slevis-lmwg slevis-lmwg moved this from Todo to Stalled in LMWG: Sprint Planning Board Apr 14, 2026
@wwieder wwieder modified the milestone: FATES freeze for ctsm6 Apr 16, 2026
@wwieder wwieder requested review from glemieux April 16, 2026 16:59
@slevis-lmwg slevis-lmwg removed the request for review from rgknox April 16, 2026 20:35
@github-project-automation github-project-automation Bot moved this to Ready to start (or start again) in CTSM: Upcoming tags Apr 20, 2026
@slevis-lmwg slevis-lmwg moved this from Ready to start (or start again) to In progress - master in CTSM: Upcoming tags Apr 20, 2026
@slevis-lmwg slevis-lmwg moved this from Stalled to In Progress in LMWG: Sprint Planning Board Apr 20, 2026
Copy link
Copy Markdown
Contributor

@glemieux glemieux left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks again to @slevis-lmwg for the walkthrough. I just have two questions/comments that should be dealt with via other PRs (if at all).

'FATES_DEMOTION_CARBONFLUX', 'FATES_PROMOTION_CARBONFLUX',
'FATES_MORTALITY_CFLUX_CANOPY', 'FATES_MORTALITY_CFLUX_USTORY',
'FATES_NEP', 'FATES_HET_RESP', 'FATES_FIRE_CLOSS', 'FATES_FIRE_FLUX_EL',
'FATES_CBALANCE_ERROR', 'FATES_ERROR_EL', 'FATES_LEAF_ALLOC',
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.

Do we have an issue to note why this shouldn't be included here? I could find anything specific outside of a conflict with using it during ST3 or SP mode tests.

<test name="ERS_D_Ld30" grid="f45_f45_mg37" compset="I2000Clm60FatesRs" testmods="clm/FatesColdPRT2_suplnAll">
<machines>
<machine name="derecho" compiler="intel" category="fates"/>
<machine name="lawrencium-lr3" compiler="intel" category="fates"/>
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.

@rgknox do you use lawrencium? We should instances of lawrencium if we don't think we're going to be using it anytime soon, but that's out of scope for this PR so I'd just make an issue if you agree.

@glemieux glemieux requested a review from samsrabin April 20, 2026 19:33
@ekluzek ekluzek changed the title Complete the FATES-CLM nitrogen coupling ctsm5.4.035: Complete the FATES-CLM nitrogen coupling Apr 22, 2026
Copy link
Copy Markdown
Contributor

@ekluzek ekluzek left a comment

Choose a reason for hiding this comment

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

I did a fairly quick skim, and only have a few suggestions. There was one thing I was concerned about, but realized it was done on purpose. So I only wonder if more comments might help with the supplemental nitrogen setting?

@glemieux had some comments to handle. And we should have him and @samsrabin finish a review as well.

The other thing I wondered about this is how FATES carbon_nitrogen will interact with other parts of Nitrogen in CLM like LUNA? That likely will take some scientific validation, but we might want to have some warnings or comments about some of that?


<!-- Supplmental Nitrogen mode -->
<suplnitro >NONE</suplnitro>
<suplnitro fates_parteh_mode="carbon_only" >ALL</suplnitro>
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.

Doesn't this need the addition of:

Suggested change
<suplnitro fates_parteh_mode="carbon_only" >ALL</suplnitro>
<suplnitro use_fates=".true." >ALL</suplnitro>
<suplnitro use_fates=".true." fates_parteh_mode="carbon_only" >ALL</suplnitro>

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.

OK, it looks like this was an intentional change. I only wonder about making this more obvious in comments though.

Comment thread src/main/clm_varctl.F90
integer, public :: fates_parteh_mode = -9 ! 1 => carbon only
! 2 => C+N+P (not enabled yet)
! no others enabled
character(len=256), public :: fates_parteh_mode = '' ! FATES Plant Allocation Reactions and Transport Hypotheses
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.

I really love upgrading this to a character description. So much easier to understand!


<entry id="fates_parteh_mode" type="integer" category="physics"
group="clm_inparm" valid_values="1,2">
<entry id="fates_parteh_mode" type="char*256" category="physics"
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.

You could make the string shorter. If you use SHR_KIND_CS it would be 80 characters which is still longer than needed for this. But, you could use it in the code and have it consistent here.

Suggested change
<entry id="fates_parteh_mode" type="char*256" category="physics"
<entry id="fates_parteh_mode" type="char*256" category="physics"

Comment thread src/main/clm_varctl.F90
integer, public :: fates_parteh_mode = -9 ! 1 => carbon only
! 2 => C+N+P (not enabled yet)
! no others enabled
character(len=256), public :: fates_parteh_mode = '' ! FATES Plant Allocation Reactions and Transport Hypotheses
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.

I do suggest either hardcoding the length to something shorter (and agree with the value in the namelist defintion above), or use SHR_KIND_CS which has a length of 80.

You can add a use statement to shr_kind, for it, and then use it similar to other string lengths.

Suggested change
character(len=256), public :: fates_parteh_mode = '' ! FATES Plant Allocation Reactions and Transport Hypotheses
character(len=CS), public :: fates_parteh_mode = '' ! FATES Plant Allocation Reactions and Transport Hypotheses
use shr_kind_mod, only: CS=>SHR_KIND_CS

end do
end do

bgc_soilc_loop2: do fc = 1, num_bgc_soilc
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.

Add a comment to say what this loop is doing.

<entry id="fates_parteh_mode" type="char*256" category="physics"
group="clm_inparm" valid_values="carbon_only,carbon_nitrogen">
Switch deciding which nutrient model to use in FATES.
(Only relevant if FATES is on)
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.

The other thing I wonder about is making a note to say that this is experimental.

Suggested change
(Only relevant if FATES is on)
(Only relevant if FATES is on)
(fates_parteh_mode='carbon_nitrogen' is EXPERIMENTAL and UNSUPPORTED)

@rosiealice
Copy link
Copy Markdown
Contributor

Hi @ekluzek thanks for this. I just wanted to say that this code does not intersect with LUNA, as Vcmax is an input oarameter in FATES and so we don't for now handle any of the acclimation processes that LUNA predicts. This also goes for FUN and the 'Flex-CN' (I'm unsure if we still call it that) functionality.

@slevis-lmwg slevis-lmwg changed the title ctsm5.4.035: Complete the FATES-CLM nitrogen coupling ctsm5.4.036: Complete the FATES-CLM nitrogen coupling Apr 23, 2026
@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

Note to self: Open new documentation issues to update Technote and User's Guide.

@samsrabin samsrabin changed the title ctsm5.4.036: Complete the FATES-CLM nitrogen coupling ctsm5.4.037: Complete the FATES-CLM nitrogen coupling Apr 23, 2026
@samsrabin samsrabin changed the title ctsm5.4.037: Complete the FATES-CLM nitrogen coupling ctsm5.4.036: Complete the FATES-CLM nitrogen coupling Apr 23, 2026
@slevis-lmwg slevis-lmwg added the blocked: dependency Wait to work on this until dependency is resolved label Apr 23, 2026
@slevis-lmwg
Copy link
Copy Markdown
Contributor Author

Blocked by NGEET/fates#1472 for now.

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

Labels

blocked: dependency Wait to work on this until dependency is resolved enhancement new capability or improved behavior of existing capability investigation Needs to be verified and more investigation into what's going on. science Enhancement to or bug impacting science test: aux_clm Pass aux_clm suite before merging test: fates Pass fates test suite before merging

Projects

Status: In progress - master
Status: In Progress

Development

Successfully merging this pull request may close these issues.

Completing the FATES-CLM nitrogen coupling

6 participants