Skip to content

Commit

Permalink
Merge pull request #2 from rgknox/kovenock_slaprofile
Browse files Browse the repository at this point in the history
modularization - variable name updates
  • Loading branch information
kovenock authored Jul 13, 2018
2 parents ec9d16f + ac9085d commit 6589417
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 156 deletions.
16 changes: 8 additions & 8 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )
currentCohort%pft,currentCohort%c_area)
currentCohort%treelai = tree_lai(currentCohort%bl, currentCohort%status_coh, &
currentCohort%pft, currentCohort%c_area, currentCohort%n, &
currentCohort%canopy_layer, currentPatch%canopy_layer_tai )
currentCohort%canopy_layer, currentPatch%canopy_layer_tvai )

canopy_leaf_area = canopy_leaf_area + currentCohort%treelai *currentCohort%c_area

Expand Down Expand Up @@ -1088,7 +1088,7 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)
!
! The following patch level diagnostics are updated here:
!
! currentPatch%canopy_layer_tai(cl) ! TAI of each canopy layer
! currentPatch%canopy_layer_tvai(cl) ! total vegetated area index of layer
! currentPatch%ncan(cl,ft) ! number of vegetation layers needed
! ! in this patch's pft/canopy-layer
! currentPatch%nrad(cl,ft) ! same as ncan, but does not include
Expand Down Expand Up @@ -1158,7 +1158,7 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)
! calculate tree lai and sai.
! --------------------------------------------------------------------------------

currentPatch%canopy_layer_tai(:) = 0._r8
currentPatch%canopy_layer_tvai(:) = 0._r8
currentPatch%ncan(:,:) = 0
currentPatch%nrad(:,:) = 0
patch_lai = 0._r8
Expand All @@ -1184,25 +1184,25 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)
cl = currentCohort%canopy_layer

currentCohort%treelai = tree_lai(currentCohort%bl, currentCohort%status_coh, currentCohort%pft, &
currentCohort%c_area, currentCohort%n, currentCohort%canopy_layer, currentPatch%canopy_layer_tai )
currentCohort%c_area, currentCohort%n, currentCohort%canopy_layer, currentPatch%canopy_layer_tvai )
currentCohort%treesai = tree_sai(currentCohort%pft, currentCohort%treelai)

currentCohort%lai = currentCohort%treelai *currentCohort%c_area/currentPatch%total_canopy_area
currentCohort%sai = currentCohort%treesai *currentCohort%c_area/currentPatch%total_canopy_area

! Number of actual vegetation layers in this cohort's crown
currentCohort%NV = ceiling((currentCohort%treelai+currentCohort%treesai)/dinc_ed)
currentCohort%nv = ceiling((currentCohort%treelai+currentCohort%treesai)/dinc_ed)

currentPatch%ncan(cl,ft) = max(currentPatch%ncan(cl,ft),currentCohort%NV)

patch_lai = patch_lai + currentCohort%lai

! currentPatch%canopy_layer_tai(cl) = currentPatch%canopy_layer_tai(cl) + &
! currentPatch%canopy_layer_tvai(cl) = currentPatch%canopy_layer_tvai(cl) + &
! currentCohort%lai + currentCohort%sai

do cl = 1,nclmax-1
if(currentCohort%canopy_layer == cl)then
currentPatch%canopy_layer_tai(cl) = currentPatch%canopy_layer_tai(cl) + &
currentPatch%canopy_layer_tvai(cl) = currentPatch%canopy_layer_tvai(cl) + &
currentCohort%lai + currentCohort%sai
endif
enddo
Expand Down Expand Up @@ -1384,7 +1384,7 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)

if(iv==currentCohort%NV) then
remainder = (currentCohort%treelai + currentCohort%treesai) - &
(dinc_ed*dble(currentCohort%NV-1.0_r8))
(dinc_ed*dble(currentCohort%nv-1.0_r8))
if(remainder > dinc_ed )then
write(fates_log(), *)'ED: issue with remainder', &
currentCohort%treelai,currentCohort%treesai,dinc_ed, &
Expand Down
3 changes: 1 addition & 2 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module EDCohortDynamicsMod
use EDTypesMod , only : min_npm2, min_nppatch
use EDTypesMod , only : min_n_safemath
use EDTypesMod , only : nlevleaf
use EDTypesMod , only : dinc_ed
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesPlantHydraulicsMod, only : FuseCohortHydraulics
use FatesPlantHydraulicsMod, only : CopyCohortHydraulics
Expand Down Expand Up @@ -153,7 +152,7 @@ subroutine create_cohort(currentSite, patchptr, pft, nn, hite, dbh, bleaf, bfine
call carea_allom(new_cohort%dbh,new_cohort%n,spread,new_cohort%pft,new_cohort%c_area)

new_cohort%treelai = tree_lai(new_cohort%bl, new_cohort%status_coh, new_cohort%pft, &
new_cohort%c_area, new_cohort%n, new_cohort%canopy_layer, patchptr%canopy_layer_tai )
new_cohort%c_area, new_cohort%n, new_cohort%canopy_layer, patchptr%canopy_layer_tvai )
new_cohort%lai = new_cohort%treelai * new_cohort%c_area/patchptr%area
new_cohort%treesai = tree_sai(new_cohort%pft, new_cohort%treelai)

Expand Down
4 changes: 2 additions & 2 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ subroutine zero_patch(cp_p)
currentPatch%age = nan
currentPatch%age_class = 1
currentPatch%area = nan
currentPatch%canopy_layer_tai(:) = nan
currentPatch%canopy_layer_tvai(:) = nan
currentPatch%total_canopy_area = nan

currentPatch%tlai_profile(:,:,:) = nan
Expand Down Expand Up @@ -1347,7 +1347,7 @@ subroutine zero_patch(cp_p)
currentPatch%burnt_frac_litter(:) = 0.0_r8
currentPatch%btran_ft(:) = 0.0_r8

currentPatch%canopy_layer_tai(:) = 0.0_r8
currentPatch%canopy_layer_tvai(:) = 0.0_r8

currentPatch%seeds_in(:) = 0.0_r8
currentPatch%seed_decay(:) = 0.0_r8
Expand Down
100 changes: 34 additions & 66 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module EDPhysiologyMod
use EDCohortDynamicsMod , only : create_cohort, sort_cohorts
use FatesAllometryMod , only : tree_lai
use FatesAllometryMod , only : tree_sai
use FatesAllometryMod , only : decay_coeff_kn
use FatesAllometryMod , only : CumulativeLayerTVAI

use EDTypesMod , only : numWaterMem
use EDTypesMod , only : dl_sf, dinc_ed
Expand Down Expand Up @@ -73,7 +75,6 @@ module EDPhysiologyMod
private :: seed_decay
private :: seed_germination
public :: flux_into_litter_pools
public :: decay_coeff_kn


logical, parameter :: DEBUG = .false. ! local debug flag
Expand Down Expand Up @@ -173,33 +174,35 @@ subroutine trim_canopy( currentSite )
type (ed_cohort_type) , pointer :: currentCohort
type (ed_patch_type) , pointer :: currentPatch

integer :: z ! leaf layer
integer :: ipft ! pft index
integer :: trimmed ! was this layer trimmed in this year? If not expand the canopy.
real(r8) :: tar_bl ! target leaf biomass (leaves flushed, trimmed)
real(r8) :: tar_bfr ! target fine-root biomass (leaves flushed, trimmed)
real(r8) :: bfr_per_bleaf ! ratio of fine root per leaf biomass
real(r8) :: sla_levleaf ! sla at leaf level z
integer :: z ! leaf layer
integer :: ipft ! pft index
logical :: trimmed ! was this layer trimmed in this year? If not expand the canopy.
real(r8) :: tar_bl ! target leaf biomass (leaves flushed, trimmed)
real(r8) :: tar_bfr ! target fine-root biomass (leaves flushed, trimmed)
real(r8) :: bfr_per_bleaf ! ratio of fine root per leaf biomass
real(r8) :: sla_levleaf ! sla at leaf level z
real(r8) :: nscaler_levleaf ! nscaler value at leaf level z
integer :: cl ! canopy layer index
real(r8) :: laican ! canopy sum of lai_z
real(r8) :: vai ! leaf and stem area in this layer
real(r8) :: kn ! nitrogen decay coefficient
real(r8) :: sla_max ! Observational constraint on how large sla (m2/gC) can become
real(r8) :: vai_to_lai ! ratio of vegetation area index (ie. lai+sai) : lai for individual tree
integer :: cl ! canopy layer index
real(r8) :: cum_tvai ! cumulative total vegetation area index at arbitrary leaf layers
real(r8) :: vai ! leaf and stem area in this layer
real(r8) :: kn ! nitrogen decay coefficient
real(r8) :: sla_max ! Observational constraint on how large sla (m2/gC) can become

!----------------------------------------------------------------------

write(fates_log(),*) 'trimming'

currentPatch => currentSite%youngest_patch

do while(associated(currentPatch))

currentCohort => currentPatch%tallest
do while (associated(currentCohort))
trimmed = 0
trimmed = .false.
ipft = currentCohort%pft
call carea_allom(currentCohort%dbh,currentCohort%n,currentSite%spread,currentCohort%pft,currentCohort%c_area)
currentCohort%treelai = tree_lai(currentCohort%bl, currentCohort%status_coh, currentCohort%pft, &
currentCohort%c_area, currentCohort%n, currentCohort%canopy_layer, currentPatch%canopy_layer_tai )
currentCohort%c_area, currentCohort%n, currentCohort%canopy_layer, currentPatch%canopy_layer_tvai )
currentCohort%treesai = tree_sai(currentCohort%pft, currentCohort%treelai)
currentCohort%nv = ceiling((currentCohort%treelai+currentCohort%treesai)/dinc_ed)
if (currentCohort%nv > nlevleaf)then
Expand All @@ -218,45 +221,28 @@ subroutine trim_canopy( currentSite )
! Identify current canopy layer (cl)
cl = currentCohort%canopy_layer

! Calculate the lai+sai of overlying canopy layers (laican)
if (cl==1) then !are we in the top canopy layer or a shaded layer?
laican = 0._r8
else
laican = sum(currentPatch%canopy_layer_tai(1:cl-1))
end if

! Observational constraint for maximum sla value (m2/gC):
! m2/gC = m2/gBiomass *kgC/kgBiomass
! m2/gC = m2/gBiomass * kgBiomass/kgC
sla_max = sla_max_drymass * EDPftvarcon_inst%c2b(ipft)
! Ratio of vegetation area index (ie. lai+sai) to lai for individual tree:
vai_to_lai = 1.0_r8 + (EDPftvarcon_inst%allom_sai_scaler(ipft)/ &
EDPftvarcon_inst%slatop(ipft))

!Leaf cost vs netuptake for each leaf layer.
do z = 1,nlevleaf

! Vegetation area index as a function of tree_lai+tree_sai
if(currentCohort%treelai >= (z-1)*dinc_ed)then
! if tree_lai in this layer is greater than 0
if (z == 1) then
! If in first layer, add value equal to vai halfway through the layer
! Here, vai = layer z's tree_lai + tree_sai = vai_to_lai *dinc_ed
laican = laican + 0.5_r8 * vai_to_lai * dinc_ed
else
! Since starting from halfway through first layer when z=1,
! we can add vai for an entire layer
! to remain at halfway value for subsequent layers.
laican = laican + vai_to_lai * dinc_ed
end if
else ! If tree_lai does not extend into this layer, do not add to laican
end if
do z = 1, currentCohort%nv

! Calculate the cumulative total vegetation area index (no snow occlusion, stems and leaves)
cum_tvai = CumulativeLayerTVAI(cl, &
z, &
ipft, &
currentCohort%treelai+currentCohort%treesai, &
currentPatch%canopy_layer_tvai(:))



if (currentCohort%year_net_uptake(z) /= 999._r8)then !there was activity this year in this leaf layer.

! Scale for leaf nitrogen profile
kn = decay_coeff_kn(ipft)
! Nscaler value at leaf level z
nscaler_levleaf = exp(-kn * laican)
nscaler_levleaf = exp(-kn * cum_tvai)
! Sla value at leaf level z after nitrogen profile scaling (m2/gC)
sla_levleaf = EDPftvarcon_inst%slatop(ipft)/nscaler_levleaf

Expand Down Expand Up @@ -312,15 +298,15 @@ subroutine trim_canopy( currentSite )
currentCohort%laimemory = currentCohort%laimemory * &
(1.0_r8 - EDPftvarcon_inst%trim_inc(ipft))
endif
trimmed = 1
trimmed = .true.
endif
endif
endif
endif !leaf activity?
enddo !z

currentCohort%year_net_uptake(:) = 999.0_r8
if (trimmed == 0.and.currentCohort%canopy_trim < 1.0_r8)then
if ( (.not.trimmed) .and.currentCohort%canopy_trim < 1.0_r8)then
currentCohort%canopy_trim = currentCohort%canopy_trim + EDPftvarcon_inst%trim_inc(ipft)
endif

Expand Down Expand Up @@ -2472,27 +2458,9 @@ subroutine flux_into_litter_pools(nsites, sites, bc_in, bc_out)

end subroutine flux_into_litter_pools


real(r8) function decay_coeff_kn(pft)

! ============================================================================
! Decay coefficient (kn) is a function of vcmax25top for each pft.
! ============================================================================

!ARGUMENTS
integer, intent(in) :: pft

!LOCAL VARIABLES
! -----------------------------------------------------------------------------------
! ===================================================================================

! Bonan et al (2011) JGR, 116, doi:10.1029/2010JG001593 used
! kn = 0.11. Here, we derive kn from vcmax25 as in Lloyd et al
! (2010) Biogeosciences, 7, 1833-1859

decay_coeff_kn = exp(0.00963_r8 * EDPftvarcon_inst%vcmax25top(pft) - 2.43_r8)

return

end function decay_coeff_kn

end module EDPhysiologyMod
Loading

0 comments on commit 6589417

Please sign in to comment.