Commit db5b3e79 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

fix: correct IniStates and StateEnd for CemaNeigeGR5H

parent 8d9557b0
Pipeline #21617 passed with stages
in 15 minutes and 51 seconds
......@@ -57,7 +57,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
Param[3L] <- Param_X1X3_threshold
}
if (Param[4L] < Param_X4_threshold) {
warning(sprintf("Param[4] (X4: unit hydrograph time constant [hour]) < %.2f\n X4 set to %.2f", Param_X4_threshold, Param_X4_threshold))
warning(sprintf("Param[4] (X4: unit hydrograph time constant [h]) < %.2f\n X4 set to %.2f", Param_X4_threshold, Param_X4_threshold))
Param[4L] <- Param_X4_threshold
}
......@@ -68,11 +68,6 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
IndPeriod1 <- c(RunOptions$IndPeriod_WarmUp, RunOptions$IndPeriod_Run)
LInputSeries <- as.integer(length(IndPeriod1))
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp) + 1):LInputSeries
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsMod <- as.integer(1:length(FortranOutputs))
} else {
IndOutputsMod <- which(FortranOutputs %in% RunOptions$Outputs_Sim)
}
ParamCemaNeige <- Param[(length(Param) - 1 - 2 * as.integer(IsHyst)):length(Param)]
NParamMod <- as.integer(length(Param) - (2 + 2 * as.integer(IsHyst)))
ParamMod <- Param[1:NParamMod]
......@@ -160,8 +155,8 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
## Use of IniResLevels
if (!is.null(RunOptions$IniResLevels)) {
RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * Param[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * Param[3] ### routing store level (mm)
RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * ParamMod[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * ParamMod[3] ### routing store level (mm)
if (IsIntStore) {
RunOptions$IniStates[4] <- RunOptions$IniResLevels[4] * Imax ### interception store level (mm)
}
......@@ -182,7 +177,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
IndOutputs = IndOutputsMod, ### indices of output series
## outputs
Outputs = matrix(as.double(-999.999), nrow = LInputSeries, ncol = length(IndOutputsMod)), ### output series [mm or mm/h]
StateEnd = rep(as.double(-999.999), length(RunOptions$IniStates)) ### state variables at the end of the model run
StateEnd = rep(as.double(-999.999), NStatesMod) ### state variables at the end of the model run
)
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
......@@ -192,7 +187,8 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
RESULTS$StateEnd <- CreateIniStates(FUN_MOD = RunModel_CemaNeigeGR5H, InputsModel = InputsModel, IsHyst = IsHyst,
ProdStore = RESULTS$StateEnd[1L], RoutStore = RESULTS$StateEnd[2L], ExpStore = NULL,
IntStore = RESULTS$StateEnd[4L],
UH1 = NULL, UH2 = RESULTS$StateEnd[(1:(40*24))+(7+20*24)],
UH1 = NULL,
UH2 = RESULTS$StateEnd[(1:(40*24)) + (7+20*24)],
GCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 1]],
eTGCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 2]],
GthrCemaNeigeLayers = CemaNeigeStateEnd[seq_len(NStates*NLayers)[idNStates == 3]],
......
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