From 5d52933b2c3ec9fe38f085c8a6fa04715bba753b Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@inrae.fr>
Date: Wed, 14 Apr 2021 18:03:32 +0200
Subject: [PATCH] fix: Qupstream conversion error with several upstream flows

Refs #110
---
 R/CreateInputsModel.R | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/R/CreateInputsModel.R b/R/CreateInputsModel.R
index 5b4fa88a..7a24cf3c 100644
--- a/R/CreateInputsModel.R
+++ b/R/CreateInputsModel.R
@@ -336,7 +336,8 @@ CreateInputsModel <- function(FUN_MOD,
     # Qupstream is internally stored in m3/time step
     if (QupstrUnit == "mm") {
       iConvBasins <- which(!is.na(BasinAreas[seq.int(length(LengthHydro))]))
-      Qupstream[,iConvBasins] <- Qupstream[,iConvBasins] * BasinAreas[iConvBasins] * 1e3
+      Qupstream[,iConvBasins] <-
+        Qupstream[,iConvBasins] * rep(BasinAreas[iConvBasins], each = LLL) * 1e3
     } else if (QupstrUnit == "m3/s") {
       Qupstream <- Qupstream * TimeStep
     } else if (QupstrUnit == "l/s") {
-- 
GitLab