From 33deb8dcb79ee312e97b950ecc7d96ea0cc6e92c Mon Sep 17 00:00:00 2001
From: Juan ESCOBAR <juan.escobar@aero.obs-mip.fr>
Date: Thu, 16 Mar 2023 11:27:12 +0100
Subject: [PATCH] Juan&Naima
 16/03/2023:MNH/advec_weno_k_3_aux.f90,bl89.f90,ice4_sedimentation_split.f90,
 Cray OpenACC opt , add present_cr to avoid recurrence in kernels

---
 src/MNH/advec_weno_k_3_aux.f90       | 84 +++++++++++++++++-----------
 src/MNH/bl89.f90                     |  4 +-
 src/MNH/ice4_sedimentation_split.f90 |  6 +-
 3 files changed, 57 insertions(+), 37 deletions(-)

diff --git a/src/MNH/advec_weno_k_3_aux.f90 b/src/MNH/advec_weno_k_3_aux.f90
index fc7d56ff5..1e233d8a5 100644
--- a/src/MNH/advec_weno_k_3_aux.f90
+++ b/src/MNH/advec_weno_k_3_aux.f90
@@ -433,7 +433,7 @@ CASE ('CYCL')
 !
 IF( LEAST_ll() .AND. .FALSE. ) THEN! East boundary is physical (monoproc)
 !
-!$acc kernels
+!$acc kernels present_cr( ZFPOS1,ZBPOS1,ZOMP1)
 ! First positive stencil, needs indices i-2, i-1, i 
 ZFPOS1(IW,:,:)  = 1./6. * (2.0*PSRC(IE,:,:)   - 7.0*PSRC(IW-1,:,:) + 11.0*PSRC(IW,:,:))! Flux IW
 ZFPOS1(IW-1,:,:) = 1./6. * (2.0*PSRC(IE-1,:,:) - 7.0*PSRC(IE,:,:)   + 11.0*PSRC(IW-1,:,:))! Flux IW-1
@@ -443,6 +443,8 @@ ZBPOS1(IW-1,:,:) = 13./12. * (PSRC(IE-1,:,:) - 2.0*PSRC(IE,:,:) +     PSRC(IW-1,
  + 1./4    * (PSRC(IE-1,:,:) - 4.0*PSRC(IE,:,:) + 3.0*PSRC(IW-1,:,:))**2 ! Smoothness indicator IW-1
 ZOMP1(IW-1:IW,:,:)  = 1./10. / (ZEPS + ZBPOS1(IW-1:IW,:,:))**2! Non-normalized weight IW,IW-1
 !
+!$acc end kernels
+!$acc kernels present_cr( ZFPOS2,ZBPOS2, ZOMP2)
 ! Second positive stencil, needs indices i-1, i, i+1
 ZFPOS2(IW,:,:)   = 1./6.* (-1.0*PSRC(IW-1,:,:) + 5.0*PSRC(IW,:,:)   + 2.0*PSRC(IW+1,:,:))! Flux IW
 ZFPOS2(IW-1,:,:) = 1./6.* (-1.0*PSRC(IE,:,:)   + 5.0*PSRC(IW-1,:,:) + 2.0*PSRC(IW,:,:)) ! Flux IW-1
@@ -452,6 +454,8 @@ ZBPOS2(IW-1,:,:) = 13./12 * (PSRC(IE,:,:) - 2.0*PSRC(IW-1,:,:) + PSRC(IW,:,:))**
  + 1./4   * (PSRC(IE,:,:) -                      PSRC(IW,:,:))**2! Smoothness indicator IW-1
 ZOMP2(IW-1:IW,:,:)  = 3./5. / (ZEPS + ZBPOS2(IW-1:IW,:,:))**2! Non-normalized weight IW,IW-1
 !
+!$acc end kernels
+!$acc kernels present_cr(ZFNEG3,ZBNEG3,ZOMN3)
 ! Third negative stencil, needs indices i-1, i, i+1
 ZFNEG3(IW,:,:)   = 1./6 * (-1.0*PSRC(IW-1,:,:) + 5.0*PSRC(IW,:,:)   + 2.0*PSRC(IW+1,:,:))! Flux IW
 ZFNEG3(IW-1,:,:) = 1./6 * (-1.0*PSRC(IE,:,:)   + 5.0*PSRC(IW-1,:,:) + 2.0*PSRC(IW,:,:))! Flux IW-1
@@ -464,7 +468,7 @@ ZOMN3(IW-1:IW,:,:) = 3./10. / (ZEPS + ZBNEG3(IW-1:IW,:,:))**2! Non-normalized we
 !$acc end kernels
 ELSEIF(IW>3) THEN! East boundary is proc border, with minimum 3 HALO points on west side
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFNEG3,ZBNEG3,ZOMN3,PSRC)
 ! First positive stencil, needs indices i-2, i-1, i
 ZFPOS1(IW,:,:)   = 1./6. * (2.0*PSRC(IW-2,:,:)   - 7.0*PSRC(IW-1,:,:) + 11.0*PSRC(IW,:,:))! Flux IW
 ZFPOS1(IW-1,:,:) = 1./6. * (2.0*PSRC(IW-3,:,:) - 7.0*PSRC(IW-2,:,:)   + 11.0*PSRC(IW-1,:,:))! Flux IW-1
@@ -497,7 +501,7 @@ ZFNEG3(IW,:,:)   = 1./6 * (-1.0*PSRC(IW-1,:,:) + 5.0*PSRC(IW,:,:)   + 2.0*PSRC(I
   call Print_msg(NVERB_FATAL,'GEN','ADVEC_WENO_K_3_UX','WENO5/CYCL fluxes calculation needs JPHEXT (&NHALO) >= 3 on west side')
  ENDIF
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS3,ZBPOS3,ZOMP3,ZFNEG1,ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,ZOMN2,PR,PSRC)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(IW,:,:)   = 1./6 * (2.0*PSRC(IW,:,:) + 5.0*PSRC(IW+1,:,:) - PSRC(IW+2,:,:)) ! Flux IW
  ZFPOS3(IW-1,:,:) = 1./6 * (2.0*PSRC(IW-1,:,:) + 5.0*PSRC(IW,:,:) - PSRC(IW+1,:,:)) ! Flux IW-1
@@ -543,7 +547,7 @@ ZFNEG3(IW,:,:)   = 1./6 * (-1.0*PSRC(IW-1,:,:) + 5.0*PSRC(IW,:,:)   + 2.0*PSRC(I
  ! Open, or Wall, or Nest boundary condition => WENO order reduction
  !---------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(PR,ZFPOS1,ZBPOS1,ZFNEG1,ZOMP1,ZOMP2,ZOMN1,ZOMN2,PSRC)
  ! WENO scheme order 1, IW-1
     PR(IW-1,:,:) = PSRC(IW-1,:,:) * (0.5+SIGN(0.5,PRUCT(IW-1,:,:))) + &
                    PSRC(IW,:,:) * &
@@ -589,7 +593,8 @@ ELSE
 !
  ! ----- Positive fluxes -----
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PSRC)
  ! First positive stencil, needs indices i-2, i-1, i
  ZFPOS1(IW,:,:)   = 1./6. * (2.0*PSRC(IW-2,:,:) - 7.0*PSRC(IW-1,:,:) + 11.0*PSRC(IW,:,:)) ! Flux IW
  ZFPOS1(IW-1,:,:) = 1./6. * (2.0*PSRC(IW-3,:,:) - 7.0*PSRC(IW-2,:,:) + 11.0*PSRC(IW-1,:,:)) ! Flux IW-1
@@ -681,7 +686,8 @@ IF( LEAST_ll() ) THEN
 ! 
  IF (LWEST_ll() .AND. .FALSE. ) THEN  ! West boundary is physical (monoproc)
 ! 
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PSRC)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(IE-1,:,:) = 1./6 * (2.0*PSRC(IE-1,:,:) + 5.0*PSRC(IE,:,:) - PSRC(IE+1,:,:)) ! Flux IE-1
  ZFPOS3(IE,:,:)   = 1./6 * (2.0*PSRC(IE,:,:) + 5.0*PSRC(IE+1,:,:) - PSRC(IW,:,:)) ! Flux IE
@@ -712,7 +718,8 @@ IF( LEAST_ll() ) THEN
 !
  ELSEIF(IE<=SIZE(PSRC,1)-3) THEN ! West boundary is proc border, with minimum 3 HALO points on east side
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PSRC)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(IE-1,:,:) = 1./6 * (2.0*PSRC(IE-1,:,:) + 5.0*PSRC(IE,:,:) - PSRC(IE+1,:,:)) ! Flux IE-1
  ZFPOS3(IE,:,:)   = 1./6 * (2.0*PSRC(IE,:,:) + 5.0*PSRC(IE+1,:,:) - PSRC(IE+2,:,:)) ! Flux IE
@@ -745,7 +752,8 @@ IF( LEAST_ll() ) THEN
   call Print_msg(NVERB_FATAL,'GEN','ADVEC_WENO_K_3_UX','WENO5/CYCL fluxes calculation needs JPHEXT (&NHALO) >= 3 on east side')
  ENDIF
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3,PSRC)
  ! First positive stencil, needs indices i-2, i-1, i
  ZFPOS1(IE-1,:,:) = 1./6. * (2.0*PSRC(IE-3,:,:) - 7.0*PSRC(IE-2,:,:) + 11.0*PSRC(IE-1,:,:)) ! Flux IE-1
  ZFPOS1(IE,:,:)   = 1./6. * (2.0*PSRC(IE-2,:,:) - 7.0*PSRC(IE-1,:,:) + 11.0*PSRC(IE,:,:)) ! Flux IE
@@ -791,7 +799,8 @@ IF( LEAST_ll() ) THEN
  ! Open, or Wall, or Nest boundary condition => WENO order reduction
  !---------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,PSRC)
  ! WENO scheme order 1, IE
     PR(IE,:,:) = PSRC(IE,:,:) * (0.5+SIGN(0.5,PRUCT(IE,:,:))) + &
                  PSRC(IE+1,:,:) * &
@@ -837,7 +846,8 @@ ELSE
 ! 
  ! ----- Positive fluxes -----
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3,PSRC)
  ! First positive stencil, needs indices i-2, i-1, i
  ZFPOS1(IE-1,:,:) = 1./6. * (2.0*PSRC(IE-3,:,:) - 7.0*PSRC(IE-2,:,:) + 11.0*PSRC(IE-1,:,:)) ! Flux IE-1
  ZFPOS1(IE,:,:)   = 1./6. * (2.0*PSRC(IE-2,:,:) - 7.0*PSRC(IE-1,:,:) + 11.0*PSRC(IE,:,:)) ! Flux IE
@@ -911,7 +921,7 @@ ELSE
 END IF ! IF(LWEST_ll()) 
 !-------------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(PR)
 PR = PR * PRUCT ! Add contravariant flux
 !$acc end kernels
 !
@@ -1025,7 +1035,8 @@ CALL GET_INDICE_ll(IIB,IJB,IIE,IJE)
 !*       0.4.   INITIALIZE THE FIELD 
 !               ---------------------
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &       present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3)
 PR(:,:,:) = 0.0
 !
 ZFPOS1 = 0.0
@@ -1136,7 +1147,7 @@ IF( LWEST_ll() ) THEN
 !
  IF(LEAST_ll()  .AND. .FALSE. ) THEN  ! East border is physical
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZFNEG3,ZBNEG3,ZOMN3)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(IW+1,:,:) = 1./6. * (2.0*PSRC(IE,:,:)   - 7.0*PSRC(IW-1,:,:) + 11.0*PSRC(IW,:,:)) ! Flux IW+1
  ZFPOS1(IW,:,:)   = 1./6. * (2.0*PSRC(IE-1,:,:) - 7.0*PSRC(IE,:,:)   + 11.0*PSRC(IW-1,:,:)) ! Flux IW
@@ -1167,7 +1178,7 @@ IF( LWEST_ll() ) THEN
 !
  ELSEIF(IW>3) THEN ! East boundary is proc border, with minimum 3 HALO points on west side
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFNEG3,ZBNEG3,ZOMN3,PSRC)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(IW+1,:,:) = 1./6. * (2.0*PSRC(IW-2,:,:)   - 7.0*PSRC(IW-1,:,:) + 11.0*PSRC(IW,:,:)) ! Flux IW+1
  ZFPOS1(IW,:,:)   = 1./6. * (2.0*PSRC(IW-3,:,:) - 7.0*PSRC(IW-2,:,:)   + 11.0*PSRC(IW-1,:,:)) ! Flux IW
@@ -1200,7 +1211,8 @@ IF( LWEST_ll() ) THEN
   call Print_msg(NVERB_FATAL,'GEN','ADVEC_WENO_K_3_MX','WENO5/CYCL fluxes calculation needs JPHEXT (&NHALO) >= 3 on west side')
  ENDIF
 ! 
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3,PSRC)
  ! Third positive stencil, needs indices i-1, i, i+1
  ZFPOS3(IW+1,:,:) = 1./6 * (2.0*PSRC(IW,:,:) + 5.0*PSRC(IW+1,:,:) - PSRC(IW+2,:,:)) ! Flux IW+1
  ZFPOS3(IW,:,:)   = 1./6 * (2.0*PSRC(IW-1,:,:) + 5.0*PSRC(IW,:,:) - PSRC(IW+1,:,:)) ! Flux IW
@@ -1247,7 +1259,7 @@ IF( LWEST_ll() ) THEN
  ! Open, or Wall, or Nest boundary condition => WENO order reduction
  !---------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(PR,ZFPOS1,ZFPOS2,ZBPOS1,ZBPOS2,ZFNEG1,ZFNEG2,ZBNEG1,ZBNEG2,ZOMP1,ZOMP2,ZOMN1,ZOMN2)
  ! WENO scheme order 1, IW
     PR(IW,:,:) = PSRC(IW-1,:,:) * (0.5+SIGN(0.5,PRUCT(IW,:,:))) + &
                  PSRC(IW,:,:)  * (0.5-SIGN(0.5,PRUCT(IW,:,:)))
@@ -1292,7 +1304,8 @@ ELSE
 !
  ! ----- Positive fluxes -----
 !
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3,PSRC)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(IW+1,:,:) = 1./6. * (2.0*PSRC(IW-2,:,:)   - 7.0*PSRC(IW-1,:,:) + 11.0*PSRC(IW,:,:)) ! Flux IW+1
  ZFPOS1(IW,:,:)   = 1./6. * (2.0*PSRC(IW-3,:,:) - 7.0*PSRC(IW-2,:,:)   + 11.0*PSRC(IW-1,:,:)) ! Flux IW
@@ -1383,7 +1396,7 @@ IF(LEAST_ll() ) THEN
 !
  IF(LWEST_ll()  .AND. .FALSE. ) THEN  ! West border is physical 
 ! 
-!$acc kernels
+!$acc kernels present_cr(ZFPOS3,ZBPOS3,ZOMP3,ZFNEG1,ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,ZOMN2,PSRC)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(IE,:,:)   = 1./6 * (2.0*PSRC(IE-1,:,:) + 5.0*PSRC(IE,:,:) - PSRC(IE+1,:,:)) ! Flux IE
  ZFPOS3(IE+1,:,:) = 1./6 * (2.0*PSRC(IE,:,:) + 5.0*PSRC(IE+1,:,:) - PSRC(IW,:,:)) ! Flux IE+1
@@ -1414,7 +1427,7 @@ IF(LEAST_ll() ) THEN
 !
  ELSEIF(IE<=SIZE(PSRC,1)-3) THEN ! West boundary is proc border, with minimum 3 HALO points on east side
 ! 
-!$acc kernels
+!$acc kernels present_cr(ZFPOS3,ZBPOS3,ZOMP3,ZFNEG1,ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,ZOMN2,PSRC)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(IE,:,:)   = 1./6 * (2.0*PSRC(IE-1,:,:) + 5.0*PSRC(IE,:,:) - PSRC(IE+1,:,:)) ! Flux IE
  ZFPOS3(IE+1,:,:) = 1./6 * (2.0*PSRC(IE,:,:) + 5.0*PSRC(IE+1,:,:) - PSRC(IE+2,:,:)) ! Flux IE+1
@@ -1447,7 +1460,7 @@ IF(LEAST_ll() ) THEN
   call Print_msg(NVERB_FATAL,'GEN','ADVEC_WENO_K_3_MX','WENO5/CYCL fluxes calculation needs JPHEXT (&NHALO) >= 3 on east side')
  ENDIF
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFNEG3,ZBNEG3,ZOMN3,PR,PSRC)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(IE,:,:)   = 1./6. * (2.0*PSRC(IE-3,:,:) - 7.0*PSRC(IE-2,:,:) + 11.0*PSRC(IE-1,:,:)) ! Flux IE
  ZFPOS1(IE+1,:,:) = 1./6. * (2.0*PSRC(IE-2,:,:) - 7.0*PSRC(IE-1,:,:) + 11.0*PSRC(IE,:,:)) ! Flux IE+1
@@ -1493,7 +1506,7 @@ IF(LEAST_ll() ) THEN
  ! Open, or Wall, or Nest boundary condition => WENO order reduction
  !---------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZFPOS2,ZBPOS1,ZBPOS2,ZFNEG1,ZBNEG1,ZOMP1,ZOMP2,ZOMN1,ZOMN2,PR,PSRC)
  ! WENO scheme order 1, IE+1
     PR(IE+1,:,:) = PSRC(IE,:,:)  * (0.5+SIGN(0.5,PRUCT(IE+1,:,:))) + &
                    PSRC(IE+1,:,:) * (0.5-SIGN(0.5,PRUCT(IE+1,:,:)))
@@ -1538,7 +1551,8 @@ ELSE
 ! 
  ! ----- Positive fluxes -----
 !
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3,PSRC)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(IE,:,:)   = 1./6. * (2.0*PSRC(IE-3,:,:) - 7.0*PSRC(IE-2,:,:) + 11.0*PSRC(IE-1,:,:)) ! Flux IE
  ZFPOS1(IE+1,:,:) = 1./6. * (2.0*PSRC(IE-2,:,:) - 7.0*PSRC(IE-1,:,:) + 11.0*PSRC(IE,:,:)) ! Flux IE+1
@@ -1730,7 +1744,8 @@ CALL GET_INDICE_ll(IIB,IJB,IIE,IJE)
 !*       0.4.   INITIALIZE THE FIELD 
 !               ---------------------
 !
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3)
 PR(:,:,:) = 0.0
 !
 ZFPOS1 = 0.0
@@ -1840,7 +1855,7 @@ IF(LSOUTH_ll()) THEN
 !
  IF(LNORTH_ll()  .AND. .FALSE. ) THEN ! North border is physical 
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFNEG3,ZBNEG3,ZOMN3)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(:,IS+1,:) = 1./6. * (2.0*PSRC(:,IN,:)   - 7.0*PSRC(:,IS-1,:) + 11.0*PSRC(:,IS,:)) ! Flux IS+1
  ZFPOS1(:,IS,:)   = 1./6. * (2.0*PSRC(:,IN-1,:) - 7.0*PSRC(:,IN,:)   + 11.0*PSRC(:,IS-1,:)) ! Flux IS
@@ -1871,7 +1886,7 @@ IF(LSOUTH_ll()) THEN
 !
  ELSEIF(IS>3) THEN ! North boundary is proc border, with minimum 3 HALO points on sounth side
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFNEG3,ZBNEG3,ZOMN3)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(:,IS+1,:) = 1./6. * (2.0*PSRC(:,IS-2,:)   - 7.0*PSRC(:,IS-1,:) + 11.0*PSRC(:,IS,:)) ! Flux IS+1
  ZFPOS1(:,IS,:)   = 1./6. * (2.0*PSRC(:,IS-3,:) - 7.0*PSRC(:,IS-2,:)   + 11.0*PSRC(:,IS-1,:)) ! Flux IS
@@ -1904,7 +1919,8 @@ IF(LSOUTH_ll()) THEN
   call Print_msg(NVERB_FATAL,'GEN','ADVEC_WENO_K_3_MY','WENO5/CYCL fluxes calculation needs JPHEXT (&NHALO) >= 3 on south side')
  ENDIF
 ! 
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3)
  ! Third positive stencil, needs indices i-1, i, i+1
  ZFPOS3(:,IS+1,:) = 1./6 * (2.0*PSRC(:,IS,:) + 5.0*PSRC(:,IS+1,:) - PSRC(:,IS+2,:)) ! Flux IS+1
  ZFPOS3(:,IS,:)   = 1./6 * (2.0*PSRC(:,IS-1,:) + 5.0*PSRC(:,IS,:) - PSRC(:,IS+1,:)) ! Flux IS
@@ -1952,7 +1968,7 @@ IF(LSOUTH_ll()) THEN
  ! Open, or Wall, or Nest boundary condition => WENO order reduction
  !---------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(PR,ZFPOS1,ZFPOS2,ZBPOS1,ZBPOS2,ZFNEG1,ZFNEG2,ZBNEG1,ZBNEG2,ZOMP1,ZOMP2,ZOMN1,ZOMN2)
  ! WENO scheme order 1, IS
     PR(:,IS,:) = PSRC(:,IS-1,:) * (0.5+SIGN(0.5,PRVCT(:,IS,:))) + &
                  PSRC(:,IS,:)  * (0.5-SIGN(0.5,PRVCT(:,IS,:)))
@@ -1997,7 +2013,8 @@ ELSE
 !
  ! ----- Positive fluxes -----
 !
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(:,IS+1,:) = 1./6. * (2.0*PSRC(:,IS-2,:)   - 7.0*PSRC(:,IS-1,:) + 11.0*PSRC(:,IS,:)) ! Flux IS+1
  ZFPOS1(:,IS,:)   = 1./6. * (2.0*PSRC(:,IS-3,:) - 7.0*PSRC(:,IS-2,:)   + 11.0*PSRC(:,IS-1,:)) ! Flux IS
@@ -2088,7 +2105,7 @@ IF( LNORTH_ll() ) THEN
 !
  IF (LSOUTH_ll()  .AND. .FALSE. ) THEN ! South border is physical 
 ! 
-!$acc kernels
+!$acc kernels present_cr(ZFPOS3,ZBPOS3,ZOMP3,ZFNEG1,ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,ZOMN2)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(:,IN,:)   = 1./6 * (2.0*PSRC(:,IN-1,:) + 5.0*PSRC(:,IN,:) - PSRC(:,IN+1,:)) ! Flux IN
  ZFPOS3(:,IN+1,:) = 1./6 * (2.0*PSRC(:,IN,:) + 5.0*PSRC(:,IN+1,:) - PSRC(:,IS,:)) ! Flux IN+1
@@ -2119,7 +2136,7 @@ IF( LNORTH_ll() ) THEN
 !
  ELSEIF(IN<=SIZE(PSRC,2)-3) THEN ! South boundary is proc border, with minimum 3 HALO points on north side
 ! 
-!$acc kernels
+!$acc kernels present_cr(ZFPOS3,ZBPOS3,ZOMP3,ZFNEG1,ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,ZOMN2)
  ! Third positive stencil, needs indices i, i+1, i+2
  ZFPOS3(:,IN,:)   = 1./6 * (2.0*PSRC(:,IN-1,:) + 5.0*PSRC(:,IN,:) - PSRC(:,IN+1,:)) ! Flux IN
  ZFPOS3(:,IN+1,:) = 1./6 * (2.0*PSRC(:,IN,:) + 5.0*PSRC(:,IN+1,:) - PSRC(:,IN+2,:)) ! Flux IN+1
@@ -2152,7 +2169,7 @@ IF( LNORTH_ll() ) THEN
   call Print_msg(NVERB_FATAL,'GEN','ADVEC_WENO_K_3_MY','WENO5/CYCL fluxes calculation needs JPHEXT (&NHALO) >= 3 on south side')
  ENDIF
 !
-!$acc kernels
+!$acc kernels present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFNEG3,ZBNEG3,ZOMN3)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(:,IN,:)   = 1./6. * (2.0*PSRC(:,IN-3,:) - 7.0*PSRC(:,IN-2,:) + 11.0*PSRC(:,IN-1,:)) ! Flux IN
  ZFPOS1(:,IN+1,:) = 1./6. * (2.0*PSRC(:,IN-2,:) - 7.0*PSRC(:,IN-1,:) + 11.0*PSRC(:,IN,:)) ! Flux IN+1
@@ -2198,7 +2215,7 @@ IF( LNORTH_ll() ) THEN
  ! Open, or Wall, or Nest boundary condition => WENO order reduction
  !---------------------------------------------------------------------------
 !
-!$acc kernels
+!$acc kernels present_cr(PR,ZFPOS1,ZFPOS2,ZBPOS1,ZBPOS2,ZFNEG1,ZFNEG2,ZBNEG1,ZBNEG2,ZOMP1,ZOMP2,ZOMN1,ZOMN2,PR)
  ! WENO scheme order 1, IN+1
     PR(:,IN+1,:) = PSRC(:,IN,:)  * (0.5+SIGN(0.5,PRVCT(:,IN+1,:))) + &
                    PSRC(:,IN+1,:) * (0.5-SIGN(0.5,PRVCT(:,IN+1,:)))
@@ -2243,7 +2260,8 @@ ELSE
 ! 
  ! ----- Positive fluxes -----
 !
-!$acc kernels
+!$acc kernels  present_cr(ZFPOS1,ZBPOS1,ZOMP1,ZFPOS2,ZBPOS2,ZOMP2,ZFPOS3,ZBPOS3,ZOMP3,ZOMN2,ZFNEG1) &
+!$acc &        present_cr(ZBNEG1,ZOMN1,ZFNEG2,ZBNEG2,PR,ZOMN3)
  ! First positive stencil, needs indices i-3, i-2, i-1
  ZFPOS1(:,IN,:)   = 1./6. * (2.0*PSRC(:,IN-3,:) - 7.0*PSRC(:,IN-2,:) + 11.0*PSRC(:,IN-1,:)) ! Flux IN
  ZFPOS1(:,IN+1,:) = 1./6. * (2.0*PSRC(:,IN-2,:) - 7.0*PSRC(:,IN-1,:) + 11.0*PSRC(:,IN,:)) ! Flux IN+1
diff --git a/src/MNH/bl89.f90 b/src/MNH/bl89.f90
index 01e89df1f..dbd82b24e 100644
--- a/src/MNH/bl89.f90
+++ b/src/MNH/bl89.f90
@@ -358,7 +358,9 @@ END IF
 !but algorithm must remain the same.
 !!!!!!!!!!!!
 
-!$acc kernels
+!$acc kernels present_cr(ZTEST0,ZPOTE,ZTEST,ZTESTM,ZLWORK1,ZLWORK2,ZLWORK,ZINTE)  &
+!$acc &       present_cr(ZTEST0,ZPOTE,ZTEST,ZTESTM,ZLWORK1,ZLWORK2,ZLWORK,ZINTE)  &
+!$acc &       present_cr(ZLWORK1,ZLWORK2,ZPOTE,ZLWORK2,ZLM)
 ZDELTVPT(:,IKTB:IKTE)=ZVPT(:,IKTB:IKTE)-ZVPT(:,IKTB-KKL:IKTE-KKL)
 ZDELTVPT(:,KKU)=ZVPT(:,KKU)-ZVPT(:,KKU-KKL)
 ZDELTVPT(:,KKA)=0.
diff --git a/src/MNH/ice4_sedimentation_split.f90 b/src/MNH/ice4_sedimentation_split.f90
index 255d6a688..5d15c772c 100644
--- a/src/MNH/ice4_sedimentation_split.f90
+++ b/src/MNH/ice4_sedimentation_split.f90
@@ -648,7 +648,7 @@ DO WHILE (ANY(ZREMAINT>0.))
     !******* for cloud
     ZWSED(:,:,:) = 0.
 !$acc loop independent private(JI,JJ,JK,JL,ZZWLBDC,ZRAY,ZZT,ZZWLBDA,ZZCC)
-    DO JL=1, ISEDIM
+    DO CONCURRENT( JL = 1 : ISEDIM )
       JI=I1(JL)
       JJ=I2(JL)
       JK=I3(JL)
@@ -680,7 +680,7 @@ DO WHILE (ANY(ZREMAINT>0.))
     ! ******* for pristine ice
     ZWSED(:,:,:) = 0.
 !$acc loop independent private(JI,JJ,JK,JL)
-    DO JL=1, ISEDIM
+    DO CONCURRENT( JL = 1 : ISEDIM )
       JI=I1(JL)
       JJ=I2(JL)
       JK=I3(JL)
@@ -731,7 +731,7 @@ DO WHILE (ANY(ZREMAINT>0.))
 !$acc kernels
     ZWSED(:,:,:) = 0.
 !$acc loop independent private(JI,JJ,JK,JL)
-    DO JL=1, ISEDIM
+    DO CONCURRENT( JL = 1 : ISEDIM )
       JI=I1(JL)
       JJ=I2(JL)
       JK=I3(JL)
-- 
GitLab