From f96883deadac434dcec8d41cf226fe169a3efc7d Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Mon, 16 Jan 2017 13:08:40 +0100
Subject: [PATCH] Philippe 16/01/2017: OpenACC: added missing if(n)def OPENACC

---
 src/MNH/advection_metsv.f90 | 11 +++++++++++
 src/MNH/init_mnh.f90        |  4 ++++
 src/MNH/les_mean_1proc.f90  |  2 ++
 src/MNH/mode_prandtl.f90    |  8 +++++++-
 src/MNH/prandtl.f90         |  6 ++++++
 5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/MNH/advection_metsv.f90 b/src/MNH/advection_metsv.f90
index cc1b8cf7d..39b1b0a38 100644
--- a/src/MNH/advection_metsv.f90
+++ b/src/MNH/advection_metsv.f90
@@ -553,6 +553,7 @@ END DO
 !
 ! Top and bottom Boundaries 
 !
+#ifdef _OPENACC
 CALL ADV_BOUNDARIES_DEVICE (HLBCX, HLBCY, ZRTHS_OTHER)
 IF (GTKE) CALL ADV_BOUNDARIES_DEVICE (HLBCX, HLBCY, ZRTKES_OTHER)
 DO JR = 1, KRR
@@ -562,6 +563,16 @@ DO JSV = 1, KSV
   CALL ADV_BOUNDARIES_DEVICE (HLBCX, HLBCY, ZRSVS_OTHER(:,:,:,JSV))
 END DO
 !Already done in ADV_BOUNDARIES_DEVICE !$acc update self(ZRTHS_OTHER,ZRTKES_OTHER,ZRRS_OTHER(:,:,:,1:KRR),ZRSVS_OTHER(:,:,:,1:KSV))
+#else
+CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZRTHS_OTHER)
+IF (GTKE) CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZRTKES_OTHER)
+DO JR = 1, KRR
+  CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZRRS_OTHER(:,:,:,JR))
+END DO
+DO JSV = 1, KSV
+  CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZRSVS_OTHER(:,:,:,JSV))
+END DO
+#endif
 !
 ! Exchanges on processors
 !
diff --git a/src/MNH/init_mnh.f90 b/src/MNH/init_mnh.f90
index 0ee13afd6..52c2d6534 100644
--- a/src/MNH/init_mnh.f90
+++ b/src/MNH/init_mnh.f90
@@ -106,7 +106,9 @@ USE MODI_INI_SPECTRE_n
 USE MODE_SPLITTINGZ_ll
 !JUAN
 !
+#ifdef _OPENACC
 USE MODE_MNH_ZWORK
+#endif
 !
 !
 IMPLICIT NONE
@@ -221,7 +223,9 @@ DO JMI=1,NMODEL
   ENDIF
 ENDDO
 !
+#ifdef _OPENACC
 CALL MNH_ALLOC_ZWORK(NMODEL)
+#endif
 !
 !-------------------------------------------------------------------------------
 !
diff --git a/src/MNH/les_mean_1proc.f90 b/src/MNH/les_mean_1proc.f90
index 560e5d59b..245f41ed5 100644
--- a/src/MNH/les_mean_1proc.f90
+++ b/src/MNH/les_mean_1proc.f90
@@ -242,7 +242,9 @@ INTEGER :: JI, JJ             ! loop counters
 !
 !-------------------------------------------------------------------------------
 !
+#ifdef _OPENACC
 PRINT *,'OPENACC: LES_MEAN_1PROC_DEVICE_2D not yet tested'
+#endif
 CALL GET_PHYSICAL_ll(IIB,IJB,IIE,IJE)
 !
 PA_MEAN  = 0.
diff --git a/src/MNH/mode_prandtl.f90 b/src/MNH/mode_prandtl.f90
index d46e5218d..501ba1d69 100644
--- a/src/MNH/mode_prandtl.f90
+++ b/src/MNH/mode_prandtl.f90
@@ -356,8 +356,10 @@ SUBROUTINE D_PHI3DTDZ2_O_DDTDZ(PPHI3,PREDTH1,PREDR1,PRED2TH3,PRED2THR3,PDTDZ,HTU
 #endif
 !$acc declare present(PPHI3,PREDTH1,PREDR1,PRED2TH3,PRED2THR3,PDTDZ,PD_PHI3DTDZ2_O_DDTDZ)
   INTEGER :: IKB, IKE
+#ifdef _OPENACC
   REAL, DIMENSION(SIZE(PREDTH1,1),SIZE(PREDTH1,2),SIZE(PREDTH1,3)) :: ZTMP1_DEVICE
 !$acc declare create(ZTMP1_DEVICE)
+#endif
 !
 IKB = 1+JPVEXT_TURB
 IKE = SIZE(PREDTH1,3)-JPVEXT_TURB
@@ -402,9 +404,13 @@ ELSE
 END IF
 !
 !* smoothing
+#ifndef _OPENACC
+CALL SMOOTH_TURB_FUNCT(PPHI3,PPHI3*2.*PDTDZ,PD_PHI3DTDZ2_O_DDTDZ)
+#else
 ZTMP1_DEVICE = PPHI3*2.*PDTDZ
 !$acc end kernels
 CALL SMOOTH_TURB_FUNCT(PPHI3,ZTMP1_DEVICE,PD_PHI3DTDZ2_O_DDTDZ)
+#endif
 !
 !
 !$acc kernels
@@ -900,7 +906,7 @@ SUBROUTINE D_M3_WTH_WTHR_O_DDTDZ(PM3_WTH_WTHR,PREDTH1,PREDR1,PD,PBLL_O_E,PETHETA
   REAL, DIMENSION(SIZE(PD,1),SIZE(PD,2),SIZE(PD,3)),INTENT(OUT) :: PD_M3_WTH_WTHR_O_DDTDZ
 #endif
 !$acc declare present(PM3_WTH_WTHR,PREDTH1,PREDR1,PD,PBLL_O_E,PETHETA,PD_M3_WTH_WTHR_O_DDTDZ)
-INTEGER :: IKB, IKE
+  INTEGER :: IKB, IKE
 !
 #ifdef _OPENACC
 PRINT *,'OPENACC: D_M3_WTH_WTHR_O_DDTDZ not yet tested'
diff --git a/src/MNH/prandtl.f90 b/src/MNH/prandtl.f90
index 119d39b69..8314af2ec 100644
--- a/src/MNH/prandtl.f90
+++ b/src/MNH/prandtl.f90
@@ -449,7 +449,9 @@ END DO
 !
 IF(HTURBDIM=='1DIM') THEN        ! 1D case
 !
+#ifdef _OPENACC
 PRINT *,'OPENACC: prandtl::1DIM not yet tested'
+#endif
 !
 !$acc kernels async
   PRED2TH3(:,:,:)  = PREDTH1(:,:,:)**2
@@ -521,7 +523,9 @@ ELSE IF (L2D) THEN                      ! 3D case in a 2D model
 #endif
 !
   ELSE                 ! dry 3D case in a 2D model
+#ifdef _OPENACC
 PRINT *,'OPENACC: prandtl::L2D=.T. and KRR=0 not yet tested'
+#endif
 #ifndef _OPENACC
     PRED2TH3(:,:,:) = PREDTH1(:,:,:)**2 +  XCTV**2*PBLL_O_E(:,:,:)**2 *     &
       MZM(KKA,KKU,KKL, GX_M_M(KKA,KKU,KKL,PTHLM,PDXX,PDZZ,PDZX)**2 )
@@ -620,7 +624,9 @@ ELSE                                 ! 3D case in a 3D model
 #endif
 !
   ELSE                 ! dry 3D case in a 3D model
+#ifdef _OPENACC
 PRINT *,'OPENACC: prandtl::L2D=.F. and KRR=0 not yet tested'
+#endif
 #ifndef _OPENACC
     PRED2TH3(:,:,:) = PREDTH1(:,:,:)**2 +  XCTV**2*PBLL_O_E(:,:,:)**2 *                &
       MZM(KKA,KKU,KKL, GX_M_M(KKA,KKU,KKL,PTHLM,PDXX,PDZZ,PDZX)**2 &
-- 
GitLab