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

v1.6.3.49 style: add spaces in RunModel_GR* functions

after "if"
before "{"
Refs #14
parent c1e540b4
Pipeline #17482 canceled with stages
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.3.48
Version: 1.6.3.49
Date: 2020-11-11
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -4,7 +4,7 @@
### 1.6.3.48 Release Notes (2020-11-11)
### 1.6.3.49 Release Notes (2020-11-11)
#### New features
......
RunModel_GR2M <- function(InputsModel,RunOptions,Param){
RunModel_GR2M <- function(InputsModel,RunOptions,Param) {
NParam <- 2;
FortranOutputs <- .FortranOutputs(GR = "GR2M")$GR
##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") }
if(inherits(InputsModel,"monthly" )==FALSE){ stop("'InputsModel' must be of class 'monthly' ") }
if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") }
if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") }
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="")) }
if (inherits(InputsModel,"InputsModel")==FALSE) { stop("'InputsModel' must be of class 'InputsModel'") }
if (inherits(InputsModel,"monthly" )==FALSE) { stop("'InputsModel' must be of class 'monthly' ") }
if (inherits(InputsModel,"GR" )==FALSE) { stop("'InputsModel' must be of class 'GR' ") }
if (inherits(RunOptions,"RunOptions" )==FALSE) { stop("'RunOptions' must be of class 'RunOptions' ") }
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_X1X2_threshold <- 1e-2
......@@ -24,10 +24,10 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){
}
##Input_data_preparation
if(identical(RunOptions$IndPeriod_WarmUp,as.integer(0))){ RunOptions$IndPeriod_WarmUp <- NULL; }
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));
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
##Output_data_preparation
......@@ -36,7 +36,7 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##Use_of_IniResLevels
if(!is.null(RunOptions$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)
}
......@@ -70,21 +70,21 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){
##Output_data_preparation
##OutputsModel_only
if(ExportDatesR==FALSE & ExportStateEnd==FALSE){
if (ExportDatesR==FALSE & ExportStateEnd==FALSE) {
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){
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]); }
##OutputsModel_and_SateEnd_only
if(ExportDatesR==FALSE & ExportStateEnd==TRUE){
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"); }
##DatesR_and_OutputsModel_and_SateEnd
if((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim){
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) );
......
RunModel_GR4H <- function(InputsModel,RunOptions,Param){
RunModel_GR4H <- function(InputsModel,RunOptions,Param) {
NParam <- 4;
FortranOutputs <- .FortranOutputs(GR = "GR4H")$GR
##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") }
if(inherits(InputsModel,"hourly" )==FALSE){ stop("'InputsModel' must be of class 'hourly' ") }
if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") }
if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") }
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="")) }
if (inherits(InputsModel,"InputsModel")==FALSE) { stop("'InputsModel' must be of class 'InputsModel'") }
if (inherits(InputsModel,"hourly" )==FALSE) { stop("'InputsModel' must be of class 'hourly' ") }
if (inherits(InputsModel,"GR" )==FALSE) { stop("'InputsModel' must be of class 'GR' ") }
if (inherits(RunOptions,"RunOptions" )==FALSE) { stop("'RunOptions' must be of class 'RunOptions' ") }
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_X1X3_threshold <- 1e-2
......@@ -29,10 +29,10 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){
}
##Input_data_preparation
if(identical(RunOptions$IndPeriod_WarmUp,as.integer(0))){ RunOptions$IndPeriod_WarmUp <- NULL; }
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));
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
##Output_data_preparation
......@@ -41,7 +41,7 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##Use_of_IniResLevels
if(!is.null(RunOptions$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)
}
......@@ -75,21 +75,21 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){
##Output_data_preparation
##OutputsModel_only
if(ExportDatesR==FALSE & ExportStateEnd==FALSE){
if (ExportDatesR==FALSE & ExportStateEnd==FALSE) {
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){
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]); }
##OutputsModel_and_SateEnd_only
if(ExportDatesR==FALSE & ExportStateEnd==TRUE){
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"); }
##DatesR_and_OutputsModel_and_SateEnd
if((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim){
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) );
......
RunModel_GR4J <- function(InputsModel,RunOptions,Param){
RunModel_GR4J <- function(InputsModel,RunOptions,Param) {
NParam <- 4;
FortranOutputs <- .FortranOutputs(GR = "GR4J")$GR
##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") }
if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") }
if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") }
if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") }
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="")) }
if (inherits(InputsModel,"InputsModel")==FALSE) { stop("'InputsModel' must be of class 'InputsModel'") }
if (inherits(InputsModel,"daily" )==FALSE) { stop("'InputsModel' must be of class 'daily' ") }
if (inherits(InputsModel,"GR" )==FALSE) { stop("'InputsModel' must be of class 'GR' ") }
if (inherits(RunOptions,"RunOptions" )==FALSE) { stop("'RunOptions' must be of class 'RunOptions' ") }
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_X1X3_threshold <- 1e-2
......@@ -29,10 +29,10 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param){
}
##Input_data_preparation
if(identical(RunOptions$IndPeriod_WarmUp,as.integer(0))){ RunOptions$IndPeriod_WarmUp <- NULL; }
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));
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;
......@@ -40,7 +40,7 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##Use_of_IniResLevels
if(!is.null(RunOptions$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)
}
......@@ -74,21 +74,21 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param){
##Output_data_preparation
##OutputsModel_only
if(ExportDatesR==FALSE & ExportStateEnd==FALSE){
if (ExportDatesR==FALSE & ExportStateEnd==FALSE) {
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){
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]); }
##OutputsModel_and_StateEnd_only
if(ExportDatesR==FALSE & ExportStateEnd==TRUE){
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"); }
##DatesR_and_OutputsModel_and_StateEnd
if((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim){
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) );
......
RunModel_GR5H <- function(InputsModel,RunOptions,Param){
RunModel_GR5H <- function(InputsModel,RunOptions,Param) {
NParam <- 5;
FortranOutputs <- .FortranOutputs(GR = "GR5H")$GR
IsIntStore <- inherits(RunOptions, "interception")
if(IsIntStore) {
if (IsIntStore) {
Imax <- RunOptions$Imax
} else {
Imax <- -99
}
##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") }
if(inherits(InputsModel,"hourly" )==FALSE){ stop("'InputsModel' must be of class 'hourly' ") }
if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") }
if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") }
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="")) }
if (inherits(InputsModel,"InputsModel")==FALSE) { stop("'InputsModel' must be of class 'InputsModel'") }
if (inherits(InputsModel,"hourly" )==FALSE) { stop("'InputsModel' must be of class 'hourly' ") }
if (inherits(InputsModel,"GR" )==FALSE) { stop("'InputsModel' must be of class 'GR' ") }
if (inherits(RunOptions,"RunOptions" )==FALSE) { stop("'RunOptions' must be of class 'RunOptions' ") }
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_X1X3_threshold <- 1e-2
......@@ -35,10 +35,10 @@ RunModel_GR5H <- function(InputsModel,RunOptions,Param){
}
##Input_data_preparation
if(identical(RunOptions$IndPeriod_WarmUp,as.integer(0))){ RunOptions$IndPeriod_WarmUp <- NULL; }
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));
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
##Output_data_preparation
......@@ -47,10 +47,10 @@ RunModel_GR5H <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##Use_of_IniResLevels
if(!is.null(RunOptions$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)
if(IsIntStore) {
if (IsIntStore) {
RunOptions$IniStates[4] <- RunOptions$IniResLevels[4] * Imax; ### interception store level (mm)
}
}
......@@ -86,21 +86,21 @@ RunModel_GR5H <- function(InputsModel,RunOptions,Param){
##Output_data_preparation
##OutputsModel_only
if(ExportDatesR==FALSE & ExportStateEnd==FALSE){
if (ExportDatesR==FALSE & ExportStateEnd==FALSE) {
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){
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]); }
##OutputsModel_and_StateEnd_only
if(ExportDatesR==FALSE & ExportStateEnd==TRUE){
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"); }
##DatesR_and_OutputsModel_and_StateEnd
if((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim){
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) );
......@@ -109,7 +109,7 @@ RunModel_GR5H <- function(InputsModel,RunOptions,Param){
##End
rm(RESULTS);
class(OutputsModel) <- c("OutputsModel","hourly","GR");
if(IsIntStore) {
if (IsIntStore) {
class(OutputsModel) <- c(class(OutputsModel), "interception")
}
return(OutputsModel);
......
RunModel_GR5J <- function(InputsModel,RunOptions,Param){
RunModel_GR5J <- function(InputsModel,RunOptions,Param) {
NParam <- 5;
FortranOutputs <- .FortranOutputs(GR = "GR5J")$GR
##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") }
if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") }
if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") }
if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") }
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="")) }
if (inherits(InputsModel,"InputsModel")==FALSE) { stop("'InputsModel' must be of class 'InputsModel'") }
if (inherits(InputsModel,"daily" )==FALSE) { stop("'InputsModel' must be of class 'daily' ") }
if (inherits(InputsModel,"GR" )==FALSE) { stop("'InputsModel' must be of class 'GR' ") }
if (inherits(RunOptions,"RunOptions" )==FALSE) { stop("'RunOptions' must be of class 'RunOptions' ") }
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_X1X3_threshold <- 1e-2
......@@ -29,10 +29,10 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param){
}
##Input_data_preparation
if(identical(RunOptions$IndPeriod_WarmUp,as.integer(0))){ RunOptions$IndPeriod_WarmUp <- NULL; }
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));
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
##Output_data_preparation
......@@ -41,7 +41,7 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##Use_of_IniResLevels
if(!is.null(RunOptions$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)
}
......@@ -75,21 +75,21 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param){
##Output_data_preparation
##OutputsModel_only
if(ExportDatesR==FALSE & ExportStateEnd==FALSE){
if (ExportDatesR==FALSE & ExportStateEnd==FALSE) {
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){
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]); }
##OutputsModel_and_SateEnd_only
if(ExportDatesR==FALSE & ExportStateEnd==TRUE){
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"); }
##DatesR_and_OutputsModel_and_SateEnd
if((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim){
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) );
......
RunModel_GR6J <- function(InputsModel,RunOptions,Param){
RunModel_GR6J <- function(InputsModel,RunOptions,Param) {
NParam <- 6;
FortranOutputs <- .FortranOutputs(GR = "GR6J")$GR
##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") }
if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") }
if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") }
if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") }
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="")) }
if (inherits(InputsModel,"InputsModel")==FALSE) { stop("'InputsModel' must be of class 'InputsModel'") }
if (inherits(InputsModel,"daily" )==FALSE) { stop("'InputsModel' must be of class 'daily' ") }
if (inherits(InputsModel,"GR" )==FALSE) { stop("'InputsModel' must be of class 'GR' ") }
if (inherits(RunOptions,"RunOptions" )==FALSE) { stop("'RunOptions' must be of class 'RunOptions' ") }
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_X1X3X6_threshold <- 1e-2
......@@ -33,10 +33,10 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param){
}
##Input_data_preparation
if(identical(RunOptions$IndPeriod_WarmUp,as.integer(0))){ RunOptions$IndPeriod_WarmUp <- NULL; }
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));
if ("all" %in% RunOptions$Outputs_Sim) { IndOutputs <- as.integer(1:length(FortranOutputs));
} else { IndOutputs <- which(FortranOutputs %in% RunOptions$Outputs_Sim); }
##Output_data_preparation
......@@ -45,7 +45,7 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##Use_of_IniResLevels
if(!is.null(RunOptions$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[3] <- RunOptions$IniResLevels[3] ### exponential store level (mm)
......@@ -80,21 +80,21 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param){
##Output_data_preparation
##OutputsModel_only
if(ExportDatesR==FALSE & ExportStateEnd==FALSE){
if (ExportDatesR==FALSE & ExportStateEnd==FALSE) {
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){
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]); }
##OutputsModel_and_SateEnd_only
if(ExportDatesR==FALSE & ExportStateEnd==TRUE){
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"); }
##DatesR_and_OutputsModel_and_SateEnd
if((ExportDatesR==TRUE & ExportStateEnd==TRUE) | "all" %in% RunOptions$Outputs_Sim){
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) );
......
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