Commit 2be91ef1 authored by unknown's avatar unknown
Browse files

#4445 Coerce NLayers to be of integer type in CreateInputsModel

Showing with 9 additions and 5 deletions
+9 -5
......@@ -35,7 +35,7 @@ CreateInputsModel <- function(FUN_MOD,DatesR,Precip,PotEvap=NULL,TempMean=NULL,T
BOOL <- TRUE
}
if(!BOOL) {
stop("incorrect FUN_MOD for use in CreateInputsModel \n")
stop("Incorrect FUN_MOD for use in CreateInputsModel \n")
return(NULL)
}
......@@ -87,7 +87,11 @@ CreateInputsModel <- function(FUN_MOD,DatesR,Precip,PotEvap=NULL,TempMean=NULL,T
if(NLayers <= 0) {
stop("NLayers must be a positive integer value \n")
return(NULL)
}
}
if(NLayers != as.integer(NLayers)) {
warning("Coerce NLayers to be of integer type (", NLayers, " => ", as.integer(NLayers), ")")
NLayers <- as.integer(NLayers)
}
}
......@@ -108,14 +112,14 @@ CreateInputsModel <- function(FUN_MOD,DatesR,Precip,PotEvap=NULL,TempMean=NULL,T
WTxt <- NULL;
WTxt <- paste(WTxt,"\t Missing values are not allowed in InputsModel \n",sep="");
Select <- (max(which(BOOL_NA))+1):length(BOOL_NA);
if(Select[1L]>Select[2L]) { stop(paste("time series could not be trunced since missing values were detected at the list time-step \n",sep="")); return(NULL); }
if(Select[1L]>Select[2L]) { stop("Time series could not be trunced since missing values were detected at the list time-step"); return(NULL); }
if("GR" %in% ObjectClass) {
Precip <- Precip[Select]; PotEvap <- PotEvap[Select]; }
if("CemaNeige" %in% ObjectClass) {
Precip <- Precip[Select]; TempMean <- TempMean[Select]; if(!is.null(TempMin) & !is.null(TempMax)) { TempMin <- TempMin[Select]; TempMax <- TempMax[Select]; } }
DatesR <- DatesR[Select];
WTxt <- paste(WTxt,"\t -> data were trunced to keep the most recent available time-steps \n",sep="");
WTxt <- paste(WTxt,"\t -> ",length(Select)," time-steps were kept \n",sep="");
WTxt <- paste(WTxt,"\t -> Data were trunced to keep the most recent available time-steps \n",sep="");
WTxt <- paste(WTxt,"\t -> ", length(Select), " time-steps were kept \n",sep="");
if(!is.null(WTxt) & verbose) { warning(WTxt); }
}
......
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