From 272dd095d868a649915a522d87cbae24e74cd7b8 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Fri, 22 Mar 2019 16:26:40 +0100
Subject: [PATCH] Philippe 22/03/2019: SURFEX: use MNH_REAL key instead of
 MNH_MPI_DOUBLE_PRECISION

---
 src/SURFEX/ini_csts.F90      | 11 ++++++++---
 src/SURFEX/modd_surf_par.F90 | 11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/SURFEX/ini_csts.F90 b/src/SURFEX/ini_csts.F90
index 39462a53a..a17a39e36 100644
--- a/src/SURFEX/ini_csts.F90
+++ b/src/SURFEX/ini_csts.F90
@@ -54,6 +54,9 @@
 !              ------------
 !
 USE MODD_CSTS
+#ifdef SFX_MNH
+USE MODD_PRECISION, ONLY: MNHREAL
+#endif
 !
 !
 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
@@ -78,10 +81,12 @@ REAL(KIND=JPRB) :: ZHOOK_HANDLE
 IF (LHOOK) CALL DR_HOOK('INI_CSTS',0,ZHOOK_HANDLE)
 
 #ifdef SFX_MNH
-#ifdef MNH_MPI_DOUBLE_PRECISION
-XSURF_TINY    = 1.0e-80
-#else
+#if (MNH_REAL == 8)
+XSURF_TINY    = 1.0e-80_MNHREAL
+#elif (MNH_REAL == 4)
 XSURF_TINY    = TINY    (XSURF_TINY    )
+#else
+#error "Invalid MNH_REAL"
 #endif
 #else
 XSURF_TINY    = 1.0e-80
diff --git a/src/SURFEX/modd_surf_par.F90 b/src/SURFEX/modd_surf_par.F90
index 2947cd3b0..f38334f2d 100644
--- a/src/SURFEX/modd_surf_par.F90
+++ b/src/SURFEX/modd_surf_par.F90
@@ -33,6 +33,9 @@ MODULE MODD_SURF_PAR
 !*       0.   DECLARATIONS
 !             ------------
 !
+#ifdef SFX_MNH
+USE MODD_PRECISION, ONLY: MNHREAL
+#endif
 !
 IMPLICIT NONE
 !
@@ -43,10 +46,12 @@ INTEGER :: NBUGFIX   ! bugfix number of this version
 #ifndef SFX_MNH
 REAL,    PARAMETER :: XUNDEF = 1.E+20
 #else 
-#ifdef MNH_MPI_DOUBLE_PRECISION
-REAL,    PARAMETER :: XUNDEF = 1.E+20! HUGE(XUNDEF) ! Z'7FFFFFFFFFFFFFFF' !  undefined value
+#if (MNH_REAL == 8)
+REAL,    PARAMETER :: XUNDEF = 1.E+20_MNHREAL ! HUGE(XUNDEF) ! Z'7FFFFFFFFFFFFFFF' !  undefined value
+#elif (MNH_REAL == 4)
+REAL,    PARAMETER :: XUNDEF = 1.E+9_MNHREAL  ! HUGE(XUNDEF) ! Z'7FBFFFFF' ! undefined value
 #else
-REAL,    PARAMETER :: XUNDEF = 1.E+9 ! HUGE(XUNDEF) ! Z'7FBFFFFF' ! undefined value
+#error "Invalid MNH_REAL"
 #endif
 #endif
 INTEGER, PARAMETER :: NUNDEF = 1E+9   !  HUGE(NUNDEF) !  undefined value
-- 
GitLab