From f614cb8f36a6db05f5ca9eee9a855a15cfd5fb2f Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.priv>
Date: Wed, 4 Sep 2019 16:30:20 +0200
Subject: [PATCH] v1.3.2.28 BUG: wrong conditional expressions correctd to have
 a right number of end states returned by CreateIniStates for CemaNeige
 whithout hysteresis #5618

---
 DESCRIPTION         |  2 +-
 NEWS.rmd            |  2 +-
 R/CreateIniStates.R | 11 ++++++++---
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 4e1d7d01..e86bef85 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.3.2.27
+Version: 1.3.2.28
 Date: 2019-09-04
 Authors@R: c(
   person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
diff --git a/NEWS.rmd b/NEWS.rmd
index adba5366..c6b9b6b3 100644
--- a/NEWS.rmd
+++ b/NEWS.rmd
@@ -14,7 +14,7 @@ output:
 
 
 
-### 1.3.2.27 Release Notes (2019-09-04)
+### 1.3.2.28 Release Notes (2019-09-04)
 
 
 
diff --git a/R/CreateIniStates.R b/R/CreateIniStates.R
index b1748a89..e9830b0a 100644
--- a/R/CreateIniStates.R
+++ b/R/CreateIniStates.R
@@ -200,13 +200,18 @@ CreateIniStates <- function(FUN_MOD, InputsModel, IsHyst = FALSE,
   if (is.null(eTGCemaNeigeLayers)) {
     eTGCemaNeigeLayers <- rep(Inf, NLayers)
   }
-  if (is.null(GthrCemaNeigeLayers) | is.infinite(GthrCemaNeigeLayers)) {
+  if (is.null(GthrCemaNeigeLayers)) {
     GthrCemaNeigeLayers <- rep(Inf, NLayers)
   }
-  if (is.null(GlocmaxCemaNeigeLayers) | is.infinite(GlocmaxCemaNeigeLayers)) {
+  if (is.infinite(GthrCemaNeigeLayers)) {
+    GthrCemaNeigeLayers <- rep(Inf, NLayers)
+  }
+  if (is.null(GlocmaxCemaNeigeLayers)) {
     GlocmaxCemaNeigeLayers <- rep(Inf, NLayers)
   }
-  
+  if (is.infinite(GlocmaxCemaNeigeLayers)) {
+    GlocmaxCemaNeigeLayers <- rep(Inf, NLayers)
+  }  
   
   # check negative values
   if (any(ProdStore < 0) | any(RoutStore < 0) |
-- 
GitLab