From 608c654342f282674f1b70d2e2018c7f77ca32b2 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@inrae.fr>
Date: Mon, 25 Jul 2022 11:08:12 +0200
Subject: [PATCH] fix: crash of ConvertMeteoSD with null area upstream nodes

Fix #89
---
 R/ConvertMeteoSD.R | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/R/ConvertMeteoSD.R b/R/ConvertMeteoSD.R
index ea3ed7c..6da9fd2 100644
--- a/R/ConvertMeteoSD.R
+++ b/R/ConvertMeteoSD.R
@@ -26,7 +26,7 @@ ConvertMeteoSD.GRiwrm <- function(x, meteo, ...) {
 #' @export
 #' @rdname ConvertMeteoSD
 ConvertMeteoSD.character <- function(x, griwrm, meteo, ...) {
-  upperBasins <- !is.na(griwrm$down) & griwrm$down == x
+  upperBasins <- !is.na(griwrm$down) & griwrm$down == x & !is.na(griwrm$area)
   if(all(!upperBasins)) {
     return(meteo[,x])
   }
-- 
GitLab