Index: LMDZ4/trunk/libf/phylmd/YOMCST2.h
===================================================================
--- LMDZ4/trunk/libf/phylmd/YOMCST2.h	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/YOMCST2.h	(revision 987)
@@ -9,4 +9,5 @@
      &               Supcrit1, Supcrit2,                                &
      &               choice,iflag_mix
+!$OMP THREADPRIVATE(/YOMCST2/)
 !    --------------------------------------------------------------------
 
Index: LMDZ4/trunk/libf/phylmd/add_phys_tend.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/add_phys_tend.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/add_phys_tend.F90	(revision 987)
@@ -38,5 +38,7 @@
 integer debug_level
 logical, save :: first=.true.
+!$OMP THREADPRIVATE(first)
 INTEGER, SAVE :: itap
+!$OMP THREADPRIVATE(itap)
 !======================================================================
 ! Initialisations
Index: LMDZ4/trunk/libf/phylmd/calltherm.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/calltherm.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/calltherm.F90	(revision 987)
@@ -86,4 +86,5 @@
       integer i,k
       logical, save :: first=.true.
+!$OMP THREADPRIVATE(first)
 !********************************************************
       if (first) then
Index: LMDZ4/trunk/libf/phylmd/comsoil.h
===================================================================
--- LMDZ4/trunk/libf/phylmd/comsoil.h	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/comsoil.h	(revision 987)
@@ -5,2 +5,3 @@
       common /comsoil/inertie_sol,inertie_sno,inertie_ice
       real inertie_sol,inertie_sno,inertie_ice
+!$OMP THREADPRIVATE(/comsoil/)
Index: LMDZ4/trunk/libf/phylmd/concvl.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/concvl.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/concvl.F	(revision 987)
@@ -151,8 +151,11 @@
       SAVE      h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot
      $        , h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot
+c$OMP THREADPRIVATE(h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot)
+c$OMP THREADPRIVATE(h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot)
       REAL      d_h_vcol, d_h_dair, d_qt, d_qw, d_ql, d_qs, d_ec
       REAL      d_h_vcol_phy
       REAL      fs_bound, fq_bound
       SAVE      d_h_vcol_phy
+c$OMP THREADPRIVATE(d_h_vcol_phy)
       REAL      zero_v(klon)
       CHARACTER*15 ztit
@@ -160,7 +163,9 @@
       SAVE      ip_ebil
       DATA      ip_ebil/2/
+c$OMP THREADPRIVATE(ip_ebil)
       INTEGER   if_ebil ! level for energy conserv. dignostics
       SAVE      if_ebil
       DATA      if_ebil/2/
+c$OMP THREADPRIVATE(if_ebil)
 c+jld ec_conser
       REAL d_t_ec(klon,klev)    ! tendance du a la conersion Ec -> E thermique
@@ -170,5 +175,7 @@
       INTEGER nloc
       logical, save :: first=.true.
-      INTEGER, SAVE :: itap, igout 
+c$OMP THREADPRIVATE(first)
+      INTEGER, SAVE :: itap, igout
+c$OMP THREADPRIVATE(itap, igout)
 c
 #include "YOMCST.h"
@@ -229,7 +236,7 @@
 C===========================================================================
 C
-c$$$         open (56,file='supcrit.data')
-c$$$         read (56,*) Supcrit1, Supcrit2
-c$$$         close (56)
+cc$$$         open (56,file='supcrit.data')
+cc$$$         read (56,*) Supcrit1, Supcrit2
+cc$$$         close (56)
 c
          print*, 'supcrit1, supcrit2' ,supcrit1, supcrit2
Index: LMDZ4/trunk/libf/phylmd/cpl_mod.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/cpl_mod.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/cpl_mod.F90	(revision 987)
@@ -88,4 +88,9 @@
   !$OMP THREADPRIVATE(cpl_windsp2D)
   
+! variable for OPENMP parallelisation
+
+  INTEGER,ALLOCATABLE,DIMENSION(:),SAVE :: knon_omp
+  REAL,ALLOCATABLE,DIMENSION(:,:),SAVE ::  buffer_omp
+  
 
 CONTAINS
@@ -204,5 +209,7 @@
     idtime = INT(dtime)
 #ifdef CPP_COUPLE
+!$OMP MASTER    
     CALL inicma
+!$OMP END MASTER
 #endif
 
@@ -252,4 +259,12 @@
     ENDIF    ! is_sequential
     
+! OPENMP Initialization
+
+!$OMP MASTER
+  ALLOCATE(knon_omp(0:omp_size-1)) 
+  ALLOCATE(buffer_omp(klon_mpi,0:omp_size-1))       
+!$OMP END MASTER
+!$OMP BARRIER
+    
   END SUBROUTINE cpl_init
   
@@ -293,5 +308,7 @@
 #ifdef CPP_COUPLE
     il_time_secs=(itime-1)*dtime
+!$OMP MASTER
     CALL fromcpl(il_time_secs, tab_read_flds)
+!$OMP END MASTER
 #endif
     
@@ -305,9 +322,21 @@
     ENDIF
 
+!$OMP MASTER
+
 ! Save each field in a 2D array. 
-    read_sst(:,:)     = tab_read_flds(:,:,1)  ! Sea surface temperature
-    read_sic(:,:)     = tab_read_flds(:,:,2)  ! Sea ice concentration
-    read_alb_sic(:,:) = tab_read_flds(:,:,3)  ! Albedo at sea ice
-    read_sit(:,:)     = tab_read_flds(:,:,4)  ! Sea ice temperature
+
+    IF (OPA_version=='OPA9') THEN
+      read_sst(:,:)     = tab_read_flds(:,:,1)  ! Sea surface temperature
+      read_sic(:,:)     = tab_read_flds(:,:,2)  ! Sea ice concentration
+      read_sit(:,:)     = tab_read_flds(:,:,3)  ! Sea ice temperature
+      read_alb_sic(:,:) = tab_read_flds(:,:,4)  ! Albedo at sea ice
+    ELSE IF (OPA_version=='OPA8') THEN
+      read_sst(:,:)     = tab_read_flds(:,:,1)  ! Sea surface temperature
+      read_sic(:,:)     = tab_read_flds(:,:,2)  ! Sea ice concentration
+      read_alb_sic(:,:) = tab_read_flds(:,:,3)  ! Albedo at sea ice
+      read_sit(:,:)     = tab_read_flds(:,:,4)  ! Sea ice temperature
+    ELSE
+      STOP 'Bad OPA version for coupled model'
+    ENDIF
 
 !*************************************************************************************
@@ -332,5 +361,6 @@
        ENDDO
     ENDDO
-    
+!$OMP END MASTER
+
 !*************************************************************************************
 !  Transform seaice fraction, read_sic into pctsrf_sav
@@ -824,6 +854,8 @@
 !
 !*************************************************************************************
+!$OMP MASTER
     rriv2D(:,:) = 0.0
     rcoa2D(:,:) = 0.0
+!$OMP END MASTER
     CALL gath2cpl(rriv_in, rriv2D, knon, knindex)
     CALL gath2cpl(rcoa_in, rcoa2D, knon, knindex)
@@ -834,6 +866,8 @@
 !*************************************************************************************
     IF (MOD(itime, nexca) == 1) THEN
+!$OMP MASTER
        cpl_rriv2D(:,:) = 0.0
        cpl_rcoa2D(:,:) = 0.0
+!$OMP END MASTER
     ENDIF
 
@@ -842,6 +876,8 @@
 !
 !*************************************************************************************    
+!$OMP MASTER
     cpl_rriv2D(:,:) = cpl_rriv2D(:,:) + rriv2D(:,:) / FLOAT(nexca)
     cpl_rcoa2D(:,:) = cpl_rcoa2D(:,:) + rcoa2D(:,:) / FLOAT(nexca)
+!$OMP END MASTER
 
   END SUBROUTINE cpl_send_land_fields
@@ -874,5 +910,7 @@
 !
 !*************************************************************************************
+!$OMP MASTER
     rlic2D(:,:) = 0.0
+!$OMP END MASTER
     CALL gath2cpl(rlic_in, rlic2D, knon, knindex)
 
@@ -882,5 +920,7 @@
 !*************************************************************************************
     IF (MOD(itime, nexca) == 1) THEN
+!$OMP MASTER
        cpl_rlic2D(:,:) = 0.0
+!$OMP END MASTER
     ENDIF
 
@@ -889,5 +929,7 @@
 !
 !*************************************************************************************    
+!$OMP MASTER
     cpl_rlic2D(:,:) = cpl_rlic2D(:,:) + rlic2D(:,:) / FLOAT(nexca)
+!$OMP END MASTER
 
   END SUBROUTINE cpl_send_landice_fields
@@ -935,4 +977,6 @@
 ! Table with all fields to send to coupler
     REAL, DIMENSION(iim, jj_nb, jpflda2o1+jpflda2o2)     :: tab_flds
+    REAL, DIMENSION(klon_mpi)                            :: rlon_mpi, rlat_mpi
+
 #ifdef CPP_PARA
     INCLUDE 'mpif.h'
@@ -950,15 +994,32 @@
 !
 !*************************************************************************************
-    tab_flds(:,:,7)  = cpl_windsp2D(:,:)
-    tab_flds(:,:,8)  = cpl_sols2D(:,:,2)
-    tab_flds(:,:,9)  = cpl_sols2D(:,:,1)
-    tab_flds(:,:,10) = cpl_nsol2D(:,:,2)
-    tab_flds(:,:,11) = cpl_nsol2D(:,:,1)
-    tab_flds(:,:,12) = cpl_fder2D(:,:,2)
-    tab_flds(:,:,13) = cpl_evap2D(:,:,2)
-    tab_flds(:,:,14) = cpl_evap2D(:,:,1)
-    tab_flds(:,:,17) = cpl_rcoa2D(:,:)
-    tab_flds(:,:,18) = cpl_rriv2D(:,:)
-    
+!! AC >>
+
+!$OMP MASTER
+    IF (OPA_version=='OPA9') THEN
+      tab_flds(:,:,7)  = cpl_windsp2D(:,:)
+      tab_flds(:,:,14) = cpl_sols2D(:,:,2)
+      tab_flds(:,:,12) = cpl_sols2D(:,:,1)
+      tab_flds(:,:,15) = cpl_nsol2D(:,:,2)
+      tab_flds(:,:,13) = cpl_nsol2D(:,:,1)
+      tab_flds(:,:,16) = cpl_fder2D(:,:,2)
+      tab_flds(:,:,11) = cpl_evap2D(:,:,2)
+      tab_flds(:,:,18) = cpl_rriv2D(:,:)
+      tab_flds(:,:,19) = cpl_rcoa2D(:,:)
+    ELSE IF (OPA_version=='OPA8') THEN
+      tab_flds(:,:,7)  = cpl_windsp2D(:,:)
+      tab_flds(:,:,8)  = cpl_sols2D(:,:,2)
+      tab_flds(:,:,9)  = cpl_sols2D(:,:,1)
+      tab_flds(:,:,10) = cpl_nsol2D(:,:,2)
+      tab_flds(:,:,11) = cpl_nsol2D(:,:,1)
+      tab_flds(:,:,12) = cpl_fder2D(:,:,2)
+      tab_flds(:,:,13) = cpl_evap2D(:,:,2)
+      tab_flds(:,:,14) = cpl_evap2D(:,:,1)
+      tab_flds(:,:,17) = cpl_rcoa2D(:,:)
+      tab_flds(:,:,18) = cpl_rriv2D(:,:)
+    ELSE
+      STOP 'Bad OPA version for coupled model'
+    ENDIF
+
 !*************************************************************************************
 ! Transform the fraction of sub-surfaces from 1D to 2D array
@@ -966,4 +1027,6 @@
 !*************************************************************************************
     pctsrf2D(:,:,:) = 0.
+!$OMP END MASTER
+
     CALL gath2cpl(pctsrf(:,is_oce), pctsrf2D(:,:,is_oce), klon, unity)
     CALL gath2cpl(pctsrf(:,is_sic), pctsrf2D(:,:,is_sic), klon, unity)
@@ -975,38 +1038,46 @@
 ! 
 !*************************************************************************************      
-    DO j = 1, jj_nb
-       tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:iim,j), &
-            pctsrf2D(1:iim,j,is_lic)) / REAL(iim)
-    ENDDO
-    
-    
-    IF (is_parallel) THEN
-       IF (.NOT. is_north_pole) THEN
+    IF (is_omp_root) THEN
+
+      DO j = 1, jj_nb
+         tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:iim,j), &
+              pctsrf2D(1:iim,j,is_lic)) / REAL(iim)
+      ENDDO
+    
+    
+      IF (is_parallel) THEN
+         IF (.NOT. is_north_pole) THEN
 #ifdef CPP_PARA
-          CALL MPI_RECV(Up,1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,status,error)
-          CALL MPI_SEND(tmp_calv(1,1),1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,error)
+            CALL MPI_RECV(Up,1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,status,error)
+            CALL MPI_SEND(tmp_calv(1,1),1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,error)
 #endif
-       ENDIF
+         ENDIF
        
-       IF (.NOT. is_south_pole) THEN
+         IF (.NOT. is_south_pole) THEN
 #ifdef CPP_PARA
-          CALL MPI_SEND(tmp_calv(1,jj_nb),1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,error)
-          CALL MPI_RECV(down,1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,status,error)
+            CALL MPI_SEND(tmp_calv(1,jj_nb),1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,error)
+            CALL MPI_RECV(down,1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,status,error)
 #endif
-       ENDIF
+         ENDIF
        
-       IF (.NOT. is_north_pole .AND. ii_begin /=1) THEN
-          Up=Up+tmp_calv(iim,1)
-          tmp_calv(:,1)=Up
-       ENDIF
+         IF (.NOT. is_north_pole .AND. ii_begin /=1) THEN
+            Up=Up+tmp_calv(iim,1)
+            tmp_calv(:,1)=Up
+         ENDIF
        
-       IF (.NOT. is_south_pole .AND. ii_end /= iim) THEN
-          Down=Down+tmp_calv(1,jj_nb)
-          tmp_calv(:,jj_nb)=Down	 
-       ENDIF
-    ENDIF
-      
-
-    tab_flds(:,:,19) = tmp_calv(:,:)
+         IF (.NOT. is_south_pole .AND. ii_end /= iim) THEN
+            Down=Down+tmp_calv(1,jj_nb)
+            tmp_calv(:,jj_nb)=Down	 
+         ENDIF
+      ENDIF
+        
+      IF (OPA_version=='OPA9') THEN
+        tab_flds(:,:,17) = tmp_calv(:,:)
+      ELSE IF (OPA_version=='OPA8') THEN
+        tab_flds(:,:,17) = tmp_calv(:,:)
+      ELSE
+        STOP 'Bad OPA version for coupled model'
+      ENDIF
+
 
 !*************************************************************************************
@@ -1018,25 +1089,53 @@
 !
 !*************************************************************************************    
-    tab_flds(:,:,15) = 0.0
-    tab_flds(:,:,16) = 0.0
-    tmp_taux(:,:)    = 0.0
-    tmp_tauy(:,:)    = 0.0
-    
-
-    ! fraction oce+seaice
-    deno =  pctsrf2D(:,:,is_oce) + pctsrf2D(:,:,is_sic) 
-    ! For all valid grid cells containing some fraction of ocean or sea-ice
-    WHERE ( deno(:,:) /= 0 )
-       tab_flds(:,:,15) = cpl_rain2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
-            cpl_rain2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
-       tab_flds(:,:,16) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
-            cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+      ! fraction oce+seaice
+      deno =  pctsrf2D(:,:,is_oce) + pctsrf2D(:,:,is_sic) 
+
+      IF (OPA_version=='OPA9') THEN
+
+        tab_flds(:,:,10) = 0.0
+        tmp_taux(:,:)    = 0.0
+        tmp_tauy(:,:)    = 0.0
+        ! fraction oce+seaice
+        ! For all valid grid cells containing some fraction of ocean or sea-ice
+        WHERE ( deno(:,:) /= 0 )
+           tab_flds(:,:,10) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                              cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+
+           tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                      cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+           tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                      cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+        ENDWHERE
+        tab_flds(:,:,8) = (cpl_evap2D(:,:,1) - ( cpl_rain2D(:,:,1) + cpl_snow2D(:,:,1)))
+        tab_flds(:,:,9) = (cpl_evap2D(:,:,2) - ( cpl_rain2D(:,:,2) + cpl_snow2D(:,:,2)))
+
+      ELSE IF (OPA_version=='OPA8') THEN
+
+        tab_flds(:,:,15) = 0.0
+        tab_flds(:,:,16) = 0.0
+        tmp_taux(:,:)    = 0.0
+        tmp_tauy(:,:)    = 0.0
+        ! For all valid grid cells containing some fraction of ocean or sea-ice
+        WHERE ( deno(:,:) /= 0 )
+           tab_flds(:,:,15) = cpl_rain2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                              cpl_rain2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+           tab_flds(:,:,16) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                              cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
        
-       tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
-            cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
-       tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
-            cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
-    ENDWHERE
-
+           tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                      cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+           tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                      cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+        ENDWHERE
+
+      ELSE
+        STOP 'Bad OPA version for coupled model'
+      ENDIF
+    
+    ENDIF ! is_omp_root  
+
+
+! AC <<
 !*************************************************************************************
 ! Transform the wind components from local atmospheric 2D coordinates to geocentric 
@@ -1046,7 +1145,12 @@
 
 ! Transform the longitudes and latitudes on 2D arrays
-    CALL Grid1DTo2D_mpi(rlon,tmp_lon)
-    CALL Grid1DTo2D_mpi(rlat,tmp_lat)
-    
+    
+    CALL gather_omp(rlon,rlon_mpi)
+    CALL gather_omp(rlat,rlat_mpi)
+!$OMP MASTER
+    CALL Grid1DTo2D_mpi(rlon_mpi,tmp_lon)
+    CALL Grid1DTo2D_mpi(rlat_mpi,tmp_lat)
+!$OMP END MASTER    
+
     IF (is_sequential) THEN
        IF (is_north_pole) tmp_lon(:,1)     = tmp_lon(:,2)
@@ -1066,4 +1170,5 @@
 ! Transform the wind from local atmospheric 2D coordinates to geocentric 
 ! 3D coordinates 
+!$OMP MASTER
     CALL atm2geo (iim, jj_nb, tmp_taux, tmp_tauy, tmp_lon, tmp_lat, &
          tab_flds(:,:,1), tab_flds(:,:,2), tab_flds(:,:,3) )
@@ -1072,4 +1177,5 @@
     tab_flds(:,:,5)  = tab_flds(:,:,2)
     tab_flds(:,:,6)  = tab_flds(:,:,3)
+!$OMP END MASTER
 
 !*************************************************************************************
@@ -1107,5 +1213,7 @@
 #ifdef CPP_COUPLE
     il_time_secs=(itime-1)*dtime
+!$OMP MASTER
     CALL intocpl(il_time_secs, lafin, tab_flds(:,:,:))
+!$OMP END MASTER
 #endif
 
@@ -1131,4 +1239,5 @@
 !
   SUBROUTINE cpl2gath(champ_in, champ_out, knon, knindex)
+  USE mod_phys_lmdz_para
 ! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
 ! au coupleur.
@@ -1151,21 +1260,29 @@
 
 ! Output
-    REAL, DIMENSION(klon), INTENT(OUT)        :: champ_out
+    REAL, DIMENSION(klon_mpi), INTENT(OUT)        :: champ_out
 
 ! Local
     INTEGER                                   :: i, ig
-    REAL, DIMENSION(klon)                     :: tamp
-
-!*************************************************************************************
-!
+    REAL, DIMENSION(klon_mpi)                 :: temp_mpi
+    REAL, DIMENSION(klon)                     :: temp_omp
+
+!*************************************************************************************
+!
+    
+
 ! Transform from 2 dimensions (iim,jj_nb) to 1 dimension (klon)
-    CALL Grid2Dto1D_mpi(champ_in,tamp)
-
+!$OMP MASTER 
+    CALL Grid2Dto1D_mpi(champ_in,temp_mpi)
+!$OMP END MASTER
+
+    CALL scatter_omp(temp_mpi,temp_omp)
+    
 ! Compress from klon to knon
     DO i = 1, knon
        ig = knindex(i)
-       champ_out(i) = tamp(ig)
+       champ_out(i) = temp_omp(ig)
     ENDDO
-
+  
+   
   END SUBROUTINE cpl2gath
 !
@@ -1173,4 +1290,5 @@
 !
   SUBROUTINE gath2cpl(champ_in, champ_out, knon, knindex)
+  USE mod_phys_lmdz_para
 ! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
 ! au coupleur.
@@ -1199,20 +1317,24 @@
 !*************************************************************************************
     INTEGER                                :: i, ig
-    REAL, DIMENSION(klon)                  :: tamp
-
+    REAL, DIMENSION(klon)                  :: temp_omp
+    REAL, DIMENSION(klon_mpi)              :: temp_mpi
 !*************************************************************************************
 
 ! Decompress from knon to klon
-    tamp = 0.
+    temp_omp = 0.
     DO i = 1, knon
        ig = knindex(i)
-       tamp(ig) = champ_in(i)
+       temp_omp(ig) = champ_in(i)
     ENDDO
 
 ! Transform from 1 dimension (klon) to 2 dimensions (iim,jj_nb)
-    CALL Grid1Dto2D_mpi(tamp,champ_out)
-    
-    IF (is_north_pole) champ_out(:,1)=tamp(1)
-    IF (is_south_pole) champ_out(:,jj_nb)=tamp(klon)
+    CALL gather_omp(temp_omp,temp_mpi)
+
+!$OMP MASTER    
+    CALL Grid1Dto2D_mpi(temp_mpi,champ_out)
+    
+    IF (is_north_pole) champ_out(:,1)=temp_mpi(1)
+    IF (is_south_pole) champ_out(:,jj_nb)=temp_mpi(klon)
+!$OMP END MASTER
     
   END SUBROUTINE gath2cpl
Index: LMDZ4/trunk/libf/phylmd/cv3_inip.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/cv3_inip.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/cv3_inip.F	(revision 987)
@@ -52,16 +52,16 @@
 C
 
-c$$$        open(57,file='parameter_mix.data')
-c$$$
-c$$$        read(57,*) iflag_mix, scut
-c$$$        read(57,*)
-c$$$        if(iflag_mix .gt. 0) then
-c$$$	      read(57,*) qqa1, qqa2
-c$$$              read(57,*)
-c$$$              read(57,*) gammas, Fmax
-c$$$              read(57,*)
-c$$$              read(57,*) alphas
-c$$$         endif
-c$$$	 close(57)
+cc$$$        open(57,file='parameter_mix.data')
+cc$$$
+cc$$$        read(57,*) iflag_mix, scut
+cc$$$        read(57,*)
+cc$$$        if(iflag_mix .gt. 0) then
+cc$$$	      read(57,*) qqa1, qqa2
+cc$$$              read(57,*)
+cc$$$              read(57,*) gammas, Fmax
+cc$$$              read(57,*)
+cc$$$              read(57,*) alphas
+cc$$$         endif
+cc$$$	 close(57)
 
 c
Index: LMDZ4/trunk/libf/phylmd/cv3param.h
===================================================================
--- LMDZ4/trunk/libf/phylmd/cv3param.h	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/cv3param.h	(revision 987)
@@ -22,3 +22,4 @@
      :                ,dtovsh, dpbase, dttrig
      :                ,dtcrit, tau, beta, alpha, alpha1, delta, betad
+!$OMP THREADPRIVATE(/cv3param/)
 
Index: LMDZ4/trunk/libf/phylmd/cva_driver.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/cva_driver.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/cva_driver.F	(revision 987)
@@ -308,4 +308,5 @@
       logical ok_inhib  ! True => possible inhibition of convection by dryness
       logical, save :: debut=.true. 
+c$OMP THREADPRIVATE(debut)
 
       real plcl1(klon)
@@ -412,4 +413,5 @@
       real hnk(nloc),unk(nloc),vnk(nloc)
       logical, save :: first=.true.
+c$OMP THREADPRIVATE(first)
 
 c
Index: LMDZ4/trunk/libf/phylmd/hgardfou.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/hgardfou.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/hgardfou.F	(revision 987)
@@ -23,4 +23,6 @@
       SAVE firstcall
       DATA firstcall /.TRUE./
+c$OMP THREADPRIVATE(firstcall)
+
       IF (firstcall) THEN
          PRINT*, 'hgardfou garantit la temperature dans [100,370] K'
Index: LMDZ4/trunk/libf/phylmd/inifis.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/inifis.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/inifis.F	(revision 987)
@@ -7,5 +7,5 @@
      $           plat,plon,parea,
      $           prad,pg,pr,pcpp)
-      use dimphy
+      USE dimphy
       IMPLICIT NONE
 c
Index: LMDZ4/trunk/libf/phylmd/mod_phys_lmdz_transfert_para.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/mod_phys_lmdz_transfert_para.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/mod_phys_lmdz_transfert_para.F90	(revision 987)
@@ -276,19 +276,11 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(Varout,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      INTEGER,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
-
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
   END SUBROUTINE scatter_i1
 
@@ -301,18 +293,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(Varout,2),SIZE(Varout,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      INTEGER,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
     
   END SUBROUTINE scatter_i2
@@ -326,18 +310,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      INTEGER,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
     
   END SUBROUTINE scatter_i3
@@ -369,18 +345,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(Varout,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      REAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
     
   END SUBROUTINE scatter_r1
@@ -394,18 +362,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(Varout,2),SIZE(Varout,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      REAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
     
   END SUBROUTINE scatter_r2
@@ -419,18 +379,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      REAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
     
   END SUBROUTINE scatter_r3
@@ -463,18 +415,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(Varout,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      LOGICAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
     
   END SUBROUTINE scatter_l1
@@ -488,19 +432,11 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(Varout,2),SIZE(Varout,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      LOGICAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
-
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
   END SUBROUTINE scatter_l2
 
@@ -513,18 +449,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      LOGICAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-!$OMP MASTER
-        CALL scatter_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-        CALL scatter_omp(Var_tmp,Varout)
-    END SUBROUTINE body
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
     
   END SUBROUTINE scatter_l3
@@ -562,19 +490,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      INTEGER,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,Varout)
+!$OMP END MASTER
   
   END SUBROUTINE gather_i1
@@ -588,19 +507,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      INTEGER,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_i2
@@ -614,19 +524,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      INTEGER,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_i3
@@ -659,19 +560,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      REAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_r1
@@ -685,19 +577,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      REAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_r2
@@ -711,19 +594,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      REAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_r3
@@ -756,19 +630,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      LOGICAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_l1
@@ -782,19 +647,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      LOGICAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_l2
@@ -808,19 +664,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      LOGICAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather_mpi(Var_tmp,Varout)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE gather_l3
@@ -858,19 +705,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      INTEGER,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_i1
@@ -884,19 +722,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2),SIZE(VarOut,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      INTEGER,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_i2  
@@ -910,19 +739,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      INTEGER,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_i3
@@ -955,19 +775,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      REAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_r1
@@ -981,19 +792,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2),SIZE(VarOut,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      REAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_r2  
@@ -1007,19 +809,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      REAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_r3
@@ -1053,19 +846,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      LOGICAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_l1
@@ -1079,19 +863,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2),SIZE(VarOut,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      LOGICAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_l2  
@@ -1105,19 +880,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
 
-    CALL body(VarIn,VarOut,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      LOGICAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
 !$OMP MASTER    
-      CALL scatter2D_mpi(VarIn,Var_tmp)
-!$OMP END MASTER
-      CALL scatter_omp(Var_tmp,VarOut)
-
-    END SUBROUTINE body
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
 
   END SUBROUTINE scatter2D_l3
@@ -1150,22 +916,14 @@
     USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
     IMPLICIT NONE
+  
     INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
     INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      INTEGER,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_i1
@@ -1179,19 +937,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      INTEGER,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_i2
@@ -1205,19 +954,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      INTEGER,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_i3
@@ -1250,19 +990,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      REAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_r1
@@ -1276,19 +1007,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      REAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_r2
@@ -1302,19 +1024,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      REAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_r3
@@ -1347,19 +1060,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      LOGICAL,DIMENSION(klon_mpi,s1) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_l1
@@ -1373,19 +1077,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      LOGICAL,DIMENSION(klon_mpi,s1,s2) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_l2
@@ -1399,19 +1094,10 @@
     LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      LOGICAL,DIMENSION(klon_mpi,s1,s2,s3) :: Var_tmp
-      
-      CALL gather_omp(VarIn,Var_tmp)
-!$OMP MASTER
-      CALL gather2D_mpi(Var_tmp,VarOut)
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
 !$OMP END MASTER    
-
-    END SUBROUTINE body
 
   END SUBROUTINE gather2D_l3
@@ -1446,19 +1132,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      INTEGER,DIMENSION(s1) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    INTEGER,DIMENSION(SIZE(VarIn))   :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE reduce_sum_i1  
@@ -1471,19 +1148,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1),SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      INTEGER,DIMENSION(s1,s2) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2)) :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE reduce_sum_i2  
@@ -1496,19 +1164,10 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      INTEGER,DIMENSION(s1,s2,s3) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE reduce_sum_i3  
@@ -1521,20 +1180,11 @@
     INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3,s4)
-      INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3,s4
-      INTEGER,DIMENSION(s1,s2,s3,s4) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
-   
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
   END SUBROUTINE reduce_sum_i4  
 
@@ -1564,19 +1214,10 @@
     REAL,INTENT(OUT),DIMENSION(:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1)
-      REAL,INTENT(IN),DIMENSION(:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:) :: VarOut
-      INTEGER,INTENT(IN) :: s1
-      REAL,DIMENSION(s1) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    REAL,DIMENSION(SIZE(VarIn))   :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE reduce_sum_r1  
@@ -1589,19 +1230,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1),SIZE(VarIn,2))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2)
-      REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2
-      REAL,DIMENSION(s1,s2) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2)) :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE reduce_sum_r2  
@@ -1614,19 +1246,10 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3)
-      REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3
-      REAL,DIMENSION(s1,s2,s3) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
   
   END SUBROUTINE reduce_sum_r3  
@@ -1639,20 +1262,11 @@
     REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
     
-    CALL body(VarIn,VarOut,SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))
-    
-  CONTAINS
-    SUBROUTINE body(VarIn,VarOut,s1,s2,s3,s4)
-      REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
-      REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
-      INTEGER,INTENT(IN) :: s1,s2,s3,s4
-      REAL,DIMENSION(s1,s2,s3,s4) :: Var_tmp
-      
-      CALL reduce_sum_omp(VarIn,Var_tmp)
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
 !$OMP MASTER      
-      CALL reduce_sum_mpi(Var_tmp,VarOut)
-!$OMP END MASTER
-
-    END SUBROUTINE body
-   
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
   END SUBROUTINE reduce_sum_r4  
 
Index: LMDZ4/trunk/libf/phylmd/mod_surf_para.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/mod_surf_para.F90	(revision 987)
+++ LMDZ4/trunk/libf/phylmd/mod_surf_para.F90	(revision 987)
@@ -0,0 +1,350 @@
+MODULE mod_surf_para
+  IMPLICIT NONE
+  
+  INTERFACE gather_surf
+    MODULE PROCEDURE gather_surf_i,gather_surf_r
+  END INTERFACE gather_surf
+  
+  INTERFACE gather_surf_omp
+    MODULE PROCEDURE gather_surf_omp_i,gather_surf_omp_r
+  END INTERFACE gather_surf_omp
+
+  INTERFACE gather_surf_mpi
+    MODULE PROCEDURE gather_surf_mpi_i,gather_surf_mpi_r
+  END INTERFACE gather_surf_mpi
+
+  INTERFACE scatter_surf
+    MODULE PROCEDURE scatter_surf_i,scatter_surf_r
+  END INTERFACE scatter_surf
+  
+  INTERFACE scatter_surf_omp
+    MODULE PROCEDURE scatter_surf_omp_i,scatter_surf_omp_r
+  END INTERFACE scatter_surf_omp
+
+  INTERFACE scatter_surf_mpi
+    MODULE PROCEDURE scatter_surf_mpi_i,scatter_surf_mpi_r
+  END INTERFACE scatter_surf_mpi
+  
+  
+  INTEGER,SAVE             :: knon_omp
+  INTEGER,SAVE             :: knon_omp_begin
+  INTEGER,SAVE             :: knon_omp_end
+!$OMP THREADPRIVATE(knon_omp,knon_omp_begin,knon_omp_end)
+  INTEGER,ALLOCATABLE,SAVE :: knon_omp_para(:)
+  INTEGER,ALLOCATABLE,SAVE :: knon_omp_begin_para(:)
+  INTEGER,ALLOCATABLE,SAVE :: knon_omp_end_para(:)
+  
+  INTEGER,SAVE             :: knon_mpi
+  INTEGER,ALLOCATABLE,SAVE :: knon_mpi_para(:)
+  INTEGER,ALLOCATABLE,SAVE :: knon_mpi_begin_para(:)
+  INTEGER,ALLOCATABLE,SAVE :: knon_mpi_end_para(:)
+  
+  INTEGER,SAVE             :: knon_glo
+  INTEGER,SAVE,ALLOCATABLE :: knon_glo_para(:)  
+  INTEGER,ALLOCATABLE,SAVE :: knon_glo_begin_para(:)
+  INTEGER,ALLOCATABLE,SAVE :: knon_glo_end_para(:)
+  
+  
+CONTAINS
+
+  SUBROUTINE Init_surf_para(knon)
+  USE mod_phys_lmdz_para, mpi_rank_root=>mpi_root
+#ifdef CPP_PARA
+  INCLUDE 'mpif.h'
+#endif
+    INTEGER :: knon
+    INTEGER :: i,ierr
+    
+    knon_omp=knon
+    IF (is_omp_root) THEN
+      ALLOCATE(knon_omp_para(0:omp_size-1))
+      ALLOCATE(knon_omp_begin_para(0:omp_size-1))
+      ALLOCATE(knon_omp_end_para(0:omp_size-1))
+    ENDIF
+!$OMP BARRIER
+    knon_omp_para(omp_rank)=knon
+!$OMP BARRIER
+    IF (is_omp_root) THEN 
+      knon_omp_begin_para(0)=1
+      knon_omp_end_para(0)=knon_omp_para(0)
+      DO i=1,omp_size-1
+        knon_omp_begin_para(i)=knon_omp_end_para(i-1)+1
+        knon_omp_end_para(i)=knon_omp_begin_para(i)+knon_omp_para(i)-1
+      ENDDO
+    ENDIF 
+!$OMP BARRIER
+    knon_omp_begin=knon_omp_begin_para(omp_rank)
+    knon_omp_end=knon_omp_end_para(omp_rank)
+!$OMP BARRIER    
+    IF (is_omp_root) THEN
+      knon_mpi=sum(knon_omp_para)
+      ALLOCATE(knon_mpi_para(0:mpi_size-1))
+      ALLOCATE(knon_mpi_begin_para(0:mpi_size-1))
+      ALLOCATE(knon_mpi_end_para(0:mpi_size-1))
+      
+      ALLOCATE(knon_glo_para(0:mpi_size*omp_size-1))
+      ALLOCATE(knon_glo_begin_para(0:mpi_size*omp_size-1))
+      ALLOCATE(knon_glo_end_para(0:mpi_size*omp_size-1))
+      
+      IF (is_ok_mpi) THEN
+#ifdef CPP_PARA
+        CALL MPI_ALLGather(knon_mpi,1,MPI_INTEGER,knon_mpi_para,1,MPI_INTEGER,COMM_LMDZ_PHY,ierr)
+        CALL MPI_ALLGather(knon_omp_para,omp_size,MPI_INTEGER,knon_glo_para,omp_size,MPI_INTEGER,COMM_LMDZ_PHY,ierr)
+#endif
+      ELSE
+        knon_mpi_para(:)=knon_mpi
+        knon_glo_para(:)=knon_omp_para(:)
+      ENDIF     
+      
+      knon_glo=sum(knon_mpi_para(:))
+      
+      knon_mpi_begin_para(0)=1
+      knon_mpi_end_para(0)=knon_mpi_para(0)
+      DO i=1,mpi_size-1
+        knon_mpi_begin_para(i)=knon_mpi_end_para(i-1)+1
+        knon_mpi_end_para(i)=knon_mpi_begin_para(i)+knon_mpi_para(i)-1
+      ENDDO
+      
+      knon_glo_begin_para(0)=1
+      knon_glo_end_para(0)=knon_glo_para(0)
+      DO i=1,mpi_size*omp_size-1
+        knon_glo_begin_para(i)=knon_glo_end_para(i-1)
+        knon_glo_end_para(i)= knon_glo_begin_para(i)+knon_glo_para(i)-1
+      ENDDO
+   ENDIF
+!$OMP BARRIER
+
+  END SUBROUTINE Init_surf_para
+
+ 
+  SUBROUTINE Finalize_surf_para
+  USE mod_phys_lmdz_para
+
+!$OMP BARRIER   
+   IF (is_omp_root) THEN
+      DEALLOCATE(knon_omp_para)
+      DEALLOCATE(knon_omp_begin_para)
+      DEALLOCATE(knon_omp_end_para)
+      DEALLOCATE(knon_mpi_para)
+      DEALLOCATE(knon_mpi_begin_para)
+      DEALLOCATE(knon_mpi_end_para)
+      DEALLOCATE(knon_glo_para)  
+      DEALLOCATE(knon_glo_begin_para)
+      DEALLOCATE(knon_glo_end_para)
+    ENDIF
+    
+  END SUBROUTINE Finalize_surf_para
+  
+  
+  SUBROUTINE gather_surf_i(FieldIn, FieldOut)
+  USE mod_phys_lmdz_para
+    INTEGER :: FieldIn(:)
+    INTEGER :: FieldOut(:)
+    INTEGER :: FieldTmp(knon_mpi)
+    
+    CALL gather_surf_omp_i(FieldIn,FieldTmp)
+    IF (is_omp_root) CALL gather_surf_mpi_i(FieldTmp,FieldOut)
+    
+  END SUBROUTINE gather_surf_i
+
+
+  SUBROUTINE gather_surf_omp_i(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para
+    INTEGER :: FieldIn(:)
+    INTEGER :: FieldOut(:)
+  
+    INTEGER,SAVE,ALLOCATABLE :: Field_tmp(:)
+    
+    IF (is_omp_root) ALLOCATE(Field_tmp(knon_mpi))
+!$OMP BARRIER
+    Field_tmp(knon_omp_begin:knon_omp_end)=FieldIn(:)
+!$OMP BARRIER        
+    IF (is_omp_root) FieldOut(:)=Field_tmp(:)
+!$OMP BARRIER
+    IF (is_omp_root) DEALLOCATE(Field_tmp)
+    
+  END SUBROUTINE  gather_surf_omp_i
+  
+     
+  SUBROUTINE gather_surf_mpi_i(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para, mpi_rank_root => mpi_root
+#ifdef CPP_PARA
+  INCLUDE 'mpif.h'
+#endif
+    INTEGER :: FieldIn(:)
+    INTEGER :: FieldOut(:)
+    INTEGER :: ierr
+    
+    IF (is_ok_mpi) THEN
+#ifdef CPP_PARA
+      CALL MPI_Gatherv(FieldIn,knon_mpi,MPI_INTEGER,                                &
+                       FieldOut,knon_mpi_para,knon_mpi_begin_para(:)-1,MPI_INTEGER, &
+                       mpi_rank_root,COMM_LMDZ_PHY,ierr)
+#endif
+    ELSE
+      FieldOut(:)=FieldIn(:)
+    ENDIF
+  
+  END SUBROUTINE gather_surf_mpi_i
+  
+
+
+
+
+  SUBROUTINE gather_surf_r(FieldIn, FieldOut)
+  USE mod_phys_lmdz_para
+    REAL :: FieldIn(:)
+    REAL :: FieldOut(:)
+    REAL :: FieldTmp(knon_mpi)
+    
+    CALL gather_surf_omp_r(FieldIn,FieldTmp)
+    IF (is_omp_root) CALL gather_surf_mpi_r(FieldTmp,FieldOut)
+    
+  END SUBROUTINE gather_surf_r
+
+
+  SUBROUTINE gather_surf_omp_r(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para
+    REAL :: FieldIn(:)
+    REAL :: FieldOut(:)
+  
+    REAL,SAVE,ALLOCATABLE :: Field_tmp(:)
+    
+    IF (is_omp_root) ALLOCATE(Field_tmp(knon_mpi))
+!$OMP BARRIER
+    Field_tmp(knon_omp_begin:knon_omp_end)=FieldIn(:)
+!$OMP BARRIER        
+    IF (is_omp_root) FieldOut(:)=Field_tmp(:)
+!$OMP BARRIER
+    IF (is_omp_root) DEALLOCATE(Field_tmp)
+    
+  END SUBROUTINE  gather_surf_omp_r
+  
+     
+  SUBROUTINE gather_surf_mpi_r(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para, mpi_rank_root => mpi_root
+#ifdef CPP_PARA
+  INCLUDE 'mpif.h'
+#endif
+    REAL :: FieldIn(:)
+    REAL :: FieldOut(:)
+    REAL :: ierr
+    
+    IF (is_ok_mpi) THEN
+#ifdef CPP_PARA
+      CALL MPI_Gatherv(FieldIn,knon_mpi,MPI_REAL_LMDZ,                                 &
+                       FieldOut,knon_mpi_para,knon_mpi_begin_para(:)-1,MPI_REAL_LMDZ,  &
+                       mpi_rank_root,COMM_LMDZ_PHY,ierr)            
+#endif
+    ELSE
+      FieldOut(:)=FieldIn(:)
+    ENDIF
+  
+  END SUBROUTINE gather_surf_mpi_r
+
+
+
+
+  SUBROUTINE scatter_surf_i(FieldIn, FieldOut)
+  USE mod_phys_lmdz_para
+    INTEGER :: FieldIn(:)
+    INTEGER :: FieldOut(:)
+    INTEGER :: FieldTmp(knon_mpi)
+    
+    IF (is_omp_root) CALL scatter_surf_mpi_i(FieldIn,FieldTmp)
+    CALL scatter_surf_omp_i(FieldTmp,FieldOut)
+    
+  END SUBROUTINE scatter_surf_i
+
+
+  SUBROUTINE scatter_surf_omp_i(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para
+    INTEGER :: FieldIn(:)
+    INTEGER :: FieldOut(:)
+  
+    INTEGER,SAVE,ALLOCATABLE :: Field_tmp(:)
+    
+    IF (is_omp_root) ALLOCATE(Field_tmp(knon_mpi))
+    IF (is_omp_root) Field_tmp(:)=FieldIn(:)
+!$OMP BARRIER        
+    FieldOut(:)=Field_tmp(knon_omp_begin:knon_omp_end)
+!$OMP BARRIER
+    IF (is_omp_root) DEALLOCATE(Field_tmp)
+    
+  END SUBROUTINE  scatter_surf_omp_i
+  
+     
+  SUBROUTINE scatter_surf_mpi_i(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para, mpi_rank_root => mpi_root
+#ifdef CPP_PARA
+  INCLUDE 'mpif.h'
+#endif
+    INTEGER :: FieldIn(:)
+    INTEGER :: FieldOut(:)
+    INTEGER :: ierr
+    
+    IF (is_ok_mpi) THEN
+#ifdef CPP_PARA
+      CALL MPI_Scatterv(FieldIn,knon_mpi_para,knon_mpi_begin_para(:)-1,MPI_INTEGER,   &
+                        FieldOut,knon_mpi,MPI_INTEGER,                                &
+                        mpi_rank_root,COMM_LMDZ_PHY,ierr)
+#endif
+    ELSE
+      FieldOut(:)=FieldIn(:)
+    ENDIF
+  
+  END SUBROUTINE scatter_surf_mpi_i
+
+
+
+  SUBROUTINE scatter_surf_r(FieldIn, FieldOut)
+  USE mod_phys_lmdz_para
+    REAL :: FieldIn(:)
+    REAL :: FieldOut(:)
+    REAL :: FieldTmp(knon_mpi)
+    
+    IF (is_omp_root) CALL scatter_surf_mpi_r(FieldIn,FieldTmp)
+    CALL scatter_surf_omp_r(FieldTmp,FieldOut)
+    
+  END SUBROUTINE scatter_surf_r
+
+
+  SUBROUTINE scatter_surf_omp_r(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para
+    REAL :: FieldIn(:)
+    REAL :: FieldOut(:)
+  
+    INTEGER,SAVE,ALLOCATABLE :: Field_tmp(:)
+    
+    IF (is_omp_root) ALLOCATE(Field_tmp(knon_mpi))
+    IF (is_omp_root) Field_tmp(:)=FieldIn(:)
+!$OMP BARRIER        
+    FieldOut(:)=Field_tmp(knon_omp_begin:knon_omp_end)
+!$OMP BARRIER
+    IF (is_omp_root) DEALLOCATE(Field_tmp)
+    
+  END SUBROUTINE  scatter_surf_omp_r
+  
+     
+  SUBROUTINE scatter_surf_mpi_r(FieldIn,FieldOut)
+  USE mod_phys_lmdz_para, mpi_rank_root => mpi_root
+#ifdef CPP_PARA
+  INCLUDE 'mpif.h'
+#endif
+    REAL :: FieldIn(:)
+    REAL :: FieldOut(:)
+    INTEGER :: ierr
+    
+    IF (is_ok_mpi) THEN
+#ifdef CPP_PARA
+      CALL MPI_Scatterv(FieldIn,knon_mpi_para,knon_mpi_begin_para(:)-1,MPI_INTEGER,   &
+                        FieldOut,knon_mpi,MPI_INTEGER,                                &
+                        mpi_rank_root,COMM_LMDZ_PHY,ierr)
+#endif
+    ELSE
+      FieldOut(:)=FieldIn(:)
+    ENDIF
+  
+  END SUBROUTINE scatter_surf_mpi_r
+
+END MODULE mod_surf_para
Index: LMDZ4/trunk/libf/phylmd/mod_synchro_omp.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/mod_synchro_omp.F90	(revision 987)
+++ LMDZ4/trunk/libf/phylmd/mod_synchro_omp.F90	(revision 987)
@@ -0,0 +1,34 @@
+MODULE mod_synchro_omp
+
+  LOGICAL,SAVE,ALLOCATABLE :: flag_omp(:)
+  
+CONTAINS
+
+  SUBROUTINE Init_synchro_omp
+  USE mod_phys_lmdz_para 
+  IMPLICIT NONE
+    
+    IF (is_omp_root) THEN
+      ALLOCATE(flag_omp(0:omp_size-1))
+      flag_omp(:)=.FALSE.
+    ENDIF
+!$OMP BARRIER
+
+  END SUBROUTINE Init_Synchro_omp
+  
+  SUBROUTINE Synchro_omp
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+  
+    flag_omp(omp_rank)=.TRUE.
+!$OMP BARRIER
+    DO WHILE (.NOT. ALL(flag_omp))
+!$OMP BARRIER
+    ENDDO
+!$OMP BARRIER        
+    flag_omp(omp_rank)=.FALSE.
+!$OMP BARRIER
+
+   END SUBROUTINE Synchro_omp
+
+END MODULE mod_synchro_omp
Index: LMDZ4/trunk/libf/phylmd/oasis.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/oasis.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/oasis.F90	(revision 987)
@@ -44,4 +44,5 @@
   !$OMP THREADPRIVATE(out_var_id)
 
+  CHARACTER(LEN=*),PARAMETER :: OPA_version='OPA9'
 
 #ifdef CPP_COUPLE
@@ -129,31 +130,65 @@
 !     Define symbolic name for fields exchanged from atmos to coupler,
 !         must be the same as (1) of the field  definition in namcouple:
-    cl_writ(1)='COTAUXXU'
-    cl_writ(2)='COTAUYYU'
-    cl_writ(3)='COTAUZZU'
-    cl_writ(4)='COTAUXXV'
-    cl_writ(5)='COTAUYYV'
-    cl_writ(6)='COTAUZZV'
-    cl_writ(7)='COWINDSP'
-    cl_writ(8)='COSHFICE'
-    cl_writ(9)='COSHFOCE'
-    cl_writ(10)='CONSFICE'
-    cl_writ(11)='CONSFOCE'
-    cl_writ(12)='CODFLXDT'
-    cl_writ(13)='COTFSICE'
-    cl_writ(14)='COTFSOCE'
-    cl_writ(15)='COTOLPSU'
-    cl_writ(16)='COTOSPSU'
-    cl_writ(17)='CORUNCOA'
-    cl_writ(18)='CORIVFLU'
-    cl_writ(19)='COCALVIN'
+    IF (OPA_version=='OPA9') THEN
+      cl_writ(1)='COTAUXXU'
+      cl_writ(2)='COTAUYYU'
+      cl_writ(3)='COTAUZZU'
+      cl_writ(4)='COTAUXXV'
+      cl_writ(5)='COTAUYYV'
+      cl_writ(6)='COTAUZZV'
+      cl_writ(7)='COWINDSP'
+      cl_writ(8)='COPEFWAT'
+      cl_writ(9)='COPEFICE'
+      cl_writ(10)='COTOSPSU'
+      cl_writ(11)='COICEVAP'
+      cl_writ(12)='COSWFLDO'
+      cl_writ(13)='CONSFLDO'
+      cl_writ(14)='COSHFLIC'
+      cl_writ(15)='CONSFLIC'
+      cl_writ(16)='CODFLXDT'
+      cl_writ(17)='CRWOCEIS'
+      cl_writ(18)='CRWOCERD'
+      cl_writ(19)='CRWOCECD'
+    ELSE IF (OPA_version=='OPA8') THEN
+      cl_writ(1)='COTAUXXU'
+      cl_writ(2)='COTAUYYU'
+      cl_writ(3)='COTAUZZU'
+      cl_writ(4)='COTAUXXV'
+      cl_writ(5)='COTAUYYV'
+      cl_writ(6)='COTAUZZV'
+      cl_writ(7)='COWINDSP'
+      cl_writ(8)='COSHFICE'
+      cl_writ(9)='COSHFOCE'
+      cl_writ(10)='CONSFICE'
+      cl_writ(11)='CONSFOCE'
+      cl_writ(12)='CODFLXDT'
+      cl_writ(13)='COTFSICE'
+      cl_writ(14)='COTFSOCE'
+      cl_writ(15)='COTOLPSU'
+      cl_writ(16)='COTOSPSU'
+      cl_writ(17)='CORUNCOA'
+      cl_writ(18)='CORIVFLU'
+      cl_writ(19)='COCALVIN'
+    ELSE
+      STOP 'Bad OPA version for coupled model'
+    ENDIF
+
 !
 !     Define symbolic name for fields exchanged from coupler to atmosphere,
 !         must be the same as (2) of the field  definition in namcouple:
 !
-    cl_read(1)='SISUTESW'
-    cl_read(2)='SIICECOV'
-    cl_read(3)='SIICEALW'
-    cl_read(4)='SIICTEMW'
+    IF (OPA_version=='OPA9') THEN
+      cl_read(1)='SISUTESW'
+      cl_read(2)='SIICECOV'
+      cl_read(4)='SIICEALW'
+      cl_read(3)='SIICTEMW'
+    ELSE IF (OPA_version=='OPA8') THEN
+      cl_read(1)='SISUTESW'
+      cl_read(2)='SIICECOV'
+      cl_read(3)='SIICEALW'
+      cl_read(4)='SIICTEMW'
+    ELSE
+      STOP 'Bad OPA version for coupled model'
+    ENDIF
     
     il_var_nodims(1) = 2
@@ -286,14 +321,15 @@
 ! Local variables
 !************************************************************************************
-    LOGICAL                     :: checkout=.FALSE.
-    INTEGER                     :: istart,iend
-    INTEGER                     :: wstart,wend
-    INTEGER, PARAMETER          :: nuout = 6 
-    INTEGER                     :: ierror, i
-    REAL, DIMENSION(iim*jj_nb)  :: field
-    CHARACTER (len = 20),SAVE   :: modname = 'intocpl'
-    CHARACTER (len = 80)        :: abort_message 
-
-!************************************************************************************
+    LOGICAL                          :: checkout
+    INTEGER                          :: istart,iend
+    INTEGER                          :: wstart,wend
+    INTEGER, PARAMETER               :: nuout = 6 
+    INTEGER                          :: ierror, i
+    REAL, DIMENSION(iim*jj_nb)       :: field
+    CHARACTER (len = 20),PARAMETER   :: modname = 'intocpl'
+    CHARACTER (len = 80)             :: abort_message 
+
+!************************************************************************************
+    checkout=.FALSE.
 
     WRITE(nuout,*) ' '
Index: LMDZ4/trunk/libf/phylmd/pbl_surface_mod.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/pbl_surface_mod.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/pbl_surface_mod.F90	(revision 987)
@@ -487,5 +487,7 @@
   LOGICAL ok_flux_surf
   data ok_flux_surf/.false./
+!ym pas glop !!
     common /flux_arp/fsens,flat,ok_flux_surf
+!$OMP THREADPRIVATE(/flux_arp/)
 
 !****************************************************************************************
Index: LMDZ4/trunk/libf/phylmd/phyetat0.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/phyetat0.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/phyetat0.F	(revision 987)
@@ -109,5 +109,4 @@
       PARAMETER (length=100)
       REAL tab_cntrl(length), tabcntr0(length)
-      REAL,SAVE :: tab_cntrl_omp(length)
       CHARACTER*7 str7
       CHARACTER*2 str2
@@ -232,6 +231,5 @@
 c Lecture des latitudes (coordonnees):
 c
-c$OMP MASTER
-      IF (is_mpi_root) THEN
+      IF (is_mpi_root .AND. is_omp_root) THEN
       
       ierr = NF_INQ_VARID (nid, "latitude", nvarid)
@@ -957,10 +955,4 @@
       PRINT*,'Rayonnement IF au sol sollw:', xmin, xmax
       
-      ENDIF  ! is_mpi_root
-c$OMP END MASTER
-
-
-c$OMP MASTER
-      IF (is_mpi_root) THEN
 c
 c Lecture derive des flux:
@@ -1729,7 +1721,6 @@
 c
       ierr = NF_CLOSE(nid)
-      ENDIF ! is_mpi_root
-c
-c$OMP END MASTER
+      ENDIF ! is_mpi_root .AND. is_omp_root
+c
 
 c$OMP MASTER
Index: LMDZ4/trunk/libf/phylmd/phys_local_var_mod.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/phys_local_var_mod.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/phys_local_var_mod.F90	(revision 987)
@@ -7,30 +7,53 @@
 ! Declaration des variables
 
-      REAL, ALLOCATABLE :: t_seri(:,:), q_seri(:,:)
-      REAL, ALLOCATABLE :: ql_seri(:,:),qs_seri(:,:)
-      REAL, ALLOCATABLE :: u_seri(:,:), v_seri(:,:)
+      REAL, SAVE, ALLOCATABLE :: t_seri(:,:), q_seri(:,:)
+      !$OMP THREADPRIVATE(t_seri, q_seri)
+      REAL, SAVE, ALLOCATABLE :: ql_seri(:,:),qs_seri(:,:)
+      !$OMP THREADPRIVATE(ql_seri,qs_seri)
+      REAL, SAVE, ALLOCATABLE :: u_seri(:,:), v_seri(:,:)
+      !$OMP THREADPRIVATE(u_seri, v_seri)
 
-      REAL, ALLOCATABLE :: tr_seri(:,:,:)
-      REAL, ALLOCATABLE :: d_t_dyn(:,:), d_q_dyn(:,:)
-      REAL, ALLOCATABLE :: d_t_con(:,:),d_q_con(:,:)
-      REAL, ALLOCATABLE :: d_u_con(:,:),d_v_con(:,:)
-      REAL, ALLOCATABLE :: d_t_wake(:,:),d_q_wake(:,:)
-      REAL, ALLOCATABLE :: d_t_lsc(:,:),d_q_lsc(:,:),d_ql_lsc(:,:)
-      REAL, ALLOCATABLE :: d_t_ajsb(:,:), d_q_ajsb(:,:)
-      REAL, ALLOCATABLE :: d_t_ajs(:,:), d_q_ajs(:,:)
-      REAL, ALLOCATABLE :: d_u_ajs(:,:), d_v_ajs(:,:)
-      REAL, ALLOCATABLE :: d_t_eva(:,:),d_q_eva(:,:)
+      REAL, SAVE, ALLOCATABLE :: tr_seri(:,:,:)
+      !$OMP THREADPRIVATE(tr_seri)
+      REAL, SAVE, ALLOCATABLE :: d_t_dyn(:,:), d_q_dyn(:,:)
+      !$OMP THREADPRIVATE(d_t_dyn, d_q_dyn)
+      REAL, SAVE, ALLOCATABLE :: d_t_con(:,:),d_q_con(:,:)
+      !$OMP THREADPRIVATE(d_t_con,d_q_con)
+      REAL, SAVE, ALLOCATABLE :: d_u_con(:,:),d_v_con(:,:)
+      !$OMP THREADPRIVATE(d_u_con,d_v_con)
+      REAL, SAVE, ALLOCATABLE :: d_t_wake(:,:),d_q_wake(:,:)
+      !$OMP THREADPRIVATE( d_t_wake,d_q_wake)
+      REAL, SAVE, ALLOCATABLE :: d_t_lsc(:,:),d_q_lsc(:,:),d_ql_lsc(:,:)
+      !$OMP THREADPRIVATE(d_t_lsc,d_q_lsc,d_ql_lsc)
+      REAL, SAVE, ALLOCATABLE :: d_t_ajsb(:,:), d_q_ajsb(:,:)
+      !$OMP THREADPRIVATE(d_t_ajsb, d_q_ajsb)
+      REAL, SAVE, ALLOCATABLE :: d_t_ajs(:,:), d_q_ajs(:,:)
+      !$OMP THREADPRIVATE(d_t_ajs, d_q_ajs)
+      REAL, SAVE, ALLOCATABLE :: d_u_ajs(:,:), d_v_ajs(:,:)
+      !$OMP THREADPRIVATE(d_u_ajs, d_v_ajs)
+      REAL, SAVE, ALLOCATABLE :: d_t_eva(:,:),d_q_eva(:,:)
+      !$OMP THREADPRIVATE(d_t_eva,d_q_eva)
 !tendances dues a oro et lif
-      REAL, ALLOCATABLE :: d_t_oli(:,:)
-      REAL, ALLOCATABLE :: d_u_oli(:,:), d_v_oli(:,:)
-      REAL, ALLOCATABLE :: d_t_vdf(:,:), d_q_vdf(:,:)
-      REAL, ALLOCATABLE :: d_u_vdf(:,:), d_v_vdf(:,:)
-      REAL, ALLOCATABLE :: d_t_oro(:,:)
-      REAL, ALLOCATABLE :: d_u_oro(:,:), d_v_oro(:,:)
-      REAL, ALLOCATABLE :: d_t_lif(:,:)
-      REAL, ALLOCATABLE :: d_u_lif(:,:), d_v_lif(:,:)
+      REAL, SAVE, ALLOCATABLE :: d_t_oli(:,:)
+      !$OMP THREADPRIVATE(d_t_oli)
+      REAL, SAVE, ALLOCATABLE :: d_u_oli(:,:), d_v_oli(:,:)
+      !$OMP THREADPRIVATE(d_u_oli, d_v_oli)
+      REAL, SAVE, ALLOCATABLE :: d_t_vdf(:,:), d_q_vdf(:,:)
+      !$OMP THREADPRIVATE( d_t_vdf, d_q_vdf)
+      REAL, SAVE, ALLOCATABLE :: d_u_vdf(:,:), d_v_vdf(:,:)
+      !$OMP THREADPRIVATE(d_u_vdf, d_v_vdf)
+      REAL, SAVE, ALLOCATABLE :: d_t_oro(:,:)
+      !$OMP THREADPRIVATE(d_t_oro)
+      REAL, SAVE, ALLOCATABLE :: d_u_oro(:,:), d_v_oro(:,:)
+      !$OMP THREADPRIVATE(d_u_oro, d_v_oro)
+      REAL, SAVE, ALLOCATABLE :: d_t_lif(:,:)
+      !$OMP THREADPRIVATE(d_t_lif)
+      REAL, SAVE, ALLOCATABLE :: d_u_lif(:,:), d_v_lif(:,:)
+      !$OMP THREADPRIVATE(d_u_lif, d_v_lif)
 ! tendance du a la conersion Ec -> E thermique
-      REAL, ALLOCATABLE :: d_t_ec(:,:)
-      REAL, ALLOCATABLE :: d_ts(:,:), d_tr(:,:,:)
+      REAL, SAVE, ALLOCATABLE :: d_t_ec(:,:)
+      !$OMP THREADPRIVATE(d_t_ec)
+      REAL, SAVE, ALLOCATABLE :: d_ts(:,:), d_tr(:,:,:)
+      !$OMP THREADPRIVATE(d_ts, d_tr)
 CONTAINS
 
Index: LMDZ4/trunk/libf/phylmd/physiq.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/physiq.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/physiq.F	(revision 987)
@@ -111,4 +111,5 @@
       integer iflag_radia     ! active ou non le rayonnement (MPL)
       save iflag_radia
+c$OMP THREADPRIVATE(iflag_radia)
 c======================================================================
       LOGICAL check ! Verifier la conservation du modele en eau
@@ -118,4 +119,5 @@
 c======================================================================
       LOGICAL, SAVE :: rnpb=.TRUE.
+c$OMP THREADPRIVATE(rnpb)
 cIM "slab" ocean
       REAL tslab(klon)    !Temperature du slab-ocean
@@ -247,4 +249,5 @@
      .15000., 10000., 7000., 5000., 3000., 2000., 1000./
       SAVE rlevstd
+c$OMP THREADPRIVATE(rlevstd)
       CHARACTER*4 clevSTD(nlevSTD)
       DATA clevSTD/'1000','925 ','850 ','700 ','600 ',
@@ -252,4 +255,5 @@
      .'70  ','50  ','30  ','20  ','10  '/
       SAVE clevSTD
+c$OMP THREADPRIVATE(clevSTD)
 c
       CHARACTER*4 bb2
@@ -353,4 +357,5 @@
 c      INTEGER ncol(napisccp), ncolmx, seed(klon,napisccp)
       INTEGER,SAVE :: ncol(napisccp)
+c$OMP THREADPRIVATE(ncol)
       INTEGER ncolmx, seed(klon,napisccp)
       REAL nbsunlit(nregISCtot,klon,napisccp)  !nbsunlit : moyenne de sunlit
@@ -554,4 +559,6 @@
       REAL qsol(klon)
       REAL,save ::  solarlong0
+c$OMP THREADPRIVATE(solarlong0)
+
 c
 c  Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
@@ -587,4 +594,5 @@
       INTEGER it_wape_prescr
       SAVE wape_prescr, fip_prescr, it_wape_prescr
+c$OMP THREADPRIVATE(wape_prescr, fip_prescr, it_wape_prescr)
 c
 c variables supplementaires de concvl
@@ -600,4 +608,5 @@
 
 c$OMP THREADPRIVATE(alp_bl_prescr,ale_bl_prescr)
+c$OMP THREADPRIVATE(ale_max,alp_max)
 
       real ale_wake(klon)
@@ -879,4 +888,5 @@
       real ratqsbas,ratqshaut
       save ratqsbas,ratqshaut
+c$OMP THREADPRIVATE(ratqsbas,ratqshaut)
       real zpt_conv(klon,klev)
 
@@ -1505,8 +1515,11 @@
 c#endif
 
+c$OMP MASTER
        call phys_output_open(jjmp1,nqmax,nlevSTD,clevSTD,nbteta, 
      &                        ctetaSTD,dtime,presnivs,ok_veget,
      &                        ocean,iflag_pbl,ok_mensuel,ok_journe,
      &                        ok_hf,ok_instan,nid_files)
+c$OMP END MASTER
+c$OMP BARRIER
 
 #ifdef histISCCP
Index: LMDZ4/trunk/libf/phylmd/surf_land_orchidee_mod.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/surf_land_orchidee_mod.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/surf_land_orchidee_mod.F90	(revision 987)
@@ -18,5 +18,5 @@
   USE comgeomphy,   ONLY : cuphy, cvphy
   USE mod_grid_phy_lmdz
-  USE mod_phys_lmdz_para
+  USE mod_phys_lmdz_para, mpi_root_rank=>mpi_root
 
   IMPLICIT NONE
@@ -25,4 +25,5 @@
   PUBLIC  :: surf_land_orchidee
 
+  LOGICAL, ALLOCATABLE, SAVE :: flag_omp(:)
 CONTAINS
 !
@@ -39,4 +40,7 @@
        tsol_rad, tsurf_new, alb1_new, alb2_new, &
        emis_new, z0_new, qsurf)
+   USE mod_surf_para
+   USE mod_synchro_omp
+   
 !    
 ! Cette routine sert d'interface entre le modele atmospherique et le 
@@ -163,5 +167,4 @@
 
     REAL, DIMENSION(knon,2)                   :: albedo_out
-    !$OMP THREADPRIVATE(albedo_out)
 
 ! Pb de nomenclature
@@ -188,4 +191,7 @@
     REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: riverflow
     !$OMP THREADPRIVATE(riverflow)
+    
+    INTEGER :: orch_omp_rank
+    INTEGER :: orch_omp_size
 !
 ! Fin definition
@@ -198,7 +204,10 @@
   
     IF (debut) THEN
+       CALL Init_surf_para(knon)
        ALLOCATE(ktindex(knon))
        IF ( .NOT. ALLOCATED(albedo_keep)) THEN
-          ALLOCATE(albedo_keep(klon))
+!ym          ALLOCATE(albedo_keep(klon))
+!ym bizarre que non alloué en knon precedement
+          ALLOCATE(albedo_keep(knon))
           ALLOCATE(zlev(knon))
        ENDIF
@@ -333,5 +342,5 @@
     IF (lafin) lrestart_write = .TRUE.
     IF (check) WRITE(lunout,*)'lafin ',lafin,lrestart_write
-    
+     
     petA_orc(1:knon) = petBcoef(1:knon) * dtime
     petB_orc(1:knon) = petAcoef(1:knon)
@@ -352,26 +361,17 @@
 !  write(*,*)'Cdrag = ',minval(cdrag),maxval(cdrag)
 
-!
-! Init Orchidee
-!
-!  if (pole_nord) then 
-!    offset=0
-!    ktindex(:)=ktindex(:)+iim-1
-!  else
-!    offset = klon_mpi_begin-1+iim-1
-!    ktindex(:)=ktindex(:)+MOD(offset,iim)
-!    offset=offset-MOD(offset,iim)
-!  endif
   
     IF (debut) THEN
-       CALL Get_orchidee_communicator(knon,orch_comm)
-       IF (knon /=0) THEN
-          CALL Init_orchidee_index(knon,orch_comm,knindex,offset,ktindex)
-
-#ifndef CPP_PARA
-#define ORC_PREPAR
-#endif
-#ifdef ORC_PREPAR
-          ! Interface for ORCHIDEE version 1.9 or earlier compiled in sequential mode(without preprocessing flag CPP_PARA)
+       CALL Init_orchidee_index(knon,knindex,offset,ktindex)
+       CALL Get_orchidee_communicator(orch_comm,orch_omp_size,orch_omp_rank)
+       CALL Init_synchro_omp
+       
+       IF (knon_mpi > 0) THEN
+         CALL Init_intersurf(nbp_lon,nbp_lat,knon,ktindex,offset,orch_omp_size,orch_omp_rank,orch_comm)
+       ENDIF
+
+       
+       IF (knon > 0) THEN
+
           CALL intersurf_main (itime+itau_phy-1, iim, jjm+1, knon, ktindex, dtime, &
                lrestart_read, lrestart_write, lalo, &
@@ -383,19 +383,8 @@
                tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
                lon_scat, lat_scat)
-
-#else          
-          ! Interface for ORCHIDEE version 1.9 compiled in parallel mode(with preprocessing flag CPP_PARA)
-          CALL intersurf_main (itime+itau_phy-1, iim, jjm+1, offset, knon, ktindex, & 
-               orch_comm, dtime, lrestart_read, lrestart_write, lalo, &
-               contfrac, neighbours, resolution, date0, &
-               zlev,  u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), &
-               cdrag(1:knon), petA_orc(1:knon), peqA_orc(1:knon), petB_orc(1:knon), peqB_orc(1:knon), &
-               precip_rain(1:knon), precip_snow(1:knon), lwdown(1:knon), swnet(1:knon), swdown(1:knon), ps(1:knon), &
-               evap(1:knon), fluxsens(1:knon), fluxlat(1:knon), coastalflow(1:knon), riverflow(1:knon), &
-               tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0_new(1:knon), &
-               lon_scat, lat_scat)
-#endif
-          
-       ENDIF
+         
+       ENDIF
+
+       CALL Synchro_omp
 
        albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
@@ -403,25 +392,12 @@
     ENDIF
 
+    
 !  swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon))
     swdown_vrai(1:knon) = swdown(1:knon)
 
-    IF (knon /=0) THEN
-    
-#ifdef ORC_PREPAR
-       ! Interface for ORCHIDEE version 1.9 or earlier compiled in sequential mode(without preprocessing flag CPP_PARA)
-       CALL intersurf_main (itime+itau_phy, iim, jjm+1, knon, ktindex, dtime, &
+    IF (knon > 0) THEN
+    
+       CALL intersurf_main (itime+itau_phy, iim, jjm+1, knon, ktindex, dtime,  &
             lrestart_read, lrestart_write, lalo, &
-            contfrac, neighbours, resolution, date0, &
-            zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, &
-            cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
-            precip_rain, precip_snow, lwdown, swnet, swdown_vrai, ps, &
-            evap, fluxsens, fluxlat, coastalflow, riverflow, &
-            tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
-            lon_scat, lat_scat)
-       
-#else
-       ! Interface for ORCHIDEE version 1.9 compiled in parallel mode(with preprocessing flag CPP_PARA)
-       CALL intersurf_main (itime+itau_phy, iim, jjm+1,offset, knon, ktindex, & 
-            orch_comm,dtime, lrestart_read, lrestart_write, lalo, &
             contfrac, neighbours, resolution, date0, &
             zlev,  u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), &
@@ -431,8 +407,9 @@
             tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0_new(1:knon), &
             lon_scat, lat_scat)
-#endif
        
     ENDIF
 
+    CALL Synchro_omp
+    
     albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
 
@@ -455,124 +432,110 @@
     IF (debut) lrestart_read = .FALSE.
     
+    IF (debut) CALL Finalize_surf_para
+    
   END SUBROUTINE surf_land_orchidee
 !
 !****************************************************************************************
 !
-  SUBROUTINE Init_orchidee_index(knon,orch_comm,knindex,offset,ktindex)
-    
-    INCLUDE "dimensions.h"
-
+  SUBROUTINE Init_orchidee_index(knon,knindex,offset,ktindex)
+  USE mod_surf_para
+  USE mod_grid_phy_lmdz
+  
+    INTEGER,INTENT(IN)    :: knon
+    INTEGER,INTENT(IN)    :: knindex(klon)    
+    INTEGER,INTENT(OUT)   :: offset
+    INTEGER,INTENT(OUT)   :: ktindex(klon)
+    
+    INTEGER               :: ktindex_glo(knon_glo)
+    INTEGER               :: offset_para(0:omp_size*mpi_size-1)
+    INTEGER               :: LastPoint
+    INTEGER               :: task
+    
+    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1
+    
+    CALL gather_surf(ktindex(1:knon),ktindex_glo) 
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      LastPoint=0
+      DO Task=0,mpi_size*omp_size-1
+        IF (knon_glo_para(Task)>0) THEN
+           offset_para(task)= LastPoint-MOD(LastPoint,nbp_lon)
+           LastPoint=ktindex_glo(knon_glo_end_para(task))
+        ENDIF
+      ENDDO
+    ENDIF
+    
+    CALL bcast(offset_para)
+    
+    offset=offset_para(omp_size*mpi_rank+omp_rank)
+    
+    ktindex(1:knon)=ktindex(1:knon)-offset
+
+  END SUBROUTINE Init_orchidee_index
+
+!
+!************************* ***************************************************************
+! 
+
+  SUBROUTINE Get_orchidee_communicator(orch_comm,orch_omp_size,orch_omp_rank)
+  USE  mod_surf_para
+      
 #ifdef CPP_PARA
     INCLUDE 'mpif.h'
 #endif    
 
-
-! Input arguments
-!****************************************************************************************
-    INTEGER, INTENT(IN)                   :: knon
-    INTEGER, INTENT(IN)                   :: orch_comm
-    INTEGER, DIMENSION(klon), INTENT(IN)  :: knindex
-
-! Output arguments
-!****************************************************************************************
-    INTEGER, INTENT(OUT)                  :: offset
-    INTEGER, DIMENSION(knon), INTENT(OUT) :: ktindex
-
-! Local varables
-!****************************************************************************************
-#ifdef CPP_PARA
-    INTEGER, DIMENSION(MPI_STATUS_SIZE)   :: status
+    INTEGER,INTENT(OUT) :: orch_comm
+    INTEGER,INTENT(OUT) :: orch_omp_size
+    INTEGER,INTENT(OUT) :: orch_omp_rank
+    INTEGER             :: color
+    INTEGER             :: i,ierr
+!
+! End definition
+!****************************************************************************************
+    
+    
+    IF (is_omp_root) THEN          
+      
+      IF (knon_mpi==0) THEN 
+         color = 0
+      ELSE 
+         color = 1
+      ENDIF
+    
+#ifdef CPP_PARA    
+      CALL MPI_COMM_SPLIT(COMM_LMDZ_PHY,color,mpi_rank,orch_comm,ierr)
 #endif
 
-    INTEGER                               :: MyLastPoint
-    INTEGER                               :: LastPoint
-    INTEGER                               :: mpi_rank_orch
-    INTEGER                               :: mpi_size_orch
-    INTEGER                               :: ierr 
-!
-! End definition
-!****************************************************************************************
-
-    MyLastPoint=klon_mpi_begin-1+knindex(knon)+iim-1
-    
-    IF (is_parallel) THEN
-#ifdef CPP_PARA    
-       CALL MPI_COMM_SIZE(orch_comm,mpi_size_orch,ierr)
-       CALL MPI_COMM_RANK(orch_comm,mpi_rank_orch,ierr)
-#endif
-    ELSE
-       mpi_rank_orch=0
-       mpi_size_orch=1
-    ENDIF
-
-    IF (is_parallel) THEN
-       IF (mpi_rank_orch /= 0) THEN
-#ifdef CPP_PARA
-          CALL MPI_RECV(LastPoint,1,MPI_INTEGER,mpi_rank_orch-1,1234,orch_comm,status,ierr)
-#endif
-       ENDIF
-       
-       IF (mpi_rank_orch /= mpi_size_orch-1) THEN
-#ifdef CPP_PARA
-          CALL MPI_SEND(MyLastPoint,1,MPI_INTEGER,mpi_rank_orch+1,1234,orch_comm,ierr)  
-#endif
-       ENDIF
-    ENDIF
-    
-    IF (mpi_rank_orch == 0) THEN 
-       offset=0
-    ELSE
-       offset=LastPoint-MOD(LastPoint,iim)
-    ENDIF
-    
-    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin+iim-1)-offset-1	
-    
-
-  END SUBROUTINE  Init_orchidee_index
-!
-!****************************************************************************************
-! 
-  SUBROUTINE Get_orchidee_communicator(knon,orch_comm)
-    
+   ENDIF
+   
+   IF (knon_mpi /= 0) THEN
+     orch_omp_size=0
+     DO i=0,omp_size-1
+       IF (knon_omp_para(i) /=0) THEN
+         orch_omp_size=orch_omp_size+1
+         IF (i==omp_rank) orch_omp_rank=orch_omp_size-1
+       ENDIF
+     ENDDO
+   ENDIF
+       
+    
+  END SUBROUTINE Get_orchidee_communicator
+!
+!****************************************************************************************
+!  
+
+  SUBROUTINE Init_neighbours(knon,neighbours,knindex,pctsrf)
+    USE mod_grid_phy_lmdz
+    USE mod_surf_para    
+    INCLUDE "indicesol.h"
+
 #ifdef CPP_PARA
     INCLUDE 'mpif.h'
 #endif    
 
-
-    INTEGER,INTENT(IN)  :: knon
-    INTEGER,INTENT(OUT) :: orch_comm
-    
-    INTEGER             :: color
-    INTEGER             :: ierr
-!
-! End definition
-!****************************************************************************************
-
-    IF (knon==0) THEN 
-       color = 0
-    ELSE 
-       color = 1
-    ENDIF
-    
-#ifdef CPP_PARA    
-    CALL MPI_COMM_SPLIT(COMM_LMDZ_PHY,color,mpi_rank,orch_comm,ierr)
-#endif
-    
-  END SUBROUTINE Get_orchidee_communicator
-!
-!****************************************************************************************
-!  
-  SUBROUTINE Init_neighbours(knon,neighbours,ktindex,pctsrf)
-    
-    INCLUDE "indicesol.h"
-    INCLUDE "dimensions.h"
-#ifdef CPP_PARA
-    INCLUDE 'mpif.h'
-#endif    
-
 ! Input arguments
 !****************************************************************************************
     INTEGER, INTENT(IN)                     :: knon
-    INTEGER, DIMENSION(klon), INTENT(IN)    :: ktindex
+    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
     REAL, DIMENSION(klon), INTENT(IN)       :: pctsrf
     
@@ -583,99 +546,67 @@
 ! Local variables
 !****************************************************************************************
-    INTEGER                              :: knon_g
     INTEGER                              :: i, igrid, jj, ij, iglob
     INTEGER                              :: ierr, ireal, index
-    INTEGER, DIMENSION(0:mpi_size-1)     :: knon_nb
-    INTEGER, DIMENSION(0:mpi_size-1)     :: displs
     INTEGER, DIMENSION(8,3)              :: off_ini
     INTEGER, DIMENSION(8)                :: offset  
-    INTEGER, DIMENSION(knon)             :: ktindex_p
-    INTEGER, DIMENSION(iim,jjm+1)        :: correspond
-    INTEGER, ALLOCATABLE, DIMENSION(:)   :: ktindex_g
-    INTEGER, ALLOCATABLE, DIMENSION(:,:) :: neighbours_g
-    REAL, DIMENSION(klon_glo)            :: pctsrf_g
-    
+    INTEGER, DIMENSION(nbp_lon,nbp_lat)  :: correspond
+    INTEGER, DIMENSION(knon_glo)         :: ktindex_glo
+    INTEGER, DIMENSION(knon_glo,8)       :: neighbours_glo
+    REAL, DIMENSION(klon_glo)            :: pctsrf_glo
+    INTEGER                              :: ktindex(klon)
 !
 ! End definition
 !****************************************************************************************
 
-    IF (is_sequential) THEN
-       knon_nb(:)=knon
-    ELSE  
-       
-#ifdef CPP_PARA  
-       CALL MPI_GATHER(knon,1,MPI_INTEGER,knon_nb,1,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr)
-#endif
-       
-    ENDIF
-    
-    IF (is_mpi_root) THEN
-       knon_g=SUM(knon_nb(:))
-       ALLOCATE(ktindex_g(knon_g))
-       ALLOCATE(neighbours_g(knon_g,8))
-       neighbours_g(:,:)=-1
-       displs(0)=0
-       DO i=1,mpi_size-1
-          displs(i)=displs(i-1)+knon_nb(i-1)
-       ENDDO
-    ENDIF
-    
-    ktindex_p(1:knon)=ktindex(1:knon)+klon_mpi_begin-1+iim-1
-    
-    IF (is_sequential) THEN
-       ktindex_g(:)=ktindex_p(:)
-    ELSE
-       
-#ifdef CPP_PARA  
-       CALL MPI_GATHERV(ktindex_p,knon,MPI_INTEGER,ktindex_g,knon_nb,&
-            displs,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr)
-#endif
-       
-    ENDIF
-    
-    CALL Gather(pctsrf,pctsrf_g)
-    
-    IF (is_mpi_root) THEN
+    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1
+    
+    CALL gather_surf(ktindex(1:knon),ktindex_glo)
+    CALL gather(pctsrf,pctsrf_glo)
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      neighbours_glo(:,:)=-1
 !  Initialisation des offset    
 !
 ! offset bord ouest
-       off_ini(1,1) = - iim  ; off_ini(2,1) = - iim + 1; off_ini(3,1) = 1
-       off_ini(4,1) = iim + 1; off_ini(5,1) = iim      ; off_ini(6,1) = 2 * iim - 1
-       off_ini(7,1) = iim -1 ; off_ini(8,1) = - 1
+       off_ini(1,1) = - nbp_lon   ; off_ini(2,1) = - nbp_lon + 1     ; off_ini(3,1) = 1
+       off_ini(4,1) = nbp_lon + 1 ; off_ini(5,1) = nbp_lon           ; off_ini(6,1) = 2 * nbp_lon - 1
+       off_ini(7,1) = nbp_lon -1  ; off_ini(8,1) = - 1 
 ! offset point normal
-       off_ini(1,2) = - iim  ; off_ini(2,2) = - iim + 1; off_ini(3,2) = 1
-       off_ini(4,2) = iim + 1; off_ini(5,2) = iim      ; off_ini(6,2) = iim - 1
-       off_ini(7,2) = -1     ; off_ini(8,2) = - iim - 1
+       off_ini(1,2) = - nbp_lon   ; off_ini(2,2) = - nbp_lon + 1     ; off_ini(3,2) = 1
+       off_ini(4,2) = nbp_lon + 1 ; off_ini(5,2) = nbp_lon           ; off_ini(6,2) = nbp_lon - 1
+       off_ini(7,2) = -1          ; off_ini(8,2) = - nbp_lon - 1
 ! offset bord   est
-       off_ini(1,3) = - iim; off_ini(2,3) = - 2 * iim + 1; off_ini(3,3) = - iim + 1
-       off_ini(4,3) =  1   ; off_ini(5,3) = iim          ; off_ini(6,3) = iim - 1
-       off_ini(7,3) = -1   ; off_ini(8,3) = - iim - 1
+       off_ini(1,3) = - nbp_lon   ; off_ini(2,3) = - 2 * nbp_lon + 1 ; off_ini(3,3) = - nbp_lon + 1
+       off_ini(4,3) =  1          ; off_ini(5,3) = nbp_lon           ; off_ini(6,3) = nbp_lon - 1
+       off_ini(7,3) = -1          ; off_ini(8,3) = - nbp_lon - 1
 !
 !
 ! Attention aux poles
 !
-       DO igrid = 1, knon_g
-          index = ktindex_g(igrid)
-          jj = INT((index - 1)/iim) + 1
-          ij = index - (jj - 1) * iim
+       DO igrid = 1, knon_glo
+          index = ktindex_glo(igrid)
+          jj = INT((index - 1)/nbp_lon) + 1
+          ij = index - (jj - 1) * nbp_lon
           correspond(ij,jj) = igrid
        ENDDO
        
-       DO igrid = 1, knon_g
-          iglob = ktindex_g(igrid)
-          IF (MOD(iglob, iim) == 1) THEN
+       DO igrid = 1, knon_glo
+          iglob = ktindex_glo(igrid)
+          
+          IF (MOD(iglob, nbp_lon) == 1) THEN
              offset = off_ini(:,1)
-          ELSE IF(MOD(iglob, iim) == 0) THEN
+          ELSE IF(MOD(iglob, nbp_lon) == 0) THEN
              offset = off_ini(:,3)
           ELSE
              offset = off_ini(:,2)
           ENDIF
+          
           DO i = 1, 8
              index = iglob + offset(i)
-             ireal = (MIN(MAX(1, index - iim + 1), klon_glo))
-             IF (pctsrf_g(ireal) > EPSFRA) THEN
-                jj = INT((index - 1)/iim) + 1
-                ij = index - (jj - 1) * iim
-                neighbours_g(igrid, i) = correspond(ij, jj)
+             ireal = (MIN(MAX(1, index - nbp_lon + 1), klon_glo))
+             IF (pctsrf_glo(ireal) > EPSFRA) THEN
+                jj = INT((index - 1)/nbp_lon) + 1
+                ij = index - (jj - 1) * nbp_lon
+                neighbours_glo(igrid, i) = correspond(ij, jj)
              ENDIF
           ENDDO
@@ -684,20 +615,14 @@
     ENDIF
     
-    DO i=1,8
-       IF (is_sequential) THEN
-          neighbours(:,i)=neighbours_g(:,i)
-       ELSE
-#ifdef CPP_PARA
-          CALL MPI_SCATTERV(neighbours_g(:,i),knon_nb,displs,MPI_INTEGER,neighbours(:,i),knon,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr) 
+    DO i = 1, 8
+      CALL scatter_surf(neighbours_glo(:,i),neighbours(1:knon,i))
+    ENDDO
+  END SUBROUTINE Init_neighbours
+
+!
+!****************************************************************************************
+!
+
 #endif
-       ENDIF
-    ENDDO
-    
-  END SUBROUTINE Init_neighbours
-!
-!****************************************************************************************
-!
-
-#endif
 
 END MODULE surf_land_orchidee_mod
Index: LMDZ4/trunk/libf/phylmd/thermcell.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/thermcell.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/thermcell.F	(revision 987)
@@ -52,5 +52,5 @@
       save idetr
       data idetr/3/
-
+c$OMP THREADPRIVATE(idetr)
 c   local:
 c   ------
@@ -94,4 +94,5 @@
       data isplit/0/
       save isplit
+c$OMP THREADPRIVATE(isplit)
 
       logical sorties
@@ -125,4 +126,5 @@
       data first /.false./
       save first
+c$OMP THREADPRIVATE(first)
 cRC
 
@@ -137,4 +139,5 @@
       save ncorrec
       data ncorrec/0/
+c$OMP THREADPRIVATE(ncorrec)
       
 c
@@ -1131,4 +1134,5 @@
 c$OMP THREADPRIVATE(zmax0_sec)
       logical, save :: first = .true.
+c$OMP THREADPRIVATE(first)
 
       if (first) then
Index: LMDZ4/trunk/libf/phylmd/thermcell.h
===================================================================
--- LMDZ4/trunk/libf/phylmd/thermcell.h	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/thermcell.h	(revision 987)
@@ -8,2 +8,3 @@
       common/ctherm3/w2di_thermals
       common/ctherm4/iflag_coupl,iflag_clos,iflag_wake
+!$OMP THREADPRIVATE(/ctherm1/,/ctherm2/,/ctherm3/,/ctherm4/)
Index: LMDZ4/trunk/libf/phylmd/thermcell_flux.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/thermcell_flux.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/thermcell_flux.F90	(revision 987)
@@ -49,4 +49,5 @@
       REAL fomass_max,alphamax
       save fomass_max,alphamax
+!$OMP THREADPRIVATE(fomass_max,alphamax)
 
       fomass_max=0.5
Index: LMDZ4/trunk/libf/phylmd/thermcell_flux2.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/thermcell_flux2.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/thermcell_flux2.F90	(revision 987)
@@ -45,4 +45,5 @@
       REAL fomass_max,alphamax
       save fomass_max,alphamax
+!$OMP THREADPRIVATE(fomass_max,alphamax)
 
       fomass_max=0.5
Index: LMDZ4/trunk/libf/phylmd/thermcell_main.F90
===================================================================
--- LMDZ4/trunk/libf/phylmd/thermcell_main.F90	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/thermcell_main.F90	(revision 987)
@@ -69,8 +69,12 @@
       data icount/0/
       save icount
+!$OMP THREADPRIVATE(icount)
 
       integer,save :: igout=1
+!$OMP THREADPRIVATE(igout)
       integer,save :: lunout1=6
+!$OMP THREADPRIVATE(lunout1)
       integer,save :: lev_out=10
+!$OMP THREADPRIVATE(lev_out)
 
       INTEGER ig,k,l,ll
@@ -118,4 +122,5 @@
       data isplit/0/
       save isplit
+!$OMP THREADPRIVATE(isplit)
 
       logical sorties
Index: LMDZ4/trunk/libf/phylmd/thermcell_old.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/thermcell_old.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/thermcell_old.F	(revision 987)
@@ -53,4 +53,5 @@
       save idetr
       data idetr/3/
+c$OMP THREADPRIVATE(idetr)
 
 c   local:
@@ -88,4 +89,5 @@
       data isplit/0/
       save isplit
+c$OMP THREADPRIVATE(isplit)
 
       logical sorties
@@ -117,4 +119,6 @@
       save ncorrec
       data ncorrec/0/
+c$OMP THREADPRIVATE(ncorrec)
+
 c
 c-----------------------------------------------------------------------
@@ -852,4 +856,5 @@
       save idetr
       data idetr/3/
+c$OMP THREADPRIVATE(idetr)
 
 c   local:
@@ -865,4 +870,6 @@
       save alpha
       data alpha/1./
+c$OMP THREADPRIVATE(alpha)
+
 c RC 
       real zmax(klon),zw,zz,zw2(klon,klev+1),ztva(klon,klev),zzz
@@ -918,4 +925,5 @@
       data isplit/0/
       save isplit
+c$OMP THREADPRIVATE(isplit)
 
       logical sorties
@@ -977,4 +985,5 @@
       real zlevinter(klon)
       logical, save :: first = .true.
+c$OMP THREADPRIVATE(first)
 c      data first /.false./
 c      save first
@@ -1000,4 +1009,6 @@
       save ncorrec
       data ncorrec/0/
+c$OMP THREADPRIVATE(ncorrec)
+
 c
 
@@ -2648,4 +2659,5 @@
       save idetr
       data idetr/3/
+c$OMP THREADPRIVATE(idetr)
 
 c   local:
@@ -2692,4 +2704,5 @@
       data isplit/0/
       save isplit
+c$OMP THREADPRIVATE(isplit)
 
       logical sorties
@@ -2727,4 +2740,6 @@
       data first /.false./
       save first
+c$OMP THREADPRIVATE(first)
+
 cRC
 
@@ -2740,4 +2755,6 @@
       save ncorrec
       data ncorrec/0/
+c$OMP THREADPRIVATE(ncorrec)
+
 c
 
@@ -3755,4 +3772,5 @@
       save idetr
       data idetr/3/
+c$OMP THREADPRIVATE(idetr)
 
 c   local:
@@ -3796,4 +3814,5 @@
       data isplit/0/
       save isplit
+c$OMP THREADPRIVATE(isplit)
 
       logical sorties
@@ -3823,4 +3842,5 @@
       data first /.false./
       save first
+c$OMP THREADPRIVATE(first)
 cRC
 
@@ -3835,4 +3855,5 @@
       save ncorrec
       data ncorrec/0/
+c$OMP THREADPRIVATE(ncorrec)
       
 c
@@ -5160,4 +5181,5 @@
       save idetr
       data idetr/3/
+c$OMP THREADPRIVATE(idetr)
 
 c   local:
@@ -5201,4 +5223,5 @@
       data isplit/0/
       save isplit
+c$OMP THREADPRIVATE(isplit)
 
       logical sorties
@@ -5228,4 +5251,5 @@
       data first /.false./
       save first
+c$OMP THREADPRIVATE(first)
 cRC
 
@@ -5240,4 +5264,5 @@
       save ncorrec
       data ncorrec/0/
+c$OMP THREADPRIVATE(ncorrec)
       
 c
Index: LMDZ4/trunk/libf/phylmd/yamada.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/yamada.F	(revision 983)
+++ LMDZ4/trunk/libf/phylmd/yamada.F	(revision 987)
@@ -55,5 +55,5 @@
       save first
       data first/.true./
-
+c$OMP THREADPRIVATE(first)
 
       integer ig,k
@@ -71,4 +71,5 @@
       save ric,rifc,b1,kap
       data ric,rifc,b1,kap/0.195,0.191,16.6,0.3/
+c$OMP THREADPRIVATE(ric,rifc,b1,kap)
 
       real frif,falpha,fsm
