Skip to content

Fix DWT_SLASH_CFLUX: weight per-column-area root fluxes by old column weight - #4343

Open
wwieder wants to merge 2 commits into
ESCOMP:masterfrom
wwieder:fix-dwt-slash-cflux-colwt
Open

wwieder wants to merge 2 commits into
ESCOMP:masterfrom
wwieder:fix-dwt-slash-cflux-colwt

Conversation

@wwieder

@wwieder wwieder commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Description of changes

DWT_SLASH_CFLUX is built from the patch-level fine root, live coarse root and dead coarse root to-litter fluxes. DynamicPatchAdjustments computes these with flux_out_col_area, so they are per unit column area. dyn_cnbal_patch summed them into dwt_slash_cflux_grc as if they were per unit gridcell area, overstating the history field by 1/cwtgcell_old for each column. Details are in #4342.

This PR:

  • Adds a public get_cwtgcell_old(bounds) accessor to patch_state_updater_type (src/dyn_subgrid/dynPatchStateUpdaterMod.F90), which returns the column weights saved by set_old_weights.
  • In dyn_cnbal_patch (src/biogeochem/dynConsBiogeochemMod.F90), multiplies the C, C13 and C14 patch slash fluxes by the old column weight before summing to the gridcell. dwt_slash_cflux_patch is now per gridcell area, matching its DWT_SLASH_CFLUX_PATCH long_name.
  • Replaces the comment that said these patch fluxes were already per gridcell area.

dwt_slash_cflux is only used for history output. Model state and the actual litter/CWD inputs from land-cover change are unchanged.

Status: tested; see the test results.

Specific notes

Contributors other than yourself, if any:

  • Bug found by the CTSM correctness audit (finding DYN-001); fix drafted with AI assistance (Claude).

CTSM issues resolved or otherwise addressed, if any:

If answers are expected to change, describe (delete this line otherwise):

  • Diagnostics only. In transient land-cover BGC runs, DWT_SLASH_CFLUX, DWT_SLASH_CFLUX_PATCH, C13_DWT_SLASH_CFLUX and C14_DWT_SLASH_CFLUX decrease (they were overstated by 1/column weight). No other fields should change; restarts and model state are b4b.

Any user interface changes (namelist or namelist defaults changes)?

  • No.

Testing planned or performed, if any:

  • SMS_Ld3_PS.f09_g17.IHistClm50BgcCrop.derecho_intel.clm-f09_dec1990Start_GU_LULCC: only the slash flux fields DIFF from baseline
  • ERP_D_Ld10_P64x2.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-ciso_decStart: same, including C13/C14
  • Consistency check: DWT_SLASH_CFLUX equals the gridcell average of the vertically integrated DWT_FROOTC_TO_* + DWT_LIVECROOTC_TO_CWDC + DWT_DEADCROOTC_TO_CWDC (exact to round-off when the column fluxes are weighted by the pre-update column weights; see the column-level check)
  • aux_clm against baselines (not run yet): expect DIFFs only in DWT_SLASH_CFLUX* fields of transient BGC tests

Questions for reviewers

  • This targets master. Since it only changes diagnostic history fields, would you rather it go to b4b-dev?
  • An alternative is to have DynamicPatchAdjustments also return the root fluxes with flux_out_grc_area in separate arrays, instead of adding the accessor. The accessor seemed less invasive. Any preference?

🤖 Generated with Claude Code

The patch-level fine/coarse root to litter fluxes used to build
dwt_slash_cflux are computed with flux_out_col_area, i.e. per unit
COLUMN area, but were summed into dwt_slash_cflux_grc as if per unit
GRIDCELL area, overstating DWT_SLASH_CFLUX (and C13/C14) by
1/cwtgcell_old. Add a get_cwtgcell_old accessor to
patch_state_updater_type and multiply the patch slash flux by the old
column weight, so the patch field is per gridcell area (as its
long_name says) and the gridcell sum is correct. Diagnostics only.

Fixes ESCOMP#4342

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wwieder wwieder added bug something is working incorrectly diagnostic Does not affect model outcome AI (LLM) guidance Things we do to our repo to try and keep AI coding agents on the rails labels Nov 23, 2026
@samsrabin samsrabin added AI-generated Stuff that was totally AI-generated, at least to start with. investigation Needs to be verified and more investigation into what's going on. and removed AI (LLM) guidance Things we do to our repo to try and keep AI coding agents on the rails labels Nov 23, 2026
@wwieder

wwieder commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Quicktest results (DYN-001)

Will ran this fix in an 80 year test against an unmodified baseline (case ctsm5.4.069_audit-easy_f09_BGCcrop_188_quicktest) and asked Claude to:

Create a report that summarizes the key differences in ctsm5.4.069_<label>_f09_BGCcrop_188_quicktest experiments compared to the baseline case, ctsm5.4.069_baseline_f09_BGCcrop_188_quicktest.

All results are in /glade/derecho/scratch/wwieder/archive/*/lnd/hist and should have run for 80 years. Focus the analysis on the last 10 years of each simulation and focus on the changes expected based on the audit made here [audit fix tracker].

Also note if there are likely climate changing differences in LAI, ET, FSH, albedo, net radiation, soil moisture, or runoff. If it's helpful you can use plotting tools available in ~/python/ldf-native-grid-merge-main/.

Below is Claude's summary of the results for this PR.

This fix was tested in the audit-easy run, which bundled DYN-001 (#4343), EMIS-002/003/004 (#4348), SBGC-001 (#4355), LAKE-001 (#4358) and BLD-055/059 (#4341). The changes below are the ones this PR's code can plausibly cause, but they come from the combined run.

Expected: A corrected DWT_SLASH_CFLUX diagnostic where columns change weight under land-use change.

Found: Not testable in this configuration. DWT_SLASH_CFLUX is zero in both runs because an 1850 control has no land-use change.

A transient historical run with dynamic land use would exercise this fix.

Global land, years 71–80 Baseline Experiment Change % p < 0.05 Units
DWT slash C flux (DWT_SLASH_CFLUX) 0 0 0 – no PgC/yr
Setup

80-year land-only runs: 1850_DATM%CRUJRA2024b_CLM60%BGC-CROP, f09, all started from the same spun-up 1850 restart with identical namelists and CRUJRA forcing (1901–1920 cycled). Each experiment is ctsm5.4.069 plus only its fix commits, compared with an unmodified ctsm5.4.069 baseline over years 71–80. Significance uses a two-sided paired t-test across the 10 annual means (p < 0.05), pairing years that used the same forcing.

Analysis scripts: /glade/u/home/wwieder/audit_quicktest_analysis on GLADE (extract.py, analysis.py). Analysis and write-up prepared with AI assistance (Claude).

@wwieder

wwieder commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

pSASU spin-up results (DYN-001)

Follow-up to the quicktest results above. Will also ran this fix through a full cold-start spin-up (AD → SASU → pSASU; case ctsm5.4.069_audit_easy_f19_BGCcrop_189_pSASU) alongside an unmodified baseline spin-up (ctsm5.4.069_baseline_f19_BGCcrop_189_pSASU), and asked Claude to:

repeat the analysis from the quicktests posted here [link to the quicktest report] but with the pSASU runs. Focus they analyses on the last 20 years available pSASU resutls and compare each of the test cases with the baseline results.

Below is Claude's summary of the results for this PR.

This fix was spun up in the combined audit_easy case, which bundles DYN-001 (#4343), EMIS-002/003/004 (#4348), SBGC-001 (#4355), LAKE-001 (#4358) and BLD-055/059 (#4341). The changes below are the ones this PR's code can plausibly cause, but they come from the combined run.

Found: Still not testable: an 1850 spin-up has no land-use change, so DWT_SLASH_CFLUX is zero in both runs.

A transient historical run with dynamic land use would exercise this fix.

Global land, pSASU years 221–240 Baseline Experiment Change % Quicktest % p < 0.05 Units
DWT slash C flux (DWT_SLASH_CFLUX) 0 0 0 – – no PgC/yr
Setup

Each case is a cold-start spin-up with its fix in place: I1850Clm60BgcCropCrujra, f19_t233, 360 years of accelerated decomposition (AD), 360 years of SASU (hybrid from AD year 361), then 240 years of pSASU (hybrid from SASU year 361, spin-up off). CRUJRA 1901–1920 forcing is cycled with DATM_YR_ALIGN=1, so a given model year has the same forcing in every case. We compare the last 20 pSASU years (221–240) with the same years of the baseline spin-up. Significance is a two-sided paired t-test across the 20 annual means (p < 0.05). Spin-up noise floor: fixes with no plausible carbon pathway (snicar, wf2-accumulator, crop-retrans) end with ecosystem C +0.10 to +0.93 PgC different from the baseline, so treat slow-pool differences of about 1 PgC as noise.

Analysis scripts: /glade/u/home/wwieder/audit_quicktest_analysis on GLADE (extract.py, analysis.py and regional.py run with psasu). Analysis and write-up prepared with AI assistance (Claude).

@wwieder

wwieder commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Implications (DYN-001)

Short summary of what the full cold-start spin-up (AD → SASU → pSASU, f19 BGC-Crop, 1850) means for this fix.

DYN-001 (DWT_SLASH_CFLUX gridcell sum adds per-COLUMN-area root fluxes without column weights): Not exercised. Tested in the audit-easy bundle. DWT_SLASH_CFLUX only changes with transient land use, so an 1850 spin-up cannot test it. Diagnostic only; rely on the targeted test.

Details: full pSASU results above

Prepared with AI assistance (Claude) from the pSASU analysis in /glade/u/home/wwieder/audit_quicktest_analysis on GLADE.

@wwieder

wwieder commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Historical (HIST) results (DYN-001)

Follow-up to the pSASU results above, which could not test this fix because an 1850 spin-up has no land-use change. Will has now run each spun-up case forward as a transient historical simulation with dynamic land use (HIST_DATM%CRUJRA2024_CLM60%BGC-CROP, f19, 1850–2023; case ctsm5.4.069_audit_easy_f19_BGCcrop_189_HIST against ctsm5.4.069_baseline_f19_BGCcrop_189_HIST, each started from its own pSASU restart), and asked Claude to add the DWT_SLASH_CFLUX HIST results to this PR.

As before, this fix was run in the combined audit_easy case (DYN-001 plus EMIS-002/003/004, SBGC-001, LAKE-001 and BLD-055/059), so the other fixes also change the vegetation and root C that feeds this flux a little.

Found: DWT_SLASH_CFLUX drops as expected. Over 2004–2023 the global slash C flux is 0.17 PgC/yr with the fix against 0.38 PgC/yr in the baseline (−55%, paired t p < 0.001). The reduction grows with land-use change: −25% in 1850–1900, −26% in 1901–1950, −45% in 1951–2000 and −55% in 2004–2023. Summed over 1850–2023 the reported slash C falls from 50.8 to 30.9 PgC (−39%).

Global DWT_SLASH_CFLUX, HIST 1850-2023

  • The baseline spikes go away. In 2004–2023 the baseline swings between 0.20 and 0.66 PgC/yr from year to year, while the fixed run stays between 0.15 and 0.20. That is consistent with the bug: the overstatement is 1/(old column weight), so a year with conversion out of a small column inflates the baseline most.
  • Lower almost everywhere. Of the 1,981 land cells with a baseline flux above 0.1 gC/m²/yr, 1,948 are lower with the fix. The median cell keeps 72% of its baseline flux, and in a tenth of the cells the baseline was overstated more than 30-fold. The 31 cells that are slightly higher are within what the other bundled fixes can cause through small changes in root C.
  • Where. The largest reductions are in the deforestation and cropland-expansion regions: southern Brazil and the Gran Chaco, northern South America, Southeast Asia, the African savannas and eastern Australia.

DWT_SLASH_CFLUX difference map, HIST 2004-2023

Global land Baseline Experiment Change % p < 0.05 Units
DWT slash C flux (DWT_SLASH_CFLUX), 2004–2023 mean 0.385 0.173 −0.212 −55% yes PgC/yr
DWT slash C flux, 1850–2023 sum 50.8 30.9 −19.9 −39% – PgC

Not tested here: that model state is bit-for-bit, as the PR expects. The bundled fixes change other fields, so this run cannot show it; the planned SMS_Ld3_PS...LULCC test is the right check for that.

Setup

HIST_DATM%CRUJRA2024_CLM60%BGC-CROP, f19_t233, monthly h0a output, transient land use. Each case starts in 1850 from its own pSASU year-241 restart, so the fixes have been in place since the cold start. Global values are day-weighted annual means summed over land (area × landfrac). The 2004–2023 comparison uses a two-sided paired t-test across the 20 annual means (same forcing year in both runs).

Analysis scripts: /glade/u/home/wwieder/audit_quicktest_analysis on GLADE (hist_extract.py, extract.py with hist, hist_spatial.py, hist_pr_figs_dwt.py). Analysis and write-up prepared with AI assistance (Claude).

@wwieder

wwieder commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

This is only a diagnostic change can it go to b4b-dev?

@wwieder
wwieder marked this pull request as ready for review December 1, 2026 20:17
@wwieder

wwieder commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Test results

Branch bd349aadd compared with its base 72209e4a8 (master) on Derecho. Baselines were generated from the base commit. I used the grids from the current test list (f09_t233, f10_f10_mt201) instead of g17 / mg37.

System tests

Test Result Compared with base
SMS_Ld3_PS.f09_t233.IHistClm50BgcCrop.derecho_intel.clm-f09_dec1990Start_GU_LULCC PASS DIFF only in DWT_SLASH_CFLUX (clm2.h0a). Everything else is identical.
ERP_D_Ld10_P64x2.f10_f10_mt201.IHistClm60BgcCrop.derecho_intel.clm-ciso_decStart PASS (COMPARE_base_rest PASS) See below.

ERP test. The test's own baseline comparison reports PASS. That is because it only checks the last daily h0a file (Jan 9), while the slash flux is nonzero only in the first timestep of the year. So I ran cprnc on every daily file of the base and branch runs:

  • Only the Jan 1 file (h0a.2002-01-02) differs, and only in DWT_SLASH_CFLUX.
  • All other h0a, h0i and h1a files are identical.

The C13/C14 slash fields aren't on this test's history tapes. They are checked in the run below.

The NLCOMP failure on the ERP test is only restart_n in nuopc.runconfig. ERP rewrites that during the run, so it is not a namelist change.

C13/C14 and the consistency check

Setup:

  • 3-day runs of the base and of this branch: IHistClm60BgcCrop, f10_f10_mt201, ciso_decStart testmod (start 2001-12-30, C13 and C14 on), crossing the 2002-01-01 land-cover update.
  • An extra tape writes every timestep: DWT_SLASH_CFLUX, C13_DWT_SLASH_CFLUX, C14_DWT_SLASH_CFLUX, DWT_FROOTC_TO_LIT_{MET,CEL,LIG}_C, DWT_LIVECROOTC_TO_CWDC, DWT_DEADCROOTC_TO_CWDC, all as gridcell averages.

Only the slash fields change.

  • C13_DWT_SLASH_CFLUX, C14_DWT_SLASH_CFLUX and DWT_SLASH_CFLUX differ, and only at the first timestep of 2002.
  • Every other history file and the restart file (clm2.r.2002-01-02) are identical between base and branch.

The ratio of branch to base, over gridcells with nonzero slash flux:

Field Gridcells Median Range Gridcells where branch > base
DWT_SLASH_CFLUX 165 0.873 0 – 1.000 0
C13_DWT_SLASH_CFLUX 170 0.872 0 – 1.000 0
C14_DWT_SLASH_CFLUX 168 0.873 0 – 1.000 0

The fix never raises a slash flux. The C13 and C14 fluxes drop by the same proportion as total C.

Consistency check. I compared DWT_SLASH_CFLUX with the history gridcell average of the root fluxes, summed over the decomposition layers using the soil layer thicknesses (DZSOI), at the Jan 1 step:

(slash − Σ roots) / Σ roots Area-weighted total, slash / Σ roots
base median +14.6%, max +6.0e6 3.58
this PR within 0.1% in 109 of 165 gridcells, within 1% in 158; one gridcell at +151% (range −0.76% to +151%) 1.003

On master, the slash flux is overstated by 1 / (column weight), which can be enormous where a column's weight is tiny. With this PR, the slash flux matches the root fluxes in total, and in most gridcells, to well under 1%. It is not exact to round-off, though: only 20 of the 165 gridcells agree to 1e-10.

The remaining gap does not simply follow column weight changes. Only 45 of the 145 differing gridcells had a column weight change at Jan 1. Possible explanations:

  • how the history output averages these column fields to the gridcell (for example, which columns hold valid values);
  • the root fluxes being per unit column area relative to the old column weight.

I haven't tracked it down. A column-level output (hist_dov2xy = .false.) with the old column weights would settle it. I've left the consistency-check box unticked for that reason.

Not run

  • aux_clm against baselines.

Tests set up and run, and this summary written, with AI assistance (Claude Code).

@wwieder

wwieder commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Consistency check settled with column-level output

This follows up on the earlier results, where DWT_SLASH_CFLUX matched the gridcell-averaged root fluxes only approximately. With per-column output, the check holds exactly (to round-off) once the right column weights are used.

Setup. I reran the same 3-day branch case (bd349aadd; IHistClm60BgcCrop, f10_f10_mt201, ciso_decStart) with the extra tape written per column (hist_dov2xy = .false.), adding DWT_SLASH_CFLUX_PATCH. At the Jan 1 land-cover step, for the 165 gridcells with slash or root flux:

DWT_SLASH_CFLUX compared with Max |relative difference| Gridcells equal to 1e-10
Σ_c w_old(c) · Σ_j (DWT_FROOTC_TO_LIT_*_C + DWT_LIVECROOTC_TO_CWDC + DWT_DEADCROOTC_TO_CWDC)(c, j) · dz_j 1.1e-15 165 of 165
the same sum with w_new(c) (the column weights after the update) 1.51 20 of 165
the gridcell sum of DWT_SLASH_CFLUX_PATCH 0 165 of 165
  • w_old comes from the file opened before the update; w_new from an h1a file opened after it.
  • In total over all gridcells: slash 0.1180694, the w_old sum 0.1180694, the w_new sum 0.1175905.

Why the earlier check was approximate. The column root fluxes are per unit area of the column's old weight. That is the convention this PR relies on when it multiplies by cwtgcell_old. The gridded history output averages columns with their new weights. The w_new row reproduces the earlier gridded result exactly (max 1.51; the same 20 exact gridcells), and every gridcell that differs is one where a column weight changed.

Two conclusions:

  • With this PR, DWT_SLASH_CFLUX is exactly the gridcell total of the root-to-litter and root-to-CWD fluxes.
  • The gridded DWT_FROOTC_TO_* / DWT_*CROOTC_TO_CWDC history fields are not on that same per-gridcell basis in update timesteps where weights change. That is a property of the history averaging, not of this PR.

Run and summary written with AI assistance (Claude Code).

@wwieder

wwieder commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

The history averaging of the gridded root-flux fields noted above is now tracked in #4385, outside this PR.

@wwieder
wwieder requested a review from samsrabin December 3, 2026 17:55
@github-project-automation github-project-automation Bot moved this to Ready to start (or start again) in CTSM: Upcoming tags Dec 3, 2026
@wwieder wwieder moved this from Ready to start (or start again) to In progress - master in CTSM: Upcoming tags Dec 3, 2026

This branch has not been deployed

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

Labels

AI-generated Stuff that was totally AI-generated, at least to start with. bug something is working incorrectly diagnostic Does not affect model outcome investigation Needs to be verified and more investigation into what's going on.

Projects

Status: In progress - master

Development

Successfully merging this pull request may close these issues.

DWT_SLASH_CFLUX history diagnostic calculated incorrectly

2 participants