Index: LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F	(revision 1910)
+++ LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F	(revision 1999)
@@ -17,9 +17,12 @@
        USE vampir
        USE timer_filtre, ONLY : print_filtre_timer
-       USE infotrac
+       USE infotrac, ONLY: nqtot
        USE guide_p_mod, ONLY : guide_main
        USE getparam
-       USE control_mod
-
+       USE control_mod, ONLY: nday, day_step, planet_type, offline,
+     &                       iconser, iphysiq, iperiod, dissip_period,
+     &                       iecri, ip_ebil_dyn, ok_dynzon, ok_dyn_ins,
+     &                       periodav, ok_dyn_ave, output_grads_dyn,
+     &                       iapp_tracvl
       IMPLICIT NONE
 
@@ -70,23 +73,25 @@
 #include "academic.h"
       
-      INTEGER         longcles
-      PARAMETER     ( longcles = 20 )
-      REAL  clesphy0( longcles )
+      INTEGER,PARAMETER :: longcles = 20
+      REAL,INTENT(IN) :: clesphy0( longcles ) ! not used
+      REAL,INTENT(IN) :: time_0 ! not used
+
+c   dynamical variables:
+      REAL,INTENT(INOUT) :: ucov(ip1jmp1,llm)    ! zonal covariant wind
+      REAL,INTENT(INOUT) :: vcov(ip1jm,llm)      ! meridional covariant wind
+      REAL,INTENT(INOUT) :: teta(ip1jmp1,llm)    ! potential temperature
+      REAL,INTENT(INOUT) :: ps(ip1jmp1)          ! surface pressure (Pa)
+      REAL,INTENT(INOUT) :: masse(ip1jmp1,llm)   ! air mass
+      REAL,INTENT(INOUT) :: phis(ip1jmp1)        ! geopotentiat at the surface
+      REAL,INTENT(INOUT) :: q(ip1jmp1,llm,nqtot) ! advected tracers
+
+      REAL,SAVE :: p (ip1jmp1,llmp1  )       ! interlayer pressure
+      REAL,SAVE :: pks(ip1jmp1)              ! exner at the surface
+      REAL,SAVE :: pk(ip1jmp1,llm)           ! exner at mid-layer
+      REAL,SAVE :: pkf(ip1jmp1,llm)          ! filtered exner at mid-layer
+      REAL,SAVE :: phi(ip1jmp1,llm)          ! geopotential
+      REAL,SAVE :: w(ip1jmp1,llm)            ! vertical velocity
 
       real zqmin,zqmax
-
-c   variables dynamiques
-      REAL :: vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
-      REAL :: teta(ip1jmp1,llm)                 ! temperature potentielle 
-      REAL :: q(ip1jmp1,llm,nqtot)              ! champs advectes
-      REAL :: ps(ip1jmp1)                       ! pression  au sol
-      REAL,SAVE :: p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
-      REAL,SAVE :: pks(ip1jmp1)                      ! exner au  sol
-      REAL,SAVE :: pk(ip1jmp1,llm)                   ! exner au milieu des couches
-      REAL,SAVE :: pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
-      REAL :: masse(ip1jmp1,llm)                ! masse d'air
-      REAL :: phis(ip1jmp1)                     ! geopotentiel au sol
-      REAL,SAVE :: phi(ip1jmp1,llm)                  ! geopotentiel
-      REAL,SAVE :: w(ip1jmp1,llm)                    ! vitesse verticale
 
 c variables dynamiques intermediaire pour le transport
@@ -123,5 +128,4 @@
 
       REAL  SSUM
-      REAL time_0 
 !      REAL,SAVE :: finvmaold(ip1jmp1,llm)
 
@@ -603,6 +607,5 @@
 
       IF( forward. OR . leapf )  THEN
-cc$OMP PARALLEL DEFAULT(SHARED) 
-c
+! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
          CALL caladvtrac_p(q,pbaru,pbarv,
      *        p, masse, dq,  teta,
@@ -616,5 +619,4 @@
 
       ENDIF ! of IF( forward. OR . leapf )
-cc$OMP END PARALLEL
 
 c-----------------------------------------------------------------------
@@ -763,4 +765,7 @@
         call Register_SwapFieldHallo(masse,masse,ip1jmp1,llm,
      *                               jj_Nb_physic,1,2,Request_physic)
+
+        call Register_SwapFieldHallo(ps,ps,ip1jmp1,1,
+     *                               jj_Nb_physic,2,2,Request_physic)
 
         call Register_SwapFieldHallo(p,p,ip1jmp1,llmp1,
@@ -907,5 +912,16 @@
      $                  ucov, vcov, teta , q   ,ps ,
      $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
-
+          ! since addfi updates ps(), also update p(), masse() and pk()
+          CALL pression_p(ip1jmp1,ap,bp,ps,p)
+c$OMP BARRIER
+          CALL massdair_p(p,masse)
+c$OMP BARRIER
+          if (pressure_exner) then
+            CALL exner_hyb_p(ip1jmp1,ps,p,alpha,beta,pks,pk,pkf)
+          else
+            CALL exner_milieu_p(ip1jmp1,ps,p,beta,pks,pk,pkf)
+          endif
+c$OMP BARRIER
+         
          IF (ok_strato) THEN
            CALL top_bound_p(vcov,ucov,teta,masse,dtphys)
@@ -930,4 +946,7 @@
         
         call Register_SwapField(masse,masse,ip1jmp1,llm,
+     *                               jj_Nb_caldyn,Request_physic)
+
+        call Register_SwapField(ps,ps,ip1jmp1,1,
      *                               jj_Nb_caldyn,Request_physic)
 
@@ -1044,4 +1063,6 @@
           CALL exner_milieu_p( ip1jmp1, ps, p, beta, pks, pk, pkf )
         endif
+c$OMP BARRIER
+        CALL massdair_p(p,masse)
 c$OMP BARRIER
 
