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

Commit

Permalink
Updated some comments, added back protections on patch canopy areas e…
Browse files Browse the repository at this point in the history
…xceeding 1 during the output boundary condition preparations.
  • Loading branch information
rgknox committed Jun 6, 2018
1 parent c357399 commit 658064e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
16 changes: 10 additions & 6 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)
! !LOCAL VARIABLES:
type(ed_cohort_type), pointer :: currentCohort,copyc
integer :: i_cwd ! Index for CWD pool
real(r8) :: cc_loss
real(r8) :: cc_loss ! cohort crown area loss in demotion (m2)
real(r8) :: lossarea
real(r8) :: newarea
real(r8) :: demote_area
Expand Down Expand Up @@ -638,7 +638,7 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
integer :: exceedance_counter
real(r8) :: remainder_area
real(r8) :: remainder_area_hold
real(r8) :: cc_gain
real(r8) :: cc_gain ! cohort crown area gain in promotion (m2)
real(r8) :: arealayer_current ! area (m2) of the current canopy layer
real(r8) :: arealayer_below ! area (m2) of the layer below the current layer

Expand Down Expand Up @@ -1628,9 +1628,11 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
! currentPatch%total_canopy_area/currentPatch%area is fraction of this patch cover by plants
! currentPatch%area/AREA is the fraction of the soil covered by this patch.

bc_out(s)%canopy_fraction_pa(ifp) = currentPatch%total_canopy_area/AREA
bc_out(s)%canopy_fraction_pa(ifp) = &
min(1.0_r8,currentPatch%total_canopy_area/currentPatch%area)*(currentPatch%area/AREA)

bare_frac_area = (1.0_r8-currentPatch%total_canopy_area/currentPatch%area)*(currentPatch%area/AREA)
bare_frac_area = (1.0_r8 - min(1.0_r8,currentPatch%total_canopy_area/currentPatch%area)) * &
(currentPatch%area/AREA)

total_patch_area = total_patch_area + bc_out(s)%canopy_fraction_pa(ifp) + bare_frac_area

Expand Down Expand Up @@ -1674,8 +1676,10 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

write(fates_log(),*) 'imprecise patch areas in update_hlm_dynamics',total_patch_area

if(DEBUG) then
write(fates_log(),*) 'imprecise patch areas in update_hlm_dynamics',total_patch_area
end if

currentPatch => sites(s)%oldest_patch
ifp = 0
do while(associated(currentPatch))
Expand Down
8 changes: 7 additions & 1 deletion biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module EDPatchDynamicsMod
use FatesConstantsMod , only : ha_per_m2
use FatesConstantsMod , only : days_per_sec
use FatesConstantsMod , only : years_per_day
use FatesConstantsMod , only : nearzero


! CIME globals
Expand Down Expand Up @@ -730,9 +731,14 @@ subroutine check_patch_area( currentSite )

if ( abs(areatot-area) > area_error_fail ) then
write(fates_log(),*) 'Patch areas do not sum to 10000 within tolerance'
write(fates_log(),*) 'Total area: ': areatot,'absolute error: ',areatot-area
write(fates_log(),*) 'Total area: ',areatot,'absolute error: ',areatot-area
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

if(debug) then
write(fates_log(),*) 'Total patch area precision being fixed, adjusting'
write(fates_log(),*) 'largest patch. This may have slight impacts on carbon balance.'
end if

largestPatch%area = largestPatch%area + (area-areatot)

Expand Down

0 comments on commit 658064e

Please sign in to comment.