Index: LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90	(revision 4137)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90	(revision 4141)
@@ -37,6 +37,7 @@
          boundslon,boundslat, dx, dy, ind_cell_glo
     USE indice_sol_mod, ONLY: nbsrf,is_ave, is_ter, is_oce, is_lic, is_sic 
-    USE ioipsl, only: histbeg, histvert, histdef, histend, histsync, &
-         histwrite, ju2ymds, ymds2ju
+!    USE ioipsl, ONLY : histbeg, histvert, histdef, histend, histsync
+!    USE ioipsl, ONLY : histwrite, ju2ymds, ymds2ju
+    USE ioipsl, ONLY :  ymds2ju
     USE ioipsl_getin_p_mod, ONLY : getin_p
 !    USE indice_sol_mod
@@ -525,5 +526,5 @@
 !JLD    REAL znivsig(klev)
 !JLD    real pir
-
+    
     REAL u(klon,klev)
     REAL v(klon,klev)
@@ -1263,4 +1264,11 @@
     REAL pi
 
+    !$acc data copyin (paprs, pplay)  &
+    !$acc &    create(t_w, q_w, limbas, d_t_adjwk, d_q_adjwk) &
+    !$acc &    create(t_x, q_x) &
+    !$acc &    present(wake_s, wake_deltat, wake_deltaq, t_seri,q_seri) &
+    !$acc &
+
+    
     pi = 4. * ATAN(1.)
 
@@ -1939,6 +1947,8 @@
              d_deltat_the(:,:) = 0.
              d_deltaq_the(:,:) = 0.
+             !$acc kernels default(none)
              d_deltat_ajs_cv(:,:) = 0.
              d_deltaq_ajs_cv(:,:) = 0.
+             !$acc end kernels
              d_s_wk(:) = 0.
              d_dens_wk(:) = 0.
@@ -2954,5 +2964,6 @@
        !t_w et t_x: si pas de poches froides, t_w=t_x=t_seri
        IF (iflag_wake>=1) THEN
-         DO k=1,klev
+          !$acc kernels default(none) async
+          DO k=1,klev
             DO i=1,klon
                 t_w(i,k) = t_seri(i,k) + (1-wake_s(i))*wake_deltat(i,k)
@@ -2962,9 +2973,16 @@
             ENDDO
          ENDDO
-       ELSE
-                t_w(:,:) = t_seri(:,:)
-                q_w(:,:) = q_seri(:,:)
-                t_x(:,:) = t_seri(:,:)
-                q_x(:,:) = q_seri(:,:)
+         !$acc end kernels
+      ELSE
+          !$acc kernels default(none) async
+          DO k=1,klev
+            DO i=1,klon
+                t_w(i,k) = t_seri(i,k)
+                q_w(i,k) = q_seri(i,k)
+                t_x(i,k) = t_seri(i,k)
+                q_x(i,k) = q_seri(i,k)
+            ENDDO
+         ENDDO
+         !$acc end kernels
        ENDIF
        !
@@ -2976,20 +2994,27 @@
           IF (iflag_adjwk >= 1) THEN
              limbas(:) = 1
+             !$acc update device(limbas)
              CALL ajsec(paprs, pplay, t_w, q_w, limbas, &
                   d_t_adjwk, d_q_adjwk)
+             !$acc update self(d_t_adjwk, d_q_adjwk)
              !
-             DO k=1,klev
-                DO i=1,klon
-                   IF (wake_s(i) .GT. 1.e-3) THEN
+             IF (wake_s(i) .GT. 1.e-3) THEN
+                !$acc kernels default(none) async
+                DO k=1,klev
+                   DO i=1,klon
                       t_w(i,k) = t_w(i,k) + d_t_adjwk(i,k)
                       q_w(i,k) = q_w(i,k) + d_q_adjwk(i,k)
                       d_deltat_ajs_cv(i,k) = d_t_adjwk(i,k)
                       d_deltaq_ajs_cv(i,k) = d_q_adjwk(i,k)
-                   ELSE
-                      d_deltat_ajs_cv(i,k) = 0.
-                      d_deltaq_ajs_cv(i,k) = 0.
-                   ENDIF
+                   ENDDO
                 ENDDO
-             ENDDO
+                !$acc end kernels
+             ELSE
+                !$acc kernels default(none)
+                d_deltat_ajs_cv(i,k) = 0.
+                d_deltaq_ajs_cv(i,k) = 0.
+                !$acc end kernels
+             ENDIF
+             !$acc update self(d_deltat_ajs_cv,d_deltaq_ajs_cv)               
              IF (iflag_adjwk == 2) THEN
                CALL add_wake_tend &
@@ -3046,4 +3071,5 @@
           !jyg   iflag_con est dans clesphys
           !c          CALL concvl (iflag_con,iflag_clos,
+!$acc update host(t_w, q_w)
           CALL concvl (iflag_clos, &
                phys_tstep, paprs, pplay, k_upper_cv, t_x,q_x, &
@@ -3591,4 +3617,5 @@
           ELSE IF (iflag_thermals>0) THEN
              ! Calling adjustment above the top of thermal plumes
+             !$acc update device(limbas)
              CALL ajsec(paprs, pplay, t_seri,q_seri,limbas &
                   , d_t_ajsb, d_q_ajsb)
@@ -3597,4 +3624,5 @@
           !--------------------------------------------------------------------
           ! ajout des tendances de l'ajustement sec ou des thermiques
+          !$acc update host (d_t_ajsb, d_q_ajsb)
           CALL add_phys_tend(du0,dv0,d_t_ajsb,d_q_ajsb,dql0,dqi0,paprs, &
                'ajsb',abortphy,flag_inhib_tend,itap,0)
@@ -5424,5 +5452,6 @@
 
     !      first=.false.
-
+    
+  !$acc end data
   END SUBROUTINE physiq
 
