Skip to content

Commit

Permalink
Updates to ed relevant namelist build options
Browse files Browse the repository at this point in the history
Corrects namelist build bugs associated with use_ed_spit_fire,
use_vertsoilc, use_century_decomp, use_lch4 and
use_nitrif_denitrif. It also ensure no-megan with ED compsets. It also
adds an edNoFire testmod which turns off ed_spit_fire for regression
tests.

Note*: As part of #13, we intend to change main regression tests to
include use_century_decomp = .true. and use_vertsoilc = .true.. To
enable baselines, these two options were set to false in
components/clm/cimetest/testmods_dirs/clm/edTest/user_nl_clm, and
should be changed to true in the next commit. Regression tests with
true passed on lawrencium.

Fixes: #16 and #13

User interface changes?: changes default name list, but underlying UI
changes, user protocols do not change

Code review: Ben Andre, Gautam Bisht, Erik Kluzek, discussions with
Charles Koven, Chonggang Xu and Rosie Fisher

Unit tests: test_build_namelist - pass, new tests added.
Test suite: 'ed' on lrc and yellowstone intel, pgi, gnu.
Test baseline: c3a1f92
Test namelist changes: added edNoFire where use_ed_spit_fire = .false.
Test answer changes: none
Test summary: no baselines for new edNoFire tests. f09 and f19 tests
fail restart as expected (#14)
  • Loading branch information
bandre-ucar committed Feb 26, 2016
2 parents 90c3758 + 3d6f43d commit 8740a1a
Show file tree
Hide file tree
Showing 15 changed files with 455 additions and 39 deletions.
4 changes: 2 additions & 2 deletions cime/machines/env_mach_specific.lawrencium-lr2
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ module load cmake
module load perl xml-libxml switch

if ( $COMPILER == "intel" ) then
module load intel/2015.0.090
module load intel/2015.6.233
module load openmpi
module load netcdf/4.3.2-intel-p
module load netcdf/4.4.0-intel-p
module load mkl
endif

Expand Down
37 changes: 37 additions & 0 deletions cime/machines/env_mach_specific.lawrencium-lr3
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/csh -f

set CESM_REPO = `./xmlquery CCSM_REPOTAG -value`
if($status == 0) then
set COMPILER = `./xmlquery COMPILER -value`
set MPILIB = `./xmlquery MPILIB -value`
set DEBUG = `./xmlquery DEBUG -value`
set OS = `./xmlquery OS -value`
set PROFILE_PAPI_ENABLE = `./xmlquery PROFILE_PAPI_ENABLE -value`
set PROJECT = `./xmlquery PROJECT -value`
else
echo $0 using settings from environment:
endif
echo "COMPILER=$COMPILER"
echo "MPILIB=$MPILIB"
echo "DEBUG=$DEBUG"
echo "OS=$OS"
echo "PROJECT=$PROJECT"

source /etc/profile.d/modules.csh
module purge
module load cmake
module load perl xml-libxml switch

if ( $COMPILER == "intel" ) then
module load intel/2015.6.233
module load openmpi
module load netcdf/4.4.0-intel-p
module load mkl
endif

setenv NETCDF_PATH $NETCDF_DIR
#-------------------------------------------------------------------------------

limit coredumpsize 1000000
limit stacksize unlimited

2 changes: 1 addition & 1 deletion cime/scripts/Tools/config_compsets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ CAM[45]%L60 => CAM with 60 layers and full gravity wave spectrum:
<CLM_BLDNML_OPTS compset="_CLM45%[^_]*BGCDV" >-bgc bgc -dynamic_vegetation</CLM_BLDNML_OPTS>
<CLM_BLDNML_OPTS compset="_CLM45%[^_]*CNDV-CROP" >-bgc cn -dynamic_vegetation -crop</CLM_BLDNML_OPTS>
<CLM_BLDNML_OPTS compset="_CLM45%[^_]*BGCDV-CROP">-bgc bgc -dynamic_vegetation -crop</CLM_BLDNML_OPTS>
<CLM_BLDNML_OPTS compset="_CLM45%[^_]*ED" >-ed_mode</CLM_BLDNML_OPTS>
<CLM_BLDNML_OPTS compset="_CLM45%[^_]*ED" >-ed_mode -no-megan</CLM_BLDNML_OPTS>

<CLM_BLDNML_OPTS compset="_CLM50%[^_]*SP" >-bgc sp</CLM_BLDNML_OPTS>
<CLM_BLDNML_OPTS compset="_CLM50%[^_]*BGC" >-bgc bgc</CLM_BLDNML_OPTS>
Expand Down
114 changes: 84 additions & 30 deletions components/clm/bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ OPTIONS
(can ONLY be turned on when BGC type is 'cn' or 'bgc')
This turns on the namelist variable: use_cndv
-ed_mode Turn ED (Ecosystem Demography) : [on | off] (default is off)
Sets the namelist variable use_ed and use_spit_fire.
Sets the namelist variable use_ed, checks for use_spit_fire,
use_vertsoilc, use_century_decomp and use_lch4
Also specifies defaults for these
-glc_present Set to true if the glc model is present (not sglc).
This is used for error-checking, to make sure other options are
set appropriately.
Expand Down Expand Up @@ -730,7 +732,6 @@ sub setup_cmdl_ed_mode {
$var = "use_ed";
$nl_flags->{$var} = ".false.";
if ($nl_flags->{'ed_mode'} eq 1) {
message("Using ED (Ecosystem Demography).");
$val = ".true.";
$nl_flags->{$var} = $val;
}
Expand All @@ -745,13 +746,42 @@ sub setup_cmdl_ed_mode {
fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n");
}

$var = "use_ed_spit_fire";
$nl->set_variable_value($group, $var, $val);
if ( ! $definition->is_valid_value($var, $val) ) {
my @valid_values = $definition->get_valid_values( $var );
fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n");
# This section is a place-holder to test for modules that are not allowed with ED
# the defaults which are set in the logic section of the namelist builder will
# automatically set these correctly (well that is the assumption), but here we
# want to set a catch to fail and warn users if they explicitly set incompatible user namelist
# options

# my $var = "use_somevar";
# $val = $nl_flags->{$var};
# if ( defined($nl->get_value($var)) ) {
# if ( $nl->get_value($var) == ".true." ) {
# fatal_error("$var was set to .true., which is incompatible when -ed_mode option is used.\n");
# }
# }


# The following variables may be set by the user and are compatible with use_ed
# no need to set defaults, covered in a different routine
my @list = ( "use_ed_spit_fire", "use_vertsoilc", "use_century_decomp", "use_lch4" );
foreach my $var ( @list ) {
if ( defined($nl->get_value($var)) ) {
$nl_flags->{$var} = $nl->get_value($var);
$val = $nl_flags->{$var};
my $group = $definition->get_group_name($var);
$nl->set_variable_value($group, $var, $val);
if ( ! $definition->is_valid_value( $var, $val ) ) {
my @valid_values = $definition->get_valid_values( $var );
fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n");
}
}
}

# add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_vertsoilc', 'use_ed'=>$nl_flags->{'use_ed'} );


} else {
# we only dis-allow ed_spit_fire with non-ed runs
$var = "use_ed_spit_fire";
if ( defined($nl->get_value($var)) ) {
fatal_error("$var is being set, but can ONLY be set when -ed_mode option is used.\n");
Expand All @@ -771,6 +801,7 @@ sub setup_cmdl_bgc {

$val = $opts->{$var};
$nl_flags->{'bgc_mode'} = $val;

if ( $physv->as_long() == $physv->as_long("clm4_0") ) {
if ( $nl_flags->{'bgc_mode'} ne "default" ) {
fatal_error("-bgc option used with clm4_0 physics. -bgc can ONLY be used with clm4_5/clm5_0 physics");
Expand Down Expand Up @@ -802,29 +833,32 @@ sub setup_cmdl_bgc {
if ( defined($nl->get_value("use_cn")) && ($nl_flags->{'use_cn'} ne $nl->get_value("use_cn")) ) {
fatal_error("The namelist variable use_cn is inconsistent with the -bgc option");
}
# If the variable has already been set use it, if not set to the value defined by the bgc_mode
my @list = ( "use_lch4", "use_nitrif_denitrif", "use_vertsoilc", "use_century_decomp" );
my $ndiff = 0;
foreach my $var ( @list ) {
if ( ! defined($nl->get_value($var)) ) {
$nl_flags->{$var} = $setting;
} else {
if ( $nl->get_value($var) ne $setting ) {
$ndiff += 1;
}
$nl_flags->{$var} = $nl->get_value($var);
}
$val = $nl_flags->{$var};
my $group = $definition->get_group_name($var);
$nl->set_variable_value($group, $var, $val);
if ( ! $definition->is_valid_value( $var, $val ) ) {
my @valid_values = $definition->get_valid_values( $var );
fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n");
}
}
# If all the variables are different report it as an error
if ( $ndiff == ($#list + 1) ) {
fatal_error("You are contradicting the -bgc setting with the namelist variables: @list" );

if ( $opts->{"ed_mode"} != 1) {
# If the variable has already been set use it, if not set to the value defined by the bgc_mode
my @list = ( "use_lch4", "use_nitrif_denitrif", "use_vertsoilc", "use_century_decomp" );
my $ndiff = 0;
foreach my $var ( @list ) {
if ( ! defined($nl->get_value($var)) ) {
$nl_flags->{$var} = $setting;
} else {
if ( $nl->get_value($var) ne $setting ) {
$ndiff += 1;
}
$nl_flags->{$var} = $nl->get_value($var);
}
$val = $nl_flags->{$var};
my $group = $definition->get_group_name($var);
$nl->set_variable_value($group, $var, $val);
if ( ! $definition->is_valid_value( $var, $val ) ) {
my @valid_values = $definition->get_valid_values( $var );
fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n");
}
}
# If all the variables are different report it as an error
if ( $ndiff == ($#list + 1) ) {
fatal_error("You are contradicting the -bgc setting with the namelist variables: @list" );
}
}

# Now set use_cn
Expand Down Expand Up @@ -1427,6 +1461,7 @@ sub process_namelist_inline_logic {
setup_logic_supplemental_nitrogen($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv);
setup_logic_snowpack($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv);
setup_logic_atm_forcing($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv);
setup_logic_ed($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv);

#########################################
# namelist group: clm_humanindex_inparm #
Expand Down Expand Up @@ -2736,6 +2771,23 @@ sub setup_logic_atm_forcing {

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

sub setup_logic_ed {
#
# Set some default options related to Ecosystem Demography
#
my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

if ($physv->as_long() >= $physv->as_long("clm4_5") && value_is_true( $nl_flags->{'use_ed'}) ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_vertsoilc', 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_century_decomp', 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_ed_spit_fire', 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_lch4', 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_nitrif_denitrif', 'use_ed'=>$nl_flags->{'use_ed'} );
}
}

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

sub write_output_files {
my ($opts, $nl_flags, $defaults, $nl, $physv) = @_;

Expand Down Expand Up @@ -2840,6 +2892,7 @@ sub add_default {
$var = $1;
}
# Query the definition to find which group the variable belongs to. Exit if not found.

my $group = $definition->get_group_name($var);
unless ($group) {
my $fname = $definition->get_file_name();
Expand All @@ -2860,6 +2913,7 @@ sub add_default {
# in %settings to the get_value method to be used as attributes that are matched
# when looking for default values.
else {

$val = $defaults->get_value($var, \%settings);

# Truncate model_version appropriately
Expand Down
11 changes: 11 additions & 0 deletions components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1612,4 +1612,15 @@ lnd/clm2/surfdata_map/surfdata_ne30np4_simyr1850_c141219.nc</fsurdat>

<use_aereoxid_prog use_cn=".true.">.true.</use_aereoxid_prog>

<!-- ========================================= -->
<!-- Defaults for use_ed = .true. -->
<!-- ========================================= -->

<use_vertsoilc use_ed=".true.">.true.</use_vertsoilc>
<use_century_decomp use_ed=".true.">.true.</use_century_decomp>
<use_ed_spit_fire use_ed=".true.">.true.</use_ed_spit_fire>
<use_lch4 use_ed=".true.">.false.</use_lch4>
<use_nitrif_denitrif use_ed=".true.">.false.</use_nitrif_denitrif>


</namelist_defaults>
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,13 @@ Requires the CN model to work (either CN or CNDV).
<entry id="use_vertsoilc" type="logical" category="bgc"
group="clm_inparm" valid_values="" value=".false.">
Turn on vertical soil carbon.
Requires the CN model to work (either CN or CNDV).
Requires the CN or ED model to work (either CN or CNDV).
</entry>

<entry id="use_century_decomp" type="logical" category="bgc"
group="clm_inparm" valid_values="" value=".false.">
Use parameters for decomposition from the CENTURY Carbon model
Requires the CN model to work (either CN or CNDV).
Requires the CN or ED model to work (either CN or CNDV).
</entry>

<entry id="use_extralakelayers" type="logical" category="physics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- Plant function types (relative to {csmdata}) -->
<paramfile >lnd/clm2/paramdata/clm_params.c130821.nc</paramfile>


<!--- ======================================== -->
<!--- Defaults for use_ed = .true. -->
<!-- ======================================== -->

<use_vertsoilc use_ed=".true.">.true.</use_vertsoilc>
<use_century_decomp use_ed=".true." >.true.</use_century_decomp>
<use_ed_spit_fire use_ed=".true.">.true.</use_ed_spit_fire>
<use_lch4 use_ed=".true.">.false.</use_lch4>
<use_nitrif_denitrif use_ed=".true.">.false.</use_nitrif_denitrif>


<!--
Original initial condition file at 1 degree resolution
Expand Down Expand Up @@ -1478,4 +1490,5 @@ lnd/clm2/surfdata_map/surfdata_ne30np4_simyr1850_c130927.nc</fsurdat>

<use_aereoxid_prog use_cn=".true.">.true.</use_aereoxid_prog>


</namelist_defaults>
10 changes: 8 additions & 2 deletions components/clm/bld/test_build_namelist/t/template_test_XXX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use parent qw(Test::Class);
# Common test fixture for all tests:
#
#-------------------------------------------------------------------------------
sub startup : Test(startup => 3) {
sub startup : Test(startup => 4) {
my $self = shift;
# provide common fixture for all tests, only created once at the
# start of the tests.
Expand All @@ -23,8 +23,14 @@ sub startup : Test(startup => 3) {
$self->{definition} = Build::NamelistDefinition->new("t/input/namelist_definition_clm4_5_test.xml");
isnt($self->{definition}, undef, (caller(0))[3] . " : namelist_definition object created.");

$self->{defaults} = Build::NamelistDefaults->new("t/input/namelist_defaults_clm4_5_test.xml");
$self->{defaults} = Build::NamelistDefaults->new("t/input/namelist_defaults_clm4_5_test.xml",$self->{cfg});
isnt($self->{defaults}, undef, (caller(0))[3] . " : namelist_defaults object created.");

# The next line may be usefull (set startup => 4) in arg call above:
$self->{physv} = config_files::clm_phys_vers->new( $self->{cfg}->get('phys') );
isnt($self->{physv}, undef, (caller(0))[3] . " : phys_vers object created.");


}

sub shutdown : Test(shutdown) {
Expand Down
Loading

0 comments on commit 8740a1a

Please sign in to comment.