From 7b2f5006cd50e5e1e59b72656c692539fd75a533 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Riette?= <sebastien.riette@meteo.fr>
Date: Tue, 21 Nov 2023 14:56:43 +0100
Subject: [PATCH] S. Riette 21 Nov 2023: enable single precision for the
 testprogs

---
 .../arch/arch-MIMPIIFC1805.EPONA.SNG.env      |  1 +
 .../arch/arch-MIMPIIFC1805.EPONA.SNG.fcm      | 25 +++++++++++++++++++
 .../arch/arch-MPIGFORTRAN920SNG.GMAP.env      |  0
 .../arch/arch-MPIGFORTRAN920SNG.GMAP.fcm      | 25 +++++++++++++++++++
 src/common/micro/mode_ice4_stepping.F90       |  1 +
 src/testprogs/ice_adjust/main_ice_adjust.F90  |  5 ++--
 src/testprogs/rain_ice/main_rain_ice.F90      |  5 ++--
 .../rain_ice_old/main_rain_ice_old.F90        |  9 +++++--
 src/testprogs/shallow/main_shallow.F90        |  5 ++--
 src/testprogs/turb_mnh/main_turb.F90          |  5 ++--
 10 files changed, 67 insertions(+), 14 deletions(-)
 create mode 100644 build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.env
 create mode 100644 build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.fcm
 create mode 100644 build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.env
 create mode 100644 build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.fcm

diff --git a/build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.env b/build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.env
new file mode 100644
index 000000000..8fdefeb29
--- /dev/null
+++ b/build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.env
@@ -0,0 +1 @@
+module load perl/5.30.3
diff --git a/build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.fcm b/build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.fcm
new file mode 100644
index 000000000..99a9ef109
--- /dev/null
+++ b/build/with_fcm/arch/arch-MIMPIIFC1805.EPONA.SNG.fcm
@@ -0,0 +1,25 @@
+# Compilation
+$FCOMPILER     =      /home/gmap/mrpm/khatib/public/bin/mimpifc-18.0.5.274
+$BASE_FFLAGS   =      -c -convert big_endian -assume byterecl -align array64byte,all -traceback -fpic -qopenmp -qopenmp-threadprivate compat -fp-model source -qopt-report=5 -qopt-report-phase=vec -ftz -diag-disable=remark,cpu-dispatch
+$PROD_FFLAGS   =      -g -O2 -march=core-avx2 -finline-functions -finline-limit=500 -Winline -qopt-prefetch=4 -fast-transcendentals -fimf-use-svml -no-fma
+$DEV_FFLAGS    =      -g -O0
+$DEBUG_FFLAGS  =      -g -O0  -check bounds  -init=arrays,snan -fp-stack-check -ftrapuv -fpe0 -fp-speculation=strict -check uninit -check pointers
+$CCOMPILER     =      /home/gmap/mrpm/khatib/public/bin/mimpicc-18.0.5.274
+$BASE_CFLAGS   =      -c -qopenmp -qopt-report=2 -qopt-report-phase=vec -fpic -malign-double -ftz -fp-model precise -diag-disable=remark,cpu-dispatch
+$PROD_CFLAGS   =      -g -O2 -march=core-avx2
+$DEV_CFLAGS    =     
+$DEBUG_CFLAGS  =     
+$OMP_FFLAGS    =
+
+# Preprocessor
+$FPP_FLAGS     =      LINUX LITTLE_ENDIAN LITTLE ADDRESS64 GRIB_API_1 REPRO48 PARKIND1_SINGLE
+$CPP_FLAGS     =      LINUX LITTLE_ENDIAN LITTLE GRIB_API_1 PARKIND1_SINGLE
+
+# Linker
+$LINK          =      /home/gmap/mrpm/khatib/public/bin/mimpifc-18.0.5.274
+$BASE_LD       =      -v -fp-stack-check -qopenmp -qopenmp-threadprivate compat -shared-intel -lrt -lstdc++
+$OMP_LD        =
+$LD_EXE_TO_SHARED =  -shared 
+
+# Other
+$AR            =      /usr/bin/ar 
diff --git a/build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.env b/build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.env
new file mode 100644
index 000000000..e69de29bb
diff --git a/build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.fcm b/build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.fcm
new file mode 100644
index 000000000..561a85432
--- /dev/null
+++ b/build/with_fcm/arch/arch-MPIGFORTRAN920SNG.GMAP.fcm
@@ -0,0 +1,25 @@
+# Compilation
+$FCOMPILER     =      mpigfortran.9.2.0 
+$BASE_FFLAGS   =      -c -fconvert=swap -fno-second-underscore -fbacktrace -m64 -fopenmp -ffree-line-length-none -fno-sign-zero -fpic -fno-range-check -g -pipe
+$PROD_FFLAGS   =      -g -O2
+$DEV_FFLAGS    =      -g -O0
+$DEBUG_FFLAGS  =      -g -O0  -fbounds-check  -finit-real=snan -ffpe-trap=invalid,zero,overflow
+$CCOMPILER     =      mpigcc.9.2.0
+$BASE_CFLAGS   =      -c -m64 -fopenmp -fpic -g -pipe
+$PROD_CFLAGS   =      -g -O2
+$DEV_CFLAGS    =     
+$DEBUG_CFLAGS  =     
+$OMP_FFLAGS    =
+
+# Preprocessor
+$FPP_FLAGS     =      LINUX LITTLE_ENDIAN LITTLE REPRO48 PARKIND1_SINGLE
+$CPP_FLAGS     =      LINUX LITTLE_ENDIAN LITTLE PARKIND1_SINGLE
+
+# Linker
+$LINK          =      mpigfortran.9.2.0
+$BASE_LD       =      -fopenmp -ffast-math -ldl -lrt
+$OMP_LD        =
+$LD_EXE_TO_SHARED =  -shared
+
+# Other
+$AR            =      ar 
diff --git a/src/common/micro/mode_ice4_stepping.F90 b/src/common/micro/mode_ice4_stepping.F90
index bef948291..a2b9e46c9 100644
--- a/src/common/micro/mode_ice4_stepping.F90
+++ b/src/common/micro/mode_ice4_stepping.F90
@@ -312,6 +312,7 @@ DO WHILE(ANY(ZTIME(1:KMICRO)<PTSTEP)) ! Loop to *really* compute tendencies
       DO JL=1, KMICRO
         IF (ZA(JL, JV) < -1.E-20 .AND. PVART(JL, JV) > ICED%XRTMIN(JV)) THEN
           ZMAXTIME(JL)=MIN(ZMAXTIME(JL), -(ZB(JL, JV)+PVART(JL, JV))/ZA(JL, JV))
+          ZMAXTIME(JL)=MAX(ZMAXTIME(JL), CST%XMNH_TINY) !to prevent rounding errors
         ENDIF
       ENDDO
     ENDDO
diff --git a/src/testprogs/ice_adjust/main_ice_adjust.F90 b/src/testprogs/ice_adjust/main_ice_adjust.F90
index a9a655ef3..77b85dac3 100644
--- a/src/testprogs/ice_adjust/main_ice_adjust.F90
+++ b/src/testprogs/ice_adjust/main_ice_adjust.F90
@@ -8,8 +8,7 @@ USE MODD_DIMPHYEX,   ONLY: DIMPHYEX_t
 USE MODD_PHYEX,      ONLY: PHYEX_t
 USE STACK_MOD
 USE OMP_LIB
-USE YOMHOOK, ONLY : LHOOK, DR_HOOK
-USE PARKIND1, ONLY : JPRB, JPIM
+USE YOMHOOK, ONLY : LHOOK, DR_HOOK, JPHOOK
 
 IMPLICIT NONE
 
@@ -73,7 +72,7 @@ REAL(KIND=8) :: TSC, TEC, TSD, TED, ZTC, ZTD
 INTEGER :: ITIME, NTIME
 INTEGER :: IRANK, ISIZE
 LOGICAL :: LLVERBOSE, LLSTAT, LLBIND
-REAL (KIND=JPRB) :: ZHOOK_HANDLE
+REAL (KIND=JPHOOK) :: ZHOOK_HANDLE
 
 CALL INITOPTIONS ()
 NGPBLKS = 296
diff --git a/src/testprogs/rain_ice/main_rain_ice.F90 b/src/testprogs/rain_ice/main_rain_ice.F90
index d2f53a272..4a6055341 100644
--- a/src/testprogs/rain_ice/main_rain_ice.F90
+++ b/src/testprogs/rain_ice/main_rain_ice.F90
@@ -8,8 +8,7 @@ USE MODD_DIMPHYEX,   ONLY: DIMPHYEX_t
 USE MODD_PHYEX,      ONLY: PHYEX_t
 USE STACK_MOD
 USE OMP_LIB
-USE YOMHOOK, ONLY : LHOOK, DR_HOOK
-USE PARKIND1, ONLY : JPRB, JPIM
+USE YOMHOOK, ONLY : LHOOK, DR_HOOK, JPHOOK
 
 IMPLICIT NONE
 
@@ -67,7 +66,7 @@ REAL(KIND=8) :: TSC, TEC, TSD, TED, ZTC, ZTD
 INTEGER :: ITIME, NTIME
 INTEGER :: IRANK, ISIZE
 LOGICAL :: LLVERBOSE, LLSTAT, LLBIND
-REAL (KIND=JPRB) :: ZHOOK_HANDLE
+REAL (KIND=JPHOOK) :: ZHOOK_HANDLE
 CHARACTER(LEN=32) :: CLTEXT
 
 CALL INITOPTIONS ()
diff --git a/src/testprogs/rain_ice_old/main_rain_ice_old.F90 b/src/testprogs/rain_ice_old/main_rain_ice_old.F90
index 8de4c7cea..55dc41c63 100644
--- a/src/testprogs/rain_ice_old/main_rain_ice_old.F90
+++ b/src/testprogs/rain_ice_old/main_rain_ice_old.F90
@@ -5,8 +5,7 @@ program main_rain_ice_old
 
   use modi_rain_ice_old
 
-  use yomhook, only: lhook, dr_hook
-  use parkind1, only: jprb, jpim
+  use yomhook, only: lhook, dr_hook, jphook
 
   use modd_dimphyex, only: dimphyex_t
   use modd_cst, only: cst
@@ -84,6 +83,8 @@ program main_rain_ice_old
 
   integer :: i, j, jrr
 
+  real(kind=jphook) :: zhook_handle
+
   real(8) :: time_start_real, time_end_real
   real(8) :: time_start_cpu, time_end_cpu
 
@@ -235,6 +236,8 @@ ENDDO
   call system_clock(count=counter, count_rate=c_rate)
   time_start_real = real(counter,8)/c_rate
 
+  if(lhook) call dr_hook ('MAIN',0,zhook_handle)
+
   do i = 1, n_gp_blocks
 
     isize = count(llmicro(:,:,i))
@@ -272,6 +275,8 @@ ENDDO
 
   enddo
 
+  if(lhook) call dr_hook ('MAIN',1,zhook_handle)
+
   call cpu_time(time_end_cpu)
   call system_clock(count=counter, count_rate=c_rate)
   time_end_real = real(counter,8)/c_rate
diff --git a/src/testprogs/shallow/main_shallow.F90 b/src/testprogs/shallow/main_shallow.F90
index f9b313141..4273072ef 100644
--- a/src/testprogs/shallow/main_shallow.F90
+++ b/src/testprogs/shallow/main_shallow.F90
@@ -8,8 +8,7 @@ USE MODD_DIMPHYEX,   ONLY: DIMPHYEX_t
 USE MODD_PHYEX,      ONLY: PHYEX_t
 USE STACK_MOD
 USE OMP_LIB
-USE YOMHOOK, ONLY : LHOOK, DR_HOOK
-USE PARKIND1, ONLY : JPRB, JPIM
+USE YOMHOOK, ONLY : LHOOK, DR_HOOK, JPHOOK
 
 IMPLICIT NONE
 
@@ -119,7 +118,7 @@ REAL(KIND=8) :: TSC, TEC, TSD, TED, ZTC, ZTD
 INTEGER :: ITIME, NTIME
 INTEGER :: IRANK, ISIZE
 LOGICAL :: LLVERBOSE, LLSTAT, LLBIND
-REAL (KIND=JPRB) :: ZHOOK_HANDLE
+REAL (KIND=JPHOOK) :: ZHOOK_HANDLE
 CHARACTER(LEN=32) :: CLTEXT
 
 CALL INITOPTIONS ()
diff --git a/src/testprogs/turb_mnh/main_turb.F90 b/src/testprogs/turb_mnh/main_turb.F90
index 4dfdf8725..423b7b419 100644
--- a/src/testprogs/turb_mnh/main_turb.F90
+++ b/src/testprogs/turb_mnh/main_turb.F90
@@ -8,8 +8,7 @@ USE MODD_DIMPHYEX,   ONLY: DIMPHYEX_t
 USE MODD_PHYEX,      ONLY: PHYEX_t
 USE STACK_MOD
 USE OMP_LIB
-USE YOMHOOK, ONLY : LHOOK, DR_HOOK
-USE PARKIND1, ONLY : JPRB, JPIM
+USE YOMHOOK, ONLY : LHOOK, DR_HOOK, JPHOOK
 USE MODD_LES,        ONLY: TLES_t
 
 IMPLICIT NONE
@@ -131,7 +130,7 @@ REAL(KIND=8) :: TSC, TEC, TSD, TED, ZTC, ZTD
 INTEGER :: ITIME, NTIME
 INTEGER :: IRANK, ISIZE
 LOGICAL :: LLVERBOSE, LLSTAT, LLBIND
-REAL (KIND=JPRB) :: ZHOOK_HANDLE
+REAL (KIND=JPHOOK) :: ZHOOK_HANDLE
 CHARACTER(LEN=32) :: CLTEXT
 
 CALL INITOPTIONS ()
-- 
GitLab