Skip to content

Commit c6c6cad

Browse files
committed
Add SUBSETDATAREGION SystemTest.
Runs subset_data region tool to extract a six-gridcell region, then runs CTSM on the outputs.
1 parent fb569f1 commit c6c6cad

File tree

9 files changed

+93
-25
lines changed

9 files changed

+93
-25
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ fxDONOTUSEurl = https://github.com/ESCOMP/CMEPS.git
9191

9292
[submodule "cdeps"]
9393
path = components/cdeps
94-
url = https://github.com/ESCOMP/CDEPS.git
95-
fxtag = cdeps1.0.75
94+
url = https://github.com/samsrabin/CDEPS.git
95+
fxtag = 304d112e23019579013d08e57a463334ac8cac8f # cx-length-filenames: Use CX-length filenames for all *_comp_nuopc.F90.
9696
fxrequired = ToplevelRequired
9797
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
9898
fxDONOTUSEurl = https://github.com/ESCOMP/CDEPS.git

cime_config/SystemTests/subsetdata.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,20 @@ def build_phase(self, sharedlib_only=False, model_only=False):
5353
# pylint: disable=wrong-import-position,import-outside-toplevel
5454
from ctsm.subset_data import main as subset_data
5555

56-
# Run the tool
57-
sys.argv = self.subset_data_cmd
58-
subset_data()
56+
# Run the tool, if not already run, and apply usermods
57+
if not os.path.exists(self.usermods_dir):
58+
sys.argv = self.subset_data_cmd
59+
subset_data()
5960

60-
# Required so that CTSM doesn't fail
61-
user_nl_clm_path = os.path.join(self.usermods_dir, "user_nl_clm")
62-
with open(user_nl_clm_path, "a", encoding="utf-8") as user_nl_clm:
63-
user_nl_clm.write("\ncheck_dynpft_consistency = .false.")
61+
# Required so that CTSM doesn't fail
62+
user_nl_clm_path = os.path.join(self.usermods_dir, "user_nl_clm")
63+
with open(user_nl_clm_path, "a", encoding="utf-8") as user_nl_clm:
64+
user_nl_clm.write("\ncheck_dynpft_consistency = .false.\n")
6465

65-
# Apply the user mods
66-
self._case.flush(flushall=True)
67-
apply_user_mods(self._get_caseroot(), self.usermods_dir)
68-
self._case.read_xml()
66+
# Apply the user mods
67+
self._case.flush(flushall=True)
68+
apply_user_mods(self._get_caseroot(), self.usermods_dir)
69+
self._case.read_xml()
6970

7071
# Do the build
7172
super().build_phase(sharedlib_only, model_only)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
CTSM-specific test that first runs the subset_data region tool and then ensures
3+
that CTSM does not fail using the just-generated input files
4+
"""
5+
6+
from subsetdata import SUBSETDATASHARED
7+
8+
9+
class SUBSETDATAREGION(SUBSETDATASHARED):
10+
def __init__(self, case):
11+
"""
12+
initialize an object interface to the SMS system test
13+
"""
14+
15+
lat1 = -9
16+
lat2 = -7
17+
lon1 = 291
18+
lon2 = 293
19+
20+
# Don't need to include things that are added during SUBSETDATASHARED.__init__()
21+
subset_data_cmd = [
22+
"tools/site_and_regional/subset_data",
23+
"region",
24+
"--lat1",
25+
str(lat1),
26+
"--lat2",
27+
str(lat2),
28+
"--lon1",
29+
str(lon1),
30+
"--lon2",
31+
str(lon2),
32+
"--create-mesh",
33+
"--create-domain",
34+
"--create-surface",
35+
"--crop",
36+
"--create-landuse",
37+
"--surf-year",
38+
"1850",
39+
]
40+
41+
super().__init__(case, subset_data_cmd)

cime_config/config_tests.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ This defines various CTSM-specific system tests
3636
</test>
3737

3838
<test NAME="SUBSETDATAPOINT">
39-
<DESC>Run CTSM with files generated by the subset_data tool</DESC>
39+
<DESC>Run CTSM with files generated by the subset_data point tool</DESC>
40+
<INFO_DBUG>1</INFO_DBUG>
41+
<DOUT_S>FALSE</DOUT_S>
42+
<CONTINUE_RUN>FALSE</CONTINUE_RUN>
43+
<REST_OPTION>never</REST_OPTION>
44+
<HIST_OPTION>$STOP_OPTION</HIST_OPTION>
45+
<HIST_N>$STOP_N</HIST_N>
46+
</test>
47+
48+
<test NAME="SUBSETDATAREGION">
49+
<DESC>Run CTSM with files generated by the subset_data region tool</DESC>
4050
<INFO_DBUG>1</INFO_DBUG>
4151
<DOUT_S>FALSE</DOUT_S>
4252
<CONTINUE_RUN>FALSE</CONTINUE_RUN>

cime_config/testdefs/testlist_clm.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
rxcropmaturity: Short tests to be run during development related to prescribed crop calendars
1414
matrixcn: Tests exercising the matrix-CN capability
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.
16+
subset_data: Tests exercising the subset_data tool and running CTSM with its output
1617
-->
1718
<testlist version="2.0">
1819
<test name="ERI_D_Ld9" grid="f10_f10_mg37" compset="I1850Clm60Bgc" testmods="clm/default">
@@ -4061,10 +4062,25 @@
40614062
<machine name="derecho" compiler="intel" category="aux_clm"/>
40624063
<machine name="derecho" compiler="intel" category="aux_clm_mpi_serial"/>
40634064
<machine name="derecho" compiler="intel" category="clm_pymods"/>
4065+
<machine name="derecho" compiler="intel" category="subset_data"/>
40644066
</machines>
40654067
<options>
40664068
<option name="wallclock">00:20:00</option>
4067-
<option name="comment">Smoke test that first runs the subset_data tool and then ensures that CTSM does not fail using the just-generated user mods.</option>
4069+
<option name="comment">Smoke test that first runs the subset_data point tool and then ensures that CTSM does not fail using the just-generated user mods.</option>
4070+
<option name="comment">This test invokes python code, so it should be run whenever changing python code (in addition to being run as part of aux_clm).</option>
4071+
</options>
4072+
</test>
4073+
4074+
<test name="SUBSETDATAREGION_Ld5_D_Mmpi-serial" grid="CLM_USRDAT" compset="I2000Clm60BgcCropCrujra" testmods="clm-default">
4075+
<machines>
4076+
<machine name="derecho" compiler="intel" category="aux_clm"/>
4077+
<machine name="derecho" compiler="intel" category="aux_clm_mpi_serial"/>
4078+
<machine name="derecho" compiler="intel" category="clm_pymods"/>
4079+
<machine name="derecho" compiler="intel" category="subset_data"/>
4080+
</machines>
4081+
<options>
4082+
<option name="wallclock">00:20:00</option>
4083+
<option name="comment">Smoke test that first runs the subset_data regiontool and then ensures that CTSM does not fail using the just-generated user mods.</option>
40684084
<option name="comment">This test invokes python code, so it should be run whenever changing python code (in addition to being run as part of aux_clm).</option>
40694085
</options>
40704086
</test>

python/ctsm/run_sys_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def _check_py_env(test_attributes):
750750
raise ModuleNotFoundError("modify_fsurdat" + err_msg) from err
751751

752752
# Check requirements for using subset_data Python module, if needed
753-
subset_data_users = ["SUBSETDATAPOINT"]
753+
subset_data_users = ["SUBSETDATAPOINT", "SUBSETDATAREGION"]
754754
if any(any(u in t for u in subset_data_users) for t in test_attributes):
755755
try:
756756
import ctsm.subset_data

src/dyn_subgrid/dynFileMod.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module dynFileMod
77
!
88
! !USES:
99
use shr_log_mod , only : errMsg => shr_log_errMsg
10+
use clm_varctl , only : fname_len
1011
use dynTimeInfoMod , only : time_info_type, year_position_type
1112
use ncdio_pio , only : file_desc_t, ncd_pio_openfile, ncd_inqdid, ncd_inqdlen, ncd_io
1213
use abortutils , only : endrun
@@ -56,7 +57,7 @@ type(dyn_file_type) function constructor(filename, year_position)
5657
type(year_position_type) , intent(in) :: year_position
5758
!
5859
! !LOCAL VARIABLES:
59-
character(len=256) :: locfn ! local file name
60+
character(len=fname_len) :: locfn ! local file name
6061
integer :: ier ! error code
6162
integer :: ntimes ! number of time samples
6263
integer :: varid ! netcdf variable ID

src/main/surfrdMod.F90

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module surfrdMod
1515
use clm_varcon , only : grlnd
1616
use clm_varctl , only : iulog
1717
use clm_varctl , only : use_cndv, use_crop, use_fates
18+
use clm_varctl , only : fname_len
1819
use surfrdUtilsMod , only : check_sums_equal_1, apply_convert_ocean_to_land, collapse_crop_types
1920
use surfrdUtilsMod , only : collapse_to_dominant, collapse_crop_var, collapse_individual_lunits
2021
use ncdio_pio , only : file_desc_t, var_desc_t, ncd_pio_openfile, ncd_pio_closefile
@@ -233,7 +234,7 @@ subroutine surfrd_get_data (begg, endg, ldomain, lfsurdat, lhillslope_file, actu
233234
character(len=*), intent(in) :: lhillslope_file ! hillslope dataset filename
234235
!
235236
! !LOCAL VARIABLES:
236-
character(len=256):: locfn ! local file name
237+
character(len=fname_len) :: locfn ! local file name
237238
integer, parameter :: n_dom_urban = 1 ! # of dominant urban landunits
238239
type(file_desc_t) :: ncid ! netcdf id for lfsurdat
239240
type(file_desc_t) :: ncid_hillslope ! netcdf id for lhillslope_file
@@ -359,7 +360,7 @@ subroutine surfrd_get_num_patches (lfsurdat, actual_maxsoil_patches, actual_nump
359360

360361
!
361362
! !LOCAL VARIABLES:
362-
character(len=256):: locfn ! local file name
363+
character(len=fname_len) :: locfn ! local file name
363364
type(file_desc_t) :: ncid ! netcdf file id
364365
integer :: dimid ! netCDF dimension id
365366
logical :: cft_dim_exists ! dimension exists on dataset
@@ -427,7 +428,7 @@ subroutine surfrd_get_nlevurb (lfsurdat, actual_nlevurb)
427428
integer, intent(out) :: actual_nlevurb ! nlevurb from surface dataset
428429
!
429430
! !LOCAL VARIABLES:
430-
character(len=256):: locfn ! local file name
431+
character(len=fname_len) :: locfn ! local file name
431432
type(file_desc_t) :: ncid ! netcdf file id
432433
integer :: dimid ! netCDF dimension id
433434
character(len=32) :: subname = 'surfrd_get_nlevurb' ! subroutine name
@@ -1153,7 +1154,6 @@ subroutine surfrd_lakemask(begg, endg)
11531154
! !USES:
11541155
use clm_instur , only : pct_lake_max
11551156
use dynSubgridControlMod , only : get_flanduse_timeseries
1156-
use clm_varctl , only : fname_len
11571157
use fileutils , only : getfil
11581158
!
11591159
! !ARGUMENTS:
@@ -1162,7 +1162,7 @@ subroutine surfrd_lakemask(begg, endg)
11621162
!
11631163
! !LOCAL VARIABLES:
11641164
type(file_desc_t) :: ncid_dynuse ! netcdf id for landuse timeseries file
1165-
character(len=256) :: locfn ! local file name
1165+
character(len=fname_len) :: locfn ! local file name
11661166
character(len=fname_len) :: fdynuse ! landuse.timeseries filename
11671167
logical :: readvar
11681168
!
@@ -1208,7 +1208,6 @@ subroutine surfrd_urbanmask(begg, endg)
12081208
! !USES:
12091209
use clm_instur , only : pct_urban_max
12101210
use dynSubgridControlMod , only : get_flanduse_timeseries
1211-
use clm_varctl , only : fname_len
12121211
use fileutils , only : getfil
12131212
!
12141213
! !ARGUMENTS:
@@ -1217,7 +1216,7 @@ subroutine surfrd_urbanmask(begg, endg)
12171216
!
12181217
! !LOCAL VARIABLES:
12191218
type(file_desc_t) :: ncid_dynuse ! netcdf id for landuse timeseries file
1220-
character(len=256) :: locfn ! local file name
1219+
character(len=fname_len) :: locfn ! local file name
12211220
character(len=fname_len) :: fdynuse ! landuse.timeseries filename
12221221
logical :: readvar
12231222
!

0 commit comments

Comments
 (0)