From 25df1f826187397a69243338011b09b05f086744 Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Mon, 28 Feb 2022 17:07:12 +0100
Subject: [PATCH] Quentin 28/02/2022: add REPRO48 bugfix from
 /mesonh/turb/mode_turb_ver_thermo_corr.F90 for PSIGS

---
 src/common/turb/mode_turb_ver.F90             | 2 +-
 src/common/turb/mode_turb_ver_thermo_corr.F90 | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/common/turb/mode_turb_ver.F90 b/src/common/turb/mode_turb_ver.F90
index 6b6b3eb42..49ed101bb 100644
--- a/src/common/turb/mode_turb_ver.F90
+++ b/src/common/turb/mode_turb_ver.F90
@@ -519,7 +519,7 @@ ENDIF
                         PRTHLS,PRRS,ZTHLP,ZRP,PTP,PWTH,PWRC )
 !
   CALL  TURB_VER_THERMO_CORR(KKA,KKU,KKL,KRR,KRRL,KRRI,               &
-                        OTURB_FLX,HTURBDIM,HTOM,OOCEAN,               &
+                        OTURB_FLX,HTURBDIM,HTOM,                      &
                         PIMPL,PEXPL,                                  &
                         TPFILE,                                       &
                         PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,           &
diff --git a/src/common/turb/mode_turb_ver_thermo_corr.F90 b/src/common/turb/mode_turb_ver_thermo_corr.F90
index a04c35ab9..db08f0ce6 100644
--- a/src/common/turb/mode_turb_ver_thermo_corr.F90
+++ b/src/common/turb/mode_turb_ver_thermo_corr.F90
@@ -6,7 +6,7 @@ MODULE MODE_TURB_VER_THERMO_CORR
 IMPLICIT NONE
 CONTAINS      
 SUBROUTINE TURB_VER_THERMO_CORR(KKA,KKU,KKL,KRR,KRRL,KRRI,    &
-                      OTURB_FLX,HTURBDIM,HTOM,OOCEAN,               &
+                      OTURB_FLX,HTURBDIM,HTOM,                      &
                       PIMPL,PEXPL,                                  &
                       TPFILE,                                       &
                       PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,           &
@@ -238,7 +238,6 @@ INTEGER,                INTENT(IN)   :: KRRL          ! number of liquid water v
 INTEGER,                INTENT(IN)   :: KRRI          ! number of ice water var.
 LOGICAL,                INTENT(IN)   ::  OTURB_FLX    ! switch to write the
                                  ! turbulent fluxes in the syncronous FM-file
-LOGICAL,                INTENT(IN)   ::  OOCEAN       ! switch for Ocean model version
 CHARACTER(len=4),       INTENT(IN)   ::  HTURBDIM     ! dimensionality of the
                                                       ! turbulence scheme
 CHARACTER(len=4),       INTENT(IN)   ::  HTOM         ! type of Third Order Moment
@@ -845,8 +844,12 @@ ENDIF
     ! Extrapolate PSIGS at the ground and at the top
     PSIGS(:,:,KKA) = PSIGS(:,:,IKB)
     PSIGS(:,:,KKU) = PSIGS(:,:,IKE)
-    PSIGS(:,:,:) =   MAX (PSIGS(:,:,:) , 0.)
+#ifdef REPRO48
+    PSIGS(:,:,:) =  MAX (PSIGS(:,:,:) , 0.)
     PSIGS(:,:,:) =  SQRT(PSIGS(:,:,:))
+#else
+    PSIGS(:,:,:) =  SQRT( MAX (PSIGS(:,:,:) , 1.E-12) )
+#endif
   END IF
 
 !
-- 
GitLab