Skip to content

Commit

Permalink
Merge tag 'ctsm5.1.dev122' into zendersource_dev
Browse files Browse the repository at this point in the history
Rework handling of evaporation constraint in SoilFluxes

Occasionally, h2osoi_ice was going significantly negative in
UpdateState_TopLayerFluxes - see
ESCOMP#1979. As noted in that issue, this
seems to be due to h2osoi_ice having a very different magnitude from
h2osoi_liq, leading to greater-than-roundoff-level differences from zero
final state in a relative sense (i.e., relative to the magnitude of
h2osoi_ice) - I think because of the appearance of the sum (h2osoi_ice +
h2osoi_liq) in the equations that limit fluxes.

To try to deal with this, I have reworked the handling of the
evaporation constraint to directly limit both the liqevap and solidevap,
so that both of them should result in the equivalent liq or ice states
going to 0 within roundoff.

To do that, I needed to move the partitioning of the total flux into
liquid and solid to earlier in the subroutine and then recalculate those
partitioning fluxes in conditions where we're applying an evaporation
constraint.

Note that I applied a max of 0 to the new fluxes because many initial
conditions files have roundoff-level negative H2OSOI_LIQ, so without
this limit, we were getting roundoff-level negative fluxes.

Resolves ESCOMP#1979
  • Loading branch information
ekluzek committed Apr 28, 2023
2 parents 4f5dcb9 + cdb6187 commit 7616b5c
Show file tree
Hide file tree
Showing 30 changed files with 2,267 additions and 122 deletions.
24 changes: 12 additions & 12 deletions .config_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
<entry_id>

<!-- This is the same as the default entry in
cime/config/cesm/config_files.xml except for the value for CTSM:
In a standalone CTSM checkout, COMP_ROOT_DIR_LND is $SRCROOT
cime/config/cesm/config_files.xml except for the value for CLM:
In a standalone CLM checkout, COMP_ROOT_DIR_LND is $SRCROOT
rather than $SRCROOT/components/clm.
However, because of the way overrides are handled, we need to
re-specify the full information here rather than just overriding
the value for CTSM.
the value for CLM.
-->
<entry id="COMP_ROOT_DIR_LND">
<type>char</type>
<default_value>unset</default_value>
<values>
<value component="clm" >$SRCROOT</value>
<value component="ctsm" >$SRCROOT</value>
<value component="dlnd" comp_interface="mct">$SRCROOT/components/cpl7/components/data_comps_mct/dlnd</value>
<value component="dlnd" comp_interface="nuopc">$SRCROOT/components/cdeps/dlnd</value>
<value component="slnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/stub_comps_mct/slnd</value>
<value component="xlnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/xcpl_comps_mct/xlnd</value>
<value component="slnd" comp_interface="nuopc" >$CIMEROOT/src/components/stub_comps_nuopc/slnd</value>
<value component="xlnd" comp_interface="nuopc" >$CIMEROOT/src/components/xcpl_comps_nuopc/xlnd</value>
<value component="clm" >$SRCROOT</value>
<value component="slim" >$SRCROOT/components/slim/</value>
<value component="dlnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/data_comps_$COMP_INTERFACE/dlnd</value>
<value component="dlnd" comp_interface="nuopc" >$SRCROOT/components/cdeps/dlnd</value>
<value component="slnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/stub_comps_$COMP_INTERFACE/slnd</value>
<value component="slnd" comp_interface="nuopc" >$CIMEROOT/CIME/non_py/src/components/stub_comps_$COMP_INTERFACE/slnd</value>
<value component="xlnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/xcpl_comps_$COMP_INTERFACE/xlnd</value>
<value component="xlnd" comp_interface="nuopc" >$CIMEROOT/CIME/non_py/src/components/xcpl_comps_$COMP_INTERFACE/xlnd</value>
</values>
<group>case_comps</group>
<file>env_case.xml</file>
<desc>Root directory of the case land model component </desc>
<schema>$CIMEROOT/config/xml_schemas/config_compsets.xsd</schema>
<schema>$CIMEROOT/CIME/data/config/xml_schemas/config_compsets.xsd</schema>
</entry>

</entry_id>
12 changes: 6 additions & 6 deletions Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ hash = 34723c2
required = True

[ccs_config]
tag = ccs_config_cesm0.0.38
tag = ccs_config_cesm0.0.58
protocol = git
repo_url = https://github.com/ESMCI/ccs_config_cesm.git
local_path = ccs_config
Expand All @@ -44,18 +44,18 @@ required = True
local_path = cime
protocol = git
repo_url = https://github.com/ESMCI/cime
tag = cime6.0.45
tag = cime6.0.100
required = True

[cmeps]
tag = cmeps0.13.71
tag = cmeps0.14.17
protocol = git
repo_url = https://github.com/ESCOMP/CMEPS.git
local_path = components/cmeps
required = True

[cdeps]
tag = cdeps0.12.65
tag = cdeps1.0.7
protocol = git
repo_url = https://github.com/ESCOMP/CDEPS.git
local_path = components/cdeps
Expand All @@ -70,7 +70,7 @@ local_path = components/cpl7
required = True

[share]
tag = share1.0.13
tag = share1.0.16
protocol = git
repo_url = https://github.com/ESCOMP/CESM_share
local_path = share
Expand All @@ -84,7 +84,7 @@ local_path = libraries/mct
required = True

[parallelio]
tag = pio2_5_7
tag = pio2_5_10
protocol = git
repo_url = https://github.com/NCAR/ParallelIO
local_path = libraries/parallelio
Expand Down
2 changes: 1 addition & 1 deletion Externals_CLM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local_path = src/fates
protocol = git
repo_url = https://github.com/NGEET/fates
tag = sci.1.61.0_api.25.0.0
tag = sci.1.65.3_api.25.4.0
required = True

[externals_description]
Expand Down
58 changes: 58 additions & 0 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,7 @@ sub setup_logic_dynamic_subgrid {
setup_logic_do_transient_lakes($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_do_transient_urban($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_do_harvest($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_do_grossunrep($opts, $nl_flags, $definition, $defaults, $nl);

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'reset_dynbal_baselines');
if ( &value_is_true($nl->get_value('reset_dynbal_baselines')) &&
Expand Down Expand Up @@ -2837,6 +2838,63 @@ sub setup_logic_do_harvest {

#-------------------------------------------------------------------------------

sub setup_logic_do_grossunrep {
#
# Set do_grossunrep default value, and perform error checking on do_grossunrep
#
# Assumes the following are already set in the namelist (although it's okay
# for them to be unset if that will be their final state):
# - flanduse_timeseries
# - use_cn
# - use_fates
#
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

my $var = 'do_grossunrep';

# Start by assuming a default value of '.true.'. Then check a number of
# conditions under which do_grossunrep cannot be true. Under these
# conditions: (1) set default value to '.false.'; (2) make sure that the
# value is indeed false (e.g., that the user didn't try to set it to true).

my $default_val = ".false.";

# cannot_be_true will be set to a non-empty string in any case where
# do_grossunrep should not be true; if it turns out that do_grossunrep IS true
# in any of these cases, a fatal error will be generated
my $cannot_be_true = "";

if (string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) {
$cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)";
}
elsif (&value_is_true($nl->get_value('use_fates'))) {
$cannot_be_true = "$var currently doesn't work with FATES";
}
elsif (!&value_is_true($nl->get_value('use_cn'))) {
$cannot_be_true = "$var can only be set to true when running with CN (use_cn = true)";
}

if ($cannot_be_true) {
$default_val = ".false.";
}

if (!$cannot_be_true) {
# Note that, if the variable cannot be true, we don't call add_default
# - so that we don't clutter up the namelist with variables that don't
# matter for this case
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, val=>$default_val);
}

# Make sure the value is false when it needs to be false - i.e., that the
# user hasn't tried to set a true value at an inappropriate time.

if (&value_is_true($nl->get_value($var)) && $cannot_be_true) {
$log->fatal_error($cannot_be_true);
}

}

#-------------------------------------------------------------------------------
sub setup_logic_spinup {
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

Expand Down
2 changes: 1 addition & 1 deletion bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- FATES default parameter file -->
<!-- ================================================================== -->

<fates_paramfile>lnd/clm2/paramdata/fates_params_api.25.0.0_12pft_c221128.nc</fates_paramfile>
<fates_paramfile>lnd/clm2/paramdata/fates_params_api.25.4.0_12pft_c230327.nc</fates_paramfile>

<!-- ======================================================================================== -->
<!-- clm 5.0 BGC nitrogen model -->
Expand Down
7 changes: 7 additions & 0 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,13 @@ If TRUE, apply harvest from flanduse_timeseries file.
(Also, only valid for use_cn = true.)
</entry>

<entry id="do_grossunrep" type="logical" category="physics"
group="dynamic_subgrid" valid_values="" >
If TRUE, apply gross unrepresented landuse/land-cover change from flanduse_timeseries file.
(Only valid for transient runs, where there is a flanduse_timeseries file.)
(Also, only valid for use_cn = true.)
</entry>

<entry id="reset_dynbal_baselines" type="logical" category="physics"
group="dynamic_subgrid" valid_values="">
If TRUE, reset baseline values of total column water and energy in the
Expand Down
19 changes: 17 additions & 2 deletions bld/unit_testers/build-namelist_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile {
#
# Figure out number of tests that will run
#
my $ntests = 1847;
my $ntests = 1850;
if ( defined($opts{'compare'}) ) {
$ntests += 1254;
}
Expand Down Expand Up @@ -1061,6 +1061,21 @@ sub cat_and_create_namelistinfile {
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm5_0",
},
"dogrossandsp" =>{ options=>"--envxml_dir . --bgc sp --use_case 20thC_transient",
namelst=>"do_grossunrep=.true.",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm5_0",
},
"dogrossandfates" =>{ options=>"--envxml_dir . --bgc fates --use_case 20thC_transient --no-megan",
namelst=>"do_grossunrep=.true.",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm5_0",
},
"dogrossandnottrans" =>{ options=>"--envxml_dir . --bgc bgc --use_case 2000_control",
namelst=>"do_grossunrep=.true.",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm5_0",
},
"nocropwfert" =>{ options=>"-envxml_dir . -bgc sp -no-crop",
namelst=>"use_fertilizer=T",
GLC_TWO_WAY_COUPLING=>"FALSE",
Expand Down Expand Up @@ -1444,7 +1459,7 @@ sub cat_and_create_namelistinfile {
my $usecase = "20thC_transient";
my $GLC_NEC = 10;
foreach my $res ( @tran_res ) {
$options = "-res $res -use_case $usecase -envxml_dir . -namelist '&a start_ymd=18500101/'";
$options = "-res $res -use_case $usecase -envxml_dir . -namelist '&a start_ymd=18500101/' -bgc bgc -crop -namelist '&a do_grossunrep=T/'";
&make_env_run();
eval{ system( "$bldnml $options > $tempfile 2>&1 " ); };
is( $@, '', "$options" );
Expand Down
1 change: 1 addition & 0 deletions cime_config/SystemTests/fsurdatmodifyctsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _run_modify_fsurdat(self):
print("getting an error within the fsurdat_modifier tool itself. ")
print("Default error message: ")
print(error.output)
raise
except:
print("ERROR trying to run fsurdat_modifier tool.")
raise
Expand Down
2 changes: 1 addition & 1 deletion cime_config/testdefs/ExpectedTestFails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</phase>
</test>

<test name="ERP_P144x2_Ld30.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-mimicsFatesCold">
<test name="ERP_P72x2_Ld30.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-mimicsFatesCold">
<phase name="SHAREDLIB_BUILD">
<status>PEND</status>
<issue>#1045</issue>
Expand Down
19 changes: 14 additions & 5 deletions cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
<machine name="cheyenne" compiler="intel" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">00:10:00</option>
<option name="wallclock">00:20:00</option>
<option name="comment">Want one C96 test in the aux_clm test suite; just a short smoke test to make sure it can get off the ground. Use a PE layout that (1) has threading, because CAM uses threading at this resolution; and (2) has a smaller-than-standard task count in order to get through the queue faster.</option>
</options>
</test>
Expand Down Expand Up @@ -467,8 +467,17 @@
<machine name="cheyenne" compiler="intel" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Transient case with isotopes with a december start</option>
<option name="wallclock">00:40:00</option>
<option name="comment" >Transient case with isotopes with a December start</option>
</options>
</test>
<test name="SMS_Ld3_PS" grid="f09_g17" compset="IHistClm50BgcCrop" testmods="clm/f09_dec1990Start_GU_LULCC">
<machines>
<machine name="cheyenne" compiler="intel" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">00:40:00</option>
<option name="comment" >Transient case with a December 1990 start, and Gross Unrepresented Land Use and Land Cover change on, with f09 datasets with non-zero GU_LULCC values</option>
</options>
</test>
<test name="ERP_D_Ld10_P36x2_Vmct" grid="f10_f10_mg37" compset="IHistClm51BgcCrop" testmods="clm/ciso_decStart">
Expand Down Expand Up @@ -1867,7 +1876,7 @@
<machine name="cheyenne" compiler="gnu" category="fates"/>
</machines>
<options>
<option name="wallclock">00:40:00</option>
<option name="wallclock">00:50:00</option>
</options>
</test>
<test name="ERS_Lm13" grid="f45_f45_mg37" compset="I2000Clm50Fates" testmods="clm/FatesColdNoComp">
Expand Down Expand Up @@ -2007,7 +2016,7 @@
<option name="comment">30 day exact restart test activating FATES size and age mortality mode on an f45 grid.</option>
</options>
</test>
<test name="ERP_P144x2_Ld30" grid="f45_f45_mg37" compset="I2000Clm50FatesRs" testmods="clm/mimicsFatesCold">
<test name="ERP_P72x2_Ld30" grid="f45_f45_mg37" compset="I2000Clm50FatesRs" testmods="clm/mimicsFatesCold">
<machines>
<machine name="cheyenne" compiler="intel" category="aux_clm"/>
<machine name="cheyenne" compiler="intel" category="fates"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../default
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./xmlchange RUN_STARTDATE=1990-12-30
# Ignore warnings because we are using crop, but starting from a different date than the initial conditions were for
./xmlchange CLM_BLDNML_OPTS=-ignore_warnings --append
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
! Specify a dataset that has non-zero Gross Unrepresented Land Use change fields on it
! And turn it on
flanduse_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_0.9x1.25_hist_78pfts_CMIP6_simyr1700-2021_c220825.nc'
fsurdat = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/ctsm5.1.dev052/surfdata_0.9x1.25_hist_78pfts_CMIP6_simyr1700_c220825.nc'
do_grossunrep = .true.
2 changes: 2 additions & 0 deletions cime_config/testdefs/testmods_dirs/clm/run_self_tests/shell_commands
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash
./xmlchange CLM_FORCE_COLDSTART="on"

# We use this testmod in a _Ln1 test; this requires forcing the ROF coupling frequency to every time step
./xmlchange ROF_NCPL=48
Loading

0 comments on commit 7616b5c

Please sign in to comment.