Skip to content

Commit

Permalink
Reorder and rework a bit the handling of methane and nitrif-denitrif,…
Browse files Browse the repository at this point in the history
… making it after soil_decomp and dependent on that setting
  • Loading branch information
ekluzek committed Aug 29, 2021
1 parent 674d282 commit 55ad5ab
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
80 changes: 40 additions & 40 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -848,33 +848,6 @@ sub setup_cmdl_bgc {
$log->fatal_error("The namelist variable use_fates 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" );
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} = $default_setting;
} else {
$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 );
$log->fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values");
}
}
# nitrif_denitrif can only be .false. if fates is on
if ( (! &value_is_true($nl_flags->{'use_fates'})) && &value_is_true($nl_flags->{'use_cn'}) ) {
$var = "use_nitrif_denitrif";
if ( ! &value_is_true($nl_flags->{$var}) ) {
$log->warning("$var normally use_nitrif_denitrif should only be FALSE if FATES is on, it has NOT been validated for being off for BGC mode" );
}
}
}

# Now set use_cn and use_fates
foreach $var ( "use_cn", "use_fates" ) {
Expand All @@ -886,19 +859,6 @@ sub setup_cmdl_bgc {
$log->fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values");
}
}

my $var = "use_fun";
if ( ! defined($nl->get_value($var)) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'},
'use_nitrif_denitrif'=>$nl_flags->{'use_nitrif_denitrif'} );
}
if ( (! &value_is_true($nl_flags->{'use_cn'}) ) && &value_is_true($nl->get_value('use_fun')) ) {
$log->fatal_error("When FUN is on, use_cn MUST also be on!");
}
if ( (! &value_is_true($nl_flags->{'use_nitrif_denitrif'}) ) && &value_is_true($nl->get_value('use_fun')) ) {
$log->fatal_error("When FUN is on, use_nitrif_denitrif MUST also be on!");
}
#
# Determine Soil decomposition method
#
Expand All @@ -913,6 +873,46 @@ sub setup_cmdl_bgc {
} elsif ( remove_leading_and_trailing_quotes($nl->get_value($var)) ne "None" ) {
$log->fatal_error("$var must be None if use_cn or use_fates are not");
}
#
# Soil decomposition control variables, methane and Nitrification-Denitrification
#
my @list = ( "use_lch4", "use_nitrif_denitrif" );
my %settings = ( 'bgc_mode'=>$nl_flags->{'bgc_mode'} );
foreach my $var ( @list ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, 'use_fates'=>$nl_flags->{'use_fates'} );
$nl_flags->{$var} = $nl->get_value($var);
}
if ( remove_leading_and_trailing_quotes( $nl->get_value($var)) eq "None" ) {
foreach my $var ( @list ) {
if ( &value_is_true($nl_flags->{$var}) ) {
$log->fatal_error("When soil_decomp_method is NONE $var can NOT be TRUE");
}
}
} else {
# nitrif_denitrif can only be .false. if fates is on
if ( (! &value_is_true($nl_flags->{'use_fates'})) && &value_is_true($nl_flags->{'use_cn'}) ) {
$var = "use_nitrif_denitrif";
if ( ! &value_is_true($nl_flags->{$var}) ) {
$log->warning("$var normally use_nitrif_denitrif should only be FALSE if FATES is on, it has NOT been validated for being off for BGC mode" );
}
}
}
#
# Set FUN for BGC
#
my $var = "use_fun";
if ( ! defined($nl->get_value($var)) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'},
'use_nitrif_denitrif'=>$nl_flags->{'use_nitrif_denitrif'} );
}
if ( (! &value_is_true($nl_flags->{'use_cn'}) ) && &value_is_true($nl->get_value('use_fun')) ) {
$log->fatal_error("When FUN is on, use_cn MUST also be on!");
}
if ( (! &value_is_true($nl_flags->{'use_nitrif_denitrif'}) ) && &value_is_true($nl->get_value('use_fun')) ) {
$log->fatal_error("When FUN is on, use_nitrif_denitrif MUST also be on!");
}
} # end bgc


Expand Down
18 changes: 9 additions & 9 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2544,15 +2544,15 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts
<!-- Defaults for different BGC modes -->
<!-- ========================================= -->

<use_lch4 bgc_mode="sp" >.false.</use_lch4>
<use_lch4 bgc_mode="bgc" >.true.</use_lch4>
<use_lch4 bgc_mode="fates" >.false.</use_lch4>
<soil_decomp_method use_cn=".true." >CENTURYKoven2013</soil_decomp_method>
<soil_decomp_method use_fates=".true.">CENTURYKoven2013</soil_decomp_method>
<soil_decomp_method >None</soil_decomp_method>
<use_nitrif_denitrif >.true.</use_nitrif_denitrif>
<use_nitrif_denitrif bgc_mode="sp" >.false.</use_nitrif_denitrif>
<use_nitrif_denitrif bgc_mode="fates" >.false.</use_nitrif_denitrif>
<use_lch4 >.false.</use_lch4>
<use_lch4 use_cn=".true." >.true.</use_lch4>
<use_lch4 use_fates=".true." >.false.</use_lch4>
<soil_decomp_method use_cn=".true." >CENTURYKoven2013</soil_decomp_method>
<soil_decomp_method use_fates=".true." >CENTURYKoven2013</soil_decomp_method>
<soil_decomp_method >None</soil_decomp_method>
<use_nitrif_denitrif >.false.</use_nitrif_denitrif>
<use_nitrif_denitrif use_cn=".true." >.true.</use_nitrif_denitrif>
<use_nitrif_denitrif use_fates=".true.">.false.</use_nitrif_denitrif>

<!-- ===== FATES DEFAULTS =========== -->
<fates_spitfire_mode use_fates=".true.">0</fates_spitfire_mode>
Expand Down

0 comments on commit 55ad5ab

Please sign in to comment.