From 3a1003f6ff49e3b36542bdd763c8efe5814e1a05 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@irstea.fr>
Date: Sat, 23 May 2020 16:19:13 +0200
Subject: [PATCH] Fix: correct area of intermediate basin passed to lag model

Refs #2
---
 R/RunModelGriwrm.R | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/R/RunModelGriwrm.R b/R/RunModelGriwrm.R
index ad96421..2cc7687 100644
--- a/R/RunModelGriwrm.R
+++ b/R/RunModelGriwrm.R
@@ -79,7 +79,13 @@ SetAirGrInputsAndOptions <- function(id, ginet, girop, gits, OutputsModels, IndP
       }
     }
     LengthHydro <- matrix(ginet$length[girop$id %in% UpstrNodes] , nrow = 1)
-    BasinAreas <- matrix(c(girop$area[girop$id %in% UpstrNodes], girop$area[girop$id == id]) , nrow = 1)
+    BasinAreas <- matrix(
+      c(
+        girop$area[girop$id %in% UpstrNodes],
+        girop$area[girop$id == id] - sum(girop$area[girop$id %in% UpstrNodes])
+      ),
+      nrow = 1
+    )
   }
   # Set model inputs
   InputsModel <- CreateInputsModel(
-- 
GitLab