Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:NGEET/fates into bchristo-planthy…
Browse files Browse the repository at this point in the history
…dro-longlived
  • Loading branch information
xuchongang committed May 11, 2018
2 parents 37b07df + 0c3e161 commit a594790
Show file tree
Hide file tree
Showing 25 changed files with 4,090 additions and 1,080 deletions.
860 changes: 477 additions & 383 deletions biogeochem/EDCanopyStructureMod.F90

Large diffs are not rendered by default.

262 changes: 105 additions & 157 deletions biogeochem/EDCohortDynamicsMod.F90

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module EDLoggingMortalityMod
use EDParamsMod , only : logging_direct_frac
use EDParamsMod , only : logging_mechanical_frac
use EDParamsMod , only : logging_coll_under_frac
use EDParamsMod , only : logging_dbhmax_infra
use FatesInterfaceMod , only : hlm_current_year
use FatesInterfaceMod , only : hlm_current_month
use FatesInterfaceMod , only : hlm_current_day
Expand Down Expand Up @@ -156,7 +157,6 @@ subroutine LoggingMortality_frac( pft_i, dbh, lmort_direct,lmort_collateral,lmor

! Parameters
real(r8), parameter :: adjustment = 1.0 ! adjustment for mortality rates
real(r8), parameter :: logging_dbhmax_infra = 35 !(cm), based on Feldpaush et al. (2005) and Ferry et al. (2010)

if (logging_time) then
if(EDPftvarcon_inst%woody(pft_i) == 1)then ! only set logging rates for trees
Expand Down
18 changes: 9 additions & 9 deletions biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module EDMortalityFunctionsMod
use EDTypesMod , only : ed_patch_type
use FatesConstantsMod , only : itrue,ifalse
use FatesAllometryMod , only : bleaf
use EDParamsMod , only : ED_val_stress_mort
use FatesAllometryMod , only : storage_fraction_of_target
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_use_ed_prescribed_phys
use FatesInterfaceMod , only : hlm_freq_day
Expand Down Expand Up @@ -58,11 +58,10 @@ subroutine mortality_rates( cohort_in,bc_in,cmort,hmort,bmort,frmort )
real(r8),intent(out) :: frmort ! freezing stress mortality

real(r8) :: frac ! relativised stored carbohydrate
real(r8) :: b_leaf ! leaf biomass kgC
real(r8) :: b_leaf ! target leaf biomass kgC
real(r8) :: hf_sm_threshold ! hydraulic failure soil moisture threshold
real(r8) :: temp_dep ! Temp. function (freezing mortality)
real(r8) :: temp_in_C ! Daily averaged temperature in Celcius
real(r8),parameter :: frost_mort_scaler = 3.0_r8 ! Scaling factor for freezing mortality
real(r8),parameter :: frost_mort_buffer = 5.0_r8 ! 5deg buffer for freezing mortality

logical, parameter :: test_zero_mortality = .false. ! Developer test which
Expand All @@ -79,18 +78,19 @@ subroutine mortality_rates( cohort_in,bc_in,cmort,hmort,bmort,frmort )
hf_sm_threshold = EDPftvarcon_inst%hf_sm_threshold(cohort_in%pft)

if(cohort_in%patchptr%btran_ft(cohort_in%pft) <= hf_sm_threshold)then
hmort = ED_val_stress_mort
hmort = EDPftvarcon_inst%mort_scalar_hydrfailure(cohort_in%pft)
else
hmort = 0.0_r8
endif

! Carbon Starvation induced mortality.
if ( cohort_in%dbh > 0._r8 ) then
call bleaf(cohort_in%dbh,cohort_in%pft,cohort_in%canopy_trim,b_leaf)
if( b_leaf > 0._r8 .and. cohort_in%bstore <= b_leaf )then
frac = cohort_in%bstore/ b_leaf
cmort = max(0.0_r8,ED_val_stress_mort*(1.0_r8 - frac))
else
call storage_fraction_of_target(b_leaf, cohort_in%bstore, frac)
if( frac .lt. 1._r8) then
cmort = max(0.0_r8,EDPftvarcon_inst%mort_scalar_cstarvation(cohort_in%pft) * &
(1.0_r8 - frac))
else
cmort = 0.0_r8
endif

Expand All @@ -109,7 +109,7 @@ subroutine mortality_rates( cohort_in,bc_in,cmort,hmort,bmort,frmort )
temp_in_C = bc_in%t_veg24_si - tfrz
temp_dep = max(0.0,min(1.0,1.0 - (temp_in_C - &
EDPftvarcon_inst%freezetol(cohort_in%pft))/frost_mort_buffer) )
frmort = frost_mort_scaler * temp_dep
frmort = EDPftvarcon_inst%mort_scalar_coldstress(cohort_in%pft) * temp_dep


!mortality_rates = bmort + hmort + cmort
Expand Down
241 changes: 150 additions & 91 deletions biogeochem/EDPatchDynamicsMod.F90

Large diffs are not rendered by default.

85 changes: 33 additions & 52 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module EDPhysiologyMod
use FatesInterfaceMod, only : bc_in_type
use EDCohortDynamicsMod , only : zero_cohort
use EDCohortDynamicsMod , only : create_cohort, sort_cohorts
use EDCohortDynamicsMod , only : tree_lai
use EDCohortDynamicsMod , only : tree_sai
use FatesAllometryMod , only : tree_lai
use FatesAllometryMod , only : tree_sai

use EDTypesMod , only : numWaterMem
use EDTypesMod , only : dl_sf, dinc_ed
Expand Down Expand Up @@ -188,17 +188,23 @@ subroutine trim_canopy( currentSite )
trimmed = 0
ipft = currentCohort%pft
call carea_allom(currentCohort%dbh,currentCohort%n,currentSite%spread,currentCohort%pft,currentCohort%c_area)
currentCohort%treelai = tree_lai(currentCohort)
currentCohort%treelai = tree_lai(currentCohort%bl, currentCohort%status_coh, currentCohort%pft, &
currentCohort%c_area, currentCohort%n )
currentCohort%treesai = tree_sai(currentCohort%dbh, currentCohort%pft, currentCohort%canopy_trim, &
currentCohort%c_area, currentCohort%n)
currentCohort%nv = ceiling((currentCohort%treelai+currentCohort%treesai)/dinc_ed)
if (currentCohort%nv > nlevleaf)then
write(fates_log(),*) 'nv > nlevleaf',currentCohort%nv,currentCohort%treelai,currentCohort%treesai, &
currentCohort%c_area,currentCohort%n,currentCohort%bl
endif

call bleaf(currentcohort%dbh,ipft,currentcohort%canopy_trim,tar_bl)
call bfineroot(currentcohort%dbh,ipft,currentcohort%canopy_trim,tar_bfr)

bfr_per_bleaf = tar_bfr/tar_bl
if ( int(EDPftvarcon_inst%allom_fmode(ipft)) .eq. 1 ) then
! only query fine root biomass if using a fine root allometric model that takes leaf trim into account
call bfineroot(currentcohort%dbh,ipft,currentcohort%canopy_trim,tar_bfr)
bfr_per_bleaf = tar_bfr/tar_bl
endif

!Leaf cost vs netuptake for each leaf layer.
do z = 1,nlevleaf
Expand All @@ -210,18 +216,27 @@ subroutine trim_canopy( currentSite )


currentCohort%leaf_cost = 1._r8/(EDPftvarcon_inst%slatop(ipft)*1000.0_r8)
currentCohort%leaf_cost = currentCohort%leaf_cost + &
1.0_r8/(EDPftvarcon_inst%slatop(ipft)*1000.0_r8) * &
bfr_per_bleaf / EDPftvarcon_inst%root_long(ipft)

if ( int(EDPftvarcon_inst%allom_fmode(ipft)) .eq. 1 ) then
! if using trimmed leaf for fine root biomass allometry, add the cost of the root increment
! to the leaf increment; otherwise do not.
currentCohort%leaf_cost = currentCohort%leaf_cost + &
1.0_r8/(EDPftvarcon_inst%slatop(ipft)*1000.0_r8) * &
bfr_per_bleaf / EDPftvarcon_inst%root_long(ipft)
endif

currentCohort%leaf_cost = currentCohort%leaf_cost * &
(EDPftvarcon_inst%grperc(ipft) + 1._r8)
else !evergreen costs
currentCohort%leaf_cost = 1.0_r8/(EDPftvarcon_inst%slatop(ipft)* &
EDPftvarcon_inst%leaf_long(ipft)*1000.0_r8) !convert from sla in m2g-1 to m2kg-1
currentCohort%leaf_cost = currentCohort%leaf_cost + &
1.0_r8/(EDPftvarcon_inst%slatop(ipft)*1000.0_r8) * &
bfr_per_bleaf / EDPftvarcon_inst%root_long(ipft)
if ( int(EDPftvarcon_inst%allom_fmode(ipft)) .eq. 1 ) then
! if using trimmed leaf for fine root biomass allometry, add the cost of the root increment
! to the leaf increment; otherwise do not.
currentCohort%leaf_cost = currentCohort%leaf_cost + &
1.0_r8/(EDPftvarcon_inst%slatop(ipft)*1000.0_r8) * &
bfr_per_bleaf / EDPftvarcon_inst%root_long(ipft)
endif
currentCohort%leaf_cost = currentCohort%leaf_cost * &
(EDPftvarcon_inst%grperc(ipft) + 1._r8)
endif
Expand Down Expand Up @@ -875,15 +890,9 @@ subroutine PlantGrowth( currentSite, currentCohort, bc_in )
integer , parameter :: max_substeps = 300
real(r8), parameter :: max_trunc_error = 1.0_r8
integer, parameter :: ODESolve = 2 ! 1=RKF45, 2=Euler
real(r8), parameter :: global_branch_turnover = 0.0_r8 ! Temporary branch turnover setting
! Branch-turnover control will be
! introduced in a later PR


ipft = currentCohort%pft

EDPftvarcon_inst%branch_turnover(ipft) = global_branch_turnover

! Initialize seed production
currentCohort%seed_prod = 0.0_r8

Expand Down Expand Up @@ -976,35 +985,6 @@ subroutine PlantGrowth( currentSite, currentCohort, bc_in )
currentCohort%canopy_trim, currentCohort%dbh, currentCohort%hite )
end if

! -----------------------------------------------------------------------------------
! III(a). Calculate the maintenance turnover demands
! Pre-check, make sure phenology is mutually exclusive and at least one chosen
! (MOVE THIS TO THE PARAMETER READ-IN SECTION)
! -----------------------------------------------------------------------------------

if (EDPftvarcon_inst%evergreen(ipft) == 1) then
if (EDPftvarcon_inst%season_decid(ipft) == 1)then
write(fates_log(),*) 'PFT # ',ipft,' was specified as being both evergreen'
write(fates_log(),*) ' and seasonally deciduous, impossible, aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
if (EDPftvarcon_inst%stress_decid(ipft) == 1)then
write(fates_log(),*) 'PFT # ',ipft,' was specified as being both evergreen'
write(fates_log(),*) ' and stress deciduous, impossible, aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if
if (EDPftvarcon_inst%stress_decid(ipft) /= 1 .and. &
EDPftvarcon_inst%season_decid(ipft) /= 1 .and. &
EDPftvarcon_inst%evergreen(ipft) /= 1) then
write(fates_log(),*) 'PFT # ',ipft,' must be defined as having one of three'
write(fates_log(),*) 'phenology habits, ie == 1'
write(fates_log(),*) 'stress_decid: ',EDPftvarcon_inst%stress_decid(ipft)
write(fates_log(),*) 'season_decid: ',EDPftvarcon_inst%season_decid(ipft)
write(fates_log(),*) 'evergreen: ',EDPftvarcon_inst%evergreen(ipft)
call endrun(msg=errMsg(sourcefile, __LINE__))
endif


! -----------------------------------------------------------------------------------
! III(b). Calculate the maintenance turnover demands
Expand Down Expand Up @@ -1463,7 +1443,7 @@ function AllomCGrowthDeriv(c_pools,c_mask,cbalance,currentCohort) result(dCdx)
if (dbh <= EDPftvarcon_inst%dbh_repro_threshold(ipft)) then ! cap on leaf biomass
repro_fraction = EDPftvarcon_inst%seed_alloc(ipft)
else
repro_fraction = EDPftvarcon_inst%seed_alloc(ipft) + EDPftvarcon_inst%clone_alloc(ipft)
repro_fraction = EDPftvarcon_inst%seed_alloc(ipft) + EDPftvarcon_inst%seed_alloc_mature(ipft)
end if

dCdx = 0.0_r8
Expand Down Expand Up @@ -1681,11 +1661,12 @@ subroutine recruitment( currentSite, currentPatch, bc_in )

if (temp_cohort%n > 0.0_r8 )then
if ( DEBUG ) write(fates_log(),*) 'EDPhysiologyMod.F90 call create_cohort '
recruitstatus = 1
call create_cohort(currentPatch, temp_cohort%pft, temp_cohort%n, temp_cohort%hite, temp_cohort%dbh, &
b_leaf, b_fineroot, b_sapwood, temp_cohort%bdead, temp_cohort%bstore, &
temp_cohort%laimemory, cohortstatus, recruitstatus, temp_cohort%canopy_trim, currentPatch%NCL_p, &
bc_in)

call create_cohort(currentPatch, temp_cohort%pft, temp_cohort%n, temp_cohort%hite, temp_cohort%dbh, &
b_leaf, b_fineroot, b_sapwood, temp_cohort%bdead, temp_cohort%bstore, &
temp_cohort%laimemory, cohortstatus, temp_cohort%canopy_trim, currentPatch%NCL_p, &
currentSite%spread, bc_in)


! keep track of how many individuals were recruited for passing to history
currentSite%recruitment_rate(ft) = currentSite%recruitment_rate(ft) + temp_cohort%n
Expand Down
Loading

0 comments on commit a594790

Please sign in to comment.