From 52c24906fff771706b7fd101be188e0d7252c82f Mon Sep 17 00:00:00 2001
From: unknown <olivier.delaigue@ANPI1430.antony.irstea.priv>
Date: Tue, 5 Sep 2017 12:20:11 +0200
Subject: [PATCH] v1.0.9.38 CreateIniStates stops if state values < 0

---
 DESCRIPTION         | 2 +-
 R/CreateIniStates.R | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 7435de1e..a6d74838 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.9.37
+Version: 1.0.9.38
 Date: 2017-09-05
 Authors@R: c(
   person("Laurent", "Coron", role = c("aut", "trl")),
diff --git a/R/CreateIniStates.R b/R/CreateIniStates.R
index 5644dcce..faa603ec 100644
--- a/R/CreateIniStates.R
+++ b/R/CreateIniStates.R
@@ -62,6 +62,12 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
   
   
   ## check states
+  if (any(ProdStore < 0) | any(RoutStore < 0) | any(ExpStore < 0) |
+      any(UH1 < 0) | any(UH2 < 0) |
+      any(GCemaNeigeLayers < 0) | any(eTGCemaNeigeLayers < 0)) {
+    stop("Negative values are not allowed for any state variables")
+  }
+  
   if (identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) {
     if (is.null(ExpStore)) {
       stop("'RunModel_*GR6J' need an 'ExpStore' value")
-- 
GitLab