Skip to content

Commit b0632b0

Browse files
committed
Merge branch 'b4b-dev' into update_submodules_cesm30alpha07g
2 parents fc14c33 + fabf7e4 commit b0632b0

File tree

11 files changed

+298
-17
lines changed

11 files changed

+298
-17
lines changed

bld/CLMBuildNamelist.pm

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3746,6 +3746,8 @@ sub setup_logic_c_isotope {
37463746
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_c14',
37473747
'bgc_mode'=>$nl_flags->{'bgc_mode'}, 'phys'=>$nl_flags->{'phys'},
37483748
'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'}, ssp_rcp=>$nl_flags->{'ssp_rcp'} );
3749+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c13" );
3750+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c14" );
37493751
my $use_c13 = $nl->get_value('use_c13');
37503752
my $use_c14 = $nl->get_value('use_c14');
37513753
if ( $nl_flags->{'bgc_mode'} ne "sp" && $nl_flags->{'bgc_mode'} ne "fates" ) {
@@ -3765,6 +3767,7 @@ sub setup_logic_c_isotope {
37653767
$use_c14_bombspike = $nl->get_value('use_c14_bombspike');
37663768
if ( &value_is_true($use_c14_bombspike) ) {
37673769
if ( defined($stream_fldfilename_atm_c14) ) {
3770+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c14_bombspike" );
37683771
setup_logic_c14_streams($opts, $nl_flags, $definition, $defaults, $nl);
37693772
} else {
37703773
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'atm_c14_filename',
@@ -3784,6 +3787,8 @@ sub setup_logic_c_isotope {
37843787
$log->fatal_error("use_c14 is FALSE and use_c14_bombspike, stream_fldfilename_atm_c14 or atm_c14_filename set");
37853788
}
37863789
}
3790+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c14_bombspike" );
3791+
37873792
my $use_c13_timeseries = $nl->get_value('use_c13_timeseries');
37883793
my $stream_fldfilename_atm_c13 = $nl->get_value('stream_fldfilename_atm_c13');
37893794
my $atm_c13_filename = $nl->get_value('atm_c13_filename');
@@ -3792,6 +3797,7 @@ sub setup_logic_c_isotope {
37923797
$use_c13_timeseries = $nl->get_value('use_c13_timeseries');
37933798
if ( &value_is_true($use_c13_timeseries) ) {
37943799
if ( defined($stream_fldfilename_atm_c13) ) {
3800+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c13_timeseries" );
37953801
setup_logic_c13_streams($opts, $nl_flags, $definition, $defaults, $nl);
37963802
} else {
37973803
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'atm_c13_filename',
@@ -3823,6 +3829,8 @@ sub setup_logic_c_isotope {
38233829
$log->fatal_error("bgc=sp and C isotope namelist variables were set, both can't be used at the same time");
38243830
}
38253831
}
3832+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c13_timeseries" );
3833+
&add_logical_to_nl_flags( $nl_flags, $nl, "use_c13_bombspike" );
38263834
}
38273835

38283836
#-------------------------------------------------------------------------------
@@ -3832,6 +3840,23 @@ sub setup_logic_c13_streams {
38323840
#
38333841
# C13 stream file settings
38343842
#
3843+
# Just return if use_c13 and use_c13_timeseries aren't both TRUE
3844+
if ( ! &value_is_true($nl_flags->{'use_c13'}) ) { return; }
3845+
if ( ! &value_is_true($nl_flags->{'use_c13_timeseries'}) ) { return; }
3846+
3847+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_atm_c13',
3848+
'use_c13'=>$nl_flags->{'use_c13'}, 'use_c13_timeseries'=>$nl_flags->{'use_c13_timeseries'},
3849+
'ssp_rcp'=>$nl_flags->{'ssp_rcp'});
3850+
3851+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_atm_c13',
3852+
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
3853+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_atm_c13',
3854+
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
3855+
# Set align year, if first and last years are different
3856+
if ( $nl->get_value('stream_year_first_atm_c13') != $nl->get_value('stream_year_last_atm_c13') ) {
3857+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_model_year_align_atm_c13',
3858+
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
3859+
}
38353860
}
38363861

38373862
#-------------------------------------------------------------------------------
@@ -3841,6 +3866,30 @@ sub setup_logic_c14_streams {
38413866
#
38423867
# C14 stream file settings
38433868
#
3869+
# Just return if use_c14 and use_c14_bombspike aren't both TRUE
3870+
if ( ! &value_is_true($nl_flags->{'use_c14'}) ) { return; }
3871+
if ( ! &value_is_true($nl_flags->{'use_c14_bombspike'}) ) { return; }
3872+
3873+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_atm_c14',
3874+
'use_c14'=>$nl_flags->{'use_c14'}, 'use_c14_bombspike'=>$nl_flags->{'use_c14_bombspike'},
3875+
'ssp_rcp'=>$nl_flags->{'ssp_rcp'});
3876+
3877+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_meshfile_atm_c14',
3878+
'use_c14'=>$nl_flags->{'use_c14'}, 'use_c14_bombspike'=>$nl_flags->{'use_c14_bombspike'});
3879+
if ( &remove_leading_and_trailing_quotes( $nl->get_value( "stream_meshfile_atm_c14") ) eq "none" ) {
3880+
# TODP: Change this to a fatal when we start using this
3881+
$log->warning( "stream_meshfile_atm_c14 is set to 'none' which will only copy the first latitude to the globe")
3882+
}
3883+
3884+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_atm_c14',
3885+
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
3886+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_atm_c14',
3887+
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
3888+
# Set align year, if first and last years are different
3889+
if ( $nl->get_value('stream_year_first_atm_c14') != $nl->get_value('stream_year_last_atm_c14') ) {
3890+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_model_year_align_atm_c14',
3891+
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
3892+
}
38443893
}
38453894

38463895
#-------------------------------------------------------------------------------
@@ -5937,6 +5986,27 @@ sub logical_to_fortran {
59375986

59385987
#-------------------------------------------------------------------------------
59395988

5989+
sub add_logical_to_nl_flags {
5990+
# Add a logical setting to the $nl_flsgs hash, so can be used in attribute checking
5991+
# This is important to do to make sure that the attribute is matched exactly as
5992+
# either: .true. or .false.
5993+
# Also sets nl_flags to .false. when the namelist variable is NOT set
5994+
my ($nl_flags, $nl, $var) = @_;
5995+
5996+
my $val = $nl->get_value($var);
5997+
if ( defined($val) ) {
5998+
if ( &value_is_true($val)) {
5999+
$nl_flags->{$var} = ".true.";
6000+
} else {
6001+
$nl_flags->{$var} = ".false.";
6002+
}
6003+
} else {
6004+
$nl_flags->{$var} = ".false.";
6005+
}
6006+
}
6007+
6008+
#-------------------------------------------------------------------------------
6009+
59406010
sub string_is_undef_or_empty {
59416011
# Return true if the given string is undefined or only spaces, false otherwise.
59426012
# A quoted empty string (' ' or " ") is treated as being empty.

bld/namelist_files/namelist_defaults_ctsm.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,58 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
149149
<atm_c14_filename use_c14=".true." use_c14_bombspike =".true." ssp_rcp="SSP5-3.4" >lnd/clm2/isotopes/atm_delta_C14_CMIP6_SSP534os_3x1_global_1850-2100_yearly_c181209.nc</atm_c14_filename>
150150
<atm_c14_filename use_c14=".true." use_c14_bombspike =".true." ssp_rcp="SSP5-8.5" >lnd/clm2/isotopes/atm_delta_C14_CMIP6_SSP5B_3x1_global_1850-2100_yearly_c181209.nc</atm_c14_filename>
151151

152+
<!-- Settings for Carbon Isotope streams -->
153+
<stream_fldfilename_atm_c14 use_c14=".true." use_c14_bombspike =".true." ssp_rcp="hist" >lnd/clm2/isotopes/ctsmforc.Graven.atm_delta_C14_CMIP7_360x720_1700-2023_yearly_v3.0_c251117.nc</stream_fldfilename_atm_c14>
154+
<stream_meshfile_atm_c14 use_c14=".true." use_c14_bombspike =".true." >share/meshes/360x720_120830_ESMFmesh_c20210507.nc</stream_meshfile_atm_c14>
155+
156+
<!-- The following are only set if both use_c14 and use_c14_bombspike are TRUE -->
157+
<stream_year_first_atm_c14 sim_year="2018" sim_year_range="constant">2018</stream_year_first_atm_c14>
158+
<stream_year_last_atm_c14 sim_year="2018" sim_year_range="constant">2018</stream_year_last_atm_c14>
159+
160+
<stream_year_first_atm_c14 sim_year="2010" sim_year_range="constant">2010</stream_year_first_atm_c14>
161+
<stream_year_last_atm_c14 sim_year="2010" sim_year_range="constant">2010</stream_year_last_atm_c14>
162+
163+
<stream_year_first_atm_c14 sim_year="2000" sim_year_range="constant">2000</stream_year_first_atm_c14>
164+
<stream_year_last_atm_c14 sim_year="2000" sim_year_range="constant">2000</stream_year_last_atm_c14>
165+
166+
<stream_year_first_atm_c14 sim_year="1979" sim_year_range="constant">1850</stream_year_first_atm_c14>
167+
<stream_year_last_atm_c14 sim_year="1979" sim_year_range="constant">1850</stream_year_last_atm_c14>
168+
169+
<stream_year_first_atm_c14 sim_year="1850" sim_year_range="constant">1850</stream_year_first_atm_c14>
170+
<stream_year_last_atm_c14 sim_year="1850" sim_year_range="constant">1850</stream_year_last_atm_c14>
171+
172+
<stream_year_first_atm_c14 sim_year="PtVg" sim_year_range="constant">1700</stream_year_first_atm_c14>
173+
<stream_year_last_atm_c14 sim_year="PtVg" sim_year_range="constant">1700</stream_year_last_atm_c14>
174+
175+
<stream_year_first_atm_c14 sim_year_range="1850-2000" >1700</stream_year_first_atm_c14>
176+
<stream_year_last_atm_c14 sim_year_range="1850-2000" >2023</stream_year_last_atm_c14>
177+
<stream_model_year_align_atm_c14 sim_year_range="1850-2000" >1700</stream_model_year_align_atm_c14>
178+
179+
<stream_fldfilename_atm_c13 use_c13=".true." use_c13_timeseries=".true." ssp_rcp="hist" >lnd/clm2/isotopes/ctsmforc.Graven.atm_delta_C13_CMIP7_global_1700-2023_yearly_v3.0_c251013.nc</stream_fldfilename_atm_c13>
180+
181+
<!-- The following are only set if both use_c13 and use_c13_bonbspike are TRUE -->
182+
<stream_year_first_atm_c13 sim_year="2018" sim_year_range="constant" >2018</stream_year_first_atm_c13>
183+
<stream_year_last_atm_c13 sim_year="2018" sim_year_range="constant" >2018</stream_year_last_atm_c13>
184+
185+
<stream_year_first_atm_c13 sim_year="2010" sim_year_range="constant" >2010</stream_year_first_atm_c13>
186+
<stream_year_last_atm_c13 sim_year="2010" sim_year_range="constant" >2010</stream_year_last_atm_c13>
187+
188+
<stream_year_first_atm_c13 sim_year="2000" sim_year_range="constant" >2000</stream_year_first_atm_c13>
189+
<stream_year_last_atm_c13 sim_year="2000" sim_year_range="constant" >2000</stream_year_last_atm_c13>
190+
191+
<stream_year_first_atm_c13 sim_year="1979" sim_year_range="constant" >1850</stream_year_first_atm_c13>
192+
<stream_year_last_atm_c13 sim_year="1979" sim_year_range="constant" >1850</stream_year_last_atm_c13>
193+
194+
<stream_year_first_atm_c13 sim_year="1850" sim_year_range="constant" >1850</stream_year_first_atm_c13>
195+
<stream_year_last_atm_c13 sim_year="1850" sim_year_range="constant" >1850</stream_year_last_atm_c13>
196+
197+
<stream_year_first_atm_c13 sim_year="PtVg" sim_year_range="constant" >1700</stream_year_first_atm_c13>
198+
<stream_year_last_atm_c13 sim_year="PtVg" sim_year_range="constant" >1700</stream_year_last_atm_c13>
199+
200+
<stream_year_first_atm_c13 sim_year_range="1850-2000" >1700</stream_year_first_atm_c13>
201+
<stream_year_last_atm_c13 sim_year_range="1850-2000" >2023</stream_year_last_atm_c13>
202+
<stream_model_year_align_atm_c13 sim_year_range="1850-2000" >1700</stream_model_year_align_atm_c13>
203+
152204
<!-- Irrigation default (Note, the use-cases also set this) -->
153205
<irrigate >.false.</irrigate>
154206
<irrigate use_cndv=".false." sim_year_range="1850-2100">.true.</irrigate>

bld/namelist_files/namelist_definition_ctsm.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,19 +1818,37 @@ First year to loop over for atmospheric C14 isotope delta data
18181818

18191819
<entry id="stream_year_last_atm_c14" type="integer" category="datasets"
18201820
group="carbon_isotope_streams" valid_values="" >
1821-
Last year to loop over for data atmospheric C14 isotope delta data
1821+
Last year to loop over for atmospheric C14 isotope delta data
18221822
</entry>
18231823

18241824
<entry id="stream_model_year_align_atm_c14" type="integer" category="datasets"
18251825
group="carbon_isotope_streams" valid_values="" >
18261826
Simulation year that aligns with stream_year_first_atm_c14 value
18271827
</entry>
18281828

1829+
<entry id="stream_tintalgo_atm_c14" type="char*256" category="datasets"
1830+
group="carbon_isotope_streams" valid_values="linear,nearest,lower,upper" >
1831+
Time interpolation method to use for atmospheric C14 delta data
1832+
</entry>
1833+
1834+
<entry id="stream_taxmode_atm_c14" type="char*80" category="datasets"
1835+
group="carbon_isotope_streams" valid_values="cycle,extend,limit" >
1836+
Time interpolation mode for atmospheric C14 delta data to determine how to handle data before and after the times in the file
1837+
cycle = Always cycle over the data
1838+
extend = Use the first time before the available data, and use the last time after the available data
1839+
limit = Only use the data within the times available -- abort if the model tries to go outside it
1840+
</entry>
1841+
18291842
<entry id="stream_fldfilename_atm_c14" type="char*512" category="datasets"
18301843
input_pathname="abs" group="carbon_isotope_streams" valid_values="" >
18311844
Filename of input stream data for atmospheric C14 isotope delta data
18321845
</entry>
18331846

1847+
<entry id="stream_meshfile_atm_c14" type="char*512" category="datasets"
1848+
input_pathname="abs" group="carbon_isotope_streams" valid_values="" >
1849+
Filename of input stream mesh for atmospheric C14 isotope delta data
1850+
</entry>
1851+
18341852
<entry id="stream_year_first_atm_c13" type="integer" category="datasets"
18351853
group="carbon_isotope_streams" valid_values="" >
18361854
First year to loop over for atmospheric C13 isotope delta data
@@ -1846,6 +1864,19 @@ Last year to loop over for data atmospheric C13 isotope delta data
18461864
Simulation year that aligns with stream_year_first_atm_c13 value
18471865
</entry>
18481866

1867+
<entry id="stream_tintalgo_atm_c13" type="char*256" category="datasets"
1868+
group="carbon_isotope_streams" valid_values="linear,nearest,lower,upper" >
1869+
Time interpolation method to use for atmospheric C13 delta data
1870+
</entry>
1871+
1872+
<entry id="stream_taxmode_atm_c13" type="char*80" category="datasets"
1873+
group="carbon_isotope_streams" valid_values="cycle,extend,limit" >
1874+
Time interpolation mode for atmospheric C13 delta data to determine how to handle data before and after the times in the file
1875+
cycle = Always cycle over the data
1876+
extend = Use the first time before the available data, and use the last time after the available data
1877+
limit = Only use the data within the times available -- abort if the model tries to go outside it
1878+
</entry>
1879+
18491880
<entry id="stream_fldfilename_atm_c13" type="char*512" category="datasets"
18501881
input_pathname="abs" group="carbon_isotope_streams" valid_values="" >
18511882
Filename of input stream data for atmospheric C13 isotope delta data

bld/unit_testers/build-namelist_test.pl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile {
163163
#
164164
# Figure out number of tests that will run
165165
#
166-
my $ntests = 3400;
166+
my $ntests = 3403;
167167

168168
if ( defined($opts{'compare'}) ) {
169169
$ntests += 2061;
@@ -1421,6 +1421,11 @@ sub cat_and_create_namelistinfile {
14211421
namelst=>"use_soil_moisture_streams=T,soilm_tintalgo='linear'",
14221422
phys=>"clm5_0",
14231423
},
1424+
"c14_meshfile_none" =>{ options=>"-envxml_dir . -bgc bgc",
1425+
namelst=>"stream_fldfilename_atm_c14='/dev/null', " .
1426+
"stream_meshfile_atm_c14='none'",
1427+
phys=>"clm6_0",
1428+
},
14241429
"missing_ndep_file" =>{ options=>"-envxml_dir . -bgc bgc -ssp_rcp SSP5-3.4",
14251430
namelst=>"",
14261431
phys=>"clm5_0",
@@ -1611,9 +1616,9 @@ sub cat_and_create_namelistinfile {
16111616
&cleanup(); print "\n";
16121617
}
16131618

1614-
print "\n==================================================\n";
1615-
print " Test all use-cases over all physics options\n";
1616-
print "==================================================\n";
1619+
print "\n=============================================================\n";
1620+
print " Test all use-cases over all physics options for f09 and SP \n";
1621+
print "=============================================================\n";
16171622

16181623
# Run over all use-cases for f09 and all physics...
16191624
my $list = `$bldnml -use_case list 2>&1 | grep "use case"`;
@@ -1634,7 +1639,8 @@ sub cat_and_create_namelistinfile {
16341639
&make_config_cache($phys);
16351640
foreach my $usecase ( @usecases ) {
16361641
print "usecase = $usecase\n";
1637-
$options = "-res 0.9x1.25 -use_case $usecase -envxml_dir .";
1642+
# Just do SP here as some use-cases can't do crop (nonanthro), and some not BGC (stdurbpt)
1643+
$options = "-res 0.9x1.25 -use_case $usecase --bgc bgc -envxml_dir .";
16381644
&make_env_run();
16391645
my $expect_fail = undef;
16401646
foreach my $failusecase ( @expect_fails ) {
@@ -1940,6 +1946,12 @@ sub cat_and_create_namelistinfile {
19401946
my @clmres = ( "10x15", "4x5", "360x720cru", "0.9x1.25", "1.9x2.5", "ne3np4", "ne3np4.pg3", "ne16np4.pg3", "ne30np4.pg3", "C96", "mpasa120" );
19411947
foreach my $res ( @clmres ) {
19421948
$options = "-res $res -envxml_dir . ";
1949+
# For clm6_0 and BGC use Carbon isotope streams
1950+
if ( ($phys eq "clm6_0") && ($clmopts =~ /bgc bgc/) ) {
1951+
$options = "$options --namelist \"&a stream_fldfilename_atm_c14 = '/dev/null'," .
1952+
"stream_meshfile_atm_c14 = '/dev/null', " .
1953+
"stream_fldfilename_atm_c13 = '/dev/null' /\"";
1954+
}
19431955
&make_env_run( );
19441956
eval{ system( "$bldnml $options $clmopts > $tempfile 2>&1 " ); };
19451957
is( $@, '', "$options $clmopts" );
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This tests with the new CMIP7 Carbon isotope datasets as streams.
2+
3+
However, this uses the initial version of C14 and hence C14 is constant with the value
4+
over the southern pole latitude band. When we can change answers the ignore-warning should
5+
be removed and the CMIP7 defaults setup to use the streams rather than default to the
6+
CMIP6 version.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
./xmlchange CLM_BLDNML_OPTS=-ignore_warnings --append
4+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
stream_fldfilename_atm_c13 = '$DIN_LOC_ROOT/lnd/clm2/isotopes/ctsmforc.Graven.atm_delta_C13_CMIP7_global_1700-2023_yearly_v3.0_c251013.nc'
2+
! NOTE: This file is the one with only 4 latitude bands, and can't be used by streams for regridding
3+
! The one copied to a half degree grid can be used to regrid the bands properly
24
stream_fldfilename_atm_c14 = '$DIN_LOC_ROOT/lnd/clm2/isotopes/ctsmforc.Graven.atm_delta_C14_CMIP7_4x1_global_1700-2023_yearly_v3.0_c251013.nc'
35
stream_year_first_atm_c14 = 2013
6+
stream_meshfile_atm_c14 = 'none' ! NOTE: By NOT using a mesh file this means the first value will be copied to the whole grid rather than regridded
47
stream_model_year_align_atm_c14 = 2013
58
stream_year_first_atm_c13 = 2013
69
stream_model_year_align_atm_c13 = 2013

0 commit comments

Comments
 (0)