From 4a3440be88e7d47e3ac96c166acb9b17f05a60d9 Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Thu, 18 Jul 2024 14:54:07 +0200
Subject: [PATCH] Jean W. 18/07/2024: SURFEX fix to avoid too violent spin-up
 in Post-treatment on fluxes to avoid extra-large positive latent and negative
 sensible fluxes

---
 src/SURFEX/isba_hveg.F90 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/SURFEX/isba_hveg.F90 b/src/SURFEX/isba_hveg.F90
index 2c32ae292..7bad4f3ad 100644
--- a/src/SURFEX/isba_hveg.F90
+++ b/src/SURFEX/isba_hveg.F90
@@ -399,6 +399,11 @@ WHERE (PLE_HVEG>PRN_HVEG .AND. PEK%XTV<PTA-1.)
   ZDELTA_H = PRHOA * XCPD * ZVEG * (ZDT ) / PEK%XRESA / PEXNS
   ZDELTA_G = ZVEG * ZCHEATV * ZDT / PTSTEP
   ZDELTA_LE= - ZDELTA_H - ZDELTA_G
+  !
+  ! J. Wurtz & V. Masson Check if ZDELTA_LE > 0 to avoid too violent spin-up
+  ! Residual is increased of remaining energy
+  ZDELTA_LE= MAX(ZDELTA_LE, -PLE_HVEG)
+  ZDELTA_G= - ZDELTA_H - ZDELTA_LE
 END WHERE
 !
 PH_HVEG (:) = PH_HVEG (:) + ZDELTA_H (:)
-- 
GitLab