Skip to content

Commit

Permalink
Make ed an option to CLM build-namlist "-bgc" option remove -ed_mode
Browse files Browse the repository at this point in the history
Merge branch 'ekluzek/lnd/clm-bldnmledbgcopt'

The -ed_mode option is removed from CLM build-namelist and "ed" is
added as a valid option to the "-bgc" option.

It doesn't fill the cnfire namelists, but does the ndep namelist,
because it looks like that is required in soilbiogeochem. It also
turns on the default soilbiogeochem settings (methane,
vertical-soil-carbon, nitrif-denitrf [I understood that was required
for methane]). The new nitrogen things are default off for this
version -- so that will need to be dealt with in a future clm update
(use_ed will need to be passed down as an attribute to check for:
use_fun, use_flexibleCN, use_luna). Only the ED namelists were
changed, other namelists should be identical.

I think probably the setup_cmdl_ed_mode should be merged into
setup_cmdl_bgc. But, I left it separate for now.

Closes: #82

User interface changes?:yes

ed is an option to "-bgc" in CLM buildnamelist CLM_BLDNML_OPTS
ed_mode option is removed.

Code review: @ckoven, @ekluzek, @bandre-ucar

Test suite: (ekluzek) build-namelist_test.pl (in components/clm/bld/unit_testers)
Test baseline: ed-clm/master
Test namelist changes: -bgc ed, option now by default turns on soil biogeochem settings
Test answer changes: climate-changing for ED because of different namelist settings
Test summary: all PASS

Test suite: ed - yellowstone intel, gnu, pgi
            clm-short - yellowstone intel, gnu, pgi
Test baseline: none
Test namelist changes: new defaults for ed as bgc mode

Test summary: all tests pass, except for expected fails: #14 f09 and
f19 and #81 ERP 15x2 restart with pe layout change in clm-short.
  • Loading branch information
bandre-ucar committed Aug 1, 2016
2 parents bd4719b + c8acaa2 commit f8e6313
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 96 deletions.
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 -no-megan</CLM_BLDNML_OPTS>
<CLM_BLDNML_OPTS compset="_CLM45%[^_]*ED" >-bgc ed -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
105 changes: 45 additions & 60 deletions components/clm/bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#-----------------------------------------------------------------------------------------------
#
# build-namelist
#
# This script builds the namelists for CLM
Expand Down Expand Up @@ -101,6 +99,9 @@ OPTIONS
use_century_decomp=true, use_nitrif_denitrif=true, and use_lch4=true)
This toggles on the namelist variables:
use_cn, use_lch4, use_nitrif_denitrif, use_vertsoilc, use_century_decomp
ed = Ecosystem Demography with below ground BGC
This toggles on the namelist variables:
use_cn, use_lch4, use_nitrif_denitrif, use_vertsoilc, use_century_decomp
-bgc_spinup "on|off" CLM 4.5 Only. For CLM 4.0, spinup is controlled from configure.
Turn on given spinup mode for BGC setting of CN
Expand Down Expand Up @@ -158,10 +159,6 @@ OPTIONS
-dynamic_vegetation Toggle for dynamic vegetation model. (default is off)
(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, 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 @@ -274,7 +271,6 @@ sub process_commandline {
bgc => "default",
crop => 0,
dynamic_vegetation => 0,
ed_mode => 0,
envxml_dir => ".",
vichydro => 0,
maxpft => "default",
Expand Down Expand Up @@ -317,7 +313,6 @@ sub process_commandline {
"bgc=s" => \$opts{'bgc'},
"crop" => \$opts{'crop'},
"dynamic_vegetation" => \$opts{'dynamic_vegetation'},
"ed_mode" => \$opts{'ed_mode'},
"vichydro" => \$opts{'vichydro'},
"maxpft=i" => \$opts{'maxpft'},
"v|verbose" => \$opts{'verbose'},
Expand Down Expand Up @@ -717,35 +712,17 @@ sub setup_cmdl_ed_mode {
my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

my $val;
my $var = "ed_mode";

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

if ( $physv->as_long() == $physv->as_long("clm4_0") || $nl_flags->{'crop'} eq "on" ) {
if ( $nl_flags->{'ed_mode'} == 1 ) {
if ( $nl_flags->{$var} eq "ed" ) {
# ED is not a clm4_0 option and should not be used with crop and not with clm4_0
fatal_error("** Cannot turn ed mode on with crop or with clm4_0 physics.\n" );
}
} else {

$var = "use_ed";
$nl_flags->{$var} = ".false.";
if ($nl_flags->{'ed_mode'} eq 1) {
$val = ".true.";
$nl_flags->{$var} = $val;
}
if ( defined($nl->get_value($var)) && $nl->get_value($var) ne $val ) {
fatal_error("$var is inconsistent with the commandline setting of -ed_mode");
}
if ( $nl_flags->{$var} eq ".true." ) {
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");
}

# 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
Expand All @@ -756,7 +733,7 @@ sub setup_cmdl_ed_mode {
# $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");
# fatal_error("$var was set to .true., which is incompatible when -bgc ed option is used.\n");
# }
# }

Expand Down Expand Up @@ -784,7 +761,7 @@ sub setup_cmdl_ed_mode {
# 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");
fatal_error("$var is being set, but can ONLY be set when -bgc ed option is used.\n");
}
}
}
Expand Down Expand Up @@ -821,28 +798,37 @@ sub setup_cmdl_bgc {
verbose_message("Using $nl_flags->{$var} for bgc.");

# now set the actual name list variables based on the bgc alias
my $setting = ".false.";
if ($nl_flags->{$var} eq "cn") {
if ($nl_flags->{$var} eq "cn" ) {
$nl_flags->{'use_cn'} = ".true.";
} elsif ($nl_flags->{$var} eq "bgc") {
$nl_flags->{'use_ed'} = ".false.";
} elsif ($nl_flags->{$var} eq "bgc" ) {
$nl_flags->{'use_cn'} = ".true.";
$setting = ".true.";
$nl_flags->{'use_ed'} = ".false.";
} elsif ($nl_flags->{$var} eq "ed" ) {
$nl_flags->{'use_cn'} = ".false.";
$nl_flags->{'use_ed'} = ".true.";
} else {
$nl_flags->{'use_cn'} = ".false.";
$nl_flags->{'use_ed'} = ".false.";
}
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 ( defined($nl->get_value("use_ed")) && ($nl_flags->{'use_ed'} ne $nl->get_value("use_ed")) ) {
fatal_error("The namelist variable use_ed is inconsistent with the -bgc option");
}

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;
my %settings = ( 'bgc_mode'=>$nl_flags->{'bgc_mode'} );
foreach my $var ( @list ) {
my $default_setting = $defaults->get_value($var, \%settings );
if ( ! defined($nl->get_value($var)) ) {
$nl_flags->{$var} = $setting;
$nl_flags->{$var} = $default_setting;
} else {
if ( $nl->get_value($var) ne $setting ) {
if ( $nl->get_value($var) ne $default_setting ) {
$ndiff += 1;
}
$nl_flags->{$var} = $nl->get_value($var);
Expand All @@ -861,14 +847,15 @@ sub setup_cmdl_bgc {
}
}

# Now set use_cn
$var = "use_cn";
$val = $nl_flags->{'use_cn'};
$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");
# Now set use_cn and use_ed
foreach $var ( "use_cn", "use_ed" ) {
$val = $nl_flags->{$var};
$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");
}
}
}
} # end bgc
Expand Down Expand Up @@ -1092,9 +1079,9 @@ sub setup_cmdl_bgc_spinup {
my @valid_values = $definition->get_valid_values( $var );
fatal_error("$var has an invalid value ($val). Valid values are: @valid_values\n");
}
# if ( $nl_flags->{'bgc_spinup'} eq "on" && $nl_flags->{'use_cn'} ne ".true.") {
# fatal_error("$var can not be '$nl_flags->{'bgc_spinup'}' if CN is turned off (use_cn=$nl_flags->{'use_cn'}).");
# }
if ( $nl_flags->{'bgc_spinup'} eq "on" && (not value_is_true( $nl_flags->{'use_cn'} )) && (not value_is_true($nl_flags->{'use_ed'})) ) {
fatal_error("$var can not be '$nl_flags->{'bgc_spinup'}' if neither CN nor ED is turned on (use_cn=$nl_flags->{'use_cn'}, use_ed=$nl_flags->{'use_ed'}).");
}
if ( $nl->get_value("spinup_state") eq 0 && $nl_flags->{'bgc_spinup'} eq "on" ) {
fatal_error("Namelist spinup_state contradicts the command line option bgc_spinup" );
}
Expand Down Expand Up @@ -2295,7 +2282,7 @@ sub setup_logic_supplemental_nitrogen {
#
my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

if ( $nl_flags->{'bgc_mode'} ne "sp" && $nl_flags->{'use_crop'} eq ".true." ) {
if ( $nl_flags->{'bgc_mode'} ne "sp" && $nl_flags->{'bgc_mode'} ne "ed" && $nl_flags->{'use_crop'} eq ".true." ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl,
'suplnitro', 'use_cn'=>$nl_flags->{'use_cn'}, 'use_crop'=>$nl_flags->{'use_crop'});
}
Expand Down Expand Up @@ -2352,8 +2339,10 @@ sub setup_logic_methane {
my ($test_files, $nl_flags, $definition, $defaults, $nl) = @_;

if ( $nl_flags->{'use_lch4'} eq '.true.' ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fin_use_fsat' );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_aereoxid_prog' );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fin_use_fsat',
'use_cn'=>$nl_flags->{'use_cn'}, 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_aereoxid_prog',
'use_cn'=>$nl_flags->{'use_cn'}, 'use_ed'=>$nl_flags->{'use_ed'} );
#
# Check if use_aereoxid_prog is set. If no, then read value of aereoxid from
# parameters file
Expand Down Expand Up @@ -2480,7 +2469,7 @@ sub setup_logic_c_isotope {

my $use_c13 = $nl->get_value('use_c13');
my $use_c14 = $nl->get_value('use_c14');
if ( $nl_flags->{'bgc_mode'} ne "sp" ) {
if ( $nl_flags->{'bgc_mode'} ne "sp" && $nl_flags->{'bgc_mode'} ne "ed" ) {
if ( $nl_flags->{'use_crop'} eq ".true." ) {
if ( defined($use_c13) ||
defined($use_c14) ||
Expand Down Expand Up @@ -2555,7 +2544,7 @@ sub setup_logic_nitrogen_deposition {
'bgc'=>$nl_flags->{'bgc_mode'}, 'rcp'=>$nl_flags->{'rcp'},
'hgrid'=>"1.9x2.5" );

} elsif ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) {
} elsif ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} =~/cn|bgc/ ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndepmapalgo', 'phys'=>$nl_flags->{'phys'},
'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_ndep', 'phys'=>$nl_flags->{'phys'},
Expand Down Expand Up @@ -2593,7 +2582,7 @@ sub setup_logic_popd_streams {
my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

if ( $physv->as_long() >= $physv->as_long("clm4_5") ) {
if ( $nl_flags->{'bgc_mode'} ne "sp" ) {
if ( $nl_flags->{'bgc_mode'} ne "sp" && $nl_flags->{'bgc_mode'} ne "ed" ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'popdensmapalgo', 'hgrid'=>$nl_flags->{'res'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_popdens', 'phys'=>$nl_flags->{'phys'},
'use_cn'=>$nl_flags->{'use_cn'}, 'sim_year'=>$nl_flags->{'sim_year'},
Expand Down Expand Up @@ -2630,7 +2619,7 @@ sub setup_logic_lightning_streams {
my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

if ( $physv->as_long() >= $physv->as_long("clm4_5") ) {
if ( $nl_flags->{'bgc_mode'} ne "sp" ) {
if ( $nl_flags->{'bgc_mode'} ne "sp" && $nl_flags->{'bgc_mode'} ne "ed" ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'},
'hgrid'=>$nl_flags->{'res'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'},
Expand Down Expand Up @@ -2685,7 +2674,7 @@ sub setup_logic_megan {
if ($opts->{'megan'} ) {
if ( value_is_true( $nl_flags->{'use_ed'} ) ) {
fatal_error("MEGAN can NOT be on when ED is also on.\n" .
" Use the '-no-megan' option when '-ed_mode' is activated");
" Use the '-no-megan' option when '-bgc ed' is activated");
}
add_default($opts->{'test'}, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'megan_specifier');
check_megan_spec( $nl, $definition );
Expand Down Expand Up @@ -2778,11 +2767,7 @@ sub setup_logic_ed {
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'} );
}
}

Expand Down
34 changes: 26 additions & 8 deletions components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case).

<!-- Supplmental Nitrogen mode -->
<suplnitro use_cn=".true." >NONE</suplnitro>
<suplnitro use_ed=".true." >NONE</suplnitro>

<!-- Albedo for glaciers -->
<albice glc_nec="0" >0.60,0.40</albice>
Expand Down Expand Up @@ -1608,19 +1609,36 @@ lnd/clm2/surfdata_map/surfdata_ne30np4_simyr1850_c141219.nc</fsurdat>
<!-- Defaults for ch4par_in namelist -->
<!-- ========================================= -->

<fin_use_fsat use_cn=".true.">.false.</fin_use_fsat>

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

<fin_use_fsat use_ed=".true.">.false.</fin_use_fsat>
<use_aereoxid_prog use_ed=".true.">.true.</use_aereoxid_prog>

<!-- ========================================= -->
<!-- Defaults for use_ed = .true. -->
<!-- Defaults for different BGC modes -->
<!-- ========================================= -->

<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>
<use_vertsoilc bgc_mode="sp" >.false.</use_vertsoilc>
<use_century_decomp bgc_mode="sp" >.false.</use_century_decomp>
<use_lch4 bgc_mode="sp" >.false.</use_lch4>
<use_nitrif_denitrif bgc_mode="sp" >.false.</use_nitrif_denitrif>

<use_vertsoilc bgc_mode="cn" >.false.</use_vertsoilc>
<use_century_decomp bgc_mode="cn" >.false.</use_century_decomp>
<use_lch4 bgc_mode="cn" >.false.</use_lch4>
<use_nitrif_denitrif bgc_mode="cn" >.false.</use_nitrif_denitrif>

<use_vertsoilc bgc_mode="bgc" >.true.</use_vertsoilc>
<use_century_decomp bgc_mode="bgc" >.true.</use_century_decomp>
<use_lch4 bgc_mode="bgc" >.true.</use_lch4>
<use_nitrif_denitrif bgc_mode="bgc" >.true.</use_nitrif_denitrif>

<use_vertsoilc bgc_mode="ed" >.true.</use_vertsoilc>
<use_century_decomp bgc_mode="ed" >.true.</use_century_decomp>
<use_lch4 bgc_mode="ed" >.false.</use_lch4>
<use_nitrif_denitrif bgc_mode="ed" >.false.</use_nitrif_denitrif>

<use_ed_spit_fire use_ed=".true.">.true.</use_ed_spit_fire>

</namelist_defaults>
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ Command line arguement for turning on CN spinup mode.
</entry>

<entry id="bgc_mode" type="char*4" category="default_settings"
group="default_settings" valid_values="sp,cn,bgc" >
group="default_settings" valid_values="sp,cn,bgc,ed" >
Command line arguement for biogeochemistry mode for CLM4.5
sp = Satellitte Phenology
cn = Carbon Nitrogen model
Expand All @@ -1087,6 +1087,7 @@ Command line arguement for biogeochemistry mode for CLM4.5
Nitrification/De-nitrification
Methane model
Vertically resolved Carbon
ed = ED (Ecosystem Demography) model with below ground BGC:
</entry>

<!-- ======================================================================================== -->
Expand Down
Loading

0 comments on commit f8e6313

Please sign in to comment.