diff --git a/DESCRIPTION b/DESCRIPTION index 2d31e79c54e9669fbb9557f1fbaa7cc25b679f06..4212eba9b9112bac090e25ef9d0cc8ee94e36167 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.6.12.9000 -Date: 2021-04-27 +Version: 1.6.12.9001 +Date: 2021-10-26 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"), diff --git a/R/RunModel_Lag.R b/R/RunModel_Lag.R index 34ea35b623e42e79aa61d91f299672762d10a943..037e1e5a6e6989c13fa3add482e63575b4db6aeb 100644 --- a/R/RunModel_Lag.R +++ b/R/RunModel_Lag.R @@ -24,10 +24,13 @@ RunModel_Lag <- function(InputsModel, RunOptions, Param, QcontribDown) { if (length(QcontribDown$Qsim) != length(RunOptions$IndPeriod_Run)) { stop("Time series Qsim in 'QcontribDown' should have the same lenght as 'RunOptions$IndPeriod_Run'") } - if (!is.null(QcontribDown$WarmUpQsim) && - length(QcontribDown$WarmUpQsim) != length(RunOptions$IndPeriod_WarmUp) && - RunOptions$IndPeriod_WarmUp != 0L) { - stop("Time series WarmUpQsim in 'QcontribDown' should have the same lenght as 'RunOptions$IndPeriod_WarmUp'") + if (!identical(RunOptions$IndPeriod_WarmUp, 0L) && RunOptions$Outputs_Sim != RunOptions$Outputs_Cal) { + # This test is not necessary during calibration but usefull in other cases because + # WarmUpQsim is then used for downstream sub-basins because of the delay in Qupstream + if (is.null(QcontribDown$RunOptions$WarmUpQsim) || + length(QcontribDown$RunOptions$WarmUpQsim) != length(RunOptions$IndPeriod_WarmUp)) { + stop("Time series WarmUpQsim in 'QcontribDown' should have the same lenght as 'RunOptions$IndPeriod_WarmUp'") + } } } else if (is.vector(QcontribDown) && is.numeric(QcontribDown)) { if (length(QcontribDown) != length(RunOptions$IndPeriod_Run)) { diff --git a/R/UtilsRunModel.R b/R/UtilsRunModel.R index 17476edeb1060f36c19d33ccb48b1bfea2c14f13..1a384a333b25d79a021e63fb6009ad0ce8d96ff9 100644 --- a/R/UtilsRunModel.R +++ b/R/UtilsRunModel.R @@ -37,8 +37,7 @@ if (!is.null(CemaNeigeLayers)) { OutputsModel$CemaNeigeLayers <- CemaNeigeLayers } - - if ("WarmUpQsim" %in% RunOptions$Outputs_Sim) { + if ("WarmUpQsim" %in% RunOptions$Outputs_Sim && !identical(RunOptions$IndPeriod_WarmUp, 0L)) { OutputsModel$RunOptions$WarmUpQsim <- RESULTS$Outputs[seq_len(length(RunOptions$IndPeriod_WarmUp)), which(FortranOutputs == "Qsim")] # class(OutputsModel$RunOptions$WarmUpQsim) <- c("WarmUpOutputsModelItem", class(OutputsModel$RunOptions$WarmUpQsim))