Commit 82796c60 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.6.3.55 style: remove semicolons in RunModel_GR* functions

Refs #14
parent 710ab8cf
Pipeline #17496 passed with stages
in 11 minutes and 14 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.3.54
Version: 1.6.3.55
Date: 2020-11-12
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -4,7 +4,7 @@
### 1.6.3.54 Release Notes (2020-11-12)
### 1.6.3.55 Release Notes (2020-11-12)
#### New features
......
......@@ -2,7 +2,7 @@ RunModel_GR2M <- function(InputsModel, RunOptions, Param) {
## Initialization of variables
NParam <- 2;
NParam <- 2
FortranOutputs <- .FortranOutputs(GR = "GR2M")$GR
......@@ -14,7 +14,7 @@ RunModel_GR2M <- function(InputsModel, RunOptions, Param) {
if (inherits(RunOptions, "GR" ) == FALSE) { stop("'RunOptions' must be of class 'GR' ") }
if (!is.vector(Param) | !is.numeric(Param)) { stop("'Param' must be a numeric vector") }
if (sum(!is.na(Param)) != NParam) { stop(paste("'Param' must be a vector of length ", NParam, " and contain no NA", sep = "")) }
Param <- as.double(Param);
Param <- as.double(Param)
Param_X1X2_threshold <- 1e-2
if (Param[1L] < Param_X1X2_threshold) {
......@@ -27,21 +27,21 @@ RunModel_GR2M <- function(InputsModel, RunOptions, Param) {
}
## Input_data_preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL; }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run);
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs))
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim) }
## Output_data_preparation
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries;
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim;
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %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[2]; ### routing store level (mm)
RunOptions$IniStates[1] <- RunOptions$IniResLevels[1]*Param[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*Param[2] ### routing store level (mm)
}
## Call_fortan
......@@ -60,8 +60,8 @@ RunModel_GR2M <- function(InputsModel, RunOptions, Param) {
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
)
RESULTS$Outputs [round(RESULTS$Outputs , 3) == (-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA;
RESULTS$Outputs [round(RESULTS$Outputs , 3) == (-999.999)] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA
if (ExportStateEnd) {
RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_GR2M, InputsModel = InputsModel,
ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL,
......@@ -74,28 +74,28 @@ RunModel_GR2M <- function(InputsModel, RunOptions, Param) {
## Output_data_preparation
## OutputsModel_only
if (ExportDatesR == FALSE & ExportStateEnd == FALSE) {
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]);
names(OutputsModel) <- FortranOutputs[IndOutputs]; }
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(OutputsModel) <- FortranOutputs[IndOutputs] }
## DatesR_and_OutputsModel_only
if (ExportDatesR == TRUE & ExportStateEnd == FALSE) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]); }
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]) }
## OutputsModel_and_SateEnd_only
if (ExportDatesR == FALSE & ExportStateEnd == TRUE) {
OutputsModel <- c( lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd") }
## DatesR_and_OutputsModel_and_SateEnd
if ((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd") }
## End
rm(RESULTS);
class(OutputsModel) <- c("OutputsModel", "monthly", "GR");
return(OutputsModel);
rm(RESULTS)
class(OutputsModel) <- c("OutputsModel", "monthly", "GR")
return(OutputsModel)
}
......@@ -2,7 +2,7 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) {
## Initialization of variables
NParam <- 4;
NParam <- 4
FortranOutputs <- .FortranOutputs(GR = "GR4H")$GR
......@@ -14,7 +14,7 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) {
if (inherits(RunOptions, "GR" ) == FALSE) { stop("'RunOptions' must be of class 'GR' ") }
if (!is.vector(Param) | !is.numeric(Param)) { stop("'Param' must be a numeric vector") }
if (sum(!is.na(Param)) != NParam) { stop(paste("'Param' must be a vector of length ", NParam, " and contain no NA", sep = "")) }
Param <- as.double(Param);
Param <- as.double(Param)
Param_X1X3_threshold <- 1e-2
Param_X4_threshold <- 0.5
......@@ -32,21 +32,21 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) {
}
## Input_data_preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL; }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run);
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs))
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim) }
## Output_data_preparation
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries;
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim;
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %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]*Param[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*Param[3] ### routing store level (mm)
}
## Call_fortan
......@@ -65,8 +65,8 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) {
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
)
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA;
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA
if (ExportStateEnd) {
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,
......@@ -79,28 +79,28 @@ RunModel_GR4H <- function(InputsModel, RunOptions, Param) {
## Output_data_preparation
## OutputsModel_only
if (ExportDatesR == FALSE & ExportStateEnd == FALSE) {
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]);
names(OutputsModel) <- FortranOutputs[IndOutputs]; }
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(OutputsModel) <- FortranOutputs[IndOutputs] }
## DatesR_and_OutputsModel_only
if (ExportDatesR == TRUE & ExportStateEnd == FALSE) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]); }
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]) }
## OutputsModel_and_SateEnd_only
if (ExportDatesR == FALSE & ExportStateEnd == TRUE) {
OutputsModel <- c( lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd") }
## DatesR_and_OutputsModel_and_SateEnd
if ((ExportDatesR == TRUE & ExportStateEnd == TRUE) | "all" %in% RunOptions$Outputs_Sim) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd") }
## End
rm(RESULTS);
class(OutputsModel) <- c("OutputsModel", "hourly", "GR");
return(OutputsModel);
rm(RESULTS)
class(OutputsModel) <- c("OutputsModel", "hourly", "GR")
return(OutputsModel)
}
......@@ -2,7 +2,7 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) {
## Initialization of variables
NParam <- 4;
NParam <- 4
FortranOutputs <- .FortranOutputs(GR = "GR4J")$GR
......@@ -14,7 +14,7 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) {
if (inherits(RunOptions, "GR" ) == FALSE) { stop("'RunOptions' must be of class 'GR' ") }
if (!is.vector(Param) | !is.numeric(Param)) { stop("'Param' must be a numeric vector") }
if (sum(!is.na(Param)) != NParam) { stop(paste("'Param' must be a vector of length ", NParam, " and contain no NA", sep = "")) }
Param <- as.double(Param);
Param <- as.double(Param)
Param_X1X3_threshold <- 1e-2
Param_X4_threshold <- 0.5
......@@ -32,20 +32,20 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) {
}
## Input_data_preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL; }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run);
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs))
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim) }
## Input_data_preparation
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries;
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim;
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %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]*Param[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*Param[3] ### routing store level (mm)
}
## Call_fortan
......@@ -64,8 +64,8 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) {
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
)
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA;
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA
if (ExportStateEnd) {
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,
......@@ -78,28 +78,28 @@ RunModel_GR4J <- function(InputsModel, RunOptions, Param) {
## Output_data_preparation
## OutputsModel_only
if (ExportDatesR == FALSE & ExportStateEnd == FALSE) {
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]);
names(OutputsModel) <- FortranOutputs[IndOutputs]; }
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(OutputsModel) <- FortranOutputs[IndOutputs] }
## DatesR_and_OutputsModel_only
if (ExportDatesR == TRUE & ExportStateEnd == FALSE) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]); }
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]) }
## OutputsModel_and_StateEnd_only
if (ExportDatesR == FALSE & ExportStateEnd == TRUE) {
OutputsModel <- c( lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd") }
## DatesR_and_OutputsModel_and_StateEnd
if ((ExportDatesR == TRUE & ExportStateEnd == TRUE) | "all" %in% RunOptions$Outputs_Sim) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd") }
## End
rm(RESULTS);
class(OutputsModel) <- c("OutputsModel", "daily", "GR");
return(OutputsModel);
rm(RESULTS)
class(OutputsModel) <- c("OutputsModel", "daily", "GR")
return(OutputsModel)
}
......@@ -2,7 +2,7 @@ RunModel_GR5H <- function(InputsModel, RunOptions, Param) {
## Initialization of variables
NParam <- 5;
NParam <- 5
FortranOutputs <- .FortranOutputs(GR = "GR5H")$GR
IsIntStore <- inherits(RunOptions, "interception")
if (IsIntStore) {
......@@ -20,7 +20,7 @@ RunModel_GR5H <- function(InputsModel, RunOptions, Param) {
if (inherits(RunOptions, "GR" ) == FALSE) { stop("'RunOptions' must be of class 'GR' ") }
if (!is.vector(Param) | !is.numeric(Param)) { stop("'Param' must be a numeric vector") }
if (sum(!is.na(Param)) != NParam) { stop(paste("'Param' must be a vector of length ", NParam, " and contain no NA", sep = "")) }
Param <- as.double(Param);
Param <- as.double(Param)
Param_X1X3_threshold <- 1e-2
Param_X4_threshold <- 0.5
......@@ -38,23 +38,23 @@ RunModel_GR5H <- function(InputsModel, RunOptions, Param) {
}
## Input_data_preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL; }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run);
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs))
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim) }
## Output_data_preparation
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries;
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim;
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %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]*Param[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*Param[3] ### routing store level (mm)
if (IsIntStore) {
RunOptions$IniStates[4] <- RunOptions$IniResLevels[4] * Imax; ### interception store level (mm)
RunOptions$IniStates[4] <- RunOptions$IniResLevels[4] * Imax ### interception store level (mm)
}
}
......@@ -75,8 +75,8 @@ RunModel_GR5H <- function(InputsModel, RunOptions, Param) {
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;
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA;
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA
if (ExportStateEnd) {
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_GR5H, InputsModel = InputsModel,
......@@ -90,31 +90,31 @@ RunModel_GR5H <- function(InputsModel, RunOptions, Param) {
## Output_data_preparation
## OutputsModel_only
if (ExportDatesR == FALSE & ExportStateEnd == FALSE) {
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]);
names(OutputsModel) <- FortranOutputs[IndOutputs]; }
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(OutputsModel) <- FortranOutputs[IndOutputs] }
## DatesR_and_OutputsModel_only
if (ExportDatesR == TRUE & ExportStateEnd == FALSE) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]); }
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]) }
## OutputsModel_and_StateEnd_only
if (ExportDatesR == FALSE & ExportStateEnd == TRUE) {
OutputsModel <- c( lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd") }
## DatesR_and_OutputsModel_and_StateEnd
if ((ExportDatesR == TRUE & ExportStateEnd == TRUE) | "all" %in% RunOptions$Outputs_Sim) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd") }
## End
rm(RESULTS);
class(OutputsModel) <- c("OutputsModel", "hourly", "GR");
rm(RESULTS)
class(OutputsModel) <- c("OutputsModel", "hourly", "GR")
if (IsIntStore) {
class(OutputsModel) <- c(class(OutputsModel), "interception")
}
return(OutputsModel);
return(OutputsModel)
}
......@@ -2,7 +2,7 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) {
## Initialization of variables
NParam <- 5;
NParam <- 5
FortranOutputs <- .FortranOutputs(GR = "GR5J")$GR
......@@ -14,7 +14,7 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) {
if (inherits(RunOptions, "GR" ) == FALSE) { stop("'RunOptions' must be of class 'GR' ") }
if (!is.vector(Param) | !is.numeric(Param)) { stop("'Param' must be a numeric vector") }
if (sum(!is.na(Param)) != NParam) { stop(paste("'Param' must be a vector of length ", NParam, " and contain no NA", sep = "")) }
Param <- as.double(Param);
Param <- as.double(Param)
Param_X1X3_threshold <- 1e-2
Param_X4_threshold <- 0.5
......@@ -32,21 +32,21 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) {
}
## Input_data_preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL; }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run);
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs))
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim) }
## Output_data_preparation
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries;
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim;
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %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]*Param[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*Param[3] ### routing store level (mm)
}
## Call_fortan
......@@ -65,8 +65,8 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) {
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
)
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA;
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == (-999.999)] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == (-999.999)] <- NA
if (ExportStateEnd) {
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,
......@@ -79,28 +79,28 @@ RunModel_GR5J <- function(InputsModel, RunOptions, Param) {
## Output_data_preparation
## OutputsModel_only
if (ExportDatesR == FALSE & ExportStateEnd == FALSE) {
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]);
names(OutputsModel) <- FortranOutputs[IndOutputs]; }
OutputsModel <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(OutputsModel) <- FortranOutputs[IndOutputs] }
## DatesR_and_OutputsModel_only
if (ExportDatesR == TRUE & ExportStateEnd == FALSE) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]); }
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs]) }
## OutputsModel_and_SateEnd_only
if (ExportDatesR == FALSE & ExportStateEnd == TRUE) {
OutputsModel <- c( lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c(FortranOutputs[IndOutputs], "StateEnd") }
## DatesR_and_OutputsModel_and_SateEnd
if ((ExportDatesR == TRUE & ExportStateEnd == TRUE) | "all" %in% RunOptions$Outputs_Sim) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(RESULTS$StateEnd) );
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd"); }
list(RESULTS$StateEnd) )
names(OutputsModel) <- c("DatesR", FortranOutputs[IndOutputs], "StateEnd") }
## End
rm(RESULTS);
class(OutputsModel) <- c("OutputsModel", "daily", "GR");
return(OutputsModel);
rm(RESULTS)
class(OutputsModel) <- c("OutputsModel", "daily", "GR")
return(OutputsModel)
}
......@@ -2,7 +2,7 @@ RunModel_GR6J <- function(InputsModel, RunOptions, Param) {
## Initialization of variables
NParam <- 6;
NParam <- 6
FortranOutputs <- .FortranOutputs(GR = "GR6J")$GR
......@@ -14,7 +14,7 @@ RunModel_GR6J <- function(InputsModel, RunOptions, Param) {
if (inherits(RunOptions, "GR" ) == FALSE) { stop("'RunOptions' must be of class 'GR' ") }
if (!is.vector(Param) | !is.numeric(Param)) { stop("'Param' must be a numeric vector") }
if (sum(!is.na(Param)) != NParam) { stop(paste("'Param' must be a vector of length ", NParam, " and contain no NA", sep = "")) }
Param <- as.double(Param);
Param <- as.double(Param)
Param_X1X3X6_threshold <- 1e-2
Param_X4_threshold <- 0.5
......@@ -36,21 +36,21 @@ RunModel_GR6J <- function(InputsModel, RunOptions, Param) {
}
## Input_data_preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL; }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run);
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) { RunOptions$IndPeriod_WarmUp <- NULL }
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs))
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim) }