diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg
index 71cbe69a29..20c468015e 100644
--- a/Externals_CLM.cfg
+++ b/Externals_CLM.cfg
@@ -2,7 +2,7 @@
local_path = src/fates
protocol = git
repo_url = https://github.com/NGEET/fates
-tag = sci.1.36.0_api.11.2.0
+tag = sci.1.39.0_api.12.0.0
required = True
[PTCLM]
diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm
index 5f5d86e5e3..836b5da16e 100755
--- a/bld/CLMBuildNamelist.pm
+++ b/bld/CLMBuildNamelist.pm
@@ -774,7 +774,7 @@ sub setup_cmdl_fates_mode {
}
} else {
# dis-allow fates specific namelist items with non-fates runs
- my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
+ my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
"use_fates_cohort_age_tracking",
"use_fates_inventory_init","use_fates_fixed_biogeog", "fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" );
foreach my $var ( @list ) {
@@ -940,12 +940,13 @@ sub setup_cmdl_fire_light_res {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method');
}
my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') );
- if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) ) {
- $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc.");
+ if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) {
+ $log->fatal_error("fire_method is being set while use_cn and use_fates are both false.");
}
if ( defined($fire_method) && $fire_method eq "nofire" ) {
$nl_flags->{$var} = ".false.";
- } elsif ( &value_is_true($nl->get_value('use_cn')) ) {
+# } elsif ( &value_is_true($nl->get_value('use_cn')) || $nl_flags->{'fates_spitfire_mode'} > 1 ) {
+ } elsif ( &value_is_true($nl->get_value('use_cn')) || &value_is_true($nl->get_value('use_fates')) ) {
$nl_flags->{$var} = ".true.";
} else {
$nl_flags->{$var} = ".false.";
@@ -3897,7 +3898,7 @@ sub setup_logic_fates {
if ($physv->as_long() >= $physv->as_long("clm4_5") && &value_is_true( $nl_flags->{'use_fates'}) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'});
- my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
+ my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
"use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" );
foreach my $var ( @list ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'} );
diff --git a/bld/namelist_files/namelist_defaults_clm4_5.xml b/bld/namelist_files/namelist_defaults_clm4_5.xml
index 03ef8a58a0..df355da513 100644
--- a/bld/namelist_files/namelist_defaults_clm4_5.xml
+++ b/bld/namelist_files/namelist_defaults_clm4_5.xml
@@ -1134,14 +1134,20 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
none
94x192
94x192
+360x720
+360x720
0001
0001
+0001
+0001
atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc
atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc
+atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc
bilinear
+bilinear
nn
nn
@@ -1178,6 +1184,24 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
2000
2000
+2010
+2010
+
+2000
+2000
+
+1850
+1850
+
+2000
+2000
+
+2000
+2000
+
+2000
+2000
+
lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202.nc
lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
@@ -1196,6 +1220,24 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202.nc
+lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP3_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP4_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP4_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc
+
+
bilinear
nn
@@ -1206,6 +1248,16 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
nn
nn
+bilinear
+
+nn
+nn
+nn
+nn
+nn
+nn
+nn
+
2015
2106
@@ -2639,7 +2691,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
.false.
-.false.
+0
.false.
.false.
.false.
diff --git a/bld/namelist_files/namelist_definition_clm4_5.xml b/bld/namelist_files/namelist_definition_clm4_5.xml
index 32e247e78d..8c98f42254 100644
--- a/bld/namelist_files/namelist_definition_clm4_5.xml
+++ b/bld/namelist_files/namelist_definition_clm4_5.xml
@@ -185,7 +185,7 @@ formulation (1).
+ group="cnfire_inparm" valid_values="nofire,li2014qianfrc,li2016crufrc,spitfire" >
The method type to use for CNFire
nofire: Turn fire effects off
@@ -618,9 +618,16 @@ Toggle to turn on the FATES model
Switch deciding which nutrient model to use in FATES.
-
-Toggle to turn on spitfire module for modeling fire (only relevant if FATES is being used).
+
+Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0.
+Relevant only if use_fates = .true.
+Allowed values are:
+ 1 : use a global constant lightning rate found in fates_params.
+ 2 : use an external lightning dataset.
+ 3 : use an external confirmed ignitions dataset.
+ 4 : use external lightning and population datasets to simulate both natural and anthropogenic
+ignitions.
"-phys clm4_0",
},
"usespitfireButNOTFATES" =>{ options=>"-envxml_dir . -no-megan",
- namelst=>"use_fates_spitfire=.true.",
+ namelst=>"fates_spitfire_mode>0",
GLC_TWO_WAY_COUPLING=>"FALSE",
conopts=>"-phys clm4_5",
},
diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml
index 9f41cc2e52..d6fae0f337 100644
--- a/cime_config/testdefs/ExpectedTestFails.xml
+++ b/cime_config/testdefs/ExpectedTestFails.xml
@@ -12,7 +12,7 @@
FAIL SMS_Lm3_D_Mmpi-serial.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-FatesHydro RUN
- FAIL ERS_D_Ld5.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-FatesHydro COMPARE_base_rest
+ FAIL ERS_D_Lm12.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-Fates_nat_and_anthro_ignitions COMPARE_base_rest
FAIL ERS_D_Ld5.1x1_brazil.I2000Clm50FatesCruGs.hobart_nag.clm-FatesHydro RUN
FAIL ERS_D_Ld5.1x1_brazil.I2000Clm50FatesCruGs.izumi_nag.clm-FatesHydro RUN
FAIL SMS_Lm3_D_Mmpi-serial.1x1_brazil.I2000Clm50FatesCruGs.hobart_nag.clm-FatesHydro MEMLEAK
diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml
index 0f1af44769..d70ce7b560 100644
--- a/cime_config/testdefs/testlist_clm.xml
+++ b/cime_config/testdefs/testlist_clm.xml
@@ -2018,6 +2018,14 @@
+
+
+
+
+
+
+
+
diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm
index 1bbaa01c6a..353a8686c2 100644
--- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm
+++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm
@@ -2,7 +2,7 @@
hist_mfilt = 365
hist_nhtfrq = -24
hist_empty_htapes = .true.
-use_fates_spitfire= .true.
+fates_spitfire_mode = 1
hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN_ELEM','LITTER_OUT_ELEM',
'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF',
'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass',
diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm
index 9b9243cee5..573c507d7e 100644
--- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm
+++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm
@@ -1,7 +1,7 @@
hist_mfilt = 365
hist_nhtfrq = -24
hist_empty_htapes = .false.
-use_fates_spitfire= .true.
+fates_spitfire_mode = 1
hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE','GPP_BY_AGE','PARSUN_Z_CNLF','PARSHA_Z_CNLF','PARSUN_Z_CNLFPFT',
'PARSHA_Z_CNLFPFT','PARSUN_Z_CAN','PARSHA_Z_CAN','LAISUN_Z_CNLF','LAISHA_Z_CNLF','LAISUN_Z_CNLFPFT','LAISHA_Z_CNLFPFT',
'LAISUN_TOP_CAN','LAISHA_TOP_CAN','FABD_SUN_CNLFPFT','FABD_SHA_CNLFPFT','FABI_SUN_CNLFPFT','FABI_SHA_CNLFPFT',
diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm
index 02b13dcd1d..c092059cea 100644
--- a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm
+++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm
@@ -1,7 +1,7 @@
hist_mfilt = 365
hist_nhtfrq = -24
hist_empty_htapes = .true.
-use_fates_spitfire= .true.
+fates_spitfire_mode = 1
hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT',
'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF',
'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass',
diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm
index dfdb775ec5..8fc4951e6a 100644
--- a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm
+++ b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm
@@ -1 +1 @@
-use_fates_spitfire= .false.
+fates_spitfire_mode = 0
diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README
new file mode 100644
index 0000000000..3bd8c7dd62
--- /dev/null
+++ b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README
@@ -0,0 +1,26 @@
+Testing capability to read/use lightning frequency & population density
+datasets. Calculates lightning ignitions using the SPITFIRE
+formulation and anthropogenic ignitions using the Li et al. 2012 formulation
+based on human population density implemented in CTSM-CN's fire model.
+
+Testing does not include a separate test for reading/using a successful
+ignitions dataset which uses the same format and units so handling
+is the same until you're in subroutine area_burnt_intensity where for
+"successful ignitions" the model selects
+currentSite%FDI = 1.0_r8
+cloud_to_ground_strikes = 1.0_r8
+while for lightning the model can use values < 1 for both.
+
+Lara Kueppers (UC-Berkeley) has access to a "successful ignitions"
+dataset for California that has not been placed in the repository of
+CTSM datasets as of 2020/6/6. That dataset can be used with the
+following settings:
+
+fire_method = 'spitfire'
+fates_spitfire_mode = 3
+stream_fldfilename_lightng = '.../data_UCB/observed/CA_monthly_ignition_number_1980-2016/ignition_1980_to_2016_monthly_20190801.nc'
+stream_year_first_lightng = 1980
+stream_year_last_lightng = 2016
+model_year_align_lightng = 1980
+
+where {...} = /fs/cgd/data0/slevis on izumi and /glade/work/slevis on cheyenne.
diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm
new file mode 100644
index 0000000000..77d3a7179f
--- /dev/null
+++ b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm
@@ -0,0 +1,4 @@
+fire_method = 'spitfire'
+fates_spitfire_mode = 4
+hist_nhtfrq = 0
+hist_mfilt = 1
diff --git a/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm
index e3a3b76d71..265f4c5406 100644
--- a/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm
+++ b/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm
@@ -1,2 +1,2 @@
-use_fates_spitfire = .true.
+fates_spitfire_mode = 1
diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90
index 71376116b9..7b3914534d 100644
--- a/src/biogeochem/CNFireFactoryMod.F90
+++ b/src/biogeochem/CNFireFactoryMod.F90
@@ -17,6 +17,18 @@ module CNFireFactoryMod
! !PUBLIC ROUTINES:
public :: CNFireReadNML ! read the fire namelist
public :: create_cnfire_method ! create an object of class cnfire_method_type
+ public :: create_fates_fire_data_method ! create an object of class cnfire_method_type
+
+ ! These parameters set the ranges of the cases in subroutine
+ ! create_fates_fire_data_method. We declare them public in order to
+ ! use them as flags elsewhere in the CTSM and FATES-SPITFIRE.
+ ! They correspond one-to-one to the fates_spitfire_mode options listed
+ ! in bld/namelist_files/namelist_definition_clm4_5.xml
+ integer, public, parameter :: no_fire = 0 ! value of no_fire mode
+ integer, public, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode
+ integer, public, parameter :: lightning_from_data = 2 ! value of lightning_from_data mode
+ integer, public, parameter :: successful_ignitions = 3 ! value of successful_ignitions mode
+ integer, public, parameter :: anthro_ignitions = 4 ! value of anthro_ignitions mode
! !PRIVATE DATA MEMBERS:
character(len=80), private :: fire_method = "li2014qianfrc"
@@ -121,5 +133,46 @@ function create_cnfire_method( NLFilename ) result(cnfire_method)
call cnfire_method%CNFireReadNML( NLFilename )
end function create_cnfire_method
+ !-----------------------------------------------------------------------
+
+ !-----------------------------------------------------------------------
+ subroutine create_fates_fire_data_method( fates_fire_data_method )
+ !
+ ! !DESCRIPTION:
+ ! Create and return an object of fates_fire_data_method_type.
+ ! The particular type is determined based on a namelist parameter.
+ !
+ ! !USES:
+ use clm_varctl, only: fates_spitfire_mode
+ use CNFireMethodMod, only: cnfire_method_type
+ use FATESFireBase, only: fates_fire_base_type
+ use FATESFireNoDataMod, only: fates_fire_no_data_type
+ use FATESFireDataMod, only: fates_fire_data_type
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_base_type), allocatable, intent(inout) :: fates_fire_data_method ! function result
+ !
+ ! !LOCAL VARIABLES:
+ integer :: current_case
+
+ character(len=*), parameter :: subname = 'create_fates_fire_data_method'
+ !-----------------------------------------------------------------------
+
+ current_case = fates_spitfire_mode
+
+ select case (current_case)
+
+ case (no_fire:scalar_lightning)
+ allocate(fates_fire_no_data_type :: fates_fire_data_method)
+ case (lightning_from_data:anthro_ignitions)
+ allocate(fates_fire_data_type :: fates_fire_data_method)
+
+ case default
+ write(iulog,*) subname//' ERROR: unknown method: ', fates_spitfire_mode
+ call endrun(msg=errMsg(sourcefile, __LINE__))
+
+ end select
+
+ end subroutine create_fates_fire_data_method
end module CNFireFactoryMod
diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90
new file mode 100644
index 0000000000..fc3f2bd4c5
--- /dev/null
+++ b/src/biogeochem/FATESFireBase.F90
@@ -0,0 +1,108 @@
+module FATESFireBase
+
+ !-----------------------------------------------------------------------
+ ! !DESCRIPTION:
+ ! Abstract base class for FATES fire data object
+ !
+ ! !USES:
+ use CNFireBaseMod , only: cnfire_base_type
+ !
+ implicit none
+ private
+ !
+ ! !PUBLIC TYPES:
+ public :: fates_fire_base_type
+ !
+ type, abstract, extends(cnfire_base_type) :: fates_fire_base_type
+ private
+
+ ! !PRIVATE MEMBER DATA:
+
+ contains
+ ! !PUBLIC MEMBER FUNCTIONS:
+ procedure(GetLight24_interface), public, deferred :: GetLight24 ! Return the 24-hour averaged lightning data
+ procedure(InitAccBuffer_interface), public, deferred :: InitAccBuffer ! Initialize accumulation processes
+ procedure(InitAccVars_interface), public, deferred :: InitAccVars ! Initialize accumulation variables
+ procedure(UpdateAccVars_interface), public, deferred :: UpdateAccVars ! Update/extract accumulations vars
+
+ end type fates_fire_base_type
+
+ abstract interface
+ !-----------------------------------------------------------------------
+
+ !------------------------------------------------------------------------
+ function GetLight24_interface( this ) result(lnfm24)
+ !
+ ! !DESCRIPTION: Get the 24-hour averaged lightning data
+ ! !USES
+ use shr_kind_mod , only: r8 => shr_kind_r8
+ import :: fates_fire_base_type
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_base_type) :: this
+ real(r8), pointer :: lnfm24(:)
+ !---------------------------------------------------------------------
+ !---------------------------------------------------------------------
+ end function GetLight24_interface
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccBuffer_interface (this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Initialize the accumulation buffers
+ !
+ ! !USES
+ use decompMod , only: bounds_type
+ import :: fates_fire_base_type
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_base_type) :: this
+ type(bounds_type), intent(in) :: bounds
+
+ ! !LOCAL VARIABLES:
+ !---------------------------------------------------------------------
+
+ end subroutine InitAccBuffer_interface
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccVars_interface(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Initialize the accumulation variables
+ !
+ ! !USES
+ use decompMod , only: bounds_type
+ import :: fates_fire_base_type
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_base_type) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+ !---------------------------------------------------------------------
+
+ end subroutine InitAccVars_interface
+
+ !-----------------------------------------------------------------------
+ subroutine UpdateAccVars_interface (this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Update accumulation variables
+ !
+ ! !USES
+ use decompMod , only: bounds_type
+ import :: fates_fire_base_type
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_base_type) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+ !---------------------------------------------------------------------
+
+ end subroutine UpdateAccVars_interface
+
+ end interface
+ !---------------------------------------------------------------------
+
+end module FATESFireBase
diff --git a/src/biogeochem/FATESFireDataMod.F90 b/src/biogeochem/FATESFireDataMod.F90
new file mode 100644
index 0000000000..f545709376
--- /dev/null
+++ b/src/biogeochem/FATESFireDataMod.F90
@@ -0,0 +1,190 @@
+module FATESFireDataMod
+
+#include "shr_assert.h"
+
+ !-----------------------------------------------------------------------
+ ! !DESCRIPTION:
+ ! module for FATES to obtain fire inputs from data
+ !
+ ! !USES:
+ use shr_kind_mod, only: r8 => shr_kind_r8, CL => shr_kind_CL
+ use shr_log_mod, only: errmsg => shr_log_errMsg
+ use abortutils, only: endrun
+ use clm_varctl, only: iulog
+ use decompMod, only: bounds_type
+ use FatesFireBase, only: fates_fire_base_type
+ !
+ implicit none
+ private
+ !
+ ! !PUBLIC TYPES:
+ public :: fates_fire_data_type
+ !
+ type, extends(fates_fire_base_type) :: fates_fire_data_type
+ ! !PRIVATE MEMBER DATA:
+ real(r8), private, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr)
+ contains
+ ! !PUBLIC MEMBER FUNCTIONS:
+ procedure, public :: GetLight24 ! Return 24-hour averaged lightning data
+ procedure, public :: InitAccBuffer ! Initialize accumulation processes
+ procedure, public :: InitAccVars ! Initialize accumulation variables
+ procedure, public :: UpdateAccVars ! Update/extract accumulations vars
+
+ end type fates_fire_data_type
+
+ character(len=*), parameter, private :: sourcefile = __FILE__
+ !
+ ! !PRIVATE MEMBER DATA:
+ !-----------------------------------------------------------------------
+
+ interface fates_fire_data_type
+ ! initialize a new cnfire_base object
+ module procedure constructor
+ end interface fates_fire_data_type
+ !-----------------------------------------------------------------------
+
+contains
+
+ !------------------------------------------------------------------------
+ type(fates_fire_data_type) function constructor()
+ !
+ ! !DESCRIPTION:
+ ! Creates an object of type fates_fire_data_type
+ ! !ARGUMENTS:
+ constructor%need_lightning_and_popdens = .true.
+ end function constructor
+
+ !-----------------------------------------------------------------------
+ function GetLight24( this ) result(lnfm24)
+ !
+ ! !DESCRIPTION: Get the 24-hour averaged lightning data
+ ! !USES
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_data_type) :: this
+ real(r8), pointer :: lnfm24(:)
+ !---------------------------------------------------------------------
+ lnfm24 => this%lnfm24
+ !---------------------------------------------------------------------
+ end function
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccBuffer (this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Initialize accumulation buffer for all required module accumulated fields
+ ! This routine set defaults values that are then overwritten by the
+ ! restart file for restart or branch runs
+ !
+ ! !USES
+ use clm_varcon, only : spval
+ use accumulMod, only : init_accum_field
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_data_type) :: this
+ type(bounds_type), intent(in) :: bounds
+
+ ! !LOCAL VARIABLES:
+ integer :: begg, endg
+ integer :: ier
+ !---------------------------------------------------------------------
+
+ begg = bounds%begg; endg = bounds%endg
+
+ allocate(this%lnfm24(begg:endg), stat=ier)
+ if (ier/=0) then
+ call endrun(msg="allocation error for lnfm24"//&
+ errmsg(sourcefile, __LINE__))
+ endif
+ this%lnfm24(:) = spval
+ call init_accum_field (name='lnfm24', units='strikes/km2/hr', &
+ desc='24hr average of lightning strikes', accum_type='runmean', &
+ accum_period=-1, subgrid_type='gridcell', numlev=1, init_value=0._r8)
+
+ end subroutine InitAccBuffer
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccVars(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Initialize module variables that are associated with
+ ! time accumulated fields. This routine is called for both an initial run
+ ! and a restart run (and must therefore must be called after the restart
+ ! file is read in and the accumulation buffer is obtained)
+ !
+ ! !USES
+ use accumulMod , only : extract_accum_field
+ use clm_time_manager , only : get_nstep
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_data_type) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+ integer :: begg, endg
+ integer :: nstep
+ integer :: ier
+ real(r8), pointer :: rbufslg(:) ! temporary
+ !---------------------------------------------------------------------
+
+ begg = bounds%begg; endg = bounds%endg
+
+ ! Allocate needed dynamic memory for single level patch field
+ allocate(rbufslg(begg:endg), stat=ier)
+ if (ier/=0) then
+ call endrun(msg="allocation error for rbufslg"//&
+ errmsg(sourcefile, __LINE__))
+ endif
+
+ ! Determine time step
+ nstep = get_nstep()
+
+ call extract_accum_field ('lnfm24', rbufslg, nstep)
+ this%lnfm24(begg:endg) = rbufslg(begg:endg)
+
+ deallocate(rbufslg)
+
+ end subroutine InitAccVars
+
+ !-----------------------------------------------------------------------
+ subroutine UpdateAccVars (this, bounds)
+ !
+ ! USES
+ use clm_time_manager, only: get_nstep
+ use accumulMod, only: update_accum_field, extract_accum_field
+ use abortutils, only: endrun
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_data_type) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+ integer :: dtime ! timestep size [seconds]
+ integer :: nstep ! timestep number
+ integer :: ier ! error status
+ integer :: begg, endg
+ real(r8), pointer :: rbufslg(:) ! temporary single level - gridcell level
+ !---------------------------------------------------------------------
+
+ begg = bounds%begg; endg = bounds%endg
+
+ nstep = get_nstep()
+
+ ! Allocate needed dynamic memory for single level gridcell field
+
+ allocate(rbufslg(begg:endg), stat=ier)
+ if (ier/=0) then
+ write(iulog,*)'UpdateAccVars allocation error for rbuf1dg'
+ call endrun(msg=errmsg(sourcefile, __LINE__))
+ endif
+
+ ! Accumulate and extract lnfm24
+ rbufslg(begg:endg) = this%forc_lnfm(begg:endg)
+ call update_accum_field ('lnfm24', rbufslg, nstep)
+ call extract_accum_field ('lnfm24', this%lnfm24, nstep)
+
+ deallocate(rbufslg)
+
+ end subroutine UpdateAccVars
+
+end module FATESFireDataMod
diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90
new file mode 100644
index 0000000000..10f7f57a68
--- /dev/null
+++ b/src/biogeochem/FATESFireNoDataMod.F90
@@ -0,0 +1,134 @@
+module FATESFireNoDataMod
+
+#include "shr_assert.h"
+
+ !-----------------------------------------------------------------------
+ ! !DESCRIPTION:
+ ! module for FATES when not obtaining fire inputs from data
+ !
+ ! !USES:
+ use shr_kind_mod, only: r8 => shr_kind_r8, CL => shr_kind_CL
+ use shr_log_mod, only: errmsg => shr_log_errMsg
+ use abortutils, only: endrun
+ use clm_varctl, only: iulog
+ use decompMod, only: bounds_type
+ use FatesFireBase, only: fates_fire_base_type
+ !
+ implicit none
+ private
+ !
+ ! !PUBLIC TYPES:
+ public :: fates_fire_no_data_type
+ !
+ type, extends(fates_fire_base_type) :: fates_fire_no_data_type
+ private
+
+ ! !PRIVATE MEMBER DATA:
+
+ contains
+ ! !PUBLIC MEMBER FUNCTIONS:
+ procedure, public :: GetLight24 ! Return the 24-hour averaged lightning data
+ procedure, public :: InitAccBuffer ! Initialize accumulation processes
+ procedure, public :: InitAccVars ! Initialize accumulation variables
+ procedure, public :: UpdateAccVars ! Update/extract accumulations vars
+
+ end type fates_fire_no_data_type
+
+ character(len=*), parameter, private :: sourcefile = __FILE__
+ !
+ ! !PRIVATE MEMBER DATA:
+ !-----------------------------------------------------------------------
+
+ interface fates_fire_no_data_type
+ ! initialize a new cnfire_base object
+ module procedure constructor
+ end interface fates_fire_no_data_type
+ !-----------------------------------------------------------------------
+
+contains
+
+ !------------------------------------------------------------------------
+ type(fates_fire_no_data_type) function constructor()
+ !
+ ! !DESCRIPTION:
+ ! Creates an object of type fates_fire_no_data_type
+ ! !ARGUMENTS:
+ constructor%need_lightning_and_popdens = .false.
+ end function constructor
+
+ !-----------------------------------------------------------------------
+ function GetLight24( this ) result(lnfm24)
+ !
+ ! !DESCRIPTION: Get the 24-hour averaged lightning data
+ ! !USES
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_no_data_type) :: this
+ real(r8), pointer :: lnfm24(:)
+ !---------------------------------------------------------------------
+ call endrun( "GetLight24 should NOT be called for the FATES No-Data case" )
+ !---------------------------------------------------------------------
+ end function
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccBuffer (this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! EMPTY subroutine for the no_data case.
+ ! Initialize accumulation buffer for all required module accumulated fields
+ ! This routine set defaults values that are then overwritten by the
+ ! restart file for restart or branch runs
+ !
+ ! !USES
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_no_data_type) :: this
+ type(bounds_type), intent(in) :: bounds
+
+ ! !LOCAL VARIABLES:
+ !---------------------------------------------------------------------
+
+
+ end subroutine InitAccBuffer
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccVars(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! EMPTY subroutine for the no_data case.
+ ! Initialize module variables that are associated with
+ ! time accumulated fields. This routine is called for both an initial run
+ ! and a restart run (and must therefore must be called after the restart
+ ! file is read in and the accumulation buffer is obtained)
+ !
+ ! !USES
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_no_data_type) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+ !---------------------------------------------------------------------
+
+
+ end subroutine InitAccVars
+
+ !-----------------------------------------------------------------------
+ subroutine UpdateAccVars (this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! EMPTY subroutine for the no_data case.
+ !
+ ! !USES
+ !
+ ! !ARGUMENTS:
+ class(fates_fire_no_data_type) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+ !---------------------------------------------------------------------
+
+
+ end subroutine UpdateAccVars
+
+end module FATESFireNoDataMod
diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90
index 216e383bbb..9403a05277 100644
--- a/src/main/clm_driver.F90
+++ b/src/main/clm_driver.F90
@@ -109,8 +109,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
!
! !USES:
use clm_time_manager , only : get_curr_date
- use clm_varctl , only : use_lai_streams
+ use clm_varctl , only : use_lai_streams, fates_spitfire_mode
use SatellitePhenologyMod, only : lai_advance
+ use CNFireFactoryMod , only : scalar_lightning
!
! !ARGUMENTS:
implicit none
@@ -395,6 +396,10 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
end if
call bgc_vegetation_inst%InterpFileInputs(bounds_proc)
call t_stopf('bgc_interp')
+ ! fates_spitfire_mode is assigned an integer value in the namelist
+ ! see bld/namelist_files/namelist_definition_clm4_5.xml for details
+ else if (fates_spitfire_mode > scalar_lightning) then
+ call clm_fates%InterpFileInputs(bounds_proc)
end if
! Get time varying urban data
@@ -904,7 +909,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
call clm_fates%dynamics_driv( nc, bounds_clump, &
atm2lnd_inst, soilstate_inst, temperature_inst, &
waterstate_inst, canopystate_inst, soilbiogeochem_carbonflux_inst,&
- frictionvel_inst)
+ frictionvel_inst )
! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a
! call to reweight_wrapup, if it's needed at all.
@@ -1133,6 +1138,10 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
temperature_inst%t_ref2m_patch, temperature_inst%t_soisno_col)
end if
+ if(use_fates) then
+ call clm_fates%UpdateAccVars(bounds_proc)
+ end if
+
call t_stopf('accum')
end if
diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90
index e740d82e04..5908c9a515 100644
--- a/src/main/clm_initializeMod.F90
+++ b/src/main/clm_initializeMod.F90
@@ -270,7 +270,7 @@ subroutine initialize2( )
use clm_varcon , only : spval
use clm_varctl , only : finidat, finidat_interp_source, finidat_interp_dest, fsurdat
use clm_varctl , only : use_century_decomp, single_column, scmlat, scmlon, use_cn, use_fates
- use clm_varctl , only : use_crop, ndep_from_cpl
+ use clm_varctl , only : use_crop, ndep_from_cpl, fates_spitfire_mode
use clm_varorb , only : eccen, mvelpp, lambm0, obliqr
use clm_time_manager , only : get_step_size, get_curr_calday
use clm_time_manager , only : get_curr_date, get_nstep, advance_timestep
@@ -294,6 +294,7 @@ subroutine initialize2( )
use controlMod , only : NLFilename
use clm_instMod , only : clm_fates
use BalanceCheckMod , only : BalanceCheckInit
+ use CNFireFactoryMod , only : scalar_lightning
!
! !ARGUMENTS
!
@@ -474,6 +475,12 @@ subroutine initialize2( )
end if
else
call SatellitePhenologyInit(bounds_proc)
+
+ ! fates_spitfire_mode is assigned an integer value in the namelist
+ ! see bld/namelist_files/namelist_definition_clm4_5.xml for details
+ if (fates_spitfire_mode > scalar_lightning) then
+ call clm_fates%Init2(bounds_proc, NLFilename)
+ end if
end if
if(use_soil_moisture_streams) then
@@ -607,6 +614,10 @@ subroutine initialize2( )
call crop_inst%initAccVars(bounds_proc)
end if
+ if ( use_fates )then
+ call clm_fates%initAccVars(bounds_proc)
+ end if
+
!------------------------------------------------------------
! Read monthly vegetation
!------------------------------------------------------------
diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90
index 9c52f98c37..5e91ac994e 100644
--- a/src/main/clm_instMod.F90
+++ b/src/main/clm_instMod.F90
@@ -433,6 +433,10 @@ subroutine clm_instInit(bounds)
call crop_inst%InitAccBuffer(bounds)
end if
+ if (use_fates) then
+ call clm_fates%InitAccBuffer(bounds)
+ end if
+
call print_accum_fields()
call t_stopf('init_accflds')
diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90
index 071ee216f9..596c1a6390 100644
--- a/src/main/clm_varctl.F90
+++ b/src/main/clm_varctl.F90
@@ -207,7 +207,9 @@ module clm_varctl
integer, public :: fates_parteh_mode = -9 ! 1 => carbon only
! 2 => C+N+P (not enabled yet)
! no others enabled
- logical, public :: use_fates_spitfire = .false. ! true => use spitfire model
+ integer, public :: fates_spitfire_mode = 0
+ ! 0 for no fire; 1 for constant ignitions; > 1 for external data (lightning and/or anthropogenic ignitions)
+ ! see bld/namelist_files/namelist_definition_clm4_5.xml for details
logical, public :: use_fates_logging = .false. ! true => turn on logging module
logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro
logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking
diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90
index 50f536b742..28a36fec9f 100644
--- a/src/main/controlMod.F90
+++ b/src/main/controlMod.F90
@@ -219,7 +219,7 @@ subroutine control_init( )
! FATES Flags
namelist /clm_inparm/ fates_paramfile, use_fates, &
- use_fates_spitfire, use_fates_logging, &
+ fates_spitfire_mode, use_fates_logging, &
use_fates_planthydro, use_fates_ed_st3, &
use_fates_cohort_age_tracking, &
use_fates_ed_prescribed_phys, &
@@ -637,7 +637,7 @@ subroutine control_spmd()
call mpi_bcast (use_fates, 1, MPI_LOGICAL, 0, mpicom, ier)
- call mpi_bcast (use_fates_spitfire, 1, MPI_LOGICAL, 0, mpicom, ier)
+ call mpi_bcast (fates_spitfire_mode, 1, MPI_INTEGER, 0, mpicom, ier)
call mpi_bcast (use_fates_logging, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier)
@@ -982,7 +982,7 @@ subroutine control_print ()
write(iulog, *) ' ED/FATES: '
write(iulog, *) ' use_fates = ', use_fates
if (use_fates) then
- write(iulog, *) ' use_fates_spitfire = ', use_fates_spitfire
+ write(iulog, *) ' fates_spitfire_mode = ', fates_spitfire_mode
write(iulog, *) ' use_fates_logging = ', use_fates_logging
write(iulog, *) ' fates_paramfile = ', fates_paramfile
write(iulog, *) ' fates_parteh_mode = ', fates_parteh_mode
diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90
index 1a3799630f..45a66a272c 100644
--- a/src/utils/clmfates_interfaceMod.F90
+++ b/src/utils/clmfates_interfaceMod.F90
@@ -46,7 +46,7 @@ module CLMFatesInterfaceMod
use clm_varctl , only : use_vertsoilc
use clm_varctl , only : fates_parteh_mode
use clm_varctl , only : use_fates
- use clm_varctl , only : use_fates_spitfire
+ use clm_varctl , only : fates_spitfire_mode
use clm_varctl , only : use_fates_planthydro
use clm_varctl , only : use_fates_cohort_age_tracking
use clm_varctl , only : use_fates_ed_st3
@@ -134,6 +134,7 @@ module CLMFatesInterfaceMod
use FatesPlantHydraulicsMod, only : HydrSiteColdStart
use FatesPlantHydraulicsMod, only : InitHydrSites
use FatesPlantHydraulicsMod, only : RestartHydrStates
+ use FATESFireBase , only : fates_fire_base_type
implicit none
@@ -174,6 +175,9 @@ module CLMFatesInterfaceMod
! fates_restart is the inteface calss for restarting the model
type(fates_restart_interface_type) :: fates_restart
+ ! fates_fire_data_method determines the fire data passed from HLM to FATES
+ class(fates_fire_base_type), allocatable :: fates_fire_data_method
+
contains
procedure, public :: init
@@ -189,6 +193,11 @@ module CLMFatesInterfaceMod
procedure, public :: wrap_canopy_radiation
procedure, public :: wrap_bgc_summary
procedure, public :: TransferZ0mDisp
+ procedure, public :: InterpFileInputs ! Interpolate inputs from files
+ procedure, public :: Init2 ! Initialization after determining subgrid weights
+ procedure, public :: InitAccBuffer ! Initialize any accumulation buffers
+ procedure, public :: InitAccVars ! Initialize any accumulation variables
+ procedure, public :: UpdateAccVars ! Update any accumulation variables
procedure, private :: init_history_io
procedure, private :: wrap_update_hlmfates_dyn
procedure, private :: init_soil_depths
@@ -227,7 +236,6 @@ subroutine CLMFatesGlobals()
logical :: verbose_output
integer :: pass_masterproc
integer :: pass_vertsoilc
- integer :: pass_spitfire
integer :: pass_ed_st3
integer :: pass_logging
integer :: pass_ed_prescribed_phys
@@ -258,6 +266,8 @@ subroutine CLMFatesGlobals()
call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode)
+ call set_fates_ctrlparms('spitfire_mode',ival=fates_spitfire_mode)
+
if(is_restart()) then
pass_is_restart = 1
else
@@ -272,13 +282,6 @@ subroutine CLMFatesGlobals()
end if
call set_fates_ctrlparms('use_vertsoilc',ival=pass_vertsoilc)
- if(use_fates_spitfire) then
- pass_spitfire = 1
- else
- pass_spitfire = 0
- end if
- call set_fates_ctrlparms('use_spitfire',ival=pass_spitfire)
-
if(use_fates_fixed_biogeog)then
pass_biogeog = 1
else
@@ -382,7 +385,9 @@ subroutine init(this, bounds_proc )
use FatesInterfaceTypesMod, only : numpft_fates => numpft
use FatesParameterDerivedMod, only : param_derived
use subgridMod, only : natveg_patch_exists
- use clm_instur , only : wt_nat_patch
+ use clm_instur , only : wt_nat_patch
+ use CNFireFactoryMod , only: create_fates_fire_data_method
+
implicit none
! Input Arguments
@@ -563,6 +568,9 @@ subroutine init(this, bounds_proc )
! Report Fates Parameters (debug flag in lower level routines)
call FatesReportParameters(masterproc)
+ ! Fire data to send to FATES
+ call create_fates_fire_data_method( this%fates_fire_data_method )
+
end subroutine init
! ===================================================================================
@@ -606,13 +614,17 @@ end subroutine check_hlm_active
subroutine dynamics_driv(this, nc, bounds_clump, &
atm2lnd_inst, soilstate_inst, temperature_inst, &
waterstate_inst, canopystate_inst, soilbiogeochem_carbonflux_inst, &
- frictionvel_inst )
+ frictionvel_inst)
! This wrapper is called daily from clm_driver
! This wrapper calls ed_driver, which is the daily dynamics component of FATES
! ed_driver is not a hlm_fates_inst_type procedure because we need an extra step
! to process array bounding information
+ ! !USES
+ use CNFireFactoryMod, only: scalar_lightning
+
+ ! !ARGUMENTS:
implicit none
class(hlm_fates_interface_type), intent(inout) :: this
type(bounds_type),intent(in) :: bounds_clump
@@ -627,6 +639,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, &
! !LOCAL VARIABLES:
integer :: s ! site index
+ integer :: g ! grid-cell index (HLM)
integer :: c ! column index (HLM)
integer :: ifp ! patch index
integer :: p ! HLM patch index
@@ -646,6 +659,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, &
integer :: days_per_year
real(r8) :: model_day
real(r8) :: day_of_year
+ real(r8), pointer :: lnfm24(:)
+ integer :: ier
!-----------------------------------------------------------------------
! ---------------------------------------------------------------------------------
@@ -675,11 +690,30 @@ subroutine dynamics_driv(this, nc, bounds_clump, &
model_day, floor(day_of_year), &
days_per_year, 1.0_r8/dble(days_per_year))
+ if (fates_spitfire_mode > scalar_lightning) then
+ allocate(lnfm24(bounds_clump%begg:bounds_clump%endg), stat=ier)
+ if (ier /= 0) then
+ call endrun(msg="allocation error for lnfm24"//&
+ errmsg(sourcefile, __LINE__))
+ endif
+
+ lnfm24 = this%fates_fire_data_method%GetLight24()
+ end if
do s=1,this%fates(nc)%nsites
c = this%f2hmap(nc)%fcolumn(s)
+ if (fates_spitfire_mode > scalar_lightning) then
+ g = col%gridcell(c)
+ do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno
+ p = ifp + col%patchi(c)
+
+ this%fates(nc)%bc_in(s)%lightning24(ifp) = lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day
+ this%fates(nc)%bc_in(s)%pop_density(ifp) = this%fates_fire_data_method%forc_hdm(g)
+ end do
+ end if
+
nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil
this%fates(nc)%bc_in(s)%h2o_liqvol_sl(1:nlevsoil) = &
@@ -1996,6 +2030,129 @@ subroutine TransferZ0mDisp(this,bounds_clump,frictionvel_inst,canopystate_inst)
return
end subroutine TransferZ0mDisp
+ !-----------------------------------------------------------------------
+ subroutine InterpFileInputs(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Interpolate inputs from files
+ !
+ ! NOTE(wjs, 2016-02-23) Stuff done here could probably be done at the end of
+ ! InitEachTimeStep, rather than in this separate routine, except for the
+ ! fact that
+ ! (currently) this Interp stuff is done with proc bounds rather thna clump
+ ! bounds. I
+ ! think that is needed so that you don't update a given stream multiple
+ ! times. If we
+ ! rework the handling of threading / clumps so that there is a separate
+ ! object for
+ ! each clump, then I think this problem would disappear - at which point we
+ ! could
+ ! remove this Interp routine, moving its body to the end of
+ ! InitEachTimeStep.
+ !
+ ! !USES:
+ !
+ ! !ARGUMENTS:
+ class(hlm_fates_interface_type), intent(inout) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+
+ character(len=*), parameter :: subname = 'InterpFileInputs'
+ !-----------------------------------------------------------------------
+
+ call this%fates_fire_data_method%CNFireInterp(bounds)
+
+ end subroutine InterpFileInputs
+
+ !-----------------------------------------------------------------------
+ subroutine Init2(this, bounds, NLFilename)
+ !
+ ! !DESCRIPTION:
+ ! Initialization after subgrid weights are determined
+ !
+ ! This copy should only be called if use_fates is .true.
+ !
+ ! !USES:
+ !
+ ! !ARGUMENTS:
+ class(hlm_fates_interface_type), intent(inout) :: this
+ type(bounds_type), intent(in) :: bounds
+ character(len=*), intent(in) :: NLFilename ! namelist filename
+ !
+ ! !LOCAL VARIABLES:
+
+ character(len=*), parameter :: subname = 'Init2'
+ !-----------------------------------------------------------------------
+
+ call this%fates_fire_data_method%CNFireInit(bounds, NLFilename)
+
+ end subroutine Init2
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccBuffer(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Initialized any accumulation buffers needed for FATES
+ !
+ ! !USES:
+ !
+ ! !ARGUMENTS:
+ class(hlm_fates_interface_type), intent(inout) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+
+ character(len=*), parameter :: subname = 'InitAccBuffer'
+ !-----------------------------------------------------------------------
+
+ call this%fates_fire_data_method%InitAccBuffer( bounds )
+
+ end subroutine InitAccBuffer
+
+
+ !-----------------------------------------------------------------------
+ subroutine InitAccVars(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Initialized any accumulation variables needed for FATES
+ !
+ ! !USES:
+ !
+ ! !ARGUMENTS:
+ class(hlm_fates_interface_type), intent(inout) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+
+ character(len=*), parameter :: subname = 'InitAccVars'
+ !-----------------------------------------------------------------------
+
+ call this%fates_fire_data_method%InitAccVars( bounds )
+
+ end subroutine InitAccVars
+
+ !-----------------------------------------------------------------------
+ subroutine UpdateAccVars(this, bounds)
+ !
+ ! !DESCRIPTION:
+ ! Update any accumulation variables needed for FATES
+ !
+ ! !USES:
+ !
+ ! !ARGUMENTS:
+ class(hlm_fates_interface_type), intent(inout) :: this
+ type(bounds_type), intent(in) :: bounds
+ !
+ ! !LOCAL VARIABLES:
+
+ character(len=*), parameter :: subname = 'UpdateAccVars'
+ !-----------------------------------------------------------------------
+
+ call this%fates_fire_data_method%UpdateAccVars( bounds )
+
+ end subroutine UpdateAccVars
+
! ======================================================================================
subroutine init_history_io(this,bounds_proc)