Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make separate instantaneous and non-inst. history tapes #2445

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

slevis-lmwg
Copy link
Contributor

@slevis-lmwg slevis-lmwg commented Mar 28, 2024

Description of changes

I started from issue #1059 and PR #2019 and am restarting here. From closed PR #2019 I preserved a few things:

  • If avgflag /= 'I', time_bounds is present and time = mid of time_bounds
  • Some long_name changes
  • Treating avgflag as a tape (not field) trait for 'I' and 'L' tapes

In this PR we also intend to split all history tapes into instantaneous and non-instantaneous. The CAM group accomplished this in PR ESCOMP/CAM#903 and we plan to maintain consistency in the appearance of CLM and CAM history files.

UPDATE
Due to higher priority, changing "time" to equal the middle of time_bounds will now get done in
#2838
ESCOMP/MOSART#106
ESCOMP/RTM#39

Specific notes

Contributors other than yourself, if any:
@ekluzek @billsacks

CTSM Issues Fixed (include github issue #):
Fixes #1059

Are answers expected to change (and if so in what way)? No

Any User Interface Changes (namelist or namelist defaults changes)?
We intend to split all history tapes into instantaneous and non-instantaneous.

...and other mods that I'm preserving from closed PR ESCOMP#2019, such as
- changes to long_names and
- treating avgflag as a tape (not field) trait for 'I' and 'L' tapes
@slevis-lmwg slevis-lmwg self-assigned this Mar 28, 2024
@slevis-lmwg slevis-lmwg added enhancement new capability or improved behavior of existing capability priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations labels Mar 29, 2024
@slevis-lmwg
Copy link
Contributor Author

This far I have tried one test:
ERP_D_P48x1.f10_f10_mg37.IHistClm51Bgc.izumi_nag.clm-decStart
The test completes as expected and shows different answers from dev175 only for the "time" variable.

@wwieder wwieder added this to the CESM3 Answer changing freeze milestone Jun 20, 2024
@wwieder
Copy link
Contributor

wwieder commented Oct 16, 2024

Conceptually, this seems like a good idea. Practically, this seems like a heavy lift.
I wonder how high a priority it should be for the CESM project and the CLM team?
How critical is this kind of consistency for CESM3?
@dlawrenncar and @briandobbins, could you weigh in here?
@billsacks and @phillips-ad, I think you've thought more about this too?

@phillips-ad
Copy link

I think that consistency in the component output of CESM3 is quite important from a user's standpoint. CTSM would be an outlier amongst the 4 major components if these changes were not implemented. Looking at the project page, these changes have already been put into CAM and CICE. MOM came with these settings out of the box. @slevis-lmwg has a couple of pull requests with these changes for MOSART and RTM. I am a bit unclear where CISM is on implementing this. The only component that I know of that will likely not be implementing this is WW.

@billsacks
Copy link
Member

I started to write a reply but @phillips-ad beat me to it. The critical piece of this is fixing time values for time-averaged fields so that the time is in the middle of the averaging period instead of at the end. As @phillips-ad says, it is likely to be particularly confusing if CTSM (and the river components) differs from other components in this respect. The separation of instantaneous from time-averaged fields is not a critical piece of this, but seemed like the best way to support having correct time values for both time-averaged fields and instantaneous fields.

@slevis-lmwg
Copy link
Contributor Author

I started to write a reply but @phillips-ad beat me to it. The critical piece of this is fixing time values for time-averaged fields so that the time is in the middle of the averaging period instead of at the end. As @phillips-ad says, it is likely to be particularly confusing if CTSM (and the river components) differs from other components in this respect. The separation of instantaneous from time-averaged fields is not a critical piece of this, but seemed like the best way to support having correct time values for both time-averaged fields and instantaneous fields.

@billsacks I find the distinction in priority between the "middle of averaging period" task and the "separating instantaneous and non" task very helpful, because the former will take me a few days at most, while the latter will take me a few weeks at least.

@billsacks
Copy link
Member

I find the distinction in priority between the "middle of averaging period" task and the "separating instantaneous and non" task very helpful, because the former will take me a few days at most, while the latter will take me a few weeks at least.

Thanks, that's good to know, @slevis-lmwg . I'm curious what the plan is, then, for instantaneous fields? Will you just let the time be incorrect for those fields for now?

@phillips-ad do you agree that getting time correct for the time-averaged fields is the high priority thing here even if instantaneous fields aren't handled ideally for now?

@phillips-ad
Copy link

Yes I 100% agree, getting the time set to the middle of the averaging period for time-averaged fields is the higher priority.

@samsrabin
Copy link
Collaborator

Just wanted to add: Separating instantaneous and time-averaged fields will probably be an issue for #2061, which adds a namelist option to enable all our history fields and put them all on the h0 file. Depending on which PR comes in first, we'll have to think about how we want to handle that.

@slevis-lmwg
Copy link
Contributor Author

Just wanted to add: Separating instantaneous and time-averaged fields will probably be an issue for #2061, which adds a namelist option to enable all our history fields and put them all on the h0 file. Depending on which PR comes in first, we'll have to think about how we want to handle that.

Thank you for pointing this out @samsrabin

@slevis-lmwg
Copy link
Contributor Author

Based on the recent conversation here, I have opened a new PR #2838 that has the same starting point as this one (#2445). The new PR will not make separate instantaneous and non-instantaneous history tapes.

@slevis-lmwg slevis-lmwg changed the title Make separate instantaneous and non-inst. history tapes; for the latter set time = mid of time_bounds Make separate instantaneous and non-inst. history tapes Oct 18, 2024
@slevis-lmwg slevis-lmwg removed the priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations label Oct 18, 2024
@ekluzek
Copy link
Collaborator

ekluzek commented Oct 23, 2024

Thanks, that's good to know, @slevis-lmwg . I'm curious what the plan is, then, for instantaneous fields? Will you just let the time be incorrect for those fields for now?

@billsacks

Yes, we will let the instantaneous fields be incorrect to start with. And then a later more involved change will fix that.

I like the way that @samsrabin framed this when we discussed this. Right now "I" fields are correct, but "A" fields are incorrect. But, we care more about "A" fields (there's more of them output and they are the standard for most things) so getting them corrected at the expense of "I" fields is an improvement.

Reduce outputs from matrixcnOn tests

slevis resolved conflicts:
src/main/histFileMod.F90
@slevis-lmwg

This comment was marked as resolved.

@samsrabin
Copy link
Collaborator

As part of work on #2838, I've added:

  • Code in python/ctsm/crop_calendars/ to handle either instantaneous or non-inst. tapes
  • RXCROPMATURITYINST and RXCROPMATURITYSKIPGENINST SystemTests, to test things when a certain tape is forced to be instantaneous.

As part of this PR, the python code can be simplified to remove the non-instantaneous tape handling (where there's an option for both). Those new SystemTests can also be removed.

Bring in several fixes for testing in the previous cesm3_0_beta03/04 tags

Fix a list of issues mostly for testing that came in with the cesm3_0_beta03 and cesm3_0_beta04 tags
for the science "chill" deadline bringing in the baseline science capabilities needed for the cesm3_0 release.

List of things:

- New polarcap grid
- Fix use_init_interp for several resolutions that had problems
- Remove clm5_1 physics option
- Newly needed surface datasets added to auto build in Makefile for mksurfdata_esmf
- Fix several individual tests that were failing
- Update to submodules to ones roughly based on cesm3_0_beta04
- Add graceful error checking to the FATES parameter file tests that will get it working in some cases
@@ -49,6 +49,7 @@ module histFileMod
integer , public, parameter :: scale_type_strlen = 32 ! maximum number of characters for scale types
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
integer , public, parameter :: scale_type_strlen = 32 ! maximum number of characters for scale types
integer , private, parameter :: scale_type_strlen = 32 ! maximum number of characters for scale types
  1. As far as I can tell this parameter could be declared private.
  2. The 3 public parameters above it get used outside of histFileMod.
  3. In the context of this PR, do I need to worry about the corresponding section of code in src/utils/clmfates_interfaceMod.F90 which looks at fincl statements for FATES vars? Follow up.

@@ -402,6 +412,7 @@ subroutine hist_printflds()
! the CTSM's web-based documentation.

! First sort the list to be in alphabetical order
! TODO Is t = 1 argument needed?
call sort_hist_list(1, nallhistflds, allhistfldlist)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
call sort_hist_list(1, nallhistflds, allhistfldlist)
call sort_hist_list(nallhistflds, allhistfldlist)

As far as I can tell, the t = 1 argument and later the plain t argument serve no purpose in subroutine sort_hist_list.

@slevis-lmwg
Copy link
Contributor Author

slevis-lmwg commented Dec 19, 2024

I got brave and submitted a test:
SMS_D.1x1_brazil.I2000Clm60Sp.derecho_gnu

See errors in the bld.log:
/glade/derecho/scratch/slevis/SMS_D.1x1_brazil.I2000Clm60Sp.derecho_gnu.20241219_160820_coctcl/bld/lnd.bldlog.241219-160827

This commit does not resolve all the errors
@slevis-lmwg
Copy link
Contributor Author

slevis-lmwg commented Dec 28, 2024

These three tests finish successfully, though I have not started looking at history output:

SMS_D.1x1_brazil.I2000Clm60Sp.derecho_gnu
SMS_D.1x1_brazil.I2000Clm60BgcCrop.derecho_gnu
SMS_D.1x1_brazil.I2000Clm60BgcCrop.derecho_gnu.clm-output_crop_highfreq

This longer test
SMS_D_Lm2.1x1_brazil.I2000Clm60BgcCrop.derecho_gnu.clm-output_crop_highfreq
fails with
ERROR: 0 NetCDF: Not a valid ID err_num = -33
from what I can tell while writing
current time sample to local history file ./SMS_D_Lm2.1x1_brazil.I2000Clm60BgcCrop.derecho_gnu.clm-output_crop_highfreq.20241227_173328_jlalex.clm2.h01.2000-01.nc at nstep = 1488 for history time interval beginning at 0. and ending at 31.

(See write-statements in latest test in /glade/derecho/scratch/slevis)

This Lm2 test passed here:
/glade/derecho/scratch/slevis/SMS_D_Lm2.1x1_brazil.I2000Clm60BgcCrop.derecho_gnu.clm-output_crop_highfreq.20250102_172648_o6z3me/run
HOWEVER, comparing the clm2.h01 and clm2.h02 files, the former seems correct (though I have not compared to a baseline) but the second is incorrect. I may want to look into adding the "file" dimension to time and/or the list of fields...

@slevis-lmwg
Copy link
Contributor Author

The same Lm2 test continues to pass with the latest commits AND it correctly separated an 'I' field from the rest (this may be the only default active 'I' field). Time-related fields also look correct but their metadata appear wrong...

@slevis-lmwg
Copy link
Contributor Author

slevis-lmwg commented Jan 4, 2025

The latest problem that I have spotted:
The 'I' field that appears in h0i (as it should), continues to also appear in h0a...

UPDATE

  1. The history field lists seem ok in the lnd.log but somehow the 'I' field (SNOW_PERSISTENCE) shows up in h0a. Why?
  2. The history field lists seem to include h0, h1, h2, ... in the lnd.log, yet a later comment states that we will get only 1 tape. Why?

NEXT

  1. I have added new write statements but have not tested them. Also, does (1) possibly come in with the call hfields_write?
  2. nflds must have the wrong value in line 1001 for ntapes to end up equal to 1. I now think ntapes needs to be dimensioned by maxsplitfiles OR (preferred?) line 1001 may need to say
    if (any(tape(t)%nflds(:)) > 0) then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new capability or improved behavior of existing capability
Projects
Status: Stalled (needs review, blocked etc.)
Status: Todo
6 participants