Skip to content

add namelist option to turn on all history fields, add a CLM test that uses this #29

Description

@billsacks

Bill Sacks < sacks@ucar.edu > - 2014-07-31 14:44:46 -0600
Bugzilla Id: 2022
Bugzilla CC: bandre@lbl.gov, erik@ucar.edu, muszala@ucar.edu, rfisher@ucar.edu,

You can turn on all history fields by ignoring a few lines of code in histFileMod:

Index: src/clm4_5/main/histFileMod.F90
===================================================================
--- src/clm4_5/main/histFileMod.F90    (revision 61424)
+++ src/clm4_5/main/histFileMod.F90    (working copy)
@@ -4139,9 +4139,6 @@
          p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, l2g_scale_type=scale_type_l2g)

     l_default = 'active'
-    if (present(default)) then
-       l_default = default
-    end if
     if (trim(l_default) == 'inactive') then
        return
     else
@@ -4429,9 +4426,6 @@
          no_snow_behavior=no_snow_behavior)

     l_default = 'active'
-    if (present(default)) then
-       l_default = default
-    end if
     if (trim(l_default) == 'inactive') then
        return
     else

It would be useful to have a namelist option that does this, for testing.

Then we should add a test that uses this.

Activity

  1. added this to the clm5 milestone on Dec 16, 2017
  2. added
    enhancementnew capability or improved behavior of existing capability
    on Dec 16, 2017
  3. billsacks commented on Dec 16, 2017

    @billsacks
    MemberAuthor

    Bill Sacks < sacks@ucar.edu > - 2014-07-31 14:47:52 -0600

    We probably want to use this option for one test for each configuration... this could replace the addition of select fields, which we do for some tests.

  4. added
    testingadditions or changes to tests
    and removed
    enhancementnew capability or improved behavior of existing capability
    on Nov 7, 2018
  5. removed this from the clm5 milestone on Nov 7, 2018
  6. billsacks commented on Apr 19, 2021

    @billsacks
    MemberAuthor

    Blocks #1347

  7. johnpaulalex commented on May 24, 2023

    @johnpaulalex
    Contributor

    I took a closer look at this. It looks like the logic is spread over two places: 'global' settings are applied from namelist variables here and then if the global settings have no opinion, the 'local' settings are applied. The local logic is in Bill's code snippet above; basically all history fields are written by default, but the caller can opt out of that by passing in 'inactive' to an optional parameter called 'default' (example).

    There are already a few relevant namelist flags affecting the global logic (per the code link above), the logic is a bit complex, and the ordering matters:

    • If hist_fincl says the specific field is on, return ON
    • If hist_empty_htapes says every field is off, return OFF
    • If hist_fexcl says the specific field is off, return OFF
    • otherwise, return the local vote (as described above)

    fwiw all local votes are recorded in a global masterlist.actflag variable, and later (at the end of the simulation I'm guessing), the logic above is executed.

    I think it makes most sense to keep all the global flags together, so I propose to modify the logic above to check some new flag ('hist_all'?) after checking the other three global flags. With that ordering, the fexcl flag can still be used to remove specific history fields.

    In addition I thought it'd make sense to leave some documentation breadcrumbs in the code: 1) if you find one global flag, find out about the others 2) if you find the local logic, find out about the global logic, and vice versa.

    On a minor note, I could make it crash if both hist_empty_htapes and the new flag (hist_all?) are set, since that's contradictory, but I'm not sure if that's CESM's usual policy for handling inconsistent flag settings.

  8. billsacks commented on May 24, 2023

    @billsacks
    MemberAuthor

    @johnpaulalex thank you for your careful work on this, as usual! You have come to understand this better than I have at this point :-) And yes, histFileMod is some of our oldest infrastructure code in CTSM, so it has accumulated some complexity and cruft over time....

    I like your suggestion of where to insert hist_all into the ordering so that hist_fexcl can still be used to remove specific history fields.

    One thing I may not have said when we talked – and I'm not sure if it's clear to you from your trace of the code logic – is that the default/inactive logic only applies to the first history "tape" (h0). My initial thought was that this new namelist option should just apply to the first history tape, and I think that's what my hacky code snippet would have accomplished, but I suppose it could be a vector namelist option like many of the other history-related namelist flags and so could theoretically apply to any history tape. Since, in practice, I only see this being used for software testing, I'd say do whichever one is cleanest to implement (unless @ekluzek or others have opinions).

    As for the name, we now tend towards longer, more explicit flag names than have been used in the past, so maybe something like, "hist_all_fields"?

    Yes, adding more documentation would be fantastic - thank you!

    And yes, we do try to add error-checking to prevent incompatible flags. We try to put this in at least one of (1) CLMBuildNamelist.pm and/or (2) the Fortran code. We try for (1) when feasible (the advantage is that this catches incompatibilities at build-namelist time, which typically means at build time or model submission time rather than waiting for run time), and it's not uncommon to do both (on the off-chance that a user has force-created a lnd_in file without going through the build-namelist script, and also because this makes the code more self-documenting as to incompatibility of flags).

    @ekluzek see above if you aren't currently following this issue.

    Also @slevis-lmwg I want to bring you in the loop here because this might have a bit of interaction with #1059 .

  9. added a commit that references this issue on Aug 1, 2023
  10. added a commit that references this issue on Jun 2, 2024
  11. added
    doneIssues whose closing PR is done but not yet merged (pending test re-run ok)
    on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    b4bbit-for-bitblockeranother issue/PR depends on this onedoneIssues whose closing PR is done but not yet merged (pending test re-run ok)good first issuesimple; good for first-time contributorstestingadditions or changes to tests

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions