Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ module FatesHistoryInterfaceMod
! land-use-resolved variables
integer :: ih_fracarea_si_landuse
integer :: ih_biomass_si_landuse
integer :: ih_biomass_si_lupft
integer :: ih_burnedarea_si_landuse
integer :: ih_gpp_si_landuse
integer :: ih_npp_si_landuse
Expand Down Expand Up @@ -650,11 +651,13 @@ module FatesHistoryInterfaceMod
integer :: ih_meansmp_si_pft
integer :: ih_elong_factor_si_pft
integer :: ih_nocomp_pftpatchfraction_si_pft
integer :: ih_nocomp_pftpatchfraction_si_lupft
integer :: ih_nocomp_pftnpatches_si_pft
integer :: ih_nocomp_pftburnedarea_si_pft
integer :: ih_seeds_out_gc_si_pft
integer :: ih_seeds_in_gc_si_pft
integer :: ih_seed_bank_si_pft ! carbon only
integer :: ih_seed_bank_si_lupft ! carbon only
integer :: ih_seeds_in_si_pft ! carbon only
integer :: ih_seeds_in_local_si_pft ! carbon only
integer :: ih_ungerm_seed_bank_si_pft ! carbon only
Expand Down Expand Up @@ -3140,7 +3143,8 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
real(r8) :: a_sapw ! sapwood area [m^2]
real(r8) :: c_sapw ! sapwood biomass [kgC]

integer :: i_dist, j_dist
integer :: i_dist, j_dist
integer :: i_lupft

type(elem_diag_type), pointer :: elflux_diags
type(elem_diag_type), pointer :: elflux_diags_c
Expand Down Expand Up @@ -3312,6 +3316,7 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
hio_fracarea_si_landuse => this%hvars(ih_fracarea_si_landuse)%r82d, &
hio_npp_si_landuse => this%hvars(ih_npp_si_landuse)%r82d, &
hio_biomass_si_landuse => this%hvars(ih_biomass_si_landuse)%r82d, &
hio_biomass_si_lupft => this%hvars(ih_biomass_si_lupft)%r82d, &
hio_burnedarea_si_landuse => this%hvars(ih_burnedarea_si_landuse)%r82d, &
hio_burnt_frac_litter_si_fuel => this%hvars(ih_burnt_frac_litter_si_fuel)%r82d, &
hio_fuel_amount_si_fuel => this%hvars(ih_fuel_amount_si_fuel)%r82d, &
Expand All @@ -3335,6 +3340,7 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
hio_meansmp_si_pft => this%hvars(ih_meansmp_si_pft)%r82d, &
hio_elong_factor_si_pft => this%hvars(ih_elong_factor_si_pft)%r82d, &
hio_seed_bank_si_pft => this%hvars(ih_seed_bank_si_pft)%r82d, &
hio_seed_bank_si_lupft => this%hvars(ih_seed_bank_si_lupft)%r82d, &
hio_ungerm_seed_bank_si_pft => this%hvars(ih_ungerm_seed_bank_si_pft)%r82d, &
hio_seedling_pool_si_pft => this%hvars(ih_seedling_pool_si_pft)%r82d, &
hio_seeds_in_si_pft => this%hvars(ih_seeds_in_si_pft)%r82d, &
Expand Down Expand Up @@ -3476,9 +3482,14 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
! there is more than one patch per age class -
! and also pft-labeled patch areas in the event that we are in nocomp mode
if ( hlm_use_nocomp .eq. itrue .and. cpatch%nocomp_pft_label .eq. ft) then
i_lupft = ft + numpft * (cpatch%land_use_label - 1)

this%hvars(ih_nocomp_pftpatchfraction_si_pft)%r82d(io_si,ft) = &
this%hvars(ih_nocomp_pftpatchfraction_si_pft)%r82d(io_si,ft) + cpatch%area * AREA_INV

this%hvars(ih_nocomp_pftpatchfraction_si_lupft)%r82d(io_si,i_lupft) = &
this%hvars(ih_nocomp_pftpatchfraction_si_lupft)%r82d(io_si,i_lupft) + cpatch%area * AREA_INV

this%hvars(ih_nocomp_pftnpatches_si_pft)%r82d(io_si,ft) = &
this%hvars(ih_nocomp_pftnpatches_si_pft)%r82d(io_si,ft) + 1._r8

Expand Down Expand Up @@ -3591,6 +3602,10 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
hio_biomass_si_landuse(io_si, cpatch%land_use_label) &
+ total_m * ccohort%n * AREA_INV

i_lupft = ccohort%pft + numpft * (cpatch%land_use_label - 1)
hio_biomass_si_lupft(io_si, i_lupft) = &
hio_biomass_si_lupft(io_si, i_lupft) + total_m * ccohort%n * AREA_INV

if (ccohort%canopy_layer .eq. 1) then
storec_canopy_scpf(i_scpf) = &
storec_canopy_scpf(i_scpf) + ccohort%n * store_m
Expand Down Expand Up @@ -4210,10 +4225,16 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
litt_c => cpatch%litter(element_pos(carbon12_element))

do i_pft = 1, numpft
i_lupft = i_pft + numpft * (cpatch%land_use_label - 1)

! Sum up total seed bank (germinated and ungerminated)
hio_seed_bank_si_pft(io_si,i_pft) = hio_seed_bank_si_pft(io_si,i_pft) + &
(litt_c%seed(i_pft)+litt_c%seed_germ(i_pft)) * cpatch%area * AREA_INV

! Sum up total seed bank (germinated and ungerminated) by land-use x PFT
hio_seed_bank_si_lupft(io_si,i_lupft) = hio_seed_bank_si_lupft(io_si,i_lupft) + &
(litt_c%seed(i_pft)+litt_c%seed_germ(i_pft)) * cpatch%area * AREA_INV

! Sum up total seed bank (just ungerminated)
hio_ungerm_seed_bank_si_pft(io_si,i_pft) = hio_ungerm_seed_bank_si_pft(io_si,i_pft) + &
litt_c%seed(i_pft) * cpatch%area * AREA_INV
Expand Down Expand Up @@ -7156,6 +7177,11 @@ subroutine define_history_vars(this, initialize_variables)
avgflag='A', vtype=site_landuse_r8, hlms='CLM:ALM', upfreq=group_dyna_complx, &
ivar=ivar, initialize=initialize_variables, index=ih_biomass_si_landuse)

call this%set_history_var(vname='FATES_VEGC_LUPF', units='kg m-2', &
long='Vegetation Carbon by land use type and PFT', use_default='active', &
avgflag='A', vtype=site_lupft_r8, hlms='CLM:ALM', upfreq=group_dyna_complx, &
ivar=ivar, initialize=initialize_variables, index=ih_biomass_si_lupft)

call this%set_history_var(vname='FATES_BURNEDAREA_LU', units='s-1', &
long='burned area by land use type', use_default='active', &
avgflag='A', vtype=site_landuse_r8, hlms='CLM:ALM', upfreq=group_dyna_complx, &
Expand Down Expand Up @@ -7254,10 +7280,16 @@ subroutine define_history_vars(this, initialize_variables)

call this%set_history_var(vname='FATES_SEED_BANK_PF', units='kg m-2', &
long='total seed mass per PFT in kg carbon per m2 land area', &
use_default='inactive', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
use_default='active', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index = ih_seed_bank_si_pft)

call this%set_history_var(vname='FATES_SEED_BANK_LUPF', units='kg m-2', &
long='total seed mass by land use type and PFT in kg carbon per m2 land area', &
use_default='active', avgflag='A', vtype=site_lupft_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index = ih_seed_bank_si_lupft)

call this%set_history_var(vname='FATES_UNGERM_SEED_BANK_PF', units='kg m-2', &
long='ungerminated seed mass per PFT in kg carbon per m2 land area', &
use_default='inactive', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
Expand Down Expand Up @@ -7343,6 +7375,12 @@ subroutine define_history_vars(this, initialize_variables)
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_nocomp_pftpatchfraction_si_pft)

call this%set_history_var(vname='FATES_NOCOMP_PATCHAREA_LUPF', units='m2 m-2',&
long='total patch area allowed by land use type and PFT (nocomp-mode-only)', &
use_default='active', avgflag='A', vtype=site_lupft_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_nocomp_pftpatchfraction_si_lupft)

call this%set_history_var(vname='FATES_NOCOMP_BURNEDAREA_PF', units='s-1', &
long='total burned area of PFT-labeled patch area (nocomp-mode-only)',&
use_default='active', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
Expand Down
10 changes: 8 additions & 2 deletions main/FatesHistoryVariableType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module FatesHistoryVariableType
use FatesIOVariableKindMod, only : site_cdsc_r8, site_cdpf_r8
use FatesIOVariableKindMod, only : site_elem_r8, site_elpft_r8
use FatesIOVariableKindMod, only : site_elcwd_r8, site_elage_r8
use FatesIOVariableKindMod, only : iotype_index, site_agefuel_r8, site_clscpf_r8
use FatesIOVariableKindMod, only : site_landuse_r8, site_lulu_r8
use FatesIOVariableKindMod, only : iotype_index, site_agefuel_r8, site_clscpf_r8
use FatesIOVariableKindMod, only : site_landuse_r8, site_lulu_r8, site_lupft_r8
use shr_log_mod , only : errMsg => shr_log_errMsg


Expand Down Expand Up @@ -225,6 +225,10 @@ subroutine Init(this, vname, units, long, use_default, &
allocate(this%r82d(lb1:ub1, lb2:ub2))
this%r82d(:,:) = flushval

case(site_lupft_r8)
allocate(this%r82d(lb1:ub1, lb2:ub2))
this%r82d(:,:) = flushval

case(site_clscpf_r8)
allocate(this%r82d(lb1:ub1, lb2:ub2))
this%r82d(:,:) = flushval
Expand Down Expand Up @@ -359,6 +363,8 @@ subroutine HFlush(this, thread, dim_bounds, dim_kinds)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval
case(site_lulu_r8)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval
case(site_lupft_r8)
this%r82d(lb1:ub1, lb2:ub2) = this%flushval

case default
write(fates_log(),*) 'fates history variable type undefined while flushing history variables'
Expand Down