From c52dcabf80be24cdc5fa1982be6e88aa0ccd740e Mon Sep 17 00:00:00 2001
From: Juan ESCOBAR <juan.escobar@aero.obs-mip.fr>
Date: Wed, 23 Mar 2022 09:38:03 +0100
Subject: [PATCH] Juan 23/03/2022:ZSOLVER, Cray GPU Opt/Bug: add present in
 kernels & !dir$ concurent in some array syntax

---
 src/ZSOLVER/advection_uvw.f90        | 2 +-
 src/ZSOLVER/qlap.f90                 | 4 ++--
 src/ZSOLVER/tke_eps_sources.f90      | 1 +
 src/ZSOLVER/turb_hor_thermo_flux.f90 | 2 +-
 src/ZSOLVER/zsolver.f90              | 4 ++--
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/ZSOLVER/advection_uvw.f90 b/src/ZSOLVER/advection_uvw.f90
index 466ff36ce..c19db8425 100644
--- a/src/ZSOLVER/advection_uvw.f90
+++ b/src/ZSOLVER/advection_uvw.f90
@@ -299,7 +299,7 @@ if ( lbudget_w ) call Budget_store_init( tbudgets(NBUDGET_W), 'ADV', prws(:, :,
 !*       1.     COMPUTES THE CONTRAVARIANT COMPONENTS
 !	        -------------------------------------
 !
-!$acc kernels
+!$acc kernels present(ZRUT,ZRVT,ZRWT)
 ZRUT(:,:,:) = PUT(:,:,:) * ZMXM_RHODJ(:,:,:)
 ZRVT(:,:,:) = PVT(:,:,:) * ZMYM_RHODJ(:,:,:)
 ZRWT(:,:,:) = PWT(:,:,:) * ZMZM_RHODJ(:,:,:)
diff --git a/src/ZSOLVER/qlap.f90 b/src/ZSOLVER/qlap.f90
index 2c9e801d5..70b033249 100644
--- a/src/ZSOLVER/qlap.f90
+++ b/src/ZSOLVER/qlap.f90
@@ -585,8 +585,8 @@ IF ( CEQNSYS == 'DUR' .OR. CEQNSYS == 'MAE' ) THEN
    !$acc end kernels
   IF(.NOT. L2D) THEN 
      CALL MYM_DEVICE (ZRHODJ, ZMYM )
-     !$acc kernels
-     ZV = ZMYM * ZV
+     !$acc kernels present(ZV)
+     ZV(:,:,:) = ZMYM(:,:,:) * ZV(:,:,:)
      !$acc end kernels
   END IF
   CALL MZM_DEVICE (ZRHODJ, ZMZM )
diff --git a/src/ZSOLVER/tke_eps_sources.f90 b/src/ZSOLVER/tke_eps_sources.f90
index 91f078a6d..78fd1bcce 100644
--- a/src/ZSOLVER/tke_eps_sources.f90
+++ b/src/ZSOLVER/tke_eps_sources.f90
@@ -568,6 +568,7 @@ if (lbudget_tke) call Budget_store_end( tbudgets(NBUDGET_TKE), 'TR', prtkes(:, :
 !
 !$acc kernels
 #ifndef MNH_BITREP
+!dir$ concurrent
 PRTHLS(:,:,:) = PRTHLS(:,:,:) + XCED * SQRT(PTKEM(:,:,:)) / PLEPS(:,:,:) * &
 #else
 PRTHLS(:,:,:) = PRTHLS(:,:,:) + XCED * BR_POW(PTKEM(:,:,:),0.5) / PLEPS(:,:,:) * &
diff --git a/src/ZSOLVER/turb_hor_thermo_flux.f90 b/src/ZSOLVER/turb_hor_thermo_flux.f90
index dc9982bb8..71cf7793c 100644
--- a/src/ZSOLVER/turb_hor_thermo_flux.f90
+++ b/src/ZSOLVER/turb_hor_thermo_flux.f90
@@ -505,7 +505,7 @@ IF ( KRRL >= 1 ) THEN
     ZTMP1_DEVICE(:,:,:) = ZTMP2_DEVICE(:,:,:) *ZFLX(:,:,:)
     !$acc end kernels
     CALL MXF_DEVICE( ZTMP1_DEVICE, ZTMP2_DEVICE)
-    !$acc kernels
+    !$acc kernels present(ZTMP1_DEVICE)
     ZTMP1_DEVICE(:,:,:) = ZFLX(:,:,:)*PINV_PDXX(:,:,:)
     !$acc end kernels
     CALL MZM_DEVICE( ZTMP1_DEVICE, ZTMP5_DEVICE )
diff --git a/src/ZSOLVER/zsolver.f90 b/src/ZSOLVER/zsolver.f90
index cf9461595..a505d79db 100644
--- a/src/ZSOLVER/zsolver.f90
+++ b/src/ZSOLVER/zsolver.f90
@@ -313,8 +313,8 @@ DO JM = 1,KITR
 !
 !*       2.3    update the residual error: r
   !
-  !$acc kernels
-  ZRESIDUE = ZRESIDUE + ZLAMBDA * ZDELTA
+  !$acc kernels present(ZRESIDUE)
+  ZRESIDUE(:,:,:) = ZRESIDUE(:,:,:)  + ZLAMBDA * ZDELTA(:,:,:) 
   !$acc end kernels
 !                        
 !*       2.4    compute the vector: q = F^(-1)*( Q(PHI) - Y )
-- 
GitLab