Commit a5ad9a33 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.2.12.19 BUG: checks on FUN_MOD modified in CreateIniStates to avoid errors...

v1.2.12.19 BUG: checks on FUN_MOD modified in CreateIniStates to avoid errors generated by the use of match.fun
parent ce5ba39d
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.2.12.18 Version: 1.2.12.19
Date: 2019-04-01 Date: 2019-04-01
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")),
......
...@@ -13,7 +13,7 @@ output: ...@@ -13,7 +13,7 @@ output:
### 1.2.12.18 Release Notes (2019-04-01) ### 1.2.12.19 Release Notes (2019-04-01)
......
...@@ -11,6 +11,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -11,6 +11,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
UH1n <- 20L UH1n <- 20L
UH2n <- UH1n * 2L UH2n <- UH1n * 2L
nameFUN_MOD <- as.character(substitute(FUN_MOD))
FUN_MOD <- match.fun(FUN_MOD) FUN_MOD <- match.fun(FUN_MOD)
## check FUN_MOD ## check FUN_MOD
...@@ -70,7 +71,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -70,7 +71,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
} }
} else if (!is.null(ExpStore)) { } else if (!is.null(ExpStore)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'ExpStore'. Value set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'ExpStore'. Value set to NA", nameFUN_MOD))
} }
ExpStore <- Inf ExpStore <- Inf
} }
...@@ -78,13 +79,13 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -78,13 +79,13 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
if (identical(FUN_MOD, RunModel_GR2M)) { if (identical(FUN_MOD, RunModel_GR2M)) {
if (!is.null(UH1)) { if (!is.null(UH1)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'UH1'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'UH1'. Values set to NA", nameFUN_MOD))
} }
UH1 <- rep(Inf, UH1n) UH1 <- rep(Inf, UH1n)
} }
if (!is.null(UH2)) { if (!is.null(UH2)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'UH2'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'UH2'. Values set to NA", nameFUN_MOD))
} }
UH2 <- rep(Inf, UH2n) UH2 <- rep(Inf, UH2n)
} }
...@@ -92,7 +93,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -92,7 +93,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
if ((identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J)) & !is.null(UH1)) { if ((identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J)) & !is.null(UH1)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'UH1'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'UH1'. Values set to NA", nameFUN_MOD))
} }
UH1 <- rep(Inf, UH1n) UH1 <- rep(Inf, UH1n)
} }
...@@ -100,43 +101,43 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -100,43 +101,43 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
if ("CemaNeige" %in% ObjectClass & ! "GR" %in% ObjectClass) { if ("CemaNeige" %in% ObjectClass & ! "GR" %in% ObjectClass) {
if (!is.null(ProdStore)) { if (!is.null(ProdStore)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'ProdStore'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'ProdStore'. Values set to NA", nameFUN_MOD))
} }
} }
ProdStore <- Inf ProdStore <- Inf
if (!is.null(RoutStore)) { if (!is.null(RoutStore)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'RoutStore'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'RoutStore'. Values set to NA", nameFUN_MOD))
} }
} }
RoutStore <- Inf RoutStore <- Inf
if (!is.null(ExpStore)) { if (!is.null(ExpStore)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'ExpStore'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'ExpStore'. Values set to NA", nameFUN_MOD))
} }
} }
ExpStore <- Inf ExpStore <- Inf
if (!is.null(UH1)) { if (!is.null(UH1)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'UH1'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'UH1'. Values set to NA", nameFUN_MOD))
} }
} }
UH1 <- rep(Inf, UH1n) UH1 <- rep(Inf, UH1n)
if (!is.null(UH2)) { if (!is.null(UH2)) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'UH2'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'UH2'. Values set to NA", nameFUN_MOD))
} }
} }
UH2 <- rep(Inf, UH2n) UH2 <- rep(Inf, UH2n)
} }
if("CemaNeige" %in% ObjectClass & if("CemaNeige" %in% ObjectClass &
(is.null(GCemaNeigeLayers) | is.null(eTGCemaNeigeLayers))) { (is.null(GCemaNeigeLayers) | is.null(eTGCemaNeigeLayers))) {
stop("'RunModel_CemaNeigeGR*' need values for 'GCemaNeigeLayers' and 'GCemaNeigeLayers'") stop(sprintf("'%s' need values for 'GCemaNeigeLayers' and 'GCemaNeigeLayers'", nameFUN_MOD))
} }
if(!"CemaNeige" %in% ObjectClass & if(!"CemaNeige" %in% ObjectClass &
(!is.null(GCemaNeigeLayers) | !is.null(eTGCemaNeigeLayers))) { (!is.null(GCemaNeigeLayers) | !is.null(eTGCemaNeigeLayers))) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'GCemaNeigeLayers' and 'GCemaNeigeLayers'. Values set to NA", as.character(substitute(FUN_MOD)))) warning(sprintf("'%s' does not require 'GCemaNeigeLayers' and 'GCemaNeigeLayers'. Values set to NA", nameFUN_MOD))
} }
GCemaNeigeLayers <- Inf GCemaNeigeLayers <- Inf
eTGCemaNeigeLayers <- Inf eTGCemaNeigeLayers <- Inf
......
Markdown is supported
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