diff --git a/R/RunModel_CemaNeige.R b/R/RunModel_CemaNeige.R index a9f35e0e189465dd24e23bb0b4904216e98b6766..2cbac8153c51987d302af9f0c8d075253122c7b9 100644 --- a/R/RunModel_CemaNeige.R +++ b/R/RunModel_CemaNeige.R @@ -94,7 +94,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series IndOutputs = IndOutputsCemaNeige, ### indices of output series ## outputs - Outputs = matrix(-999.999, ### output series [mm] + Outputs = matrix(-999.999, ### output series [mm, mm/time step or degC] nrow = length(IndPeriod1), ncol = length(IndOutputsCemaNeige)), StateEnd = rep(-999.999, NStates) ### state variables at the end of the model run diff --git a/R/RunModel_CemaNeigeGR4H.R b/R/RunModel_CemaNeigeGR4H.R index fe29e9096e863e14283b54635006c341d13ab9dd..4e73176cf8108a9585bee1231d183644e344616c 100644 --- a/R/RunModel_CemaNeigeGR4H.R +++ b/R/RunModel_CemaNeigeGR4H.R @@ -51,7 +51,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) { Param[3L] <- Param_X1X3_threshold } if (Param[4L] < Param_X4_threshold) { - warning(sprintf("Param[4] (X4: unit hydrograph time constant [hour]) < %.2f\n X4 set to %.2f", Param_X4_threshold, Param_X4_threshold)) + warning(sprintf("Param[4] (X4: unit hydrograph time constant [h]) < %.2f\n X4 set to %.2f", Param_X4_threshold, Param_X4_threshold)) Param[4L] <- Param_X4_threshold } @@ -62,11 +62,13 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) { IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run) LInputSeries <- as.integer(length(IndPeriod1)) IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp) + 1):LInputSeries - ParamCemaNeige <- Param[(length(Param)-1 - 2 * as.integer(IsHyst)):length(Param)] + ParamCemaNeige <- Param[(length(Param) - 1 - 2 * as.integer(IsHyst)):length(Param)] NParamMod <- as.integer(length(Param) - (2 + 2 * as.integer(IsHyst))) ParamMod <- Param[1:NParamMod] NLayers <- length(InputsModel$LayerPrecip) NStatesMod <- as.integer(length(RunOptions$IniStates) - NStates * NLayers) + + ## Output data preparation ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim @@ -106,7 +108,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series IndOutputs = IndOutputsCemaNeige, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm, mm/h or degC] StateEnd = rep(as.double(-999.999), as.integer(NStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -164,7 +166,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsMod)), ### number of output series IndOutputs = IndOutputsMod, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm or mm/h] StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -174,7 +176,8 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) { idNStates <- seq_len(NStates*NLayers) %% NStates RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeigeGR4H, InputsModel = InputsModel, IsHyst = IsHyst, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, - UH1 = RESULTS$StateEnd[(1:(20*24))+7], UH2 = RESULTS$StateEnd[(1:(40*24))+(7+20*24)], + UH1 = RESULTS$StateEnd[(1:(20*24)) + 7], + UH2 = RESULTS$StateEnd[(1:(40*24)) + (7+20*24)], GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]], eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]], GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]], @@ -183,7 +186,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) { } if (inherits(RunOptions, "CemaNeige") & "Precip" %in% RunOptions$Outputs_Sim) { - RESULTS$Outputs[, which(FortranOutputs$GR[IndOutputsMod] == "Precip")] <- InputsModel$Precip[IndPeriod1] + RESULTS$Outputs[, which(FortranOutputs$GR[IndOutputsMod] == "Precip")] <- InputsModel$Precip[IndPeriod1] } ## Output data preparation diff --git a/R/RunModel_CemaNeigeGR4J.R b/R/RunModel_CemaNeigeGR4J.R index 9156165856ae34a26358c231d9466c8174823bee..974e20d7de7827f20c69e225696d30da966691c6 100644 --- a/R/RunModel_CemaNeigeGR4J.R +++ b/R/RunModel_CemaNeigeGR4J.R @@ -104,7 +104,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series IndOutputs = IndOutputsCemaNeige, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm, mm/d or degC] StateEnd = rep(as.double(-999.999), as.integer(NStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -162,7 +162,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsMod)), ### number of output series IndOutputs = IndOutputsMod, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm or mm/d] StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -172,7 +172,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) { idNStates <- seq_len(NStates*NLayers) %% NStates RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeigeGR4J, InputsModel = InputsModel, IsHyst = IsHyst, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, - UH1 = RESULTS$StateEnd[(1:20)+7], UH2 = RESULTS$StateEnd[(1:40)+(7+20)], + UH1 = RESULTS$StateEnd[(1:20) + 7], UH2 = RESULTS$StateEnd[(1:40) + (7+20)], GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]], eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]], GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]], diff --git a/R/RunModel_CemaNeigeGR5H.R b/R/RunModel_CemaNeigeGR5H.R index 6cfcc4180c93eb3fa361830d55b0f382df949b57..8f1f70ccc35cf2e0320da80b109a96f3e1eec602 100644 --- a/R/RunModel_CemaNeigeGR5H.R +++ b/R/RunModel_CemaNeigeGR5H.R @@ -65,27 +65,20 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { if (identical(RunOptions$IndPeriod_WarmUp, 0L)) { RunOptions$IndPeriod_WarmUp <- NULL } - IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run) - - LInputSeries <- as.integer(length(IndPeriod1)) - if ("all" %in% RunOptions$Outputs_Sim) { - IndOutputsMod <- as.integer(1:length(FortranOutputs)) - } else { - IndOutputsMod <- which(FortranOutputs %in% RunOptions$Outputs_Sim) - } - + IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run) + LInputSeries <- as.integer(length(IndPeriod1)) + IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp) + 1):LInputSeries ParamCemaNeige <- Param[(length(Param) - 1 - 2 * as.integer(IsHyst)):length(Param)] NParamMod <- as.integer(length(Param) - (2 + 2 * as.integer(IsHyst))) ParamMod <- Param[1:NParamMod] NLayers <- length(InputsModel$LayerPrecip) NStatesMod <- as.integer(length(RunOptions$IniStates) - NStates * NLayers) - ## Output data preparation - IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim + ## CemaNeige________________________________________________________________________________ if (inherits(RunOptions, "CemaNeige")) { if ("all" %in% RunOptions$Outputs_Sim) { @@ -99,13 +92,14 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { ## Call CemaNeige Fortran_________________________ - for(iLayer in 1:NLayers) { + for (iLayer in 1:NLayers) { + if (!IsHyst) { StateStartCemaNeige <- RunOptions$IniStates[(7 + 20*24 + 40*24) + c(iLayer, iLayer+NLayers)] } else { StateStartCemaNeige <- RunOptions$IniStates[(7 + 20*24 + 40*24) + c(iLayer, iLayer+NLayers, iLayer+2*NLayers, iLayer+3*NLayers)] } - RESULTS <- .Fortran("frun_cemaneige",PACKAGE="airGR", + RESULTS <- .Fortran("frun_cemaneige", PACKAGE = "airGR", ## inputs LInputs = LInputSeries, ### length of input and output series InputsPrecip = InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/h] @@ -120,7 +114,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series IndOutputs = IndOutputsCemaNeige, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm, mm/h or degC] StateEnd = rep(as.double(-999.999), as.integer(NStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -147,43 +141,43 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { CemaNeigeLayers <- list() CemaNeigeStateEnd <- NULL NameCemaNeigeLayers <- NULL - CatchMeltAndPliq <- InputsModel$Precip[IndPeriod1] + CatchMeltAndPliq <- InputsModel$Precip[IndPeriod1] } - - - - ## GR model______________________________________________________________________________________ + + + + ## GR model if ("all" %in% RunOptions$Outputs_Sim) { IndOutputsMod <- as.integer(1:length(FortranOutputs$GR)) } else { IndOutputsMod <- which(FortranOutputs$GR %in% RunOptions$Outputs_Sim) } - + ## Use of IniResLevels if (!is.null(RunOptions$IniResLevels)) { - RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * Param[1] ### production store level (mm) - RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * Param[3] ### routing store level (mm) + RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * ParamMod[1] ### production store level (mm) + RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * ParamMod[3] ### routing store level (mm) if (IsIntStore) { RunOptions$IniStates[4] <- RunOptions$IniResLevels[4] * Imax ### interception store level (mm) } } - + ## Call GR model Fortan - RESULTS <- .Fortran("frun_gr5h",PACKAGE="airGR", + RESULTS <- .Fortran("frun_gr5h", PACKAGE = "airGR", ## inputs - LInputs = LInputSeries, ### length of input and output series - InputsPrecip = InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/h] - InputsPE = InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/h] - NParam = as.integer(length(Param)), ### number of model parameter - Param = Param, ### parameter set - NStates = as.integer(length(RunOptions$IniStates)), ### number of state variables used for model initialising - StateStart = RunOptions$IniStates, ### state variables used when the model run starts - Imax = Imax, ### maximal capacity of interception store - NOutputs = as.integer(length(IndOutputsMod)), ### number of output series - IndOutputs = IndOutputsMod, ### indices of output series + LInputs = LInputSeries, ### length of input and output series + InputsPrecip = CatchMeltAndPliq, ### input series of total precipitation [mm/h] + InputsPE = InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/h] + NParam = NParamMod, ### number of model parameter + Param = ParamMod, ### parameter set + NStates = NStatesMod, ### number of state variables used for model initialising + StateStart = RunOptions$IniStates[1:NStatesMod], ### state variables used when the model run starts + Imax = Imax, ### maximal capacity of interception store + NOutputs = as.integer(length(IndOutputsMod)), ### number of output series + IndOutputs = IndOutputsMod, ### indices of output series ## outputs Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm or mm/h] - StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run + StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA @@ -193,7 +187,8 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeigeGR5H, InputsModel = InputsModel, IsHyst = IsHyst, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, IntStore = RESULTS$StateEnd[4L], - UH1 = NULL, UH2 = RESULTS$StateEnd[(1:(40*24))+(7+20*24)], + UH1 = NULL, + UH2 = RESULTS$StateEnd[(1:(40*24)) + (7+20*24)], GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]], eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]], GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]], @@ -202,12 +197,11 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { } if (inherits(RunOptions, "CemaNeige") & "Precip" %in% RunOptions$Outputs_Sim) { - RESULTS$Outputs[,which(FortranOutputs$GR[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1] + RESULTS$Outputs[, which(FortranOutputs$GR[IndOutputsMod] == "Precip")] <- InputsModel$Precip[IndPeriod1] } ## Output data preparation ## OutputsModel only - ## OutputsModel only if (!ExportDatesR & !ExportStateEnd) { OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]), list(CemaNeigeLayers)) @@ -229,10 +223,10 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) { } ## DatesR and OutputsModel and SateEnd if ( ExportDatesR & ExportStateEnd) { - OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]), - lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]), - list(CemaNeigeLayers), - list(RESULTS$StateEnd)) + OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]), + lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]), + list(CemaNeigeLayers), + list(RESULTS$StateEnd)) names(OutputsModel) <- c("DatesR", FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers, "StateEnd") } diff --git a/R/RunModel_CemaNeigeGR5J.R b/R/RunModel_CemaNeigeGR5J.R index 3e3344d5e3b589bb310d15e075a528e86a2b91b2..e09d22d19ba5e32c3b453e67760705d7f4c628d5 100644 --- a/R/RunModel_CemaNeigeGR5J.R +++ b/R/RunModel_CemaNeigeGR5J.R @@ -105,7 +105,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series IndOutputs = IndOutputsCemaNeige, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsCemaNeige)), ### output series [mm, mm/d or degC] StateEnd = rep(as.double(-999.999), as.integer(NStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -163,8 +163,8 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsMod)), ### number of output series IndOutputs = IndOutputsMod, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm] - StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm or mm/d] + StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA @@ -173,7 +173,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) { idNStates <- seq_len(NStates*NLayers) %% NStates RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeigeGR5J, InputsModel = InputsModel, IsHyst = IsHyst, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, - UH1 = NULL, UH2 = RESULTS$StateEnd[(1:40)+(7+20)], + UH1 = NULL, UH2 = RESULTS$StateEnd[(1:40) + (7+20)], GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]], eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]], GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]], diff --git a/R/RunModel_CemaNeigeGR6J.R b/R/RunModel_CemaNeigeGR6J.R index 60c32a26898d8fa164b78d46d02cce8e7267419b..d8421231f932260d63f198e818952cf858071c16 100644 --- a/R/RunModel_CemaNeigeGR6J.R +++ b/R/RunModel_CemaNeigeGR6J.R @@ -109,7 +109,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series IndOutputs = IndOutputsCemaNeige, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries,ncol = length(IndOutputsCemaNeige)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries,ncol = length(IndOutputsCemaNeige)), ### output series [mm, mm/d or degC] StateEnd = rep(as.double(-999.999), as.integer(NStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -168,7 +168,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputsMod)), ### number of output series IndOutputs = IndOutputsMod, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries,ncol = length(IndOutputsMod)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries,ncol = length(IndOutputsMod)), ### output series [mm or mm/d] StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -178,7 +178,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) { idNStates <- seq_len(NStates*NLayers) %% NStates RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeigeGR6J, InputsModel = InputsModel, IsHyst = IsHyst, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = RESULTS$StateEnd[3L], - UH1 = RESULTS$StateEnd[(1:20)+7], UH2 = RESULTS$StateEnd[(1:40)+(7+20)], + UH1 = RESULTS$StateEnd[(1:20) + 7], UH2 = RESULTS$StateEnd[(1:40) + (7+20)], GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]], eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]], GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]], diff --git a/R/RunModel_GR1A.R b/R/RunModel_GR1A.R index 58bca283713067eb4ebc0547671b0fc61303b790..7f67a3f9bfe35b594d4cc0d683604ac687df63d2 100644 --- a/R/RunModel_GR1A.R +++ b/R/RunModel_GR1A.R @@ -63,8 +63,8 @@ RunModel_GR1A <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputs)), ### number of output series IndOutputs = IndOutputs, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol=length(IndOutputs)), ### output series [mm] - StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm/y] + StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA diff --git a/R/RunModel_GR2M.R b/R/RunModel_GR2M.R index 52e068c47e536527bbfbcbfef3e37251dc6befdf..e2868936c2ca06bebd0e2299c2f8c17dead6760c 100644 --- a/R/RunModel_GR2M.R +++ b/R/RunModel_GR2M.R @@ -76,7 +76,7 @@ RunModel_GR2M <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputs)), ### number of output series IndOutputs = IndOutputs, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm or mm/month] StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run ) RESULTS$Outputs [round(RESULTS$Outputs , 3) == -999.999] <- NA diff --git a/R/RunModel_GR4H.R b/R/RunModel_GR4H.R index 749ae6a39ec4a34dcab587cbd552ff65b2ac481e..388cb90021e2a3d147f7634b5070a38e0d6c4dbf 100644 --- a/R/RunModel_GR4H.R +++ b/R/RunModel_GR4H.R @@ -81,7 +81,7 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputs)), ### number of output series IndOutputs = IndOutputs, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm or mm/h] StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -90,7 +90,7 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) { RESULTS$StateEnd[-3L] <- ifelse(RESULTS$StateEnd[-3L] < 0, 0, RESULTS$StateEnd[-3L]) ### remove negative values except for the ExpStore location RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_GR4H, InputsModel = InputsModel, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, - UH1 = RESULTS$StateEnd[(1:(20*24))+7], UH2 = RESULTS$StateEnd[(1:(40*24))+(7+20*24)], + UH1 = RESULTS$StateEnd[(1:(20*24)) + 7], UH2 = RESULTS$StateEnd[(1:(40*24)) + (7+20*24)], GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, verbose = FALSE) } diff --git a/R/RunModel_GR4J.R b/R/RunModel_GR4J.R index 0be613be0d5fca604e72c9696e1d72bde93716ff..cab27ee3e8026c693113a17a397eb08a53d6faca 100644 --- a/R/RunModel_GR4J.R +++ b/R/RunModel_GR4J.R @@ -80,7 +80,7 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputs)), ### number of output series IndOutputs = IndOutputs, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm or mm/d] StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -89,7 +89,7 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) { RESULTS$StateEnd[-3L] <- ifelse(RESULTS$StateEnd[-3L] < 0, 0, RESULTS$StateEnd[-3L]) ### remove negative values except for the ExpStore location RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, - UH1 = RESULTS$StateEnd[(1:20)+7], UH2 = RESULTS$StateEnd[(1:40)+(7+20)], + UH1 = RESULTS$StateEnd[(1:20) + 7], UH2 = RESULTS$StateEnd[(1:40) + (7+20)], GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, verbose = FALSE) } diff --git a/R/RunModel_GR5H.R b/R/RunModel_GR5H.R index 3f985cb78b4956225029561409d4bff0ecdc80f0..a8a5944e320cd18bf943ea74604a4670bde1608f 100644 --- a/R/RunModel_GR5H.R +++ b/R/RunModel_GR5H.R @@ -101,7 +101,7 @@ RunModel_GR5H <- function(InputsModel, RunOptions, Param) { RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_GR5H, InputsModel = InputsModel, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, IntStore = RESULTS$StateEnd[4L], - UH1 = NULL, UH2 = RESULTS$StateEnd[(1:(40*24))+(7+20*24)], + UH1 = NULL, UH2 = RESULTS$StateEnd[(1:(40*24)) + (7+20*24)], GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, verbose = FALSE) } diff --git a/R/RunModel_GR5J.R b/R/RunModel_GR5J.R index ee8f7756670dcafc0b3450f82cb29c5c536c07c0..60fe028c313bdeec040f072de92e9f547ce53ce0 100644 --- a/R/RunModel_GR5J.R +++ b/R/RunModel_GR5J.R @@ -81,7 +81,7 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputs)), ### number of output series IndOutputs = IndOutputs, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm or mm/d] StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -90,7 +90,7 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) { RESULTS$StateEnd[-3L] <- ifelse(RESULTS$StateEnd[-3L] < 0, 0, RESULTS$StateEnd[-3L]) ### remove negative values except for the ExpStore location RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_GR5J, InputsModel = InputsModel, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL, - UH1 = NULL, UH2 = RESULTS$StateEnd[(1:40)+(7+20)], + UH1 = NULL, UH2 = RESULTS$StateEnd[(1:40) + (7+20)], GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, verbose = FALSE) } diff --git a/R/RunModel_GR6J.R b/R/RunModel_GR6J.R index 52df6553e18f143f379b4f29d764f4e929716abf..4539fe3bbe3fb46561d8c75befe85fe07be3ab3a 100644 --- a/R/RunModel_GR6J.R +++ b/R/RunModel_GR6J.R @@ -86,7 +86,7 @@ RunModel_GR6J <- function(InputsModel, RunOptions, Param) { NOutputs = as.integer(length(IndOutputs)), ### number of output series IndOutputs = IndOutputs, ### indices of output series ## outputs - Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm] + Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputs)), ### output series [mm or mm/d] StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run ) RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA @@ -95,7 +95,7 @@ RunModel_GR6J <- function(InputsModel, RunOptions, Param) { RESULTS$StateEnd[-3L] <- ifelse(RESULTS$StateEnd[-3L] < 0, 0, RESULTS$StateEnd[-3L]) ### remove negative values except for the ExpStore location RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_GR6J, InputsModel = InputsModel, ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = RESULTS$StateEnd[3L], - UH1 = RESULTS$StateEnd[(1:20)+7], UH2 = RESULTS$StateEnd[(1:40)+(7+20)], + UH1 = RESULTS$StateEnd[(1:20) + 7], UH2 = RESULTS$StateEnd[(1:40) + (7+20)], GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, verbose = FALSE) }