From ae5af36cf5936e21b7c517efe6e85f9f1e63c8f2 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Tue, 9 Jul 2019 15:48:12 +0200
Subject: [PATCH] Philippe 09/07/2019: bug corrections to allow correct
 compilation

---
 src/MNH/gradient_m.f90           |  4 ++--
 src/MNH/ice4_nucleation.f90      |  2 +-
 src/MNH/ppm.f90                  | 30 ++++++++++++++++++++++--------
 src/MNH/turb_ver_thermo_corr.f90 |  3 ++-
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/MNH/gradient_m.f90 b/src/MNH/gradient_m.f90
index f65faf2dd..09ca81931 100644
--- a/src/MNH/gradient_m.f90
+++ b/src/MNH/gradient_m.f90
@@ -138,7 +138,7 @@ REAL, DIMENSION(:,:,:), INTENT(IN)  :: PDZZ                   !d*zz
 !
 REAL, DIMENSION(:,:,:), INTENT(IN)                :: PY       ! variable at mass
                                                               ! localization
-REAL, DIMENSION(:,:,:)              :: PGY_M_V  ! result at flux side
+REAL, DIMENSION(SIZE(PY,1),SIZE(PY,2),SIZE(PY,3)) :: PGY_M_V  ! result at flux side
 END FUNCTION GY_M_V
 !
 !
@@ -969,7 +969,7 @@ REAL, DIMENSION(:,:,:), INTENT(IN)  :: PDZZ                   !d*zz
 !
 REAL, DIMENSION(:,:,:), INTENT(IN)                :: PY       ! variable at mass
                                                               ! localization
-REAL, DIMENSION(:,:,:)               :: PGY_M_V  ! result at flux side
+REAL, DIMENSION(SIZE(PY,1),SIZE(PY,2),SIZE(PY,3)) :: PGY_M_V  ! result at flux side
 
 INTEGER  IJU,IKU,JJ,JK
 !
diff --git a/src/MNH/ice4_nucleation.f90 b/src/MNH/ice4_nucleation.f90
index 4f1ebb48d..73c5f20b1 100644
--- a/src/MNH/ice4_nucleation.f90
+++ b/src/MNH/ice4_nucleation.f90
@@ -175,7 +175,7 @@ IF(.NOT. GDSOFT) THEN
       ZZW(JI)=XNU20*EXP(XALPHA2*ZSSI(JI)-XBETA2)
     ELSE IF (GWORK2(JI)) THEN
       ZZW(JI)=MAX(XNU20*(-XBETA2 ), &
-              XNU10*EXP(-XBETA1*(PT(JI)-XTT))*(ZSSI(JI)/ZUSW(JI)**XALPHA1)
+              XNU10*EXP(-XBETA1*(PT(JI)-XTT))*(ZSSI(JI)/ZUSW(JI))**XALPHA1)
     END IF
   END DO
 #endif
diff --git a/src/MNH/ppm.f90 b/src/MNH/ppm.f90
index 6323a8f9e..a96d8c7f5 100644
--- a/src/MNH/ppm.f90
+++ b/src/MNH/ppm.f90
@@ -474,7 +474,9 @@ REAL, DIMENSION(IIU,IJU,IKU), INTENT(OUT) :: PR
 INTEGER:: IIB,IJB    ! Begining useful area in x,y,z directions
 INTEGER:: IIE,IJE    ! End useful area in x,y,z directions
 !
+integer :: ji, jj, jk
 #ifndef _OPENACC
+integer :: iiu, iju, iku
 ! terms used in parabolic interpolation, dmq, qL, qR, dq, q6
 REAL, DIMENSION(SIZE(PCR,1),SIZE(PCR,2),SIZE(PCR,3)) :: ZQL,ZQR
 REAL, DIMENSION(SIZE(PCR,1),SIZE(PCR,2),SIZE(PCR,3)) :: ZDQ,ZQ6
@@ -491,7 +493,6 @@ INTEGER                          :: IJS,IJN
 !END JUAN PPM_LL
 #else
 INTEGER                          :: I,J,K 
-integer                          :: ji, jj, jk
 !
 !!$!
 !!$! terms used in parabolic interpolation, dmq, qL, qR, dq, q6
@@ -525,6 +526,10 @@ GEAST = LEAST_ll()
 !*              initialise & update halo & halo2 for PSRC
 !
 #ifndef _OPENACC
+iiu = size( PSRC, 1 )
+iju = size( PSRC, 2 )
+iku = size( PSRC, 3 )
+
 CALL GET_HALO(PSRC)
 !
 PR   (:,:,:) = PSRC(:,:,:)
@@ -1153,6 +1158,9 @@ IMPLICIT NONE
 !
 !*       0.1   Declarations of dummy arguments :
 !
+#ifdef _OPENACC
+integer, intent(in) :: iiu, iju, iku
+#endif
 CHARACTER (LEN=4), DIMENSION(2), INTENT(IN) :: HLBCY  ! Y direction LBC type
 !
 INTEGER,                INTENT(IN)  :: KGRID   ! C grid localisation
@@ -1182,6 +1190,7 @@ INTEGER                          :: IIW,IIA
 !
 LOGICAL                          :: GSOUTH , GNORTH
 #ifndef _OPENACC
+integer ::  iiu, iju, iku
 !
 ! terms used in parabolic interpolation, dmq, qL, qR, dq, q6
 REAL, DIMENSION(SIZE(PCR,1),SIZE(PCR,2),SIZE(PCR,3)) :: ZQL,ZQR
@@ -1206,7 +1215,7 @@ REAL, DIMENSION(IIU,IJU,IKU) :: &
 
 !
 !JUAN ACC
-INTEGER                          :: I,J,K ,IIU,IJU,IKU
+INTEGER                          :: I,J,K
 !
 INTEGER                          :: IKB,IKE
 INTEGER                          :: IJN,IJS
@@ -1226,6 +1235,10 @@ GSOUTH=LSOUTH_ll()
 GNORTH=LNORTH_ll()
 !
 #ifndef _OPENACC
+iiu = size( PSRC, 1 )
+iju = size( PSRC, 2 )
+iku = size( PSRC, 3 )
+
 CALL GET_HALO(PSRC)
 #else
 IJS=1
@@ -1838,6 +1851,9 @@ IMPLICIT NONE
 !
 !*       0.1   Declarations of dummy arguments :
 !
+#ifdef _OPENACC
+integer,                intent(in)    :: iiu, iju, iku
+#endif
 INTEGER,                INTENT(IN)  :: KGRID   ! C grid localisation
 !
 #ifndef _OPENACC
@@ -1863,9 +1879,9 @@ REAL, DIMENSION(IIU,IJU,IKU), INTENT(OUT) :: PR
 !*       0.2   Declarations of local variables :
 !
 #ifndef _OPENACC
+INTEGER :: IIU, IJU, IKU
 INTEGER:: IKB    ! Begining useful area in x,y,z directions
 INTEGER:: IKE    ! End useful area in x,y,z directions
-INTEGER:: IKU
 !
 ! terms used in parabolic interpolation, dmq, qL, qR, dq, q6
 REAL, DIMENSION(SIZE(PCR,1),SIZE(PCR,2),SIZE(PCR,3)) :: ZQL,ZQR
@@ -1892,11 +1908,7 @@ REAL, DIMENSION(IIU,IJU,IKU) :: &
 INTEGER:: IKB    ! Begining useful area in x,y,z directions
 INTEGER:: IKE    ! End useful area in x,y,z directions
 !
-!JUAN ACC
-INTEGER                          :: IIU,IJU,IKU
-!
 INTEGER                          :: I,J,K 
-!JUAN ACC
 #endif
 integer                          :: ji, jj, jk
 !
@@ -1908,7 +1920,9 @@ integer                          :: ji, jj, jk
 IKB = 1 + JPVEXT
 IKE = SIZE(PSRC,3) - JPVEXT
 #ifndef _OPENACC
-IKU = SIZE(PSRC,3)
+iiu = size( PSRC, 1 )
+iju = size( PSRC, 2 )
+iku = size( PSRC, 3 )
 #endif
 !
 !-------------------------------------------------------------------------------
diff --git a/src/MNH/turb_ver_thermo_corr.f90 b/src/MNH/turb_ver_thermo_corr.f90
index 5732723a1..372cc9f32 100644
--- a/src/MNH/turb_ver_thermo_corr.f90
+++ b/src/MNH/turb_ver_thermo_corr.f90
@@ -1004,7 +1004,8 @@ END IF
     CALL DZM_DEVICE(KKA,KKU,KKL,ZTMP8_DEVICE,ZTMP1_DEVICE)
     !!!
     !$acc kernels
-    ZTMP7_DEVICE = (ZTMP3_DEVICE +ZTMP4_DEVICE) *PDR_DZ  *ZTMP2_DEVICE / PDZZ + (ZTMP5_DEVICE+ZTMP6_DEVICE) *PDTH_DZ *ZTMP1_DEVICE / PDZZ
+    ZTMP7_DEVICE =   ( ZTMP3_DEVICE + ZTMP4_DEVICE) * PDR_DZ  * ZTMP2_DEVICE / PDZZ &
+                   + ( ZTMP5_DEVICE + ZTMP6_DEVICE) * PDTH_DZ * ZTMP1_DEVICE / PDZZ
     !$acc end kernels
     !!!
     !$acc kernels
-- 
GitLab