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

Mise au propre de la casse de caractères pour être cohérent lors de la...

Mise au propre de la casse de caractères pour être cohérent lors de la création du lien  vers les routines FORTRAN
parent c91208c6
#*****************************************************************************************************************
#' Function which performs a single run for the CemaNeige-GR4J daily lumped model.
#'
#' For further details on the model, see the references section.
#' For further details on the argument structures and initialisation options, see \code{\link{CreateRunOptions}}.
#*****************************************************************************************************************
#' @title Run with the CemaNeigeGR4J hydrological model
#' @author Laurent Coron (December 2013)
#' @references
#' Perrin, C., C. Michel and V. Andréassian (2003),
#' Improvement of a parsimonious model for streamflow simulation,
#' Journal of Hydrology, 279(1-4), 275-289, doi:10.1016/S0022-1694(03)00225-7. \cr
#' Valéry, A., V. Andréassian and C. Perrin (2014),
#' "As simple as possible but not simpler": what is useful in a temperature-based snow-accounting routine?
#' Part 1 - Comparison of six snow accounting routines on 380 catchments, Journal of Hydrology, doi:10.1016/j.jhydrol.2014.04.059. \cr
#' Valéry, A., V. Andréassian and C. Perrin (2014),
#' "As simple as possible but not simpler": What is useful in a temperature-based snow-accounting routine?
#' Part 2 - Sensitivity analysis of the Cemaneige snow accounting routine on 380 catchments, Journal of Hydrology, doi:10.1016/j.jhydrol.2014.04.058.
#' @seealso \code{\link{RunModel_CemaNeigeGR5J}}, \code{\link{RunModel_CemaNeigeGR6J}}, \code{\link{RunModel_GR4J}},
#' \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}.
#' @example tests/example_RunModel_CemaNeigeGR4J.R
#' @useDynLib airGR
#' @encoding UTF-8
#' @export
#_FunctionInputs__________________________________________________________________________________________________
#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details
#' @param RunOptions [object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details
#' @param Param [numeric] vector of 6 parameters
#' \tabular{ll}{
#' GR4J X1 \tab production store capacity [mm] \cr
#' GR4J X2 \tab intercatchment exchange coefficient [mm/d] \cr
#' GR4J X3 \tab routing store capacity [mm] \cr
#' GR4J X4 \tab unit hydrograph time constant [d] \cr
#' CemaNeige X1 \tab weighting coefficient for snow pack thermal state [-] \cr
#' CemaNeige X2 \tab degree-day melt coefficient [mm/degC/d] \cr
#' }
#_FunctionOutputs_________________________________________________________________________________________________
#' @return [list] list containing the function outputs organised as follows:
#' \tabular{ll}{
#' \emph{$DatesR } \tab [POSIXlt] series of dates \cr
#' \emph{$PotEvap } \tab [numeric] series of input potential evapotranspiration [mm/d] \cr
#' \emph{$Precip } \tab [numeric] series of input total precipitation [mm/d] \cr
#' \emph{$Prod } \tab [numeric] series of production store level (X(2)) [mm] \cr
#' \emph{$AE } \tab [numeric] series of actual evapotranspiration [mm/d] \cr
#' \emph{$Perc } \tab [numeric] series of percolation (PERC) [mm/d] \cr
#' \emph{$PR } \tab [numeric] series of PR=PN-PS+PERC [mm/d] \cr
#' \emph{$Q9 } \tab [numeric] series of HU1 outflow (Q9) [mm/d] \cr
#' \emph{$Q1 } \tab [numeric] series of HU2 outflow (Q1) [mm/d] \cr
#' \emph{$Rout } \tab [numeric] series of routing store level (X(1)) [mm] \cr
#' \emph{$Exch } \tab [numeric] series of potential semi-exchange between catchments [mm/d] \cr
#' \emph{$AExch } \tab [numeric] series of actual exchange between catchments (1+2) [mm/d] \cr
#' \emph{$QR } \tab [numeric] series of routing store outflow (QR) [mm/d] \cr
#' \emph{$QD } \tab [numeric] series of direct flow from HU2 after exchange (QD) [mm/d] \cr
#' \emph{$Qsim } \tab [numeric] series of Qsim [mm/d] \cr
#' \emph{$CemaNeigeLayers} \tab [list] list of CemaNeige outputs (1 list per layer) \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Pliq } \tab [numeric] series of liquid precip. [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Psol } \tab [numeric] series of solid precip. [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$SnowPack } \tab [numeric] series of snow pack [mm] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$ThermalState } \tab [numeric] series of snow pack thermal state [degC] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Gratio } \tab [numeric] series of Gratio [0-1] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$PotMelt } \tab [numeric] series of potential snow melt [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Melt } \tab [numeric] series of actual snow melt [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$PliqAndMelt } \tab [numeric] series of liquid precip. + actual snow melt [mm/d] \cr
#' \emph{$StateEnd} \tab [numeric] states at the end of the run: \cr\tab res. & HU levels [mm], CemaNeige states [mm & degC] \cr
#' }
#' (refer to the provided references or to the package source code for further details on these model outputs)
#*****************************************************************************************************************
RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){
NParam <- 6; NParam <- 6;
...@@ -97,7 +30,6 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ ...@@ -97,7 +30,6 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){
ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim; ExportStateEnd <- "StateEnd" %in% RunOptions$Outputs_Sim;
##SNOW_MODULE________________________________________________________________________________## ##SNOW_MODULE________________________________________________________________________________##
if(RunOptions$RunSnowModule==TRUE){ if(RunOptions$RunSnowModule==TRUE){
if("all" %in% RunOptions$Outputs_Sim){ IndOutputsCemaNeige <- as.integer(1:length(FortranOutputsCemaNeige)); if("all" %in% RunOptions$Outputs_Sim){ IndOutputsCemaNeige <- as.integer(1:length(FortranOutputsCemaNeige));
...@@ -107,7 +39,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ ...@@ -107,7 +39,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){
##Call_DLL_CemaNeige_________________________ ##Call_DLL_CemaNeige_________________________
for(iLayer in 1:NLayers){ for(iLayer in 1:NLayers){
StateStartCemaNeige <- RunOptions$IniStates[ (NStatesMod+2*(iLayer-1)+1):(NStatesMod+2*(iLayer-1)+2) ]; StateStartCemaNeige <- RunOptions$IniStates[ (NStatesMod+2*(iLayer-1)+1):(NStatesMod+2*(iLayer-1)+2) ];
RESULTS <- .Fortran("frun_cemaneige",PACKAGE="airGR", RESULTS <- .Fortran("frun_CemaNeige",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/d] InputsPrecip=InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/d]
...@@ -150,12 +82,12 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ ...@@ -150,12 +82,12 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){
##Use_of_IniResLevels ##Use_of_IniResLevels
if("IniResLevels" %in% RunOptions){ if("IniResLevels" %in% RunOptions){
RunOptions$IniStates[1] <- RunOptions$IniResLevels[2]*ParamMod[3]; ### routing store level (mm) RunOptions$IniStates[1] <- RunOptions$IniResLevels[1]*ParamMod[1]; ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[1]*ParamMod[1]; ### production store level (mm) RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*ParamMod[3]; ### routing store level (mm)
} }
##Call_fortan ##Call_fortan
RESULTS <- .Fortran("frun_gr4j",PACKAGE="airGR", RESULTS <- .Fortran("frun_GR4J",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=CatchMeltAndPliq, ### input series of total precipitation [mm/d] InputsPrecip=CatchMeltAndPliq, ### input series of total precipitation [mm/d]
...@@ -168,7 +100,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ ...@@ -168,7 +100,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){
IndOutputs=IndOutputsMod, ### indices of output series IndOutputs=IndOutputsMod, ### indices of output series
##outputs ##outputs
Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputsMod)), ### output series [mm] Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputsMod)), ### output series [mm]
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$Outputs[ round(RESULTS$Outputs ,3)==(-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA; RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA;
......
#*****************************************************************************************************************
#' Function which performs a single run for the CemaNeige-GR5J daily lumped model.
#'
#' For further details on the model, see the references section.
#' For further details on the argument structures and initialisation options, see \code{\link{CreateRunOptions}}.
#*****************************************************************************************************************
#' @title Run with the CemaNeigeGR5J hydrological model
#' @author Laurent Coron (December 2013)
#' @references
#' Le Moine, N. (2008), Le bassin versant de surface vu par le souterrain : une voie d'amélioration des performances
#' et du réalisme des modèles pluie-débit ?, PhD thesis (french), UPMC, Paris, France. \cr
#' Pushpalatha, R., C. Perrin, N. Le Moine, T. Mathevet and V. Andréassian (2011),
#' A downward structural sensitivity analysis of hydrological models to improve low-flow simulation,
#' Journal of Hydrology, 411(1-2), 66-76, doi:10.1016/j.jhydrol.2011.09.034. \cr
#' Valéry, A., V. Andréassian and C. Perrin (2014),
#' "As simple as possible but not simpler": what is useful in a temperature-based snow-accounting routine?
#' Part 1 - Comparison of six snow accounting routines on 380 catchments, Journal of Hydrology, doi:10.1016/j.jhydrol.2014.04.059. \cr
#' Valéry, A., V. Andréassian and C. Perrin (2014),
#' "As simple as possible but not simpler": What is useful in a temperature-based snow-accounting routine?
#' Part 2 - Sensitivity analysis of the Cemaneige snow accounting routine on 380 catchments, Journal of Hydrology, doi:10.1016/j.jhydrol.2014.04.058.
#' @seealso \code{\link{RunModel_CemaNeigeGR4J}}, \code{\link{RunModel_CemaNeigeGR6J}}, \code{\link{RunModel_GR5J}},
#' \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}.
#' @example tests/example_RunModel_CemaNeigeGR5J.R
#' @useDynLib airGR
#' @encoding UTF-8
#' @export
#_FunctionInputs__________________________________________________________________________________________________
#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details
#' @param RunOptions [object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details
#' @param Param [numeric] vector of 7 parameters
#' \tabular{ll}{
#' GR5J X1 \tab production store capacity [mm] \cr
#' GR5J X2 \tab intercatchment exchange coefficient 1 [mm/d] \cr
#' GR5J X3 \tab routing store capacity [mm] \cr
#' GR5J X4 \tab unit hydrograph time constant [d] \cr
#' GR5J X5 \tab intercatchment exchange coefficient 2 [-] \cr
#' CemaNeige X1 \tab weighting coefficient for snow pack thermal state [-] \cr
#' CemaNeige X2 \tab degree-day melt coefficient [mm/degC/d] \cr
#' }
#_FunctionOutputs_________________________________________________________________________________________________
#' @return [list] list containing the function outputs organised as follows:
#' \tabular{ll}{
#' \emph{$DatesR } \tab [POSIXlt] series of dates \cr
#' \emph{$PotEvap } \tab [numeric] series of input potential evapotranspiration [mm/d] \cr
#' \emph{$Precip } \tab [numeric] series of input total precipitation [mm/d] \cr
#' \emph{$Prod } \tab [numeric] series of production store level (X(2)) [mm] \cr
#' \emph{$AE } \tab [numeric] series of actual evapotranspiration [mm/d] \cr
#' \emph{$Perc } \tab [numeric] series of percolation (PERC) [mm/d] \cr
#' \emph{$PR } \tab [numeric] series of PR=PN-PS+PERC [mm/d] \cr
#' \emph{$Q9 } \tab [numeric] series of HU1 outflow (Q9) [mm/d] \cr
#' \emph{$Q1 } \tab [numeric] series of HU2 outflow (Q1) [mm/d] \cr
#' \emph{$Rout } \tab [numeric] series of routing store level (X(1)) [mm] \cr
#' \emph{$Exch } \tab [numeric] series of potential semi-exchange between catchments [mm/d] \cr
#' \emph{$AExch } \tab [numeric] series of actual exchange between catchments (1+2) [mm/d] \cr
#' \emph{$QR } \tab [numeric] series of routing store outflow (QR) [mm/d] \cr
#' \emph{$QD } \tab [numeric] series of direct flow from HU2 after exchange (QD) [mm/d] \cr
#' \emph{$Qsim } \tab [numeric] series of Qsim [mm/d] \cr
#' \emph{$CemaNeigeLayers} \tab [list] list of CemaNeige outputs (1 list per layer) \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Pliq } \tab [numeric] series of liquid precip. [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Psol } \tab [numeric] series of solid precip. [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$SnowPack } \tab [numeric] series of snow pack [mm] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$ThermalState } \tab [numeric] series of snow pack thermal state [degC] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Gratio } \tab [numeric] series of Gratio [0-1] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$PotMelt } \tab [numeric] series of potential snow melt [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Melt } \tab [numeric] series of actual snow melt [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$PliqAndMelt } \tab [numeric] series of liquid precip. + actual snow melt [mm/d] \cr
#' \emph{$StateEnd} \tab [numeric] states at the end of the run: \cr\tab res. & HU levels [mm], CemaNeige states [mm & degC] \cr
#' }
#' (refer to the provided references or to the package source code for further details on these model outputs)
#*****************************************************************************************************************
RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){
NParam <- 7; NParam <- 7;
...@@ -109,7 +39,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ ...@@ -109,7 +39,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){
##Call_DLL_CemaNeige_________________________ ##Call_DLL_CemaNeige_________________________
for(iLayer in 1:NLayers){ for(iLayer in 1:NLayers){
StateStartCemaNeige <- RunOptions$IniStates[ (NStatesMod+2*(iLayer-1)+1):(NStatesMod+2*(iLayer-1)+2) ]; StateStartCemaNeige <- RunOptions$IniStates[ (NStatesMod+2*(iLayer-1)+1):(NStatesMod+2*(iLayer-1)+2) ];
RESULTS <- .Fortran("frun_cemaneige",PACKAGE="airGR", RESULTS <- .Fortran("frun_CemaNeige",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/d] InputsPrecip=InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/d]
...@@ -152,12 +82,12 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ ...@@ -152,12 +82,12 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){
##Use_of_IniResLevels ##Use_of_IniResLevels
if("IniResLevels" %in% RunOptions){ if("IniResLevels" %in% RunOptions){
RunOptions$IniStates[1] <- RunOptions$IniResLevels[2]*ParamMod[3]; ### routing store level (mm) RunOptions$IniStates[1] <- RunOptions$IniResLevels[1]*ParamMod[1]; ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[1]*ParamMod[1]; ### production store level (mm) RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*ParamMod[3]; ### routing store level (mm)
} }
##Call_fortan ##Call_fortan
RESULTS <- .Fortran("frun_gr5j",PACKAGE="airGR", RESULTS <- .Fortran("frun_GR5J",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=CatchMeltAndPliq, ### input series of total precipitation [mm/d] InputsPrecip=CatchMeltAndPliq, ### input series of total precipitation [mm/d]
...@@ -170,7 +100,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ ...@@ -170,7 +100,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){
IndOutputs=IndOutputsMod, ### indices of output series IndOutputs=IndOutputsMod, ### indices of output series
##outputs ##outputs
Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputsMod)), ### output series [mm] Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputsMod)), ### output series [mm]
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$Outputs[ round(RESULTS$Outputs ,3)==(-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA; RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA;
......
#*****************************************************************************************************************
#' Function which performs a single run for the CemaNeige-GR6J daily lumped model.
#'
#' For further details on the model, see the references section.
#' For further details on the argument structures and initialisation options, see \code{\link{CreateRunOptions}}.
#*****************************************************************************************************************
#' @title Run with the CemaNeigeGR6J hydrological model
#' @author Laurent Coron (December 2013)
#' @references
#' Pushpalatha, R., C. Perrin, N. Le Moine, T. Mathevet and V. Andréassian (2011),
#' A downward structural sensitivity analysis of hydrological models to improve low-flow simulation,
#' Journal of Hydrology, 411(1-2), 66-76, doi:10.1016/j.jhydrol.2011.09.034. \cr
#' Valéry, A., V. Andréassian and C. Perrin (2014),
#' "As simple as possible but not simpler": what is useful in a temperature-based snow-accounting routine?
#' Part 1 - Comparison of six snow accounting routines on 380 catchments, Journal of Hydrology, doi:10.1016/j.jhydrol.2014.04.059. \cr
#' Valéry, A., V. Andréassian and C. Perrin (2014),
#' "As simple as possible but not simpler": What is useful in a temperature-based snow-accounting routine?
#' Part 2 - Sensitivity analysis of the Cemaneige snow accounting routine on 380 catchments, Journal of Hydrology, doi:10.1016/j.jhydrol.2014.04.058.
#' @seealso \code{\link{RunModel_CemaNeigeGR4J}}, \code{\link{RunModel_CemaNeigeGR5J}}, \code{\link{RunModel_GR6J}},
#' \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}.
#' @example tests/example_RunModel_CemaNeigeGR6J.R
#' @useDynLib airGR
#' @encoding UTF-8
#' @export
#_FunctionInputs__________________________________________________________________________________________________
#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details
#' @param RunOptions [object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details
#' @param Param [numeric] vector of 8 parameters
#' \tabular{ll}{
#' GR6J X1 \tab production store capacity [mm] \cr
#' GR6J X2 \tab intercatchment exchange coefficient 1 [mm/d] \cr
#' GR6J X3 \tab routing store capacity [mm] \cr
#' GR6J X4 \tab unit hydrograph time constant [d] \cr
#' GR6J X5 \tab intercatchment exchange coefficient 2 [-] \cr
#' GR6J X6 \tab coefficient for emptying exponential store [-] \cr
#' CemaNeige X1 \tab weighting coefficient for snow pack thermal state [-] \cr
#' CemaNeige X2 \tab degree-day melt coefficient [mm/degC/d] \cr
#' }
#_FunctionOutputs_________________________________________________________________________________________________
#' @return [list] list containing the function outputs organised as follows:
#' \tabular{ll}{
#' \emph{$DatesR } \tab [POSIXlt] series of dates \cr
#' \emph{$PotEvap } \tab [numeric] series of input potential evapotranspiration [mm/d] \cr
#' \emph{$Precip } \tab [numeric] series of input total precipitation [mm/d] \cr
#' \emph{$Prod } \tab [numeric] series of production store level (X(2)) [mm] \cr
#' \emph{$AE } \tab [numeric] series of actual evapotranspiration [mm/d] \cr
#' \emph{$Perc } \tab [numeric] series of percolation (PERC) [mm/d] \cr
#' \emph{$PR } \tab [numeric] series of PR=PN-PS+PERC [mm/d] \cr
#' \emph{$Q9 } \tab [numeric] series of HU1 outflow (Q9) [mm/d] \cr
#' \emph{$Q1 } \tab [numeric] series of HU2 outflow (Q1) [mm/d] \cr
#' \emph{$Rout } \tab [numeric] series of routing store level (X(1)) [mm] \cr
#' \emph{$Exch } \tab [numeric] series of potential semi-exchange between catchments [mm/d] \cr
#' \emph{$AExch } \tab [numeric] series of actual exchange between catchments (1+2) [mm/d] \cr
#' \emph{$QR } \tab [numeric] series of routing store outflow (QR) [mm/d] \cr
#' \emph{$QR1 } \tab [numeric] series of exponential store outflow (QR1) [mm/d] \cr
#' \emph{$Exp } \tab [numeric] series of exponential store level (X(6)) (negative) [mm] \cr
#' \emph{$QD } \tab [numeric] series of direct flow from HU2 after exchange (QD) [mm/d] \cr
#' \emph{$Qsim } \tab [numeric] series of Qsim [mm/d] \cr
#' \emph{$CemaNeigeLayers} \tab [list] list of CemaNeige outputs (1 list per layer) \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Pliq } \tab [numeric] series of liquid precip. [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Psol } \tab [numeric] series of solid precip. [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$SnowPack } \tab [numeric] series of snow pack [mm] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$ThermalState } \tab [numeric] series of snow pack thermal state [degC] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Gratio } \tab [numeric] series of Gratio [0-1] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$PotMelt } \tab [numeric] series of potential snow melt [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$Melt } \tab [numeric] series of actual snow melt [mm/d] \cr
#' \emph{$CemaNeigeLayers[[iLayer]]$PliqAndMelt } \tab [numeric] series of liquid precip. + actual snow melt [mm/d] \cr
#' \emph{$StateEnd} \tab [numeric] states at the end of the run: \cr\tab res. & HU levels [mm], CemaNeige states [mm & degC] \cr
#' }
#' (refer to the provided references or to the package source code for further details on these model outputs)
#*****************************************************************************************************************
RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){
NParam <- 8; NParam <- 8;
...@@ -111,7 +40,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ ...@@ -111,7 +40,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){
##Call_DLL_CemaNeige_________________________ ##Call_DLL_CemaNeige_________________________
for(iLayer in 1:NLayers){ for(iLayer in 1:NLayers){
StateStartCemaNeige <- RunOptions$IniStates[ (NStatesMod+2*(iLayer-1)+1):(NStatesMod+2*(iLayer-1)+2) ]; StateStartCemaNeige <- RunOptions$IniStates[ (NStatesMod+2*(iLayer-1)+1):(NStatesMod+2*(iLayer-1)+2) ];
RESULTS <- .Fortran("frun_cemaneige",PACKAGE="airGR", RESULTS <- .Fortran("frun_CemaNeige",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/d] InputsPrecip=InputsModel$LayerPrecip[[iLayer]][IndPeriod1], ### input series of total precipitation [mm/d]
...@@ -154,12 +83,12 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ ...@@ -154,12 +83,12 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){
##Use_of_IniResLevels ##Use_of_IniResLevels
if("IniResLevels" %in% RunOptions){ if("IniResLevels" %in% RunOptions){
RunOptions$IniStates[1] <- RunOptions$IniResLevels[2]*ParamMod[3]; ### routing store level (mm) RunOptions$IniStates[1] <- RunOptions$IniResLevels[1]*ParamMod[1]; ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[1]*ParamMod[1]; ### production store level (mm) RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*ParamMod[3]; ### routing store level (mm)
} }
##Call_fortan ##Call_fortan
RESULTS <- .Fortran("frun_gr6j",PACKAGE="airGR", RESULTS <- .Fortran("frun_GR6J",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=CatchMeltAndPliq, ### input series of total precipitation [mm/d] InputsPrecip=CatchMeltAndPliq, ### input series of total precipitation [mm/d]
...@@ -172,7 +101,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ ...@@ -172,7 +101,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){
IndOutputs=IndOutputsMod, ### indices of output series IndOutputs=IndOutputsMod, ### indices of output series
##outputs ##outputs
Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputsMod)), ### output series [mm] Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputsMod)), ### output series [mm]
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$Outputs[ round(RESULTS$Outputs ,3)==(-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA; RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA;
......
#*****************************************************************************************************************
#' Function which performs a single run for the GR2M monthly lumped model.
#'
#' For further details on the model, see the references section.
#' For further details on the argument structures and initialisation options, see \code{\link{CreateRunOptions}}.
#*****************************************************************************************************************
#' @title Run with the GR2M hydrological model
#' @author Laurent Coron (March 2015)
#' @example tests/example_RunModel_GR2M.R
#' @references
#' Mouelhi S. (2003),
#' Vers une chaîne cohérente de modèles pluie-débit conceptuels globaux aux pas de temps pluriannuel, annuel, mensuel et journalier,
#' PhD thesis (in French), ENGREF, Cemagref Antony, France. \cr
#' Mouelhi, S., C. Michel, C. Perrin and V. Andréassian (2006),
#' Stepwise development of a two-parameter monthly water balance model,
#' Journal of Hydrology, 318(1-4), 200-214, doi:10.1016/j.jhydrol.2005.06.014.
#' @useDynLib airGR
#' @encoding UTF-8
#' @export
#_FunctionInputs__________________________________________________________________________________________________
#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details
#' @param RunOptions [object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details
#' @param Param [numeric] vector of 2 parameters
#' \tabular{ll}{
#' GR2M X1 \tab production store capacity [mm] \cr
#' GR2M X2 \tab groundwater exchange coefficient [-] \cr
#' }
#_FunctionOutputs_________________________________________________________________________________________________
#' @return [list] list containing the function outputs organised as follows:
#' \tabular{ll}{
#' \emph{$DatesR } \tab [POSIXlt] series of dates \cr
#' \emph{$PotEvap } \tab [numeric] series of input potential evapotranspiration [mm/month] \cr
#' \emph{$Precip } \tab [numeric] series of input total precipitation [mm/month] \cr
#' \emph{$Qsim } \tab [numeric] series of Qsim [mm/month] \cr
#' \emph{$StateEnd} \tab [numeric] states at the end of the run (res. levels, HU1 levels, HU2 levels) [mm] \cr
#' }
#' (refer to the provided references or to the package source code for further details on these model outputs)
#*****************************************************************************************************************
RunModel_GR2M <- function(InputsModel,RunOptions,Param){ RunModel_GR2M <- function(InputsModel,RunOptions,Param){
NParam <- 2; NParam <- 2;
FortranOutputs <- c("PotEvap","Precip","Prod","Rout","Qsim"); FortranOutputs <- c("PotEvap","Precip","AE","Perc","P3","Exch","Prod","Rout","Qsim");
### FortranOutputs <- c("PotEvap","Precip","Prod","AE","Perc","PR","Q9","Q1","Rout","Exch","AExch","QR","QD","Qsim");
##Arguments_check ##Arguments_check
if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); }
...@@ -65,7 +26,7 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){ ...@@ -65,7 +26,7 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){
} }
##Call_fortan ##Call_fortan
RESULTS <- .Fortran("frun_gr2m",PACKAGE="airGR", RESULTS <- .Fortran("frun_GR2M",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/month] InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/month]
...@@ -80,7 +41,7 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){ ...@@ -80,7 +41,7 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){
Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputs)), ### output series [mm] Outputs=matrix(as.double(-999.999),nrow=LInputSeries,ncol=length(IndOutputs)), ### output series [mm]
StateEnd=rep(as.double(-999.999),length(RunOptions$IniStates)) ### state variables at the end of the model run StateEnd=rep(as.double(-999.999),length(RunOptions$IniStates)) ### state variables at the end of the model run
) )
RESULTS$Outputs[ round(RESULTS$Outputs ,3)==(-999.999)] <- NA; RESULTS$Outputs [round(RESULTS$Outputs ,3)==(-999.999)] <- NA;
RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA; RESULTS$StateEnd[round(RESULTS$StateEnd,3)==(-999.999)] <- NA;
##Output_data_preparation ##Output_data_preparation
......
#*****************************************************************************************************************
#' Function which performs a single run for the GR4H hourly lumped model.
#'
#' For further details on the model, see the references section.
#' For further details on the argument structures and initialisation options, see \code{\link{CreateRunOptions}}.
#*****************************************************************************************************************
#' @title Run with the GR4H hydrological model
#' @author Laurent Coron (July 2014)
#' @seealso \code{\link{RunModel_GR4J}},
#' \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}.
#' @example tests/example_RunModel_GR4H.R
#' @references
#' Mathevet, T. (2005),
#' Quels modèles pluie-débit globaux pour le pas de temps horaire ? Développement empirique et comparaison de modèles sur un large échantillon de bassins versants,
#' PhD thesis (in French), ENGREF - Cemagref (Antony), Paris, France.
#' @useDynLib airGR
#' @encoding UTF-8
#' @export
#_FunctionInputs__________________________________________________________________________________________________
#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details
#' @param RunOptions [object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details
#' @param Param [numeric] vector of 4 parameters
#' \tabular{ll}{
#' GR4H X1 \tab production store capacity [mm] \cr
#' GR4H X2 \tab groundwater exchange coefficient [mm/h] \cr
#' GR4H X3 \tab routing store capacity [mm] \cr
#' GR4H X4 \tab unit hydrograph time constant [h] \cr
#' }
#_FunctionOutputs_________________________________________________________________________________________________
#' @return [list] list containing the function outputs organised as follows:
#' \tabular{ll}{
#' \emph{$DatesR } \tab [POSIXlt] series of dates \cr
#' \emph{$PotEvap } \tab [numeric] series of input potential evapotranspiration [mm/h] \cr
#' \emph{$Precip } \tab [numeric] series of input total precipitation [mm/h] \cr
#' \emph{$Prod } \tab [numeric] series of production store level (X(2)) [mm] \cr
#' \emph{$AE } \tab [numeric] series of actual evapotranspiration [mm/h] \cr
#' \emph{$Perc } \tab [numeric] series of percolation (PERC) [mm/h] \cr
#' \emph{$PR } \tab [numeric] series of PR=PN-PS+PERC [mm/h] \cr
#' \emph{$Q9 } \tab [numeric] series of HU1 outflow (Q9) [mm/h] \cr
#' \emph{$Q1 } \tab [numeric] series of HU2 outflow (Q1) [mm/h] \cr
#' \emph{$Rout } \tab [numeric] series of routing store level (X(1)) [mm] \cr
#' \emph{$Exch } \tab [numeric] series of potential semi-exchange between catchments [mm/h] \cr
#' \emph{$AExch } \tab [numeric] series of actual exchange between catchments (1+2) [mm/h] \cr
#' \emph{$QR } \tab [numeric] series of routing store outflow (QR) [mm/h] \cr
#' \emph{$QD } \tab [numeric] series of direct flow from HU2 after exchange (QD) [mm/h] \cr
#' \emph{$Qsim } \tab [numeric] series of Qsim [mm/h] \cr
#' \emph{$StateEnd} \tab [numeric] states at the end of the run (res. levels, HU1 levels, HU2 levels) [mm] \cr
#' }
#' (refer to the provided references or to the package source code for further details on these model outputs)
#*****************************************************************************************************************'
RunModel_GR4H <- function(InputsModel,RunOptions,Param){ RunModel_GR4H <- function(InputsModel,RunOptions,Param){
NParam <- 4; NParam <- 4;
...@@ -72,12 +22,12 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){ ...@@ -72,12 +22,12 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){
##Use_of_IniResLevels ##Use_of_IniResLevels
if("IniResLevels" %in% names(RunOptions)){ if("IniResLevels" %in% names(RunOptions)){
RunOptions$IniStates[1] <- RunOptions$IniResLevels[2]*Param[3]; ### routing store level (mm) RunOptions$IniStates[1] <- RunOptions$IniResLevels[1]*Param[1]; ### production store level (mm)
RunOptions$IniStates[2] <- RunOptions$IniResLevels[1]*Param[1]; ### production store level (mm) RunOptions$IniStates[2] <- RunOptions$IniResLevels[2]*Param[3]; ### routing store level (mm)
} }
##Call_fortan ##Call_fortan
RESULTS <- .Fortran("frun_gr4h",PACKAGE="airGR", RESULTS <- .Fortran("frun_GR4H",PACKAGE="airGR",
##inputs ##inputs
LInputs=LInputSeries, ### length of input and output series LInputs=LInputSeries, ### length of input and output series
InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/h] InputsPrecip=InputsModel$Precip[IndPeriod1], ### input series of total precipitation [mm/h]
......
#*****************************************************************************************************************
#' Function which performs a single run for the GR4J daily lumped model.
#'
#' For further details on the model, see the references section.
#' For further details on the argument structures and initialisation options, see \code{\link{CreateRunOptions}}.
#*****************************************************************************************************************
#' @title Run with the GR4J hydrological model
#' @author Laurent Coron (December 2013)
#' @references
#' Perrin, C., C. Michel and V. Andréassian (2003),
#' Improvement of a parsimonious model for streamflow simulation,
#' Journal of Hydrology, 279(1-4), 275-289, doi:10.1016/S0022-1694(03)00225-7.
#' @seealso \code{\link{RunModel_GR5J}}, \code{\link{RunModel_GR6J}}, \code{\link{RunModel_CemaNeigeGR4J}},
#' \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}.
#' @example tests/example_RunModel_GR4J.R
#' @useDynLib airGR
#' @encoding UTF-8
#' @export
#_FunctionInputs__________________________________________________________________________________________________
#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details
#' @param RunOptions [object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details
#' @param Param [numeric] vector of 4 parameters
#' \tabular{ll}{
#' GR4J X1 \tab production store capacity [mm] \cr
#' GR4J X2 \tab intercatchment exchange coefficient [mm/d] \cr
#' GR4J X3 \tab routing store capacity [mm] \cr
#' GR4J X4 \tab unit hydrograph time constant [d] \cr
#' }
#_FunctionOutputs_________________________________________________________________________________________________
#' @return [list] list containing the function outputs organised as follows:
#' \tabular{ll}{
#' \emph{$DatesR } \tab [POSIXlt] series of dates \cr
#' \emph{$PotEvap } \tab [numeric] series of input potential evapotranspiration [mm/d] \cr
#' \emph{$Precip } \tab [numeric] series of input total precipitation [mm/d] \cr
#' \emph{$Prod } \tab [numeric] series of production store level (X(2)) [mm] \cr
#' \emph{$AE } \tab [numeric] series of actual evapotranspiration [mm/d] \cr
#' \emph{$Perc } \tab [numeric] series of percolation (PERC) [mm/d] \cr
#' \emph{$PR } \tab [numeric] series of PR=PN-PS+PERC [mm/d] \cr
#' \emph{$Q9 } \tab [numeric] series of HU1 outflow (Q9) [mm/d] \cr
#' \emph{$Q1 } \tab [numeric] series of HU2 outflow (Q1) [mm/d] \cr
#' \emph{$Rout } \tab [numeric] series of routing store level (X(1)) [mm] \cr
#' \emph{$Exch } \tab [numeric] series of potential semi-exchange between catchments [mm/d] \cr
#' \emph{$AExch } \tab [numeric] series of actual exchange between catchments (1+2) [mm/d] \cr
#' \emph{$QR } \tab [numeric] series of routing store outflow (QR) [mm/d] \cr
#' \emph{$QD } \tab [numeric] series of direct flow from HU2 after exchange (QD) [mm/d] \cr
#' \emph{$Qsim } \tab [numeric] series of Qsim [mm/d] \cr
#' \emph{$StateEnd} \tab [numeric] states at the end of the run (res. levels, HU1 levels, HU2 levels) [mm] \cr
#' }
#' (refer to the provided references or to the package source code for further details on these model outputs)
#*****************************************************************************************************************'
RunModel_GR4J <- function(InputsModel,RunOptions,Param){ RunModel_GR4J <- function(InputsModel,RunOptions,Param){