Skip to content

Commit

Permalink
Merge pull request ESCOMP#405 from rgknox/rgknox-fates-protectbaresoi…
Browse files Browse the repository at this point in the history
…lfrac

Protected fates calculation of bare-soil area to not go below 0
  • Loading branch information
rgknox authored Jul 9, 2018
2 parents f6452af + bc2127c commit 7ec0960
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,15 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, &
! Set the bareground patch indicator
patch%is_bareground(col%patchi(c)) = .true.
npatch = this%fates(nc)%sites(s)%youngest_patch%patchno
patch%wt_ed(col%patchi(c)) = 1.0_r8-sum(this%fates(nc)%bc_out(s)%canopy_fraction_pa(1:npatch))

! Precision errors on the canopy_fraction_pa sum, even small (e-12)
! do exist, and can create potentially negetive bare-soil fractions
! (ie -1e-12 or smaller). Even though this is effectively zero,
! it can generate weird logic scenarios in the ctsm/elm code, so we
! protext it here with a lower bound of 0.0_r8.

patch%wt_ed(col%patchi(c)) = max(0.0_r8, &
1.0_r8-sum(this%fates(nc)%bc_out(s)%canopy_fraction_pa(1:npatch)))

if(sum(this%fates(nc)%bc_out(s)%canopy_fraction_pa(1:npatch))>1.0_r8)then
write(iulog,*)'Projected Canopy Area of all FATES patches'
Expand Down

0 comments on commit 7ec0960

Please sign in to comment.