Index: LMDZ6/branches/Portage_acc/libf/dyn3d/driver.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/driver.F90	(revision 4165)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/driver.F90	(revision 4166)
@@ -24,4 +24,5 @@
 
   INTEGER :: ngrid ! # of grid points on physics grid = 2+(jjm-1)*iim-1/jjm
+  INTEGER :: ig,l
 
 !  REAL, PARAMETER :: unjours=86400.,    & ! solar day in seconds
@@ -169,6 +170,4 @@
   ALLOCATE(pq(ngrid,llm,nqtot)) ! tracers
 
-  !$acc data create(pplev, pplay, pphi, pphis, pt, pu, pv, pq, pr)
-
   CALL init_temperature_pressure_geopot(ps,masse,teta,phis, &
                                         ngrid,pplev,pplay,pphi,pphis,pt)
@@ -178,4 +177,7 @@
 ! 3. Temporal loop  
 
+  ! First time on GPU
+  !$acc data create(pplev, pplay, pphi, pphis, pt, pu, pv, pq, pr)
+
   CALL timeloop(ngrid,llm,nqtot,nday,day_step/iphysiq,dtphys,&
                 pplev,pplay,pphi,pphis,&
@@ -183,4 +185,14 @@
 
   !$acc end data
+
+  ! output final state as plain text file
+  open(10,file="driver.dat")
+  do ig=1,ngrid
+   do l=1,llm
+    write(10,"(I5,I3,X,20(1PE15.8,X))") &
+         ig,l,pu(ig,l),pv(ig,l),pt(ig,l)!,pq(ig,l,1:nqtot)
+   enddo
+  enddo
+  close(10)
 
   write(*,*)"driver: Everything is cool :-)"
Index: LMDZ6/branches/Portage_acc/libf/phylmd/ajsec.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/ajsec.F90	(revision 4165)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/ajsec.F90	(revision 4166)
@@ -15,9 +15,10 @@
   ! ======================================================================
   include "YOMCST.h"
-  REAL paprs(klon, klev+1), pplay(klon, klev)
-  REAL t(klon, klev), q(klon, klev)
-  REAL d_t(klon, klev), d_q(klon, klev)
-
-  INTEGER limbas(klon), limhau ! les couches a ajuster
+  REAL,INTENT(IN) :: paprs(klon, klev+1), pplay(klon, klev)
+  REAL,INTENT(IN) :: t(klon, klev), q(klon, klev)
+  REAL,INTENT(OUT) :: d_t(klon, klev), d_q(klon, klev)
+
+  INTEGER,INTENT(IN) :: limbas(klon)
+  INTEGER :: limhau ! les couches a ajuster
 
   LOGICAL mixq
Index: LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90	(revision 4165)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90	(revision 4166)
@@ -519,19 +519,19 @@
     ! NB: pdtphys to be used in physics is in time_phylmdz_mod
     LOGICAL debut, lafin
-    REAL paprs(klon,klev+1)
-    REAL pplay(klon,klev)
-    REAL pphi(klon,klev)
-    REAL pphis(klon)
-    REAL presnivs(klev)
+    REAL,INTENT(IN) :: paprs(klon,klev+1)
+    REAL,INTENT(IN) :: pplay(klon,klev)
+    REAL,INTENT(IN) :: pphi(klon,klev)
+    REAL,INTENT(IN) :: pphis(klon)
+    REAL,INTENT(IN) :: presnivs(klev)
 !JLD    REAL znivsig(klev)
 !JLD    real pir
     
-    REAL u(klon,klev)
-    REAL v(klon,klev)
-
+    REAL,INTENT(IN) :: u(klon,klev)
+    REAL,INTENT(IN) :: v(klon,klev)
     REAL, intent(in):: rot(klon, klev)
     ! relative vorticity, in s-1, needed for frontal waves
-
-    REAL t(klon,klev),thetal(klon,klev)
+    REAL t(klon,klev)
+    
+    REAL thetal(klon,klev)
     ! thetal: ligne suivante a decommenter si vous avez les fichiers
     !     MPL 20130625
@@ -539,11 +539,12 @@
     ! sinon thetal=theta
     !     REAL fth_thetae,fth_thetav,fth_thetal
-    REAL qx(klon,klev,nqtot)
-    REAL flxmass_w(klon,klev)
-    REAL d_u(klon,klev)
-    REAL d_v(klon,klev)
-    REAL d_t(klon,klev)
-    REAL d_qx(klon,klev,nqtot)
-    REAL d_ps(klon)
+    REAL,INTENT(IN) :: qx(klon,klev,nqtot)
+    REAL,INTENT(IN) :: flxmass_w(klon,klev)
+   
+    REAL,INTENT(OUT) :: d_u(klon,klev)
+    REAL,INTENT(OUT) :: d_v(klon,klev)
+    REAL,INTENT(OUT) :: d_t(klon,klev)
+    REAL,INTENT(OUT) :: d_qx(klon,klev,nqtot)
+    REAL,INTENT(OUT) :: d_ps(klon)
   ! variables pour tend_to_tke
     REAL duadd(klon,klev)
@@ -1264,9 +1265,13 @@
     REAL pi
 
-    !$acc data copyin (paprs, pplay)  &
+    !$acc data copyin(paprs,pplay,pphi,pphis,presnivs) &
+    !$acc & copyin(u,v) &
+    !$acc & copyin(rot,t) &
+    !$acc & copyin(qx,flxmass_w) &
+    !$acc & copyout(d_u,d_v,d_t,d_qx,d_ps) &
     !$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 &
+    !$acc &    create(t_x, q_x) 
+!    !$acc &    present(wake_s, wake_deltat, wake_deltaq)  &
+!    !$acc &    present(t_seri,q_seri)
 
     
@@ -2319,4 +2324,5 @@
     ! Ne pas affecter les valeurs entrees de u, v, h, et q
     !
+    !$acc kernels default(none)
     DO k = 1, klev
        DO i = 1, klon
@@ -2339,4 +2345,7 @@
        ENDDO
     ENDDO
+    !$acc end kernels
+    !temporary, update CPU
+    !$acc update self (t_seri,u_seri,v_seri,q_seri,ql_seri,qs_seri,rneb_seri)
     !
     !--OB mass fixer 
@@ -2963,4 +2972,6 @@
        !ajout pour la parametrisation des poches froides: calcul de
        !t_w et t_x: si pas de poches froides, t_w=t_x=t_seri
+       ! temporary , update on device
+       !$acc update device (t_seri, q_seri, wake_s, wake_deltat, wake_deltaq)
        IF (iflag_wake>=1) THEN
           !$acc kernels default(none) async
@@ -2994,5 +3005,5 @@
           IF (iflag_adjwk >= 1) THEN
              limbas(:) = 1
-             !$acc update device(limbas)
+             !$acc update device(limbas,wake_s)
              CALL ajsec(paprs, pplay, t_w, q_w, limbas, &
                   d_t_adjwk, d_q_adjwk)
@@ -3070,5 +3081,6 @@
           !jyg   iflag_con est dans clesphys
           !c          CALL concvl (iflag_con,iflag_clos,
-!$acc update host(t_w, q_w)
+! temporary, put data on CPU
+!$acc update self(t_w, q_w, t_x, q_x)
           CALL concvl (iflag_clos, &
                phys_tstep, paprs, pplay, k_upper_cv, t_x,q_x, &
@@ -3616,5 +3628,5 @@
           ELSE IF (iflag_thermals>0) THEN
              ! Calling adjustment above the top of thermal plumes
-             !$acc update device(limbas)
+             !$acc update device(t_seri,q_seri,limbas)
              CALL ajsec(paprs, pplay, t_seri,q_seri,limbas &
                   , d_t_ajsb, d_q_ajsb)
@@ -3623,4 +3635,5 @@
           !--------------------------------------------------------------------
           ! ajout des tendances de l'ajustement sec ou des thermiques
+          ! temporary, update CPU
           !$acc update host (d_t_ajsb, d_q_ajsb)
           CALL add_phys_tend(du0,dv0,d_t_ajsb,d_q_ajsb,dql0,dqi0,paprs, &
