Skip to content

Commit

Permalink
Merge pull request #814 from ekluzek/relfixesfor5028
Browse files Browse the repository at this point in the history
A few fixes and extend mksurfdata to set PFT/CFT fractions but use veg-cover from dataset
  • Loading branch information
ekluzek authored Nov 15, 2019
2 parents c7a45bd + 93444b3 commit d5f3086
Show file tree
Hide file tree
Showing 38 changed files with 1,902 additions and 497 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ clm.input_data_list
clm.input_data_list.previous
*.stdout.txt.o*

# mksurfdata unit tests
unit_test_build

# Tools executables
/tools/mksurfdata_map/mksurfdata_map
/tools/mkprocdata_map/mkprocdata_map
Expand Down
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ required = True
local_path = cime
protocol = git
repo_url = https://github.com/ESMCI/cime
tag = cime5.6.20
tag = cime5.6.25
required = True

[externals_description]
Expand Down
59 changes: 44 additions & 15 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,22 @@ sub setup_cmdl_maxpft {
$log->verbose_message("Using $nl_flags->{'maxpft'} for maxpft.");

$var = "maxpatch_pft";
$val = $nl_flags->{'maxpft'};
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");
if ( ! defined($nl->get_variable_value($group, $var)) ) {
$val = $nl_flags->{'maxpft'};
$nl->set_variable_value($group, $var, $val);
}
$val = $nl->get_variable_value($group, $var);
my @valid_values = ($maxpatchpft{'.true.'}, $maxpatchpft{'.false.'} );
my $found = 0;
foreach my $valid_val ( @valid_values ) {
if ( $val == $valid_val ) {
$found = 1;
last;
}
}
if ( ! $found ) {
$log->warning("$var has a value ($val) that is normally NOT valid. Normal valid values are: @valid_values");
}
}
}
Expand Down Expand Up @@ -1931,6 +1941,12 @@ sub setup_logic_start_type {
if (not defined $nl->get_value('nrevsn')) {
$log->fatal_error("nrevsn is required for a branch type.");
}
if (defined $nl->get_value('use_init_interp')) {
if ( &value_is_true($nl->get_value('use_init_interp') ) ) {
# Always print this warning, but don't stop if it happens
print "\nWARNING: use_init_interp will NOT happen for a branch case.\n\n";
}
}
} else {
if (defined $nl->get_value('nrevsn')) {
$log->fatal_error("nrevsn should ONLY be set for a branch type.");
Expand Down Expand Up @@ -3379,9 +3395,10 @@ sub setup_logic_popd_streams {
if ( defined($nl->get_value('stream_year_first_popdens')) ||
defined($nl->get_value('stream_year_last_popdens')) ||
defined($nl->get_value('model_year_align_popdens')) ||
defined($nl->get_value('popdens_tintalgo' )) ||
defined($nl->get_value('stream_fldfilename_popdens')) ) {
$log->fatal_error("When bgc is SP (NOT CN or BGC) or fire_method==nofire none of: stream_year_first_popdens,\n" .
"stream_year_last_popdens, model_year_align_popdens, nor\n" .
"stream_year_last_popdens, model_year_align_popdens, popdens_tintalgo nor\n" .
"stream_fldfilename_popdens can be set!");
}
}
Expand Down Expand Up @@ -3445,9 +3462,10 @@ sub setup_logic_lightning_streams {
if ( defined($nl->get_value('stream_year_first_lightng')) ||
defined($nl->get_value('stream_year_last_lightng')) ||
defined($nl->get_value('model_year_align_lightng')) ||
defined($nl->get_value('lightng_tintalgo' )) ||
defined($nl->get_value('stream_fldfilename_lightng')) ) {
$log->fatal_error("When bgc is SP (NOT CN or BGC) or fire_method==nofire none of: stream_year_first_lightng,\n" .
"stream_year_last_lightng, model_year_align_lightng, nor\n" .
"stream_year_last_lightng, model_year_align_lightng, lightng_tintalgo nor\n" .
"stream_fldfilename_lightng can be set!");
}
}
Expand Down Expand Up @@ -3525,35 +3543,45 @@ sub setup_logic_megan {

sub setup_logic_soilm_streams {
# prescribed soil moisture streams require clm4_5/clm5_0
my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_;
my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

if ( $physv->as_long() >= $physv->as_long("clm4_5") ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_soil_moisture_streams');
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_soil_moisture_streams');
if ( &value_is_true( $nl->get_value('use_soil_moisture_streams') ) ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'soilm_tintalgo',
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'soilm_tintalgo',
'hgrid'=>$nl_flags->{'res'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_soilm', 'phys'=>$nl_flags->{'phys'},
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'soilm_offset',
'hgrid'=>$nl_flags->{'res'} );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_soilm', 'phys'=>$nl_flags->{'phys'},
'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_soilm', 'phys'=>$nl_flags->{'phys'},
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_soilm', 'phys'=>$nl_flags->{'phys'},
'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
# Set align year, if first and last years are different
if ( $nl->get_value('stream_year_first_soilm') !=
$nl->get_value('stream_year_last_soilm') ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl,
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl,
'model_year_align_soilm', 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
}
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_soilm', 'phys'=>$nl_flags->{'phys'},
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_soilm', 'phys'=>$nl_flags->{'phys'},
'hgrid'=>$nl_flags->{'res'} );
if ( ($opts->{'use_case'} =~ /_transient$/) &&
(remove_leading_and_trailing_quotes($nl->get_value("soilm_tintalgo")) eq "linear") ) {
$log->warning("For a transient case, soil moisture streams, should NOT use soilm_tintalgo='linear'" .
" since vegetated areas could go from missing to not missing or vice versa" );
}
} else {
if ( defined($nl->get_value('stream_year_first_soilm')) ||
defined($nl->get_value('model_year_align_soilm')) ||
defined($nl->get_value('stream_fldfilename_soilm')) ||
defined($nl->get_value('soilm_tintalgo')) ||
defined($nl->get_value('soilm_offset')) ||
defined($nl->get_value('stream_year_last_soilm')) ) {
$log->fatal_error("One of the soilm streams namelist items (stream_year_first_soilm, " .
" model_year_align_soilm, stream_fldfilename_soilm, stream_fldfilename_soilm)" .
" soilm_tintalgo soilm_offset" .
" is defined, but use_soil_moisture_streams option NOT set to true");
}
}
Expand Down Expand Up @@ -3599,9 +3627,10 @@ sub setup_logic_lai_streams {
if ( defined($nl->get_value('stream_year_first_lai')) ||
defined($nl->get_value('stream_year_last_lai')) ||
defined($nl->get_value('model_year_align_lai')) ||
defined($nl->get_value('lai_tintalgo' )) ||
defined($nl->get_value('stream_fldfilename_lai')) ) {
$log->fatal_error("When bgc is NOT SP none of the following can be set: stream_year_first_lai,\n" .
"stream_year_last_lai, model_year_align_lai, nor\n" .
"stream_year_last_lai, model_year_align_lai, lai_tintalgo nor\n" .
"stream_fldfilename_lai (eg. don't use this option with BGC,CN,CNDV nor BGDCV).");
}
}
Expand Down
23 changes: 11 additions & 12 deletions bld/namelist_files/namelist_defaults_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1052,28 +1052,26 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
<stream_year_last_ndep use_cn=".true." sim_year="constant" sim_year_range="1000-1004" >2000</stream_year_last_ndep>

<stream_fldfilename_ndep phys="clm5_0" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="hist" >lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm4_5" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="hist" >lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc</stream_fldfilename_ndep>

<!-- Only the CMIP6 Tier I Nitogen deposition files are available -->
<stream_fldfilename_ndep phys="clm5_0" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP5-8.5"
>lnd/clm2/ndepdata/fndep_clm_SSP585_b.e21.BWSSP585cmip6.f09_g17.CMIP6-SSP5-8.5-WACCM.001_2014-2101_monthly_0.9x1.25_c190211.nc</stream_fldfilename_ndep>
<!-- We currently only have the Tier I Nitogen deposition files available -->
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP5-8.5-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm5_0" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP1-2.6"
>lnd/clm2/ndepdata/fndep_clm_SSP126_b.e21.BWSSP126cmip6.f09_g17.CMIP6-SSP1-2.6-WACCM.001_2014-2101_monthly_0.9x1.25_c190221.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP1-2.6-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm5_0" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP2-4.5"
>lnd/clm2/ndepdata/fndep_clm_SSP245_b.e21.BWSSP245cmip6.f09_g17.CMIP6-SSP2-4.5-WACCM.001_2014-2101_monthly_0.9x1.25_c190401.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP2-4.5-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm5_0" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP3-7.0"
>lnd/clm2/ndepdata/fndep_clm_SSP370_b.e21.BWSSP370cmip6.f09_g17.CMIP6-SSP3-7.0-WACCM.001_2014-2101_monthly_0.9x1.25_c190401.nc</stream_fldfilename_ndep>

<stream_fldfilename_ndep phys="clm4_5" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="hist" >lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP3-7.0-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>

<!-- We currently only have the Tier I Nitogen deposition files available -->
<stream_fldfilename_ndep phys="clm4_5" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP5-8.5"
>lnd/clm2/ndepdata/fndep_clm_SSP585_b.e21.BWSSP585cmip6.f09_g17.CMIP6-SSP5-8.5-WACCM.001_2014-2101_monthly_0.9x1.25_c190211.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP5-8.5-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm4_5" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP1-2.6"
>lnd/clm2/ndepdata/fndep_clm_SSP126_b.e21.BWSSP126cmip6.f09_g17.CMIP6-SSP1-2.6-WACCM.001_2014-2101_monthly_0.9x1.25_c190221.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP1-2.6-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm4_5" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP2-4.5"
>lnd/clm2/ndepdata/fndep_clm_SSP245_b.e21.BWSSP245cmip6.f09_g17.CMIP6-SSP2-4.5-WACCM.001_2014-2101_monthly_0.9x1.25_c190401.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP5-8.5-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>
<stream_fldfilename_ndep phys="clm4_5" hgrid="0.9x1.25" use_cn=".true." ssp_rcp="SSP3-7.0"
>lnd/clm2/ndepdata/fndep_clm_SSP370_b.e21.BWSSP370cmip6.f09_g17.CMIP6-SSP3-7.0-WACCM.001_2014-2101_monthly_0.9x1.25_c190401.nc</stream_fldfilename_ndep>
>lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP3-7.0-WACCM_1849-2101_monthly_c191007.nc</stream_fldfilename_ndep>

<ndep_taxmode phys="clm5_0" use_cn=".true.">cycle</ndep_taxmode>
<ndep_varlist phys="clm5_0" use_cn=".true.">NDEP_month</ndep_varlist>
Expand Down Expand Up @@ -1103,6 +1101,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
<stream_fldfilename_soilm hgrid="0.9x1.25">lnd/clm2/prescribed_data/LFMIP-pdLC-SST.H2OSOI.0.9x1.25.20levsoi.natveg.climo1980-2014.MONS_c190709.nc</stream_fldfilename_soilm>

<soilm_tintalgo>linear</soilm_tintalgo>
<soilm_offset >0</soilm_offset>

<!-- LAI streams namelist defaults -->
<use_lai_streams >.false.</use_lai_streams>
Expand Down
38 changes: 38 additions & 0 deletions bld/namelist_files/namelist_definition_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,11 @@ Time interpolation mode to determine how to handle data before and after the tim
limit = Only use the data within the times available -- abort if the model tries to go outside it
</entry>

<entry id="ndep_tintalgo" type="char*80" category="datasets"
group="ndepdyn_nml" valid_values="linear,nearest,lower,upper" >
Time interpolation method to use for Nitrogen Deposition
</entry>

<entry id="ndep_varlist" type="char*256" category="datasets"
group="ndepdyn_nml" valid_values="" >
Colon delimited list of variables to read from the streams file for nitrogen deposition
Expand Down Expand Up @@ -1584,6 +1589,19 @@ Filename of input stream data for prescribed soil moisture streams data
Time interpolation method to use for prescribed soil moisture streams data
</entry>

<entry id="soilm_offset" type="integer" category="datasets"
group="soil_moisture_streams" >
Offset in time coordinate for soil moisture streams (sec)
</entry>

<entry id="soilm_ignore_data_if_missing" type="logical" category="datasets"
group="soil_moisture_streams" >
If false will abort if using soil moisture streams and find a point where the model shows H2OSOI_VOL
should be set because it's vegetated, but the input soilm streams dataset shows that point is missing.
If true, will ignore the prescribed soilm data for that point and let the model run for that point without
prescribed data.
</entry>

<!-- ======================================================================================== -->
<!-- lai_streams streams Namelist (when phys = CLM4_5) -->
<!-- ======================================================================================== -->
Expand Down Expand Up @@ -1615,6 +1633,11 @@ Simulation year that aligns with stream_year_first_lai value
Filename of input stream data for LAI
</entry>

<entry id="lai_tintalgo" type="char*80" category="datasets"
group="lai_streams" valid_values="linear,nearest,lower,upper" >
Time interpolation method to use with LAI streams
</entry>

<entry id="lai_mapalgo" type="char*256" category="datasets"
group="lai_streams" valid_values="bilinear,nn,nnoni,nnonj,spval,copy" >
Mapping method from LAI input file to the model resolution
Expand Down Expand Up @@ -1651,6 +1674,11 @@ Simulation year that aligns with stream_year_first_lightng value
Filename of input stream data for Lightning
</entry>

<entry id="lightng_tintalgo" type="char*80" category="datasets"
group="light_streams" valid_values="linear,nearest,lower,upper" >
Time interpolation method to use with Lightning streams
</entry>

<entry id="lightngmapalgo" type="char*256" category="datasets"
group="light_streams" valid_values="bilinear,nn,nnoni,nnonj,spval,copy" >
Mapping method from Lightning input file to the model resolution
Expand Down Expand Up @@ -1688,6 +1716,11 @@ Simulation year that aligns with stream_year_first_popdens value
Filename of input stream data for human population density
</entry>

<entry id="popdens_tintalgo" type="char*80" category="datasets"
group="popd_streams" valid_values="linear,nearest,lower,upper" >
Time interpolation method to use with human population density streams
</entry>

<entry id="popdensmapalgo" type="char*256" category="datasets"
group="popd_streams" valid_values="bilinear,nn,nnoni,nnonj,spval,copy" >
Mapping method from human population density input file to the model resolution
Expand Down Expand Up @@ -1725,6 +1758,11 @@ Simulation year that aligns with stream_year_first_urbantv value
Filename of input stream data for urban time varying
</entry>

<entry id="urbantv_tintalgo" type="char*80" category="datasets"
group="urbantv_streams" valid_values="linear,nearest,lower,upper" >
Time interpolation method to use with urban time varying streams
</entry>

<entry id="urbantvmapalgo" type="char*256" category="datasets"
group="urbantv_streams" valid_values="bilinear,nn,nnoni,nnonj,spval,copy" >
Mapping method from urban time varying input file to the model resolution
Expand Down
Loading

0 comments on commit d5f3086

Please sign in to comment.