Skip to content

Commit

Permalink
[BROKEN] Merge tag 'ctsm5.3.019' into merge-b4bdev-20250116
Browse files Browse the repository at this point in the history
Includes merge conflicts in src/cpl/lilac/lnd_comp_esmf.F90 due to PR #2912.
  • Loading branch information
samsrabin committed Jan 16, 2025
2 parents 0ec2493 + 2f6b129 commit 6d1a0e0
Show file tree
Hide file tree
Showing 20 changed files with 552 additions and 284 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ d866510188d26d51bcd6d37239283db690af7e82
e096358c832ab292ddfd22dd5878826c7c788968
475831f0fb0e31e97f630eac4e078c886558b61c
fd5f177131d63d39e79a13918390bdfb642d781e
a51816e0de380300b69db9fc3e2c7fa83b267b64
# Ran SystemTests and python/ctsm through black python formatter
5364ad66eaceb55dde2d3d598fe4ce37ac83a93c
8056ae649c1b37f5e10aaaac79005d6e3a8b2380
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ fxDONOTUSEurl = https://github.com/ESCOMP/CISM-wrapper
[submodule "rtm"]
path = components/rtm
url = https://github.com/ESCOMP/RTM
fxtag = rtm1_0_80
fxtag = rtm1_0_84
fxrequired = ToplevelRequired
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
fxDONOTUSEurl = https://github.com/ESCOMP/RTM

[submodule "mosart"]
path = components/mosart
url = https://github.com/ESCOMP/MOSART
fxtag = mosart1.1.02
fxtag = mosart1.1.06
fxrequired = ToplevelRequired
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
fxDONOTUSEurl = https://github.com/ESCOMP/MOSART
Expand Down
210 changes: 210 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,214 @@
===============================================================
Tag name: ctsm5.3.019
Originator(s): olyson (Keith Oleson, UCAR/TSS)
Date: Tue 14 Jan 2025 02:46:11 PM MST
One-line Summary: Stop running 0th time step

Purpose and description of changes
----------------------------------
As with the last tag, this is also for consistency with CAM.

Contributors
------------
Bill Sacks. In the final steps, also slevis.

Significant changes to scientifically-supported configurations
--------------------------------------------------------------

Does this tag change answers significantly for any of the following physics configurations?
(Details of any changes will be given in the "Answer changes" section below.)

[Put an [X] in the box for any configuration with significant answer changes.]

[ ] clm6_0

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Bugs fixed
----------
List of CTSM issues fixed (include CTSM Issue # and description) [one per line]:
Fixes #925

Notes of particular relevance for developers:
---------------------------------------------
Caveats for developers (e.g., code that is duplicated that requires double maintenance):
Same or similar changes needed separately in clm, in mosart, and in rtm.

Changes to tests or testing:
FAIL RXCROPMATURITYSKIPGEN_Ld1097.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-cropMonthOutput RUN
I did not label this failure EXPECTED because the fix is planned for the next tag, ctsm5.3.020.

I resolved the izumi nag tests that failed to build (due to a bug in rtm and mosart) by introducing the bug-fix manually, as explained here:
https://github.com/ESCOMP/CTSM/pull/2084#issuecomment-2584164690
In ctsm5.3.020 we plan to update to the rtm/mosart tags that include the fix.

Testing summary:
----------------

[PASS means all tests PASS; OK means tests PASS other than expected fails.]

build-namelist tests (if CLMBuildNamelist.pm has changed):

derecho - PASS

python testing (if python code has changed; see instructions in python/README.md; document testing done):

derecho - PASS

regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):

derecho ----- OK
izumi ------- OK

mosart
derecho ----- OK
izumi ------- OK

rtm
derecho ----- OK

If the tag used for baseline comparisons was NOT the previous tag, note that here:
I repeated the rtm & mosart test-suites with mosart1.1.04 instead of 06 and rtm1_0_82 instead of 84 (all else the same) and compared against the new baselines mosart1.1.06-ctsm5.3.019 and rtm1_0_84-ctsm5.3.019. These gave b4b identical answers.

Answer changes
--------------

Changes answers relative to baseline: Yes

Summarize any changes to answers, i.e.,
- what code configurations: All
- what platforms/compilers: All
- nature of change: larger than roundoff/same climate

Caveat: We see diffs in mosart and cpl output that will be eliminated in ctsm5.3.020. They are discussed here:
https://github.com/ESCOMP/CTSM/pull/2838#issuecomment-2477608383
https://github.com/ESCOMP/MOSART/issues/103#issuecomment-2479679014

Other details
-------------
List any git submodules updated (cime, rtm, mosart, cism, fates, etc.):
rtm and mosart were already updated in the previous tag (ctsm5.3.018) to include the corresponding rtm and mosart tags

Pull Requests that document the changes (include PR ids):
https://github.com/ESCOMP/ctsm/pull/2084
https://github.com/ESCOMP/MOSART/pull/67
https://github.com/ESCOMP/RTM/pull/37

===============================================================
===============================================================
Tag name: ctsm5.3.018
Originator(s): slevis (Samuel Levis,UCAR/TSS,303-665-1310)
Date: Fri 10 Jan 2025 05:37:08 PM MST
One-line Summary: Change history time to be the middle of the time bounds

Purpose and description of changes
----------------------------------
Making the change to be consistent with CAM and to make history output more intuitive.

Significant changes to scientifically-supported configurations
--------------------------------------------------------------

Does this tag change answers significantly for any of the following physics configurations?
(Details of any changes will be given in the "Answer changes" section below.)

[Put an [X] in the box for any configuration with significant answer changes.]

[ ] clm6_0

[ ] clm5_1

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Bugs fixed
----------
List of CTSM issues fixed (include CTSM Issue # and description) [one per line]:
Partly addresses issue #1059

Notes of particular relevance for users
---------------------------------------
Caveats for users (e.g., need to interpolate initial conditions):
The history time variable now equals the middle of the time bounds.
Instantaneous history tapes now do not include time bounds.
Mixed history tapes do not change the treatment of instantaneous fields or move them to separate tapes, yet.

Notes of particular relevance for developers:
---------------------------------------------
Caveats for developers (e.g., code that is duplicated that requires double maintenance):
Same changes are needed separately in clm, in mosart, and in rtm.

Changes to tests or testing:
This tag introduces changes to the mosart/rtm testlists.

FAIL RXCROPMATURITYSKIPGEN_Ld1097.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-cropMonthOutput RUN
I did not label this failure EXPECTED because the fix comes in later in this series of "history" tags, in particular ctsm5.3.020.

I resolved the izumi nag tests that failed to build (due to a bug in rtm and mosart) by introducing the bug-fix manually, as explained here:
https://github.com/ESCOMP/CTSM/pull/2084#issuecomment-2584164690
In the next tag we expect to update to the rtm/mosart tags that include the fix.

Testing summary:
----------------

[PASS means all tests PASS; OK means tests PASS other than expected fails.]

build-namelist tests

derecho - PASS

python testing (if python code has changed; see instructions in python/README.md; document testing done):

derecho - PASS

regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):

derecho ----- OK
izumi ------- OK

mosart
derecho ----- OK
izumi ------- OK

rtm
derecho ----- OK

Answer changes
--------------

Changes answers relative to baseline: Only time variable, plus read caveat

Summarize any changes to answers, i.e.,
- what code configurations: all
- what platforms/compilers: all
- nature of change: only the time variable

Caveat: We see diffs in mosart and cpl output that will be eliminated later in this series of "history" tags, in particular ctsm5.3.020. They are discussed here:
https://github.com/ESCOMP/CTSM/pull/2838#issuecomment-2477608383
https://github.com/ESCOMP/MOSART/issues/103#issuecomment-2479679014

Other details
-------------
List any git submodules updated (cime, rtm, mosart, cism, fates, etc.):
rtm, mosart (see related note in ctsm5.3.019)

Pull Requests that document the changes (include PR ids):
https://github.com/ESCOMP/ctsm/pull/2838
https://github.com/ESCOMP/MOSART/pull/70
https://github.com/ESCOMP/RTM/issues/54
https://github.com/ESCOMP/MOSART/pull/106
https://github.com/ESCOMP/RTM/pull/39

===============================================================
===============================================================
Tag name: ctsm5.3.017
Originator(s): slevis (Samuel Levis,UCAR/TSS,303-665-1310)
Date: Thu 09 Jan 2025 11:56:43 AM MST
Expand Down
2 changes: 2 additions & 0 deletions doc/ChangeSum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Tag Who Date Summary
============================================================================================================================
ctsm5.3.019 olyson 01/14/2025 Stop running 0th time step
ctsm5.3.018 slevis 01/10/2025 Change history time to be the middle of the time bounds
ctsm5.3.017 slevis 01/09/2025 Merge tmp-241219 branch to master
tmp-241219.n03.ctsm5.3.016 01/09/2025 Bug fix for izumi nag tests to pass (slevis)
tmp-241219.n02.ctsm5.3.016 01/08/2025 FATES hydro test update (glemieux)
Expand Down
34 changes: 30 additions & 4 deletions python/ctsm/crop_calendars/cropcal_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,7 @@ def import_output(
)

# Convert time axis to integer year, saving original as 'cftime'
this_ds_gs = this_ds_gs.assign_coords(
{"cftime": this_ds["time_bounds"].isel({"hist_interval": 0})}
)
this_ds_gs = this_ds_gs.assign_coords({"time": [t.year for t in this_ds_gs["cftime"].values]})
this_ds_gs = convert_time_to_int_year(filename, this_ds, this_ds_gs)

# Get number of harvests
this_ds_gs["NHARVESTS"] = (this_ds_gs["GDDHARV_PERHARV"] > 0).sum(dim="mxharvests")
Expand All @@ -458,6 +455,35 @@ def import_output(
return this_ds_gs, any_bad


def convert_time_to_int_year(filename, this_ds, this_ds_gs):
"""
Convert time axis to integer year, saving original as 'cftime'
"""
if "time_bounds" in this_ds:
# Always true before PR #2838, when even files with all instantaneous variables got
# time_bounds saved. After that PR (and before the segregation of instantaneous and other
# variables onto separate files), files with an instantaneous variable first in their list
# do not get time_bounds saved.
this_ds_gs = this_ds_gs.assign_coords(
{"cftime": this_ds["time_bounds"].isel({"hist_interval": 0})}
)
this_ds_gs = this_ds_gs.assign_coords(
{"time": [t.year for t in this_ds_gs["cftime"].values]}
)
elif this_ds["time"].attrs["long_name"] == "time at end of time step":
# This is an "instantaneous file."
this_ds_gs = this_ds_gs.assign_coords({"cftime": this_ds["time"]})
this_ds_gs = this_ds_gs.assign_coords(
{"time": [t.year - 1 for t in this_ds_gs["cftime"].values]}
)
else:
raise RuntimeError(
f"{filename} is neither an instantaneous nor a combined/non-instantaneous file."
)

return this_ds_gs


def handle_zombie_crops(this_ds):
"""
When doing transient runs, it's somehow possible for crops in newly-active patches to be
Expand Down
16 changes: 9 additions & 7 deletions python/ctsm/crop_calendars/generate_gdds_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def error(logger, string):
"""
Simultaneously print ERROR messages to console and to log file
"""
print(string)
logger.error(string)
raise RuntimeError(string)

Expand Down Expand Up @@ -271,7 +272,7 @@ def import_and_process_1yr(
else:
chunks = None

# Get h2 file (list)
# Get h1 file (list)
h1_pattern = os.path.join(indir, "*h1.*.nc")
h1_filelist = glob.glob(h1_pattern)
if not h1_filelist:
Expand Down Expand Up @@ -551,13 +552,14 @@ def import_and_process_1yr(
log(logger, " Importing accumulated GDDs...")
clm_gdd_var = "GDDACCUM"
my_vars = [clm_gdd_var, "GDDHARV"]
pattern = os.path.join(indir, f"*h2.{this_year-1}-01-01*.nc")
h2_files = glob.glob(pattern)
if not h2_files:
pattern = os.path.join(indir, f"*h2.{this_year-1}-01-01*.nc.base")
patterns = [f"*h2.{this_year-1}-01*.nc", f"*h2.{this_year-1}-01*.nc.base"]
for p in patterns:
pattern = os.path.join(indir, p)
h2_files = glob.glob(pattern)
if not h2_files:
error(logger, f"No files found matching pattern '*h2.{this_year-1}-01-01*.nc(.base)'")
if h2_files:
break
if not h2_files:
error(logger, f"No files found matching patterns: {patterns}")
h2_ds = import_ds(
h2_files,
my_vars=my_vars,
Expand Down
14 changes: 1 addition & 13 deletions src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -392,19 +392,7 @@ subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
soilstate_inst, temperature_inst, atm2lnd_inst, wateratm2lndbulk_inst, cnveg_state_inst, &
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst)

! BACKWARDS_COMPATIBILITY(wjs, 2022-02-03) Old restart files generated at the end
! of the year can indicate that a crop was panted on Jan 1, because that used to be
! the time given to the last time step of the year. This would cause problems if we
! ran CropPhenology in time step 0, because now time step 0 is labeled as Dec 31,
! so CropPhenology would see the crop as having been planted 364 days ago, and so
! would want to harvest this newly-planted crop. To avoid this situation, we avoid
! calling CropPhenology on time step 0.
!
! This .not. is_first_step() condition can be removed either when we can rely on
! all restart files having been generated with
! https://github.com/ESCOMP/CTSM/issues/1623 resolved, or we stop having a time
! step 0 (https://github.com/ESCOMP/CTSM/issues/925).
if (num_pcropp > 0 .and. .not. is_first_step()) then
if (num_pcropp > 0) then
call CropPhenology(num_pcropp, filter_pcropp, &
waterdiagnosticbulk_inst, temperature_inst, crop_inst, canopystate_inst, cnveg_state_inst, &
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/CNVegetationFacade.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ subroutine EndOfTimeStepVegDynamics(this, bounds, num_natvegp, filter_natvegp, &
! Call dv (dynamic vegetation) at last time step of year

call t_startf('d2dgvm')
if (is_end_curr_year() .and. .not. is_first_step()) then
if (is_end_curr_year()) then

! Get date info. kyr is used in lpj(). At end of first year, kyr = 2.
call get_curr_date(yr, mon, day, sec)
Expand Down Expand Up @@ -1337,7 +1337,7 @@ subroutine WriteHistory(this, bounds)

! Write to CNDV history buffer if appropriate
if (use_cndv) then
if (is_end_curr_year() .and. .not. is_first_step()) then
if (is_end_curr_year()) then
call t_startf('clm_drv_io_hdgvm')
call CNDVHist( bounds, this%dgvs_inst )
if (masterproc) write(iulog,*) 'Annual CNDV calculations are complete'
Expand Down
2 changes: 1 addition & 1 deletion src/biogeochem/CropType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ subroutine CropIncrementYear (this, num_pcropp, filter_pcropp)
! Update nyrs when it's the end of the year (unless it's the very start of the
! run). This assumes that, if this patch is active at the end of the year, then it was
! active for the whole year.
if ((kmo == 1 .and. kda == 1 .and. mcsec == 0) .and. .not. is_first_step()) then
if ((kmo == 1 .and. kda == 1 .and. mcsec == 0)) then
do fp = 1, num_pcropp
p = filter_pcropp(fp)

Expand Down
2 changes: 1 addition & 1 deletion src/biogeochem/dynCNDVMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ subroutine dynCNDV_interp( bounds, dgvs_inst)
patch%wtcol(p) = dgvs_inst%fpcgrid_patch(p) + &
wt1 * (dgvs_inst%fpcgridold_patch(p) - dgvs_inst%fpcgrid_patch(p))

if (mon==1 .and. day==1 .and. sec==dtime .and. nstep>0) then
if (mon==1 .and. day==1 .and. sec==dtime) then
dgvs_inst%fpcgridold_patch(p) = dgvs_inst%fpcgrid_patch(p)
end if
end if
Expand Down
Loading

0 comments on commit 6d1a0e0

Please sign in to comment.