diff --git a/R/CreateInputsCrit.GRiwrmInputsModel.R b/R/CreateInputsCrit.GRiwrmInputsModel.R index 1430274b2245739e360102c6eb7ba260c2fb56c8..8cef43058954b5bd23526b5ff04f788412eff326 100644 --- a/R/CreateInputsCrit.GRiwrmInputsModel.R +++ b/R/CreateInputsCrit.GRiwrmInputsModel.R @@ -61,6 +61,10 @@ CreateInputsCrit.GRiwrmInputsModel <- function(InputsModel, stop("'AprioriIds': the node \"", AprioriIds[id], "\" is an ungauged upstream node of the node \"", id,"\"") } + if (!identical(InputsModel[[id]]$FUN_MOD, InputsModel[[AprioriIds[id]]]$FUN_MOD)) { + stop("'AprioriIds': the node \"", AprioriIds[id], + "\" must use the same hydrological model as the node \"", id,"\"") + } }) } diff --git a/tests/testthat/test-CreateInputsCrit.R b/tests/testthat/test-CreateInputsCrit.R index f5b55d689867bb9269ddbe3f14cd42d8379cc401..3d02d28056fedb515635e283026b6655c0f7b45b 100644 --- a/tests/testthat/test-CreateInputsCrit.R +++ b/tests/testthat/test-CreateInputsCrit.R @@ -109,6 +109,18 @@ test_that("Lavenne criterion: wrong sub-catchment order should throw error", { ) }) +test_that("Lavenne criterion: current node and a priori node must use the same model", { + InputsModel[["54032"]]$FUN_MOD <- RunModel_GR6J + expect_error( + CreateInputsCrit(InputsModel = InputsModel, + RunOptions = RunOptions, + Obs = Qobs[IndPeriod_Run,], + AprioriIds = AprioriIds, + transfo = "sqrt"), + regexp = "must use the same hydrological model" + ) +}) + test_that("Ungauged node as Apriori node should throw an error", { nodes$model[nodes$gauge_id == "54001"] <- "Ungauged" griwrm <- CreateGRiwrm(