diff --git a/biogeochem/EDCanopyStructureMod.F90 b/biogeochem/EDCanopyStructureMod.F90 index e859a7339f..22951fcf9f 100644 --- a/biogeochem/EDCanopyStructureMod.F90 +++ b/biogeochem/EDCanopyStructureMod.F90 @@ -2245,7 +2245,7 @@ subroutine UpdateCohortLAI(currentCohort, canopy_layer_tlai, total_canopy_area) ! Update LAI and related variables for a given cohort ! Uses - use EDParamsMod, only : dlower_vai + use EDParamsMod, only : dlower_vai, dinc_vai ! Arguments type(fates_cohort_type),intent(inout), target :: currentCohort @@ -2272,6 +2272,12 @@ subroutine UpdateCohortLAI(currentCohort, canopy_layer_tlai, total_canopy_area) currentCohort%vcmax25top,4) end if + ! cap leaf allometries that are larger than the allowable array space. + if( (currentCohort%treelai + currentCohort%treesai) > (sum(dinc_vai)) )then + currentCohort%treelai = sum(dinc_vai) * (1._r8 - prt_params%allom_sai_scaler(currentCohort%pft)) + currentCohort%treesai = sum(dinc_vai) * prt_params%allom_sai_scaler(currentCohort%pft) + endif + ! Number of actual vegetation layers in this cohort's crown currentCohort%nv = count((currentCohort%treelai+currentCohort%treesai) .gt. dlower_vai(:)) + 1 diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index dddfd83113..053f6f7064 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -720,6 +720,12 @@ subroutine trim_canopy( currentSite ) currentPatch%canopy_layer_tlai, currentCohort%treelai, & currentCohort%vcmax25top,0 ) + ! cap leaf allometries that are larger than the allowable array space. + if( (currentCohort%treelai + currentCohort%treesai) > (sum(dinc_vai)) )then + currentCohort%treelai = sum(dinc_vai) * (1._r8 - prt_params%allom_sai_scaler(currentCohort%pft)) + currentCohort%treesai = sum(dinc_vai) * prt_params%allom_sai_scaler(currentCohort%pft) + endif + currentCohort%nv = count((currentCohort%treelai+currentCohort%treesai) .gt. dlower_vai(:)) + 1 if (currentCohort%nv > nlevleaf)then diff --git a/biogeochem/FatesAllometryMod.F90 b/biogeochem/FatesAllometryMod.F90 index 3cf1ab36a4..c2a35fd948 100644 --- a/biogeochem/FatesAllometryMod.F90 +++ b/biogeochem/FatesAllometryMod.F90 @@ -829,29 +829,33 @@ real(r8) function tree_sai(pft, dbh, crowndamage, canopy_trim, elongf_stem, c_ar if( (treelai + tree_sai) > (sum(dinc_vai)) )then - call h_allom(dbh,pft,h) - - write(fates_log(),*) 'The leaf and stem are predicted for a cohort, maxed out the array size' - write(fates_log(),*) 'lai: ',treelai - write(fates_log(),*) 'sai: ',tree_sai - write(fates_log(),*) 'lai+sai: ',treelai+tree_sai - write(fates_log(),*) 'target_bleaf: ', target_bleaf - write(fates_log(),*) 'area: ', c_area - write(fates_log(),*) 'target_lai: ',target_lai - write(fates_log(),*) 'dinc_vai:',dinc_vai - write(fates_log(),*) 'nlevleaf,sum(dinc_vai):',nlevleaf,sum(dinc_vai) - write(fates_log(),*) 'pft: ',pft - write(fates_log(),*) 'call id: ',call_id - write(fates_log(),*) 'n: ',nplant - write(fates_log(),*) 'dbh: ',dbh,' dbh_max: ',prt_params%allom_dbh_maxheight(pft) - write(fates_log(),*) 'h: ',h - write(fates_log(),*) 'canopy_trim: ',canopy_trim - write(fates_log(),*) 'canopy layer: ',cl - write(fates_log(),*) 'canopy_tlai: ',canopy_lai(:) - write(fates_log(),*) 'vcmax25top: ',vcmax25top - call endrun(msg=errMsg(sourcefile, __LINE__)) + ! output warning message. use a separate warning index for each PFT that encounters this error. + warn_msg = 'Lai+sai for cohort maxed out the array size. lai, sai, pft, dbh: '//trim(N2S(treelai))// & + ', '//trim(N2S(tree_sai))//', '//trim(I2S(pft))//', '//trim(N2S(dbh)) + call FatesWarn(warn_msg,index=100+pft) + + ! old error message below. + ! call h_allom(dbh,pft,h) + ! write(fates_log(),*) 'lai: ',treelai + ! write(fates_log(),*) 'sai: ',tree_sai + ! write(fates_log(),*) 'lai+sai: ',treelai+tree_sai + ! write(fates_log(),*) 'target_bleaf: ', target_bleaf + ! write(fates_log(),*) 'area: ', c_area + ! write(fates_log(),*) 'target_lai: ',target_lai + ! write(fates_log(),*) 'dinc_vai:',dinc_vai + ! write(fates_log(),*) 'nlevleaf,sum(dinc_vai):',nlevleaf,sum(dinc_vai) + ! write(fates_log(),*) 'pft: ',pft + ! write(fates_log(),*) 'call id: ',call_id + ! write(fates_log(),*) 'n: ',nplant + ! write(fates_log(),*) 'dbh: ',dbh,' dbh_max: ',prt_params%allom_dbh_maxheight(pft) + ! write(fates_log(),*) 'h: ',h + ! write(fates_log(),*) 'canopy_trim: ',canopy_trim + ! write(fates_log(),*) 'canopy layer: ',cl + ! write(fates_log(),*) 'canopy_tlai: ',canopy_lai(:) + ! write(fates_log(),*) 'vcmax25top: ',vcmax25top + ! call endrun(msg=errMsg(sourcefile, __LINE__)) end if - + return