From 9f7e9ffef1f7a0ca33314634a079e7673fb2384b Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Thu, 18 Jul 2024 15:11:51 +0200
Subject: [PATCH] Jean W. 18/07/2024: SURFEX add init of old pressure to actual
 pressure. Previous pressure is used in BEM but is default is wrong leading to
 possible crash at first timestep.

---
 src/SURFEX/coupling_tebn.F90 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/SURFEX/coupling_tebn.F90 b/src/SURFEX/coupling_tebn.F90
index 3626e3764..73615be56 100644
--- a/src/SURFEX/coupling_tebn.F90
+++ b/src/SURFEX/coupling_tebn.F90
@@ -1061,6 +1061,14 @@ DO JP = 1,TOP%NTEB_PATCH
      CALL ABOR1_SFX("COUPLING_TEBN: Negative humidity in canyon")
   ENDIF
   !
+    !CHECK if old pressure is initialized
+  
+  IF (ANY(NB%AL(JP)%XPSOLD(:)==XUNDEF)) THEN
+  NB%AL(JP)%XPSOLD(:)=PPS(:)
+  
+  END IF
+  
+  
   CALL TOWN_ENERGY_BALANCE(DTCO, G, TOP, SPAOP, NT%AL(JP), BOP, NB%AL(JP), TPN, TIR, TD%NDMT%AL(JP), GDM, GRM, &
        HM, SB, CT, JP, HPROGRAM, CIMPLICIT_WIND, PTSUN, ZT_CAN, ZQ_CAN, ZU_CANYON, ZT_LOWCAN,  &
        ZQ_LOWCAN, ZU_LOWCAN, ZZ_LOWCAN, ZTA_HVEG, ZQA_HVEG,                                    &
-- 
GitLab