Skip to content

Avoid tiny non-zero landunit weights in dynamic landunits - #4280

Open
billsacks wants to merge 3 commits into
ESCOMP:masterfrom
billsacks:fix_dynlu_landunit_reweights
Open

billsacks wants to merge 3 commits into
ESCOMP:masterfrom
billsacks:fix_dynlu_landunit_reweights

Conversation

@billsacks

Copy link
Copy Markdown
Member

Description of changes

With dynamic landunits, I noticed that landunit areas can end up roundoff-level greater than zero. The issue is that, when the areas of one or more landunits increases, other landunit areas decrease to accommodate this. However, the algorithm for the decrease is prone to roundoff-level errors. This can leave some landunit areas just roundoff-level greater than zero when they should be exactly zero.

This PR fixes this issue by truncating tiny landunit weights to exactly 0 during landunit area changes.

This also changes and adds unit tests to ensure that weights go to exactly 0 when they should. The two new unit tests here failed before these changes, at least with gfortran on my Mac (behavior could differ on different machines / compilers).

Specific notes

Contributors other than yourself, if any:

  • Unit test changes were written by Claude. I carefully reviewed all changes.

CTSM issues resolved or otherwise addressed, if any:

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

  • Roundoff-level changes in potentially any configuration with evolving GLC or transient landcover; can also even occur with non-evolving DGLC because of the glacier area changes in the first time step of the run
  • Vector output (not averaged to gridcell) could show larger than roundoff level differences in columns that were active before but are now inactive

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

Testing planned or performed, if any:

  • Only minimal testing performed so far
  • Warrants full aux_clm testing eventually

Requirements before merge:

  • I have followed the CTSM contribution guidelines.
  • The code in this PR branch builds with no errors.
  • The code in this PR branch runs with no errors. Briefly describe tested configuration(s):
  • This either (a) does not change answers, (b) it only changes answers at roundoff level, or (c) I have performed a scientific evaluation of the answer changes. Which?: (b) it only changes answers at roundoff level
  • I have reviewed relevant parts of the CLM documentation Tech Note or User's Guide to determine if anything needs to be changed or added. If it does, describe:
  • This PR either (a) does not create a need to update the documentation or (b) includes required documentation updates (see guidelines for contributing documentation). Which?:

Code written by Claude, reviewed carefully by myself
I noticed that we sometimes were left with tiny but non-zero areas when
they should have been 0. This should resolve that issue.

This is answer changing, but should only change answers by roundoff.

Unit tests were written by Claude and reviewed by myself. Production
code changes were done by myself.
Written by Claude, reviewed by myself.
@billsacks

Copy link
Copy Markdown
Member Author

This seems worth getting in eventually, but I'd suggest waiting until post-CESM3, since the benefits are probably minor and I don't think it's worth the risk at this stage.

@ekluzek ekluzek added blocked: answer changing Can't be resolved until we're ready for answer changes on master (non b4b) non-b4b Changes answers (incl. adding tests) labels Oct 23, 2026
@ekluzek ekluzek added this to the ctsm6.1.0 milestone Oct 23, 2026
@ekluzek ekluzek added enhancement new capability or improved behavior of existing capability next this should get some attention in the next week or two. Normally each Thursday SE meeting. science Enhancement to or bug impacting science labels Oct 23, 2026
@ekluzek

ekluzek commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Cool, thanks for creating a PR for this @billsacks. I assigned it a 6.1 milestone because of your thought about doing this after cesm3.0.

But I added next so we can discuss when we think this should happen. We'll make sure it's a draft if it'll be on a 6.1 timeline.

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

blocked: answer changing Can't be resolved until we're ready for answer changes on master (non b4b) enhancement new capability or improved behavior of existing capability next this should get some attention in the next week or two. Normally each Thursday SE meeting. non-b4b Changes answers (incl. adding tests) science Enhancement to or bug impacting science

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With dynamic landunits, landunit areas can end up roundoff-level greater than zero

2 participants