Skip to content

Commit

Permalink
Merge branch 'rgknox/lnd/fates-part3' into next (PR #1536)
Browse files Browse the repository at this point in the history
This change set completes a first version of 1) the ALM-side interface for FATES,
2) initializes FATES as a submodule and 3) adds a test to acme_land_developer.
Restart simulations, while having the code in place, are not passing tests yet and
will be addressed in forthcoming changesets. Modifications to the namelist build
system were necessary. Thus, there are trivial conflicts with namelists generated
by master, specifically use_ed=.false. is now appended to all namelists where it
is not used.This has no impact on existing tests' model output, however CLM
regression tests will fail namelist comparisons for this reason.
As this PR initializes a new submodule, all CLM users must update their submodule
pointers to bring the fates codeset in, without this the code will not compile.

[BFB]
[NML]
  • Loading branch information
Gautam Bisht committed May 23, 2017
2 parents 1793e10 + 1ee1d0a commit 9233c4b
Show file tree
Hide file tree
Showing 43 changed files with 8,403 additions and 5,074 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
path = components/mpas-cice/model
url = git@github.com:ACME-Climate/MPAS.git
branch = cice/develop
[submodule "components/clm/src/external_models/fates"]
path = components/clm/src/external_models/fates
url = git@github.com:ACME-Climate/fates.git
2 changes: 2 additions & 0 deletions cime/config/acme/machines/config_machines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,7 @@
<machine MACH="lawrencium-lr3">
<DESC>Lawrencium LR3 cluster at LBL, OS is Linux (intel), batch system is SLURM</DESC>
<OS>LINUX</OS>
<NODENAME_REGEX>n000*</NODENAME_REGEX>
<COMPILERS>intel</COMPILERS>
<MPILIBS>openmpi,mpi-serial</MPILIBS>
<CIME_OUTPUT_ROOT>/global/scratch/$ENV{USER}</CIME_OUTPUT_ROOT>
Expand Down Expand Up @@ -2403,6 +2404,7 @@
<machine MACH="lawrencium-lr2">
<DESC>Lawrencium LR2 cluster at LBL, OS is Linux (intel), batch system is SLURM</DESC>
<OS>LINUX</OS>
<NODENAME_REGEX>n000*</NODENAME_REGEX>
<COMPILERS>intel</COMPILERS>
<MPILIBS>openmpi,mpi-serial</MPILIBS>
<CIME_OUTPUT_ROOT>/global/scratch/$ENV{USER}</CIME_OUTPUT_ROOT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ hist_mfilt = 365
hist_nhtfrq = -24
hist_empty_htapes = .true.
hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT',
'STORVEGC','FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef',
'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef',
'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass',
'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','DISPVEGC','AREA_TREES','AREA_PLANT'
'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT',
'HR','TOTLITC','TOTSOMC','AR'

1 change: 1 addition & 0 deletions cime/scripts/lib/update_acme_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
("ERS.f19_g16.I1850CNECACNTBC" ,"clm-eca"),
("ERS.f19_g16.I1850CNECACTCBC" ,"clm-eca"),
("SMS_Ly2_P1x1.1x1_smallvilleIA.ICLM45CNCROP", "force_netcdf_pio"),
("SMS_Ld4.f45_f45.ICLM45ED","clm-fates"),
("ERS.f19_g16.I1850CLM45","clm-betr"),
"ERS.ne11_oQU240.I20TRCLM45",
"ERS.f09_g16.IMCLM45BC")
Expand Down
149 changes: 95 additions & 54 deletions components/clm/bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ REQUIRED OPTIONS
"-sim_year list" to list valid simulation years
(default 2000)
OPTIONS
-bgc "value" Build CLM with BGC package [ sp | cn | bgc ]
-bgc "value" Build CLM with BGC package [ sp | cn | bgc | ed ]
(default is sp).
CLM Biogeochemistry mode
sp = Satellite Phenology (SP)
Expand All @@ -101,9 +101,13 @@ OPTIONS
(or CLM45BGC if phys=clm4_5/clm5_0, use_cn=true, use_vertsoilc=true,
use_century_decomp=true, use_nitrif_denitrif=true, and use_lch4=true,
use_dynroot)
This toggles on the namelist variables:
This toggles on the namelist variables:
use_cn, use_lch4, use_nitrif_denitrif, use_vertsoilc, use_century_decomp,
use_dynroot
ed = (fates) functionaly assembled terrestrial ecosystem simulator
with native below ground bgc
This toggles on the namelist variables:
use_ed, 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 @@ -161,8 +165,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 and use_spit_fire.
-fsnowoptics "opticalpropertiesfile" Snow optical properties input file
-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
Expand Down Expand Up @@ -295,7 +297,6 @@ sub process_commandline {
bgc => "default",
crop => 0,
dynamic_vegetation => 0,
ed_mode => 0,
envxml_dir => ".",
vichydro => 0,
maxpft => "default",
Expand Down Expand Up @@ -345,7 +346,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 @@ -679,7 +679,7 @@ sub process_namelist_commandline_options {
setup_cmdl_simulation_year($opts, $nl_flags, $definition, $defaults, $nl);
setup_cmdl_run_type($opts, $nl_flags, $definition, $defaults, $nl);
setup_cmdl_dynamic_vegetation($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_cmdl_ed_mode($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_cmdl_fates_mode($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_cmdl_vichydro($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_cmdl_betr_mode($opts, $nl_flags, $definition, $defaults, $nl, $physv);
}
Expand Down Expand Up @@ -750,54 +750,66 @@ sub setup_cmdl_mask {
verbose_message("CLM land mask is $nl_flags->{'mask'}");
}

#-------------------------------------------------------------------------------
sub setup_cmdl_ed_mode {
sub setup_cmdl_fates_mode {
#
# call this at least after crop check is called
#
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" );
}
} elsif ($nl_flags->{"bgc_mode"} eq "ed" && $nl_flags->{"use_ed"} ne ".true.") {
fatal_error("DEV_ERROR: internal logic error: bgc_mode = ed and use_ed = false.\n");

} else {

$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;
}
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
# 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 -bgc ed 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_spitfire", "use_vertsoilc", "use_century_decomp" );
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'} );


$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");
}
} else {
$var = "use_ed_spit_fire";
# we only dis-allow ed_spitfire with non-ed runs
$var = "use_ed_spitfire";
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 All @@ -817,10 +829,10 @@ sub setup_cmdl_betr_mode {
$nl_flags->{'betr_mode'} = $val;

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

$var = "use_betr";
Expand Down Expand Up @@ -907,6 +919,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 All @@ -929,15 +942,25 @@ sub setup_cmdl_bgc {
my $setting = ".false.";
if ($nl_flags->{$var} eq "cn") {
$nl_flags->{'use_cn'} = ".true.";
$nl_flags->{'use_ed'} = ".false.";
} elsif ($nl_flags->{$var} eq "bgc") {
$nl_flags->{'use_cn'} = ".true.";
$nl_flags->{'use_ed'} = ".false.";
$setting = ".true.";
} 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 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;
Expand Down Expand Up @@ -966,14 +989,18 @@ sub setup_cmdl_bgc {
fatal_error("You are contradicting the -bgc setting with the namelist variables: @list" );
}

# 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
# $var = "use_cn";

# 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");
}
}

# Now set use_dynroot
Expand Down Expand Up @@ -1873,6 +1900,7 @@ sub process_namelist_inline_logic {
setup_logic_bgc_spinup($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv);
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_fates($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv);

#########################################
# namelist group: clm_humanindex_inparm #
Expand Down Expand Up @@ -2947,7 +2975,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 @@ -3008,7 +3036,7 @@ sub setup_logic_phosphorus_deposition {
# 'hgrid'=>"1.9x2.5" );

# } elsif ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) {
if ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) {
if ( $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, 'pdepmapalgo', '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_pdep', 'phys'=>$nl_flags->{'phys'},
Expand Down Expand Up @@ -3046,7 +3074,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'} =~/cn|bgc/ ) {
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 @@ -3083,7 +3111,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'} =~/cn|bgc/ ) {
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 @@ -3138,7 +3166,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 @@ -3230,6 +3258,19 @@ sub setup_logic_pflotran {
}
} # end setup_logic_pflotran

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

sub setup_logic_fates {
#
# 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_ed_spitfire', 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'});
}
}

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

Expand Down
7 changes: 5 additions & 2 deletions components/clm/bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OPTIONS
or double leading dashes. A consequence of this is that single letter options may
NOT be bundled.
-bgc <name> Build CLM with BGC package [ none | cn | cndv ]
-bgc <name> Build CLM with BGC package [ none | cn | cndv | ed]
(default is none).
-cache <file> Name of output cache file (default: config_cache.xml).
-cachedir <file> Name of directory where output cache file is written
Expand Down Expand Up @@ -654,7 +654,10 @@ sub write_filepath_cesmbld
"biogeophys/vsfm",
"biogeochem",
"dyn_subgrid",
"ED/main",
"external_models/fates/main",
"external_models/fates/biogeophys",
"external_models/fates/biogeochem",
"external_models/fates/fire",
"utils",
"cpl" );

Expand Down
Loading

0 comments on commit 9233c4b

Please sign in to comment.