Commit 52cf5081 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.6.3.69 style: clean frun_etp_oudin Fortran subroutine

- format header
- change variable names
- indent code
- manage consistent types (integer, real, double)
Refs #62
Showing with 90 additions and 42 deletions
+90 -42
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.3.68 Version: 1.6.3.69
Date: 2020-11-23 Date: 2020-11-23
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
### 1.6.3.68 Release Notes (2020-11-23) ### 1.6.3.69 Release Notes (2020-11-23)
#### New features #### New features
......
!------------------------------------------------------------------------------
! Subroutines relative to the Oudin potential evapotranspiration (PE) formula
!------------------------------------------------------------------------------
! TITLE : airGR
! PROJECT : airGR
! FILE : frun_ETP.f90
!------------------------------------------------------------------------------
! AUTHORS
! Original code: L. Oudin
! Cleaning and formatting for airGR: Fr. Bourgin
! Further cleaning: O. Delaigue, G. Thirel
!------------------------------------------------------------------------------
! Creation date: 2004
! Last modified: 20/10/2020
!------------------------------------------------------------------------------
! REFERENCES
! Oudin, L., Hervieu, F., Michel, C., Perrin, C., Andréassian, V.,
! Anctil, F. and Loumagne, C., 2005. Which potential evapotranspiration
! input for a rainfall-runoff model? Part 2 - Towards a simple and
! efficient PE model for rainfall-runoff modelling. Journal of Hydrology
! 303(1-4), 290-306.
!------------------------------------------------------------------------------
! Quick description of public procedures:
! 1. frun_etp_oudin
! 2. PE_OUDIN
!------------------------------------------------------------------------------
!******************************************************************************* !*******************************************************************************
SUBROUTINE frun_etp_oudin(LInputs,InputsLAT,InputsTT,InputsJJ,OutputsETP) SUBROUTINE frun_etp_oudin(LInputs,InputsLAT,InputsTemp,InputsJJ,OutputsPE)
!******************************************************************************* !*******************************************************************************
! Subroutine that performs the call to the PE_OUDIN subroutine at each time step,
! and stores the final values
! Inputs
! LInputs ! Integer, length of input and output series
! InputsLAT ! Vector of real, input series of latitude [rad]
! InputsTemp ! Vector of real, input series of air mean temperature [degC]
! InputsJJ ! Vector of real, input series of Julian day [-]
! Outputs
! OutputsPE ! Vector of real, output series of potential evapotranspiration (PE) [mm/time step]
!DEC$ ATTRIBUTES DLLEXPORT :: frun_etp_oudin !DEC$ ATTRIBUTES DLLEXPORT :: frun_etp_oudin
...@@ -10,27 +49,27 @@ ...@@ -10,27 +49,27 @@
! in ! in
integer, intent(in) :: LInputs integer, intent(in) :: LInputs
doubleprecision, dimension(LInputs), intent(in) :: InputsLAT doubleprecision, dimension(LInputs), intent(in) :: InputsLAT
doubleprecision, dimension(LInputs), intent(in) :: InputsTT doubleprecision, dimension(LInputs), intent(in) :: InputsTemp
doubleprecision, dimension(LInputs), intent(in) :: InputsJJ doubleprecision, dimension(LInputs), intent(in) :: InputsJJ
! out ! out
doubleprecision, dimension(LInputs), intent(out) :: OutputsETP doubleprecision, dimension(LInputs), intent(out) :: OutputsPE
!! locals !! locals
integer :: k integer :: k
real :: FI, tt, jj, ETPoud doubleprecision :: FI, tt, jj, PEoud
!-------------------------------------------------------------- !--------------------------------------------------------------
! Time loop ! Time loop
!-------------------------------------------------------------- !--------------------------------------------------------------
DO k=1,LInputs DO k = 1, LInputs
tt = InputsTT(k) tt = InputsTemp(k)
jj = InputsJJ(k) jj = InputsJJ(k)
FI = InputsLAT(k) / 57.296 FI = InputsLAT(k)!
!model run on one time step !model run on one time step
CALL ETP_OUDIN(FI,tt,jj,ETPoud) CALL PE_OUDIN(FI, tt, jj, PEoud)
!storage of outputs !storage of outputs
OutputsETP(k) = ETPoud OutputsPE(k) = PEoud
ENDDO ENDDO
RETURN RETURN
...@@ -38,14 +77,22 @@ ...@@ -38,14 +77,22 @@
ENDSUBROUTINE ENDSUBROUTINE
!################################################################################################################################
!******************************************************************************* !*******************************************************************************
SUBROUTINE ETP_OUDIN(FI,DT,JD,DPE) SUBROUTINE PE_OUDIN(FI,DT,JD,DPE)
!******************************************************************************* !*******************************************************************************
! This subroutine calculates daily potential evapotranspiration (DPE) ! Calculation of potential evapotranspiration (DPE) on a single time step
! using daily temperature and daily extra-atmospheric global radiation ! using air temperature and daily extra-atmospheric global radiation
! (that depends only on Julian day) ! (that depends only on Julian day)
! !
! The PE formula is is that described in: ! The PE formula is described in:
! Oudin, L., Hervieu, F., Michel, C., Perrin, C., Andréassian, V., ! Oudin, L., Hervieu, F., Michel, C., Perrin, C., Andréassian, V.,
! Anctil, F. and Loumagne, C., 2005. Which potential evapotranspiration ! Anctil, F. and Loumagne, C., 2005. Which potential evapotranspiration
! input for a rainfall-runoff model? Part 2 - Towards a simple and ! input for a rainfall-runoff model? Part 2 - Towards a simple and
...@@ -58,67 +105,68 @@ ...@@ -58,67 +105,68 @@
! of hydrology. Journal of Hydrology 66 (1/4), 1-76. ! of hydrology. Journal of Hydrology 66 (1/4), 1-76.
! !
!*************************************************************** !***************************************************************
! Inputs: ! Inputs
! xLAT: Latitude in decimal degrees ! FI ! Latitude [rad]
! DT: Temperature in degree C ! DT ! Air Temperature [degC]
! JD: Julian day ! JD ! Julian day [-]
! !
! Output: ! Outputs
! DPE: Daily potential evapotranspiration in mm ! DPE ! Potential evapotranspiration [mm/time step]
!*************************************************************** !***************************************************************
IMPLICIT NONE IMPLICIT NONE
REAL :: xLAT, FI, COSFI, TETA, COSTETA, COSGZ, GZ, COSGZ2 !! dummies
REAL :: SINGZ, COSOM, COSOM2, SINOM, COSPZ, OM, GE ! in
REAL :: ETA, DPE, DT, JD, RD doubleprecision, intent(in) :: FI, DT, JD
! out
! DATA RD/57.296/ doubleprecision, intent(out) :: DPE
!! locals
doubleprecision :: COSFI, TETA, COSTETA, COSGZ, GZ, COSGZ2
doubleprecision :: SINGZ, COSOM, COSOM2, SINOM, COSPZ, OM, GE
doubleprecision :: ETA
! Calculation of extra-atmospheric global radiation (Appendix C in Morton ! Calculation of extra-atmospheric global radiation (Appendix C in Morton
! (1983), Eq. C-6 to C-11, p.60-61) ! (1983), Eq. C-6 to C-11, p.60-61)
! Converts latitude in radians
! FI=xLAT/RD
COSFI=COS(FI) COSFI=COS(FI)
! AFI=ABS(xLAT/42.)
! TETA: Declination of the sun in radians ! TETA: Declination of the sun in radians
TETA=0.4093*SIN(JD/58.1-1.405) TETA=0.4093*SIN(JD/58.1-1.405)
COSTETA=COS(TETA) COSTETA=COS(TETA)
COSGZ=MAX(0.001,COS(FI-TETA)) COSGZ=MAX(0.001d0,COS(FI-TETA))
! GZ: Noon angular zenith distance of the sun ! GZ: Noon angular zenith distance of the sun
GZ=ACOS(COSGZ) GZ=ACOS(COSGZ)
COSGZ2=COSGZ*COSGZ COSGZ2=COSGZ*COSGZ
IF(COSGZ2.GE.1.)THEN IF(COSGZ2.GE.1.) THEN
SINGZ=0. SINGZ=0.
ELSE ELSE
SINGZ=SQRT(1.-COSGZ2) SINGZ=SQRT(1.-COSGZ2)
ENDIF ENDIF
COSOM=1.-COSGZ/COSFI/COSTETA COSOM=1.-COSGZ/COSFI/COSTETA
IF(COSOM.LT.-1.)COSOM=-1. IF(COSOM.LT.-1.) COSOM=-1.
IF(COSOM.GT.1.)COSOM=1. IF(COSOM.GT.1.) COSOM=1.
COSOM2=COSOM*COSOM COSOM2=COSOM*COSOM
IF(COSOM2.GE.1.)THEN IF(COSOM2.GE.1.) THEN
SINOM=0. SINOM=0.
ELSE ELSE
SINOM=SQRT(1.-COSOM2) SINOM=SQRT(1.-COSOM2)
ENDIF ENDIF
OM=ACOS(COSOM) OM=ACOS(COSOM)
! PZ: Average angular zenith distance of the sun ! PZ: Average angular zenith distance of the sun
COSPZ=COSGZ+COSFI*COSTETA*(SINOM/OM-1.) COSPZ=COSGZ+COSFI*COSTETA*(SINOM/OM-1.)
IF(COSPZ.LT.0.001)COSPZ=0.001 IF(COSPZ.LT.0.001) COSPZ=0.001
! ETA: Radius vector of the sun ! ETA: Radius vector of the sun
ETA=1.+COS(JD/58.1)/30. ETA=1.+COS(JD/58.1)/30.
! GE: extra-atmospheric global radiation ! GE: extra-atmospheric global radiation
GE=446.*OM*COSPZ*ETA GE=446.*OM*COSPZ*ETA
! Daily PE by Oudin et al. (2006) formula: ! Daily PE by Oudin et al. (2006) formula:
DPE=MAX(0.,GE*(DT+5.)/100./28.5) DPE=MAX(0.d0,GE*(DT+5.)/100./28.5)
RETURN RETURN
END SUBROUTINE ETP_OUDIN END SUBROUTINE PE_OUDIN
!******************************************************************************* !*******************************************************************************
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment