From ec27c27cba60d90e456fd1385357725b9153127e Mon Sep 17 00:00:00 2001 From: Delaigue Olivier <olivier.delaigue@irstea.fr> Date: Wed, 11 Nov 2020 15:04:22 +0100 Subject: [PATCH] v1.6.3.52 style: add spaces around equal sign in RunModel_GR* functionss Refs #14 --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/RunModel_GR2M.R | 40 ++++++++++++++++++------------------- R/RunModel_GR4H.R | 48 ++++++++++++++++++++++----------------------- R/RunModel_GR4J.R | 48 ++++++++++++++++++++++----------------------- R/RunModel_GR5H.R | 50 +++++++++++++++++++++++------------------------ R/RunModel_GR5J.R | 48 ++++++++++++++++++++++----------------------- R/RunModel_GR6J.R | 48 ++++++++++++++++++++++----------------------- 8 files changed, 143 insertions(+), 143 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3f755b76..e949a975 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.6.3.51 +Version: 1.6.3.52 Date: 2020-11-11 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.md b/NEWS.md index 72b585ff..0ff11b94 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ -### 1.6.3.51 Release Notes (2020-11-11) +### 1.6.3.52 Release Notes (2020-11-11) #### New features diff --git a/R/RunModel_GR2M.R b/R/RunModel_GR2M.R index fa0a1d6f..a40a4966 100644 --- a/R/RunModel_GR2M.R +++ b/R/RunModel_GR2M.R @@ -7,13 +7,13 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param) { ## 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 (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 (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 @@ -45,23 +45,23 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param) { } ## Call_fortan - RESULTS <- .Fortran("frun_gr2M",PACKAGE="airGR", + RESULTS <- .Fortran("frun_gr2M",PACKAGE = "airGR", ## inputs - LInputs=LInputSeries, ### length of input and output series - InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/month] - InputsPE=InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/month] - 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 - NOutputs=as.integer(length(IndOutputs)), ### number of output series - IndOutputs=IndOutputs, ### indices of output series + LInputs = LInputSeries, ### length of input and output series + InputsPrecip = InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/month] + InputsPE = InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/month] + 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 + 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] + 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, diff --git a/R/RunModel_GR4H.R b/R/RunModel_GR4H.R index 6b2b55a0..7cbe925a 100644 --- a/R/RunModel_GR4H.R +++ b/R/RunModel_GR4H.R @@ -7,13 +7,13 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param) { ## 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 (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 (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 @@ -50,23 +50,23 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param) { } ## Call_fortan - RESULTS <- .Fortran("frun_gr4h",PACKAGE="airGR", + RESULTS <- .Fortran("frun_gr4h",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 - NOutputs=as.integer(length(IndOutputs)), ### number of output series - IndOutputs=IndOutputs, ### indices of output series + 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 + 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] + 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, @@ -78,21 +78,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) ); diff --git a/R/RunModel_GR4J.R b/R/RunModel_GR4J.R index 0bcade5f..4ba3dac3 100644 --- a/R/RunModel_GR4J.R +++ b/R/RunModel_GR4J.R @@ -7,13 +7,13 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param) { ## 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 (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 (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 @@ -49,23 +49,23 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param) { } ## Call_fortan - RESULTS <- .Fortran("frun_gr4j",PACKAGE="airGR", + RESULTS <- .Fortran("frun_gr4j",PACKAGE = "airGR", ## inputs - LInputs=LInputSeries, ### length of input and output series - InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/d] - InputsPE=InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/d] - 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 - NOutputs=as.integer(length(IndOutputs)), ### number of output series - IndOutputs=IndOutputs, ### indices of output series + LInputs = LInputSeries, ### length of input and output series + InputsPrecip = InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/d] + InputsPE = InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/d] + 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 + 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] + 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, @@ -77,21 +77,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) ); diff --git a/R/RunModel_GR5H.R b/R/RunModel_GR5H.R index f57c6b74..c6ec844a 100644 --- a/R/RunModel_GR5H.R +++ b/R/RunModel_GR5H.R @@ -13,13 +13,13 @@ RunModel_GR5H <- function(InputsModel,RunOptions,Param) { ## 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 (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 (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 @@ -59,24 +59,24 @@ RunModel_GR5H <- function(InputsModel,RunOptions,Param) { } ## Call_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(IndOutputs)), ### number of output series - IndOutputs=IndOutputs, ### indices of output series + 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(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 or mm/h] - 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 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, @@ -89,21 +89,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) ); diff --git a/R/RunModel_GR5J.R b/R/RunModel_GR5J.R index e7d4f474..e1b9a85a 100644 --- a/R/RunModel_GR5J.R +++ b/R/RunModel_GR5J.R @@ -7,13 +7,13 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param) { ## 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 (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 (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 @@ -50,23 +50,23 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param) { } ## Call_fortan - RESULTS <- .Fortran("frun_gr5j",PACKAGE="airGR", + RESULTS <- .Fortran("frun_gr5j",PACKAGE = "airGR", ## inputs - LInputs=LInputSeries, ### length of input and output series - InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/d] - InputsPE=InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/d] - 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 - NOutputs=as.integer(length(IndOutputs)), ### number of output series - IndOutputs=IndOutputs, ### indices of output series + LInputs = LInputSeries, ### length of input and output series + InputsPrecip = InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/d] + InputsPE = InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/d] + 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 + 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] + 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, @@ -78,21 +78,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) ); diff --git a/R/RunModel_GR6J.R b/R/RunModel_GR6J.R index 19bdac99..9b98e18e 100644 --- a/R/RunModel_GR6J.R +++ b/R/RunModel_GR6J.R @@ -7,13 +7,13 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param) { ## 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 (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 (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 @@ -55,23 +55,23 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param) { } ## Call_fortan - RESULTS <- .Fortran("frun_gr6j",PACKAGE="airGR", + RESULTS <- .Fortran("frun_gr6j",PACKAGE = "airGR", ## inputs - LInputs=LInputSeries, ### length of input and output series - InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/d] - InputsPE=InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/d] - 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 - NOutputs=as.integer(length(IndOutputs)), ### number of output series - IndOutputs=IndOutputs, ### indices of output series + LInputs = LInputSeries, ### length of input and output series + InputsPrecip = InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/d] + InputsPE = InputsModel$PotEvap[IndPeriod1], ### input series potential evapotranspiration [mm/d] + 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 + 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] + 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_GR6J, InputsModel = InputsModel, @@ -83,21 +83,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) ); -- GitLab