Skip to content

Commit

Permalink
Avoid divide by zero
Browse files Browse the repository at this point in the history
This should only affect tests with the oldhyd test mod. However, it is
needed in order for these tests to pass:

ERP_D_Ld5.f10_f10_musgs.I2000Clm50BgcCrop.yellowstone_intel.clm-allActive
ERP_D_P15x2_Ld3.f10_f10_musgs.I2000Clm50BgcCrop.yellowstone_intel.clm-cropColdStart
ERP_P180x2_D_Ld5.f19_g17.I2000Clm50BgcDvCrop.yellowstone_pgi.clm-crop
ERP_D_Ld5.f10_f10_musgs.I2000Clm50BgcCrop.cheyenne_intel.clm-allActive
ERP_D_P15x2_Ld3.f10_f10_musgs.I2000Clm50BgcCrop.cheyenne_intel.clm-cropColdStart
  • Loading branch information
billsacks committed Dec 28, 2017
1 parent 182b2c1 commit e44881c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/biogeophys/SoilHydrologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ subroutine SetSoilWaterFractions(bounds, num_hydrologyc, filter_hydrologyc, &

! fracice is only used in code with origflag == 1. For this calculation, we use
! the version of icefrac that was used in this original hydrology code.
icefrac_orig = min(1._r8,h2osoi_ice(c,j)/(h2osoi_ice(c,j)+h2osoi_liq(c,j)))
if (h2osoi_ice(c,j) == 0._r8) then
! Avoid possible divide by zero (in case h2osoi_liq(c,j) is also 0)
icefrac_orig = 0._r8
else
icefrac_orig = min(1._r8,h2osoi_ice(c,j)/(h2osoi_ice(c,j)+h2osoi_liq(c,j)))
end if
fracice(c,j) = max(0._r8,exp(-3._r8*(1._r8-icefrac_orig))- exp(-3._r8))/(1.0_r8-exp(-3._r8))
end do
end do
Expand Down

0 comments on commit e44881c

Please sign in to comment.