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

v1.6.3.52 style: add spaces around equal sign in RunModel_GR* functionss

Refs #14
parent 29d64e4e
Pipeline #17485 failed with stages
in 2 seconds
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")),
......
......@@ -4,7 +4,7 @@
### 1.6.3.51 Release Notes (2020-11-11)
### 1.6.3.52 Release Notes (2020-11-11)
#### New features
......
......@@ -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,
......
......@@ -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) );
......
......@@ -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) );
......
......@@ -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) );
......
......@@ -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) );
......
......@@ -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) );
......
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