Skip to content

Commit 72e8451

Browse files
authored
Merge pull request #3431 from samsrabin/b4b-dev-merge-20250822
ctsm5.3.071: b4b-dev merge 2025-08-22
2 parents a855d4e + 0f90c77 commit 72e8451

File tree

74 files changed

+3852
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3852
-349
lines changed

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,8 @@ cdf40d265cc82775607a1bf25f5f527bacc97405
7070
4ad46f46de7dde753b4653c15f05326f55116b73
7171
75db098206b064b8b7b2a0604d3f0bf8fdb950cc
7272
84609494b54ea9732f64add43b2f1dd035632b4c
73+
7eb17f3ef0b9829fb55e0e3d7f02e157b0e41cfb
74+
62d7711506a0fb9a3ad138ceceffbac1b79a6caa
75+
49ad0f7ebe0b07459abc00a5c33c55a646f1e7e0
76+
ac03492012837799b7111607188acff9f739044a
77+
d858665d799690d73b56bcb961684382551193f4
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""
2+
CTSM-specific test that first runs the set_paramfile tool and then ensures that CTSM does not fail
3+
using the just-generated parameter file
4+
"""
5+
6+
import os
7+
import sys
8+
import logging
9+
import re
10+
from CIME.SystemTests.system_tests_common import SystemTestsCommon
11+
12+
# In case we need to import set_paramfile later
13+
_CTSM_PYTHON = os.path.join(
14+
os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, "python"
15+
)
16+
sys.path.insert(1, _CTSM_PYTHON)
17+
18+
logger = logging.getLogger(__name__)
19+
20+
21+
class SETPARAMFILE(SystemTestsCommon):
22+
def __init__(self, case):
23+
"""
24+
initialize an object interface to the SMS system test
25+
"""
26+
SystemTestsCommon.__init__(self, case)
27+
28+
# Create out-of-the-box lnd_in to obtain paramfile
29+
case.create_namelists(component="lnd")
30+
31+
# Find the paramfile to modify
32+
lnd_in_path = os.path.join(self._get_caseroot(), "CaseDocs", "lnd_in")
33+
self._paramfile_in = None
34+
with open(lnd_in_path, "r", encoding="utf-8") as lnd_in:
35+
for line in lnd_in:
36+
paramfile_in = re.match(r" *paramfile *= *'(.*)'", line)
37+
if paramfile_in:
38+
self._paramfile_in = paramfile_in.group(1)
39+
break
40+
if not self._paramfile_in:
41+
raise RuntimeError(f"paramfile not found in {lnd_in_path}")
42+
43+
# Get the output file
44+
self.paramfile_out = os.path.join(self._get_caseroot(), "paramfile.nc")
45+
46+
# Define set_paramfile command
47+
self.set_paramfile_cmd = [
48+
"set_paramfile",
49+
"-i",
50+
self._paramfile_in,
51+
"-o",
52+
self.paramfile_out,
53+
# Change two parameters for one PFT
54+
"-p",
55+
"needleleaf_deciduous_boreal_tree",
56+
"rswf_min=0.35",
57+
"rswf_max=0.7",
58+
]
59+
60+
def build_phase(self, sharedlib_only=False, model_only=False):
61+
"""
62+
Run set_paramfile and then build the model
63+
"""
64+
65+
# Run set_paramfile.
66+
# build_phase gets called twice:
67+
# - once with sharedlib_only = True and
68+
# - once with model_only = True
69+
# Because we only need set_paramfile run once, we only do it for the sharedlib_only call.
70+
# We could also check for the existence of the set_paramfile outputs, but that might lead to
71+
# a situation where the user expects set_paramfile to be called but it's not. Better to run
72+
# unnecessarily (e.g., if you fixed some FORTRAN code and just need to rebuild).
73+
if sharedlib_only:
74+
self._run_set_paramfile()
75+
76+
# Do the build
77+
self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
78+
79+
def _run_set_paramfile(self):
80+
"""
81+
Run set_paramfile
82+
"""
83+
# Import set_paramfile. Do it here rather than at top because otherwise the import will
84+
# be attempted even during RUN phase.
85+
# pylint: disable=wrong-import-position,import-outside-toplevel
86+
from ctsm.param_utils.set_paramfile import main as set_paramfile
87+
88+
# Run set_paramfile
89+
sys.argv = self.set_paramfile_cmd
90+
set_paramfile()
91+
92+
# Append
93+
user_nl_clm_path = os.path.join(self._get_caseroot(), "user_nl_clm")
94+
with open(user_nl_clm_path, "a", encoding="utf-8") as user_nl_clm:
95+
user_nl_clm.write(f"paramfile = '{self.paramfile_out}'\n")

cime_config/config_pes.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,44 @@
20922092
</rootpe>
20932093
</pes>
20942094
</mach>
2095+
</grid>
2096+
<grid name="l%mpasa3p75">
2097+
<mach name="derecho">
2098+
<pes pesize="any" compset="any">
2099+
<comment>none</comment>
2100+
<ntasks>
2101+
<ntasks_atm>-80</ntasks_atm>
2102+
<ntasks_lnd>-80</ntasks_lnd>
2103+
<ntasks_rof>-80</ntasks_rof>
2104+
<ntasks_ice>-80</ntasks_ice>
2105+
<ntasks_ocn>-80</ntasks_ocn>
2106+
<ntasks_glc>-80</ntasks_glc>
2107+
<ntasks_wav>-80</ntasks_wav>
2108+
<ntasks_cpl>-80</ntasks_cpl>
2109+
<ntasks_lnd>-80</ntasks_lnd>
2110+
</ntasks>
2111+
<nthrds>
2112+
<nthrds_atm>1</nthrds_atm>
2113+
<nthrds_lnd>1</nthrds_lnd>
2114+
<nthrds_rof>1</nthrds_rof>
2115+
<nthrds_ice>1</nthrds_ice>
2116+
<nthrds_ocn>1</nthrds_ocn>
2117+
<nthrds_glc>1</nthrds_glc>
2118+
<nthrds_wav>1</nthrds_wav>
2119+
<nthrds_cpl>1</nthrds_cpl>
2120+
</nthrds>
2121+
<rootpe>
2122+
<rootpe_atm>0</rootpe_atm>
2123+
<rootpe_lnd>0</rootpe_lnd>
2124+
<rootpe_rof>0</rootpe_rof>
2125+
<rootpe_ice>0</rootpe_ice>
2126+
<rootpe_ocn>0</rootpe_ocn>
2127+
<rootpe_glc>0</rootpe_glc>
2128+
<rootpe_wav>0</rootpe_wav>
2129+
<rootpe_cpl>0</rootpe_cpl>
2130+
</rootpe>
2131+
</pes>
2132+
</mach>
20952133
</grid>
20962134
<grid name="l%0.125nldas2">
20972135
<mach name="any">

cime_config/config_tests.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ This defines various CTSM-specific system tests
175175
<HIST_N>$STOP_N</HIST_N>
176176
</test>
177177

178+
<test NAME="SETPARAMFILE">
179+
<DESC>Modify a copy of the paramfile and run with it.</DESC>
180+
<INFO_DBUG>1</INFO_DBUG>
181+
<DOUT_S>FALSE</DOUT_S>
182+
<CONTINUE_RUN>FALSE</CONTINUE_RUN>
183+
<REST_OPTION>never</REST_OPTION>
184+
<HIST_OPTION>$STOP_OPTION</HIST_OPTION>
185+
<HIST_N>$STOP_N</HIST_N>
186+
</test>
187+
178188
<!--
179189
SSP smoke CLM spinup test (only valid for CLM compsets with CLM45)
180190
do an initial spin test (setting CLM_ACCELERATED_SPINUP to on)

cime_config/testdefs/testlist_clm.xml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
aux_clm_mpi_serial: aux_clm tests using mpi-serial. Useful for redoing tests that failed due to https://github.com/ESCOMP/CTSM/issues/2916, after having replaced libraries/mpi-serial with a fresh copy.
1616
subset_data: Tests exercising the subset_data tool and running CTSM with its output
1717
decomp_init: Initialization tests specifically for examining the PE layout decomposition initialization
18+
uhr_decomp_init: Initialization tests at Ultra High Resolution - specifically for examining the PE layout decomposition initialization
1819
interim_restart: Tests having to do with interim restart capability.
1920
-->
2021
<testlist version="2.0">
@@ -4203,7 +4204,28 @@
42034204
</test>
42044205

42054206
<!-- decomp_init tests -->
4206-
<test name="SMS_Ln1_P86x1" grid="ne30pg3_ne30pg3_mt232" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4207+
<test name="SMS_D_Ln1_Mmpi-serial" grid="1x1_brazil" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4208+
<machines>
4209+
<machine name="derecho" compiler="intel" category="decomp_init"/>
4210+
<machine name="izumi" compiler="nag" category="decomp_init"/>
4211+
</machines>
4212+
<options>
4213+
<option name="wallclock">0:05:00</option>
4214+
<option name="comment">mpi-serial self tests with DEBUG</option>
4215+
</options>
4216+
</test>
4217+
<test name="SMS_D_Ln1" grid="f10_f10_mt232" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4218+
<machines>
4219+
<machine name="derecho" compiler="intel" category="decomp_init"/>
4220+
<machine name="derecho" compiler="gnu" category="decomp_init"/>
4221+
<machine name="izumi" compiler="nag" category="decomp_init"/>
4222+
</machines>
4223+
<options>
4224+
<option name="wallclock">0:05:00</option>
4225+
<option name="comment">Self tests with DEBUG on for f10</option>
4226+
</options>
4227+
</test>
4228+
<test name="SMS_Ln1_P86x1" grid="ne30pg3_ne30pg3_mt232" compset="I2000Clm45Sp" testmods="clm-for_testing_fastsetup_bypassrun">
42074229
<machines>
42084230
<machine name="derecho" compiler="intel" category="decomp_init"/>
42094231
</machines>
@@ -4212,7 +4234,7 @@
42124234
<option name="comment">Initialization test for ne30pg3 with "Large" layout</option>
42134235
</options>
42144236
</test>
4215-
<test name="SMS_Ln1_P43x1" grid="ne30pg3_ne30pg3_mt232" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4237+
<test name="SMS_Ln1_P43x1" grid="ne30pg3_ne30pg3_mt232" compset="I2000Clm45Sp" testmods="clm-for_testing_fastsetup_bypassrun">
42164238
<machines>
42174239
<machine name="derecho" compiler="intel" category="decomp_init"/>
42184240
</machines>
@@ -4221,7 +4243,7 @@
42214243
<option name="comment">Initialization test for ne30pg3 with "Medium" layout</option>
42224244
</options>
42234245
</test>
4224-
<test name="SMS_Ln1_P22x1" grid="ne30pg3_ne30pg3_mt232" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4246+
<test name="SMS_Ln1_P22x1" grid="ne30pg3_ne30pg3_mt232" compset="I2000Clm45Sp" testmods="clm-for_testing_fastsetup_bypassrun">
42254247
<machines>
42264248
<machine name="derecho" compiler="intel" category="decomp_init"/>
42274249
</machines>
@@ -4230,7 +4252,7 @@
42304252
<option name="comment">Initialization test for ne30pg3 with "Small" layout</option>
42314253
</options>
42324254
</test>
4233-
<test name="SMS_Ln1_PL" grid="ne120pg3_ne120pg3_mt13" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4255+
<test name="SMS_Ln1_PL" grid="ne120pg3_ne120pg3_mt13" compset="I2000Clm45Sp" testmods="clm-for_testing_fastsetup_bypassrun">
42344256
<machines>
42354257
<machine name="derecho" compiler="intel" category="decomp_init"/>
42364258
</machines>
@@ -4239,7 +4261,7 @@
42394261
<option name="comment">Initialization test for ne120pg3 with "Large" layout</option>
42404262
</options>
42414263
</test>
4242-
<test name="SMS_Ln1_PL" grid="mpasa15_mpasa15" compset="I2000Clm45Sp" testmods="clm-run_self_tests">
4264+
<test name="SMS_Ln1_PL" grid="mpasa15_mpasa15" compset="I2000Clm45Sp" testmods="clm-for_testing_fastsetup_bypassrun">
42434265
<machines>
42444266
<machine name="derecho" compiler="intel" category="decomp_init"/>
42454267
</machines>
@@ -4248,6 +4270,15 @@
42484270
<option name="comment">Initialization test for mpasa15 with "Large" layout</option>
42494271
</options>
42504272
</test>
4273+
<test name="SMS_Ln1" grid="mpasa3p75_mpasa3p75_mt13" compset="I2000Clm45Sp" testmods="clm-for_testing_fastsetup_bypassrun--clm-mpasa3p75">
4274+
<machines>
4275+
<machine name="derecho" compiler="intel" category="uhr_decomp_init"/>
4276+
</machines>
4277+
<options>
4278+
<option name="wallclock">0:15:00</option>
4279+
<option name="comment">Initialization test for mpasa3p75 default layout</option>
4280+
</options>
4281+
</test>
42514282

42524283
<test name="LGRAIN2_Ly1_P128x1" grid="f10_f10_mg37" compset="I1850Clm50BgcCrop" testmods="clm/ciso--clm/cropMonthOutput">
42534284
<machines>
@@ -4534,6 +4565,16 @@
45344565
</options>
45354566
</test>
45364567

4568+
<test name="SETPARAMFILE_Ld5" grid="f10_f10_mg37" compset="I1850Clm60BgcCrujra" testmods="clm/default">
4569+
<machines>
4570+
<machine name="derecho" compiler="gnu" category="aux_clm"/>
4571+
<machine name="derecho" compiler="gnu" category="clm_pymods"/>
4572+
</machines>
4573+
<options>
4574+
<option name="wallclock">00:20:00</option>
4575+
</options>
4576+
</test>
4577+
45374578
<test name="SMS_Ld5" grid="f10_f10_mg37" compset="IHistClm60BgcCrop" testmods="clm/default">
45384579
<machines>
45394580
<machine name="derecho" compiler="gnu" category="interim_restart"/>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The purpose of this testmod directory is to setup for running fast testing
2+
of initialization. So it bypasses the run phase and exits early.
3+
4+
We use cold start so that we can get through initialization faster,
5+
6+
I/O is turned off as much as possible.
7+
8+
And physics options that make the model run faster are used.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
./xmlchange CLM_FORCE_COLDSTART="on"
3+
4+
# We use this testmod in a _Ln1 test; this requires forcing the ROF coupling frequency to same frequency as DATM
5+
./xmlchange ROF_NCPL='$ATM_NCPL'
6+
7+
# Turn off ROF model when used with compsets that have them
8+
./xmlchange RTM_MODE='NULL'
9+
10+
# Turn MEGAN off to run faster
11+
./xmlchange CLM_BLDNML_OPTS='--no-megan' --append
12+
13+
# Use fast structure and NWP configuration for speed
14+
./xmlchange CLM_STRUCTURE="fast"
15+
./xmlchange CLM_CONFIGURATION="nwp"
16+
17+
# Restarts aren't allowed for these tests, and turn off CPL history
18+
# First change in env_test.xml, then in the standard one so it won't complain there
19+
./xmlchange --force REST_OPTION="never" --file env_test.xml
20+
./xmlchange --force HIST_OPTION="never" --file env_test.xml
21+
./xmlchange REST_OPTION="never"
22+
./xmlchange HIST_OPTION="never"
23+
24+
# Timer settings
25+
./xmlchange TIMER_DETAIL="2"
26+
./xmlchange SAVE_TIMING="TRUE"
27+
./xmlchange CHECK_TIMING="TRUE"
28+
./xmlchange ESMF_PROFILING_LEVEL="10"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
! Turn off history, restarts, and output
2+
hist_empty_htapes = .true.
3+
use_noio = .true.
4+
5+
! Turn off urban options, and only do urban in gridcells that are majority urban
6+
urban_hac = 'OFF'
7+
toosmall_urban = 98.0d00 ! Minimize urban in gridcells
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
! Settings currently required to run at the mpasa3p75 grid
2+
! urbantv files at that resolution and use a redistribution mapping
3+
4+
stream_fldfilename_urbantv = '$DIN_LOC_ROOT/lnd/clm2/urbandata/CTSM52_tbuildmax_OlesonFeddema_2020_mpasa3p75_fromf09_simyr1849-2106_c20240502.nc'
5+
stream_meshfile_urbantv = '$DIN_LOC_ROOT/lnd/clm2/urbandata/CTSM52_tbuildmax_Oleson_2020_mpasa3p75_ESMFmesh_cdf5_c202405021.nc'
6+
urbantvmapalgo = 'redist'
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
The purpose of this testmod directory is to trigger the runtime
2-
self-tests. This runs a suite of unit/integration tests.
1+
The purpose of this testmod directory is to trigger runtime
2+
initialization self-tests. This runs a set of unit/integration tests
3+
that apply at initialization.
34

4-
We use cold start so that we can get through initialization faster,
5-
since how we initialize the model is unimportant for these self-tests.
5+
We inherit the test-mod that sets up for testing and bypassing as much as possible for speed.
6+
7+
There are other self_tests that need to be exercised in the model time stepping
8+
and are done outside of these.

0 commit comments

Comments
 (0)