From 442b7cf1aa7b090e065eefe500e4c618177c6d25 Mon Sep 17 00:00:00 2001
From: JUan ESCOBAR <juan.escobar@aero.obs-mip.fr>
Date: Mon, 4 Jan 2021 15:57:07 +0100
Subject: [PATCH] Juan 04/01/2021: MNH/ini_rain_ice.f90, for OpenACC , add acc
 enter data create for X... module variable

---
 src/MNH/ini_rain_ice.f90 | 45 +++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/MNH/ini_rain_ice.f90 b/src/MNH/ini_rain_ice.f90
index d6c3562e4..d8200edbe 100644
--- a/src/MNH/ini_rain_ice.f90
+++ b/src/MNH/ini_rain_ice.f90
@@ -675,9 +675,18 @@ XGAMINC_BOUND_MIN = 1.0E-1 ! Minimal value of (Lbda * D_cs^lim)**alpha
 XGAMINC_BOUND_MAX = 1.0E7  ! Maximal value of (Lbda * D_cs^lim)**alpha
 ZRATE = EXP(LOG(XGAMINC_BOUND_MAX/XGAMINC_BOUND_MIN)/REAL(NGAMINC-1))
 !
-IF( .NOT.ALLOCATED(XGAMINC_RIM1) ) ALLOCATE( XGAMINC_RIM1(NGAMINC) )
-IF( .NOT.ALLOCATED(XGAMINC_RIM2) ) ALLOCATE( XGAMINC_RIM2(NGAMINC) )
-IF( .NOT.ALLOCATED(XGAMINC_RIM4) ) ALLOCATE( XGAMINC_RIM4(NGAMINC) )
+IF( .NOT.ALLOCATED(XGAMINC_RIM1) ) THEN
+   ALLOCATE( XGAMINC_RIM1(NGAMINC) )
+   !$acc enter data create (XGAMINC_RIM1)
+END IF
+IF( .NOT.ALLOCATED(XGAMINC_RIM2) ) THEN
+   ALLOCATE( XGAMINC_RIM2(NGAMINC) )
+   !$acc enter data create (XGAMINC_RIM2)
+END IF
+IF( .NOT.ALLOCATED(XGAMINC_RIM4) ) THEN
+   ALLOCATE( XGAMINC_RIM4(NGAMINC) )
+   !$acc enter data create (XGAMINC_RIM4)
+END IF
 !
 DO J1=1,NGAMINC
   ZBOUND = XGAMINC_BOUND_MIN*ZRATE**(J1-1)
@@ -686,7 +695,7 @@ DO J1=1,NGAMINC
   XGAMINC_RIM4(J1) = GAMMA_INC(XNUS+XBG/XALPHAS      ,ZBOUND)
 END DO
 !
-!$acc enter data copyin (XGAMINC_RIM1,XGAMINC_RIM2,XGAMINC_RIM4)
+!$acc update device (XGAMINC_RIM1,XGAMINC_RIM2,XGAMINC_RIM4)
 !
 XRIMINTP1 = XALPHAS / LOG(ZRATE)
 XRIMINTP2 = 1.0 + XRIMINTP1*LOG( XDCSLIM/(XGAMINC_BOUND_MIN)**(1.0/XALPHAS) )
@@ -729,10 +738,18 @@ IND      = 50    ! Interval number, collection efficiency and infinite diameter
 ZESR     = 1.0   ! factor used to integrate the dimensional distributions when
 ZFDINFTY = 20.0  ! computing the kernels XKER_RACCSS, XKER_RACCS and XKER_SACCRG
 !
-IF( .NOT.ALLOCATED(XKER_RACCSS) ) ALLOCATE( XKER_RACCSS(NACCLBDAS,NACCLBDAR) )
-IF( .NOT.ALLOCATED(XKER_RACCS ) ) ALLOCATE( XKER_RACCS (NACCLBDAS,NACCLBDAR) )
-IF( .NOT.ALLOCATED(XKER_SACCRG) ) ALLOCATE( XKER_SACCRG(NACCLBDAR,NACCLBDAS) )
-!$acc enter data create(XKER_RACCSS,XKER_RACCS,XKER_SACCRG)
+IF( .NOT.ALLOCATED(XKER_RACCSS) ) THEN
+   ALLOCATE( XKER_RACCSS(NACCLBDAS,NACCLBDAR) )
+   !$acc enter data create(XKER_RACCSS)
+END IF
+IF( .NOT.ALLOCATED(XKER_RACCS ) ) THEN
+   ALLOCATE( XKER_RACCS (NACCLBDAS,NACCLBDAR) )
+   !$acc enter data create(XKER_RACCS)
+END IF
+IF( .NOT.ALLOCATED(XKER_SACCRG) ) THEN
+   ALLOCATE( XKER_SACCRG(NACCLBDAR,NACCLBDAS) )
+   !$acc enter data create(XKER_SACCRG)
+END IF
 !
 CALL READ_XKER_RACCS (KACCLBDAS,KACCLBDAR,KND,                                &
                       PALPHAS,PNUS,PALPHAR,PNUR,PESR,PBS,PBR,PCS,PDS,PCR,PDR, &
@@ -946,8 +963,10 @@ IND      = 50    ! Interval number, collection efficiency and infinite diameter
 ZEGS     = 1.0   ! factor used to integrate the dimensional distributions when
 ZFDINFTY = 20.0  ! computing the kernels XKER_SDRYG
 !
-IF( .NOT.ALLOCATED(XKER_SDRYG) ) ALLOCATE( XKER_SDRYG(NDRYLBDAG,NDRYLBDAS) )
-!$acc enter data create(XKER_SDRYG)
+IF( .NOT.ALLOCATED(XKER_SDRYG) ) THEN
+   ALLOCATE( XKER_SDRYG(NDRYLBDAG,NDRYLBDAS) )
+   !$acc enter data create(XKER_SDRYG)
+END IF
 !
 CALL READ_XKER_SDRYG (KDRYLBDAG,KDRYLBDAS,KND,                              &
                    PALPHAG,PNUG,PALPHAS,PNUS,PEGS,PBS,PCG,PDG,PCS,PDS,      &
@@ -1019,8 +1038,10 @@ IND      = 50    ! Number of interval used to integrate the dimensional
 ZEGR     = 1.0   ! distributions when computing the kernel XKER_RDRYG
 ZFDINFTY = 20.0
 !
-IF( .NOT.ALLOCATED(XKER_RDRYG) ) ALLOCATE( XKER_RDRYG(NDRYLBDAG,NDRYLBDAR) )
-!$acc enter data create(XKER_RDRYG)
+IF( .NOT.ALLOCATED(XKER_RDRYG) ) THEN
+   ALLOCATE( XKER_RDRYG(NDRYLBDAG,NDRYLBDAR) )
+   !$acc enter data create(XKER_RDRYG)
+END IF
 !
 CALL READ_XKER_RDRYG (KDRYLBDAG,KDRYLBDAR,KND,                              &
                    PALPHAG,PNUG,PALPHAR,PNUR,PEGR,PBR,PCG,PDG,PCR,PDR,      &
-- 
GitLab