From 9c462193bfdd50cf1b2be7e77ca73a7f22cc8076 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.priv>
Date: Wed, 20 Mar 2019 09:04:48 +0100
Subject: [PATCH] v1.2.9.32 BUG: check FUN_CRIT in Calibration* funs and  fixed
 return in Calibration fun

---
 DESCRIPTION            | 2 +-
 NEWS.rmd               | 2 +-
 R/Calibration.R        | 7 +++++--
 R/Calibration_Michel.R | 4 +++-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 705ecb74..aa364b19 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.2.9.31
+Version: 1.2.9.32
 Date: 2019-03-20
 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 c15f129a..f2756cb9 100644
--- a/NEWS.rmd
+++ b/NEWS.rmd
@@ -13,7 +13,7 @@ output:
 
 
 
-### 1.2.9.31 Release Notes (2019-03-20) 
+### 1.2.9.32 Release Notes (2019-03-20) 
 
 
 
diff --git a/R/Calibration.R b/R/Calibration.R
index a65d78c4..c6088ad3 100644
--- a/R/Calibration.R
+++ b/R/Calibration.R
@@ -8,11 +8,14 @@ Calibration <- function(InputsModel,
                         FUN_TRANSFO = NULL,
                         verbose = TRUE) {
   FUN_MOD   <- match.fun(FUN_MOD)
-  FUN_CRIT  <- match.fun(FUN_CRIT)
+  if (!missing(FUN_CRIT)) {
+    FUN_CRIT <- match.fun(FUN_CRIT)
+  }
   FUN_CALIB <- match.fun(FUN_CALIB)
   if (!is.null(FUN_TRANSFO)) {
     FUN_TRANSFO <- match.fun(FUN_TRANSFO)
   }
-  return(FUN_CALIB(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD, FUN_TRANSFO, verbose = verbose))
+  return(FUN_CALIB(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit,
+                   CalibOptions = CalibOptions, FUN_MOD = FUN_MOD, FUN_TRANSFO = FUN_TRANSFO, verbose = verbose))
 }
 
diff --git a/R/Calibration_Michel.R b/R/Calibration_Michel.R
index b782e309..6051506a 100644
--- a/R/Calibration_Michel.R
+++ b/R/Calibration_Michel.R
@@ -9,7 +9,9 @@ Calibration_Michel <- function(InputsModel,
   
   
   FUN_MOD  <- match.fun(FUN_MOD)
-  FUN_CRIT <- match.fun(FUN_CRIT)
+  if (!missing(FUN_CRIT)) {
+    FUN_CRIT <- match.fun(FUN_CRIT)
+  }
   if (!is.null(FUN_TRANSFO)) {
     FUN_TRANSFO <- match.fun(FUN_TRANSFO)
   }
-- 
GitLab