Skip to content

Lake: subtract the heat used to melt snow (not heatrem) from the top lake layer - #4358

Open
wwieder wants to merge 2 commits into
ESCOMP:masterfrom
wwieder:fix-lake-snowmelt-heat
Open

wwieder wants to merge 2 commits into
ESCOMP:masterfrom
wwieder:fix-lake-snowmelt-heat

Conversation

@wwieder

@wwieder wwieder commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description of changes

When snow layers sit over an unfrozen top lake layer that has enough heat to melt them, LakeHydrology removes the snow and is meant to take the melt energy (heatsum) out of the top lake layer. It subtracted the leftover heat (heatrem) instead, so the layer ended at tfrz + heatsum/C rather than the energy-conserving t_lake − heatsum/C (= tfrz + heatrem/C). The resulting energy error, of either sign, is not seen by any balance check, because it happens after LakeTemperature. The code has been unchanged since clm4_0_60 (2013). Details and history are in #4356.

This PR changes only src/biogeophys/LakeHydrologyMod.F90: in the heatrem > 0 branch, t_lake(c,1) is reduced by heatsum(c)/(cpliq*denh2o*dz_lake(c,1)). A comment gives the equivalent tfrz + heatrem/C form. The partial-freeze branch was already correct and is unchanged.

Status: draft. The code has not been compiled or run yet.

Specific notes

Contributors other than yourself, if any:

  • Bug found by the CTSM correctness audit (finding LAKE-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):

  • Answer-changing for all configurations with lake columns, but only in time steps where resolved snow layers sit on an ice-free top lake layer above freezing and the layer has enough heat to melt them. TLAKE, lake heat content, ice onset and later lake surface fluxes can change. Non-lake columns are unchanged.

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

  • No.

Testing planned or performed, if any:

  • ERP_D_Ld5.f10_f10_mg37.I1850Clm60Bgc.derecho_intel.clm-ciso (contains lakes)
  • Temporary debug write when the branch fires, checking that C·ΔT = −heatsum to roundoff: single-column run at the f09 Lake Tahoe gridcell, 20 years. The branch fired twice; the residual is ~1e-9 J/m² with this fix and +1.4e6 J/m² on master (results)
  • aux_clm against baselines: expect DIFFs only in tests where this branch fires over lakes
  • Global runs in the audit_easy bundle: f09 80-year quicktest, f19 spin-up (pSASU) and HIST. The branch fired in only one gridcell (lake diagnostics)

Questions for reviewers

  • How often does this branch fire in practice? A count from a global multi-year run would show whether the answer change is negligible or noticeable in lake temperature and ice climatology.

…p layer

When snow layers over an unfrozen top lake layer were melted, the layer
was set to t_lake - heatrem/C = tfrz + heatsum/C instead of the
energy-conserving t_lake - heatsum/C = tfrz + heatrem/C.

Fixes ESCOMP#4356

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wwieder

wwieder commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Quicktest results (LAKE-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: Rare corrections to the top lake-layer temperature when snow melts on a lake.

Found: Lake surface-layer temperature and lake ice fraction show no detectable change over years 71–80.

The affected code path (snow melting on a lake while the top layer is near freezing) is rare, so a 10-year global mean is not a sensitive test; the fix is a correctness change.

Global land, years 71–80 Baseline Experiment Change % p < 0.05 Units
Lake surface-layer temperature (TLAKE) 282 282 −4.48e−07 −0.0% no K
Lake surface ice fraction (LAKEICEFRAC_SURF) 0.349 0.349 +6.54e−08 +0.0% no -
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 (LAKE-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: Lake surface-layer temperature and lake ice fraction are identical to the baseline spin-up over years 221–240. The affected code path (snow melting on a lake near freezing) is rare, so a 20-year global mean is not a sensitive test.

The fix is a correctness change; this configuration is not a sensitive test of it.

Global land, pSASU years 221–240 Baseline Experiment Change % Quicktest % p < 0.05 Units
Lake surface-layer temperature (TLAKE) 282 282 0 0.0% −0.0% no K
Lake surface ice fraction (LAKEICEFRAC_SURF) 0.356 0.356 0 0.0% +0.0% no -
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 (LAKE-001)

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

LAKE-001 (Snow-over-unfrozen-lake melt sets t_lake(1) to tfrz+heatsum/C instead of t_lake-heatsum/C): Not exercised. Tested in the audit-easy bundle. The 1850 spin-up shows no measurable lake effect. Rely on the targeted lake 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

This seems like a simple fix, an may rarely be triggered. This seems ready for review. Do we have a test case that would be more useful to evaluate lake dynamics?

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

wwieder commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Lake diagnostics: pSASU and HIST (LAKE-001)

Follow-up to the pSASU results and to the question in #4356 about how often this branch runs. Will asked Claude to add TLAKE diagnostics for the audit_easy bundle to the pSASU and HIST evaluations. Below is Claude's summary.

Approach. Lake columns exchange nothing with the vegetated and soil columns, and every case uses identical forcing. So a lake grid cell in audit_easy can only differ from the baseline if the fixed heatrem > 0 branch ran there. The other bundled fixes (DYN-001, EMIS, SBGC-001, BLD) don't touch lake columns. We compared every lake grid cell in every monthly file for all 10 TLAKE levels, LAKEICEFRAC_SURF, LAKEICETHICK, TKE1 and EFLX_GRND_LAKE. The fix is compiled into the audit_easy executable.

Found: the branch almost never runs in global simulations.

Run Months Lake grid cells Months with any lake difference Cells that ever differ Largest monthly ΔTLAKE
f09 quicktest (80 yr) 960 3,345 768 1 (39.1°N, 120°W) 1.1 K
f19 pSASU (240 yr) 2,880 964 0 0 0
f19 HIST 1850–2023 2,088 964–1,114 649 1 (40.7°N, 70°E) 0.0016 K
  • pSASU: every lake cell is bit-identical to the baseline for all 240 years. The branch never ran.
  • HIST: every lake cell is bit-identical except one. That lake doesn't exist until transient land cover adds it in 1957 (0 → 1% of the cell), and it differs at round-off level from its first month. Monthly output can't show whether the branch ran there or the new lake started from a slightly different state. Either way the effect is negligible: TLAKE ≤ 0.0016 K and ice fraction ≤ 1e−4. Lake-area-weighted means over 2004–2023 are identical: top-layer TLAKE 10.16 °C, ice fraction 0.317, ice thickness 0.172 m.
  • Quicktest: the branch evidently ran once, in one f09 lake cell near Lake Tahoe (5% lake). That cell first differs in December of year 15 and stays different afterwards, by up to 1.1 K in a monthly mean. The other 3,344 f09 lake cells never differ.

Lake grid cells that differ from the baseline each month

HIST 2004–2023 lake seasonal cycle

Implication. This matches the reasoning in #4356. Snow layers only sit on an ice-free lake above freezing in the short window after the top layer melts, so the condition is rarely met. When it is met, the error is local but not negligible (about 1 K in the f09 cell). Global climate runs at this resolution can't test the fix; the targeted test with a debug write (C·ΔT = −heatsum) remains the right check. The answer change for typical global configurations should be confined to a handful of lake cells.

Setup
  • pSASU: ctsm5.4.069_audit_easy_f19_BGCcrop_189_pSASU vs ctsm5.4.069_baseline_f19_BGCcrop_189_pSASU, I1850Clm60BgcCropCrujra, f19_t233. Cold-start spin-up: AD 360 yr → SASU 360 yr → pSASU 240 yr, CRUJRA 1901–1920 cycled.
  • HIST: ctsm5.4.069_*_f19_BGCcrop_189_HIST, 1850–2023, each from its own pSASU year-241 restart, with transient land use.
  • Quicktest: ctsm5.4.069_*_f09_BGCcrop_188_quicktest, 80 years from a shared spun-up 1850 restart.
  • Comparison: monthly h0a files, exact equality per grid cell. Lake area is PCT_LANDUNIT (deep lake) × landfrac × area.

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

@wwieder

wwieder commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Targeted single-point test (LAKE-001)

Follow-up to the lake diagnostics, which found that the fixed branch ran in only one f09 quicktest gridcell (39.1°N, 120°W, near Lake Tahoe). Will asked Claude to rerun that gridcell as a single column with a temporary energy check in the changed branch. Below is Claude's summary.

Found: the branch fired on the same date as in the quicktest. The current code loses about 75% of the snowmelt energy; the fix conserves it to roundoff.

Run Passes through heatrem > 0 Top-layer t_lake before → after Energy residual C·Δt + heatsum
master 2 (year 15, Dec 9, consecutive steps) 278.83 K → 277.68 K +1.41e6, +1.42e6 J/m² (75% of heatsum)
this PR 2 (same steps) 278.83 K → 274.30 K −6e−9, +5e−10 J/m² (roundoff)
  • Size of the error: heatsum (the energy needed to warm and melt the snow) was 1.9e6 J/m². The current code removed only heatrem (4.8e5 J/m²) from the 0.1 m top layer. That left the layer 3.4 K too warm and created 1.4e6 J/m² of energy that no balance check sees.
  • After the event:
    • Top-layer TLAKE differs on every later day of the 20-year run, but mostly by small amounts: more than 0.1 K on 81 days and more than 0.01 K on 262 days.
    • The largest daily difference is −3.06 K in March of year 18, when the timing of spring ice melt shifts. Lake ice fraction differs by up to 0.59 that spring.
    • Annual-mean top-layer differences are −0.13 K in year 18 and below 0.03 K in the other years. The fix runs slightly colder, as expected, since it removes more heat.
  • Consistency with the quicktest: the quicktest gridcell first differed in December of year 15 (up to 1.1 K in monthly means), which matches this event.

This covers the "temporary debug write" item in the testing plan. The remaining item is aux_clm against baselines.

Setup
  • Code: master 72209e4a8, single column (PTS_LAT=39.109947, PTS_LON=240.0) from the global f09 surface data (surfdata_0.9x1.25_hist_1850_78pfts_c251022.nc; this gridcell is 5% lake, 22 m deep).
  • Compset: 1850_DATM%CRUJRA2024b_CLM60%BGC-CROP_SICE_SOCN_SROF_SGLC_SWAV, CRUJRA 1901–1920 cycled with DATM_YR_ALIGN=1.
  • Initial conditions: the same spun-up restart as the quicktests, via use_init_interp. 20 years, run in 5-year segments.
  • Cases:
    • master: LakeHydrologyMod.F90 from master.
    • PR: LakeHydrologyMod.F90 from this branch.
    • Both add the same temporary write as a SourceMod. It is not in this PR. It logs date, t_lake(1) before and after, heatsum, heatrem and C·(t_new − t_old) + heatsum on every pass through the heatrem > 0 branch.
  • Daily output: TLAKE, LAKEICEFRAC_SURF, LAKEICETHICK, EFLX_GRND_LAKE, SNOWDP and H2OSNO.

Cases: /glade/work/wwieder/clm6_bug_fixes/ctsm_master_lake-tahoe-{base,fix}_f09pt_BGCcrop_20yr; setup make_lake_tahoe_cases.sh, analysis logs/check_lake_tahoe.py (output logs/lake_tahoe_check.txt) on GLADE. Analysis and write-up prepared with AI assistance (Claude).

@wwieder wwieder added bug something is working incorrectly and removed investigation Needs to be verified and more investigation into what's going on. labels 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lake: melting snow over an unfrozen top lake layer subtracts the wrong heat (energy not conserved)

2 participants