Skip to content

Commit

Permalink
Merge pull request #451 from andywood/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
arbennett authored Mar 2, 2021
2 parents f75949b + 8437cb0 commit a165ac7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
32 changes: 23 additions & 9 deletions build/source/engine/updatState.f90
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ subroutine updateSnow(&
USE snow_utils_module,only:fracliquid ! compute volumetric fraction of liquid water
implicit none
! input variables
real(dp),intent(in) :: mLayerTemp ! temperature (K)
real(dp),intent(in) :: mLayerTheta ! volume fraction of total water (-)
real(dp),intent(in) :: snowfrz_scale ! scaling parameter for the snow freezing curve (K-1)
real(dp),intent(in) :: mLayerTemp ! temperature (K)
real(dp),intent(in) :: mLayerTheta ! volume fraction of total water (-)
real(dp),intent(in) :: snowfrz_scale ! scaling parameter for the snow freezing curve (K-1)
! output variables
real(dp),intent(out) :: mLayerVolFracLiq ! volumetric fraction of liquid water (-)
real(dp),intent(out) :: mLayerVolFracIce ! volumetric fraction of ice (-)
real(dp),intent(out) :: fLiq ! fraction of liquid water (-)
real(dp),intent(out) :: mLayerVolFracLiq ! volumetric fraction of liquid water (-)
real(dp),intent(out) :: mLayerVolFracIce ! volumetric fraction of ice (-)
real(dp),intent(out) :: fLiq ! fraction of liquid water (-)
! error control
integer(i4b),intent(out) :: err ! error code
character(*),intent(out) :: message ! error message
integer(i4b),intent(out) :: err ! error code
character(*),intent(out) :: message ! error message

! initialize error control
err=0; message="updateSnow/"

Expand Down Expand Up @@ -115,12 +116,25 @@ subroutine updateSoil(&
real(dp) :: TcSoil ! critical soil temperature when all water is unfrozen (K)
real(dp) :: xConst ! constant in the freezing curve function (m K-1)
real(dp) :: mLayerPsiLiq ! liquid water matric potential (m)
real(dp),parameter :: tinyVal=epsilon(1._dp) ! used in balance check

! initialize error control
err=0; message="updateSoil/"

! compute fractional **volume** of total water (liquid plus ice)
mLayerVolFracWat = volFracLiq(mLayerMatricHead,vGn_alpha,theta_res,theta_sat,vGn_n,vGn_m)
if(mLayerVolFracWat > theta_sat)then; err=20; message=trim(message)//'volume of liquid and ice exceeds porosity'; return; end if
if(mLayerVolFracWat > (theta_sat + tinyVal)) then
err=20
message=trim(message)//'volume of liquid and ice (mLayerVolFracWat) exceeds porosity'
print*, 'mLayerVolFracWat = ', mLayerVolFracWat
print*, 'theta_sat (porosity) = ', theta_sat
print*, 'mLayerMatricHead = ', mLayerMatricHead
print*, 'theta_res = ', theta_res
print*, 'vGn_alpha = ', vGn_alpha
print*, 'vGn_n = ', vGn_n
print*, 'vGn_m = ', vGn_m
return
end if

! compute the critical soil temperature where all water is unfrozen (K)
! (eq 17 in Dall'Amico 2011)
Expand Down
2 changes: 1 addition & 1 deletion docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ This page provides simple, high-level documentation about what has changed in ea
- Fixes a segfault of mysterious origin when using JRDN snow layering
- Fixes a water balance error w.r.t transpiration
- Fixes the output message to report the correct solution type

- Adds tolerance to balance check in updatState.f90

0 comments on commit a165ac7

Please sign in to comment.