From cd4ff63a59813b21d0e0f68a795249f8f0ae22fa Mon Sep 17 00:00:00 2001
From: unknown <olivier.delaigue@ANPI1430.antony.irstea.priv>
Date: Mon, 23 Jan 2017 17:14:18 +0100
Subject: [PATCH] v1.0.5.12 convert type from REAL(4) to REAL(8) when the MAX()
 function is used with REAL(8) variables in FORTRAN codes in order to succeed
 the check of the CRAN

---
 DESCRIPTION          |  2 +-
 NEWS                 |  2 +-
 man/airGR.Rd         |  2 +-
 src/frun_CEMANEIGE.f | 14 +++++++-------
 src/frun_GR2M.f      |  4 ++--
 src/frun_GR4H.f      | 10 +++++-----
 src/frun_GR4J.f      | 10 +++++-----
 src/frun_GR5J.f      | 10 +++++-----
 src/frun_GR6J.f      |  4 ++--
 src/utils_D.f        |  4 ++--
 src/utils_H.f        |  4 ++--
 11 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 64d83527..710d5d7d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
 Package: airGR
 Type: Package
 Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
-Version: 1.0.5.11
+Version: 1.0.5.12
 Date: 2017-01-23
 Authors@R: c(
   person("Laurent", "Coron", role = c("aut", "trl")),
diff --git a/NEWS b/NEWS
index 236868df..09a2a301 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@
 RELEASE HISTORY OF THE airGR PACKAGE
 
 
-#### 1.0.5.10 RELEASE NOTES ###########################
+#### 1.0.5.12 RELEASE NOTES ###########################
 
 - Bug fixed in DataAltiExtrapolation_Valery(). The elevation gradients for air temperature returned by CreateInputsModel() are improved.
 
diff --git a/man/airGR.Rd b/man/airGR.Rd
index 2001b335..ec63fbb6 100644
--- a/man/airGR.Rd
+++ b/man/airGR.Rd
@@ -2,7 +2,7 @@
 \alias{airGR}
 \docType{package}
 \encoding{UTF-8}
-\title{Suite of GR hydrological models for precipitation-runoff modelling}
+\title{Suite of GR Hydrological Models for Precipitation-Runoff Modelling}
 \description{
 This package brings into R the hydrological modelling tools used at Irstea-Antony (HBAN Research Unit, France), including rainfall-runoff models (GR4H, GR4J, GR5J, GR6J, GR2M, GR1A) and a snowmelt module (CemaNeige). Each model core is coded in FORTRAN to ensure low computational time. The other package functions (i.e. mainly the calibration algorithm and the computation of the efficiency criteria) are coded in R. \cr
 
diff --git a/src/frun_CEMANEIGE.f b/src/frun_CEMANEIGE.f
index 628e7ab1..1278b9c7 100644
--- a/src/frun_CEMANEIGE.f
+++ b/src/frun_CEMANEIGE.f
@@ -46,14 +46,14 @@
       !--------------------------------------------------------------
 
       !initilisation des constantes
-      Tmelt=0
+      Tmelt=0.
       Gthreshold=0.9*MeanAnSolidPrecip
       MinSpeed=0.1
 
       !initilisation of model states using StateStart
       G=StateStart(1)
       eTG=StateStart(2)
-      PliqAndMelt=0
+      PliqAndMelt=0.
 
       !setting parameter values
       CTG=Param(1)
@@ -79,21 +79,21 @@ c      Outputs = -999.999  !initialisation made in R
 
         !Snow pack thermal state before melt
         eTG=CTG*eTG + (1-CTG)*InputsTemp(k)
-        IF(eTG.GT.0) eTG=0
+        IF(eTG.GT.0.) eTG=0.
 
         !Potential melt
-        IF(eTG.EQ.0.AND.InputsTemp(k).GT.Tmelt) THEN
+        IF(eTG.EQ.0..AND.InputsTemp(k).GT.Tmelt) THEN
           PotMelt=Kf*(InputsTemp(k)-Tmelt)
           IF(PotMelt.GT.G) PotMelt=G
         ELSE
-          PotMelt=0
+          PotMelt=0.
         ENDIF
 
         !Gratio
         IF(G.LT.Gthreshold) THEN
           Gratio=G/Gthreshold
         ELSE
-          Gratio=1
+          Gratio=1.
         ENDIF
 
         !Actual melt
@@ -106,7 +106,7 @@ c      Outputs = -999.999  !initialisation made in R
         IF(G.LT.Gthreshold) THEN
           Gratio=G/Gthreshold
         ELSE
-          Gratio=1
+          Gratio=1.
         ENDIF
 
         !Water volume to pass to the hydrological model
diff --git a/src/frun_GR2M.f b/src/frun_GR2M.f
index 2a15353c..98ecf120 100644
--- a/src/frun_GR2M.f
+++ b/src/frun_GR2M.f
@@ -121,7 +121,7 @@ C**********************************************************************
 	  
 C Production store
       WS=P/Param(1)  
-      IF(WS.GT.13)WS=13   
+      IF(WS.GT.13.)WS=13.
 	  
  	  ! speed-up
 	  TWS = tanHyp(WS)
@@ -131,7 +131,7 @@ C Production store
 
 	  P1=P+St(1)-S1                  
       WS=E/Param(1)         
-      IF(WS.GT.13)WS=13  
+      IF(WS.GT.13.)WS=13.
 	  
  	  ! speed-up
 	  TWS = tanHyp(WS)
diff --git a/src/frun_GR4H.f b/src/frun_GR4H.f
index 3c473319..c7994982 100644
--- a/src/frun_GR4H.f
+++ b/src/frun_GR4H.f
@@ -165,7 +165,7 @@ C Interception and production store
       EN=E-P1
       PN=0.
       WS=EN/A
-      IF(WS.GT.13)WS=13.
+      IF(WS.GT.13.)WS=13.
 	  
 	  ! speed-up
 		TWS = tanHyp(WS)
@@ -182,7 +182,7 @@ C Interception and production store
       AE=E
       PN=P1-E
       WS=PN/A
-      IF(WS.GT.13)WS=13.
+      IF(WS.GT.13.)WS=13.
 	  
 	  ! speed-up
 		TWS = tanHyp(WS)
@@ -236,7 +236,7 @@ C Potential intercatchment semi-exchange
 
 C Routing store
       AEXCH1=EXCH
-      IF((St(2)+StUH1(1)+EXCH).LT.0) AEXCH1=-St(2)-StUH1(1)
+      IF((St(2)+StUH1(1)+EXCH).LT.0.) AEXCH1=-St(2)-StUH1(1)
       St(2)=St(2)+StUH1(1)+EXCH
       IF(St(2).LT.0.)St(1)=0.
 
@@ -252,8 +252,8 @@ C Routing store
 
 C Runoff from direct branch QD
       AEXCH2=EXCH
-      IF((StUH2(1)+EXCH).LT.0) AEXCH2=-StUH2(1)
-      QD=MAX(0.,StUH2(1)+EXCH)
+      IF((StUH2(1)+EXCH).LT.0.) AEXCH2=-StUH2(1)
+      QD=MAX(0.d0,StUH2(1)+EXCH)
 
 C Total runoff
       Q=QR+QD
diff --git a/src/frun_GR4J.f b/src/frun_GR4J.f
index 29302aeb..e021eac4 100644
--- a/src/frun_GR4J.f
+++ b/src/frun_GR4J.f
@@ -164,7 +164,7 @@ C Interception and production store
       EN=E-P1
       PN=0.
       WS=EN/A
-      IF(WS.GT.13)WS=13.
+      IF(WS.GT.13.)WS=13.
 	  ! speed-up
       TWS = tanHyp(WS)
       Sr = St(1)/A
@@ -179,7 +179,7 @@ C Interception and production store
       AE=E
       PN=P1-E
       WS=PN/A
-      IF(WS.GT.13)WS=13.
+      IF(WS.GT.13.)WS=13.
 	  ! speed-up
       TWS = tanHyp(WS)
       Sr = St(1)/A
@@ -229,7 +229,7 @@ C Potential intercatchment semi-exchange
 
 C Routing store
       AEXCH1=EXCH
-      IF((St(2)+StUH1(1)+EXCH).LT.0) AEXCH1=-St(2)-StUH1(1)
+      IF((St(2)+StUH1(1)+EXCH).LT.0.) AEXCH1=-St(2)-StUH1(1)
       St(2)=St(2)+StUH1(1)+EXCH
       IF(St(2).LT.0.)St(2)=0.
 	  ! speed-up
@@ -243,8 +243,8 @@ C Routing store
 
 C Runoff from direct branch QD
       AEXCH2=EXCH
-      IF((StUH2(1)+EXCH).LT.0) AEXCH2=-StUH2(1)
-      QD=MAX(0.,StUH2(1)+EXCH)
+      IF((StUH2(1)+EXCH).LT.0.) AEXCH2=-StUH2(1)
+      QD=MAX(0.d0,StUH2(1)+EXCH)
 
 C Total runoff
       Q=QR+QD
diff --git a/src/frun_GR5J.f b/src/frun_GR5J.f
index 3dacbb39..6744a80b 100644
--- a/src/frun_GR5J.f
+++ b/src/frun_GR5J.f
@@ -154,7 +154,7 @@ C Interception and production store
       EN=E-P1
       PN=0.
       WS=EN/A
-      IF(WS.GT.13)WS=13.
+      IF(WS.GT.13.)WS=13.
 	  ! speed-up
 	  TWS = tanHyp(WS)
 	  Sr = St(1)/A
@@ -169,7 +169,7 @@ C Interception and production store
       AE=E
       PN=P1-E
       WS=PN/A
-      IF(WS.GT.13)WS=13.
+      IF(WS.GT.13.)WS=13.
 	  ! speed-up
 	  TWS = tanHyp(WS)
 	  Sr = St(1)/A
@@ -212,7 +212,7 @@ C Potential intercatchment semi-exchange
 
 C Routing store
       AEXCH1=EXCH
-      IF((St(2)+Q9+EXCH).LT.0) AEXCH1=-St(2)-Q9
+      IF((St(2)+Q9+EXCH).LT.0.) AEXCH1=-St(2)-Q9
       St(2)=St(2)+Q9+EXCH
       IF(St(2).LT.0.)St(2)=0.
 
@@ -228,8 +228,8 @@ C Routing store
 
 C Runoff from direct branch QD
       AEXCH2=EXCH
-      IF((Q1+EXCH).LT.0) AEXCH2=-Q1
-      QD=MAX(0.,Q1+EXCH)
+      IF((Q1+EXCH).LT.0.) AEXCH2=-Q1
+      QD=MAX(0.d0,Q1+EXCH)
 
 C Total runoff
       Q=QR+QD
diff --git a/src/frun_GR6J.f b/src/frun_GR6J.f
index 06390244..76ca17d6 100644
--- a/src/frun_GR6J.f
+++ b/src/frun_GR6J.f
@@ -148,7 +148,7 @@ C**********************************************************************
       PARAMETER (NH=20,NMISC=30)
       PARAMETER (NParam=6)
       DOUBLEPRECISION St(3)
-	  DOUBLEPRECISION StUH1(NH),StUH2(2*NH),OrdUH1(NH),OrdUH2(2*NH)
+      DOUBLEPRECISION StUH1(NH),StUH2(2*NH),OrdUH1(NH),OrdUH2(2*NH)
       DOUBLEPRECISION Param(NParam)
       DOUBLEPRECISION MISC(NMISC)
       DOUBLEPRECISION P1,E,Q
@@ -273,7 +273,7 @@ C Update of exponential store
 C Runoff from direct branch QD
       AEXCH2=EXCH
       IF((StUH2(1)+EXCH).LT.0) AEXCH2=-StUH2(1)
-      QD=MAX(0.,StUH2(1)+EXCH)
+      QD=MAX(0.d0,StUH2(1)+EXCH)
 
 C Total runoff
       Q=QR+QD+QR1
diff --git a/src/utils_D.f b/src/utils_D.f
index 953a6495..b87484d8 100644
--- a/src/utils_D.f
+++ b/src/utils_D.f
@@ -57,7 +57,7 @@ C**********************************************************************
       INTEGER I,FI
 
       FI=I
-      IF(FI.LE.0.) THEN
+      IF(FI.LE.0) THEN
       SS1=0.
       RETURN
       ENDIF
@@ -84,7 +84,7 @@ C**********************************************************************
       INTEGER I,FI
 
       FI=I
-      IF(FI.LE.0.) THEN
+      IF(FI.LE.0) THEN
       SS2=0.
       RETURN
       ENDIF
diff --git a/src/utils_H.f b/src/utils_H.f
index 6de1123f..78352f3c 100644
--- a/src/utils_H.f
+++ b/src/utils_H.f
@@ -59,7 +59,7 @@ C**********************************************************************
       INTEGER I,FI
 
       FI=I
-      IF(FI.LE.0.) THEN
+      IF(FI.LE.0) THEN
       SS1_H=0.
       RETURN
       ENDIF
@@ -86,7 +86,7 @@ C**********************************************************************
       INTEGER I,FI
 
       FI=I
-      IF(FI.LE.0.) THEN
+      IF(FI.LE.0) THEN
       SS2_H=0.
       RETURN
       ENDIF
-- 
GitLab