Skip to content

Commit 61955c5

Browse files
authored
Merge pull request #2844 from ekluzek/fire_emis
branch with 5.3.05Y: Make sure FORTRAN code properly aborts when fire-emission is asked for and it can't be provided
2 parents 027adc5 + 99aed55 commit 61955c5

36 files changed

+1044
-134
lines changed

bld/CLMBuildNamelist.pm

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,7 +4071,16 @@ sub setup_logic_fire_emis {
40714071
if ( &value_is_true( $nl_flags->{'use_fates'} ) ) {
40724072
$log->warning("Fire emission option $var can NOT be on when FATES is also on.\n" .
40734073
" DON'T use the '--fire_emis' option when '--bgc fates' is activated");
4074-
}
4074+
} elsif ( ! &value_is_true( $nl_flags->{'use_cn'} ) ) {
4075+
$log->fatal_error("Fire emission option $var can NOT be on when BGC SP (i.e. Satellite Phenology) is also on.\n" .
4076+
" DON'T use the '--fire_emis' option when '--bgc sp' is activated");
4077+
} elsif ( &value_is_true( $nl_flags->{'use_cn'}) ) {
4078+
my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') );
4079+
if ( $fire_method eq "nofire" ) {
4080+
$log->fatal_error("Fire emission option $var can NOT be on with BGC and fire_method=='nofire'.\n" .
4081+
" DON'T use the '--fire_emis' option when fire_method is nofire");
4082+
}
4083+
}
40754084
}
40764085
}
40774086
}
@@ -4235,7 +4244,7 @@ sub setup_logic_lai_streams {
42354244
if ( &value_is_true($nl_flags->{'use_crop'}) && &value_is_true($nl->get_value('use_lai_streams')) ) {
42364245
$log->fatal_error("turning use_lai_streams on is incompatable with use_crop set to true.");
42374246
}
4238-
if ( $nl_flags->{'bgc_mode'} eq "sp" || ($nl_flags->{'bgc_mode'} eq "fates" && &value_is_true($nl->get_value('use_fates_sp')) )) {
4247+
if ( $nl_flags->{'bgc_mode'} eq "sp" || ($nl_flags->{'bgc_mode'} eq "fates" && &value_is_true($nl_flags->{'use_fates_sp'}) )) {
42394248
if ( &value_is_true($nl->get_value('use_lai_streams')) ) {
42404249
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_lai_streams');
42414250
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lai_mapalgo',
@@ -4745,29 +4754,26 @@ sub setup_logic_fates {
47454754
# For FATES SP mode make sure no-competetiion, and fixed-biogeography are also set
47464755
# And also check for other settings that can't be trigged on as well
47474756
#
4748-
my $var = "use_fates_sp";
4749-
if ( defined($nl->get_value($var)) ) {
4750-
if ( &value_is_true($nl->get_value($var)) ) {
4751-
my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog" );
4752-
foreach my $var ( @list ) {
4753-
if ( ! &value_is_true($nl->get_value($var)) ) {
4754-
$log->fatal_error("$var is required when FATES SP is on (use_fates_sp)" );
4755-
}
4756-
}
4757-
# spit-fire can't be on with FATES SP mode is active
4758-
if ( $nl->get_value('fates_spitfire_mode') > 0 ) {
4759-
$log->fatal_error('fates_spitfire_mode can NOT be set to greater than 0 when use_fates_sp is true');
4760-
}
4757+
if ( &value_is_true($nl_flags->{'use_fates_sp'}) ) {
4758+
my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog" );
4759+
foreach my $var ( @list ) {
4760+
if ( ! &value_is_true($nl->get_value($var)) ) {
4761+
$log->fatal_error("$var is required when FATES SP is on (use_fates_sp)" );
4762+
}
4763+
}
4764+
# spit-fire can't be on with FATES SP mode is active
4765+
if ( $nl->get_value('fates_spitfire_mode') > 0 ) {
4766+
$log->fatal_error('fates_spitfire_mode can NOT be set to greater than 0 when use_fates_sp is true');
4767+
}
47614768

4762-
# fates landuse can't be on with FATES SP mode is active
4763-
if ( &value_is_true($nl->get_value('use_fates_luh')) ) {
4764-
$log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true');
4765-
}
4769+
# fates landuse can't be on with FATES SP mode is active
4770+
if ( &value_is_true($nl->get_value('use_fates_luh')) ) {
4771+
$log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true');
4772+
}
47664773

4767-
# hydro isn't currently supported to work when FATES SP mode is active
4768-
if (&value_is_true( $nl->get_value('use_fates_planthydro') )) {
4769-
$log->fatal_error('fates sp mode is currently not supported to work with fates hydro');
4770-
}
4774+
# hydro isn't currently supported to work when FATES SP mode is active
4775+
if (&value_is_true( $nl->get_value('use_fates_planthydro') )) {
4776+
$log->fatal_error('fates sp mode is currently not supported to work with fates hydro');
47714777
}
47724778
}
47734779
my $var = "use_fates_inventory_init";
@@ -4792,6 +4798,13 @@ sub setup_logic_fates {
47924798
}
47934799
}
47944800
}
4801+
# Check that both FaTES-SP and FATES ST3 aren't both on
4802+
my $var = "use_fates_ed_st3";
4803+
if ( defined($nl->get_value($var)) ) {
4804+
if ( &value_is_true($nl->get_value($var)) && &value_is_true($nl_flags->{'use_fates_sp'}) ) {
4805+
$log->fatal_error("$var can NOT also be true with use_fates_sp true" );
4806+
}
4807+
}
47954808
# check that fates landuse change mode has the necessary luh2 landuse timeseries data
47964809
# and add the default if not defined. Do not add default if use_fates_potentialveg is true.
47974810
# If fixed biogeography is on, make sure that flandusepftdat is avilable.

bld/unit_testers/build-namelist_test.pl

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

168168
if ( defined($opts{'compare'}) ) {
169-
$ntests += 1987;
169+
$ntests += 2161;
170170
}
171171
plan( tests=>$ntests );
172172

@@ -288,7 +288,7 @@ sub cat_and_create_namelistinfile {
288288
&make_config_cache($phys);
289289
my @mfiles = ( "lnd_in", "drv_flds_in", $tempfile );
290290
my $mfiles = NMLTest::CompFiles->new( $cwd, @mfiles );
291-
foreach my $options ( "-drydep", "-megan", "-drydep -megan", "-fire_emis", "-drydep -megan -fire_emis" ) {
291+
foreach my $options ( "-drydep --bgc sp", "-megan --bgc sp", "-drydep -megan --bgc bgc", "-fire_emis --bgc bgc", "-drydep -megan -fire_emis --bgc bgc" ) {
292292
&make_env_run();
293293
eval{ system( "$bldnml -envxml_dir . $options > $tempfile 2>&1 " ); };
294294
is( $@, '', "options: $options" );
@@ -576,8 +576,8 @@ sub cat_and_create_namelistinfile {
576576
"--res 1.9x2.5 --bgc bgc --use_case 1850-2100_SSP2-4.5_transient --namelist '&a start_ymd=19101023/'",
577577
"-namelist \"&a dust_emis_method='Zender_2003', zender_soil_erod_source='lnd' /'\"",
578578
"-bgc bgc -use_case 2000_control -namelist \"&a fire_method='nofire'/\" -crop",
579-
"-res 0.9x1.25 -bgc sp -use_case 1850_noanthro_control -drydep -fire_emis",
580-
"-res 0.9x1.25 -bgc bgc -use_case 1850_noanthro_control -drydep -fire_emis -light_res 360x720",
579+
"-res 0.9x1.25 -bgc sp -use_case 1850_noanthro_control -drydep",
580+
"-res 0.9x1.25 -bgc bgc -use_case 1850_noanthro_control -drydep -fire_emis -megan -light_res 360x720",
581581
"--bgc bgc --light_res none --namelist \"&a fire_method='nofire'/\"",
582582
"--bgc fates --light_res 360x720 --no-megan --namelist \"&a fates_spitfire_mode=2/\"",
583583
"--bgc fates --light_res none --no-megan --namelist \"&a fates_spitfire_mode=1/\"",
@@ -1093,6 +1093,10 @@ sub cat_and_create_namelistinfile {
10931093
namelst=>"suplnitro='NONE'",
10941094
phys=>"clm6_0",
10951095
},
1096+
"FATESwBothSpST3" =>{ options=>"--bgc fates --envxml_dir . --no-megan",
1097+
namelst=>"use_fates_sp = TRUE, use_fates_ed_st3 = TRUE",
1098+
phys=>"clm6_0",
1099+
},
10961100
"FireNoneButBGCfireon" =>{ options=>"-bgc bgc -envxml_dir . -light_res none",
10971101
namelst=>"fire_method='li2021gswpfrc'",
10981102
phys=>"clm6_0",
@@ -1145,6 +1149,14 @@ sub cat_and_create_namelistinfile {
11451149
namelst=>"",
11461150
phys=>"clm4_5",
11471151
},
1152+
"useFIREEMISwithNOFIRE" =>{ options=>"--bgc bgc --envxml_dir . --fire_emis",
1153+
namelst=>"fire_method='nofire'",
1154+
phys=>"clm6_0",
1155+
},
1156+
"useFIREEMISwithSP" =>{ options=>"--bgc sp --envxml_dir . --fire_emis",
1157+
namelst=>"",
1158+
phys=>"clm6_0",
1159+
},
11481160
"useDRYDEPwithFATES" =>{ options=>"--bgc fates --envxml_dir . --no-megan --drydep",
11491161
namelst=>"",
11501162
phys=>"clm4_5",

cime_config/config_component.xml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,24 @@
241241
<type>char</type>
242242
<default_value></default_value>
243243
<values>
244-
<!--- All versions -->
245-
<value compset="_CLM[^_]*%SP" >-bgc sp</value>
246-
<value compset="_CLM[^_]*BGC" >-bgc bgc</value>
247-
<value compset="_CLM[^_]*BGC-CROP" >-bgc bgc -crop</value>
248-
<value compset="_CLM[^_]*FATES" >-bgc fates -no-megan</value>
249-
<value compset="_CLM[^_]*FATES-SP" >-bgc fates -no-megan</value>
244+
<!--- All versions with DATM -->
245+
<value compset="DATM[^_]*_CLM[^_]*%SP" >-bgc sp</value>
246+
<value compset="DATM[^_]*_CLM[^_]*BGC" >-bgc bgc</value>
247+
<value compset="DATM[^_]*_CLM[^_]*BGC-CROP" >-bgc bgc -crop</value>
248+
249+
<!-- FATES currently can't use MEGAN, drydep, or fire-emission whether coupled to CAM or NOT-->
250+
<value compset="CLM[^_]*FATES" >--bgc fates --no-megan --no-drydep --no-fire_emis</value>
251+
252+
<!-- ======================================= Coupled to CAM Options ======================================
253+
All versions with CAM - turn off sending test drv_flds_in namelists from CTSM
254+
255+
When coupled to CAM - expect CAM to determine these drv_flds settings
256+
See issue #2713 for more information on this.
257+
-->
258+
<value compset="CAM[^_]*_CLM[^_]*%SP" >--bgc sp --no-megan --no-drydep --no-fire_emis</value>
259+
<value compset="CAM[^_]*_CLM[^_]*BGC" >--bgc bgc --no-megan --no-drydep --no-fire_emis</value>
260+
<value compset="CAM[^_]*_CLM[^_]*BGC-CROP" >--bgc bgc --crop --no-megan --no-drydep --no-fire_emis</value>
261+
<!-- ======================================= End of Coupled to CAM Options =============================== -->
250262

251263
<!-- Options specific for CLM4.5 -->
252264
<value compset="_CLM45%[^_]*BGCDV" >-bgc bgc -dynamic_vegetation</value>

0 commit comments

Comments
 (0)