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

fates parameter file auto-build for all tests #2336

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
./xmlchange CLM_BLDNML_OPTS="-no-megan" --append
./xmlchange BFBFLAG="TRUE"

SRCROOT=`./xmlquery SRCROOT --value`
. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh

ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ hist_nhtfrq = -24
hist_empty_htapes = .true.
hist_ndens = 1
fates_spitfire_mode = 1
fates_paramfile='${SRCROOT}/src/fates/parameter_files/binaries/${CASE}-params.nc'
hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS',
'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD',
'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF','FATES_DAYSINCE_COLDLEAFON',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
SRCDIR=`./xmlquery SRCROOT --value`
CASEDIR=`./xmlquery CASEROOT --value`
FATESDIR=$SRCDIR/src/fates/
FATESPARAMFILE=$SRCDIR/fates_params_seeddisp_4x5.nc
SRCROOT=`./xmlquery SRCROOT --value`
. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh
CASE=`./xmlquery CASE --value`

ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl

$FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_fraction --val 0.2 --allpfts
$FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_max_dist --val 2500000 --allpfts
$FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_pdf_scale --val 1e-05 --allpfts
$FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_pdf_shape --val 0.1 --allpfts
python $FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_fraction --val 0.2 --allpfts
python $FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_max_dist --val 2500000 --allpfts
python $FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_pdf_scale --val 1e-05 --allpfts
python $FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_seed_dispersal_pdf_shape --val 0.1 --allpfts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fates_paramfile = '$SRCROOT/fates_params_seeddisp_4x5.nc'
fates_seeddisp_cadence = 1
hist_fincl1 = 'FATES_SEEDS_IN_GRIDCELL_PF', 'FATES_SEEDS_OUT_GRIDCELL_PF'
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
SRCDIR=`./xmlquery SRCROOT --value`
CASEDIR=`./xmlquery CASEROOT --value`
FATESDIR=$SRCDIR/src/fates
FATESPARAMFILE=$CASEDIR/fates_params_twostream.nc

ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl

$FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_rad_model --val 2 --allpfts
SRCROOT=`./xmlquery SRCROOT --value`
. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh
python $FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_rad_model --val 2 --allpfts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fates_paramfile = '$CASEROOT/fates_params_twostream.nc'

Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
SRCDIR=`./xmlquery SRCROOT --value`
CASEDIR=`./xmlquery CASEROOT --value`
FATESDIR=$SRCDIR/src/fates
FATESPARAMFILE=$CASEDIR/fates_params_twostream.nc

ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl

$FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_rad_model --val 2 --allpfts
SRCROOT=`./xmlquery SRCROOT --value`
. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh
python $FATESDIR/tools/modify_fates_paramfile.py --O --fin $FATESPARAMFILE --fout $FATESPARAMFILE --var fates_rad_model --val 2 --allpfts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fates_paramfile = '$CASEROOT/fates_params_twostream.nc'
use_fates_fixed_biogeog=.true.
use_fates_fixed_biogeog=.true.
2 changes: 2 additions & 0 deletions cime_config/testdefs/testmods_dirs/clm/_scripts/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory contains scripts that can be called in
shell_commands of multiple testmods.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This script should be called in shell_commands with
# . "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh
# where the leading period ensures it's run in the same shell.

CASE=`./xmlquery CASE --value`
FATESDIR="${SRCROOT}/src/fates"
FATESPARAMDIR="${SRCROOT}/src/fates/parameter_files/binaries"
mkdir -p "${FATESPARAMDIR}"
FATESPARAMFILE="${FATESPARAMDIR}/${CASE}-params.nc"

# No exit status because it should be called in the same shell.
9 changes: 7 additions & 2 deletions python/ctsm/run_sys_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ def _get_testmod_list(test_attributes, unique=False):
for test_attribute in test_attributes:
for dot_split in test_attribute.split("."):
slash_replaced = dot_split.replace("/", "-")
for ddash_split in slash_replaced.split("--"):
newline_replaced = slash_replaced.replace("\n", "")
for ddash_split in newline_replaced.split("--"):
if "clm-" in ddash_split and (ddash_split not in testmods or not unique):
testmods.append(ddash_split)

Expand All @@ -744,7 +745,11 @@ def _check_py_env(test_attributes):
raise ModuleNotFoundError("modify_fsurdat" + err_msg) from err

# Check that list for any testmods that use modify_fates_paramfile.py
testmods_to_check = ["clm-FatesColdTwoStream", "clm-FatesColdTwoStreamNoCompFixedBioGeo"]
testmods_to_check = [
"clm-FatesColdSeedDisp",
"clm-FatesColdTwoStream",
"clm-FatesColdTwoStreamNoCompFixedBioGeo",
]
testmods = _get_testmod_list(test_attributes)
if any(t in testmods_to_check for t in testmods):
# This bit is needed because it's outside the top-level python/ directory.
Expand Down
Loading