Skip to content

Commit

Permalink
syntax fix for CanopyHydrologyMod
Browse files Browse the repository at this point in the history
  • Loading branch information
rfiorella committed May 9, 2024
1 parent 82ffcc7 commit 9cf511d
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions components/elm/src/biogeophys/CanopyHydrologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -801,20 +801,20 @@ subroutine FracH2OSfc(bounds, num_h2osfc, filter_h2osfc, &
real(r8):: min_h2osfc
!-----------------------------------------------------------------------

associate( &
micro_sigma => col_pp%micro_sigma , & ! Input: [real(r8) (:) ] microtopography pdf sigma (m)

iwp_microrel => col_pp%iwp_microrel , & ! Input: [real(r8) (:) ] ice wedge polygon microtopographic relief (m)
iwp_exclvol => col_pp%iwp_exclvol , & ! Input: [real(r8) (:) ] microtopography pdf sigma (m)
iwp_ddep => col_pp%iwp_ddep , & ! Input: [real(r8) (:) ] microtopography pdf sigma (m)
h2osno => col_ws%h2osno , & ! Input: [real(r8) (:) ] snow water (mm H2O)
h2osoi_liq => col_ws%h2osoi_liq , & ! Output: [real(r8) (:,:) ] liquid water (col,lyr) [kg/m2]
h2osfc => col_ws%h2osfc , & ! Output: [real(r8) (:) ] surface water (mm)
frac_sno => col_ws%frac_sno , & ! Output: [real(r8) (:) ] fraction of ground covered by snow (0 to 1)
frac_sno_eff => col_ws%frac_sno_eff , & ! Output: [real(r8) (:) ] eff. fraction of ground covered by snow (0 to 1)
frac_h2osfc => col_ws%frac_h2osfc , & ! Output: [real(r8) (:) ] col fractional area with surface water greater than zero
associate( &
micro_sigma => col_pp%micro_sigma , & ! Input: [real(r8) (:) ] microtopography pdf sigma (m)

iwp_microrel => col_pp%iwp_microrel , & ! Input: [real(r8) (:) ] ice wedge polygon microtopographic relief (m)
iwp_exclvol => col_pp%iwp_exclvol , & ! Input: [real(r8) (:) ] microtopography pdf sigma (m)
iwp_ddep => col_pp%iwp_ddep , & ! Input: [real(r8) (:) ] microtopography pdf sigma (m)

h2osno => col_ws%h2osno , & ! Input: [real(r8) (:) ] snow water (mm H2O)

h2osoi_liq => col_ws%h2osoi_liq , & ! Output: [real(r8) (:,:) ] liquid water (col,lyr) [kg/m2]
h2osfc => col_ws%h2osfc , & ! Output: [real(r8) (:) ] surface water (mm)
frac_sno => col_ws%frac_sno , & ! Output: [real(r8) (:) ] fraction of ground covered by snow (0 to 1)
frac_sno_eff => col_ws%frac_sno_eff , & ! Output: [real(r8) (:) ] eff. fraction of ground covered by snow (0 to 1)
frac_h2osfc => col_ws%frac_h2osfc , & ! Output: [real(r8) (:) ] col fractional area with surface water greater than zero
frac_h2osfc_act => col_ws%frac_h2osfc_act & ! Output: [real(r8) (:) ] col fractional area with surface water greater than zero
)

Expand All @@ -829,19 +829,19 @@ subroutine FracH2OSfc(bounds, num_h2osfc, filter_h2osfc, &
if (lun_pp%itype(l) == istsoil .or. lun_pp%itype(l) == istcrop) then

! Use newton-raphson method to iteratively determine frac_h20sfc
! based on amount of surface water storage (h2osfc) and
! based on amount of surface water storage (h2osfc) and
! microtopography variability (micro_sigma) if nonpolygonal, or
! amount of surface water (h2osfc) and microtopographic attributes
! (iwp_microrel, iwp_exclvol) if polygonal tundra

if (h2osfc(c) > min_h2osfc) then
! a cutoff is needed for numerical reasons...(nonconvergence after 5 iterations)
if lun_pp%ispolygon(l) then

if (lun_pp%ispolygon(l)) then
! calculate water depth and inundation fraction if column is polygonal
swc = h2osfc(c)/1000 ! convert to m
if swc > iwp_microrel - iwp_exclvol then

if (swc > iwp_microrel - iwp_exclvol) then
d = swc + iwp_exclvol
else
d = 0.0
Expand All @@ -857,11 +857,9 @@ subroutine FracH2OSfc(bounds, num_h2osfc, filter_h2osfc, &

!-- update the submerged areal fraction using the new d value
frac_h2osfc(c) = (3_r8/iwp_microrel) * (2_r8*iwp_exclvol - iwp_microrel) * (d/iwp_microrel)**2_r8 &
+ (2_r8/iwp_microrel) * (2_r8*iwp_microrel - 3_r8*iwp_exclvol) * (d/iwp_microrel)
endif

else
! calculate water depth and inudation fraction if column is non-polygonal
+ (2_r8/iwp_microrel) * (2_r8*iwp_microrel - 3_r8*iwp_exclvol) * (d/iwp_microrel)

else ! calculate water depth and inudation fraction if column is non-polygonal
d=0.0
sigma=1.0e3 * micro_sigma(c) ! convert to mm
do k=1,10
Expand All @@ -874,9 +872,8 @@ subroutine FracH2OSfc(bounds, num_h2osfc, filter_h2osfc, &
enddo
!-- update the submerged areal fraction using the new d value
frac_h2osfc(c) = 0.5*(1.0_r8+erf(d/(sigma*sqrt(2.0))))
endif

else
endif ! end if polygonal test
else ! if h2osfc(c) <= min_h2osfc
frac_h2osfc(c) = 0._r8
h2osoi_liq(c,1) = h2osoi_liq(c,1) + h2osfc(c)
qflx_h2osfc2topsoi(c) = h2osfc(c)/dtime
Expand All @@ -899,7 +896,6 @@ subroutine FracH2OSfc(bounds, num_h2osfc, filter_h2osfc, &
frac_sno_eff(c)=frac_sno(c)

endif

endif ! end of no_update construct

else !if landunit not istsoil/istcrop, set frac_h2osfc to zero
Expand Down

0 comments on commit 9cf511d

Please sign in to comment.