Skip to content

Commit

Permalink
Merge ed namelist updates, commit '8740a1a3', into andre-ed-clm-16x
Browse files Browse the repository at this point in the history
Merge conflicts in machines for lrc.

Test suite: ed - yellowstone gnu, intel, pgi
Test baseline: none
Test status: all tests pass
  • Loading branch information
bandre-ucar committed Jun 23, 2016
2 parents de89c1d + 8740a1a commit 09ae271
Show file tree
Hide file tree
Showing 14 changed files with 448 additions and 37 deletions.
31 changes: 31 additions & 0 deletions cime/cime_config/cesm/machines/config_env.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@
<module>load compiler/gnu/4.4.7</module>
</block>
</machine>

<machine mach="lawrencium-lr2">
<module_system>module</module_system>
<block>
<module>purge</module>
<module>load cmake</module>
<module>load perl xml-libxml switch</module>
</block>
<block compiler="intel">
<block>load intel/2015.6.233</block>
<block>load openmpi</block>
<block>load netcdf/4.4.0-intel-p</block>
<block>load mkl</block>
</block>
</machine>

<machine mach="lawrencium-lr3">
<module_system>module</module_system>
<block>
<module>purge</module>
<module>load cmake</module>
<module>load perl xml-libxml switch</module>
</block>
<block compiler="intel">
<block>load intel/2015.6.233</block>
<block>load openmpi</block>
<block>load netcdf/4.4.0-intel-p</block>
<block>load mkl</block>
</block>
</machine>

<machine mach="mira">
<module_system>soft</module_system>
<init_path lang="perl">. /etc/profile.d/00softenv.sh</init_path>
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
-fire_emis Produce a fire_emis_nl namelist that will go into the
"drv_flds_in" file for the driver to pass fire emissions to the atm.
(Note: buildnml copies the file for use by the driver)
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 @@ -1445,6 +1479,7 @@ sub process_namelist_inline_logic {
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_limit_river_withdrawal($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 @@ -3066,6 +3101,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 @@ -3183,6 +3235,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 @@ -3203,6 +3256,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 @@ -1793,4 +1793,15 @@ lnd/clm2/surfdata_map/surfdata_ne120np4_78pfts_simyr1850_c160216.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 @@ -654,13 +654,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 @@ -1473,4 +1485,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 09ae271

Please sign in to comment.