Skip to content

Commit 7c065e2

Browse files
authored
Merge pull request #632 from rosiealice/fates_sp
Fates Fixed Biogeography
2 parents 9213ca2 + 0f2ea16 commit 7c065e2

File tree

7 files changed

+120
-18
lines changed

7 files changed

+120
-18
lines changed

biogeochem/EDPhysiologyMod.F90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ subroutine SeedIn( currentSite, bc_in )
12051205
! !USES:
12061206
use EDTypesMod, only : area
12071207
use EDTypesMod, only : homogenize_seed_pfts
1208+
!use FatesInterfaceTypesMod, only : hlm_use_fixed_biogeog ! For future reduced complexity?
12081209
!
12091210
! !ARGUMENTS
12101211
type(ed_site_type), intent(inout), target :: currentSite
@@ -1308,18 +1309,17 @@ subroutine SeedIn( currentSite, bc_in )
13081309

13091310
litt => currentPatch%litter(el)
13101311
do pft = 1,numpft
1311-
1312+
if(currentSite%use_this_pft(pft).eq.itrue)then
13121313
! Seed input from local sources (within site)
13131314
litt%seed_in_local(pft) = litt%seed_in_local(pft) + site_seed_rain(pft)/area
13141315

13151316
! Seed input from external sources (user param seed rain, or dispersal model)
13161317
seed_in_external = seed_stoich*EDPftvarcon_inst%seed_suppl(pft)*years_per_day
1317-
13181318
litt%seed_in_extern(pft) = litt%seed_in_extern(pft) + seed_in_external
13191319

13201320
! Seeds entering externally [kg/site/day]
13211321
site_mass%seed_in = site_mass%seed_in + seed_in_external*currentPatch%area
1322-
1322+
end if !use this pft
13231323
enddo
13241324

13251325

@@ -1411,6 +1411,7 @@ subroutine SeedGermination( litt, cold_stat, drought_stat )
14111411
litt%seed_germ_in(pft) = 0.0_r8
14121412
end if
14131413

1414+
14141415
enddo
14151416

14161417
end subroutine SeedGermination
@@ -1467,14 +1468,15 @@ subroutine recruitment( currentSite, currentPatch, bc_in )
14671468
real(r8) :: mass_demand ! Total mass demanded by the plant to achieve the stoichiometric targets
14681469
! of all the organs in the recruits. Used for both [kg per plant] and [kg per cohort]
14691470
real(r8) :: stem_drop_fraction
1470-
1471+
14711472
!----------------------------------------------------------------------
14721473

14731474
allocate(temp_cohort) ! create temporary cohort
14741475
call zero_cohort(temp_cohort)
14751476

1476-
do ft = 1,numpft
14771477

1478+
do ft = 1,numpft
1479+
if(currentSite%use_this_pft(ft).eq.itrue)then
14781480
temp_cohort%canopy_trim = 0.8_r8 !starting with the canopy not fully expanded
14791481
temp_cohort%pft = ft
14801482
temp_cohort%hite = EDPftvarcon_inst%hgt_min(ft)
@@ -1711,6 +1713,7 @@ subroutine recruitment( currentSite, currentPatch, bc_in )
17111713

17121714

17131715
endif
1716+
endif !use_this_pft
17141717
enddo !pft loop
17151718

17161719
deallocate(temp_cohort) ! delete temporary cohort

main/EDInitMod.F90

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ module EDInitMod
3535
use EDTypesMod , only : phen_dstat_moistoff
3636
use EDTypesMod , only : phen_cstat_notcold
3737
use EDTypesMod , only : phen_dstat_moiston
38-
use EDTypesMod , only : element_pos
3938
use FatesInterfaceTypesMod , only : bc_in_type
4039
use FatesInterfaceTypesMod , only : hlm_use_planthydro
4140
use FatesInterfaceTypesMod , only : hlm_use_inventory_init
41+
use FatesInterfaceTypesMod , only : hlm_use_fixed_biogeog
4242
use FatesInterfaceTypesMod , only : numpft
4343
use FatesInterfaceTypesMod , only : nleafage
4444
use FatesInterfaceTypesMod , only : nlevsclass
@@ -124,6 +124,9 @@ subroutine init_site_vars( site_in, bc_in )
124124
allocate(site_in%dz_soil(site_in%nlevsoil))
125125
allocate(site_in%z_soil(site_in%nlevsoil))
126126

127+
allocate(site_in%area_pft(1:numpft))
128+
allocate(site_in%use_this_pft(1:numpft))
129+
127130
do el=1,num_elements
128131
allocate(site_in%flux_diags(el)%leaf_litter_input(1:numpft))
129132
allocate(site_in%flux_diags(el)%root_litter_input(1:numpft))
@@ -136,7 +139,7 @@ subroutine init_site_vars( site_in, bc_in )
136139
site_in%zi_soil(:) = bc_in%zi_sisl(:)
137140
site_in%dz_soil(:) = bc_in%dz_sisl(:)
138141
site_in%z_soil(:) = bc_in%z_sisl(:)
139-
142+
140143

141144
!
142145
end subroutine init_site_vars
@@ -218,10 +221,12 @@ subroutine zero_site( site_in )
218221
! canopy spread
219222
site_in%spread = 0._r8
220223

224+
site_in%area_pft(:) = 0._r8
225+
site_in%use_this_pft(:) = fates_unset_int
221226
end subroutine zero_site
222227

223228
! ============================================================================
224-
subroutine set_site_properties( nsites, sites )
229+
subroutine set_site_properties( nsites, sites,bc_in )
225230
!
226231
! !DESCRIPTION:
227232
!
@@ -231,7 +236,7 @@ subroutine set_site_properties( nsites, sites )
231236

232237
integer, intent(in) :: nsites
233238
type(ed_site_type) , intent(inout), target :: sites(nsites)
234-
239+
type(bc_in_type), intent(in) :: bc_in(nsites)
235240
!
236241
! !LOCAL VARIABLES:
237242
integer :: s
@@ -244,6 +249,7 @@ subroutine set_site_properties( nsites, sites )
244249
integer :: cleafoff ! DOY for cold-decid leaf-off, initial guess
245250
integer :: dleafoff ! DOY for drought-decid leaf-off, initial guess
246251
integer :: dleafon ! DOY for drought-decid leaf-on, initial guess
252+
integer :: ft ! PFT loop
247253
!----------------------------------------------------------------------
248254

249255

@@ -286,7 +292,24 @@ subroutine set_site_properties( nsites, sites )
286292
sites(s)%acc_NI = acc_NI
287293
sites(s)%NF = 0.0_r8
288294
sites(s)%frac_burnt = 0.0_r8
289-
295+
296+
! PLACEHOLDER FOR PFT AREA DATA MOVED ACROSS INTERFACE
297+
if(hlm_use_fixed_biogeog.eq.itrue)then
298+
do ft = 1,numpft
299+
sites(s)%area_pft(ft) = bc_in(s)%pft_areafrac(ft)
300+
end do
301+
end if
302+
303+
do ft = 1,numpft
304+
sites(s)%use_this_pft(ft) = itrue
305+
if(hlm_use_fixed_biogeog.eq.itrue)then
306+
if(sites(s)%area_pft(ft).gt.0.0_r8)then
307+
sites(s)%use_this_pft(ft) = itrue
308+
else
309+
sites(s)%use_this_pft(ft) = ifalse
310+
end if !area
311+
end if !SBG
312+
end do !ft
290313

291314
end do
292315

@@ -466,7 +489,7 @@ subroutine init_cohorts( site_in, patch_in, bc_in)
466489
patch_in%shortest => null()
467490

468491
do pft = 1,numpft
469-
492+
if(site_in%use_this_pft(pft).eq.itrue)then
470493
if(EDPftvarcon_inst%initd(pft)>1.0E-7) then
471494

472495
allocate(temp_cohort) ! temporary cohort
@@ -610,7 +633,7 @@ subroutine init_cohorts( site_in, patch_in, bc_in)
610633
deallocate(temp_cohort) ! get rid of temporary cohort
611634

612635
endif
613-
636+
endif !use_this_pft
614637
enddo !numpft
615638

616639
! Zero the mass flux pools of the new cohorts

main/EDMainMod.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ subroutine TotalBalanceCheck (currentSite, call_index )
673673
write(fates_log(),*) 'biomass', biomass_stock
674674
write(fates_log(),*) 'litter',litter_stock
675675
write(fates_log(),*) 'seeds',seed_stock
676+
write(fates_log(),*) 'total stock', total_stock
676677
write(fates_log(),*) 'previous total',site_mass%old_stock
677678
write(fates_log(),*) 'lat lon',currentSite%lat,currentSite%lon
678679

@@ -690,6 +691,7 @@ subroutine TotalBalanceCheck (currentSite, call_index )
690691
write(fates_log(),*) 'root litter (by layer): ',sum(litt%root_fines,dim=1)
691692
write(fates_log(),*) 'dist mode: ',currentPatch%disturbance_mode
692693
write(fates_log(),*) 'anthro_disturbance_label: ',currentPatch%anthro_disturbance_label
694+
write(fates_log(),*) 'use_this_pft: ', currentSite%use_this_pft(:)
693695
if(print_cohorts)then
694696
write(fates_log(),*) '---- Biomass by cohort and organ -----'
695697
currentCohort => currentPatch%tallest

main/EDTypesMod.F90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module EDTypesMod
3232
! are not the top canopy layer)
3333

3434
integer, parameter, public :: nlevleaf = 30 ! number of leaf layers in canopy layer
35-
integer, parameter, public :: maxpft = 15 ! maximum number of PFTs allowed
35+
integer, parameter, public :: maxpft = 16 ! maximum number of PFTs allowed
3636
! the parameter file may determine that fewer
3737
! are used, but this helps allocate scratch
3838
! space and output arrays.
@@ -657,7 +657,11 @@ module EDTypesMod
657657
! INDICES
658658
real(r8) :: lat ! latitude: degrees
659659
real(r8) :: lon ! longitude: degrees
660-
660+
661+
! Fixed Biogeography mode inputs
662+
real(r8), allocatable :: area_PFT(:) ! Area allocated to individual PFTs
663+
integer, allocatable :: use_this_pft(:) ! Is area_PFT > 0 ? (1=yes, 0=no)
664+
661665
! Mass Balance (allocation for each element)
662666

663667
type(site_massbal_type), pointer :: mass_balance(:)

main/FatesInterfaceMod.F90

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module FatesInterfaceMod
7676
public :: allocate_bcin
7777
public :: allocate_bcout
7878
public :: zero_bcs
79+
public :: set_bcs
7980

8081
contains
8182

@@ -354,6 +355,9 @@ subroutine allocate_bcin(bc_in, nlevsoil_in, nlevdecomp_in)
354355
allocate(bc_in%h2o_liq_sisl(nlevsoil_in)); bc_in%h2o_liq_sisl = nan
355356
end if
356357

358+
allocate(bc_in%pft_areafrac(maxpft))
359+
360+
357361
return
358362
end subroutine allocate_bcin
359363

@@ -986,6 +990,8 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
986990
hlm_use_logging = unset_int
987991
hlm_use_ed_st3 = unset_int
988992
hlm_use_ed_prescribed_phys = unset_int
993+
hlm_use_fixed_biogeog = unset_int
994+
!hlm_use_nocomp = unset_int ! future reduced complexity mode
989995
hlm_use_inventory_init = unset_int
990996
hlm_inventory_ctrl_file = 'unset'
991997

@@ -1186,6 +1192,21 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
11861192
call endrun(msg=errMsg(sourcefile, __LINE__))
11871193
end if
11881194

1195+
if(hlm_use_fixed_biogeog.eq.unset_int) then
1196+
if(fates_global_verbose()) then
1197+
write(fates_log(), *) 'switch for fixed biogeog unset: him_use_fixed_biogeog, exiting'
1198+
end if
1199+
call endrun(msg=errMsg(sourcefile, __LINE__))
1200+
end if
1201+
1202+
! Future reduced complexity mode
1203+
!if(hlm_use_nocomp.eq.unset_int) then
1204+
! if(fates_global_verbose()) then
1205+
! write(fates_log(), *) 'switch for no competition mode. '
1206+
! end if
1207+
! call endrun(msg=errMsg(sourcefile, __LINE__))
1208+
! end if
1209+
11891210
if(hlm_use_cohort_age_tracking .eq. unset_int) then
11901211
if (fates_global_verbose()) then
11911212
write(fates_log(), *) 'switch for cohort_age_tracking unset: hlm_use_cohort_age_tracking, exiting'
@@ -1269,7 +1290,21 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
12691290
if (fates_global_verbose()) then
12701291
write(fates_log(),*) 'Transfering hlm_use_spitfire= ',ival,' to FATES'
12711292
end if
1272-
1293+
1294+
case('use_fixed_biogeog')
1295+
hlm_use_fixed_biogeog = ival
1296+
if (fates_global_verbose()) then
1297+
write(fates_log(),*) 'Transfering hlm_use_fixed_biogeog= ',ival,' to FATES'
1298+
end if
1299+
1300+
! Future reduced complexity mode
1301+
!case('use_nocomp')
1302+
! hlm_use_nocomp = ival
1303+
! if (fates_global_verbose()) then
1304+
! write(fates_log(),*) 'Transfering hlm_use_nocomp= ',ival,' to FATES'
1305+
! end if
1306+
1307+
12731308
case('use_planthydro')
12741309
hlm_use_planthydro = ival
12751310
if (fates_global_verbose()) then

main/FatesInterfaceTypesMod.F90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ module FatesInterfaceTypesMod
133133
! This need only be defined when
134134
! hlm_use_inventory_init = 1
135135

136+
integer, public :: hlm_use_fixed_biogeog ! Flag to use FATES fixed biogeography mode
137+
! 1 = TRUE, 0 = FALSE
138+
136139
! -------------------------------------------------------------------------------------
137140
! Parameters that are dictated by FATES and known to be required knowledge
138141
! needed by the HLMs
@@ -423,7 +426,10 @@ module FatesInterfaceTypesMod
423426
real(r8),allocatable :: hksat_sisl(:) ! hydraulic conductivity at saturation (mm H2O /s)
424427
real(r8),allocatable :: h2o_liq_sisl(:) ! Liquid water mass in each layer (kg/m2)
425428
real(r8) :: smpmin_si ! restriction for min of soil potential (mm)
426-
429+
430+
! Fixed biogeography mode
431+
real(r8), allocatable :: pft_areafrac(:) ! Fractional area of the FATES column occupied by each PFT
432+
427433
end type bc_in_type
428434

429435

main/FatesRestartInterfaceMod.F90

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ module FatesRestartInterfaceMod
152152
integer :: ir_seed_bank_sift
153153
integer :: ir_spread_si
154154
integer :: ir_recrate_sift
155+
integer :: ir_use_this_pft_sift
156+
integer :: ir_area_pft_sift
155157
integer :: ir_fmortrate_cano_siscpf
156158
integer :: ir_fmortrate_usto_siscpf
157159
integer :: ir_imortrate_siscpf
@@ -177,7 +179,6 @@ module FatesRestartInterfaceMod
177179
integer :: ir_errfates_mbal
178180
integer :: ir_prt_base ! Base index for all PRT variables
179181

180-
181182
! Hydraulic indices
182183
integer :: ir_hydro_th_ag_covec
183184
integer :: ir_hydro_th_troot
@@ -1005,6 +1006,17 @@ subroutine define_restart_vars(this, initialize_variables)
10051006
units='indiv/ha/day', flushval = flushzero, &
10061007
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_recrate_sift)
10071008

1009+
call this%set_restart_var(vname='fates_use_this_pft', vtype=cohort_int, & !should this be cohort_int as above?
1010+
long_name='in fixed biogeog mode, is pft in gridcell?', &
1011+
units='0/1', flushval = flushzero, &
1012+
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_use_this_pft_sift)
1013+
1014+
call this%set_restart_var(vname='fates_area_pft', vtype=cohort_r8, &
1015+
long_name='in fixed biogeog mode, what is pft area in gridcell?', &
1016+
units='0/1', flushval = flushzero, &
1017+
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_area_pft_sift)
1018+
1019+
10081020
call this%set_restart_var(vname='fates_fmortrate_canopy', vtype=cohort_r8, &
10091021
long_name='fates diagnostics on fire mortality canopy', &
10101022
units='indiv/ha/year', flushval = flushzero, &
@@ -1533,6 +1545,8 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
15331545
rio_watermem_siwm => this%rvars(ir_watermem_siwm)%r81d, &
15341546
rio_vegtempmem_sitm => this%rvars(ir_vegtempmem_sitm)%r81d, &
15351547
rio_recrate_sift => this%rvars(ir_recrate_sift)%r81d, &
1548+
rio_use_this_pft_sift => this%rvars(ir_use_this_pft_sift)%int1d, &
1549+
rio_area_pft_sift => this%rvars(ir_area_pft_sift)%r81d, &
15361550
rio_fmortrate_cano_siscpf => this%rvars(ir_fmortrate_cano_siscpf)%r81d, &
15371551
rio_fmortrate_usto_siscpf => this%rvars(ir_fmortrate_usto_siscpf)%r81d, &
15381552
rio_imortrate_siscpf => this%rvars(ir_imortrate_siscpf)%r81d, &
@@ -1588,6 +1602,14 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
15881602
rio_recrate_sift(io_idx_co_1st+i_pft-1) = sites(s)%recruitment_rate(i_pft)
15891603
end do
15901604

1605+
do i_pft = 1,numpft
1606+
rio_use_this_pft_sift(io_idx_co_1st+i_pft-1) = sites(s)%use_this_pft(i_pft)
1607+
end do
1608+
1609+
do i_pft = 1,numpft
1610+
rio_area_pft_sift(io_idx_co_1st+i_pft-1) = sites(s)%area_pft(i_pft)
1611+
end do
1612+
15911613
do el = 1, num_elements
15921614

15931615
io_idx_si_cwd = io_idx_co_1st
@@ -2270,6 +2292,8 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
22702292
rio_watermem_siwm => this%rvars(ir_watermem_siwm)%r81d, &
22712293
rio_vegtempmem_sitm => this%rvars(ir_vegtempmem_sitm)%r81d, &
22722294
rio_recrate_sift => this%rvars(ir_recrate_sift)%r81d, &
2295+
rio_use_this_pft_sift => this%rvars(ir_use_this_pft_sift)%int1d, &
2296+
rio_area_pft_sift => this%rvars(ir_area_pft_sift)%r81d,&
22732297
rio_fmortrate_cano_siscpf => this%rvars(ir_fmortrate_cano_siscpf)%r81d, &
22742298
rio_fmortrate_usto_siscpf => this%rvars(ir_fmortrate_usto_siscpf)%r81d, &
22752299
rio_imortrate_siscpf => this%rvars(ir_imortrate_siscpf)%r81d, &
@@ -2313,7 +2337,12 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
23132337
do i_pft = 1,numpft
23142338
sites(s)%recruitment_rate(i_pft) = rio_recrate_sift(io_idx_co_1st+i_pft-1)
23152339
enddo
2316-
2340+
2341+
!variables for fixed biogeography mode. These are currently used in restart even when this is off.
2342+
do i_pft = 1,numpft
2343+
sites(s)%use_this_pft(i_pft) = rio_use_this_pft_sift(io_idx_co_1st+i_pft-1)
2344+
sites(s)%area_pft(i_pft) = rio_area_pft_sift(io_idx_co_1st+i_pft-1)
2345+
enddo
23172346

23182347
! Mass balance and diagnostics across elements at the site level
23192348
do el = 1, num_elements

0 commit comments

Comments
 (0)