Index: /LMDZ4/trunk/libf/dyn3dpar/addfi_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/addfi_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/addfi_p.F	(revision 774)
@@ -1,2 +1,5 @@
+!
+! $Header$
+!
       SUBROUTINE addfi_p(nq, pdt, leapf, forward,
      S          pucov, pvcov, pteta, pq   , pps ,
Index: /LMDZ4/trunk/libf/dyn3dpar/advect_new_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/advect_new_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/advect_new_p.F	(revision 774)
@@ -1,2 +1,5 @@
+!
+! $Header$
+!
       SUBROUTINE advect_new_p(ucov,vcov,teta,w,massebx,masseby,
      &                        du,dv,dteta)
Index: /LMDZ4/trunk/libf/dyn3dpar/advect_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/advect_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/advect_p.F	(revision 774)
@@ -1,2 +1,5 @@
+!
+! $Header$
+!
       SUBROUTINE advect_p(ucov,vcov,teta,w,massebx,masseby,du,dv,dteta)
       USE parallel
Index: /LMDZ4/trunk/libf/dyn3dpar/bands.F90
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/bands.F90	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/bands.F90	(revision 774)
@@ -11,5 +11,5 @@
     INTEGER,dimension(:),allocatable :: jj_Nb_physic
     INTEGER,dimension(:),allocatable :: jj_Nb_physic_bis
-    INTEGER,dimension(:),allocatable :: New_klon_para_nb
+    INTEGER,dimension(:),allocatable :: distrib_phys
   
   contains
@@ -25,14 +25,13 @@
     allocate(jj_Nb_physic(0:MPI_Size-1))
     allocate(jj_Nb_physic_bis(0:MPI_Size-1))
-    allocate(New_klon_para_nb(0:MPI_Size-1))
+    allocate(distrib_phys(0:MPI_Size-1))
   
   end subroutine AllocateBands
   
-  subroutine InitBands
+  subroutine Read_distrib
     use parallel
-    use dimphy
     implicit none
 
-#include "dimensions90.h"
+    include "dimensions90.h"
 !#include "paramet90.h"   
       integer :: i,j
@@ -67,8 +66,7 @@
       
         do i=0,mpi_size-1
-          read (unit_number,*) j,klon_para_nb(i)
+          read (unit_number,*) j,distrib_phys(i)
         enddo
 	
-	call InitDimphy
 	CLOSE(unit_number)  
   
@@ -81,7 +79,21 @@
         jj_nb_vanleer(:)=jj_nb_caldyn(:)
         jj_nb_dissip(:)=jj_nb_caldyn(:)
+        
+	do i=0,mpi_size-1
+	  distrib_phys(i)=(iim*(jjm-1)+2)/mpi_size
+	  IF (i<MOD(iim*(jjm-1)+2,mpi_size)) distrib_phys(i)=distrib_phys(i)+1
+	enddo
+      endif
+  
+   end subroutine Read_distrib
    
-      endif
-    
+   
+   SUBROUTINE  Set_Bands 
+     USE parallel
+     USE mod_phys_lmdz_para, ONLY : jj_para_begin,jj_para_end
+     IMPLICIT NONE
+     INCLUDE 'dimensions90.h'    
+     INTEGER :: i
+        
       do i=0,mpi_size-1
          jj_nb_vanleer2(i)=(jjm+1)/mpi_size
@@ -90,7 +102,7 @@
           
       do i=0,MPI_Size-1
-        jj_Nb_physic(i)=jjphy_para_end(i)-jjphy_para_begin(i)+1
+        jj_Nb_physic(i)=jj_para_end(i)-jj_para_begin(i)+1
         if (i/=0) then
-          if (jjphy_para_begin(i)==jjphy_para_end(i-1)) then
+          if (jj_para_begin(i)==jj_para_end(i-1)) then
             jj_Nb_physic(i-1)=jj_Nb_physic(i-1)-1
           endif
@@ -99,7 +111,7 @@
       
       do i=0,MPI_Size-1
-        jj_Nb_physic_bis(i)=jjphy_para_end(i)-jjphy_para_begin(i)+1
+        jj_Nb_physic_bis(i)=jj_para_end(i)-jj_para_begin(i)+1
         if (i/=0) then
-          if (jjphy_para_begin(i)==jjphy_para_end(i-1)) then
+          if (jj_para_begin(i)==jj_para_end(i-1)) then
             jj_Nb_physic_bis(i)=jj_Nb_physic_bis(i)-1
           else
@@ -110,12 +122,10 @@
       enddo
       
-      do i=0,MPI_Size-1
-        New_klon_para_nb(i)=klon_para_nb(i)
-      enddo
-       
-    end subroutine InitBands
+    end subroutine Set_Bands
+
 
     subroutine AdjustBands_caldyn
       use times
+      use parallel
       implicit none
 
@@ -182,4 +192,5 @@
     subroutine AdjustBands_vanleer
       use times
+      use parallel
       implicit none
 
@@ -247,4 +258,5 @@
     subroutine AdjustBands_dissip
       use times
+      use parallel
       implicit none
 
@@ -312,5 +324,6 @@
     subroutine AdjustBands_physic
       use times
-      use dimphy
+      USE mod_phys_lmdz_para, only : klon_mpi_para_nb
+      USE parallel
       implicit none
 
@@ -336,5 +349,5 @@
       NbTot=0
       do i=0,mpi_size-1
-        Inc(i)=nint(klon_para_nb(i)*(medium-value(i))/value(i))
+        Inc(i)=nint(klon_mpi_para_nb(i)*(medium-value(i))/value(i))
         NbTot=NbTot+Inc(i)  
       enddo
@@ -355,5 +368,5 @@
       
       do i=0,mpi_size-1
-        New_klon_para_nb(i)=klon_para_nb(i)+inc(i)
+        distrib_phys(i)=klon_mpi_para_nb(i)+inc(i)
       enddo
      
@@ -363,5 +376,5 @@
     USE parallel
     implicit none
-#include "dimensions90.h"
+    include "dimensions90.h"
 
       integer :: i,j
@@ -399,5 +412,5 @@
         
 	do i=0,mpi_size-1
-          write (unit_number,*) i,New_klon_para_nb(i)
+          write (unit_number,*) i,distrib_phys(i)
         enddo
 	
Index: /LMDZ4/trunk/libf/dyn3dpar/calfis_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/calfis_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/calfis_p.F	(revision 774)
@@ -36,5 +36,7 @@
 c   .........
       USE dimphy
-      USE parallel
+      USE mod_phys_lmdz_para, mpi_root_xx=>mpi_root 
+      USE parallel, ONLY : omp_chunk
+      USE mod_interface_dyn_phys
       USE Write_Field
       Use Write_field_p
@@ -281,6 +283,6 @@
 c$OMP MASTER             
       do ig0=1,klon
-        i=Liste_i(ig0)
-        j=Liste_j(ig0)
+        i=index_i(ig0)
+        j=index_j(ig0)
         zpsrf(ig0)=pps(i,j)
       enddo
@@ -303,6 +305,6 @@
       DO l = 1, llmp1
         do ig0=1,klon
-          i=Liste_i(ig0)
-          j=Liste_j(ig0)
+          i=index_i(ig0)
+          j=index_j(ig0)
           zplev( ig0,l ) = pp(i,j,l)
         enddo
@@ -318,6 +320,6 @@
 
         do ig0=1,klon
-          i=Liste_i(ig0)
-          j=Liste_j(ig0)
+          i=index_i(ig0)
+          j=index_j(ig0)
           pksurcp        = ppk(i,j,l) / cpp
           zplay(ig0,l)   = preff * pksurcp ** unskap
@@ -338,6 +340,6 @@
          DO l=1,llm
            do ig0=1,klon
-             i=Liste_i(ig0)
-             j=Liste_j(ig0)
+             i=index_i(ig0)
+             j=index_j(ig0)
              zqfi(ig0,l,iq)  = pq(i,j,l,iiq)
            enddo
@@ -352,6 +354,6 @@
          DO l=1,llm
            do ig0=1,klon
-             i=Liste_i(ig0)
-             j=Liste_j(ig0)
+             i=index_i(ig0)
+             j=index_j(ig0)
 c             pcvgq(ig0,l,iq) = pdq(i,j,l,iq) / pmasse(i,j,l)
            enddo
@@ -384,10 +386,10 @@
       DO l=1,llm
         do ig0=1,klon
-           i=Liste_i(ig0)
-           j=Liste_j(ig0)
+           i=index_i(ig0)
+           j=index_j(ig0)
            pvervel(ig0,l) = pw(i,j,l)*g* unsaire(i,j)
         enddo
-	if (pole_nord) pvervel(1,l)=pw(1,1,l)*g /apoln
-	if (pole_sud) pvervel(klon,l)=pw(1,jjp1,l)*g/apols
+	if (is_north_pole) pvervel(1,l)=pw(1,1,l)*g /apoln
+	if (is_south_pole) pvervel(klon,l)=pw(1,jjp1,l)*g/apols
       ENDDO
 c$OMP END DO NOWAIT
@@ -400,12 +402,12 @@
       kend=klon
       
-      if (pole_nord) kstart=2
-      if (pole_sud) kend=klon-1
+      if (is_north_pole) kstart=2
+      if (is_south_pole) kend=klon-1
       
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
       DO l=1,llm
         do ig0=kstart,kend
-          i=Liste_i(ig0)
-          j=Liste_j(ig0)
+          i=index_i(ig0)
+          j=index_j(ig0)
           if (i==1) then
             zufi(ig0,l)= 0.5 *(  pucov(iim,j,l)/cu(iim,j)
@@ -427,6 +429,6 @@
       DO l=1,llm
         DO ig0=kstart,kend
-          i=Liste_i(ig0)
-          j=Liste_j(ig0)
+          i=index_i(ig0)
+          j=index_j(ig0)
           zvfi(ig0,l)= 0.5 *(  pvcov(i,j-1,l)/cv(i,j-1) 
      $                       + pvcov(i,j,l)/cv(i,j) )
@@ -443,5 +445,5 @@
 c        V = 1 / pi  *  integrale [ v * sin(long) * d long ]
 
-      if (pole_nord) then
+      if (is_north_pole) then
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
         DO l=1,llm
@@ -476,5 +478,5 @@
 c        V = 1 / pi  *  integrale [ v * sin(long) * d long ]
 
-      if (pole_sud) then
+      if (is_south_pole) then
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
         DO l=1,llm
@@ -504,5 +506,5 @@
 
 
-      IF (monocpu) THEN
+      IF (is_sequential) THEN
 c
 cIM calcul PV a teta=350, 380, 405K
@@ -535,5 +537,5 @@
 c$OMP BARRIER
       if (first_omp) then
-        klon=klon_omp_nb(omp_rank)
+        klon=klon_omp
 
         allocate(zplev_omp(klon,llm+1))
@@ -556,6 +558,6 @@
        
 	   
-      klon=klon_omp_nb(omp_rank)
-      offset=klon_omp_begin(omp_rank)-1
+      klon=klon_omp
+      offset=klon_omp_begin-1
       
       do l=1,llm+1
@@ -577,5 +579,4 @@
       enddo
 	
-
       do i=1,klon
 	zphis_omp(i)=zphis(offset+i)
@@ -840,14 +841,14 @@
         zdvfi2(klon+1:klon+iim,l)=dv_recv(1:iim,l) 
   
-         pdhfi(:,jjphy_begin,l)=0
-         pdqfi(:,jjphy_begin,l,:)=0
-         pdufi(:,jjphy_begin,l)=0
-         pdvfi(:,jjphy_begin,l)=0
+         pdhfi(:,jj_begin,l)=0
+         pdqfi(:,jj_begin,l,:)=0
+         pdufi(:,jj_begin,l)=0
+         pdvfi(:,jj_begin,l)=0
          
-         if (.not. pole_sud) then
-           pdhfi(:,jjphy_end,l)=0
-           pdqfi(:,jjphy_end,l,:)=0
-           pdufi(:,jjphy_end,l)=0
-           pdvfi(:,jjphy_end,l)=0
+         if (.not. is_south_pole) then
+           pdhfi(:,jj_end,l)=0
+           pdqfi(:,jj_end,l,:)=0
+           pdufi(:,jj_end,l)=0
+           pdvfi(:,jj_end,l)=0
          endif
       
@@ -856,7 +857,7 @@
 
 c$OMP MASTER
-       pdpsfi(:,jjphy_begin)=0    
-       if (.not. pole_sud) then
-	 pdpsfi(:,jjphy_end)=0
+       pdpsfi(:,jj_begin)=0    
+       if (.not. is_south_pole) then
+	 pdpsfi(:,jj_end)=0
        endif
 c$OMP END MASTER
@@ -877,6 +878,6 @@
       kend=klon
 
-      if (pole_nord) kstart=2
-      if (pole_sud)  kend=klon-1
+      if (is_north_pole) kstart=2
+      if (is_south_pole)  kend=klon-1
 
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
@@ -885,11 +886,11 @@
 !!cdir NODEP
         do ig0=kstart,kend
-          i=Liste_i(ig0)
-          j=Liste_j(ig0)
+          i=index_i(ig0)
+          j=index_j(ig0)
           pdhfi(i,j,l) = cpp * zdtfi(ig0,l) / ppk(i,j,l)
           if (i==1) pdhfi(iip1,j,l) =  cpp * zdtfi(ig0,l) / ppk(i,j,l)
          enddo          
 
-        if (pole_nord) then
+        if (is_north_pole) then
             DO i=1,iip1
               pdhfi(i,1,l)    = cpp *  zdtfi(1,l)      / ppk(i, 1  ,l)
@@ -897,5 +898,5 @@
         endif
         
-        if (pole_sud) then
+        if (is_south_pole) then
             DO i=1,iip1
               pdhfi(i,jjp1,l) = cpp *  zdtfi(klon,l)/ ppk(i,jjp1,l)
@@ -913,11 +914,11 @@
 !!cdir NODEP 
            do ig0=kstart,kend
-             i=Liste_i(ig0)
-             j=Liste_j(ig0)
+             i=index_i(ig0)
+             j=index_j(ig0)
              pdqfi(i,j,l,iq) = zdqfi(ig0,l,iq) 
              if (i==1) pdqfi(iip1,j,l,iq) = zdqfi(ig0,l,iq) 
            enddo
            
-           if (pole_nord) then
+           if (is_north_pole) then
              do i=1,iip1
                pdqfi(i,1,l,iq)    = zdqfi(1,l,iq)             
@@ -925,5 +926,5 @@
            endif
            
-           if (pole_sud) then
+           if (is_south_pole) then
              do i=1,iip1
                pdqfi(i,jjp1,l,iq) = zdqfi(klon,l,iq) 
@@ -954,11 +955,11 @@
 !!cdir NODEP           
 	     DO ig0=kstart,kend
-              i=Liste_i(ig0)
-              j=Liste_j(ig0)
+              i=index_i(ig0)
+              j=index_j(ig0)
               pdqfi(i,j,l,iiq) = zdqfi(ig0,l,iq)
               if (i==1) pdqfi(iip1,j,l,iiq) = zdqfi(ig0,l,iq)
             ENDDO
 	    
-	    IF (pole_nord) then
+	    IF (is_north_pole) then
 	      DO i=1,iip1
                 pdqfi(i,1,l,iiq)    = zdqfi(1,l,iq)
@@ -966,5 +967,5 @@
 	    ENDIF
 	    
-	    IF (pole_sud) then
+	    IF (is_south_pole) then
 	      DO i=1,iip1
                 pdqfi(i,jjp1,l,iiq) = zdqfi(klon,l,iq)
@@ -982,6 +983,6 @@
 !!cdir NODEP
          do ig0=kstart,kend
-           i=Liste_i(ig0)
-           j=Liste_j(ig0)
+           i=index_i(ig0)
+           j=index_j(ig0)
            
            if (i/=iim) then
@@ -997,5 +998,5 @@
          enddo
          
-         if (Pole_nord) then
+         if (is_north_pole) then
            DO i=1,iip1
             pdufi(i,1,l)    = 0.
@@ -1003,5 +1004,5 @@
          endif
          
-         if (Pole_sud) then
+         if (is_south_pole) then
            DO i=1,iip1
             pdufi(i,jjp1,l) = 0.
@@ -1018,6 +1019,6 @@
       kend=klon
 
-      if (pole_nord) kstart=2
-      if (pole_sud)  kend=klon-1-iim
+      if (is_north_pole) kstart=2
+      if (is_south_pole)  kend=klon-1-iim
       
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
@@ -1025,6 +1026,6 @@
 !!cdir NODEP
         do ig0=kstart,kend
-           i=Liste_i(ig0)
-           j=Liste_j(ig0)
+           i=index_i(ig0)
+           j=index_j(ig0)
            pdvfi(i,j,l)=0.5*(zdvfi2(ig0,l)+zdvfi2(ig0+iim,l))*cv(i,j)
            if (i==1) pdvfi(iip1,j,l) = 0.5*(zdvfi2(ig0,l)+
@@ -1041,5 +1042,5 @@
 c      v = U * cos(long) + V * SIN(long)
 
-      if (pole_nord) then
+      if (is_north_pole) then
 
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
@@ -1061,5 +1062,5 @@
       endif    
       
-      if (pole_sud) then
+      if (is_south_pole) then
 
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
Index: /LMDZ4/trunk/libf/dyn3dpar/exner_hyb_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/exner_hyb_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/exner_hyb_p.F	(revision 774)
@@ -51,10 +51,11 @@
       INTEGER ije,ijb,jje,jjb
 c
-      
+c$OMP MASTER           
       unpl2k    = 1.+ 2.* kappa
 c
       ijb=ij_begin
       ije=ij_end
-      
+
+
       DO   ij  = ijb, ije
         pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
@@ -103,8 +104,10 @@
 c
       ENDDO
+
 c
 c  ***********************************************************************
 c     .....  Calcul de pk pour la couche 1 , pres du sol  ....
 c
+
       DO   ij   = ijb, ije
        pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  /
@@ -123,4 +126,6 @@
 c      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
       pkf(ijb:ije,1:llm)=pk(ijb:ije,1:llm)
+c$OMP END MASTER
+c$OMP BARRIER
       
       jjb=jj_begin
Index: /LMDZ4/trunk/libf/dyn3dpar/gcm.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/gcm.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/gcm.F	(revision 774)
@@ -9,6 +9,8 @@
       USE IOIPSL
 #endif
+      USE mod_const_mpi, ONLY: init_const_mpi
       USE parallel
       USE dimphy
+      USE mod_interface_dyn_phys
       USE comgeomphy
       USE mod_hallo
@@ -212,6 +214,9 @@
 c------------------------------------
       call init_parallel
-      call InitDimphy
-      call InitBands
+      call Read_Distrib
+      CALL init_const_mpi
+      CALL Init_Phys_lmdz(iim,jjp1,llm,nqmx-2,mpi_size,distrib_phys)
+      CALL set_bands
+      CALL Init_interface_dyn_phys
       call MPI_BARRIER(COMM_LMDZ,ierr)
       if (mpi_rank==0) call WriteBands
@@ -226,5 +231,4 @@
       call Init_Mod_hallo(MPI_Buffer)
 c$OMP PARALLEL
-      call init_phys_openmp
       call InitComgeomphy
 c$OMP END PARALLEL 
@@ -434,8 +438,8 @@
 c       write(78,*) 'q',q
 
-
+c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logic/)
       CALL leapfrog_p(ucov,vcov,teta,ps,masse,phis,nq,q,clesphy0,
      .              time_0)
-
+c$OMP END PARALLEL
 
 
Index: /LMDZ4/trunk/libf/dyn3dpar/gr_dyn_fi_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/gr_dyn_fi_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/gr_dyn_fi_p.F	(revision 774)
@@ -1,3 +1,4 @@
       SUBROUTINE gr_dyn_fi_p(nfield,im,jm,ngrid,pdyn,pfi)
+      USE mod_interface_dyn_phys
       USE dimphy
       USE PARALLEL
@@ -27,6 +28,6 @@
       DO l=1,nfield    
        DO ig=1,klon
-         i=Liste_i(ig)
-         j=Liste_j(ig)
+         i=index_i(ig)
+         j=index_j(ig)
          pfi(ig,l)=pdyn(i,j,l)
        ENDDO
Index: /LMDZ4/trunk/libf/dyn3dpar/gr_fi_dyn_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/gr_fi_dyn_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/gr_fi_dyn_p.F	(revision 774)
@@ -1,4 +1,5 @@
       SUBROUTINE gr_fi_dyn_p(nfield,ngrid,im,jm,pfi,pdyn)
-      use dimphy
+      USE mod_interface_dyn_phys
+      USE dimphy
       use parallel
       IMPLICIT NONE
@@ -24,6 +25,6 @@
 
         do ig=1,klon
-          i=Liste_i(ig)
-          j=Liste_j(ig)
+          i=index_i(ig)
+          j=index_j(ig)
           pdyn(i,j,ifield)=pfi(ig,ifield)
           if (i==1) pdyn(im,j,ifield)=pdyn(i,j,ifield)
Index: /LMDZ4/trunk/libf/dyn3dpar/gr_u_scal_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/gr_u_scal_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/gr_u_scal_p.F	(revision 774)
@@ -66,5 +66,5 @@
       DO l=1,nx
          DO ij=ijb,ije-iip1+1,iip1
-	   x_scal(ij,l)=x_scal(ij+iip1-1)
+qy	   x_scal(ij,l)=x_scal(ij+iip1-1,l)
 	 ENDDO
       ENDDO
Index: /LMDZ4/trunk/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/leapfrog_p.F	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/leapfrog_p.F	(revision 774)
@@ -85,36 +85,37 @@
 
 c   variables dynamiques
-      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
-      REAL teta(ip1jmp1,llm)                 ! temperature potentielle 
-      REAL q(ip1jmp1,llm,nqmx)               ! champs advectes
-      REAL ps(ip1jmp1)                       ! pression  au sol
-      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
-      REAL pks(ip1jmp1)                      ! exner au  sol
-      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
-      REAL masse(ip1jmp1,llm)                ! masse d'air
-      REAL phis(ip1jmp1)                     ! geopotentiel au sol
-      REAL phi(ip1jmp1,llm)                  ! geopotentiel
-      REAL w(ip1jmp1,llm)                    ! vitesse verticale
+      REAL :: vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
+      REAL :: teta(ip1jmp1,llm)                 ! temperature potentielle 
+      REAL :: q(ip1jmp1,llm,nqmx)               ! 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
-      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm) !flux de masse
+      REAL,SAVE :: pbaru(ip1jmp1,llm),pbarv(ip1jm,llm) !flux de masse
 
 c   variables dynamiques au pas -1
-      REAL vcovm1(ip1jm,llm),ucovm1(ip1jmp1,llm)
-      REAL tetam1(ip1jmp1,llm),psm1(ip1jmp1)
-      REAL massem1(ip1jmp1,llm)
+      REAL,SAVE :: vcovm1(ip1jm,llm),ucovm1(ip1jmp1,llm)
+      REAL,SAVE :: tetam1(ip1jmp1,llm),psm1(ip1jmp1)
+      REAL,SAVE :: massem1(ip1jmp1,llm)
 
 c   tendances dynamiques
-      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
-      REAL dteta(ip1jmp1,llm),dq(ip1jmp1,llm,nqmx),dp(ip1jmp1)
+      REAL,SAVE :: dv(ip1jm,llm),du(ip1jmp1,llm)
+      REAL,SAVE :: dteta(ip1jmp1,llm),dq(ip1jmp1,llm,nqmx),dp(ip1jmp1)
 
 c   tendances de la dissipation
-      REAL dvdis(ip1jm,llm),dudis(ip1jmp1,llm)
-      REAL dtetadis(ip1jmp1,llm)
+      REAL,SAVE :: dvdis(ip1jm,llm),dudis(ip1jmp1,llm)
+      REAL,SAVE :: dtetadis(ip1jmp1,llm)
 
 c   tendances physiques
-      REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
-      REAL dtetafi(ip1jmp1,llm),dqfi(ip1jmp1,llm,nqmx),dpfi(ip1jmp1)
+      REAL,SAVE :: dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
+      REAL,SAVE :: dtetafi(ip1jmp1,llm)
+      REAL,SAVE :: dqfi(ip1jmp1,llm,nqmx),dpfi(ip1jmp1)
 
 c   variables pour le fichier histoire
@@ -128,8 +129,9 @@
 
       REAL  SSUM
-      REAL time_0 , finvmaold(ip1jmp1,llm)
+      REAL time_0 
+      REAL,SAVE :: finvmaold(ip1jmp1,llm)
 
 cym      LOGICAL  lafin
-      LOGICAL :: lafin=.false.
+      LOGICAL :: lafin
       INTEGER ij,iq,l
       INTEGER ik
@@ -143,17 +145,17 @@
       character*10 string10
 
-      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
+      REAL,SAVE :: alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
 #ifdef INCA
-      REAL :: flxw(ip1jmp1,llm)
+      REAL,SAVE :: flxw(ip1jmp1,llm)
 #endif
 
 c+jld variables test conservation energie
-      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
+      REAL,SAVE :: ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
 C     Tendance de la temp. potentiel d (theta)/ d t due a la 
 C     tansformation d'energie cinetique en energie thermique
 C     cree par la dissipation
-      REAL dtetaecdt(ip1jmp1,llm)
-      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
-      REAL vnat(ip1jm,llm),unat(ip1jmp1,llm)
+      REAL,SAVE :: dtetaecdt(ip1jmp1,llm)
+      REAL,SAVE :: vcont(ip1jm,llm),ucont(ip1jmp1,llm)
+      REAL,SAVE :: vnat(ip1jm,llm),unat(ip1jmp1,llm)
       REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
       CHARACTER*15 ztit
@@ -171,11 +173,6 @@
       PARAMETER (true_calendar = .false.)
 
-      logical dissip_conservative
-      save dissip_conservative
-      data dissip_conservative/.true./
-
-      LOGICAL prem
-      save prem
-      DATA prem/.true./
+      logical,PARAMETER :: dissip_conservative=.TRUE.
+ 
       INTEGER testita
       PARAMETER (testita = 9)
@@ -183,19 +180,30 @@
 c declaration liees au parallelisme
       INTEGER :: ierr
-      LOGICAL :: FirstCaldyn=.TRUE.
-      LOGICAL :: FirstPhysic=.TRUE.
+      LOGICAL :: FirstCaldyn
+      LOGICAL :: FirstPhysic
       INTEGER :: ijb,ije,j,i
       type(Request) :: TestRequest
       type(Request) :: Request_Dissip
       type(Request) :: Request_physic
-      REAL dvfi_tmp(iip1,llm),dufi_tmp(iip1,llm)
-      REAL dtetafi_tmp(iip1,llm),dqfi_tmp(iip1,llm,nqmx)
-      REAL dpfi_tmp(iip1)
-      INTEGER :: true_itau=0
+      REAL,SAVE :: dvfi_tmp(iip1,llm),dufi_tmp(iip1,llm)
+      REAL,SAVE :: dtetafi_tmp(iip1,llm),dqfi_tmp(iip1,llm,nqmx)
+      REAL,SAVE :: dpfi_tmp(iip1)
+
+      INTEGER :: true_itau
       LOGICAL :: verbose=.true.
-      INTEGER :: iapptrac = 0
-      INTEGER :: AdjustCount = 0
+      INTEGER :: iapptrac
+      INTEGER :: AdjustCount
       INTEGER :: var_time
+      LOGICAL :: ok_start_timer=.FALSE.
+
+c$OMP MASTER
       ItCount=0
+c$OMP END MASTER      
+      true_itau=0
+      FirstCaldyn=.TRUE.
+      FirstPhysic=.TRUE.
+      iapptrac=0
+      AdjustCount = 0
+      lafin=.false.
       
       itaufin   = nday*day_step
@@ -211,13 +219,16 @@
          ENDIF
 
-
+c$OMP MASTER
+      OMP_CHUNK=5
+c$OMP END MASTER	  
 c-----------------------------------------------------------------------
 c   On initialise la pression et la fonction d'Exner :
 c   --------------------------------------------------
 
+c$OMP MASTER
       dq=0.
       CALL pression ( ip1jmp1, ap, bp, ps, p       )
       CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
-
+c$OMP END MASTER
 c-----------------------------------------------------------------------
 c   Debut de l'integration temporelle:
@@ -227,7 +238,11 @@
    1  CONTINUE
 
+c$OMP MASTER
       call MPI_BARRIER(COMM_LMDZ,ierr)
+c$OMP END MASTER
+c$OMP BARRIER
 
 #ifdef CPP_IOIPSL
+c$OMP MASTER
       if (ok_guide.and.(itaufin-itau-1)*dtvr.gt.21600) then
         call guide_pp(itau,ucov,vcov,teta,q,masse,ps)
@@ -236,4 +251,5 @@
      .    '6 dernieres heures'
       endif
+c$OMP END MASTER
 #endif
 c
@@ -250,4 +266,5 @@
 
        if (FirstCaldyn) then
+c$OMP MASTER
          ucovm1=ucov
          vcovm1=vcov
@@ -258,20 +275,32 @@
          finvmaold = masse
          CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
-
+c$OMP END MASTER
+c$OMP BARRIER
        else
           
          ijb=ij_begin
          ije=ij_end
-               
-         ucovm1   (ijb:ije,:) = ucov  (ijb:ije,:)
-         tetam1   (ijb:ije,:) = teta  (ijb:ije,:)
-         massem1  (ijb:ije,:) = masse (ijb:ije,:)
+
+c$OMP MASTER           
          psm1     (ijb:ije) = ps    (ijb:ije)
-      
-         if (pole_sud) ije=ij_end-iip1
-         vcovm1(ijb:ije,:) = vcov  (ijb:ije,:)
+c$OMP END MASTER
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)         
+	 DO l=1,llm      
+           ije=ij_end
+	   ucovm1   (ijb:ije,l) = ucov  (ijb:ije,l)
+           tetam1   (ijb:ije,l) = teta  (ijb:ije,l)
+           massem1  (ijb:ije,l) = masse (ijb:ije,l)
+           finvmaold(ijb:ije,l)=masse(ijb:ije,l)
+	         
+           if (pole_sud) ije=ij_end-iip1
+           vcovm1(ijb:ije,l) = vcov  (ijb:ije,l)
        
-         finvmaold(ij_begin:ij_end,1:llm)=masse(ij_begin:ij_end,1:llm)
-         CALL filtreg_p ( finvmaold ,jj_begin,jj_end,jjp1, 
+
+         ENDDO
+c$OMP ENDDO	  
+
+
+          CALL filtreg_p ( finvmaold ,jj_begin,jj_end,jjp1, 
      .                    llm, -2,2, .TRUE., 1 )
 
@@ -292,4 +321,5 @@
    2  CONTINUE
 
+c$OMP MASTER
       ItCount=ItCount+1
       if (MOD(ItCount,1)==1) then
@@ -298,4 +328,5 @@
         debug=.false.
       endif
+c$OMP END MASTER
 c-----------------------------------------------------------------------
 
@@ -331,19 +362,27 @@
       
       if (firstCaldyn) then
-
+c$OMP MASTER
           call SetDistrib(jj_Nb_Caldyn)
+c$OMP END MASTER
+c$OMP BARRIER
           firstCaldyn=.FALSE.
 cym          call InitTime
+c$OMP MASTER
           call Init_timer
+c$OMP END MASTER
       endif
-      
-      
-      
-      
+
+c$OMP MASTER      
+      IF (ok_start_timer) THEN
+        CALL InitTime
+	ok_start_timer=.FALSE.
+      ENDIF      
+c$OMP END MASTER      
+     
       if (Adjust) then
-          AdjustCount=AdjustCount+1
-c         if (MOD(itau+1,20)==0) then
-          if (iapptrac==iapp_tracvl .and. (forward. OR . leapf)
-     &         .and. .not.FirstPhysic .and. Adjustcount>30) then
+c$OMP MASTER 
+        AdjustCount=AdjustCount+1
+        if (iapptrac==iapp_tracvl .and. (forward. OR . leapf)
+     &         .and. itau/iphysiq>2 .and. Adjustcount>30) then
            AdjustCount=0
            call allgather_timer_average
@@ -413,5 +452,5 @@
          call Register_SwapFieldHallo(phis,phis,ip1jmp1,1,
      &                                jj_Nb_caldyn,0,0,TestRequest)
-        call Register_SwapFieldHallo(phi,phi,ip1jmp1,llm,
+         call Register_SwapFieldHallo(phi,phi,ip1jmp1,llm,
      &                                jj_Nb_caldyn,0,0,TestRequest)
          call Register_SwapFieldHallo(finvmaold,finvmaold,ip1jmp1,llm,
@@ -427,24 +466,11 @@
          call WaitRequest(TestRequest)
          
-c	call SetDistrib(jj_Nb_vanleer)
-c        call AdjustBands_vanleer
-c	do j=1,nqmx
-c         call Register_SwapFieldHallo(q(1,1,j),q(1,1,j),ip1jmp1,llm,
-c     *                                jj_nb_vanleer,0,0,TestRequest)
-c        enddo
-c
-c         call Register_SwapFieldHallo(finvmaold,finvmaold,ip1jmp1,llm,
-c     &                                jj_Nb_vanleer,0,0,TestRequest)
-        
-c        call SendRequest(TestRequest)
-c        call WaitRequest(TestRequest)
-
 	call AdjustBands_dissip
 	call AdjustBands_physic
-c        call SetDistrib(jj_nb_caldyn)
+
       endif
-      
+c$OMP END MASTER  
       endif       
-       
+     
       
       
@@ -452,5 +478,6 @@
 c   calcul des tendances dynamiques:
 c   --------------------------------
-
+c$OMP BARRIER
+c$OMP MASTER
        call VTb(VThallo)
        call Register_Hallo(ucov,ip1jmp1,llm,1,1,1,1,TestRequest)
@@ -488,8 +515,10 @@
         enddo        
       endif
- 
-
+c$OMP END MASTER 
+c$OMP BARRIER
       
       True_itau=True_itau+1
+
+c$OMP MASTER
       print*,"Iteration No",True_itau
 
@@ -501,11 +530,15 @@
       
       call VTb(VTcaldyn)
-
+c$OMP END MASTER
+c$OMP BARRIER
       var_time=time+iday-day_ini
-      OMP_CHUNK=5
-c$OMP PARALLEL DEFAULT(SHARED) 
+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+                var_time)      
+cc$OMP+                time, iday,day_ini,forward,leapf, iapptrac,
+cc$OMP+                q,dq,p,VTcaldyn,offline,dtvr,itau)      
 
       CALL caldyn_p 
@@ -513,6 +546,8 @@
      $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time+iday-day_ini )
 
-c$OMP END PARALLEL      
+ccc$OMP END PARALLEL      
+c$OMP MASTER
       call VTe(VTcaldyn)
+c$OMP END MASTER      
 c      call WriteField_p('du',reshape(du,(/iip1,jmp1,llm/)))
 c      call WriteField_p('dv',reshape(dv,(/iip1,jjm,llm/)))
@@ -528,5 +563,5 @@
 
       IF( forward. OR . leapf )  THEN
-c$OMP PARALLEL DEFAULT(SHARED) 
+cc$OMP PARALLEL DEFAULT(SHARED) 
 c
 #ifdef INCA
@@ -542,5 +577,5 @@
 #endif
 
-c$OMP END PARALLEL
+
 
 c      do j=1,nqmx
@@ -562,11 +597,13 @@
 c
       ENDIF
-
+cc$OMP END PARALLEL
 
 c-----------------------------------------------------------------------
 c   integrations dynamique et traceurs:
 c   ----------------------------------
- 
+
+c$OMP MASTER 
        call VTb(VTintegre)
+c$OMP END MASTER
 c      call WriteField_p('ucovm1',reshape(ucovm1,(/iip1,jmp1,llm/)))
 c      call WriteField_p('vcovm1',reshape(vcovm1,(/iip1,jjm,llm/)))
@@ -577,10 +614,10 @@
 c      call WriteField_p('teta',reshape(teta,(/iip1,jmp1,llm/)))
 c      call WriteField_p('ps',reshape(ps,(/iip1,jmp1/)))
-c$OMP PARALLEL DEFAULT(SHARED)
+cc$OMP PARALLEL DEFAULT(SHARED)
        CALL integrd_p ( 2,vcovm1,ucovm1,tetam1,psm1,massem1 ,
      $         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis ,
      $              finvmaold                                    )
 
-c$OMP END PARALLEL
+
 c      call WriteField_p('ucovm1',reshape(ucovm1,(/iip1,jmp1,llm/)))
 c      call WriteField_p('vcovm1',reshape(vcovm1,(/iip1,jjm,llm/)))
@@ -593,7 +630,7 @@
 
 c      call WriteField_p('ps',reshape(ps,(/iip1,jmp1/)))
- 
+c$OMP MASTER 
        call VTe(VTintegre)
-
+c$OMP END MASTER
 c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
 c
@@ -608,4 +645,7 @@
           IF( itau+1. EQ. itaufin )              lafin = .TRUE.
        ENDIF
+
+cc$OMP END PARALLEL
+
 c
 c
@@ -614,6 +654,6 @@
 c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
 c
-c$OMP PARALLEL DEFAULT(SHARED)
-c$OMP+         PRIVATE(rdaym_ini,rdayvrai,ijb,ije)
+cc$OMP PARALLEL DEFAULT(SHARED)
+cc$OMP+         PRIVATE(rdaym_ini,rdayvrai,ijb,ije)
 
 c$OMP MASTER
@@ -622,11 +662,8 @@
 c$OMP END MASTER
 
+c$OMP BARRIER
          CALL pression_p (  ip1jmp1, ap, bp, ps,  p      )
-c$OMP BARRIER
-
-c$OMP MASTER
+
          CALL exner_hyb_p(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
-c$OMP END MASTER
-c$OMP BARRIER
            rdaym_ini  = itau * dtvr / daysec
            rdayvrai   = rdaym_ini  + day_ini
@@ -888,14 +925,16 @@
          call resume_timer(timer_caldyn)
 	 if (FirstPhysic) then
-	   call InitTime
+	   ok_start_timer=.TRUE.
 	   FirstPhysic=.false.
 	 endif
 c$OMP END MASTER
-c$OMP END PARALLEL
        ENDIF
 
+c$OMP BARRIER
         CALL pression_p ( ip1jmp1, ap, bp, ps, p                  )
         CALL exner_hyb_p( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
-
+c$OMP BARRIER
+
+cc$OMP END PARALLEL
 
 c-----------------------------------------------------------------------
@@ -904,6 +943,6 @@
 
       IF(apdiss) THEN
-c$OMP  PARALLEL DEFAULT(SHARED) 
-c$OMP+          PRIVATE(ijb,ije,tppn,tpn,tpps,tps)
+cc$OMP  PARALLEL DEFAULT(SHARED) 
+cc$OMP+          PRIVATE(ijb,ije,tppn,tpn,tpps,tps)
 c$OMP MASTER
         call suspend_timer(timer_caldyn)
@@ -1103,6 +1142,7 @@
 	print *,'fin dissipation'
 c$OMP END MASTER
-c$OMP END PARALLEL
       END IF
+
+cc$OMP END PARALLEL
 
 c ajout debug
@@ -1121,7 +1161,9 @@
 cym      call WriteField('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
 cym      call WriteField('vcov',reshape(vcov,(/iip1,jjm,llm/)))
-      
+c$OMP MASTER      
       call stop_timer(timer_caldyn)
+c$OMP END MASTER
       IF (itau==itaumax) then
+c$OMP MASTER
             call allgather_timer_average
 
@@ -1166,6 +1208,8 @@
       print *, 'Temps total ecoule sur la parallelisation :',DiffTime()
       print *, 'Temps CPU ecoule sur la parallelisation :',DiffCpuTime()
+
         call finalize_parallel
-	STOP
+c$OMP END MASTER
+	RETURN
       ENDIF
       
@@ -1188,5 +1232,7 @@
             IF( itau. EQ. itaufinp1 ) then  
 
+c$OMP MASTER
               call finalize_parallel
+c$OMP END MASTER
               abort_message = 'Simulation finished'
               call abort_gcm(modname,abort_message,0)
@@ -1197,4 +1243,6 @@
 
             IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
+c$OMP BARRIER
+c$OMP MASTER
                IF(itau.EQ.itaufin) THEN
                   iav=1
@@ -1203,5 +1251,5 @@
                ENDIF
 #ifdef CPP_IOIPSL
-              call Register_Hallo(vcov,ip1jm,llm,1,0,0,1,TestRequest)
+             call Register_Hallo(vcov,ip1jm,llm,1,0,0,1,TestRequest)
               call SendRequest(TestRequest)
               call WaitRequest(TestRequest)
@@ -1212,5 +1260,5 @@
 c     ,           ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
 #endif
-
+c$OMP END MASTER
             ENDIF
 
@@ -1220,9 +1268,11 @@
 
 c      IF( MOD(itau,iecri         ).EQ.0) THEN
+
            IF( MOD(itau,iecri*day_step).EQ.0) THEN
-
+c$OMP BARRIER
+c$OMP MASTER
                nbetat = nbetatdem
         CALL geopot_p  ( ip1jmp1, teta  , pk , pks,  phis  , phi )
-        
+       
 cym	unat=0.
 	
@@ -1269,11 +1319,14 @@
 c       endif
 #endif
-
-            ENDIF
+c$OMP END MASTER
+           ENDIF
 
             IF(itau.EQ.itaufin) THEN
 
+c$OMP BARRIER
+c$OMP MASTER
 
 c#ifdef CPP_IOIPSL
+
        CALL dynredem1_p("restart.nc",0.0,
      ,                     vcov,ucov,teta,q,nqmx,masse,ps)
@@ -1281,4 +1334,5 @@
 
               CLOSE(99)
+c$OMP END MASTER
             ENDIF
 
@@ -1332,5 +1386,7 @@
                forward =  .FALSE.
                IF( itau. EQ. itaufinp1 ) then  
+c$OMP MASTER
 	         call finalize_parallel
+c$OMP END MASTER
                  abort_message = 'Simulation finished'
                  call abort_gcm(modname,abort_message,0)
@@ -1347,4 +1403,7 @@
                ENDIF
 #ifdef CPP_IOIPSL
+c$OMP BARRIER
+c$OMP MASTER
+
               call Register_Hallo(vcov,ip1jm,llm,1,0,0,1,TestRequest)
               call SendRequest(TestRequest)
@@ -1355,10 +1414,12 @@
 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
-
             ENDIF
 
 c               IF(MOD(itau,iecri         ).EQ.0) THEN
               IF(MOD(itau,iecri*day_step).EQ.0) THEN
+c$OMP BARRIER
+c$OMP MASTER
                   nbetat = nbetatdem
        CALL geopot_p( ip1jmp1, teta  , pk , pks,  phis  , phi   )
@@ -1408,13 +1469,13 @@
 #endif
 
-
+c$OMP END MASTER
                ENDIF
 
-c#ifdef CPP_IOIPSL
-                 IF(itau.EQ.itaufin)
-     . CALL dynredem1_p("restart.nc",0.0,
-     .                     vcov,ucov,teta,q,nqmx,masse,ps)
-c#endif
-
+                 IF(itau.EQ.itaufin) THEN
+c$OMP MASTER
+                   CALL dynredem1_p("restart.nc",0.0,
+     .                               vcov,ucov,teta,q,nqmx,masse,ps)
+c$OMP END MASTER
+                 ENDIF
                  forward = .TRUE.
                  GO TO  1
@@ -1423,6 +1484,7 @@
 
       END IF
-
+c$OMP MASTER
         call finalize_parallel
-	STOP
+c$OMP END MASTER
+	RETURN
       END
Index: /LMDZ4/trunk/libf/dyn3dpar/logic.h
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/logic.h	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/logic.h	(revision 774)
@@ -16,3 +16,4 @@
 
       INTEGER iflag_phys
+c$OMP THREADPRIVATE(/logic/)
 c-----------------------------------------------------------------------
Index: /LMDZ4/trunk/libf/dyn3dpar/mod_const_para.F90
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/mod_const_para.F90	(revision 774)
+++ /LMDZ4/trunk/libf/dyn3dpar/mod_const_para.F90	(revision 774)
@@ -0,0 +1,17 @@
+MODULE mod_const_mpi
+
+  INTEGER :: COMM_LMDZ
+  INTEGER :: MPI_REAL_LMDZ
+ 
+
+CONTAINS 
+
+  SUBROUTINE Init_const_mpi
+  IMPLICIT NONE
+    INCLUDE 'mpif.h'
+  
+    COMM_LMDZ=MPI_COMM_WORLD
+    MPI_REAL_LMDZ=MPI_REAL8
+  END SUBROUTINE Init_const_mpi
+
+END MODULE mod_const_mpi
Index: /LMDZ4/trunk/libf/dyn3dpar/mod_interface_dyn_phys.F90
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/mod_interface_dyn_phys.F90	(revision 774)
+++ /LMDZ4/trunk/libf/dyn3dpar/mod_interface_dyn_phys.F90	(revision 774)
@@ -0,0 +1,52 @@
+MODULE mod_interface_dyn_phys
+  INTEGER,SAVE,dimension(:),allocatable :: index_i
+  INTEGER,SAVE,dimension(:),allocatable :: index_j
+  
+  
+CONTAINS
+  
+  SUBROUTINE Init_interface_dyn_phys
+    USE mod_phys_lmdz_mpi_data
+    IMPLICIT NONE
+    include 'dimensions90.h'    
+    
+    INTEGER :: i,j,k
+    
+    ALLOCATE(index_i(klon_mpi))
+    ALLOCATE(index_j(klon_mpi))
+    
+    k=1
+    IF (is_north_pole) THEN
+      index_i(k)=1
+      index_j(k)=1
+      k=2
+    ELSE
+      DO i=ii_begin,iim
+	index_i(k)=i
+	index_j(k)=jj_begin
+	k=k+1
+       ENDDO
+    ENDIF
+    
+    DO j=jj_begin+1,jj_end-1
+      DO i=1,iim
+	index_i(k)=i
+	index_j(k)=j
+	k=k+1
+      ENDDO
+    ENDDO
+    
+    IF (is_south_pole) THEN
+      index_i(k)=1
+      index_j(k)=jj_end
+    ELSE
+      DO i=1,ii_end
+	index_i(k)=i
+	index_j(k)=jj_end
+	k=k+1
+       ENDDO
+    ENDIF
+  
+  END SUBROUTINE Init_interface_dyn_phys 
+
+END MODULE mod_interface_dyn_phys
Index: /LMDZ4/trunk/libf/dyn3dpar/temps.h
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/temps.h	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/temps.h	(revision 774)
@@ -13,4 +13,4 @@
       INTEGER*4 day_ini, day_end, annee_ref, day_ref
       REAL      dt
-
+c$OMP THREADPRIVATE(/temps/)
 !-----------------------------------------------------------------------
Index: /LMDZ4/trunk/libf/dyn3dpar/temps.inc
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/temps.inc	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/temps.inc	(revision 774)
@@ -14,4 +14,4 @@
       INTEGER*4 day_ini, day_end, annee_ref, day_ref
       REAL     dt
-
+!$OMP THREADPRIVATE(/temps/)
 !-----------------------------------------------------------------------
Index: /LMDZ4/trunk/libf/dyn3dpar/times.F90
===================================================================
--- /LMDZ4/trunk/libf/dyn3dpar/times.F90	(revision 773)
+++ /LMDZ4/trunk/libf/dyn3dpar/times.F90	(revision 774)
@@ -1,7 +1,6 @@
 module times
-  use parallel
   integer,private,save :: Last_Count=0
   real, private,save :: Last_cpuCount=0
-  logical, private,save :: AllTimer_IsActive=.true.
+  logical, private,save :: AllTimer_IsActive=.false.
   
   integer, parameter :: nb_timer = 4
@@ -26,4 +25,5 @@
   
   subroutine init_timer
+    use parallel
     implicit none
 #include "dimensions90.h"
@@ -101,4 +101,5 @@
 
   subroutine stop_timer(no_timer)
+    use parallel
     implicit none
     integer :: no_timer
@@ -126,5 +127,5 @@
 	V2=timer_table_sqr(jj_nb,no_timer,mpi_rank)
 	V=timer_table(jj_nb,no_timer,mpi_rank)
-	timer_delta(jj_nb,no_timer,mpi_rank)=sqrt(abs(V2-V*V/N)/(N-1)) 
+	timer_delta(jj_nb,no_timer,mpi_rank)=sqrt(ABS(V2-V*V/N)/(N-1)) 
       else
         timer_delta(jj_nb,no_timer,mpi_rank)=0
@@ -135,4 +136,5 @@
    
   subroutine allgather_timer
+    use parallel
     implicit none
     include 'mpif.h'
@@ -160,4 +162,5 @@
   
   subroutine allgather_timer_average
+    use parallel
     implicit none
     include 'mpif.h'
@@ -193,8 +196,9 @@
     integer :: count,count_rate,count_max
     
-    if (AllTimer_IsActive) then
-    call system_clock(count,count_rate,count_max)
-    call cpu_time(Last_cpuCount)
-    Last_Count=count
+    AllTimer_IsActive=.TRUE.
+    if (AllTimer_IsActive) then
+      call system_clock(count,count_rate,count_max)
+      call cpu_time(Last_cpuCount)
+      Last_Count=count
     endif
   end subroutine InitTime
