Commit 96b3ec9e authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.2.0.4 NEW, add an IsHyst argument in RunModel_CemaNeige to use hysteresis #5252

parent 5ce462ce
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.2.0.3
Date: 2019-01-29
Version: 1.2.0.4
Date: 2019-01-30
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
person("Charles", "Perrin", role = c("aut", "ths"), comment = c(ORCID = "0000-0001-8552-1881")),
......
......@@ -13,7 +13,7 @@ output:
### 1.2.0.3 Release Notes (2019-01-29)
### 1.2.0.4 Release Notes (2019-01-30)
......
RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
RunModel_CemaNeige <- function(InputsModel, RunOptions, Param, IsHyst) {
## Arguments_check
if (!is.logical(IsHyst) | length(IsHyst) != 1L) {
stop("'IsHyst' must be a 'logical' of length 1")
return(NULL)
}
NParam <- 2L
## Initialization of variables
NParam <- ifelse(IsHyst, 4L, 2L)
NStates <- 4L
FortranOutputsCemaNeige <- c("Pliq", "Psol",
"SnowPack", "ThermalState", "Gratio",
"PotMelt", "Melt", "PliqAndMelt", "Temp")
"PotMelt", "Melt", "PliqAndMelt", "Temp",
"Gthreshold", "Glocalmax")
......@@ -47,7 +57,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim
......@@ -81,17 +91,18 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
InputsFracSolidPrecip = InputsModel$LayerFracSolidPrecip[[iLayer]][IndPeriod1], ### input series of fraction of solid precipitation [0-1]
InputsTemp = InputsModel$LayerTemp[[iLayer]][IndPeriod1], ### input series of air mean temperature [degC]
MeanAnSolidPrecip = RunOptions$MeanAnSolidPrecip[iLayer], ### value of annual mean solid precip [mm/y]
NParam = as.integer(2), ### number of model parameter = 2
NParam = as.integer(NParam), ### number of model parameter
Param = as.double(ParamCemaNeige), ### parameter set
NStates = as.integer(2), ### number of state variables used for model initialising = 2
NStates = as.integer(NStates), ### number of state variables used for model initialising
StateStart = StateStartCemaNeige, ### state variables used when the model run starts
IsHyst = as.integer(IsHyst), ### use of hysteresis
NOutputs = as.integer(length(IndOutputsCemaNeige)), ### number of output series
IndOutputs = IndOutputsCemaNeige, ### indices of output series
## outputs
Outputs = matrix(-999.999, ### output series [mm]
nrow = length(IndPeriod1),
ncol = length(IndOutputsCemaNeige)),
StateEnd = rep(-999.999, 2) ### state variables at the end of the model run (reservoir levels [mm] and HU)
StateEnd = rep(-999.999, NStates) ### state variables at the end of the model run (reservoir levels [mm] and HU)
)
RESULTS$Outputs[round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
......@@ -112,11 +123,14 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
if (ExportStateEnd) {
idNStates <- seq_len(NStates*NLayers) %% NStates
CemaNeigeStateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeige, InputsModel = InputsModel,
ProdStore = NULL, RoutStore = NULL, ExpStore = NULL,
UH1 = NULL, UH2 = NULL,
GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(2*NLayers)[seq_len(2*NLayers) %% 2 == 1]],
eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(2*NLayers)[seq_len(2*NLayers) %% 2 == 0]],
GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]],
eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]],
GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]],
GlocmaxCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 0]],
verbose = FALSE)
}
......
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