Index: LMDZ4/trunk/libf/dyn3dpar/abort_gcm.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/abort_gcm.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/abort_gcm.F	(revision 985)
@@ -25,6 +25,8 @@
       write(lunout,*) 'in abort_gcm'
 #ifdef CPP_IOIPSL
+c$OMP MASTER
       call histclo
       call restclo
+c$OMP END MASTER
 #endif
 c     call getin_dump
@@ -39,5 +41,5 @@
       else
         write(lunout,*) 'Houston, we have a problem ', ierr
+      STOP
       endif
-      STOP
       END
Index: LMDZ4/trunk/libf/dyn3dpar/advtrac_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/advtrac_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/advtrac_p.F	(revision 985)
@@ -82,5 +82,5 @@
       DATA fill/.true./
       DATA dum/.true./
-      REAL finmasse(ip1jmp1,llm)
+      REAL,SAVE :: finmasse(ip1jmp1,llm)
       integer ijb,ije,ijb_u,ijb_v,ije_u,ije_v,j
       type(Request) :: Request_vanleer
@@ -161,14 +161,25 @@
 c     2. groupement des mailles pres du pole.
 
-c$OMP BARRIER
         CALL groupe_p( massem, pbaruc,pbarvc, pbarug,pbarvg,wg )
-c$OMP BARRIER
-
-c$OMP BARRIER
-c$OMP MASTER      
-      p_tmp(ijb:ije,1:llmp1)=p(ijb:ije,1:llmp1)
-      pk_tmp(ijb:ije,1:llm)=pk(ijb:ije,1:llm)
-      teta_tmp(ijb:ije,1:llm)=teta(ijb:ije,1:llm)
+
+c$OMP BARRIER
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      DO l=1,llmp1
+        p_tmp(ijb:ije,l)=p(ijb:ije,l)
+      ENDDO
+c$OMP END DO NOWAIT
+      
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      DO l=1,llm
+        pk_tmp(ijb:ije,l)=pk(ijb:ije,l)
+        teta_tmp(ijb:ije,l)=teta(ijb:ije,l)
+      ENDDO
+c$OMP END DO NOWAIT
+
+c$OMP MASTER
       call VTb(VTHallo)
+c$OMP END MASTER
+
       call Register_SwapFieldHallo(pbarug,pbarug,ip1jmp1,llm,
      *                             jj_Nb_vanleer,0,0,Request_vanleer)
@@ -189,11 +200,14 @@
      *                             jj_nb_vanleer,0,0,Request_vanleer)
       enddo
-      
+
+      call SendRequest(Request_vanleer)
+c$OMP BARRIER
+      call WaitRequest(Request_vanleer)
+
+
+c$OMP BARRIER
+c$OMP MASTER      
       call SetDistrib(jj_nb_vanleer)
-      call SendRequest(Request_vanleer)
-      call WaitRequest(Request_vanleer)
-
       call VTe(VTHallo)
-      
       call VTb(VTadvection)
       call start_timer(timer_vanleer)
@@ -440,8 +454,9 @@
 1234  CONTINUE
 c$OMP BARRIER
-c$OMP MASTER
+
       ijb=ij_begin
       ije=ij_end
-      
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
        DO l = 1, llm
          DO ij = ijb, ije
@@ -449,5 +464,5 @@
          ENDDO
        ENDDO
-
+c$OMP END DO
 
        CALL qminimum_p( q, 2, finmasse )
@@ -457,8 +472,11 @@
 c---------------------------------------------------
 c          iadvtr=0
+
+c$OMP MASTER
 	call VTe(VTadvection)
         call stop_timer(timer_vanleer)
-
         call VTb(VThallo)
+c$OMP END MASTER
+
 	do j=1,nqmx
           call Register_SwapFieldHallo(q(1,1,j),q(1,1,j),ip1jmp1,llm,
@@ -469,8 +487,11 @@
      *       jj_nb_caldyn,0,0,Request_vanleer)
 
+        call SendRequest(Request_vanleer)
+c$OMP BARRIER
+        call WaitRequest(Request_vanleer)      
+
+c$OMP BARRIER
+c$OMP MASTER
         call SetDistrib(jj_nb_caldyn)
-        call SendRequest(Request_vanleer)
-        call WaitRequest(Request_vanleer)      
-        
 	call VTe(VThallo)
 	call resume_timer(timer_caldyn)
Index: LMDZ4/trunk/libf/dyn3dpar/bilan_dyn_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/bilan_dyn_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/bilan_dyn_p.F	(revision 985)
@@ -164,4 +164,16 @@
       type(Request) :: Req
 
+! definition du domaine d'ecriture pour le rebuild
+
+      INTEGER,DIMENSION(1) :: ddid
+      INTEGER,DIMENSION(1) :: dsg
+      INTEGER,DIMENSION(1) :: dsl
+      INTEGER,DIMENSION(1) :: dpf
+      INTEGER,DIMENSION(1) :: dpl
+      INTEGER,DIMENSION(1) :: dhs
+      INTEGER,DIMENSION(1) :: dhe 
+      
+      INTEGER :: bilan_dyn_domain_id
+
 
 c=====================================================================
@@ -233,10 +245,25 @@
       jje=jj_end
       jjn=jj_nb
-      if (pole_sud) jjn=jj_nb-1
+      IF (pole_sud) THEN
+        jjn=jj_nb-1
+        jje=jj_end-1
+      ENDIF
+
+      ddid=(/ 2 /)
+      dsg=(/ jjm /)
+      dsl=(/ jjn /)
+      dpf=(/ jjb /)
+      dpl=(/ jje /)
+      dhs=(/ 0 /)
+      dhe=(/ 0 /)
+
+      call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, 
+     .                 'box',bilan_dyn_domain_id)
        
-      call histbeg(trim(infile)//'_'//trim(int2str(mpi_rank)),
+      call histbeg(trim(infile),
      .             1, rlong(jjb:jje), jjn, rlatg(jjb:jje),
      .             1, 1, 1, jjn,
-     .             tau0, zjulian, dt_cum, thoriid, fileid)
+     .             tau0, zjulian, dt_cum, thoriid, fileid,
+     .             bilan_dyn_domain_id)
 
 C
@@ -352,11 +379,16 @@
 c
       if(icum.EQ.0) then
-         ps_cum=0.
-         masse_cum=0.
-         flux_u_cum=0.
-         flux_v_cum=0.
-         Q_cum=0.
-         flux_vQ_cum=0.
-         flux_uQ_cum=0.
+         jjb=jj_begin
+         jje=jj_end
+
+         ps_cum(:,jjb:jje)=0.
+         masse_cum(:,jjb:jje,:)=0.
+         flux_u_cum(:,jjb:jje,:)=0.
+         Q_cum(:,jjb:jje,:,:)=0.
+         flux_uQ_cum(:,jjb:jje,:,:)=0.
+         flux_v_cum(:,jjb:jje,:)=0.
+         if (pole_sud) jje=jj_end-1
+         flux_v_cum(:,jjb:jje,:)=0.
+         flux_vQ_cum(:,jjb:jje,:,:)=0.
       endif
 
@@ -366,8 +398,18 @@
 
 c   accumulation des flux de masse horizontaux
-      ps_cum=ps_cum+ps
-      masse_cum=masse_cum+masse
-      flux_u_cum=flux_u_cum+flux_u
-      flux_v_cum=flux_v_cum+flux_v
+      jjb=jj_begin
+      jje=jj_end
+
+      ps_cum(:,jjb:jje)=ps_cum(:,jjb:jje)+ps(:,jjb:jje)
+      masse_cum(:,jjb:jje,:)=masse_cum(:,jjb:jje,:)+masse(:,jjb:jje,:)
+      flux_u_cum(:,jjb:jje,:)=flux_u_cum(:,jjb:jje,:)
+     .                       +flux_u(:,jjb:jje,:)
+      if (pole_sud) jje=jj_end-1
+      flux_v_cum(:,jjb:jje,:)=flux_v_cum(:,jjb:jje,:)
+     .                         +flux_v(:,jjb:jje,:)
+
+      jjb=jj_begin
+      jje=jj_end
+
       do iQ=1,nQ
         Q_cum(:,jjb:jje,:,iQ)=Q_cum(:,jjb:jje,:,iQ)
@@ -396,4 +438,14 @@
 c    -------------
       do iQ=1,nQ
+        call Register_Hallo(Q(1,1,1,iQ),ip1jmp1,llm,0,1,1,0,Req)
+      enddo
+      call SendRequest(Req)
+      call WaitRequest(Req)
+      
+      jjb=jj_begin
+      jje=jj_end
+      if (pole_sud) jje=jj_end-1
+      
+      do iQ=1,nQ
          do l=1,llm
             do j=jjb,jje
@@ -426,4 +478,7 @@
       call convmas_p(flux_u_cum,flux_v_cum,convm)
       CALL vitvert_p(convm,w)
+
+      jjb=jj_begin
+      jje=jj_end
 
       do iQ=1,nQ
@@ -455,11 +510,20 @@
       enddo
       zz=1./float(ncum)
-      ps_cum=ps_cum*zz
-      masse_cum=masse_cum*zz
-      flux_u_cum=flux_u_cum*zz
-      flux_v_cum=flux_v_cum*zz
-      flux_uQ_cum=flux_uQ_cum*zz
-      flux_vQ_cum=flux_vQ_cum*zz
-      dQ=dQ*zz
+
+      jjb=jj_begin
+      jje=jj_end
+
+      ps_cum(:,jjb:jje)=ps_cum(:,jjb:jje)*zz
+      masse_cum(:,jjb:jje,:)=masse_cum(:,jjb:jje,:)*zz
+      flux_u_cum(:,jjb:jje,:)=flux_u_cum(:,jjb:jje,:)*zz
+      flux_uQ_cum(:,jjb:jje,:,:)=flux_uQ_cum(:,jjb:jje,:,:)*zz
+      dQ(:,jjb:jje,:,:)=dQ(:,jjb:jje,:,:)*zz
+      
+      IF (pole_sud) jje=jj_end-1
+      flux_v_cum(:,jjb:jje,:)=flux_v_cum(:,jjb:jje,:)*zz
+      flux_vQ_cum(:,jjb:jje,:,:)=flux_vQ_cum(:,jjb:jje,:,:)*zz
+
+      jjb=jj_begin
+      jje=jj_end
 
 
@@ -476,7 +540,20 @@
 c   cumul zonal des masses des mailles
 c   ----------------------------------
-      zv=0.
-      zmasse=0.
-      call massbar(masse_cum,massebx,masseby)
+      jjb=jj_begin
+      jje=jj_end
+      if (pole_sud) jje=jj_end-1
+
+      zv(jjb:jje,:)=0.
+      zmasse(jjb:jje,:)=0.
+
+      call Register_Hallo(masse_cum,ip1jmp1,llm,1,1,1,1,Req)
+      do iQ=1,nQ
+        call Register_Hallo(Q_cum(1,1,1,iQ),ip1jmp1,llm,0,1,1,0,Req)
+      enddo
+
+      call SendRequest(Req)
+      call WaitRequest(Req)
+
+      call massbar_p(masse_cum,massebx,masseby)
       
       jjb=jj_begin
@@ -524,4 +601,8 @@
 c   ----------------------------------------
 
+      jjb=jj_begin
+      jje=jj_end
+      if (pole_sud) jje=jj_end-1
+      
       zvQ=0.
       psiQ=0.
@@ -560,5 +641,5 @@
 
 c   fonction de courant pour la circulation meridienne moyenne
-      psi=0.
+      psi(jjb:jje,:)=0.
       do l=llm,1,-1
          do j=jjb,jje
@@ -588,9 +669,9 @@
       enddo
 
-      call histwrite(fileid,'masse',itau,zmasse(jjb:jje,1)
+      call histwrite(fileid,'masse',itau,zmasse(jjb:jje,1:llm)
      s   ,jjn*llm,ndex3d)
-      call histwrite(fileid,'v',itau,zv(jjb:jje,1)
+      call histwrite(fileid,'v',itau,zv(jjb:jje,1:llm)
      s   ,jjn*llm,ndex3d)
-      psi=psi*1.e-9
+      psi(jjb:jje,:)=psi(jjb:jje,:)*1.e-9
       call histwrite(fileid,'psi',itau,psi(jjb:jje,1:llm),
      s               jjn*llm,ndex3d)
@@ -603,9 +684,10 @@
 c   -----------------
 
-      zamasse=0.
+      zamasse(jjb:jje)=0.
       do l=1,llm
          zamasse(jjb:jje)=zamasse(jjb:jje)+zmasse(jjb:jje,l)
       enddo
-      zavQ=0.
+     
+      zavQ(jjb:jje,:,:)=0.
       do iQ=1,nQ
          do itr=2,ntr
Index: LMDZ4/trunk/libf/dyn3dpar/calfis_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/calfis_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/calfis_p.F	(revision 985)
@@ -161,4 +161,6 @@
       REAL,ALLOCATABLE,SAVE :: zdtfi(:,:),zdqfi(:,:,:)
       REAL,ALLOCATABLE,SAVE :: zdpsrf(:)
+      REAL,SAVE,ALLOCATABLE ::  flxwfi(:,:)     ! Flux de masse verticale sur la grille physiq
+
 c
       REAL,ALLOCATABLE,SAVE :: zplev_omp(:,:)
@@ -177,9 +179,10 @@
       REAL,ALLOCATABLE,SAVE :: zdqfi_omp(:,:,:)
       REAL,ALLOCATABLE,SAVE :: zdpsrf_omp(:)
+      REAL,SAVE,ALLOCATABLE ::  flxwfi_omp(:,:)     ! Flux de masse verticale sur la grille physiq
 
 c$OMP THREADPRIVATE(zplev_omp,zplay_omp,zphi_omp,zphis_omp,
 c$OMP+                 presnivs_omp,zufi_omp,zvfi_omp,ztfi_omp,
-c$OMP+                 zqfi_omp,pvervel_omp,zdufi_omp,zdvfi_omp,
-c$OMP+                 zdtfi_omp,zdqfi_omp,zdpsrf_omp)       
+c$OMP+                 zqfi_omp,zdufi_omp,zdvfi_omp,
+c$OMP+                 zdtfi_omp,zdqfi_omp,zdpsrf_omp,flxwfi_omp)       
 
       LOGICAL,SAVE :: first_omp=.true.
@@ -198,5 +201,4 @@
       
       REAL flxw(iip1,jjp1,llm)  ! Flux de masse verticale sur la grille dynamique
-      REAL flxwfi(klon,llm)     ! Flux de masse verticale sur la grille physiq
       
       REAL SSUM
@@ -254,4 +256,5 @@
       ALLOCATE(zdpsrf(klon))
       ALLOCATE(zdufi2(klon+iim,llm),zdvfi2(klon+iim,llm))
+      ALLOCATE(flxwfi(klon,llm))
 c$OMP END MASTER
 c$OMP BARRIER	  
@@ -548,4 +551,5 @@
         allocate(zdqfi_omp(klon,llm,nq))
         allocate(zdpsrf_omp(klon))
+        allocate(flxwfi_omp(klon,llm))
 	first_omp=.false.
       endif
@@ -643,4 +647,10 @@
 	zdpsrf_omp(i)=zdpsrf(offset+i)
       enddo 
+
+      do l=1,llm
+        do i=1,klon
+          flxwfi_omp(i,l)=flxwfi(offset+i,l)
+	enddo 
+      enddo
       
 c$OMP BARRIER
@@ -667,5 +677,5 @@
 c     .             pvervel_omp,
 c#ifdef INCA
-     .             flxwfi,
+     .             flxwfi_omp,
 c#endif
      .             zdufi_omp,
@@ -794,8 +804,10 @@
 c$OMP BARRIER
 c$OMP MASTER
+!$OMP CRITICAL (MPI)
         call MPI_ISSEND(du_send,iim*llm,MPI_REAL8,MPI_Rank-1,401,
      &                   COMM_LMDZ,Req(1),ierr)
         call MPI_ISSEND(dv_send,iim*llm,MPI_REAL8,MPI_Rank-1,402,
      &                  COMM_LMDZ,Req(2),ierr)
+!$OMP END CRITICAL (MPI)
 c$OMP END MASTER
 c$OMP BARRIER
@@ -806,8 +818,10 @@
 c$OMP BARRIER
 c$OMP MASTER      
+!$OMP CRITICAL (MPI)
         call MPI_IRECV(du_recv,iim*llm,MPI_REAL8,MPI_Rank+1,401,
      &                 COMM_LMDZ,Req(3),ierr)
         call MPI_IRECV(dv_recv,iim*llm,MPI_REAL8,MPI_Rank+1,402,
      &                 COMM_LMDZ,Req(4),ierr)
+!$OMP END CRITICAL (MPI)
 c$OMP END MASTER
 c$OMP BARRIER     
@@ -816,4 +830,5 @@
 c$OMP BARRIER
 c$OMP MASTER    
+!$OMP CRITICAL (MPI)
       if (MPI_rank>0 .and. MPI_rank< MPI_Size-1) then
         call MPI_WAITALL(4,Req(1),Status,ierr)
@@ -823,4 +838,5 @@
         call MPI_WAITALL(2,Req(3),Status,ierr)
       endif
+!$OMP END CRITICAL (MPI)
 c$OMP END MASTER
 c$OMP BARRIER     
Index: LMDZ4/trunk/libf/dyn3dpar/conf_gcm.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/conf_gcm.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/conf_gcm.F	(revision 985)
@@ -8,4 +8,7 @@
       use IOIPSL
       use misc_mod
+      use mod_filtre_fft, ONLY : use_filtre_fft
+      use mod_hallo, ONLY : use_mpi_alloc
+      use parallel, ONLY : omp_chunk
       IMPLICIT NONE
 c-----------------------------------------------------------------------
@@ -34,6 +37,8 @@
 #include "serre.h"
 #include "comdissnew.h"
-#include "clesphys.h"
+!#include "clesphys.h"
 #include "iniprint.h"
+
+! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
 c
 c
@@ -298,79 +303,5 @@
 c
 
-!Config  Key  = ecritphy
-!Config  Desc = Frequence d'ecriture de la physique
-!Config  Def  = 1
-!Config  Help = frequence  de l'ecriture du fichier histphy
-!Config         en jours.
-       ecritphy = 1
-       CALL getin('ecritphy',ecritphy)
-
-!Config  Key  = cycle_diurne
-!Config  Desc = Cycle ddiurne
-!Config  Def  = y
-!Config  Help = Cette option permet d'eteidre le cycle diurne.
-!Config         Peut etre util pour accelerer le code !
-       cycle_diurne = .TRUE.
-       CALL getin('cycle_diurne',cycle_diurne)
-
-!Config  Key  = soil_model
-!Config  Desc = Modele de sol
-!Config  Def  = y
-!Config  Help = Choix du modele de sol (Thermique ?)
-!Config         Option qui pourait un string afin de pouvoir
-!Config         plus de choix ! Ou meme une liste d'options !
-       soil_model = .TRUE.
-       CALL getin('soil_model',soil_model)
-
-!Config  Key  = new_oliq
-!Config  Desc = Nouvelle eau liquide
-!Config  Def  = y
-!Config  Help = Permet de mettre en route la
-!Config         nouvelle parametrisation de l'eau liquide !
-       new_oliq = .TRUE.
-       CALL getin('new_oliq',new_oliq)
-
-!Config  Key  = ok_orodr
-!Config  Desc = Orodr ???
-!Config  Def  = y
-!Config  Help = Y en a pas comprendre !
-!Config         
-       ok_orodr = .TRUE.
-       CALL getin('ok_orodr',ok_orodr)
-
-!Config  Key  =  ok_orolf
-!Config  Desc = Orolf ??
-!Config  Def  = y
-!Config  Help = Connais pas !
-       ok_orolf = .TRUE.
-       CALL getin('ok_orolf', ok_orolf)
-
-!Config  Key  = ok_limitvrai
-!Config  Desc = Force la lecture de la bonne annee
-!Config  Def  = n
-!Config  Help = On peut forcer le modele a lire le
-!Config         fichier SST de la bonne annee. C'est une tres bonne
-!Config         idee, pourquoi ne pas mettre toujours a y ???
-       ok_limitvrai = .FALSE.
-       CALL getin('ok_limitvrai',ok_limitvrai)
-
-!Config  Key  = nbapp_rad
-!Config  Desc = Frequence d'appel au rayonnement
-!Config  Def  = 12
-!Config  Help = Nombre  d'appels des routines de rayonnements
-!Config         par jour.
-       nbapp_rad = 12
-       CALL getin('nbapp_rad',nbapp_rad)
-
-!Config  Key  = iflag_con
-!Config  Desc = Flag de convection
-!Config  Def  = 2
-!Config  Help = Flag  pour la convection les options suivantes existent :
-!Config         1 pour LMD,
-!Config         2 pour Tiedtke,
-!Config         3 pour CCM(NCAR)  
-       iflag_con = 2
-       CALL getin('iflag_con',iflag_con)
-!
+
 !Config  Key  = ip_ebil_dyn
 !Config  Desc = PRINT level for energy conserv. diag.
@@ -384,17 +315,4 @@
        CALL getin('ip_ebil_dyn',ip_ebil_dyn)
 !
-
-      DO i = 1, longcles
-       clesphy0(i) = 0.
-      ENDDO
-                          clesphy0(1) = FLOAT( iflag_con )
-                          clesphy0(2) = FLOAT( nbapp_rad )
-
-       IF( cycle_diurne  ) clesphy0(3) =  1.
-       IF(   soil_model  ) clesphy0(4) =  1.
-       IF(     new_oliq  ) clesphy0(5) =  1.
-       IF(     ok_orodr  ) clesphy0(6) =  1.
-       IF(     ok_orolf  ) clesphy0(7) =  1.
-       IF(  ok_limitvrai ) clesphy0(8) =  1.
 
 
@@ -633,14 +551,4 @@
       write(lunout,*)' purmats = ', purmats
       write(lunout,*)' iflag_phys = ', iflag_phys
-      write(lunout,*)' iphysiq = ', iphysiq
-      write(lunout,*)' ecritphy = ', ecritphy
-      write(lunout,*)' cycle_diurne = ', cycle_diurne
-      write(lunout,*)' soil_model = ', soil_model
-      write(lunout,*)' new_oliq = ', new_oliq
-      write(lunout,*)' ok_orodr = ', ok_orodr
-      write(lunout,*)' ok_orolf = ', ok_orolf
-      write(lunout,*)' ok_limitvrai = ', ok_limitvrai
-      write(lunout,*)' nbapp_rad = ', nbapp_rad
-      write(lunout,*)' iflag_con = ', iflag_con
       write(lunout,*)' clonn = ', clonn 
       write(lunout,*)' clatt = ', clatt
@@ -777,4 +685,31 @@
       CALL getin('config_inca',config_inca)
 
+!Config  Key  = use_filtre_fft
+!Config  Desc = flag d'activation des FFT pour le filtre
+!Config  Def  = false
+!Config  Help = permet d'activer l'utilisation des FFT pour effectuer
+!Config         le filtrage aux poles. 
+      use_filtre_fft=.FALSE.
+      CALL getin('use_filtre_fft',use_filtre_fft)
+      
+!Config  Key  = use_mpi_alloc
+!Config  Desc = Utilise un buffer MPI en mémoire globale
+!Config  Def  = false
+!Config  Help = permet d'activer l'utilisation d'un buffer MPI
+!Config         en mémoire globale a l'aide de la fonction MPI_ALLOC.
+!Config         Cela peut améliorer la bande passante des transferts MPI
+!Config         d'un facteur 2  
+      use_mpi_alloc=.FALSE.
+      CALL getin('use_mpi_alloc',use_mpi_alloc)
+
+!Config  Key  = omp_chunk
+!Config  Desc = taille des blocs openmp
+!Config  Def  = 1
+!Config  Help = defini la taille des packets d'itération openmp
+!Config         distribuée à chaque tâche lors de l'entrée dans une
+!Config         boucle parallélisée
+  
+      omp_chunk=1
+      CALL getin('omp_chunk',omp_chunk)
 
       write(lunout,*)' #########################################'
@@ -799,16 +734,6 @@
       write(lunout,*)' purmats = ', purmats
       write(lunout,*)' iflag_phys = ', iflag_phys
-      write(lunout,*)' iphysiq = ', iphysiq
-      write(lunout,*)' ecritphy = ', ecritphy
-      write(lunout,*)' cycle_diurne = ', cycle_diurne
-      write(lunout,*)' soil_model = ', soil_model
-      write(lunout,*)' new_oliq = ', new_oliq
-      write(lunout,*)' ok_orodr = ', ok_orodr
-      write(lunout,*)' ok_orolf = ', ok_orolf
-      write(lunout,*)' ok_limitvrai = ', ok_limitvrai
-      write(lunout,*)' nbapp_rad = ', nbapp_rad
-      write(lunout,*)' iflag_con = ', iflag_con
-      write(lunout,*)' clonn = ', clonn 
-      write(lunout,*)' clatt = ', clatt
+      write(lunout,*)' clon = ', clon 
+      write(lunout,*)' clat = ', clat
       write(lunout,*)' grossismx = ', grossismx
       write(lunout,*)' grossismy = ', grossismy
@@ -820,4 +745,7 @@
       write(lunout,*)' offline = ', offline
       write(lunout,*)' config_inca = ', config_inca
+      write(lunout,*)' use_filtre_fft = ', use_filtre_fft
+      write(lunout,*)' use_mpi_alloc = ', use_mpi_alloc
+      write(lunout,*)' omp_chunk = ', omp_chunk
 c
       RETURN
Index: LMDZ4/trunk/libf/dyn3dpar/control.h
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/control.h	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/control.h	(revision 985)
@@ -13,5 +13,5 @@
       COMMON/control/nday,day_step,                                     &
      &              iperiod,iapp_tracvl,iconser,iecri,idissip,iphysiq , &
-     &              periodav,ecritphy,iecrimoy,dayref,anneeref,         &
+     &              periodav,iecrimoy,dayref,anneeref,                  &
      &              raz_date,offline,ip_ebil_dyn,config_inca
 
@@ -19,5 +19,5 @@
      &          idissip,iphysiq,iecrimoy,dayref,anneeref, raz_date      &
      &          ,ip_ebil_dyn
-      REAL periodav, ecritphy
+      REAL periodav
       logical offline
       CHARACTER*4 config_inca
Index: LMDZ4/trunk/libf/dyn3dpar/defrun.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/defrun.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/defrun.F	(revision 985)
@@ -198,9 +198,4 @@
 ccc   .... P.Le Van, ajout le 03/01/96 pour l'ecriture phys ...
 c
-      READ (tapedef,9001) ch1,ch4
-      READ (tapedef,*)    ecritphy
-      WRITE(tapeout,9001) ch1,'ecritphy'
-      WRITE(tapeout,*)    ecritphy
-
       READ (tapedef,9001) ch1,ch4
       READ (tapedef,*)    cycle_diurne
Index: LMDZ4/trunk/libf/dyn3dpar/dissip_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/dissip_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/dissip_p.F	(revision 985)
@@ -99,7 +99,4 @@
       ENDIF
 
-c      call write_field3d_p('gdx',reshape(gdx,(/iip1,jjp1,llm/)))
-c     call write_field3d_p('gdy',reshape(gdy,(/iip1,jjm,llm/)))
-c       stop
 
       ijb=ij_begin
@@ -143,7 +140,4 @@
       ENDIF
 
-c      call write_field3d_p('grx',reshape(grx,(/iip1,jjp1,llm/)))
-c      call write_field3d_p('gry',reshape(gry,(/iip1,jjm,llm/)))
-c          stop
 
 
Index: LMDZ4/trunk/libf/dyn3dpar/divgrad2_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/divgrad2_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/divgrad2_p.F	(revision 985)
@@ -12,4 +12,5 @@
       USE parallel
       USE times
+      USE mod_hallo
       IMPLICIT NONE
 c
@@ -32,5 +33,5 @@
       INTEGER  l,ij,iter,lh
 c    ...................................................................
-
+      Type(Request) :: request_dissip
       INTEGER ijb,ije
 c
@@ -48,10 +49,10 @@
 c
 c$OMP BARRIER
-c$OMP MASTER
-      call suspend_timer(timer_dissip)
-      call exchange_Hallo(divgra,ip1jmp1,llm,1,1)
-      call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(divgra,ip1jmp1,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
 c$OMP BARRIER
+       call WaitRequest(Request_dissip)
+c$OMP BARRIER
+
       CALL laplacien_p( klevel, divgra, divgra )
 
@@ -77,10 +78,12 @@
       DO  iter = 1, lh - 2
 c$OMP BARRIER
-c$OMP MASTER
-       call suspend_timer(timer_dissip)
-       call exchange_Hallo(divgra,ip1jmp1,llm,1,1)
-       call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(divgra,ip1jmp1,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
 c$OMP BARRIER
+       call WaitRequest(Request_dissip)
+
+c$OMP BARRIER
+
+
        CALL laplacien_gam_p ( klevel,cuvscvgam2,cvuscugam2,unsair_gam2,
      *                     unsapolnga2, unsapolsga2,  divgra, divgra )
@@ -98,9 +101,8 @@
 c
 c$OMP BARRIER
-c$OMP MASTER
-      call suspend_timer(timer_dissip)
-      call exchange_Hallo(divgra,ip1jmp1,llm,1,1)
-      call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(divgra,ip1jmp1,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
+c$OMP BARRIER
+       call WaitRequest(Request_dissip)
 c$OMP BARRIER
 
Index: LMDZ4/trunk/libf/dyn3dpar/dynredem_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/dynredem_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/dynredem_p.F	(revision 985)
@@ -527,4 +527,5 @@
 #include "advtrac.h"
 #include "temps.h"
+#include "control.h"
 
       INTEGER nq, l
@@ -536,6 +537,7 @@
      
       REAL time
-      INTEGER nid, nvarid
-      INTEGER ierr
+      INTEGER nid, nvarid, nid_trac, nvarid_trac
+      REAL trac_tmp(ip1jmp1,llm)      
+      INTEGER ierr, ierr_file
       INTEGER iq
       INTEGER length
@@ -641,18 +643,89 @@
 #endif
 
+      IF (config_inca /= 'none') THEN
+! Ajout Anne pour lecture valeurs traceurs dans un fichier start_trac.nc
+         ierr_file = NF_OPEN ("start_trac.nc", NF_NOWRITE,nid_trac)
+         IF (ierr_file .NE.NF_NOERR) THEN
+            write(6,*)' Pb d''ouverture du fichier start_trac.nc'
+            write(6,*)' ierr = ', ierr_file 
+         ENDIF
+      END IF
+
       IF(nq.GE.1) THEN
-       do iq=1,nq   
-        ierr = NF_INQ_VARID(nid, tname(iq), nvarid)
-        IF (ierr .NE. NF_NOERR) THEN
-           PRINT*, "Variable  tname(iq) n est pas definie"
-           CALL abort
-        ENDIF
-#ifdef NC_DOUBLE
-          ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q(1,1,iq))
-#else
-          ierr = NF_PUT_VAR_REAL (nid,nvarid,q(1,1,iq))
-#endif
+      do iq=1,nq 
+
+         IF (config_inca == 'none') THEN
+            ierr = NF_INQ_VARID(nid, tname(iq), nvarid)
+            IF (ierr .NE. NF_NOERR) THEN
+               PRINT*, "Variable  tname(iq) n est pas definie"
+               CALL abort
+            ENDIF
+#ifdef NC_DOUBLE
+            ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q(1,1,iq))
+#else
+            ierr = NF_PUT_VAR_REAL (nid,nvarid,q(1,1,iq))
+#endif
+        ELSE ! config_inca = 'chem' ou 'aero'
+! lecture de la valeur du traceur dans start_trac.nc
+           IF (ierr_file .ne. 2) THEN
+             ierr = NF_INQ_VARID (nid_trac, tname(iq), nvarid_trac)
+             IF (ierr .NE. NF_NOERR) THEN
+                PRINT*, tname(iq),"est absent de start_trac.nc"
+                ierr = NF_INQ_VARID(nid, tname(iq), nvarid)
+                IF (ierr .NE. NF_NOERR) THEN
+                   PRINT*, "Variable ", tname(iq)," n est pas definie"
+                   CALL abort
+                ENDIF
+#ifdef NC_DOUBLE
+                ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q(1,1,iq))
+#else
+                ierr = NF_PUT_VAR_REAL (nid,nvarid,q(1,1,iq))
+#endif
+                
+             ELSE
+                PRINT*, tname(iq), "est present dans start_trac.nc"
+#ifdef NC_DOUBLE
+               ierr = NF_GET_VAR_DOUBLE(nid_trac, nvarid_trac, trac_tmp)
+#else
+               ierr = NF_GET_VAR_REAL(nid_trac, nvarid_trac, trac_tmp)
+#endif
+                IF (ierr .NE. NF_NOERR) THEN
+                   PRINT*, "Lecture echouee pour", tname(iq)
+                   CALL abort
+                ENDIF
+                ierr = NF_INQ_VARID(nid, tname(iq), nvarid)
+                IF (ierr .NE. NF_NOERR) THEN
+                   PRINT*, "Variable ", tname(iq)," n est pas definie"
+                   CALL abort
+                ENDIF
+#ifdef NC_DOUBLE
+                ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,trac_tmp)
+#else
+                ierr = NF_PUT_VAR_REAL (nid,nvarid,trac_tmp)
+#endif
+               
+             ENDIF ! IF (ierr .NE. NF_NOERR)
+! fin lecture du traceur
+          ELSE                  ! si il n'y a pas de fichier start_trac.nc
+!             print *, 'il n y a pas de fichier start_trac'
+             ierr = NF_INQ_VARID(nid, tname(iq), nvarid)
+             IF (ierr .NE. NF_NOERR) THEN
+                PRINT*, "Variable  tname(iq) n est pas definie"
+                CALL abort
+             ENDIF
+#ifdef NC_DOUBLE
+             ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q(1,1,iq))
+#else
+             ierr = NF_PUT_VAR_REAL (nid,nvarid,q(1,1,iq))
+#endif
+          ENDIF ! (ierr_file .ne. 2)
+       END IF   ! config_inca
+      
       ENDDO
       ENDIF
+
+
+
+
 c
       ierr = NF_INQ_VARID(nid, "masse", nvarid)
Index: LMDZ4/trunk/libf/dyn3dpar/exner_hyb_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/exner_hyb_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/exner_hyb_p.F	(revision 985)
@@ -51,5 +51,5 @@
       INTEGER ije,ijb,jje,jjb
 c
-c$OMP MASTER           
+c$OMP BARRIER           
       unpl2k    = 1.+ 2.* kappa
 c
@@ -57,9 +57,12 @@
       ije=ij_end
 
-
+c$OMP DO SCHEDULE(STATIC)
       DO   ij  = ijb, ije
         pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
       ENDDO
+c$OMP ENDDO
+c Synchro OPENMP ici
 
+c$OMP MASTER
       if (pole_nord) then
         DO  ij   = 1, iim
@@ -83,13 +86,15 @@
         ENDDO
       endif
-
+c$OMP END MASTER
 c
 c
 c    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
 c
+c$OMP DO SCHEDULE(STATIC)
       DO     ij      = ijb,ije
        alpha(ij,llm) = 0.
        beta (ij,llm) = 1./ unpl2k
       ENDDO
+c$OMP ENDDO NOWAIT
 c
 c     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
@@ -97,4 +102,5 @@
       DO l = llm -1 , 2 , -1
 c
+c$OMP DO SCHEDULE(STATIC)
         DO ij = ijb, ije
         dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
@@ -102,4 +108,5 @@
         beta (ij,l)  =   p(ij,l  ) / dellta   
         ENDDO
+c$OMP ENDDO NOWAIT
 c
       ENDDO
@@ -109,22 +116,31 @@
 c     .....  Calcul de pk pour la couche 1 , pres du sol  ....
 c
-
+c$OMP DO SCHEDULE(STATIC)
       DO   ij   = ijb, ije
        pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  /
      *    (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
       ENDDO
+c$OMP ENDDO NOWAIT
 c
 c    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
 c
       DO l = 2, llm
+c$OMP DO SCHEDULE(STATIC)
         DO   ij   = ijb, ije
          pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
         ENDDO
+c$OMP ENDDO NOWAIT        
       ENDDO
 c
 c
 c      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      pkf(ijb:ije,1:llm)=pk(ijb:ije,1:llm)
-c$OMP END MASTER
+      DO l = 1, llm
+c$OMP DO SCHEDULE(STATIC)
+         DO   ij   = ijb, ije
+           pkf(ij,l)=pk(ij,l)
+         ENDDO
+c$OMP ENDDO NOWAIT             
+      ENDDO
+
 c$OMP BARRIER
       
Index: LMDZ4/trunk/libf/dyn3dpar/filtreg_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/filtreg_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/filtreg_p.F	(revision 985)
@@ -1,5 +1,9 @@
+
+
       SUBROUTINE filtreg_p ( champ, ibeg, iend, nlat, nbniv, 
      .                       ifiltre, iaire, griscal ,iter)
       USE Parallel, only : OMP_CHUNK 
+      USE mod_filtre_fft
+      USE timer_filtre
       IMPLICIT NONE
 
@@ -59,8 +63,39 @@
      ,             , matricevn(iim,iim,nfilvn),matricevs(iim,iim,nfilvs)
      ,             ,  matrinvn(iim,iim,nfilun),matrinvs (iim,iim,nfilus)
-      REAL  eignq(iim), sdd1(iim),sdd2(iim)
+cym      REAL  eignq(iim), sdd1(iim),sdd2(iim)
+
+      REAL  eignq(iim)
+      REAL :: sdd1(iim),sdd2(iim)
+      
       LOGICAL    griscal
       INTEGER    hemisph, iaire
-c
+      
+      REAL :: champ_fft(iip1,nlat,nbniv)
+      REAL :: champ_in(iip1,nlat,nbniv)
+      
+      REAL,SAVE,TARGET :: sddu_loc(iim)
+      REAL,SAVE,TARGET :: sddv_loc(iim)
+      REAL,SAVE,TARGET :: unsddu_loc(iim)
+      REAL,SAVE,TARGET :: unsddv_loc(iim)
+c$OMP THREADPRIVATE(sddu_loc,sddv_loc,unsddu_loc,unsddv_loc)
+      LOGICAL,SAVE     :: first=.TRUE.
+c$OMP THREADPRIVATE(first) 
+
+      IF (first) THEN
+        sddu_loc(1:iim)=sddu(1:iim)
+        sddv_loc(1:iim)=sddv(1:iim)
+        unsddu_loc(1:iim)=unsddu(1:iim)
+        unsddv_loc(1:iim)=unsddv(1:iim)
+        CALL Init_timer
+        first=.FALSE.
+c	PRINT *,"----> sddu_loc=",sddu_loc
+c	PRINT *,"----> sddv_loc=",sddv_loc
+c	PRINT *,"----> unsddu_loc=",unsddu_loc
+c	PRINT *,"----> unsddv_loc=",unsddv_loc
+      ENDIF
+
+c$OMP MASTER      
+      CALL start_timer
+c$OMP END MASTER
 
       IF(ifiltre.EQ.1.or.ifiltre.EQ.-1) 
@@ -97,9 +132,15 @@
 c
              IF( iaire.EQ.1 )  THEN
-                CALL SCOPY(  iim,    sddv, 1,  sdd1, 1 ) 
-                CALL SCOPY(  iim,  unsddv, 1,  sdd2, 1 )
+cym                CALL SCOPY(  iim,    sddv, 1,  sdd1, 1 ) 
+cym                CALL SCOPY(  iim,  unsddv, 1,  sdd2, 1 )
+cym               sdd1=>sddv_loc
+cym               sdd2=>unsddv_loc
+               sdd1(1:iim)=sddv_loc(1:iim)
+               sdd2(1:iim)=unsddv_loc(1:iim)
              ELSE
-                CALL SCOPY(  iim,  unsddv, 1,  sdd1, 1 )
-                CALL SCOPY(  iim,    sddv, 1,  sdd2, 1 )
+cym                CALL SCOPY(  iim,  unsddv, 1,  sdd1, 1 )
+cym                CALL SCOPY(  iim,    sddv, 1,  sdd2, 1 )
+               sdd1(1:iim)=unsddv_loc(1:iim)
+               sdd2(1:iim)=sddv_loc(1:iim)
              END IF
 c
@@ -116,9 +157,18 @@
 c
              IF( iaire.EQ.1 )  THEN
-                CALL SCOPY(  iim,    sddu, 1,  sdd1, 1 ) 
-                CALL SCOPY(  iim,  unsddu, 1,  sdd2, 1 )
+cym                CALL SCOPY(  iim,    sddu, 1,  sdd1, 1 ) 
+cym                CALL SCOPY(  iim,  unsddu, 1,  sdd2, 1 )
+cym                sdd1=>sddu_loc
+cym                sdd2=>unsddu_loc
+                sdd1(1:iim)=sddu_loc(1:iim)
+                sdd2(1:iim)=unsddu_loc(1:iim)
+
              ELSE
-                CALL SCOPY(  iim,  unsddu, 1,  sdd1, 1 )
-                CALL SCOPY(  iim,    sddu, 1,  sdd2, 1 )
+cym                CALL SCOPY(  iim,  unsddu, 1,  sdd1, 1 )
+cym                CALL SCOPY(  iim,    sddu, 1,  sdd2, 1 )
+cym               sdd1=>unsddu_loc
+cym               sdd2=>sddu_loc
+	       sdd1(1:iim)=unsddu_loc(1:iim)
+               sdd2(1:iim)=sddu_loc(1:iim)
              END IF
 c
@@ -129,4 +179,12 @@
           END IF
       END IF
+
+c      PRINT *,"APPEL a filtreg --> sdd1=",sdd1
+c      PRINT *,"APPEL a filtreg --> sdd2=",sdd2
+c      PRINT *,"----> sddu_loc=",sddu_loc
+c	PRINT *,"----> sddv_loc=",sddv_loc
+c	PRINT *,"----> unsddu_loc=",unsddu_loc
+c	PRINT *,"----> unsddv_loc=",unsddv_loc
+ 
 c
 c
@@ -143,156 +201,161 @@
       END IF
 
+
+cccccccccccccccccccccccccccccccccccccccccccc
+c Utilisation du filtre classique
+cccccccccccccccccccccccccccccccccccccccccccc
+
+      IF (.NOT. use_filtre_fft) THEN
+      
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)    
       DO 50  l = 1, nbniv
-      DO 30  j = jdfil,jffil
+        DO 30  j = jdfil,jffil
  
  
-      DO  5  i = 1, iim
-      champ(i,j,l) = champ(i,j,l) * sdd1(i)
-   5  CONTINUE
-c
-
-      IF( hemisph. EQ. 1 )      THEN
-
-        IF( ifiltre. EQ. -2 )   THEN
-#ifdef CRAY
-         CALL MXVA( matrinvn(1,1,j), 1, iim, champ(1,j,l), 1, eignq  , 
-     *                             1, iim, iim                         )
-#else
-#ifdef BLAS
-      CALL SGEMV("N", iim,iim, 1.0, matrinvn(1,1,j),iim,
-     .           champ(1,j,l), 1, 0.0, eignq, 1)
-#else
-      DO k = 1, iim
-         eignq(k) = 0.0
-      ENDDO
-      DO k = 1, iim
-      DO i = 1, iim
-         eignq(k) = eignq(k) + matrinvn(k,i,j)*champ(i,j,l)
-      ENDDO
-      ENDDO
-#endif
-#endif
-        ELSE IF ( griscal )     THEN
-#ifdef CRAY
-         CALL MXVA( matriceun(1,1,j), 1, iim, champ(1,j,l), 1, eignq ,
-     *                             1, iim, iim                         )
-#else
-#ifdef BLAS
-      CALL SGEMV("N", iim,iim, 1.0, matriceun(1,1,j),iim,
-     .           champ(1,j,l), 1, 0.0, eignq, 1)
-#else
-      DO k = 1, iim
-         eignq(k) = 0.0
-      ENDDO
-      DO i = 1, iim
-      DO k = 1, iim
-         eignq(k) = eignq(k) + matriceun(k,i,j)*champ(i,j,l)
-      ENDDO
-      ENDDO
-#endif
-#endif
-        ELSE 
-#ifdef CRAY
-         CALL MXVA( matricevn(1,1,j), 1, iim, champ(1,j,l), 1, eignq , 
-     *                             1, iim, iim                         )
-#else
-#ifdef BLAS
-      CALL SGEMV("N", iim,iim, 1.0, matricevn(1,1,j),iim,
-     .           champ(1,j,l), 1, 0.0, eignq, 1)
-#else
-      DO k = 1, iim
-         eignq(k) = 0.0
-      ENDDO
-      DO i = 1, iim
-      DO k = 1, iim
-         eignq(k) = eignq(k) + matricevn(k,i,j)*champ(i,j,l)
-      ENDDO
-      ENDDO
-#endif
-#endif
-        ENDIF
-
-      ELSE
-
-        IF( ifiltre. EQ. -2 )   THEN
-#ifdef CRAY
-         CALL MXVA( matrinvs(1,1,j-jfiltsu+1),  1, iim, champ(1,j,l),1 ,  
-     *                          eignq,  1, iim, iim                    )
-#else
-#ifdef BLAS
-      CALL SGEMV("N", iim,iim, 1.0, matrinvs(1,1,j-jfiltsu+1),iim,
-     .           champ(1,j,l), 1, 0.0, eignq, 1)
-#else
-      DO k = 1, iim
-         eignq(k) = 0.0
-      ENDDO
-      DO i = 1, iim
-      DO k = 1, iim
-         eignq(k) = eignq(k) + matrinvs(k,i,j-jfiltsu+1)*champ(i,j,l)
-      ENDDO
-      ENDDO
-#endif
-#endif
-        ELSE IF ( griscal )     THEN
-#ifdef CRAY
-         CALL MXVA( matriceus(1,1,j-jfiltsu+1), 1, iim, champ(1,j,l),1 , 
-     *                          eignq,  1, iim, iim                    )
-#else
-#ifdef BLAS
-      CALL SGEMV("N", iim,iim, 1.0, matriceus(1,1,j-jfiltsu+1),iim,
-     .           champ(1,j,l), 1, 0.0, eignq, 1)
-#else
-      DO k = 1, iim
-         eignq(k) = 0.0
-      ENDDO
-      DO i = 1, iim
-      DO k = 1, iim
-         eignq(k) = eignq(k) + matriceus(k,i,j-jfiltsu+1)*champ(i,j,l)
-      ENDDO
-      ENDDO
-#endif
-#endif
-        ELSE 
-#ifdef CRAY
-         CALL MXVA( matricevs(1,1,j-jfiltsv+1), 1, iim, champ(1,j,l),1 , 
-     *                          eignq,  1, iim, iim                    )
-#else
-#ifdef BLAS
-      CALL SGEMV("N", iim,iim, 1.0, matricevs(1,1,j-jfiltsv+1),iim,
-     .           champ(1,j,l), 1, 0.0, eignq, 1)
-#else
-      DO k = 1, iim
-         eignq(k) = 0.0
-      ENDDO
-      DO i = 1, iim
-      DO k = 1, iim
-         eignq(k) = eignq(k) + matricevs(k,i,j-jfiltsv+1)*champ(i,j,l)
-      ENDDO
-      ENDDO
-#endif
-#endif
-        ENDIF
-
-      ENDIF
-c
-      IF( ifiltre.EQ. 2 )  THEN
-        DO 15 i = 1, iim
-        champ( i,j,l ) = ( champ(i,j,l) + eignq(i) ) * sdd2(i)
-  15    CONTINUE
-      ELSE
-        DO 16 i=1,iim
-        champ( i,j,l ) = ( champ(i,j,l) - eignq(i) ) * sdd2(i)
-16      CONTINUE
-      ENDIF
-c
-      champ( iip1,j,l ) = champ( 1,j,l )
-c
-  30  CONTINUE
+          DO  5  i = 1, iim
+            champ(i,j,l) = champ(i,j,l) * sdd1(i)
+   5      CONTINUE
+c
+
+          IF( hemisph. EQ. 1 )      THEN
+
+            IF( ifiltre. EQ. -2 )   THEN
+
+
+              CALL SGEMV("N", iim,iim, 1.0, matrinvn(1,1,j),iim,
+     .                     champ(1,j,l), 1, 0.0, eignq, 1)
+
+
+            ELSE IF ( griscal )     THEN
+
+              CALL SGEMV("N", iim,iim, 1.0, matriceun(1,1,j),iim,
+     .                    champ(1,j,l), 1, 0.0, eignq, 1)
+
+            ELSE 
+
+              CALL SGEMV("N", iim,iim, 1.0, matricevn(1,1,j),iim,
+     .                   champ(1,j,l), 1, 0.0, eignq, 1)
+            ENDIF
+
+          ELSE
+
+            IF( ifiltre. EQ. -2 )   THEN
+      
+              CALL SGEMV("N",iim,iim,1.0, matrinvs(1,1,j-jfiltsu+1),iim,
+     .                   champ(1,j,l), 1, 0.0, eignq, 1)
+      
+            ELSE IF ( griscal )     THEN
+      
+              CALL SGEMV("N",iim,iim,1.0,matriceus(1,1,j-jfiltsu+1),iim,
+     .                   champ(1,j,l), 1, 0.0, eignq, 1)
+            ELSE 
+          
+	      CALL SGEMV("N",iim,iim,1.0,matricevs(1,1,j-jfiltsv+1),iim,
+     .                    champ(1,j,l), 1, 0.0, eignq, 1)
+            ENDIF
+
+          ENDIF
+
+
+c
+          IF( ifiltre.EQ. 2 )  THEN
+         
+	    DO 15 i = 1, iim
+              champ( i,j,l ) = ( champ(i,j,l) + eignq(i) ) * sdd2(i)
+  15        CONTINUE
+         
+	  ELSE
+        
+	    DO 16 i=1,iim
+               champ( i,j,l ) = ( champ(i,j,l) - eignq(i) ) * sdd2(i)
+16          CONTINUE
+          
+	  ENDIF
+c
+          champ( iip1,j,l ) = champ( 1,j,l )
+c
+  30    CONTINUE
 c
   50  CONTINUE
 c$OMP END DO NOWAIT
-c    
+
+ccccccccccccccccccccccccccccccccccccccccccccc
+c Utilisation du filtre FFT
+ccccccccccccccccccccccccccccccccccccccccccccc
+        
+       ELSE
+       
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+	  DO l=1,nbniv
+	    DO j=jdfil,jffil
+	      DO  i = 1, iim
+                champ( i,j,l)= champ(i,j,l)*sdd1(i)
+		champ_fft( i,j,l) = champ(i,j,l)
+              ENDDO
+            ENDDO
+	  ENDDO
+c$OMP END DO NOWAIT
+
+      IF (jdfil<=jffil) THEN
+        IF( ifiltre. EQ. -2 )   THEN
+          CALL Filtre_inv_fft(champ_fft,nlat,jdfil,jffil,nbniv) 
+        ELSE IF ( griscal )     THEN
+	  CALL Filtre_u_fft(champ_fft,nlat,jdfil,jffil,nbniv)
+	ELSE
+	  CALL Filtre_v_fft(champ_fft,nlat,jdfil,jffil,nbniv)
+	ENDIF
+      ENDIF
+
+
+        IF( ifiltre.EQ. 2 )  THEN
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)          
+	  DO l=1,nbniv
+	    DO j=jdfil,jffil
+	      DO  i = 1, iim
+                champ( i,j,l)=(champ(i,j,l)+champ_fft(i,j,l))
+     .                             *sdd2(i)
+              ENDDO
+            ENDDO
+	  ENDDO
+c$OMP END DO NOWAIT	  
+	ELSE
+        
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)  
+	  DO l=1,nbniv
+	    DO j=jdfil,jffil
+	      DO  i = 1, iim
+                champ(i,j,l)=(champ(i,j,l)-champ_fft(i,j,l))
+     .                            *sdd2(i)
+              ENDDO
+            ENDDO
+	  ENDDO
+c$OMP END DO NOWAIT          
+        ENDIF
+c
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
+	DO l=1,nbniv
+	  DO j=jdfil,jffil
+!            champ_FFT( iip1,j,l ) = champ_FFT( 1,j,l )
+	    champ( iip1,j,l ) = champ( 1,j,l )
+          ENDDO
+	ENDDO
+c$OMP END DO NOWAIT          	
+      ENDIF 
+c Fin de la zone de filtrage
+
+	
  100  CONTINUE
+
+!      DO j=1,nlat
+!     
+!          PRINT *,"check FFT ----> Delta(",j,")=",
+!     &            sum(champ(:,j,:)-champ_fft(:,j,:))/sum(champ(:,j,:)),
+!     &            sum(champ(:,j,:)-champ_in(:,j,:))/sum(champ(:,j,:)) 
+!      ENDDO
+      
+!          PRINT *,"check FFT ----> Delta(",j,")=",
+!     &            sum(champ-champ_fft)/sum(champ)
+!      
+      
 c
 1111  FORMAT(//20x,'ERREUR dans le dimensionnement du tableau  CHAMP a 
@@ -300,4 +363,7 @@
 2222  FORMAT(//20x,'ERREUR dans le dimensionnement du tableau CHAMP a fi
      *ltrer, sur la grille de V ou de Z'/)
+c$OMP MASTER      
+      CALL stop_timer
+c$OMP END MASTER
       RETURN
       END
Index: LMDZ4/trunk/libf/dyn3dpar/gcm.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/gcm.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/gcm.F	(revision 985)
@@ -18,6 +18,4 @@
       USE mod_hallo
       USE Bands
-      USE Write_Field
-      USE Write_Field_phy
       IMPLICIT NONE
 
@@ -225,5 +223,8 @@
       if (mpi_rank==0) call WriteBands
       call SetDistrib(jj_Nb_Caldyn)
+
+c$OMP PARALLEL
       call Init_Mod_hallo
+c$OMP END PARALLEL
 
 c$OMP PARALLEL
Index: LMDZ4/trunk/libf/dyn3dpar/gr_u_scal_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/gr_u_scal_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/gr_u_scal_p.F	(revision 985)
@@ -50,5 +50,5 @@
       ijb=ij_begin
       ije=ij_end
-      if (pole_nord) ijb=ij_begin+1
+      if (pole_nord) ijb=ij_begin+iip1
       
       DO l=1,nx
Index: LMDZ4/trunk/libf/dyn3dpar/gr_v_scal_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/gr_v_scal_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/gr_v_scal_p.F	(revision 985)
@@ -49,6 +49,6 @@
       ijb=ij_begin
       ije=ij_end
-      if (pole_nord) ijb=ij_begin+1
-      if (pole_sud)  ije=ij_end-1
+      if (pole_nord) ijb=ij_begin+iip1
+      if (pole_sud)  ije=ij_end-iip1
       
       DO l=1,nx
Index: LMDZ4/trunk/libf/dyn3dpar/gradiv2_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/gradiv2_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/gradiv2_p.F	(revision 985)
@@ -16,4 +16,5 @@
       USE times
       USE Write_field_p
+      USE mod_hallo
       IMPLICIT NONE
 c
@@ -33,7 +34,9 @@
 c
       REAL,SAVE :: div(ip1jmp1,llm)
+      REAL      :: tmp_div2(ip1jmp1,llm)
       REAL signe, nugrads
       INTEGER l,ij,iter,ld
       INTEGER :: ijb,ije,jjb,jje
+      Type(Request)  :: request_dissip
       
 c    ........................................................
@@ -63,9 +66,8 @@
 
 c$OMP BARRIER
-c$OMP MASTER      
-      call suspend_timer(timer_dissip)
-      call exchange_Hallo(gdy,ip1jm,llm,1,0)
-      call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(gdy,ip1jm,llm,1,0,0,1,Request_dissip)
+       call SendRequest(Request_dissip)
+c$OMP BARRIER
+       call WaitRequest(Request_dissip)
 c$OMP BARRIER
 c
@@ -81,9 +83,8 @@
       IF( ld.GT.1 )   THEN
 c$OMP BARRIER
-c$OMP MASTER        
-	call suspend_timer(timer_dissip)
-        call exchange_Hallo(div,ip1jmp1,llm,1,1)
-        call resume_timer(timer_dissip)
-c$OMP END MASTER        
+       call Register_Hallo(div,ip1jmp1,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
+c$OMP BARRIER
+       call WaitRequest(Request_dissip)
 c$OMP BARRIER
 	CALL laplacien_p ( klevel, div,  div     )
@@ -94,10 +95,11 @@
         DO iter = 1, ld -2
 c$OMP BARRIER
-c$OMP MASTER
-	 call suspend_timer(timer_dissip)
-         call exchange_Hallo(div,ip1jmp1,llm,1,1)
-	 call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(div,ip1jmp1,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
 c$OMP BARRIER
+       call WaitRequest(Request_dissip)
+
+c$OMP BARRIER
+
          CALL laplacien_gam ( klevel,cuvscvgam1,cvuscugam1,unsair_gam1,
      *                       unsapolnga1, unsapolsga1,  div, div       )
@@ -112,11 +114,12 @@
 c       call exchange_Hallo(div,ip1jmp1,llm,0,1)
 c$OMP BARRIER
-c$OMP MASTER        
-	call suspend_timer(timer_dissip)
-	call exchange_Hallo(div,ip1jmp1,llm,1,1)
-        call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(div,ip1jmp1,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
 c$OMP BARRIER
-c       call write_field3d_p('div4',reshape(div,(/iip1,jjp1,llm/)))
+       call WaitRequest(Request_dissip)
+
+c$OMP BARRIER
+
+
        CALL  grad_p  ( klevel,  div,   gdx,  gdy             )
 
Index: LMDZ4/trunk/libf/dyn3dpar/guide_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/guide_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/guide_p.F	(revision 985)
@@ -128,15 +128,10 @@
       jjn=jj_nb
       
-      print*,'OK0'
       CALL pression_p( ip1jmp1, ap, bp, ps, p )
       call massdair_p(p,masse)
-      print*,'OK1'
       CALL exner_hyb_p(ip1jmp1,ps,p,alpha,beta,pks,pk,pkf)
-      print*,'OK2'
       tnat(ijb:ije,:)=pk(ijb:ije,:)*teta(ijb:ije,:)/cpp
-      print*,'OK3'
       unskap   = 1./ kappa
       pres(ijb:ije,:)=preff*(pk(ijb:ije,:)/cpp)**unskap
-      print*,'OK4'
       call q_sat(iip1*jjn*llm,tnat(ijb:ije,:),pres(ijb:ije,:),
      .            qsat(ijb:ije,:))
@@ -151,5 +146,4 @@
 c-----------------------------------------------------------------------
 
-      print*,'ONLINE=',online
       if(online.eq.-1) then
           return
Index: LMDZ4/trunk/libf/dyn3dpar/integrd_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/integrd_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/integrd_p.F	(revision 985)
@@ -58,5 +58,5 @@
       REAL tpn,tps,tppn(iim),tpps(iim)
       REAL qpn,qps,qppn(iim),qpps(iim)
-      REAL deltap( ip1jmp1,llm )
+      REAL,SAVE :: deltap( ip1jmp1,llm )
 
       INTEGER  l,ij,iq
@@ -66,6 +66,8 @@
       INTEGER ijb,ije,jjb,jje
       REAL,SAVE :: ps(ip1jmp1)
+      LOGICAL :: checksum
+      INTEGER :: stop_it
 c-----------------------------------------------------------------------
-     
+c$OMP BARRIER     
       if (pole_nord) THEN
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
@@ -102,17 +104,33 @@
 c$OMP END DO NOWAIT 
 
-c$OMP MASTER      
+c$OMP DO SCHEDULE(STATIC)
       DO 2 ij = ijb,ije
        pscr (ij)    = ps0(ij)
        ps (ij)      = psm1(ij) + dt * dp(ij)
    2  CONTINUE
-c
+c$OMP END DO  
+c$OMP BARRIER
+c --> ici synchro OPENMP pour ps
+       
+      checksum=.TRUE.
+      stop_it=0
+
+c$OMP DO SCHEDULE(STATIC)
       DO ij = ijb,ije
-        IF( ps(ij).LT.0. ) THEN
-         PRINT*,' Au point ij = ',ij, ' , pression sol neg. ', ps(ij)
+         IF( ps(ij).LT.0. ) THEN
+           IF (checksum) stop_it=ij
+           checksum=.FALSE.
+         ENDIF
+       ENDDO
+c$OMP END DO NOWAIT 
+       
+        IF( .NOT. checksum ) THEN
+         PRINT*,' Au point ij = ',stop_it, ' , pression sol neg. '
+     &         , ps(stop_it)
          STOP' dans integrd'
         ENDIF
-      ENDDO
-c
+
+c
+C$OMP MASTER
       if (pole_nord) THEN
       
@@ -248,5 +266,6 @@
       ije=ij_end
       
-c$OMP MASTER
+c$OMP BARRIER
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
          DO l = 1, llm
           DO ij = ijb, ije
@@ -254,4 +273,6 @@
           ENDDO
          ENDDO
+c$OMP END DO NOWAIT
+c$OMP BARRIER
 
          CALL qminimum_p( q, nq, deltap )
@@ -259,8 +280,10 @@
 c    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
 c
-
+c$OMP BARRIER
       IF (pole_nord) THEN 
       
         DO iq = 1, nq
+        
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l = 1, llm
   
@@ -275,4 +298,6 @@
   
           ENDDO
+c$OMP END DO NOWAIT
+
         ENDDO
       
@@ -282,4 +307,6 @@
       
         DO iq = 1, nq
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l = 1, llm
   
@@ -294,11 +321,10 @@
   
           ENDDO
-        ENDDO
-      
-      ENDIF
-      
-c$OMP END MASTER
-c$OMP BARRIER
-
+c$OMP END DO NOWAIT
+
+        ENDDO
+      
+      ENDIF
+      
 c         CALL  SCOPY( ijp1llm , finvmasse, 1, finvmaold, 1 )
 
@@ -314,7 +340,10 @@
 15    continue
 
-c$OMP MASTER
-        ps0(ijb:ije)=ps(ijb:ije)
-c$OMP END MASTER
+c$OMP DO SCHEDULE(STATIC)
+      DO ij=ijb,ije  
+        ps0(ij)=ps(ij)
+      ENDDO
+c$OMP END DO NOWAIT 
+
 c    .................................................................
 
@@ -323,7 +352,9 @@
 c       CALL SCOPY (    ip1jmp1 ,  pscr   , 1,   psm1  , 1 )
 c       CALL SCOPY ( ip1jmp1*llm, massescr, 1,  massem1, 1 )
-c$OMP MASTER
-        psm1(ijb:ije)=pscr(ijb:ije)
-c$OMP END MASTER
+c$OMP DO SCHEDULE(STATIC)
+      DO ij=ijb,ije  
+        psm1(ij)=pscr(ij)
+      ENDDO
+c$OMP END DO NOWAIT 
 
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
@@ -333,5 +364,5 @@
 c$OMP END DO NOWAIT	  
       END IF
-
+c$OMP BARRIER
       RETURN
       END
Index: LMDZ4/trunk/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/leapfrog_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/leapfrog_p.F	(revision 985)
@@ -6,5 +6,6 @@
 #define IO_DEBUG
 
-!#undef CPP_IOIPSL
+#undef CPP_IOIPSL
+#define CPP_IOIPSL
 
       SUBROUTINE leapfrog_p(ucov,vcov,teta,ps,masse,phis,nq,q,clesphy0,
@@ -19,4 +20,5 @@
        USE Write_Field_p
        USE vampir
+       USE timer_filtre, ONLY : print_filtre_timer
 
       IMPLICIT NONE
@@ -71,5 +73,5 @@
 
 #include "academic.h"
-#include "clesphys.h"
+!#include "clesphys.h"
 #include "advtrac.h"
       
@@ -217,7 +219,4 @@
          ENDIF
 
-c$OMP MASTER
-      OMP_CHUNK=5
-c$OMP END MASTER  
 c-----------------------------------------------------------------------
 c   On initialise la pression et la fonction d'Exner :
@@ -237,5 +236,9 @@
 
 c$OMP MASTER
+
+!$OMP CRITICAL (MPI)
       call MPI_BARRIER(COMM_LMDZ,ierr)
+!$OMP END CRITICAL (MPI)
+
 c$OMP END MASTER
 c$OMP BARRIER
@@ -297,5 +300,5 @@
 
          ENDDO
-c$OMP ENDDO          
+c$OMP ENDDO  
 
 
@@ -321,5 +324,5 @@
 c$OMP MASTER
       ItCount=ItCount+1
-      if (MOD(ItCount,1)==1) then
+      if (MOD(ItCount,1)==0) then
         debug=.true.
       else
@@ -479,4 +482,6 @@
 c$OMP MASTER
        call VTb(VThallo)
+c$OMP END MASTER
+
        call Register_Hallo(ucov,ip1jmp1,llm,1,1,1,1,TestRequest)
        call Register_Hallo(vcov,ip1jm,llm,1,1,1,1,TestRequest)
@@ -494,9 +499,15 @@
 
        call SendRequest(TestRequest)
+c$OMP BARRIER
        call WaitRequest(TestRequest)
+
+c$OMP MASTER
        call VTe(VThallo)
-
+c$OMP END MASTER
+c$OMP BARRIER
       
       if (debug) then        
+!$OMP BARRIER
+!$OMP MASTER
         call WriteField_p('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
         call WriteField_p('vcov',reshape(vcov,(/iip1,jjm,llm/)))
@@ -511,13 +522,14 @@
           call WriteField_p('q'//trim(int2str(j)),
      .                reshape(q(:,:,j),(/iip1,jmp1,llm/)))
-        enddo        
+        enddo
+!$OMP END MASTER        
+c$OMP BARRIER
       endif
-c$OMP END MASTER 
-c$OMP BARRIER
+
       
       True_itau=True_itau+1
 
 c$OMP MASTER
-c     print*,"Iteration No",True_itau
+      print*,"Iteration No",True_itau
 
 
@@ -529,23 +541,19 @@
       call VTb(VTcaldyn)
 c$OMP END MASTER
-c$OMP BARRIER
       var_time=time+iday-day_ini
-cc$OMP PARALLEL DEFAULT(SHARED)
-cc$OMP+         PRIVATE(rdaym_ini,rdayvrai,ijb,ije,
-cc$OMP+                 tppn,tpn,tpps,tps)
-
-cc$OMP+         SHARED(itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
-cc$OMP+                phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, 
-cc$OMP+                time, iday,day_ini,forward,leapf, iapptrac,
-cc$OMP+                q,dq,p,VTcaldyn,offline,dtvr,itau)      
-
+
+c$OMP BARRIER
+!      CALL FTRACE_REGION_BEGIN("caldyn")
       CALL caldyn_p 
      $  ( itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
      $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time+iday-day_ini )
 
-ccc$OMP END PARALLEL      
+!      CALL FTRACE_REGION_END("caldyn")
 c$OMP MASTER
       call VTe(VTcaldyn)
 c$OMP END MASTER      
+
+cc$OMP BARRIER
+cc$OMP MASTER
 c      call WriteField_p('du',reshape(du,(/iip1,jmp1,llm/)))
 c      call WriteField_p('dv',reshape(dv,(/iip1,jjm,llm/)))
@@ -555,4 +563,8 @@
 c      call WriteField_p('pbaru',reshape(pbaru,(/iip1,jmp1,llm/)))
 c      call WriteField_p('pbarv',reshape(pbarv,(/iip1,jjm,llm/)))
+c      call WriteField_p('p',reshape(p,(/iip1,jmp1,llmp1/)))
+c      call WriteField_p('masse',reshape(masse,(/iip1,jmp1,llm/)))
+c      call WriteField_p('pk',reshape(pk,(/iip1,jmp1,llm/)))
+cc$OMP END MASTER
 
 c-----------------------------------------------------------------------
@@ -566,16 +578,10 @@
      *        p, masse, dq,  teta,
      .        flxw,pk, iapptrac)
-         
-c      do j=1,nqmx
-c        call WriteField_p('q'//trim(int2str(j)),
-c     .                reshape(q(:,:,j),(/iip1,jmp1,llm/)))
-c        call WriteField_p('dq'//trim(int2str(j)),
-c     .                reshape(dq(:,:,j),(/iip1,jmp1,llm/)))
-c      enddo
+
        IF (offline) THEN
 Cmaf stokage du flux de masse pour traceurs OFF-LINE
-#undef CPP_IOIPSL
+
 #ifdef CPP_IOIPSL
-           CALL fluxstokenc(pbaru,pbarv,masse,teta,phi,phis,
+           CALL fluxstokenc_p(pbaru,pbarv,masse,teta,phi,phis,
      .   dtvr, itau)
 #endif
@@ -603,9 +609,13 @@
 c      call WriteField_p('ps',reshape(ps,(/iip1,jmp1/)))
 cc$OMP PARALLEL DEFAULT(SHARED)
+c$OMP BARRIER
+!       CALL FTRACE_REGION_BEGIN("integrd")
        CALL integrd_p ( 2,vcovm1,ucovm1,tetam1,psm1,massem1 ,
      $         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis ,
      $              finvmaold                                    )
 
-
+!       CALL FTRACE_REGION_END("integrd")
+c$OMP BARRIER
+cc$OMP MASTER
 c      call WriteField_p('ucovm1',reshape(ucovm1,(/iip1,jmp1,llm/)))
 c      call WriteField_p('vcovm1',reshape(vcovm1,(/iip1,jjm,llm/)))
@@ -616,6 +626,15 @@
 c      call WriteField_p('teta',reshape(teta,(/iip1,jmp1,llm/)))
 c      call WriteField_p('dteta',reshape(dteta,(/iip1,jmp1,llm/)))
-
+c
 c      call WriteField_p('ps',reshape(ps,(/iip1,jmp1/)))
+c      do j=1,nqmx
+c        call WriteField_p('q'//trim(int2str(j)),
+c     .                reshape(q(:,:,j),(/iip1,jmp1,llm/)))
+c        call WriteField_p('dq'//trim(int2str(j)),
+c     .                reshape(dq(:,:,j),(/iip1,jmp1,llm/)))
+c      enddo
+cc$OMP END MASTER
+
+
 c$OMP MASTER 
        call VTe(VTintegre)
@@ -647,11 +666,13 @@
 c$OMP MASTER
          call suspend_timer(timer_caldyn)
-c        print*,'Entree dans la physique : Iteration No ',true_itau
-c$OMP END MASTER
-
-c$OMP BARRIER
+         print*,'Entree dans la physique : Iteration No ',true_itau
+c$OMP END MASTER
+
          CALL pression_p (  ip1jmp1, ap, bp, ps,  p      )
 
+c$OMP BARRIER
+
          CALL exner_hyb_p(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
+c$OMP BARRIER
            rdaym_ini  = itau * dtvr / daysec
            rdayvrai   = rdaym_ini  + day_ini
@@ -678,4 +699,6 @@
 c$OMP MASTER
         call VTb(VThallo)
+c$OMP END MASTER
+
         call SetTag(Request_physic,800)
         
@@ -716,6 +739,10 @@
         
         call SendRequest(Request_Physic)
+c$OMP BARRIER
         call WaitRequest(Request_Physic)       
-        
+
+c$OMP BARRIER
+c$OMP MASTER
+        call SetDistrib(jj_nb_Physic)
         call VTe(VThallo)
         
@@ -732,5 +759,5 @@
 cc$OMP END MASTER
 cc$OMP BARRIER
-        
+!        CALL FTRACE_REGION_BEGIN("calfis")
         CALL calfis_p( nq, lafin ,rdayvrai,time  ,
      $               ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
@@ -738,4 +765,5 @@
      $               flxw,
      $               clesphy0, dufi,dvfi,dtetafi,dqfi,dpfi  )
+!        CALL FTRACE_REGION_END("calfis")
         ijb=ij_begin
         ije=ij_end  
@@ -760,4 +788,6 @@
 
         call VTb(VThallo)
+c$OMP END MASTER
+c$OMP BARRIER
  
         call Register_Hallo(dufi,ip1jmp1,llm,
@@ -779,6 +809,9 @@
         
         call SendRequest(Request_Physic)
+c$OMP BARRIER
         call WaitRequest(Request_Physic)
              
+c$OMP BARRIER
+c$OMP MASTER
         call VTe(VThallo)
  
@@ -829,4 +862,5 @@
 
         call VTb(VThallo)
+c$OMP END MASTER
 
         call SetTag(Request_physic,800)
@@ -863,9 +897,11 @@
 
         call SendRequest(Request_Physic)
+c$OMP BARRIER
         call WaitRequest(Request_Physic)     
 
-        call VTe(VThallo)
-
-        call SetDistrib(jj_Nb_caldyn)
+c$OMP BARRIER
+c$OMP MASTER
+       call VTe(VThallo)
+       call SetDistrib(jj_Nb_caldyn)
 c$OMP END MASTER
 c$OMP BARRIER
@@ -916,6 +952,8 @@
        ENDIF
 
-c$OMP BARRIER
         CALL pression_p ( ip1jmp1, ap, bp, ps, p                  )
+c$OMP BARRIER
+
+
         CALL exner_hyb_p( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
 c$OMP BARRIER
@@ -941,5 +979,5 @@
 
 c$OMP BARRIER
-c$OMP MASTER
+
         call Register_SwapFieldHallo(ucov,ucov,ip1jmp1,llm,
      *                          jj_Nb_dissip,1,1,Request_dissip)
@@ -958,11 +996,12 @@
 
         call SendRequest(Request_dissip)       
+c$OMP BARRIER
         call WaitRequest(Request_dissip)       
+
+c$OMP BARRIER
+c$OMP MASTER
         call SetDistrib(jj_Nb_dissip)
-        
         call VTe(VThallo)
-
         call VTb(VTdissipation)
-        
         call start_timer(timer_dissip)
 c$OMP END MASTER
@@ -974,5 +1013,7 @@
 c   dissipation
 
+!        CALL FTRACE_REGION_BEGIN("dissip")
         CALL dissip_p(vcov,ucov,teta,p,dvdis,dudis,dtetadis)
+!        CALL FTRACE_REGION_END("dissip")
          
         ijb=ij_begin
@@ -1001,9 +1042,11 @@
             call suspend_timer(timer_dissip)
             call VTb(VThallo)
-
+c$OMP END MASTER
             call Register_Hallo(ucov,ip1jmp1,llm,1,1,1,1,Request_Dissip)
             call Register_Hallo(vcov,ip1jm,llm,1,1,1,1,Request_Dissip)
             call SendRequest(Request_Dissip)
+c$OMP BARRIER
             call WaitRequest(Request_Dissip)
+c$OMP MASTER
             call VTe(VThallo)
             call resume_timer(timer_dissip)
@@ -1104,5 +1147,5 @@
         
         call VTb(VThallo)
-
+c$OMP END MASTER
         call Register_SwapField(ucov,ucov,ip1jmp1,llm,
      *                          jj_Nb_caldyn,Request_dissip)
@@ -1121,5 +1164,9 @@
 
         call SendRequest(Request_dissip)       
+c$OMP BARRIER
         call WaitRequest(Request_dissip)       
+
+c$OMP BARRIER
+c$OMP MASTER
         call SetDistrib(jj_Nb_caldyn)
         call VTe(VThallo)
@@ -1127,4 +1174,5 @@
 c        print *,'fin dissipation'
 c$OMP END MASTER
+c$OMP BARRIER
       END IF
 
@@ -1193,7 +1241,8 @@
       print *, 'Temps total ecoule sur la parallelisation :',DiffTime()
       print *, 'Temps CPU ecoule sur la parallelisation :',DiffCpuTime()
-
+      CALL print_filtre_timer
         call finalize_parallel
 c$OMP END MASTER
+c$OMP BARRIER
         RETURN
       ENDIF
@@ -1222,4 +1271,5 @@
               abort_message = 'Simulation finished'
               call abort_gcm(modname,abort_message,0)
+              RETURN
             ENDIF
 c-----------------------------------------------------------------------
@@ -1229,5 +1279,4 @@
             IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
 c$OMP BARRIER
-c$OMP MASTER
                IF(itau.EQ.itaufin) THEN
                   iav=1
@@ -1237,13 +1286,13 @@
 #ifdef CPP_IOIPSL
              call Register_Hallo(vcov,ip1jm,llm,1,0,0,1,TestRequest)
-              call SendRequest(TestRequest)
+             call SendRequest(TestRequest)
+c$OMP BARRIER
               call WaitRequest(TestRequest)
-
+c$OMP MASTER
               CALL writedynav_p(histaveid, nqmx, itau,vcov ,
      ,                          ucov,teta,pk,phi,q,masse,ps,phis)
-c               call bilan_dyn_p(2,dtvr*iperiod,dtvr*day_step*periodav,
-c     ,           ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
+c$OMP END MASTER
+
 #endif
-c$OMP END MASTER
             ENDIF
 
@@ -1376,4 +1425,5 @@
                  abort_message = 'Simulation finished'
                  call abort_gcm(modname,abort_message,0)
+                 RETURN
                ENDIF
                GO TO 2
@@ -1389,14 +1439,15 @@
 #ifdef CPP_IOIPSL
 c$OMP BARRIER
-c$OMP MASTER
 
               call Register_Hallo(vcov,ip1jm,llm,1,0,0,1,TestRequest)
               call SendRequest(TestRequest)
+c$OMP BARRIER
               call WaitRequest(TestRequest)
 
+c$OMP MASTER
               CALL writedynav_p(histaveid, nqmx, itau,vcov ,
      ,                          ucov,teta,pk,phi,q,masse,ps,phis)
-c               call bilan_dyn_p (2,dtvr*iperiod,dtvr*day_step*periodav,
-c     ,           ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
+               call bilan_dyn_p (2,dtvr*iperiod,dtvr*day_step*periodav,
+     ,           ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
 c$OMP END MASTER
 #endif
Index: LMDZ4/trunk/libf/dyn3dpar/mod_const_para.F90
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/mod_const_para.F90	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/mod_const_para.F90	(revision 985)
@@ -1,6 +1,6 @@
 MODULE mod_const_mpi
 
-  INTEGER :: COMM_LMDZ
-  INTEGER :: MPI_REAL_LMDZ
+  INTEGER,SAVE :: COMM_LMDZ
+  INTEGER,SAVE :: MPI_REAL_LMDZ
  
 
@@ -14,4 +14,6 @@
     INTEGER             :: ierr
     INTEGER             :: comp_id
+    INTEGER             :: thread_required
+    INTEGER             :: thread_provided
     CHARACTER(len = 6)  :: ocean
 
@@ -19,14 +21,24 @@
     ocean = 'force '
     CALL getin('OCEAN', ocean)
-!$OMP END
+!$OMP END MASTER
+!$OMP BARRIER
 
     IF (ocean=='couple') THEN
 #ifdef CPP_COUPLE
+!$OMP MASTER
        CALL prism_init_comp_proto (comp_id, 'lmdz.x', ierr)
        CALL prism_get_localcomm_proto(COMM_LMDZ,ierr)
+!$OMP END MASTER
 #endif
     ELSE
-       CALL MPI_INIT(ierr)
+!$OMP MASTER
+       thread_required=MPI_THREAD_SERIALIZED
+       CALL MPI_INIT_THREAD(thread_required,thread_provided,ierr)
+       IF (thread_provided < thread_required) THEN
+         CALL abort_gcm('The multithreaded level of MPI librairy do not provide the requiered level', &
+                        'mod_const_mpi::Init_const_mpi',1)
+       ENDIF
        COMM_LMDZ=MPI_COMM_WORLD
+!$OMP END MASTER
     END IF
 
Index: LMDZ4/trunk/libf/dyn3dpar/mod_hallo.F90
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/mod_hallo.F90	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/mod_hallo.F90	(revision 985)
@@ -2,5 +2,5 @@
 USE parallel
 implicit none
-
+  logical,save :: use_mpi_alloc
   integer, parameter :: MaxRequest=200
   integer, parameter :: MaxProc=80
@@ -9,9 +9,12 @@
   
   integer,save       :: MaxBufferSize_Used
- 
-    real,save,pointer,dimension(:) :: Buffer
-
-   integer,dimension(Listsize) :: Buffer_Pos
-   integer :: Index_Pos
+!$OMP THREADPRIVATE( MaxBufferSize_Used)
+
+   real,save,pointer,dimension(:) :: Buffer
+!$OMP THREADPRIVATE(Buffer)
+
+   integer,save,dimension(Listsize) :: Buffer_Pos
+   integer,save :: Index_Pos
+!$OMP THREADPRIVATE(Buffer_Pos,Index_pos)
    
   type Hallo
@@ -47,8 +50,11 @@
     MaxBufferSize_Used=0
 
-    CALL create_global_mpi_buffer
-    
+    IF (use_mpi_alloc) THEN
+      CALL create_global_mpi_buffer
+    ELSE 
+      CALL create_standard_mpi_buffer
+    ENDIF
+     
   end subroutine init_mod_hallo
-
 
   SUBROUTINE create_standard_mpi_buffer
@@ -59,5 +65,4 @@
   END SUBROUTINE create_standard_mpi_buffer
   
-
   SUBROUTINE create_global_mpi_buffer
   IMPLICIT NONE
@@ -68,7 +73,9 @@
     INTEGER :: i,ierr
 
-
+!  Allocation du buffer MPI
       Bs=8*MaxBufferSize
+!$OMP CRITICAL (MPI)
       CALL MPI_ALLOC_MEM(BS,MPI_INFO_NULL,Pbuffer,ierr)
+!$OMP END CRITICAL (MPI)
       DO i=1,MaxBufferSize
 	MPI_Buffer(i)=i
@@ -88,6 +95,5 @@
                                       
   END SUBROUTINE create_global_mpi_buffer
-
-
+ 
       
   subroutine allocate_buffer(Size,Index,Pos)
@@ -381,5 +387,4 @@
       integer :: i,rank,l,ij,Pos,ierr
       integer :: offset
-!      real,dimension(:),pointer :: Buffer
       real,dimension(:,:),pointer :: Field
       integer :: Nb
@@ -392,14 +397,16 @@
         do i=1,Req%NbRequest
           PtrHallo=>Req%Hallo(i)
-          SizeBuffer=SizeBuffer+PtrHallo%size*PtrHallo%NbLevel*iip1
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
+          DO l=1,PtrHallo%NbLevel
+            SizeBuffer=SizeBuffer+PtrHallo%size*iip1
+          ENDDO
+!$OMP ENDDO NOWAIT          
         enddo
       
         if (SizeBuffer>0) then
        
-!          allocate(Req%Buffer(SizeBuffer))
           call allocate_buffer(SizeBuffer,Req%Index,Req%pos)
 
           Pos=Req%Pos
-!          Buffer=>req%Buffer
           do i=1,Req%NbRequest
             PtrHallo=>Req%Hallo(i)
@@ -407,5 +414,6 @@
             Nb=iip1*PtrHallo%size-1
             Field=>PtrHallo%Field
-            
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)           
             do l=1,PtrHallo%NbLevel
 !cdir NODEP
@@ -413,17 +421,19 @@
 	        Buffer(Pos+ij)=Field(Offset+ij,l)
 	      enddo
-!              Buffer(Pos:Pos+Nb)=Field(offset:offset+Nb,l)
               
               Pos=Pos+Nb+1
             enddo
-            
+!$OMP END DO NOWAIT            
           enddo
     
-!         print *, 'process',MPI_RANK,'ISSEND: requette ',a_request%tag,'au process',rank,'de taille',SizeBuffer
-!         call MPI_ISSEND(Req%Buffer,SizeBuffer,MPI_REAL8,rank,a_request%tag,     &
-!                         COMM_LMDZ,Req%MSG_Request,ierr)
-         call MPI_ISSEND(Buffer(req%Pos),SizeBuffer,MPI_REAL8,rank,a_request%tag,     &
+!$OMP CRITICAL (MPI)
+         call MPI_ISSEND(Buffer(req%Pos),SizeBuffer,MPI_REAL8,rank,a_request%tag+1000*omp_rank,     &
                          COMM_LMDZ,Req%MSG_Request,ierr)
-
+!         PRINT *,"-------------------------------------------------------------------"
+!         PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->"
+!         PRINT *,"Requete envoye au proc :",rank,"tag :",a_request%tag+1000*omp_rank
+!         PRINT *,"Taille du message :",SizeBuffer,"requete no :",Req%MSG_Request
+!         PRINT *,"-------------------------------------------------------------------"
+!$OMP END CRITICAL (MPI)
         endif
 
@@ -438,17 +448,25 @@
 	  do i=1,Req%NbRequest
             PtrHallo=>Req%Hallo(i)
-            SizeBuffer=SizeBuffer+PtrHallo%size*PtrHallo%NbLevel*iip1
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
+            DO l=1,PtrHallo%NbLevel
+              SizeBuffer=SizeBuffer+PtrHallo%size*iip1
+            ENDDO
+!$OMP ENDDO NOWAIT          
           enddo
         
           if (SizeBuffer>0) then
-!            allocate(Req%Buffer(SizeBuffer))
+
              call allocate_buffer(SizeBuffer,Req%Index,Req%Pos)
-!            print *, 'process',MPI_RANK,'IRECV: requette ',a_request%tag,'au process',rank,'de taille',SizeBuffer
-            
-!	    call MPI_IRECV(Req%Buffer,SizeBuffer,MPI_REAL8,rank,a_request%tag,     &
-!                           COMM_LMDZ,Req%MSG_Request,ierr)
-	    call MPI_IRECV(Buffer(Req%Pos),SizeBuffer,MPI_REAL8,rank,a_request%tag,     &
+!$OMP CRITICAL (MPI)
+             call MPI_IRECV(Buffer(Req%Pos),SizeBuffer,MPI_REAL8,rank,a_request%tag+1000*omp_rank,     &
                            COMM_LMDZ,Req%MSG_Request,ierr)
-
+!         PRINT *,"-------------------------------------------------------------------"
+!         PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->"
+!         PRINT *,"Requete en attente du proc :",rank,"tag :",a_request%tag+1000*omp_rank
+!         PRINT *,"Taille du message :",SizeBuffer,"requete no :",Req%MSG_Request
+!         PRINT *,"-------------------------------------------------------------------"
+
+!$OMP END CRITICAL (MPI)
           endif
       
@@ -492,6 +510,14 @@
       enddo
      
-      if (NbRequest>0) call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
-      
+      if (NbRequest>0) then
+!$OMP CRITICAL (MPI)
+!        PRINT *,"-------------------------------------------------------------------"
+!        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"en attente"
+!        PRINT *,"No des requetes :",TabRequest(1:NbRequest)
+        call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
+!        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"complete"
+!        PRINT *,"-------------------------------------------------------------------"
+!$OMP END CRITICAL (MPI)
+      endif
       do rank=0,MPI_Size-1
         Req=>a_request%RequestRecv(rank)
@@ -502,5 +528,6 @@
             offset=(PtrHallo%offset-1)*iip1+1
 	    Nb=iip1*PtrHallo%size-1
-            
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)            
 	    do l=1,PtrHallo%NbLevel
 !cdir NODEP
@@ -508,12 +535,8 @@
 	        PtrHallo%Field(offset+ij,l)=Buffer(Pos+ij)
 	      enddo
-!              PtrHallo%Field(offset:offset+Nb,l)=Buffer(Pos:Pos+Nb)
-!	      do ij=offset,offset+iip1*PtrHallo%size-1
-!                PtrHallo%Field(ij,l)=Buffer(Pos)
-!                Pos=Pos+1
-!              enddo
+
               Pos=Pos+Nb+1
 	    enddo
-	    
+!$OMP ENDDO NOWAIT	    
           enddo
         endif
@@ -566,6 +589,15 @@
       
 
-      if (NbRequest>0) call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
-      
+      if (NbRequest>0) THEN 
+!$OMP CRITICAL (MPI)     
+!        PRINT *,"-------------------------------------------------------------------"
+!        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"en attente"
+!        PRINT *,"No des requetes :",TabRequest(1:NbRequest)
+        call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
+!        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"complete"
+!        PRINT *,"-------------------------------------------------------------------"
+
+!$OMP END CRITICAL (MPI)
+      endif      
       
       do rank=0,MPI_SIZE-1
@@ -608,5 +640,14 @@
      
       
-      if (NbRequest>0) call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
+      if (NbRequest>0) then
+!$OMP CRITICAL (MPI)     
+!        PRINT *,"-------------------------------------------------------------------"
+!        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"en attente"
+!        PRINT *,"No des requetes :",TabRequest(1:NbRequest)
+        call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
+!        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"complete"
+!        PRINT *,"-------------------------------------------------------------------"
+!$OMP END CRITICAL (MPI)     
+      endif
       
       do rank=0,MPI_Size-1
@@ -618,5 +659,5 @@
             offset=(PtrHallo%offset-1)*iip1+1
 	    Nb=iip1*PtrHallo%size-1
-            
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)            
 	    do l=1,PtrHallo%NbLevel
 !cdir NODEP
@@ -626,4 +667,5 @@
                  Pos=Pos+Nb+1
             enddo
+!$OMP END DO NOWAIT
           enddo
         endif
@@ -651,5 +693,5 @@
     include 'mpif.h'
     
-    INTEGER :: ij,ll
+    INTEGER :: ij,ll,l
     REAL, dimension(ij,ll) :: FieldS
     REAL, dimension(ij,ll) :: FieldR
@@ -673,6 +715,12 @@
       ijb=(jjb-1)*iip1+1
       ije=jje*iip1
-      FieldR(ijb:ije,1:ll)=FieldS(ijb:ije,1:ll)
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      do l=1,ll
+        FieldR(ijb:ije,l)=FieldS(ijb:ije,l)
+      enddo
+!$OMP ENDDO NOWAIT
     endif
+
 
   end subroutine CopyField    
@@ -691,5 +739,5 @@
     integer,dimension(0:MPI_Size-1) :: jj_Begin_New,jj_End_New
 
-    integer ::i,jje,jjb,ijb,ije
+    integer ::i,jje,jjb,ijb,ije,l
 
      
@@ -710,5 +758,11 @@
       ijb=(jjb-1)*iip1+1
       ije=jje*iip1
-      FieldR(ijb:ije,1:ll)=FieldS(ijb:ije,1:ll)
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      do l=1,ll
+        FieldR(ijb:ije,l)=FieldS(ijb:ije,l)
+      enddo
+!$OMP ENDDO NOWAIT
+
     endif
    end subroutine CopyFieldHallo        
Index: LMDZ4/trunk/libf/dyn3dpar/nxgraro2_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/nxgraro2_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/nxgraro2_p.F	(revision 985)
@@ -15,4 +15,5 @@
       USE parallel
       USE times
+      USE mod_hallo
       IMPLICIT NONE
 c
@@ -33,4 +34,5 @@
       REAL  signe, nugradrs
       INTEGER l,ij,iter,lr
+      Type(Request) :: Request_dissip
 c    ........................................................
 c
@@ -55,9 +57,8 @@
 
 c$OMP BARRIER
-c$OMP MASTER          
-      call suspend_timer(timer_dissip)
-      call exchange_Hallo(grx,ip1jmp1,llm,0,1)
-      call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(grx,ip1jmp1,llm,0,1,1,0,Request_dissip)
+       call SendRequest(Request_dissip)
+c$OMP BARRIER
+       call WaitRequest(Request_dissip)
 c$OMP BARRIER
 
@@ -77,9 +78,8 @@
 
 c$OMP BARRIER
-c$OMP MASTER      
-      call suspend_timer(timer_dissip)
-      call exchange_Hallo(rot,ip1jm,llm,1,1)
-      call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(rot,ip1jm,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
+c$OMP BARRIER
+       call WaitRequest(Request_dissip)
 c$OMP BARRIER
       
@@ -91,10 +91,10 @@
       DO  iter = 1, lr -2
 c$OMP BARRIER
-c$OMP MASTER
-        call suspend_timer(timer_dissip)
-	call exchange_Hallo(rot,ip1jm,llm,1,1)
-        call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(rot,ip1jm,llm,1,1,1,1,Request_dissip)
+       call SendRequest(Request_dissip)
 c$OMP BARRIER
+       call WaitRequest(Request_dissip)
+c$OMP BARRIER
+
 	CALL laplacien_rotgam_p ( klevel, rot, rot )
       ENDDO
@@ -110,10 +110,10 @@
       CALL filtreg_p( rot, jjb,jje,jjm, klevel, 2,1, .FALSE.,1)
 c$OMP BARRIER
-c$OMP MASTER
-      call suspend_timer(timer_dissip)
-      call exchange_Hallo(rot,ip1jm,llm,1,0)
-      call resume_timer(timer_dissip)
-c$OMP END MASTER
+       call Register_Hallo(rot,ip1jm,llm,1,0,0,1,Request_dissip)
+       call SendRequest(Request_dissip)
 c$OMP BARRIER
+       call WaitRequest(Request_dissip)
+c$OMP BARRIER
+
       CALL nxgrad_p ( klevel, rot, grx, gry )
 
Index: LMDZ4/trunk/libf/dyn3dpar/parallel.F90
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/parallel.F90	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/parallel.F90	(revision 985)
@@ -16,5 +16,8 @@
     integer, allocatable, save, dimension(:) :: jj_nb_para
     integer, save :: OMP_CHUNK
-    
+    integer, save :: omp_rank
+    integer, save :: omp_size  
+!$OMP THREADPRIVATE(omp_rank)
+
  contains
  
@@ -27,6 +30,11 @@
       integer :: type_size
       integer, dimension(3) :: blocklen,type
-      
-      
+      integer :: comp_id
+#ifdef _OPENMP    
+      INTEGER :: OMP_GET_NUM_THREADS
+      EXTERNAL OMP_GET_NUM_THREADS
+      INTEGER :: OMP_GET_THREAD_NUM
+      EXTERNAL OMP_GET_THREAD_NUM
+#endif  
       include 'mpif.h'
 #include "dimensions.h"
@@ -95,5 +103,17 @@
       print *,"ij_begin",ij_begin
       print *,"ij_end",ij_end
-    
+
+!$OMP PARALLEL
+
+#ifdef _OPENMP
+!$OMP MASTER
+        omp_size=OMP_GET_NUM_THREADS()
+!$OMP END MASTER
+        omp_rank=OMP_GET_THREAD_NUM()    
+#else    
+        omp_size=1
+        omp_rank=0
+#endif
+!$OMP END PARALLEL         
     
     end subroutine init_parallel
@@ -230,6 +250,8 @@
       REAL, dimension(:),allocatable :: Buffer_Recv_up,Buffer_Recv_down
       INTEGER :: Buffer_size      
-      
+
+!$OMP CRITICAL (MPI)      
       call MPI_Barrier(COMM_LMDZ,ierr)
+!$OMP END CRITICAL (MPI)
       call VTb(VThallo)
       
@@ -266,6 +288,8 @@
         allocate(Buffer_Send_up(Buffer_size))
         call PACK_Data(Field(ij_begin,1),ij,ll,down,Buffer_Send_up)
+!$OMP CRITICAL (MPI)
         call MPI_ISSEND(Buffer_send_up,Buffer_Size,MPI_REAL8,MPI_Rank-1,1,     &
                         COMM_LMDZ,Request(NbRequest),ierr)
+!$OMP END CRITICAL (MPI)
       ENDIF
   
@@ -277,6 +301,8 @@
         call PACK_Data(Field(ij_end+1-up*iip1,1),ij,ll,up,Buffer_send_down)
         
+!$OMP CRITICAL (MPI)
         call MPI_ISSEND(Buffer_send_down,Buffer_Size,MPI_REAL8,MPI_Rank+1,1,     &
                         COMM_LMDZ,Request(NbRequest),ierr)
+!$OMP END CRITICAL (MPI)
       ENDIF
     
@@ -287,6 +313,8 @@
         allocate(Buffer_recv_up(Buffer_size))
               
+!$OMP CRITICAL (MPI)
         call MPI_IRECV(Buffer_recv_up,Buffer_size,MPI_REAL8,MPI_Rank-1,1,  &
                         COMM_LMDZ,Request(NbRequest),ierr)
+!$OMP END CRITICAL (MPI)
      
        
@@ -298,6 +326,8 @@
         allocate(Buffer_recv_down(Buffer_size))
         
+!$OMP CRITICAL (MPI)
         call MPI_IRECV(Buffer_recv_down,Buffer_size,MPI_REAL8,MPI_Rank+1,1,     &
                         COMM_LMDZ,Request(NbRequest),ierr)
+!$OMP END CRITICAL (MPI)
       
         
@@ -309,10 +339,13 @@
 
       call VTe(VThallo)
+!$OMP CRITICAL (MPI)
       call MPI_Barrier(COMM_LMDZ,ierr)
+!$OMP END CRITICAL (MPI)
+
       RETURN
       
     end subroutine exchange_Hallo
     
-    
+
     subroutine Gather_Field(Field,ij,ll,rank)
     implicit none
@@ -342,6 +375,8 @@
       if (MPI_Rank==rank) then
         allocate(Buffer_Recv(ij*ll))
+
+!CDIR NOVECTOR
         do i=0,MPI_Size-1
-          
+           
           if (ij==ip1jmp1) then 
             Recv_count(i)=(jj_end_para(i)-jj_begin_para(i)+1)*ll*iip1
@@ -351,5 +386,5 @@
             stop 'erreur dans Gather_Field'
           endif
-          
+                 
           if (i==0) then 
             displ(i)=0 
@@ -361,7 +396,9 @@
         
       endif
-      
+  
+!$OMP CRITICAL (MPI)
       call MPI_GATHERV(Buffer_send,(min(ij_end,ij)-ij_begin+1)*ll,MPI_REAL8,   &
                         Buffer_Recv,Recv_count,displ,MPI_REAL8,rank,COMM_LMDZ,ierr)
+!$OMP END CRITICAL (MPI)
       
       if (MPI_Rank==rank) then                  
@@ -380,7 +417,8 @@
       
       endif
-      
+     
     end subroutine Gather_Field
-    
+
+
     subroutine AllGather_Field(Field,ij,ll)
     implicit none
@@ -394,5 +432,7 @@
       
       call Gather_Field(Field,ij,ll,0)
+!$OMP CRITICAL (MPI)
       call MPI_BCAST(Field,ij*ll,MPI_REAL8,0,COMM_LMDZ,ierr)
+!$OMP END CRITICAL (MPI)
       
     end subroutine AllGather_Field
@@ -409,5 +449,7 @@
       INTEGER :: ierr
       
+!$OMP CRITICAL (MPI)
       call MPI_BCAST(Field,ij*ll,MPI_REAL8,rank,COMM_LMDZ,ierr)
+!$OMP END CRITICAL (MPI)
       
     end subroutine Broadcast_Field
Index: LMDZ4/trunk/libf/dyn3dpar/qminimum_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/qminimum_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/qminimum_p.F	(revision 985)
@@ -34,5 +34,8 @@
       SAVE imprim
       DATA imprim /0/
+c$OMP THREADPRIVATE(imprim)
       INTEGER ijb,ije
+      INTEGER Index_pump(ip1jmp1)
+      INTEGER nb_pump
 c
 c Quand l'eau liquide est trop petite (ou negative), on prend
@@ -40,7 +43,9 @@
 c (sans changer la temperature !)
 c
+
       ijb=ij_begin
       ije=ij_end
-      
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
       DO 1000 k = 1, llm
       DO 1040 i = ijb, ije
@@ -50,4 +55,8 @@
  1040 CONTINUE
  1000 CONTINUE
+c$OMP END DO NOWAIT
+c$OMP BARRIER
+c --->  SYNCHRO OPENMP ICI
+
 c
 c Quand l'eau vapeur est trop faible (ou negative), on complete
@@ -58,4 +67,5 @@
       DO k = llm, 2, -1
 ccc      zx_abc = dpres(k) / dpres(k-1)
+c$OMP DO SCHEDULE(STATIC)
       DO i = ijb, ije
          zx_abc = deltap(i,k)/deltap(i,k-1)
@@ -64,21 +74,29 @@
          q(i,k,iq)   =  q(i,k,iq)   + zx_defau  
       ENDDO
+c$OMP END DO NOWAIT
       ENDDO
+c$OMP BARRIER
 c
 c Quand il s'agit de la premiere couche au-dessus du sol, on
 c doit imprimer un message d'avertissement (saturation possible).
 c
+      nb_pump=0
+c$OMP DO SCHEDULE(STATIC)
       DO i = ijb, ije
          zx_pump(i) = AMAX1( 0.0, seuil_vap - q(i,1,iq) )
          q(i,1,iq)  = AMAX1( q(i,1,iq), seuil_vap )
+         IF (zx_pump(i) > 0.0) THEN
+            nb_pump = nb_pump+1
+            Index_pump(nb_pump)=i
+         ENDIF
       ENDDO
-      pompe = SSUM(ije-ijb+1,zx_pump(ijb),1)
-      IF (imprim.LE.500 .AND. pompe.GT.0.0) THEN
-         WRITE(6,'(1x,"ATT!:on pompe de l eau au sol",e15.7)') pompe
-         DO i = ijb, ije
-            IF (zx_pump(i).GT.0.0) THEN
+c$OMP END DO  
+!      pompe = SSUM(ije-ijb+1,zx_pump(ijb),1)
+
+      IF (imprim.LE.100 .AND. nb_pump .GT. 0 ) THEN
+         PRINT *, 'ATT!:on pompe de l eau au sol'
+         DO i = 1, nb_pump
                imprim = imprim + 1
-               PRINT*,'  en ',i,zx_pump(i)
-            ENDIF
+               PRINT*,'  en ',index_pump(i),zx_pump(index_pump(i))
          ENDDO
       ENDIF
Index: LMDZ4/trunk/libf/dyn3dpar/temps.h
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/temps.h	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/temps.h	(revision 985)
@@ -18,4 +18,3 @@
       INTEGER*4 day_ini, day_end, annee_ref, day_ref
       REAL      dt
-
-!-----------------------------------------------------------------------
+!$OMP THREADPRIVATE(/temps/)
Index: LMDZ4/trunk/libf/dyn3dpar/vlspltgen_p.F
===================================================================
--- LMDZ4/trunk/libf/dyn3dpar/vlspltgen_p.F	(revision 961)
+++ LMDZ4/trunk/libf/dyn3dpar/vlspltgen_p.F	(revision 985)
@@ -87,8 +87,8 @@
 c-- approximation: au milieu des couches play(l)=(p(l)+p(l+1))/2
 c   pour eviter une exponentielle.
-c$OMP MASTER
+
       call SetTag(MyRequest1,100)
       call SetTag(MyRequest2,101)
-c$OMP END MASTER
+
         
 	ijb=ij_begin-iip1
@@ -182,22 +182,45 @@
 	
 	else if (iadv(iq)==10) then
-        
+
+#ifdef _ADV_HALO        
+	  call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
+     &	             ij_begin,ij_begin+2*iip1-1)
+          call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
+     &               ij_end-2*iip1+1,ij_end)
+#else
 	  call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
      &	             ij_begin,ij_end)
+#endif
 
 c$OMP MASTER
           call VTb(VTHallo)
+c$OMP END MASTER
           call Register_Hallo(zq(1,1,iq),ip1jmp1,llm,2,2,2,2,MyRequest1)
           call Register_Hallo(zm(1,1,iq),ip1jmp1,llm,1,1,1,1,MyRequest1)
+
+c$OMP MASTER
           call VTe(VTHallo)
 c$OMP END MASTER
 	else if (iadv(iq)==14) then
-      
+
+#ifdef _ADV_HALO           
+          call vlxqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,qsat,
+     &                 ij_begin,ij_begin+2*iip1-1)
+          call vlxqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,qsat,
+     &                 ij_end-2*iip1+1,ij_end)
+#else
+
           call vlxqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,qsat,
      &                 ij_begin,ij_end)
+#endif
+
 c$OMP MASTER
           call VTb(VTHallo)
+c$OMP END MASTER
+
           call Register_Hallo(zq(1,1,iq),ip1jmp1,llm,2,2,2,2,MyRequest1)
           call Register_Hallo(zm(1,1,iq),ip1jmp1,llm,1,1,1,1,MyRequest1)
+
+c$OMP MASTER
           call VTe(VTHallo)
 c$OMP END MASTER 
@@ -214,7 +237,48 @@
 c$OMP MASTER      
       call VTb(VTHallo)
+c$OMP END MASTER
+
       call SendRequest(MyRequest1)
-      call WaitRecvRequest(MyRequest1)
-      call WaitSendRequest(MyRequest1)
+
+c$OMP MASTER
+      call VTe(VTHallo)
+c$OMP END MASTER       
+c$OMP BARRIER
+      do iq=1,nqmx
+
+        if(iadv(iq) == 0) then
+	
+	  cycle 
+	
+	else if (iadv(iq)==10) then
+
+#ifdef _ADV_HALLO
+          call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
+     &               ij_begin+2*iip1,ij_end-2*iip1)
+#endif        
+	else if (iadv(iq)==14) then
+#ifdef _ADV_HALLO
+          call vlxqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,qsat,
+     &                 ij_begin+2*iip1,ij_end-2*iip1)
+#endif    
+        else
+	
+	  stop 'vlspltgen_p : schema non parallelise'
+      
+        endif
+      
+      enddo
+c$OMP BARRIER      
+c$OMP MASTER
+      call VTb(VTHallo)
+c$OMP END MASTER
+
+!      call WaitRecvRequest(MyRequest1)
+!      call WaitSendRequest(MyRequest1)
+c$OMP BARRIER
+       call WaitRequest(MyRequest1)
+
+
+c$OMP MASTER
       call VTe(VTHallo)
 c$OMP END MASTER
@@ -243,4 +307,5 @@
        enddo
 
+
       do iq=1,nqmx
 
@@ -252,12 +317,23 @@
 
 c$OMP BARRIER        
+#ifdef _ADV_HALLO
+          call vlz_p(zq(1,1,iq),pente_max,zm(1,1,iq),mw,
+     &               ij_begin,ij_begin+2*iip1-1)
+          call vlz_p(zq(1,1,iq),pente_max,zm(1,1,iq),mw,
+     &               ij_end-2*iip1+1,ij_end)
+#else
           call vlz_p(zq(1,1,iq),pente_max,zm(1,1,iq),mw,
      &               ij_begin,ij_end)
+#endif
 c$OMP BARRIER
 
 c$OMP MASTER
           call VTb(VTHallo)
+c$OMP END MASTER
+
           call Register_Hallo(zq(1,1,iq),ip1jmp1,llm,2,2,2,2,MyRequest2)
           call Register_Hallo(zm(1,1,iq),ip1jmp1,llm,1,1,1,1,MyRequest2)
+
+c$OMP MASTER
           call VTe(VTHallo)
 c$OMP END MASTER	
@@ -271,9 +347,50 @@
       enddo
 c$OMP BARRIER      
+
 c$OMP MASTER        
       call VTb(VTHallo)
+c$OMP END MASTER
+
       call SendRequest(MyRequest2)
-      call WaitRecvRequest(MyRequest2)
-      call WaitSendRequest(MyRequest2)
+
+c$OMP MASTER
+      call VTe(VTHallo)
+c$OMP END MASTER	
+
+c$OMP BARRIER
+      do iq=1,nqmx
+
+        if(iadv(iq) == 0) then
+	  
+	  cycle 
+	
+	else if (iadv(iq)==10 .or. iadv(iq)==14 ) then
+c$OMP BARRIER        
+
+#ifdef _ADV_HALLO
+          call vlz_p(zq(1,1,iq),pente_max,zm(1,1,iq),mw,
+     &               ij_begin+2*iip1,ij_end-2*iip1)
+#endif
+
+c$OMP BARRIER        
+        else
+	
+	  stop 'vlspltgen_p : schema non parallelise'
+      
+        endif
+      
+      enddo
+
+c$OMP BARRIER
+c$OMP MASTER
+      call VTb(VTHallo)
+c$OMP END MASTER
+
+!      call WaitRecvRequest(MyRequest2)
+!      call WaitSendRequest(MyRequest2)
+c$OMP BARRIER
+       CALL WaitRequest(MyRequest2)
+
+c$OMP MASTER
       call VTe(VTHallo)
 c$OMP END MASTER
@@ -331,4 +448,5 @@
       ije=ij_end
 c$OMP BARRIER      
+
 
       DO iq=1,nqmx
