CreateRunOptions.R 20.94 KiB
CreateRunOptions <- function(FUN_MOD, InputsModel,
                             IndPeriod_WarmUp = NULL, IndPeriod_Run,
                             IniStates = NULL, IniResLevels = NULL, Imax = NULL,
                             Outputs_Cal = NULL, Outputs_Sim = "all",
                             MeanAnSolidPrecip = NULL, IsHyst = FALSE,
                             warnings = TRUE, verbose = TRUE) {
  if (!is.null(Imax)) {
    if (!is.numeric(Imax) | length(Imax) != 1L) {
      stop("'Imax' must be a non negative 'numeric' value of length 1")
    } else {
      if (Imax < 0) {
        stop("'Imax' must be a non negative 'numeric' value of length 1")
    IsIntStore <- TRUE
  } else {
    IsIntStore <- FALSE
  ObjectClass <- NULL
  FUN_MOD <- match.fun(FUN_MOD)
  ##check_FUN_MOD
  BOOL <- FALSE
  if (identical(FUN_MOD, RunModel_GR4H) | identical(FUN_MOD, RunModel_GR5H)) {
    ObjectClass <- c(ObjectClass, "GR", "hourly")
    BOOL <- TRUE
  if (identical(FUN_MOD, RunModel_GR4J) | identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_GR6J)) {
    ObjectClass <- c(ObjectClass, "GR", "daily")
    BOOL <- TRUE
  if (identical(FUN_MOD, RunModel_GR2M)) {
    ObjectClass <- c(ObjectClass, "GR", "monthly")
    BOOL <- TRUE
  if (identical(FUN_MOD, RunModel_GR1A)) {
    ObjectClass <- c(ObjectClass, "GR", "yearly")
    BOOL <- TRUE
  if (identical(FUN_MOD, RunModel_CemaNeige)) {
    ObjectClass <- c(ObjectClass, "CemaNeige", "daily")
    BOOL <- TRUE
  if (identical(FUN_MOD, RunModel_CemaNeigeGR4J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) {
    ObjectClass <- c(ObjectClass, "GR", "CemaNeige", "daily")
    BOOL <- TRUE
  if (identical(FUN_MOD, RunModel_CemaNeigeGR4H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) {
    ObjectClass <- c(ObjectClass, "GR", "CemaNeige", "hourly")
    BOOL <- TRUE
  if (IsIntStore) {
    ObjectClass <- c(ObjectClass, "interception")
  if (IsHyst) {
    ObjectClass <- c(ObjectClass, "hysteresis")
  if (!BOOL) {
    stop("incorrect 'FUN_MOD' for use in 'CreateRunOptions'")
  if (!"CemaNeige" %in% ObjectClass & "hysteresis" %in% ObjectClass) {
    stop("'IsHyst' cannot be TRUE for the chosen 'FUN_MOD'")
  if (!(identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) & "interception" %in% ObjectClass) {
    stop("'IMax' cannot be set for the chosen 'FUN_MOD'")