Commit 81fb0b6c authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.6.3.65 style: format comments in RunModel_* functions

Refs #14
parent 02de3917
Pipeline #17611 passed with stages
in 11 minutes and 15 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.3.64
Version: 1.6.3.65
Date: 2020-11-17
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -4,7 +4,7 @@
### 1.6.3.64 Release Notes (2020-11-17)
### 1.6.3.65 Release Notes (2020-11-17)
#### New features
......
......@@ -8,7 +8,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
FortranOutputsCemaNeige <- .FortranOutputs(GR = NULL, isCN = TRUE)$CN
## Arguments_check
## Arguments check
if (!inherits(InputsModel, "InputsModel")) {
stop("'InputsModel' must be of class 'InputsModel'")
}
......@@ -39,7 +39,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
time_mult <- 24
}
## Input_data_preparation
## Input data preparation
if (identical(RunOptions$IndPeriod_WarmUp, as.integer(0))) {
RunOptions$IndPeriod_WarmUp <- NULL
}
......@@ -52,7 +52,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
## SNOW_MODULE________________________________________________________________________________
## CemaNeige________________________________________________________________________________
ParamCemaNeige <- Param
NLayers <- length(InputsModel$LayerPrecip)
......@@ -71,7 +71,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
NameCemaNeigeLayers <- "CemaNeigeLayers"
## Call_DLL_CemaNeige_________________________
## Call CemaNeige Fortran_________________________
for (iLayer in 1:NLayers) {
if (!IsHyst) {
......@@ -105,7 +105,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
## Data_storage
## Data storage
CemaNeigeLayers[[iLayer]] <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(CemaNeigeLayers[[iLayer]]) <- FortranOutputsCemaNeige[IndOutputsCemaNeige]
if (ExportStateEnd) {
......@@ -113,7 +113,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
}
rm(RESULTS)
} ### ENDFOR_iLayer
} ### ENDFOR iLayer
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
......@@ -129,7 +129,7 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) {
verbose = FALSE)
}
## Output_data_preparation
## Output data preparation
if (!ExportDatesR & !ExportStateEnd) {
OutputsModel <- list(CemaNeigeLayers)
names(OutputsModel) <- NameCemaNeigeLayers
......
......@@ -9,7 +9,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
FortranOutputs <- .FortranOutputs(GR = "GR4H", isCN = TRUE)
## Arguments_check
## Arguments check
if (!inherits(InputsModel, "InputsModel")) {
stop("'InputsModel' must be of class 'InputsModel'")
}
......@@ -55,7 +55,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
Param[4L] <- Param_X4_threshold
}
## Input_data_preparation
## Input data preparation
if (identical(RunOptions$IndPeriod_WarmUp, 0L)) {
RunOptions$IndPeriod_WarmUp <- NULL
}
......@@ -71,7 +71,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim
## SNOW_MODULE________________________________________________________________________________
## CemaNeige________________________________________________________________________________
if (inherits(RunOptions, "CemaNeige")) {
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsCemaNeige <- as.integer(1:length(FortranOutputs$CN))
......@@ -83,7 +83,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
NameCemaNeigeLayers <- "CemaNeigeLayers"
## Call_DLL_CemaNeige_________________________
## Call CemaNeige Fortran_________________________
for (iLayer in 1:NLayers) {
if (!IsHyst) {
......@@ -112,7 +112,7 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
## Data_storage
## Data storage
CemaNeigeLayers[[iLayer]] <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(CemaNeigeLayers[[iLayer]]) <- FortranOutputs$CN[IndOutputsCemaNeige]
IndPliqAndMelt <- which(names(CemaNeigeLayers[[iLayer]]) == "PliqAndMelt")
......@@ -126,9 +126,9 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
CemaNeigeStateEnd <- c(CemaNeigeStateEnd, RESULTS$StateEnd)
}
rm(RESULTS)
} ### ENDFOR_iLayer
} ### ENDFOR iLayer
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
} ### ENDIF_RunSnowModule
} ### ENDIF RunSnowModule
if (!inherits(RunOptions, "CemaNeige")) {
CemaNeigeLayers <- list()
CemaNeigeStateEnd <- NULL
......@@ -138,20 +138,20 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
## MODEL
## GR model
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsMod <- as.integer(1:length(FortranOutputs$GR))
} else {
IndOutputsMod <- which(FortranOutputs$GR %in% RunOptions$Outputs_Sim)
}
## Use_of_IniResLevels
## Use of IniResLevels
if (!is.null(RunOptions$IniResLevels)) {
RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * ParamMod[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * ParamMod[3] ### routing store level (mm)
}
## Call_fortan
## Call GR model Fortan
RESULTS <- .Fortran("frun_gr4h", PACKAGE = "airGR",
## inputs
LInputs = LInputSeries, ### length of input and output series
......@@ -186,28 +186,28 @@ RunModel_CemaNeigeGR4H <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[, which(FortranOutputs$GR[IndOutputsMod] == "Precip")] <- InputsModel$Precip[IndPeriod1]
}
## Output_data_preparation
## OutputsModel_only
## Output data preparation
## OutputsModel only
if (!ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## DatesR_and_OutputsModel_only
## DatesR and OutputsModel only
if ( ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c("DatesR", FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## OutputsModel_and_SateEnd_only
## OutputsModel and SateEnd only
if (!ExportDatesR & ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers),
list(RESULTS$StateEnd))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers, "StateEnd")
}
## DatesR_and_OutputsModel_and_SateEnd
## DatesR and OutputsModel and SateEnd
if ( ExportDatesR & ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
......
......@@ -9,7 +9,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
FortranOutputs <- .FortranOutputs(GR = "GR4J", isCN = TRUE)
## Arguments_check
## Arguments check
if (!inherits(InputsModel, "InputsModel")) {
stop("'InputsModel' must be of class 'InputsModel'")
}
......@@ -54,7 +54,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
Param[4L] <- Param_X4_threshold
}
## Input_data_preparation
## Input data preparation
if (identical(RunOptions$IndPeriod_WarmUp, 0L)) {
RunOptions$IndPeriod_WarmUp <- NULL
}
......@@ -70,7 +70,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim
## SNOW_MODULE________________________________________________________________________________
## CemaNeige________________________________________________________________________________
if (inherits(RunOptions, "CemaNeige")) {
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsCemaNeige <- as.integer(1:length(FortranOutputs$CN))
......@@ -82,7 +82,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
NameCemaNeigeLayers <- "CemaNeigeLayers"
## Call_DLL_CemaNeige_________________________
## Call CemaNeige Fortran_________________________
for(iLayer in 1:NLayers) {
if (!IsHyst) {
StateStartCemaNeige <- RunOptions$IniStates[(7 + 20 + 40) + c(iLayer, iLayer+NLayers)]
......@@ -110,7 +110,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
## Data_storage
## Data storage
CemaNeigeLayers[[iLayer]] <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(CemaNeigeLayers[[iLayer]]) <- FortranOutputs$CN[IndOutputsCemaNeige]
IndPliqAndMelt <- which(names(CemaNeigeLayers[[iLayer]]) == "PliqAndMelt")
......@@ -124,9 +124,9 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
CemaNeigeStateEnd <- c(CemaNeigeStateEnd, RESULTS$StateEnd)
}
rm(RESULTS)
} ### ENDFOR_iLayer
} ### ENDFOR iLayer
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
} ### ENDIF_RunSnowModule
} ### ENDIF RunSnowModule
if (!inherits(RunOptions, "CemaNeige")) {
CemaNeigeLayers <- list()
CemaNeigeStateEnd <- NULL
......@@ -136,20 +136,20 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
## MODEL______________________________________________________________________________________
## GR model______________________________________________________________________________________
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsMod <- as.integer(1:length(FortranOutputs$GR))
} else {
IndOutputsMod <- which(FortranOutputs$GR %in% RunOptions$Outputs_Sim)
}
## Use_of_IniResLevels
## Use of IniResLevels
if (!is.null(RunOptions$IniResLevels)) {
RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * ParamMod[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * ParamMod[3] ### routing store level (mm)
}
## Call_fortan
## Call GR model Fortan
RESULTS <- .Fortran("frun_gr4j", PACKAGE = "airGR",
## inputs
LInputs = LInputSeries, ### length of input and output series
......@@ -184,28 +184,28 @@ RunModel_CemaNeigeGR4J <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[, which(FortranOutputs$GR[IndOutputsMod] == "Precip")] <- InputsModel$Precip[IndPeriod1]
}
## Output_data_preparation
## OutputsModel_only
## Output data preparation
## OutputsModel only
if (!ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## DatesR_and_OutputsModel_only
## DatesR and OutputsModel only
if ( ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c("DatesR", FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## OutputsModel_and_SateEnd_only
## OutputsModel and SateEnd only
if (!ExportDatesR & ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers),
list(RESULTS$StateEnd))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers, "StateEnd")
}
## DatesR_and_OutputsModel_and_Sate
## DatesR and OutputsModel and Sate
if ( ExportDatesR & ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
......
......@@ -15,7 +15,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
}
## Arguments_check
## Arguments check
if (!inherits(InputsModel, "InputsModel")) {
stop("'InputsModel' must be of class 'InputsModel'")
}
......@@ -61,7 +61,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
Param[4L] <- Param_X4_threshold
}
## Input_data_preparation
## Input data preparation
if (identical(RunOptions$IndPeriod_WarmUp, 0L)) {
RunOptions$IndPeriod_WarmUp <- NULL
}
......@@ -81,12 +81,12 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
NStatesMod <- as.integer(length(RunOptions$IniStates) - NStates * NLayers)
## Output_data_preparation
## Output data preparation
IndPeriod2 <- (length(RunOptions$IndPeriod_WarmUp)+1):LInputSeries
ExportDatesR <- "DatesR" %in% RunOptions$Outputs_Sim
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim
## SNOW_MODULE________________________________________________________________________________
## CemaNeige________________________________________________________________________________
if (inherits(RunOptions, "CemaNeige")) {
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsCemaNeige <- as.integer(1:length(FortranOutputs$CN))
......@@ -98,7 +98,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
NameCemaNeigeLayers <- "CemaNeigeLayers"
## Call_DLL_CemaNeige_________________________
## Call CemaNeige Fortran_________________________
for(iLayer in 1:NLayers) {
if (!IsHyst) {
StateStartCemaNeige <- RunOptions$IniStates[(7 + 20*24 + 40*24) + c(iLayer, iLayer+NLayers)]
......@@ -126,7 +126,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
## Data_storage
## Data storage
CemaNeigeLayers[[iLayer]] <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(CemaNeigeLayers[[iLayer]]) <- FortranOutputs$CN[IndOutputsCemaNeige]
IndPliqAndMelt <- which(names(CemaNeigeLayers[[iLayer]]) == "PliqAndMelt")
......@@ -140,9 +140,9 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
CemaNeigeStateEnd <- c(CemaNeigeStateEnd, RESULTS$StateEnd)
}
rm(RESULTS)
} ### ENDFOR_iLayer
} ### ENDFOR iLayer
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
} ### ENDIF_RunSnowModule
} ### ENDIF RunSnowModule
if (!inherits(RunOptions, "CemaNeige")) {
CemaNeigeLayers <- list()
CemaNeigeStateEnd <- NULL
......@@ -152,14 +152,14 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
## MODEL______________________________________________________________________________________
## GR model______________________________________________________________________________________
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsMod <- as.integer(1:length(FortranOutputs$GR))
} else {
IndOutputsMod <- which(FortranOutputs$GR %in% RunOptions$Outputs_Sim)
}
## Use_of_IniResLevels
## 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)
......@@ -168,7 +168,7 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
}
}
## Call_fortan
## Call GR model Fortan
RESULTS <- .Fortran("frun_gr5h",PACKAGE="airGR",
## inputs
LInputs = LInputSeries, ### length of input and output series
......@@ -205,29 +205,29 @@ RunModel_CemaNeigeGR5H <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[,which(FortranOutputs$GR[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]
}
## Output_data_preparation
## OutputsModel_only
## OutputsModel_only
## Output data preparation
## OutputsModel only
## OutputsModel only
if (!ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## DatesR_and_OutputsModel_only
## DatesR and OutputsModel only
if ( ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c("DatesR", FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## OutputsModel_and_SateEnd_only
## OutputsModel and SateEnd only
if (!ExportDatesR & ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers),
list(RESULTS$StateEnd))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers, "StateEnd")
}
## DatesR_and_OutputsModel_and_SateEnd
## DatesR and OutputsModel and SateEnd
if ( ExportDatesR & ExportStateEnd) {
OutputsModel <- c( list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
......
......@@ -9,7 +9,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
FortranOutputs <- .FortranOutputs(GR = "GR5J", isCN = TRUE)
## Arguments_check
## Arguments check
if (!inherits(InputsModel, "InputsModel")) {
stop("'InputsModel' must be of class 'InputsModel'")
}
......@@ -55,7 +55,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
Param[4L] <- Param_X4_threshold
}
## Input_data_preparation
## Input data preparation
if (identical(RunOptions$IndPeriod_WarmUp, 0L)) {
RunOptions$IndPeriod_WarmUp <- NULL
}
......@@ -71,7 +71,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim
## SNOW_MODULE________________________________________________________________________________
## CemaNeige________________________________________________________________________________
if (inherits(RunOptions, "CemaNeige")) {
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsCemaNeige <- as.integer(1:length(FortranOutputs$CN))
......@@ -83,7 +83,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
NameCemaNeigeLayers <- "CemaNeigeLayers"
## Call_DLL_CemaNeige_________________________
## Call CemaNeige Fortran_________________________
for(iLayer in 1:NLayers) {
if (!IsHyst) {
StateStartCemaNeige <- RunOptions$IniStates[(7 + 20 + 40) + c(iLayer, iLayer+NLayers)]
......@@ -111,7 +111,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
## Data_storage
## Data storage
CemaNeigeLayers[[iLayer]] <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(CemaNeigeLayers[[iLayer]]) <- FortranOutputs$CN[IndOutputsCemaNeige]
IndPliqAndMelt <- which(names(CemaNeigeLayers[[iLayer]]) == "PliqAndMelt")
......@@ -125,9 +125,9 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
CemaNeigeStateEnd <- c(CemaNeigeStateEnd, RESULTS$StateEnd)
}
rm(RESULTS)
} ### ENDFOR_iLayer
} ### ENDFOR iLayer
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
} ### ENDIF_RunSnowModule
} ### ENDIF RunSnowModule
if (!inherits(RunOptions, "CemaNeige")) {
CemaNeigeLayers <- list()
CemaNeigeStateEnd <- NULL
......@@ -137,20 +137,20 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
## MODEL______________________________________________________________________________________
## GR model______________________________________________________________________________________
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsMod <- as.integer(1:length(FortranOutputs$GR))
} else {
IndOutputsMod <- which(FortranOutputs$GR %in% RunOptions$Outputs_Sim)
}
## Use_of_IniResLevels
## Use of IniResLevels
if (!is.null(RunOptions$IniResLevels)) {
RunOptions$IniStates[1] <- RunOptions$IniResLevels[1] * ParamMod[1] ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[2] * ParamMod[3] ### routing store level (mm)
}
## Call_fortan
## Call GR model Fortan
RESULTS <- .Fortran("frun_gr5j", PACKAGE = "airGR",
## inputs
LInputs = LInputSeries, ### length of input and output series
......@@ -185,28 +185,28 @@ RunModel_CemaNeigeGR5J <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[,which(FortranOutputs$GR[IndOutputsMod] == "Precip")] <- InputsModel$Precip[IndPeriod1]
}
## Output_data_preparation
## OutputsModel_only
## Output data preparation
## OutputsModel only
if (!ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## DatesR_and_OutputsModel_only
## DatesR and OutputsModel only
if (ExportDatesR & !ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers))
names(OutputsModel) <- c("DatesR", FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers)
}
## OutputsModel_and_SateEnd_only
## OutputsModel and SateEnd only
if (!ExportDatesR & ExportStateEnd) {
OutputsModel <- c(lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
list(CemaNeigeLayers),
list(RESULTS$StateEnd))
names(OutputsModel) <- c(FortranOutputs$GR[IndOutputsMod], NameCemaNeigeLayers, "StateEnd")
}
## DatesR_and_OutputsModel_and_SateEnd
## DatesR and OutputsModel and SateEnd
if (ExportDatesR & ExportStateEnd) {
OutputsModel <- c(list(InputsModel$DatesR[RunOptions$IndPeriod_Run]),
lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i]),
......
......@@ -9,7 +9,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) {
FortranOutputs <- .FortranOutputs(GR = "GR6J", isCN = TRUE)
## Arguments_check
## Arguments check
if (!inherits(InputsModel, "InputsModel")) {
stop("'InputsModel' must be of class 'InputsModel'")
}
......@@ -59,7 +59,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) {
Param[6L] <- Param_X1X3X6_threshold
}
## Input_data_preparation
## Input data preparation
if (identical(RunOptions$IndPeriod_WarmUp, 0L)) {
RunOptions$IndPeriod_WarmUp <- NULL
}
......@@ -75,7 +75,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) {
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim
## SNOW_MODULE________________________________________________________________________________
## CemaNeige________________________________________________________________________________
if (inherits(RunOptions, "CemaNeige")) {
if ("all" %in% RunOptions$Outputs_Sim) {
IndOutputsCemaNeige <- as.integer(1:length(FortranOutputs$CN))
......@@ -87,7 +87,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) {
NameCemaNeigeLayers <- "CemaNeigeLayers"
## Call_DLL_CemaNeige_________________________
## Call CemaNeige Fortran_________________________
for(iLayer in 1:NLayers) {
if (!IsHyst) {
StateStartCemaNeige <- RunOptions$IniStates[(7 + 20 + 40) + c(iLayer, iLayer+NLayers)]
......@@ -115,7 +115,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) {
RESULTS$Outputs[ round(RESULTS$Outputs , 3) == -999.999] <- NA
RESULTS$StateEnd[round(RESULTS$StateEnd, 3) == -999.999] <- NA
## Data_storage
## Data storage
CemaNeigeLayers[[iLayer]] <- lapply(seq_len(RESULTS$NOutputs), function(i) RESULTS$Outputs[IndPeriod2, i])
names(CemaNeigeLayers[[iLayer]]) <- FortranOutputs$CN[IndOutputsCemaNeige]
IndPliqAndMelt <- which(names(CemaNeigeLayers[[iLayer]]) == "PliqAndMelt")
......@@ -129,9 +129,9 @@ RunModel_CemaNeigeGR6J <- function(InputsModel, RunOptions, Param) {
CemaNeigeStateEnd <- c(CemaNeigeStateEnd,RESULTS$StateEnd)
}
rm(RESULTS)
} ### ENDFOR_iLayer
} ### ENDFOR iLayer
names(CemaNeigeLayers) <- sprintf("Layer%02i", seq_len(NLayers))
} ### ENDIF_RunSnowModule
} ### ENDIF RunSnowModule
if (!inherits(RunOptions, "CemaNeige")) {