Commit 52bb6523 authored by David's avatar David
Browse files

fix(RunModel.GRiwrmOutputsModel): check issues

- NAs in IniStates
- Documentation warning
Showing with 6 additions and 3 deletions
+6 -3
......@@ -41,7 +41,8 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel,
DatesR = getNextTimeSteps(OutputsModel),
Qinf = NULL,
Qrelease = NULL,
Qmin = NULL) {
Qmin = NULL,
...) {
stopifnot(inherits(OutputsModel, "GRiwrmOutputsModel"),
inherits(InputsModel, "GRiwrmInputsModel"),
inherits(RunOptions, "GRiwrmRunOptions"))
......
......@@ -43,6 +43,9 @@ RunModel.InputsModel <- function(x = NULL,
}
}
# Avoiding Error in `FUN_MOD(x, RunOptions, Param)`: NA/NaN/Inf in foreign function call (arg 7)
RunOptions$IniStates[is.na(RunOptions$IniStates)] <- 0
FUN_MOD <- match.fun(FUN_MOD)
if (identical(FUN_MOD, RunModel_Lag)) {
OutputsModel <- RunModel_Routing(x, RunOptions, Param)
......
......@@ -62,7 +62,6 @@ OutputsModelQsim <- function(InputsModel, OutputsModel, IndPeriod_Run) {
#'
serializeIniStates <- function(IniStates) {
IniStates <- unlist(IniStates)
IniStates[is.na(IniStates)] <- 0
return(IniStates)
}
......@@ -109,4 +108,4 @@ getNextTimeSteps <- function(OutputsModel, TimeStep = 1L) {
last_date <- dplyr::last(OutputsModel[[1]]$DatesR)
first_date <- last_date + attr(OutputsModel, "TimeStep")
return(seq(first_date, length.out = TimeStep, by = attr(OutputsModel, "TimeStep")))
}
}
Supports Markdown
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