Skip to content

Commit 2d76738

Browse files
authored
Merge pull request #3745 from ekluzek/quick_fix_ndep_from_atm
ctsm5.4.018: Quick fix so that we can use Nitrogen Deposition sent from the ATM model
2 parents 700b68d + d689768 commit 2d76738

File tree

21 files changed

+220
-46
lines changed

21 files changed

+220
-46
lines changed

bld/CLMBuildNamelist.pm

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,8 @@ sub setup_cmdl_simulation_year {
13601360
}
13611361
$val = "'".$defaults->get_value($var)."'";
13621362
$nl->set_variable_value($group, $var, $val );
1363-
$log->verbose_message("CLM sim_year_range is $nl_flags->{'sim_year_range'}");
13641363
}
1364+
$log->verbose_message("CLM sim_year_range is $nl_flags->{'sim_year_range'}");
13651365
}
13661366

13671367
#-------------------------------------------------------------------------------
@@ -1758,10 +1758,10 @@ sub process_namelist_inline_logic {
17581758
###############################
17591759
setup_logic_methane($opts, $nl_flags, $definition, $defaults, $nl);
17601760

1761-
###############################
1762-
# namelist group: ndepdyn_nml #
1763-
###############################
1764-
setup_logic_nitrogen_deposition($opts, $nl_flags, $definition, $defaults, $nl);
1761+
######################################################
1762+
# Handle Nitrogen Deposition either from CPL or CTSM #
1763+
######################################################
1764+
setup_logic_nitrogen_deposition($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref);
17651765

17661766
##################################
17671767
# namelist group: cnmresp_inparm #
@@ -3916,12 +3916,33 @@ sub setup_logic_c14_streams {
39163916
#-------------------------------------------------------------------------------
39173917

39183918
sub setup_logic_nitrogen_deposition {
3919+
my ($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref) = @_;
3920+
3921+
# Determine if we are using ndep from the CPL or internal to CTSM
3922+
# and if it's needed
3923+
$nl_flags->{'ndep_from_cpl'} = logical_to_fortran( $envxml_ref->{'CLM_NDEP_FROM_CPL'} );
3924+
if ( ($nl_flags->{'bgc_mode'} =~/bgc/) ) { # or ($nl_flags->{'bgc_mode'} =~/fates/) ) {
3925+
$nl_flags->{'ndep_needed'} = ".true."
3926+
} else {
3927+
$nl_flags->{'ndep_needed'} = ".false."
3928+
}
3929+
# Handle the ndep_inparm namelist in drv_flds_in
3930+
if ( &value_is_true($nl_flags->{'ndep_from_cpl'}) && &value_is_true($nl_flags->{'ndep_needed'}) ) {
3931+
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, "ndep_list", val=>"'noy','nhx'" );
3932+
}
3933+
# Handle the internal ndep-streams namelist
3934+
setup_logic_nitrogen_deposition_streams($opts, $nl_flags, $definition, $defaults, $nl);
3935+
}
3936+
3937+
#-------------------------------------------------------------------------------
3938+
3939+
sub setup_logic_nitrogen_deposition_streams {
39193940
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;
39203941

39213942
#
3922-
# Nitrogen deposition for bgc=CN or fates
3943+
# Nitrogen deposition streams when needed to be read internally for BGC
39233944
#
3924-
if ( ($nl_flags->{'bgc_mode'} =~/bgc/) ) { # or ($nl_flags->{'bgc_mode'} =~/fates/) ) {
3945+
if ( (not &value_is_true($nl_flags->{'ndep_from_cpl'})) and &value_is_true($nl_flags->{'ndep_needed'}) ) {
39253946
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndepmapalgo', 'phys'=>$nl_flags->{'phys'},
39263947
'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'},
39273948
'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} );
@@ -3943,15 +3964,17 @@ sub setup_logic_nitrogen_deposition {
39433964
'sim_year_range'=>$nl_flags->{'sim_year_range'});
39443965
}
39453966
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_ndep', 'phys'=>$nl_flags->{'phys'},
3946-
'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'},
3947-
'hgrid'=>"0.9x1.25", 'ssp_rcp'=>$nl_flags->{'ssp_rcp'}, 'nofail'=>1 );
3967+
'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'},
3968+
'hgrid'=>"0.9x1.25", 'ssp_rcp'=>$nl_flags->{'ssp_rcp'}, 'sim_year'=>$nl_flags->{'sim_year'}, 'nofail'=>1 );
39483969
if ( ! defined($nl->get_value('stream_fldfilename_ndep') ) ) {
39493970
# Also check at f19 resolution
39503971
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_ndep', 'phys'=>$nl_flags->{'phys'},
3951-
'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'},
3952-
'hgrid'=>"1.9x2.5", 'ssp_rcp'=>$nl_flags->{'ssp_rcp'}, 'nofail'=>1 );
3972+
'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'},
3973+
'hgrid'=>"1.9x2.5", 'ssp_rcp'=>$nl_flags->{'ssp_rcp'}, 'sim_year'=>$nl_flags->{'sim_year'}, 'nofail'=>1 );
39533974
# If not found report an error
39543975
if ( ! defined($nl->get_value('stream_fldfilename_ndep') ) ) {
3976+
$log->verbose_message( "lnd_tuning_mode = " . $nl_flags->{'lnd_tuning_mode'}, " ssp_rcp = " . $nl_flags->{'ssp_rcp'} );
3977+
$log->verbose_message( "sim_year = " . $nl_flags->{'sim_year'}, " sim_year_range = " . $nl_flags->{'sim_year_range'} );
39553978
$log->warning("Did NOT find the Nitrogen-deposition forcing file (stream_fldfilename_ndep) for this ssp_rcp\n" .
39563979
"One way to get around this is to point to a file for another existing ssp_rcp in your user_nl_clm file.\n" .
39573980
"If you are running with CAM and WACCM chemistry Nitrogen deposition will come through the coupler.\n" .
@@ -3974,15 +3997,15 @@ sub setup_logic_nitrogen_deposition {
39743997
}
39753998
}
39763999
} else {
3977-
# If bgc is NOT CN/CNDV then make sure none of the ndep settings are set!
4000+
# If ndep is NOT required then make sure none of the ndep settings are set!
39784001
if ( defined($nl->get_value('stream_year_first_ndep')) ||
39794002
defined($nl->get_value('stream_year_last_ndep')) ||
39804003
defined($nl->get_value('model_year_align_ndep')) ||
39814004
defined($nl->get_value('ndep_taxmode' )) ||
39824005
defined($nl->get_value('ndep_varlist' )) ||
39834006
defined($nl->get_value('stream_fldfilename_ndep'))
39844007
) {
3985-
$log->fatal_error("When bgc is NOT CN or CNDV none of: stream_year_first_ndep," .
4008+
$log->fatal_error("When ndep isn't required or coming from the CPL none of: stream_year_first_ndep," .
39864009
"stream_year_last_ndep, model_year_align_ndep, ndep_taxmod, " .
39874010
"ndep_varlist, nor stream_fldfilename_ndep" .
39884011
" can be set!");
@@ -5452,7 +5475,7 @@ sub write_output_files {
54525475
$log->verbose_message("Writing clm namelist to $outfile");
54535476

54545477
# Drydep, fire-emission or MEGAN namelist for driver
5455-
@groups = qw(drydep_inparm megan_emis_nl fire_emis_nl carma_inparm dust_emis_inparm);
5478+
@groups = qw(drydep_inparm megan_emis_nl fire_emis_nl carma_inparm dust_emis_inparm ndep_inparm);
54565479
$outfile = "$opts->{'dir'}/drv_flds_in";
54575480
$nl->write($outfile, 'groups'=>\@groups, 'note'=>"$note" );
54585481
$log->verbose_message("Writing @groups namelists to $outfile");

bld/namelist_files/namelist_defaults_ctsm.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,17 +2182,23 @@ lnd/clm2/surfdata_esmf/NEON/ctsm5.4.0/surfdata_1x1_NEON_TOOL_hist_2000_78pfts_c2
21822182
<do_sno_oc >.false.</do_sno_oc>
21832183

21842184
<!-- Nitrogen deposition streams namelist defaults -->
2185-
<stream_year_first_ndep use_cn=".true." sim_year_range="1850-2100" >2015</stream_year_first_ndep>
2186-
<stream_year_last_ndep use_cn=".true." sim_year_range="1850-2100" >2101</stream_year_last_ndep>
2187-
<model_year_align_ndep use_cn=".true." sim_year_range="1850-2100" >2015</model_year_align_ndep>
2185+
<stream_year_first_ndep use_cn=".true." sim_year_range="1850-2100" >2015</stream_year_first_ndep>
2186+
<stream_year_last_ndep use_cn=".true." sim_year_range="1850-2100" >2101</stream_year_last_ndep>
2187+
<model_year_align_ndep use_cn=".true." sim_year_range="1850-2100" >2015</model_year_align_ndep>
2188+
2189+
<stream_year_first_ndep use_cn=".true." sim_year="1850" sim_year_range="1850-2000" >1850</stream_year_first_ndep>
2190+
<stream_year_last_ndep use_cn=".true." sim_year="1850" sim_year_range="1850-2000" >2015</stream_year_last_ndep>
2191+
<model_year_align_ndep use_cn=".true." sim_year="1850" sim_year_range="1850-2000" >1850</model_year_align_ndep>
21882192

21892193
<stream_year_first_ndep use_cn=".true." sim_year="2018" >2018</stream_year_first_ndep>
21902194
<stream_year_last_ndep use_cn=".true." sim_year="2018" >2018</stream_year_last_ndep>
2195+
<stream_year_last_ndep use_cn=".true." sim_year="2018" sim_year_range="1850-2100" >2022</stream_year_last_ndep>
21912196

21922197
<stream_year_first_ndep use_cn=".true." sim_year="2010" >2010</stream_year_first_ndep>
21932198
<stream_year_last_ndep use_cn=".true." sim_year="2010" >2010</stream_year_last_ndep>
21942199

21952200
<stream_year_first_ndep use_cn=".true." sim_year="2000" >2000</stream_year_first_ndep>
2201+
21962202
<stream_year_last_ndep use_cn=".true." sim_year="2000" >2000</stream_year_last_ndep>
21972203

21982204
<stream_year_first_ndep use_cn=".true." sim_year="1850" >1850</stream_year_first_ndep>
@@ -2201,13 +2207,18 @@ lnd/clm2/surfdata_esmf/NEON/ctsm5.4.0/surfdata_1x1_NEON_TOOL_hist_2000_78pfts_c2
22012207
<stream_year_first_ndep use_cn=".true." sim_year="1000" >2000</stream_year_first_ndep>
22022208
<stream_year_last_ndep use_cn=".true." sim_year="1000" >2000</stream_year_last_ndep>
22032209

2210+
<stream_year_first_ndep use_cn=".true." sim_year="PtVg" >1850</stream_year_first_ndep>
2211+
<stream_year_last_ndep use_cn=".true." sim_year="PtVg" >1850</stream_year_last_ndep>
2212+
22042213
<stream_year_first_ndep use_cn=".true." sim_year="constant" sim_year_range="1000-1002" >2000</stream_year_first_ndep>
22052214
<stream_year_last_ndep use_cn=".true." sim_year="constant" sim_year_range="1000-1002" >2000</stream_year_last_ndep>
22062215

22072216
<stream_year_first_ndep use_cn=".true." sim_year="constant" sim_year_range="1000-1004" >2000</stream_year_first_ndep>
22082217
<stream_year_last_ndep use_cn=".true." sim_year="constant" sim_year_range="1000-1004" >2000</stream_year_last_ndep>
22092218

2210-
<stream_fldfilename_ndep 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>
2219+
<stream_fldfilename_ndep hgrid="0.9x1.25" use_cn=".true." ssp_rcp="hist" sim_year_range="1850-2000" >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>
2220+
<stream_fldfilename_ndep hgrid="0.9x1.25" use_cn=".true." ssp_rcp="hist" sim_year="1850" sim_year_range="constant">lnd/clm2/ndepdata/fndep_clm_WACCM6_CMIP6piControl001_y21-50avg_1850monthly_0.95x1.25_c180802.nc</stream_fldfilename_ndep>
2221+
<stream_fldfilename_ndep hgrid="0.9x1.25" use_cn=".true." ssp_rcp="hist" sim_year_range="constant" >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>
22112222

22122223
<stream_meshfile_ndep hgrid="1.9x2.5">share/meshes/fv1.9x2.5_141008_ESMFmesh_c20191001.nc</stream_meshfile_ndep>
22132224
<stream_meshfile_ndep hgrid="0.9x1.25">share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc</stream_meshfile_ndep>

bld/namelist_files/namelist_definition_drv_flds.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@
8585
Henry's law coefficients.
8686
</entry>
8787

88+
<!-- ======================================================================================== -->
89+
<!-- Nitrogen deposition -->
90+
<!-- ======================================================================================== -->
91+
92+
<entry id="ndep_list"
93+
type="char*16(2)"
94+
category="nitrogen_deposition"
95+
group="ndep_inparm" valid_values="noy,nhx">
96+
List of nitrogen deposition fluxes to be sent from ATM to surface models.
97+
</entry>
98+
8899
<!-- ======================================================================================== -->
89100
<!-- Fire emissions fluxes -->
90101
<!-- ======================================================================================== -->

bld/namelist_files/use_cases/1850_control.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@
1010

1111
<irrigate use_crop=".true." >.false.</irrigate>
1212

13-
<stream_year_first_ndep use_cn=".true." >1850</stream_year_first_ndep>
14-
<stream_year_last_ndep use_cn=".true." >1850</stream_year_last_ndep>
15-
1613
<stream_year_first_popdens cnfireson=".true." >1850</stream_year_first_popdens>
1714
<stream_year_last_popdens cnfireson=".true." >1850</stream_year_last_popdens>
1815

1916
<stream_year_first_urbantv >1850</stream_year_first_urbantv>
2017
<stream_year_last_urbantv >1850</stream_year_last_urbantv>
2118

22-
<stream_fldfilename_ndep use_cn=".true."
23-
>lnd/clm2/ndepdata/fndep_clm_WACCM6_CMIP6piControl001_y21-50avg_1850monthly_0.95x1.25_c180802.nc</stream_fldfilename_ndep>
24-
2519
</namelist_defaults>

bld/namelist_files/use_cases/1850_noanthro_control.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
<irrigate>.false.</irrigate>
1212

13-
<stream_year_first_ndep use_cn=".true." >1850</stream_year_first_ndep>
14-
<stream_year_last_ndep use_cn=".true." >1850</stream_year_last_ndep>
15-
1613
<stream_year_first_popdens cnfireson=".true." >1925</stream_year_first_popdens>
1714
<stream_year_last_popdens cnfireson=".true." >1925</stream_year_last_popdens>
1815

bld/namelist_files/use_cases/2000_control.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
<irrigate use_crop=".true." use_cndv=".true." >.false.</irrigate>
1313
<irrigate use_crop=".true." phys="clm4_5" >.false.</irrigate>
1414

15-
<stream_year_first_ndep use_cn=".true." >2000</stream_year_first_ndep>
16-
<stream_year_last_ndep use_cn=".true." >2000</stream_year_last_ndep>
17-
1815
<stream_year_first_popdens cnfireson=".true." >2000</stream_year_first_popdens>
1916
<stream_year_last_popdens cnfireson=".true." >2000</stream_year_last_popdens>
2017

bld/namelist_files/use_cases/2010_control.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
<irrigate use_crop=".true." use_cndv=".true." >.false.</irrigate>
1313
<irrigate use_crop=".true." use_cndv=".false." phys="clm4_5" >.false.</irrigate>
1414

15-
<stream_year_first_ndep bgc="cn" use_cn=".true." >2010</stream_year_first_ndep>
16-
<stream_year_last_ndep bgc="cn" use_cn=".true." >2010</stream_year_last_ndep>
17-
1815
<stream_year_first_popdens cnfireson=".true." >2010</stream_year_first_popdens>
1916
<stream_year_last_popdens cnfireson=".true." >2010</stream_year_last_popdens>
2017

bld/namelist_files/use_cases/2018-PD_transient.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
<!-- Use future data as needed from the SSP3-7.0 scenario-->
1919
<ssp_rcp>SSP3-7.0</ssp_rcp>
2020

21-
<stream_year_first_ndep use_cn=".true." >2018</stream_year_first_ndep>
22-
<stream_year_last_ndep use_cn=".true." >2022</stream_year_last_ndep>
23-
<model_year_align_ndep use_cn=".true." >2018</model_year_align_ndep>
24-
2521
<stream_year_first_popdens cnfireson=".true." >2018</stream_year_first_popdens>
2622
<stream_year_last_popdens cnfireson=".true." >2022</stream_year_last_popdens>
2723
<model_year_align_popdens cnfireson=".true." >2018</model_year_align_popdens>

bld/namelist_files/use_cases/20thC_transient.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
<irrigate use_crop=".true." use_cndv=".true." >.false.</irrigate>
2323
<irrigate use_crop=".true." phys="clm4_5" use_cndv=".false.">.false.</irrigate>
2424

25-
<stream_year_first_ndep use_cn=".true." >1850</stream_year_first_ndep>
26-
<stream_year_last_ndep use_cn=".true." >2015</stream_year_last_ndep>
27-
<model_year_align_ndep use_cn=".true." >1850</model_year_align_ndep>
28-
2925
<stream_year_first_popdens cnfireson=".true." >1850</stream_year_first_popdens>
3026
<stream_year_last_popdens cnfireson=".true." >2016</stream_year_last_popdens>
3127
<model_year_align_popdens cnfireson=".true." >1850</model_year_align_popdens>

bld/unit_testers/build-namelist_test.pl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ sub make_env_run {
4242
my %settings = @_;
4343

4444
# Set default settings
45-
my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", LND_SETS_DUST_EMIS_DRV_FLDS=>"TRUE", NEONSITE=>"", PLUMBER2SITE=>"", CLM_CMIP_ERA=>"cmip7" );
45+
my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE",
46+
LND_SETS_DUST_EMIS_DRV_FLDS=>"TRUE", NEONSITE=>"", PLUMBER2SITE=>"",
47+
CLM_CMIP_ERA=>"cmip7", CLM_NDEP_FROM_CPL=>"FALSE" );
4648
# Set any settings that came in from function call
4749
foreach my $item ( keys(%settings) ) {
4850
$env_vars{$item} = $settings{$item};
@@ -1416,7 +1418,7 @@ sub cat_and_create_namelistinfile {
14161418
my $options = $failtest{$key}{"options"};
14171419
my $namelist = $failtest{$key}{"namelst"};
14181420
my %settings;
1419-
foreach my $xmlvar ( "GLC_TWO_WAY_COUPLING", "LND_SETS_DUST_EMIS_DRV_FLDS", "CLM_CMIP_ERA") {
1421+
foreach my $xmlvar ( "GLC_TWO_WAY_COUPLING", "LND_SETS_DUST_EMIS_DRV_FLDS", "CLM_CMIP_ERA", "CLM_NDEP_FROM_CPL") {
14201422
if ( defined($failtest{$key}{$xmlvar}) ) {
14211423
$settings{$xmlvar} = $failtest{$key}{$xmlvar};
14221424
}

0 commit comments

Comments
 (0)