Skip to content

Commit

Permalink
Merge master, commit '0ea3fed', into andre-ed-params
Browse files Browse the repository at this point in the history
Testing:

  Test suite: ed - yellowstone gnu, intel, pgi
                   hobart nag
  Test baseline: 0ea3fed
  Test namelist changes: addition of fates_paramfile
  Test answer changes: bit for bit
  Test status: all tests pass

  Test suite: clm_short - yellowstone gnu, intel, pgi
  Test baseline: clm4_5_12_r195
  Test namelist changes: none
  Test answer changes: bit for bit
  Test status: all tests pass
  • Loading branch information
bandre-ucar committed Mar 15, 2017
2 parents 7afeecc + 0ea3fed commit 1992685
Show file tree
Hide file tree
Showing 28 changed files with 1,977 additions and 1,051 deletions.
118 changes: 75 additions & 43 deletions components/clm/src/ED/biogeochem/EDCanopyStructureMod.F90

Large diffs are not rendered by default.

59 changes: 41 additions & 18 deletions components/clm/src/ED/biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ module EDCohortDynamicsMod
! Cohort stuctures in ED.
!
! !USES:
use abortutils , only : endrun
use FatesGlobals , only : endrun => fates_endrun
use FatesGlobals , only : fates_log
use FatesGlobals , only : freq_day
use FatesInterfaceMod , only : hlm_freq_day
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : fates_unset_int
use shr_log_mod , only : errMsg => shr_log_errMsg
use EDPftvarcon , only : EDPftvarcon_inst
use EDPftvarcon , only : EDPftvarcon_inst
use EDEcophysContype , only : EDecophyscon
use EDGrowthFunctionsMod , only : c_area, tree_lai
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type
use EDTypesMod , only : fusetol, cp_nclmax
use EDtypesMod , only : ncwd, maxcohortsperpatch
use EDtypesMod , only : sclass_ed,nlevsclass_ed,AREA
use EDtypesMod , only : min_npm2, min_nppatch, min_n_safemath
use EDTypesMod , only : fusetol
use EDTypesMod , only : nclmax
use EDTypesMod , only : ncwd
use EDTypesMod , only : maxCohortsPerPatch
use EDTypesMod , only : sclass_ed,nlevsclass_ed,AREA
use EDTypesMod , only : min_npm2, min_nppatch
use EDTypesMod , only : min_n_safemath
! CIME globals
use shr_log_mod , only : errMsg => shr_log_errMsg
!
implicit none
private
Expand Down Expand Up @@ -94,6 +98,7 @@ subroutine create_cohort(patchptr, pft, nn, hite, dbh, &
new_cohort%dbh = dbh
new_cohort%canopy_trim = ctrim
new_cohort%canopy_layer = clayer
new_cohort%canopy_layer_yesterday = real(clayer, r8)
new_cohort%laimemory = laimemory
new_cohort%bdead = bdead
new_cohort%balive = balive
Expand Down Expand Up @@ -223,7 +228,6 @@ subroutine allocate_live_biomass(cc_p,mode)
! Use different proportions if the leaves are on vs off
if(leaves_off_switch==0)then


new_bl = currentcohort%balive*leaf_frac

new_br = EDpftvarcon_inst%froot_leaf(ft) * (currentcohort%balive + currentcohort%laimemory) * leaf_frac
Expand All @@ -236,12 +240,12 @@ subroutine allocate_live_biomass(cc_p,mode)
if(mode==1)then

currentcohort%npp_leaf = currentcohort%npp_leaf + &
max(0.0_r8,new_bl - currentcohort%bl) / freq_day
max(0.0_r8,new_bl - currentcohort%bl) / hlm_freq_day

currentcohort%npp_froot = currentcohort%npp_froot + &
max(0._r8,new_br - currentcohort%br) / freq_day
max(0._r8,new_br - currentcohort%br) / hlm_freq_day

currentcohort%npp_bsw = max(0.0_r8, new_bsw - currentcohort%bsw)/freq_day
currentcohort%npp_bsw = max(0.0_r8, new_bsw - currentcohort%bsw)/hlm_freq_day

currentcohort%npp_bdead = currentCohort%dbdeaddt

Expand Down Expand Up @@ -273,9 +277,9 @@ subroutine allocate_live_biomass(cc_p,mode)
if(mode==1)then

currentcohort%npp_froot = currentcohort%npp_froot + &
max(0.0_r8,new_br-currentcohort%br)/freq_day
max(0.0_r8,new_br-currentcohort%br)/hlm_freq_day

currentcohort%npp_bsw = max(0.0_r8, new_bsw-currentcohort%bsw)/freq_day
currentcohort%npp_bsw = max(0.0_r8, new_bsw-currentcohort%bsw)/hlm_freq_day

currentcohort%npp_bdead = currentCohort%dbdeaddt

Expand Down Expand Up @@ -333,6 +337,7 @@ subroutine nan_cohort(cc_p)
currentCohort%pft = fates_unset_int ! pft number
currentCohort%indexnumber = fates_unset_int ! unique number for each cohort. (within clump?)
currentCohort%canopy_layer = fates_unset_int ! canopy status of cohort (1 = canopy, 2 = understorey, etc.)
currentCohort%canopy_layer_yesterday = nan ! recent canopy status of cohort (1 = canopy, 2 = understorey, etc.)
currentCohort%NV = fates_unset_int ! Number of leaf layers: -
currentCohort%status_coh = fates_unset_int ! growth status of plant (2 = leaves on , 1 = leaves off)
currentCohort%size_class = fates_unset_int ! size class index
Expand Down Expand Up @@ -479,7 +484,7 @@ subroutine zero_cohort(cc_p)
end subroutine zero_cohort

!-------------------------------------------------------------------------------------!
subroutine terminate_cohorts( patchptr )
subroutine terminate_cohorts( siteptr, patchptr )
!
! !DESCRIPTION:
! terminates cohorts when they get too small
Expand All @@ -489,6 +494,7 @@ subroutine terminate_cohorts( patchptr )
use SFParamsMod, only : SF_val_CWD_frac
!
! !ARGUMENTS
type (ed_site_type), intent(inout), target :: siteptr
type (ed_patch_type), intent(inout), target :: patchptr
!
! !LOCAL VARIABLES:
Expand All @@ -497,6 +503,7 @@ subroutine terminate_cohorts( patchptr )
type (ed_cohort_type) , pointer :: nextc
integer :: terminate ! do we terminate (1) or not (0)
integer :: c ! counter for litter size class.
integer :: levcan ! canopy level
!----------------------------------------------------------------------

currentPatch => patchptr
Expand Down Expand Up @@ -529,7 +536,7 @@ subroutine terminate_cohorts( patchptr )
endif

! In the third canopy layer
if (currentCohort%canopy_layer > cp_nclmax ) then
if (currentCohort%canopy_layer > nclmax ) then
terminate = 1
if ( DEBUG ) then
write(fates_log(),*) 'terminating cohorts 2', currentCohort%canopy_layer
Expand Down Expand Up @@ -558,6 +565,17 @@ subroutine terminate_cohorts( patchptr )
endif

if (terminate == 1) then
! preserve a record of the to-be-terminated cohort for mortality accounting
if (currentCohort%canopy_layer .eq. 1) then
levcan = 1
else
levcan = 2
endif
siteptr%terminated_nindivs(currentCohort%size_class,currentCohort%pft,levcan) = &
siteptr%terminated_nindivs(currentCohort%size_class,currentCohort%pft,levcan) + currentCohort%n
!
siteptr%termination_carbonflux(levcan) = siteptr%termination_carbonflux(levcan) + &
currentCohort%n * currentCohort%b
if (.not. associated(currentCohort%taller)) then
currentPatch%tallest => currentCohort%shorter
else
Expand Down Expand Up @@ -601,7 +619,7 @@ subroutine fuse_cohorts(patchptr)
! Join similar cohorts to reduce total number
!
! !USES:
use EDTypesMod , only : cp_nlevcan
use EDTypesMod , only : nlevcan
!
! !ARGUMENTS
type (ed_patch_type), intent(inout), target :: patchptr
Expand Down Expand Up @@ -753,7 +771,11 @@ subroutine fuse_cohorts(patchptr)
currentCohort%npp_bseed = (currentCohort%n*currentCohort%npp_bseed + nextc%n*nextc%npp_bseed)/newn
currentCohort%npp_store = (currentCohort%n*currentCohort%npp_store + nextc%n*nextc%npp_store)/newn

do i=1, cp_nlevcan
! recent canopy history
currentCohort%canopy_layer_yesterday = (currentCohort%n*currentCohort%canopy_layer_yesterday + &
nextc%n*nextc%canopy_layer_yesterday)/newn

do i=1, nlevcan
if (currentCohort%year_net_uptake(i) == 999._r8 .or. nextc%year_net_uptake(i) == 999._r8) then
currentCohort%year_net_uptake(i) = min(nextc%year_net_uptake(i),currentCohort%year_net_uptake(i))
else
Expand Down Expand Up @@ -1030,6 +1052,7 @@ subroutine copy_cohort( currentCohort,copyc )
n%gscan = o%gscan
n%leaf_cost = o%leaf_cost
n%canopy_layer = o%canopy_layer
n%canopy_layer_yesterday = o%canopy_layer_yesterday
n%nv = o%nv
n%status_coh = o%status_coh
n%canopy_trim = o%canopy_trim
Expand Down
16 changes: 8 additions & 8 deletions components/clm/src/ED/biogeochem/EDGrowthFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module EDGrowthFunctionsMod
! At present, there is only a single allocation trajectory.
! ============================================================================

use shr_kind_mod , only : r8 => shr_kind_r8
use FatesConstantsMod, only : r8 => fates_r8
use FatesGlobals , only : fates_log
use EDPftvarcon , only : EDPftvarcon_inst
use EDEcophysContype , only : EDecophyscon
use EDTypesMod , only : ed_cohort_type, cp_nlevcan, dinc_ed
use EDTypesMod , only : ed_cohort_type, nlevcan, dinc_ed

implicit none
private
Expand Down Expand Up @@ -159,10 +159,10 @@ real(r8) function tree_lai( cohort_in )
cohort_in%treelai = tree_lai

! here, if the LAI exceeeds the maximum size of the possible array, then we have no way of accomodating it
! at the moments cp_nlevcan default is 40, which is very large, so exceeding this would clearly illustrate a
! at the moments nlevcan default is 40, which is very large, so exceeding this would clearly illustrate a
! huge error
if(cohort_in%treelai > cp_nlevcan*dinc_ed)then
write(fates_log(),*) 'too much lai' , cohort_in%treelai , cohort_in%pft , cp_nlevcan * dinc_ed
if(cohort_in%treelai > nlevcan*dinc_ed)then
write(fates_log(),*) 'too much lai' , cohort_in%treelai , cohort_in%pft , nlevcan * dinc_ed
endif

return
Expand Down Expand Up @@ -196,10 +196,10 @@ real(r8) function tree_sai( cohort_in )
cohort_in%treesai = tree_sai

! here, if the LAI exceeeds the maximum size of the possible array, then we have no way of accomodating it
! at the moments cp_nlevcan default is 40, which is very large, so exceeding this would clearly illustrate a
! at the moments nlevcan default is 40, which is very large, so exceeding this would clearly illustrate a
! huge error
if(cohort_in%treesai > cp_nlevcan*dinc_ed)then
write(fates_log(),*) 'too much sai' , cohort_in%treesai , cohort_in%pft , cp_nlevcan * dinc_ed
if(cohort_in%treesai > nlevcan*dinc_ed)then
write(fates_log(),*) 'too much sai' , cohort_in%treesai , cohort_in%pft , nlevcan * dinc_ed
endif

return
Expand Down
Loading

0 comments on commit 1992685

Please sign in to comment.