CreateRunOptions.R 18.8 KB
Newer Older
1
2
CreateRunOptions <- function(FUN_MOD, InputsModel,
                             IndPeriod_WarmUp = NULL, IndPeriod_Run,
3
                             IniStates = NULL, IniResLevels = NULL, Imax = NULL,
4
                             Outputs_Cal = NULL, Outputs_Sim = "all",
5
                             MeanAnSolidPrecip = NULL, IsHyst = FALSE,
6
                             warnings = TRUE, verbose = TRUE) {
7

8
  if (!is.null(Imax)) {
9
    if (!is.numeric(Imax) | length(Imax) != 1L) {
10
11
      stop("'Imax' must be a non negative 'numeric' value of length 1")
    } else {
12
13
14
      if (Imax < 0) {
        stop("'Imax' must be a non negative 'numeric' value of length 1")
      }
15
    }
16
17
18
    IsIntStore <- TRUE
  } else {
    IsIntStore <- FALSE
19
  }
20
21

  ## check FUN_MOD
22
  FUN_MOD <- match.fun(FUN_MOD)
23
24
25
26
  FeatFUN_MOD <- .GetFeatModel(FUN_MOD = FUN_MOD, DatesR = InputsModel$DatesR)
  ObjectClass <- FeatFUN_MOD$Class
  TimeStepMean <- FeatFUN_MOD$TimeStepMean

27
  ## Model output variable list
28
29
  FortranOutputs <- .FortranOutputs(GR = FeatFUN_MOD$CodeModHydro,
                                    isCN = "CemaNeige" %in% FeatFUN_MOD$Class)
30

31
32
33
34
35
36
  ## manage class
  if (IsIntStore) {
    ObjectClass <- c(ObjectClass, "interception")
  }
  if (IsHyst) {
    ObjectClass <- c(ObjectClass, "hysteresis")
37
    FeatFUN_MOD$IsHyst <- IsHyst
38
    FeatFUN_MOD$NbParam <- FeatFUN_MOD$NbParam + 2
39
40
  }

41
42
43
44
45
46
  ## SD model
  FeatFUN_MOD$IsSD <- inherits(InputsModel, "SD")
  if (FeatFUN_MOD$IsSD) {
    FeatFUN_MOD$NbParam <- FeatFUN_MOD$NbParam + 1
  }

47
48
49
  if (!"CemaNeige" %in% ObjectClass & "hysteresis" %in% ObjectClass) {
    stop("'IsHyst' cannot be TRUE for the chosen 'FUN_MOD'")
  }
50
  if (!(identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) & "interception" %in% ObjectClass) {
51
    stop("'IMax' cannot be set for the chosen 'FUN_MOD'")
52
  }
53

Delaigue Olivier's avatar
Delaigue Olivier committed
54
  ##check_InputsModel
55
  if (!inherits(InputsModel, "InputsModel")) {
56
    stop("'InputsModel' must be of class 'InputsModel'")
57
58
  }
  if ("GR" %in% ObjectClass & !inherits(InputsModel, "GR")) {
59
    stop("'InputsModel' must be of class 'GR'")
60
61
62
  }
  if ("CemaNeige" %in% ObjectClass &
      !inherits(InputsModel, "CemaNeige")) {
63
    stop("'InputsModel' must be of class 'CemaNeige'")
64
65
66
  }
  if ("hourly" %in% ObjectClass &
      !inherits(InputsModel, "hourly")) {
67
    stop("'InputsModel' must be of class 'hourly'")
68
69
  }
  if ("daily" %in% ObjectClass & !inherits(InputsModel, "daily")) {
70
    stop("'InputsModel' must be of class 'daily'")
71
72
73
  }
  if ("monthly" %in% ObjectClass &
      !inherits(InputsModel, "monthly")) {
74
    stop("'InputsModel' must be of class 'monthly'")
75
76
77
  }
  if ("yearly" %in% ObjectClass &
      !inherits(InputsModel, "yearly")) {
78
    stop("'InputsModel' must be of class 'yearly'")
79
  }
80
81


Delaigue Olivier's avatar
Delaigue Olivier committed
82
  ##check_IndPeriod_Run
83
  if (!is.vector(IndPeriod_Run)) {
84
    stop("'IndPeriod_Run' must be a vector of numeric values")
85
86
  }
  if (!is.numeric(IndPeriod_Run)) {
87
    stop("'IndPeriod_Run' must be a vector of numeric values")
88
  }
89
  if (!identical(as.integer(IndPeriod_Run), as.integer(seq(from = IndPeriod_Run[1], to = tail(IndPeriod_Run, 1), by = 1)))) {
90
    stop("'IndPeriod_Run' must be a continuous sequence of integers")
91
92
  }
  if (storage.mode(IndPeriod_Run) != "integer") {
93
    stop("'IndPeriod_Run' should be of type integer")
94
  }
95
96


Delaigue Olivier's avatar
Delaigue Olivier committed
97
  ##check_IndPeriod_WarmUp
98
99
  WTxt <- NULL
  if (is.null(IndPeriod_WarmUp)) {
100
    WTxt <- paste(WTxt, "model warm up period not defined: default configuration used", sep = "")
101
    ##If_the_run_period_starts_at_the_very_beginning_of_the_time_series
102
    if (IndPeriod_Run[1L] == 1L) {
103
      IndPeriod_WarmUp <- 0L
104
      WTxt <- paste0(WTxt,"\n no data were found for model warm up!")
Delaigue Olivier's avatar
Delaigue Olivier committed
105
      ##We_look_for_the_longest_period_preceeding_the_run_period_with_a_maximum_of_one_year
106
107
108
109
110
111
112
    } else {
      TmpDateR0 <- InputsModel$DatesR[IndPeriod_Run[1]]
      TmpDateR  <- TmpDateR0 - 365 * 24 * 60 * 60
      ### minimal date to start the warmup
      if (format(TmpDateR, format = "%d") != format(TmpDateR0, format = "%d")) {
        ### leap year
        TmpDateR <- TmpDateR - 1 * 24 * 60 * 60
Delaigue Olivier's avatar
Delaigue Olivier committed
113
      }
114
      IndPeriod_WarmUp <- which(InputsModel$DatesR == max(InputsModel$DatesR[1], TmpDateR)):(IndPeriod_Run[1] - 1)
115
      if (length(IndPeriod_WarmUp) * TimeStepMean / (365 * 24 * 60 * 60) >= 1) {
116
        WTxt <- paste0(WTxt, "\n  the year preceding the run period is used \n")
117
      } else {
118
119
        WTxt <- paste0(WTxt, "\n  less than a year (without missing values) was found for model warm up:")
        WTxt <- paste0(WTxt, "\n  (", length(IndPeriod_WarmUp), " time-steps are used for initialisation)")
120
      }
121
122
123
124
    }
  }
  if (!is.null(IndPeriod_WarmUp)) {
    if (!is.vector(IndPeriod_WarmUp)) {
125
      stop("'IndPeriod_WarmUp' must be a vector of numeric values")
126
127
    }
    if (!is.numeric(IndPeriod_WarmUp)) {
128
      stop("'IndPeriod_WarmUp' must be a vector of numeric values")
129
130
    }
    if (storage.mode(IndPeriod_WarmUp) != "integer") {
131
      stop("'IndPeriod_WarmUp' should be of type integer")
132
    }
133
    if (identical(IndPeriod_WarmUp, 0L) & verbose) {
134
      message(paste0(WTxt, " No warm up period is used"))
135
    }
136
    if ((IndPeriod_Run[1] - 1) != tail(IndPeriod_WarmUp, 1) & !identical(IndPeriod_WarmUp, 0L)) {
137
      WTxt <- paste0(WTxt, " Model warm up period is not directly before the model run period")
138
139
    }
  }
140
  if (!is.null(WTxt) & warnings) {
141
142
    warning(WTxt)
  }
143
144
145


  ## check IniResLevels
146
147
  if ("GR" %in% ObjectClass & ("monthly" %in% ObjectClass | "daily" %in% ObjectClass | "hourly" %in% ObjectClass)) {
    if (!is.null(IniResLevels)) {
148
      # if (!is.vector(IniResLevels) | !is.numeric(IniResLevels) | any(is.na(IniResLevels))) {
149
      if (!is.vector(IniResLevels) | is.character(IniResLevels) | is.factor(IniResLevels) | length(IniResLevels) != 4) {
150
        stop("'IniResLevels' must be a vector of 4 numeric values")
Delaigue Olivier's avatar
Delaigue Olivier committed
151
      }
152
153
      # if ((identical(FUN_MOD, RunModel_GR4H) | identical(FUN_MOD, RunModel_CemaNeigeGR4H) |
      #      # (identical(FUN_MOD, RunModel_GR5H) & !IsIntStore) |
154
      #      identical(FUN_MOD, RunModel_GR5H) |
155
156
157
158
159
      #      identical(FUN_MOD, RunModel_GR4J) | identical(FUN_MOD, RunModel_CemaNeigeGR4J) |
      #      identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) |
      #      identical(FUN_MOD, RunModel_GR2M)) &
      #     length(IniResLevels) != 2) {
      #   stop("the length of 'IniResLevels' must be 2 for the chosen 'FUN_MOD'")
160
      # }
161
162
      if (any(is.na(IniResLevels[1:2]))) {
        stop("the first 2 values of 'IniResLevels' cannot be missing values for the chosen 'FUN_MOD'")
163
      }
164
      # if ((identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J) |
165
166
167
      #      (identical(FUN_MOD, RunModel_GR5H) & IsIntStore)) &
      #     length(IniResLevels) != 3) {
      #   stop("the length of 'IniResLevels' must be 3 for the chosen 'FUN_MOD'")
168
      # }
169
      if ((identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J))) {
170
        if (is.na(IniResLevels[3L])) {
171
172
173
174
175
176
177
          stop("the third value of 'IniResLevels' cannot be a missing value for the chosen 'FUN_MOD'")
        }
      } else {
        if (!is.na(IniResLevels[3L])) {
          warning("the third value of 'IniResLevels' is set to NA value for the chosen 'FUN_MOD'. Only GR6J presents an exponential store")
          IniResLevels[3L] <- NA
        }
178
      }
179
      if (identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) {
180
        if (IsIntStore & is.na(IniResLevels[4L])) {
181
          stop("the fourth value of 'IniResLevels' cannot be a missing value for the chosen 'FUN_MOD' (GR5H with an interception store)")
182
        }
183
        if (!IsIntStore & !is.na(IniResLevels[4L])) {
184
          warning("the fourth value of 'IniResLevels' is set to NA value for the chosen 'FUN_MOD'. Only GR5H used with an 'Imax' value presents an interception store")
185
186
187
          IniResLevels[4L] <- NA
        }
      } else {
188
        if (!is.na(IniResLevels[4L])) {
189
          warning("the fourth value of 'IniResLevels' is set to NA value for the chosen 'FUN_MOD'. Only GR5H used with an 'Imax' value presents an interception store")
190
191
          IniResLevels[4L] <- NA
        }
192
      }
193
    } else if (is.null(IniStates)) {
194
      IniResLevels <- as.double(c(0.3, 0.5, NA, NA))
195
      if (identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) {
196
197
        IniResLevels <- as.double(c(0.3, 0.5, 0, NA))
      }
198
      if ((identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) & IsIntStore) {
199
200
        IniResLevels <- as.double(c(0.3, 0.5, NA, 0))
      }
201
202
      # if (!identical(FUN_MOD, RunModel_GR6J) & !identical(FUN_MOD, RunModel_CemaNeigeGR6J) &
      #     !identical(FUN_MOD, RunModel_GR5H) & !identical(FUN_MOD, RunModel_CemaNeigeGR5H)) {
203
      # if (is.null(IniStates)) {
204
205
      #   IniResLevels <- as.double(c(0.3, 0.5, NA, NA))
      # }
Delaigue Olivier's avatar
Delaigue Olivier committed
206
    }
207
208
  } else {
    if (!is.null(IniResLevels)) {
209
      stop("'IniResLevels' can only be used with monthly or daily or hourly GR models")
210
211
212
    }
  }
  ## check IniStates
213
  if (is.null(IniStates) & is.null(IniResLevels) & warnings) {
214
    warning("model states initialisation not defined: default configuration used")
215
  }
216
  if (!is.null(IniStates) & !is.null(IniResLevels) & warnings) {
217
    warning("'IniStates' and 'IniResLevels' are both defined: store levels are taken from 'IniResLevels'")
218
219
220
221
222
223
224
225
226
  }
  if ("CemaNeige" %in% ObjectClass) {
    NLayers <- length(InputsModel$LayerPrecip)
  } else {
    NLayers <- 0
  }
  NState <- NULL
  if ("GR" %in% ObjectClass | "CemaNeige" %in% ObjectClass) {
    if ("hourly"  %in% ObjectClass) {
227
      NState <- 7 + 3 * 24 * 20 + 4 * NLayers
228
229
    }
    if ("daily"   %in% ObjectClass) {
230
      NState <- 7 + 3 * 20 + 4 * NLayers
231
232
233
234
235
236
237
238
239
    }
    if ("monthly" %in% ObjectClass) {
      NState <- 2
    }
    if ("yearly"  %in% ObjectClass) {
      NState <- 1
    }
  }
  if (!is.null(IniStates)) {
240

241
    if (!inherits(IniStates, "IniStates")) {
242
      stop("'IniStates' must be an object of class 'IniStates'")
243
244
    }
    if (sum(ObjectClass %in% class(IniStates)) < 2) {
245
      stop(paste0("non convenient 'IniStates' for the chosen 'FUN_MOD'"))
246
247
    }
    if (identical(FUN_MOD, RunModel_GR1A) & !is.null(IniStates)) { ## GR1A
248
      stop(paste0("'IniStates' is not available for the chosen 'FUN_MOD'"))
249
    }
250
251
    if ((identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) |
         identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) &
252
        !all(is.na(IniStates$UH$UH1))) { ## GR5J or GR5H
253
      stop(paste0("non convenient 'IniStates' for the chosen 'FUN_MOD'.' In 'IniStates', 'UH1' has to be a vector of NA for GR5J"))
254
255
    }
    if ((identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) & is.na(IniStates$Store$Exp)) { ## GR6J
256
      stop(paste0("non convenient 'IniStates' for the chosen 'FUN_MOD'.' GR6J needs an exponential store value in 'IniStates'"))
257
    }
258
    if ((identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) & is.na(IniStates$Store$Int)) { ## GR5H interception
259

260
261
      stop(paste0("non convenient 'IniStates' for the chosen 'FUN_MOD'.' GR5H (with interception store) needs an interception store value in 'IniStates'"))
    }
262
    if (!(identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) & !is.na(IniStates$Store$Exp)) { ## except GR6J
263
      stop(paste0("non convenient 'IniStates' for the chosen 'FUN_MOD'.' No exponential store value needed in 'IniStates'"))
264
    }
265
    if (!(identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) & !is.na(IniStates$Store$Int)) { ## except GR5H interception
266
267
      stop(paste0("non convenient 'IniStates' for the chosen 'FUN_MOD'.' No interception store value needed in 'IniStates'"))
    }
268
    # if (length(na.omit(unlist(IniStates))) != NState) {
269
    #   stop(paste0("the length of IniStates must be ", NState, " for the chosen FUN_MOD"))
270
    # }
271
    if ((!"CemaNeige" %in% ObjectClass &  inherits(IniStates, "CemaNeige")) |
272
273
274
275
276
277
278
        ( "CemaNeige" %in% ObjectClass & !inherits(IniStates, "CemaNeige"))) {
      stop("'FUN_MOD' and 'IniStates' must be both of class 'CemaNeige'")
    }
    if (( "hysteresis" %in% ObjectClass & !inherits(IniStates, "hysteresis")) |
        (!"hysteresis" %in% ObjectClass &  inherits(IniStates, "hysteresis"))) {
      stop("'IsHyst' and 'IniStates' are not consistent on the use of the hysteresis")
    }
279
    if (!"CemaNeige" %in% ObjectClass & any(is.na(IniStates$CemaNeigeLayers$G  ))) {
280
      IniStates$CemaNeigeLayers$G <- NULL
281
282
283
284
    }
    if (!"CemaNeige" %in% ObjectClass & any(is.na(IniStates$CemaNeigeLayers$eTG))) {
      IniStates$CemaNeigeLayers$eTG <- NULL
    }
285
286
287
288
289
290
    if (!"CemaNeige" %in% ObjectClass & any(is.na(IniStates$CemaNeigeLayers$Gthr))) {
      IniStates$CemaNeigeLayers$Gthr <- NULL
    }
    if (!"CemaNeige" %in% ObjectClass & any(is.na(IniStates$CemaNeigeLayers$Glocmax))) {
      IniStates$CemaNeigeLayers$Glocmax <- NULL
    }
291
    IniStates$Store$Rest <- rep(NA, 3)
292
293
294
295
296
297
298
299
    IniStates <- unlist(IniStates)
    IniStates[is.na(IniStates)] <- 0
    if ("monthly" %in% ObjectClass) {
      IniStates <- IniStates[seq_len(NState)]
    }
  } else {
    IniStates <- as.double(rep(0.0, NState))
  }
300
301


Delaigue Olivier's avatar
Delaigue Olivier committed
302
  ##check_Outputs_Cal_and_Sim
303

304
  ##Outputs_all
305
  Outputs_all <- c("DatesR", unlist(FortranOutputs), "WarmUpQsim", "StateEnd", "Param")
306

307
308
  ##check_Outputs_Sim
  if (!is.vector(Outputs_Sim)) {
309
    stop("'Outputs_Sim' must be a vector of characters")
310
311
  }
  if (!is.character(Outputs_Sim)) {
312
    stop("'Outputs_Sim' must be a vector of characters")
313
314
  }
  if (sum(is.na(Outputs_Sim)) != 0) {
315
    stop("'Outputs_Sim' must not contain NA")
316
317
  }
  if ("all" %in% Outputs_Sim) {
318
    Outputs_Sim <- Outputs_all
319
  }
320
  Test <- which(!Outputs_Sim %in% Outputs_all)
321
  if (length(Test) != 0) {
322
    stop(paste0( "'Outputs_Sim' is incorrectly defined: ",
323
                 paste(Outputs_Sim[Test], collapse = ", "), " not found"))
324
325
  }
  Outputs_Sim <- Outputs_Sim[!duplicated(Outputs_Sim)]
326
327


328
  ##check_Outputs_Cal
329
330
  if (is.null(Outputs_Cal)) {
    if ("GR" %in% ObjectClass) {
331
      Outputs_Cal <- c("Qsim", "Param")
332
333
334
335
336
337
338
339
340
341
    }
    if ("CemaNeige" %in% ObjectClass) {
      Outputs_Cal <- c("all")
    }
    if ("GR" %in% ObjectClass &
        "CemaNeige" %in% ObjectClass) {
      Outputs_Cal <- c("PliqAndMelt", "Qsim")
    }
  } else {
    if (!is.vector(Outputs_Cal)) {
342
      stop("'Outputs_Cal' must be a vector of characters")
343
344
    }
    if (!is.character(Outputs_Cal)) {
345
      stop("'Outputs_Cal' must be a vector of characters")
346
347
    }
    if (sum(is.na(Outputs_Cal)) != 0) {
348
      stop("'Outputs_Cal' must not contain NA")
349
350
351
    }
  }
  if ("all" %in% Outputs_Cal) {
352
    Outputs_Cal <- Outputs_all
353
  }
354
  Test <- which(!Outputs_Cal %in% Outputs_all)
355
  if (length(Test) != 0) {
356
    stop(paste0("'Outputs_Cal' is incorrectly defined: ",
357
                paste(Outputs_Cal[Test], collapse = ", "), " not found"))
358
  }
359
  Outputs_Cal <- unique(Outputs_Cal)
360
361


362
363
364
365
366
367
368
369
370
  ##check_MeanAnSolidPrecip
  if ("CemaNeige" %in% ObjectClass & is.null(MeanAnSolidPrecip)) {
    NLayers <- length(InputsModel$LayerPrecip)
    SolidPrecip <- NULL
    for (iLayer in 1:NLayers) {
      if (iLayer == 1) {
        SolidPrecip <-
          InputsModel$LayerFracSolidPrecip[[1]] * InputsModel$LayerPrecip[[iLayer]] /
          NLayers
Delaigue Olivier's avatar
Delaigue Olivier committed
371
      } else {
372
        SolidPrecip <- SolidPrecip + InputsModel$LayerFracSolidPrecip[[iLayer]] * InputsModel$LayerPrecip[[iLayer]] / NLayers
Delaigue Olivier's avatar
Delaigue Olivier committed
373
374
      }
    }
375
376
    Factor <- NULL
    if (inherits(InputsModel, "hourly")) {
377
      Factor <- 365.25 * 24
378
379
    }
    if (inherits(InputsModel, "daily")) {
380
      Factor <- 365.25
381
382
383
384
385
386
387
388
    }
    if (inherits(InputsModel, "monthly")) {
      Factor <- 12
    }
    if (inherits(InputsModel, "yearly")) {
      Factor <- 1
    }
    if (is.null(Factor)) {
389
      stop("'InputsModel' must be of class 'hourly', 'daily', 'monthly' or 'yearly'")
390
391
392
    }
    MeanAnSolidPrecip <- rep(mean(SolidPrecip) * Factor, NLayers)
    ### default value: same Gseuil for all layers
393
    if (warnings) {
394
      warning("'MeanAnSolidPrecip' not defined: it was automatically set to c(",
395
396
              paste(round(MeanAnSolidPrecip), collapse = ","), ")  from the 'InputsModel' given to the function. ",
              "Be careful in case your application is (short-term) forecasting.\n")
397
398
399
400
    }
  }
  if ("CemaNeige" %in% ObjectClass & !is.null(MeanAnSolidPrecip)) {
    if (!is.vector(MeanAnSolidPrecip)) {
401
      stop(paste0("'MeanAnSolidPrecip' must be a vector of numeric values"))
402
403
    }
    if (!is.numeric(MeanAnSolidPrecip)) {
404
      stop(paste0("'MeanAnSolidPrecip' must be a vector of numeric values"))
405
406
    }
    if (length(MeanAnSolidPrecip) != NLayers) {
407
      stop(paste0("'MeanAnSolidPrecip' must be a numeric vector of length ", NLayers, ""))
408
409
    }
  }
410
411


Delaigue Olivier's avatar
Delaigue Olivier committed
412
  ##check_PliqAndMelt
413
  if ("GR" %in% ObjectClass & "CemaNeige" %in% ObjectClass) {
414
    if (!"PliqAndMelt" %in% Outputs_Cal & !"all" %in% Outputs_Cal) {
415
      WTxt <- NULL
416
417
      WTxt <- paste0(WTxt, "'PliqAndMelt' was not defined in 'Outputs_Cal' but is needed to feed the hydrological model with the snow modele outputs \n")
      WTxt <- paste0(WTxt, ": it was automatically added \n")
418
      if (!is.null(WTxt) & warnings) {
419
420
421
        warning(WTxt)
      }
      Outputs_Cal <- c(Outputs_Cal, "PliqAndMelt")
Delaigue Olivier's avatar
Delaigue Olivier committed
422
    }
423
    if (!"PliqAndMelt" %in% Outputs_Sim & !"all" %in% Outputs_Sim) {
424
      WTxt <- NULL
425
426
      WTxt <- paste0(WTxt, "'PliqAndMelt' was not defined in 'Outputs_Sim' but is needed to feed the hydrological model with the snow modele outputs \n")
      WTxt <- paste0(WTxt, ": it was automatically added \n")
427
      if (!is.null(WTxt) & warnings) {
428
429
430
431
432
        warning(WTxt)
      }
      Outputs_Sim <- c(Outputs_Sim, "PliqAndMelt")
    }
  }
433
434


435
436
437
438
  ##check_Qsim
  if ("GR" %in% ObjectClass) {
    if (!"Qsim" %in% Outputs_Cal & !"all" %in% Outputs_Cal) {
      WTxt <- NULL
439
440
      WTxt <- paste0(WTxt, "'Qsim' was not defined in 'Outputs_Cal' \n")
      WTxt <- paste0(WTxt, ": it was automatically added \n")
441
442
443
444
445
446
447
      if (!is.null(WTxt) & warnings) {
        warning(WTxt)
      }
      Outputs_Cal <- c(Outputs_Cal, "Qsim")
    }
    if (!"Qsim" %in% Outputs_Sim & !"all" %in% Outputs_Sim) {
      WTxt <- NULL
448
449
      WTxt <- paste0(WTxt, "'Qsim' was not defined in 'Outputs_Sim' \n")
      WTxt <- paste0(WTxt, ": it was automatically added \n")
450
451
452
453
454
455
      if (!is.null(WTxt) & warnings) {
        warning(WTxt)
      }
      Outputs_Sim <- c(Outputs_Sim, "Qsim")
    }
  }
456

Delaigue Olivier's avatar
Delaigue Olivier committed
457
  ##Create_RunOptions
458
459
460
461
462
  RunOptions <- list(IndPeriod_WarmUp = IndPeriod_WarmUp,
                     IndPeriod_Run = IndPeriod_Run,
                     IniStates = IniStates,
                     IniResLevels = IniResLevels,
                     Outputs_Cal = Outputs_Cal,
463
                     Outputs_Sim = Outputs_Sim,
464
465
                     FortranOutputs = FortranOutputs,
                     FeatFUN_MOD = FeatFUN_MOD)
466

467
  if ("CemaNeige" %in% ObjectClass) {
468
    RunOptions <- c(RunOptions, list(MeanAnSolidPrecip = MeanAnSolidPrecip))
469
  }
470
  if ("interception" %in% ObjectClass) {
471
    RunOptions <- c(RunOptions, list(Imax = Imax))
472
  }
473
  class(RunOptions) <- c("RunOptions", ObjectClass)
474

475
  return(RunOptions)
476
477


Delaigue Olivier's avatar
Delaigue Olivier committed
478
479
}