Skip to content

Commit

Permalink
tweak: change additional variables related to reference et to c_double
Browse files Browse the repository at this point in the history
  • Loading branch information
smwesten-usgs committed Jan 12, 2024
1 parent 2d253a4 commit 6a69fa1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/actual_et__thornthwaite_mather.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ elemental subroutine calculate_actual_et_thornthwaite_mather(
actual_et = soil_storage - soil_storage_temp

else
! open water - limit actual et to the lesser of the reference ET *or* the amount of water 'infiltrated'

actual_et = infiltration
actual_et = min(real(infiltration, c_double), real(crop_etc, c_double))

endif

Expand Down
6 changes: 3 additions & 3 deletions src/constants_and_conversions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module constants_and_conversions

! [ common mathematical constants ]
public :: PI, TWOPI, HALFPI
real (c_double), parameter :: PI = 3.1415926535897932384626433_c_double
real (c_double), parameter :: TWOPI = 3.1415926535897932384626433_c_double * 2.0_c_double
real (c_double), parameter :: HALFPI = 3.1415926535897932384626433_c_double / 2.0_c_double
real (c_double), parameter :: PI = 4.0_c_double*atan(1.0_c_double)
real (c_double), parameter :: TWOPI = PI * 2.0_c_double
real (c_double), parameter :: HALFPI = PI / 2.0_c_double

! [ trig conversion factors ]
public :: DEGREES_TO_RADIANS, RADIANS_TO_DEGREES
Expand Down
20 changes: 6 additions & 14 deletions src/et__hargreaves_samani.F90
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ end subroutine et_hargreaves_initialize

!------------------------------------------------------------------------------

elemental function et_hargreaves_calculate( iDayOfYear, iNumDaysInYear, fLatitude, fTMin, fTMax ) result(fReferenceET0)
impure elemental function et_hargreaves_calculate( iDayOfYear, iNumDaysInYear, fLatitude, fTMin, fTMax ) result(fReferenceET0)
!! Computes the potential ET for each cell, based on TMIN and TMAX.
!! Stores cell-by-cell PET values in the model grid.

Expand All @@ -122,7 +122,7 @@ elemental function et_hargreaves_calculate( iDayOfYear, iNumDaysInYear, fLatitud
real (c_float), intent(in) :: fLatitude
real (c_float), intent(in) :: fTMin
real (c_float), intent(in) :: fTMax
real (c_float) :: fReferenceET0
real (c_double) :: fReferenceET0

! [ LOCALS ]
real (c_double) :: fDelta, fOmega_s, fD_r, fRa
Expand All @@ -131,7 +131,7 @@ elemental function et_hargreaves_calculate( iDayOfYear, iNumDaysInYear, fLatitud
dLatitude_radians = fLatitude * DEGREES_TO_RADIANS

fD_r =relative_earth_sun_distance__D_r(iDayOfYear,iNumDaysInYear)
fDelta = solar_declination_simple__delta(iDayOfYear, iNumDaysInYear)
fDelta = solar_declination__delta(iDayOfYear, iNumDaysInYear)

fOmega_s = sunrise_sunset_angle__omega_s(dLatitude_radians, fDelta)

Expand All @@ -141,7 +141,7 @@ elemental function et_hargreaves_calculate( iDayOfYear, iNumDaysInYear, fLatitud
fRa = extraterrestrial_radiation__Ra(dLatitude_radians, fDelta, fOmega_s, fD_r)

fReferenceET0 = ET0_hargreaves( equivalent_evaporation(fRa), fTMin, fTMax)

end function et_hargreaves_calculate


Expand All @@ -153,28 +153,20 @@ elemental function ET0_hargreaves( rRa, rTMinF, rTMaxF ) result(rET_0)
real (c_float),intent(in) :: rTMaxF

! [ RETURN VALUE ]
real (c_float) :: rET_0
real (c_double) :: rET_0

! [ LOCALS ]
real (c_double) :: rTDelta
real (c_double) :: rTAvg

rTAvg = (rTMinF + rTMaxF) / 2.0_c_double

rTDelta = F_to_K(rTMaxF) - F_to_K(rTMinF)
rTDelta = F_to_K(real(rTMaxF, c_double)) - F_to_K(real(rTMinF, c_double))

rET_0 = MAX(rZERO, &
mm_to_in( ET_SLOPE * rRa * (F_to_C(rTavg) + ET_CONSTANT) * (rTDelta**ET_EXPONENT) ) )
! mm_to_in( 0.0023_c_float * rRa * (F_to_C(rTavg) + 17.8_c_float) * sqrt(rTDelta)) )


! rET_0 = MAX(rZERO, &
! ( fET_Slope &
! * rRa &
! * (F_to_C(rTavg) + pConfig%fET_Constant) &
! * (rTDelta**fET_Exponent)) &
! / rMM_PER_INCH)

end function ET0_hargreaves


Expand Down
2 changes: 1 addition & 1 deletion src/et__jensen_haise.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ elemental function et_jh_calculate( iDayOfYear, iNumDaysInYear, fLatitude, fTMin
real (c_float), intent(in), optional :: fAs
real (c_float), intent(in), optional :: fBs
real (c_float), intent(in), optional :: fSunPct
real (c_float) :: fReferenceET0
real (c_double) :: fReferenceET0

! [ LOCALS ]
real (c_double) :: dRa
Expand Down
4 changes: 2 additions & 2 deletions src/solar_calculations.F90
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ elemental function relative_earth_sun_distance__D_r( iDayOfYear, iNumDaysInYear
integer (c_int), intent(in) :: iNumDaysInYear
real (c_double) :: dDsubR

dDsubR = 1_c_double + 0.033_c_double &
* cos( TWOPI * real( iDayOfYear, c_double ) &
dDsubR = 1.0_c_double + 0.033_c_double &
* cos( TWOPI * real( iDayOfYear, c_double ) &
/ real( iNumDaysInYear, c_double ) )

end function relative_earth_sun_distance__D_r
Expand Down

0 comments on commit 6a69fa1

Please sign in to comment.