Skip to content

Commit ef056b4

Browse files
committed
Replaced some magic numbers with local and global constants, following @bishtgautam's suggestions.
1 parent 8c92820 commit ef056b4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

components/elm/src/biogeophys/CanopyFluxesMod.F90

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module CanopyFluxesMod
1717
use elm_varctl , only : use_hydrstress
1818
use elm_varpar , only : nlevgrnd, nlevsno
1919
use elm_varcon , only : namep
20+
use elm_varcon , only : mm_epsilon
21+
use elm_varcon , only : pa_to_kpa
2022
use pftvarcon , only : crop, nfixer
2123
use decompMod , only : bounds_type
2224
use PhotosynthesisMod , only : Photosynthesis, PhotosynthesisTotal, Fractionation, PhotoSynthesisHydraulicStress
@@ -318,6 +320,9 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, &
318320
! Indices for raw and rah
319321
integer, parameter :: above_canopy = 1 ! Above canopy
320322
integer, parameter :: below_canopy = 2 ! Below canopy
323+
324+
! Lower bound for VPD (based on CLM)
325+
real(r8), parameter :: vpd_min = 50._r8
321326
!------------------------------------------------------------------------------
322327

323328
associate( &
@@ -863,15 +868,15 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, &
863868
! Done each iteration to account for differences in eah, tv.
864869

865870
svpts(p) = el(p) ! Pa
866-
eah(p) = forc_pbot(t) * qaf(p) / 0.622_r8 ! Pa
871+
eah(p) = forc_pbot(t) * qaf(p) / mm_epsilon ! Pa
867872
rhaf(p) = eah(p)/svpts(p)
868873

869874
! variables for history fields
870875
rah_above(p) = rah(p,above_canopy)
871876
raw_above(p) = raw(p,above_canopy)
872877
rah_below(p) = rah(p,below_canopy)
873878
raw_below(p) = raw(p,below_canopy)
874-
vpd(p) = max((svpts(p) - eah(p)), 50._r8) * 0.001_r8 ! kPa
879+
vpd(p) = max((svpts(p) - eah(p)), vpd_min) * pa_to_kpa ! kPa
875880
end do
876881

877882
! Modification for shrubs proposed by X.D.Z

components/elm/src/main/elm_varcon.F90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ module elm_varcon
7272
real(r8) :: tlsai_crit = 2.0_r8 ! critical value of elai+esai for which aerodynamic parameters are maximum
7373
real(r8) :: watmin = 0.01_r8 ! minimum soil moisture (mm)
7474

75+
real(r8), parameter :: mm_epsilon = 0.622_r8 ! Molar mass ratio (water:dry air)
76+
! This is set to 0.622 for bit-for-bit compatibility, but
77+
! this should be defined as SHR_CONST_MWWV/SHR_CONST_MWDAIR
78+
7579
real(r8) :: re = SHR_CONST_REARTH*0.001_r8 ! radius of earth (km)
7680

7781
real(r8), public, parameter :: degpsec = 15._r8/3600.0_r8 ! Degree's earth rotates per second
@@ -81,6 +85,13 @@ module elm_varcon
8185
integer , public, parameter :: ispval = -9999 ! special value for int data
8286
! (keep this negative to avoid conflicts with possible valid values)
8387

88+
89+
!------------------------------------------------------------------
90+
! Unit conversion constants
91+
!------------------------------------------------------------------
92+
93+
real(r8), parameter :: pa_to_kpa = 0.001_r8 ! Conversion factor (Pa to kPa) [kPa/Pa]
94+
8495
! These are tunable constants from clm2_3
8596

8697
real(r8) :: zlnd = 0.01_r8 ! Roughness length for soil [m]

0 commit comments

Comments
 (0)