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
29 changes: 29 additions & 0 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ module FatesHistoryInterfaceMod
use FatesSizeAgeTypeIndicesMod, only : get_cdamagesize_class_index
use FatesSizeAgeTypeIndicesMod, only : get_cdamagesizepft_class_index
use FatesSizeAgeTypeIndicesMod, only : coagetype_class_index
use FatesSizeAgeTypeIndicesMod, only : get_landusepft_class_index

implicit none
private ! By default everything is private
Expand Down Expand Up @@ -366,6 +367,10 @@ module FatesHistoryInterfaceMod
! land use by land use variables
integer :: ih_disturbance_rate_si_lulu
integer :: ih_transition_matrix_si_lulu

! land use by PFT variables
integer :: ih_biomass_si_lupft
integer :: ih_nocomp_patcharea_si_lupft

integer :: ih_fire_disturbance_rate_si
integer :: ih_logging_disturbance_rate_si
Expand Down Expand Up @@ -3125,6 +3130,7 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
integer :: i_heightbin ! iterator for height bins
integer :: ilyr ! Soil index for nlevsoil
integer :: icdpf, icdsc, icdam ! iterators for the crown damage level
integer :: lupft_index ! land use x PFT index
real(r8) :: gpp_cached ! gpp from previous timestep, for c13 discrimination
real(r8) :: crown_depth ! Depth of the crown [m]
real(r8) :: gpp_cached_scpf(numpft*nlevsclass) ! variable used to cache gpp value in previous time step; for C13 discrimination
Expand Down Expand Up @@ -3306,6 +3312,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 Down Expand Up @@ -3479,6 +3486,11 @@ subroutine update_history_dyn_subsite(this,nc,nsites,sites,bc_in)
this%hvars(ih_nocomp_pftburnedarea_si_pft)%r82d(io_si,ft) = &
this%hvars(ih_nocomp_pftburnedarea_si_pft)%r82d(io_si,ft) + &
cpatch%frac_burnt * cpatch%area * AREA_INV / sec_per_day

! land use x pft too
lupft_index = get_landusepft_class_index(cpatch%land_use_label,ft)
this%hvars(ih_nocomp_patcharea_si_lupft)%r82d(io_si,lupft_index) = &
this%hvars(ih_nocomp_patcharea_si_lupft)%r82d(io_si,lupft_index) + cpatch%area * AREA_INV
endif

end do
Expand Down Expand Up @@ -3583,6 +3595,12 @@ 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

! biomass by land use type and pft
lupft_index = get_landusepft_class_index(cpatch%land_use_label,ccohort%pft)
hio_biomass_si_lupft(io_si, lupft_index) = &
hio_biomass_si_lupft(io_si, lupft_index) &
+ 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 @@ -7142,6 +7160,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 @@ -7328,6 +7351,12 @@ subroutine define_history_vars(this, initialize_variables)
use_default='active', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_nocomp_pftburnedarea_si_pft)

call this%set_history_var(vname='FATES_NOCOMP_PATCHAREA_LUPF', units='m2 m-2',&
long='total patch area allowed per PFT and land use type (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_patcharea_si_lupft)
endif nocomp_if

call this%set_history_var(vname='FATES_CANOPYAREA', units='m2 m-2', &
Expand Down
8 changes: 7 additions & 1 deletion main/FatesHistoryVariableType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module FatesHistoryVariableType
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 : 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
18 changes: 17 additions & 1 deletion main/FatesSizeAgeTypeIndicesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module FatesSizeAgeTypeIndicesMod
use EDParamsMod, only : ED_val_history_height_bin_edges
use EDParamsMod, only : ED_val_history_coageclass_bin_edges
use EDParamsMod, only : ED_val_history_damage_bin_edges
use FatesConstantsMod, only : n_landuse_cats

implicit none
private ! Modules are private by default
Expand All @@ -31,6 +32,7 @@ module FatesSizeAgeTypeIndicesMod
public :: get_coage_class_index
public :: get_agefuel_class_index
public :: get_layersizetype_class_index
public :: get_landusepft_class_index

contains

Expand Down Expand Up @@ -257,6 +259,20 @@ function get_agefuel_class_index(age,fuel) result(age_by_fuel_class)

age_by_fuel_class = age_class + (fuel-1) * nlevage

end function get_agefuel_class_index
end function get_agefuel_class_index

! =====================================================================================

function get_landusepft_class_index(landuse_label,pft) result(landusepft_class)

! Arguments
integer,intent(in) :: landuse_label
integer,intent(in) :: pft

integer :: landusepft_class

landusepft_class = landuse_label + n_landuse_cats * (pft-1)

end function get_landusepft_class_index

end module FatesSizeAgeTypeIndicesMod