From c56f457d0c7cbbc840f0d8a0d5fbd01d0454b8ab Mon Sep 17 00:00:00 2001 From: David <david.dorchies@inrae.fr> Date: Tue, 22 Nov 2022 18:20:03 +0100 Subject: [PATCH] fix: error on CreateInputsModel with node RunModel_Lag and area=NA Refs #107 --- R/CreateInputsModel.GRiwrm.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/R/CreateInputsModel.GRiwrm.R b/R/CreateInputsModel.GRiwrm.R index 557ae31..801fd13 100644 --- a/R/CreateInputsModel.GRiwrm.R +++ b/R/CreateInputsModel.GRiwrm.R @@ -278,11 +278,13 @@ CreateOneGRiwrmInputsModel <- function(id, griwrm, ..., Qobs, Qmin) { griwrm$area[UpstreamNodeRows], node$area - sum(griwrm$area[UpstreamNodeRows], na.rm = TRUE) ) - if (BasinAreas[length(BasinAreas)] < 0) { - stop(sprintf( - "Area of the catchment %s must be greater than the sum of the areas of its upstream catchments", - id - )) + if (!is.na(node$area)) { + if (BasinAreas[length(BasinAreas)] < 0) { + stop(sprintf( + "Area of the catchment %s must be greater than the sum of the areas of its upstream catchments", + id + )) + } } names(BasinAreas) <- c(griwrm$id[UpstreamNodeRows], id) } -- GitLab