Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3d_common/cpdet_mod.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3d_common/cpdet_mod.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3d_common/cpdet_mod.F90	(revision 227)
@@ -142,4 +142,5 @@
 ! Parallel version of t2tpot, for an arbitrary number of columns
       USE control_mod, only : planet_type
+      USE parallel_lmdz, only : OMP_CHUNK
       IMPLICIT none
 
@@ -179,5 +180,5 @@
 ! Parallel version of t2tpot, over the full dynamics (scalar) grid
 ! (more efficient than multiple calls to t2tpot_p() with slices of data)
-      USE parallel_lmdz, only : jj_begin,jj_end
+      USE parallel_lmdz, only : jj_begin,jj_end,OMP_CHUNK
       USE control_mod, only : planet_type
       IMPLICIT none
@@ -223,4 +224,5 @@
 ! Parallel version of tpot2t, for an arbitrary number of columns
       USE control_mod, only : planet_type
+      USE parallel_lmdz, only : OMP_CHUNK
       IMPLICIT none
 ! for cpp, nu_venus and t0_venus:
@@ -259,5 +261,5 @@
 ! Parallel version of tpot2t, over the full dynamics (scalar) grid
 ! (more efficient than multiple calls to tpot2t_p() with slices of data)
-      USE parallel_lmdz, only : jj_begin,jj_end
+      USE parallel_lmdz, only : jj_begin,jj_end,OMP_CHUNK
       USE control_mod, only : planet_type
       IMPLICIT none
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3dpar/gcm.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 227)
@@ -599,5 +599,8 @@
 c       write(78,*) 'q',q
 
-c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
+!c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
+!variable temps no longer exists
+c$OMP PARALLEL DEFAULT(SHARED)
+c$OMP1 COPYIN(/temps_r/,/temps_i/,/temps_c/,/logici/,/logicl/)
       CALL leapfrog_p(ucov,vcov,teta,ps,masse,phis,q,
      .              time_0)
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3dpar/sponge_mod_p.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3dpar/sponge_mod_p.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3dpar/sponge_mod_p.F90	(revision 227)
@@ -31,5 +31,5 @@
 
       USE Write_Field_p
-      use parallel_lmdz, only: pole_sud,pole_nord,jj_begin,jj_end
+      use parallel_lmdz, only: pole_sud,pole_nord,jj_begin,jj_end,OMP_CHUNK
       implicit none
 #include "dimensions.h"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aeropacity.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aeropacity.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aeropacity.F90	(revision 227)
@@ -30,6 +30,6 @@
 !     pq                Aerosol mixing ratio
 !     reffrad(ngrid,nlayer,naerkind)         Aerosol effective radius
-!     QREFvis3d(ngrid,nlayermx,naerkind) \ 3d extinction coefficients
-!     QREFir3d(ngrid,nlayermx,naerkind)  / at reference wavelengths
+!     QREFvis3d(ngrid,nlayer,naerkind) \ 3d extinction coefficients
+!     QREFir3d(ngrid,nlayer,naerkind)  / at reference wavelengths
 !
 !     Output
@@ -40,9 +40,9 @@
 !=======================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "callkeys.h"
 #include "comcstfi.h"
-#include "comvert.h"
+!#include "comvert.h"
 
       INTEGER,INTENT(IN) :: ngrid  ! number of atmospheric columns
@@ -54,9 +54,9 @@
       REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! aerosol optical depth
       REAL,INTENT(IN) :: reffrad(ngrid,nlayer,naerkind) ! aerosol effective radius
-      REAL,INTENT(IN) :: QREFvis3d(ngrid,nlayermx,naerkind) ! extinction coefficient in the visible
-      REAL,INTENT(IN) :: QREFir3d(ngrid,nlayermx,naerkind)
+      REAL,INTENT(IN) :: QREFvis3d(ngrid,nlayer,naerkind) ! extinction coefficient in the visible
+      REAL,INTENT(IN) :: QREFir3d(ngrid,nlayer,naerkind)
       REAL,INTENT(OUT):: tau_col(ngrid) !column integrated visible optical depth
       ! BENJAMIN MODIFS
-      real,intent(in) :: cloudfrac(ngrid,nlayermx) ! cloud fraction
+      real,intent(in) :: cloudfrac(ngrid,nlayer) ! cloud fraction
       real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction
       logical,intent(in) :: clearsky
@@ -67,4 +67,5 @@
 
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
       REAL CBRT
       EXTERNAL CBRT
@@ -72,4 +73,5 @@
       INTEGER,SAVE :: i_co2ice=0      ! co2 ice
       INTEGER,SAVE :: i_h2oice=0      ! water ice
+!$OMP THREADPRIVATE(i_co2ice,i_h2oice)
       CHARACTER(LEN=20) :: tracername ! to temporarily store text
 
@@ -135,10 +137,10 @@
            iaer=iaero_co2
 !       1. Initialization
-            aerosol(1:ngrid,1:nlayermx,iaer)=0.0
+            aerosol(1:ngrid,1:nlayer,iaer)=0.0
 !       2. Opacity calculation
             if (noaero) then ! aerosol set to zero
-             aerosol(1:ngrid,1:nlayermx,iaer)=0.0
+             aerosol(1:ngrid,1:nlayer,iaer)=0.0
             elseif (aerofixco2.or.(i_co2ice.eq.0)) then !  CO2 ice cloud prescribed
-               aerosol(1:ngrid,1:nlayermx,iaer)=1.e-9
+               aerosol(1:ngrid,1:nlayer,iaer)=1.e-9
                !aerosol(1:ngrid,12,iaer)=4.0 ! single cloud layer option
             else
@@ -172,8 +174,8 @@
            iaer=iaero_h2o
 !       1. Initialization
-            aerosol(1:ngrid,1:nlayermx,iaer)=0.0
+            aerosol(1:ngrid,1:nlayer,iaer)=0.0
 !       2. Opacity calculation
             if (aerofixh2o.or.(i_h2oice.eq.0).or.clearsky) then
-               aerosol(1:ngrid,1:nlayermx,iaer) =1.e-9
+               aerosol(1:ngrid,1:nlayer,iaer) =1.e-9
 
                ! put cloud at cloudlvl
@@ -226,5 +228,5 @@
 
                if(CLFvarying)then
-                  call totalcloudfrac(ngrid,nq,cloudfrac,totcloudfrac,pplev,pq,aerosol(1:ngrid,1:nlayermx,iaer))
+                  call totalcloudfrac(ngrid,nlayer,nq,cloudfrac,totcloudfrac,pplev,pq,aerosol(1,1,iaer))
                   do ig=1, ngrid
                      do l=1,nlayer-1 ! to stop the rad tran bug
@@ -253,5 +255,5 @@
           iaer=iaero_dust
 !         1. Initialization 
-          aerosol(1:ngrid,1:nlayermx,iaer)=0.0
+          aerosol(1:ngrid,1:nlayer,iaer)=0.0
           
           topdust=30.0 ! km  (used to be 10.0 km) LK
@@ -264,5 +266,5 @@
 !             Typical mixing ratio profile
 
-                 zp=(preff/pplay(ig,l))**(70./topdust)
+                 zp=(pplev(ig,1)/pplay(ig,l))**(70./topdust)
                  expfactor=max(exp(0.007*(1.-max(zp,1.))),1.e-3)
 
@@ -277,6 +279,5 @@
 !          Rescaling each layer to reproduce the choosen (or assimilated)
 !          dust extinction opacity at visible reference wavelength, which
-!          is scaled to the "preff" reference surface pressure available in comvert.h
-!          and stored in startfi.nc
+!          is scaled to the surface pressure pplev(ig,1)
 
             taudusttmp(1:ngrid)=0.
@@ -291,5 +292,5 @@
                   aerosol(ig,l,iaer) = max(1E-20, &
                           dusttau &
-                       *  pplev(ig,1) / preff &
+                       *  pplev(ig,1) / pplev(ig,1) &
                        *  aerosol(ig,l,iaer) &
                        /  taudusttmp(ig))
@@ -307,5 +308,5 @@
 
 !       1. Initialization
-         aerosol(1:ngrid,1:nlayermx,iaer)=0.0
+         aerosol(1:ngrid,1:nlayer,iaer)=0.0
 
 
@@ -317,5 +318,5 @@
 !              Typical mixing ratio profile
 
-               zp=(preff/pplay(ig,l))**(70./30) !emulating topdust
+               zp=(pplev(ig,1)/pplay(ig,l))**(70./30) !emulating topdust
                expfactor=max(exp(0.007*(1.-max(zp,1.))),1.e-3)
 
@@ -335,5 +336,5 @@
                aerosol(ig,l,iaer) = max(1E-20, &
                           1 &
-                       *  pplev(ig,1) / preff &
+                       *  pplev(ig,1) / pplev(ig,1) &
                        *  aerosol(ig,l,iaer) &
                        /  tauh2so4tmp(ig))
@@ -367,5 +368,5 @@
            iaer=iaero_back2lay
 !       1. Initialization
-            aerosol(1:ngrid,1:nlayermx,iaer)=0.0
+            aerosol(1:ngrid,1:nlayer,iaer)=0.0
 !       2. Opacity calculation
           DO ig=1,ngrid
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aeroptproperties.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aeroptproperties.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aeroptproperties.F90	(revision 227)
@@ -32,6 +32,6 @@
 !     ==============================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "callkeys.h"
 
@@ -60,5 +60,5 @@
       INTEGER :: grid_i,grid_j
 !     Intermediate variable
-      REAL :: var_tmp,var3d_tmp(ngrid,nlayermx)
+      REAL :: var_tmp,var3d_tmp(ngrid,nlayer)
 !     Bilinear interpolation factors
       REAL :: kx,ky,k1,k2,k3,k4
@@ -67,4 +67,5 @@
 !     Pi!
       REAL,SAVE :: pi
+!$OMP THREADPRIVATE(pi)
 !     Variables used by the Gauss-Legendre integration:
       INTEGER radius_id,gausind
@@ -87,4 +88,5 @@
                       0.08327674160932,0.06267204829828, &
                       0.04060142982019,0.01761400714091/
+!$OMP THREADPRIVATE(radgaus,weightgaus)
 !     Indices
       INTEGER :: i,j,k,l,m,iaer,idomain
@@ -102,4 +104,5 @@
 !     Grid used to remember which calculation is done
       LOGICAL,SAVE :: checkgrid(refftabsize,nuefftabsize,naerkind,2) = .false.
+!$OMP THREADPRIVATE(refftab,nuefftab,logvratgrid,vratgrid,checkgrid)
 !     Optical properties of the grid (VISIBLE)
       REAL,SAVE :: qsqrefVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
@@ -108,4 +111,5 @@
       REAL,SAVE :: omegVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
       REAL,SAVE :: gVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
+!$OMP THREADPRIVATE(qsqrefVISgrid,qextVISgrid,qscatVISgrid,omegVISgrid,gVISgrid)
 !     Optical properties of the grid (INFRARED)
       REAL,SAVE :: qsqrefIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
@@ -114,4 +118,5 @@
       REAL,SAVE :: omegIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
       REAL,SAVE :: gIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
+!$OMP THREADPRIVATE(qsqrefIRgrid,qextIRgrid,qscatIRgrid,omegIRgrid,gIRgrid)
 !     Optical properties of the grid (REFERENCE WAVELENGTHS)
       REAL,SAVE :: qrefVISgrid(refftabsize,nuefftabsize,naerkind)
@@ -121,13 +126,18 @@
       REAL,SAVE :: omegrefVISgrid(refftabsize,nuefftabsize,naerkind)
       REAL,SAVE :: omegrefIRgrid(refftabsize,nuefftabsize,naerkind)
+!$OMP THREADPRIVATE(qrefVISgrid,qscatrefVISgrid,qrefIRgrid,qscatrefIRgrid,omegrefVISgrid,&
+	!$OMP omegrefIRgrid)
 !     Firstcall
       LOGICAL,SAVE :: firstcall = .true.
+!$OMP THREADPRIVATE(firstcall)
 !     Variables used by the Gauss-Legendre integration:
       REAL,SAVE :: normd(refftabsize,nuefftabsize,naerkind,2)
       REAL,SAVE :: dista(refftabsize,nuefftabsize,naerkind,2,ngau)
       REAL,SAVE :: distb(refftabsize,nuefftabsize,naerkind,2,ngau)
+!$OMP THREADPRIVATE(normd,dista,distb)
 
       REAL,SAVE :: radGAUSa(ngau,naerkind,2)
       REAL,SAVE :: radGAUSb(ngau,naerkind,2)
+!$OMP THREADPRIVATE(radGAUSa,radGAUSb)
 
       REAL,SAVE :: qsqrefVISa(L_NSPECTV,ngau,naerkind)
@@ -141,4 +151,6 @@
       REAL,SAVE :: gVISa(L_NSPECTV,ngau,naerkind)
       REAL,SAVE :: gVISb(L_NSPECTV,ngau,naerkind)
+!$OMP THREADPRIVATE(qsqrefVISa,qrefVISa,qsqrefVISb,qrefVISb,omegVISa, &
+	!$OMP omegrefVISa,omegVISb,omegrefVISb,gVISa,gVISb)
 
       REAL,SAVE :: qsqrefIRa(L_NSPECTI,ngau,naerkind)
@@ -152,4 +164,6 @@
       REAL,SAVE :: gIRa(L_NSPECTI,ngau,naerkind)
       REAL,SAVE :: gIRb(L_NSPECTI,ngau,naerkind)
+!$OMP THREADPRIVATE(qsqrefIRa,qrefIRa,qsqrefIRb,qrefIRb,omegIRa,omegrefIRa,&
+	!$OMP omegIRb,omegrefIRb,gIRa,gIRb)
 
       REAL :: radiusm
@@ -161,24 +175,24 @@
       INTEGER :: ngrid,nlayer
 !     Aerosol effective radius used for radiative transfer (meter)
-      REAL :: reffrad(ngrid,nlayermx,naerkind)
+      REAL,INTENT(IN) :: reffrad(ngrid,nlayer,naerkind)
 !     Aerosol effective variance used for radiative transfer (n.u.)
-      REAL :: nueffrad(ngrid,nlayermx,naerkind)
+      REAL,INTENT(IN) :: nueffrad(ngrid,nlayer,naerkind)
 
 !     Outputs
 !     -------
 
-      REAL :: QVISsQREF3d(ngrid,nlayermx,L_NSPECTV,naerkind)
-      REAL :: omegaVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
-      REAL :: gVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
-
-      REAL :: QIRsQREF3d(ngrid,nlayermx,L_NSPECTI,naerkind)
-      REAL :: omegaIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
-      REAL :: gIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
-
-      REAL :: QREFvis3d(ngrid,nlayermx,naerkind)
-      REAL :: QREFir3d(ngrid,nlayermx,naerkind)
-
-      REAL :: omegaREFvis3d(ngrid,nlayermx,naerkind)
-      REAL :: omegaREFir3d(ngrid,nlayermx,naerkind)
+      REAL,INTENT(OUT) :: QVISsQREF3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL,INTENT(OUT) :: omegaVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL,INTENT(OUT) :: gVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+
+      REAL,INTENT(OUT) :: QIRsQREF3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL,INTENT(OUT) :: omegaIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL,INTENT(OUT) :: gIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+
+      REAL,INTENT(OUT) :: QREFvis3d(ngrid,nlayer,naerkind)
+      REAL,INTENT(OUT) :: QREFir3d(ngrid,nlayer,naerkind)
+
+      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
+      REAL :: omegaREFir3d(ngrid,nlayer,naerkind)
 
       DO iaer = 1, naerkind ! Loop on aerosol kind
@@ -724,5 +738,5 @@
                         k2*omegrefIRgrid(grid_i+1,1,iaer)
           ENDIF                  ! --------------------------------
-        ENDDO !nlayermx
+        ENDDO !nlayer
       ENDDO !ngrid
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aerosol_mod.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aerosol_mod.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/aerosol_mod.F90	(revision 227)
@@ -16,4 +16,5 @@
 ! two-layer simple aerosol model
       integer :: iaero_back2lay = 0
+!$OMP THREADPRIVATE(iaero_co2,iaero_h2o,iaero_dust,iaero_h2so4,noaero,iaero_back2lay)
       
 !==================================================================
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ave_stelspec.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ave_stelspec.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ave_stelspec.F90	(revision 227)
@@ -38,5 +38,5 @@
       integer ifine
 
-      real,allocatable :: lam(:),stel_f(:)
+      real,allocatable,save :: lam(:),stel_f(:) 	!read by master
       real band,lamm,lamp
       real dl
@@ -116,4 +116,5 @@
          End Select
 
+!$OMP MASTER
 	 allocate(lam(Nfine),stel_f(Nfine))
 
@@ -153,4 +154,6 @@
            close(111)
          endif
+!$OMP END MASTER
+!$OMP BARRIER
 	 
          ! sum data by band
@@ -173,6 +176,10 @@
 	 
          STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV))
-         deallocate(lam,stel_f)
-         
+!$OMP BARRIER
+!$OMP MASTER
+	 if (allocated(lam)) deallocate(lam)
+	 if (allocated(stel_f)) deallocate(stel_f)
+!$OMP END MASTER
+!$OMP BARRIER         
       endif
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/bilinearbig.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/bilinearbig.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/bilinearbig.F90	(revision 227)
@@ -14,4 +14,5 @@
       real*8 f2d_arr(nX,nY)
       real*8,save :: x,y
+!$OMP THREADPRIVATE(x,y)
 
       integer strlen
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calc_cpp_mugaz.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calc_cpp_mugaz.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calc_cpp_mugaz.F90	(revision 227)
@@ -20,6 +20,6 @@
       implicit none
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calcenergy_kcm.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calcenergy_kcm.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calcenergy_kcm.F90	(revision 227)
@@ -1,3 +1,3 @@
-subroutine calcenergy_kcm(Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot)
+subroutine calcenergy_kcm(nlayer,Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot)
 
 
@@ -11,6 +11,6 @@
 !     ----------------------------------------------------------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 !#include "callkeys.h"
@@ -19,8 +19,9 @@
 
   ! inputs
-  real Tsurf,T(1:nlayermx)
-  real Play(1:nlayermx),Plev(1:nlayermx+1)
-  real Qsurf,Q(1:nlayermx)
-  real muvar(1,nlayermx+1)
+  integer,intent(in) :: nlayer
+  real Tsurf,T(1:nlayer)
+  real Play(1:nlayer),Plev(1:nlayer+1)
+  real Qsurf,Q(1:nlayer)
+  real muvar(1,nlayer+1)
 
   ! internal
@@ -29,5 +30,5 @@
   real s_c,rho_v,L
   double precision p_v, s_v, nul
-  real VMR(1:nlayermx)
+  real VMR(1:nlayer)
 
   ! output
@@ -41,5 +42,5 @@
 
 
-  do il=1,nlayermx
+  do il=1,nlayer
      VMR(il)=Q(il)*(muvar(1,il+1)/mH2O)
   end do
@@ -47,5 +48,5 @@
 
   Eatmtot = 0.0
-  do il=1,nlayermx
+  do il=1,nlayer
 
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callcorrk.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callcorrk.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callcorrk.F90	(revision 227)
@@ -12,5 +12,6 @@
       use watercommon_h
       use datafile_mod, only: datadir
-      use ioipsl_getincom 
+!      use ioipsl_getincom 
+      use ioipsl_getincom_p
       use gases_h
       use radii_mod, only : su_aer_radii,co2_reffrad,h2o_reffrad,dust_reffrad,h2so4_reffrad,back2lay_reffrad
@@ -35,5 +36,5 @@
 !==================================================================
 
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -42,5 +43,5 @@
 !     Declaration of the arguments (INPUT - OUTPUT) on the LMD GCM grid
 !     Layer #1 is the layer near the ground. 
-!     Layer #nlayermx is the layer at the top.
+!     Layer #nlayer is the layer at the top.
 
       INTEGER,INTENT(IN) :: ngrid ! number of atmospheric columns
@@ -52,14 +53,14 @@
       REAL,INTENT(IN) :: emis(ngrid)     ! LW emissivity
       real,intent(in) :: mu0(ngrid) ! cosine of sun incident angle
-      REAL,INTENT(IN) :: pplev(ngrid,nlayermx+1)  ! inter-layer pressure (Pa)
-      REAL,INTENT(IN) :: pplay(ngrid,nlayermx)    ! mid-layer pressure (Pa)
-      REAL,INTENT(IN) :: pt(ngrid,nlayermx)  ! air temperature (K)
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1)  ! inter-layer pressure (Pa)
+      REAL,INTENT(IN) :: pplay(ngrid,nlayer)    ! mid-layer pressure (Pa)
+      REAL,INTENT(IN) :: pt(ngrid,nlayer)  ! air temperature (K)
       REAL,INTENT(IN) :: tsurf(ngrid)        ! surface temperature (K)
       REAL,INTENT(IN) :: fract(ngrid)        ! fraction of day
       REAL,INTENT(IN) :: dist_star           ! distance star-planet (AU)
-      REAL,INTENT(OUT) :: aerosol(ngrid,nlayermx,naerkind) ! aerosol tau (kg/kg)
-      real,intent(in) :: muvar(ngrid,nlayermx+1)
-      REAL,INTENT(OUT) :: dtlw(ngrid,nlayermx) ! heating rate (K/s) due to LW
-      REAL,INTENT(OUT) :: dtsw(ngrid,nlayermx) ! heating rate (K/s) due to SW
+      REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! aerosol tau (kg/kg)
+      real,intent(in) :: muvar(ngrid,nlayer+1)
+      REAL,INTENT(OUT) :: dtlw(ngrid,nlayer) ! heating rate (K/s) due to LW
+      REAL,INTENT(OUT) :: dtsw(ngrid,nlayer) ! heating rate (K/s) due to SW
       REAL,INTENT(OUT) :: fluxsurf_lw(ngrid)   ! incident LW flux to surf (W/m2)
       REAL,INTENT(OUT) :: fluxsurf_sw(ngrid)   ! incident SW flux to surf (W/m2)
@@ -71,5 +72,5 @@
       REAL,INTENT(OUT) :: tau_col(ngrid) ! diagnostic from aeropacity
 !     for H2O cloud fraction in aeropacity
-      real,intent(in) :: cloudfrac(ngrid,nlayermx)
+      real,intent(in) :: cloudfrac(ngrid,nlayer)
       real,intent(out) :: totcloudfrac(ngrid)
       logical,intent(in) :: clearsky
@@ -79,17 +80,18 @@
 !     Globally varying aerosol optical properties on GCM grid
 !     Not needed everywhere so not in radcommon_h
-      REAL :: QVISsQREF3d(ngrid,nlayermx,L_NSPECTV,naerkind)
-      REAL :: omegaVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
-      REAL :: gVIS3d(ngrid,nlayermx,L_NSPECTV,naerkind)
-
-      REAL :: QIRsQREF3d(ngrid,nlayermx,L_NSPECTI,naerkind)
-      REAL :: omegaIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
-      REAL :: gIR3d(ngrid,nlayermx,L_NSPECTI,naerkind)
-
-!      REAL :: omegaREFvis3d(ngrid,nlayermx,naerkind)
-!      REAL :: omegaREFir3d(ngrid,nlayermx,naerkind) ! not sure of the point of these...
+      REAL :: QVISsQREF3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL :: omegaVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL :: gVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+
+      REAL :: QIRsQREF3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL :: omegaIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL :: gIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+
+!      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
+!      REAL :: omegaREFir3d(ngrid,nlayer,naerkind) ! not sure of the point of these...
 
       REAL,ALLOCATABLE,SAVE :: reffrad(:,:,:) ! aerosol effective radius (m)
       REAL,ALLOCATABLE,SAVE :: nueffrad(:,:,:) ! aerosol effective variance
+!$OMP THREADPRIVATE(reffrad,nueffrad)
 
 !-----------------------------------------------------------------------
@@ -128,4 +130,5 @@
       logical global1d
       save szangle,global1d
+!$OMP THREADPRIVATE(szangle,global1d)
       real*8 taugsurf(L_NSPECTV,L_NGAUSS-1)
       real*8 taugsurfi(L_NSPECTI,L_NGAUSS-1)
@@ -141,9 +144,10 @@
       real*8,save ::  GIAER(L_LEVELS+1,L_NSPECTI,naerkind)
 
-      !REAL :: QREFvis3d(ngrid,nlayermx,naerkind)
-      !REAL :: QREFir3d(ngrid,nlayermx,naerkind)
+      !REAL :: QREFvis3d(ngrid,nlayer,naerkind)
+      !REAL :: QREFir3d(ngrid,nlayer,naerkind)
       !save QREFvis3d, QREFir3d 
       real, dimension(:,:,:), save, allocatable :: QREFvis3d
       real, dimension(:,:,:), save, allocatable :: QREFir3d
+!$OMP THREADPRIVATE(QXVAER,QSVAER,GVAER,QXIAER,QSIAER,GIAER,QREFvis3d,QREFir3d)
 
 
@@ -177,5 +181,5 @@
 
 !     included by RW for runaway greenhouse 1D study
-      real vtmp(nlayermx)
+      real vtmp(nlayer)
       REAL*8 muvarrad(L_LEVELS)
 
@@ -195,6 +199,6 @@
          !!! ALLOCATED instances are necessary because of CLFvarying
          !!! strategy to call callcorrk twice in physiq...
-         IF(.not.ALLOCATED(QREFvis3d)) ALLOCATE(QREFvis3d(ngrid,nlayermx,naerkind))
-         IF(.not.ALLOCATED(QREFir3d)) ALLOCATE(QREFir3d(ngrid,nlayermx,naerkind))
+         IF(.not.ALLOCATED(QREFvis3d)) ALLOCATE(QREFvis3d(ngrid,nlayer,naerkind))
+         IF(.not.ALLOCATED(QREFir3d)) ALLOCATE(QREFir3d(ngrid,nlayer,naerkind))
          ! Effective radius and variance of the aerosols
          IF(.not.ALLOCATED(reffrad)) allocate(reffrad(ngrid,nlayer,naerkind))
@@ -207,5 +211,5 @@
             call abort
          endif
-         call su_aer_radii(ngrid,reffrad,nueffrad)
+         call su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
 	 
 	 
@@ -214,5 +218,5 @@
 !     set up correlated k
          print*, "callcorrk: Correlated-k data base folder:",trim(datadir)
-         call getin("corrkdir",corrkdir)
+         call getin_p("corrkdir",corrkdir)
          print*, "corrkdir = ",corrkdir
          write( tmp1, '(i3)' ) L_NSPECTI
@@ -238,5 +242,5 @@
            PRINT*, 'Simulate global averaged conditions ?'
            global1d = .false. ! default value
-           call getin("global1d",global1d)
+           call getin_p("global1d",global1d)
            write(*,*) "global1d = ",global1d
            ! Test of incompatibility:
@@ -251,5 +255,5 @@
              PRINT *,'(assumed for averaged solar flux S/4)'
              szangle=60.0  ! default value
-             call getin("szangle",szangle)
+             call getin_p("szangle",szangle)
              write(*,*) "szangle = ",szangle
            endif
@@ -266,20 +270,20 @@
 
          if ((iaer.eq.iaero_co2).and.tracer.and.(igcm_co2_ice.gt.0)) then ! treat condensed co2 particles.
-	    call co2_reffrad(ngrid,nq,pq,reffrad(1,1,iaero_co2))
-            print*,'Max. CO2 ice particle size = ',maxval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
-            print*,'Min. CO2 ice particle size = ',minval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
+	    call co2_reffrad(ngrid,nlayer,nq,pq,reffrad(1,1,iaero_co2))
+            print*,'Max. CO2 ice particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
+            print*,'Min. CO2 ice particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
 	 end if
          if ((iaer.eq.iaero_h2o).and.water) then ! treat condensed water particles. to be generalized for other aerosols
-	    call h2o_reffrad(ngrid,pq(1,1,igcm_h2o_ice),pt, &
+	    call h2o_reffrad(ngrid,nlayer,pq(1,1,igcm_h2o_ice),pt, &
                              reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
-            print*,'Max. H2O cloud particle size = ',maxval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
-            print*,'Min. H2O cloud particle size = ',minval(reffrad(1:ngrid,1:nlayermx,iaer))/1.e-6,' um'
+            print*,'Max. H2O cloud particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
+            print*,'Min. H2O cloud particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
          endif
          if(iaer.eq.iaero_dust)then
-	    call dust_reffrad(ngrid,reffrad(1,1,iaero_dust))
+	    call dust_reffrad(ngrid,nlayer,reffrad(1,1,iaero_dust))
             print*,'Dust particle size = ',reffrad(1,1,iaer)/1.e-6,' um'
          endif
          if(iaer.eq.iaero_h2so4)then
-	    call h2so4_reffrad(ngrid,reffrad(1,1,iaero_h2so4))
+	    call h2so4_reffrad(ngrid,nlayer,reffrad(1,1,iaero_h2so4))
             print*,'H2SO4 particle size =',reffrad(1,1,iaer)/1.e-6,' um'
          endif
@@ -318,23 +322,23 @@
             do iaer=1,naerkind
                DO nw=1,L_NSPECTV 
-                  do l=1,nlayermx
-
-                     temp1=QVISsQREF3d(ig,nlayermx+1-l,nw,iaer)         &
-                         *QREFvis3d(ig,nlayermx+1-l,iaer)
-
-                     temp2=QVISsQREF3d(ig,max(nlayermx-l,1),nw,iaer)    &
-                         *QREFvis3d(ig,max(nlayermx-l,1),iaer)
+                  do l=1,nlayer
+
+                     temp1=QVISsQREF3d(ig,nlayer+1-l,nw,iaer)         &
+                         *QREFvis3d(ig,nlayer+1-l,iaer)
+
+                     temp2=QVISsQREF3d(ig,max(nlayer-l,1),nw,iaer)    &
+                         *QREFvis3d(ig,max(nlayer-l,1),iaer)
 
                      qxvaer(2*l,nw,iaer)  = temp1
                      qxvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
 
-                     temp1=temp1*omegavis3d(ig,nlayermx+1-l,nw,iaer)
-                     temp2=temp2*omegavis3d(ig,max(nlayermx-l,1),nw,iaer)
+                     temp1=temp1*omegavis3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=temp2*omegavis3d(ig,max(nlayer-l,1),nw,iaer)
 
                      qsvaer(2*l,nw,iaer)  = temp1
                      qsvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
 
-                     temp1=gvis3d(ig,nlayermx+1-l,nw,iaer)
-                     temp2=gvis3d(ig,max(nlayermx-l,1),nw,iaer)
+                     temp1=gvis3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=gvis3d(ig,max(nlayer-l,1),nw,iaer)
 
                      gvaer(2*l,nw,iaer)  = temp1
@@ -344,11 +348,11 @@
 
                   qxvaer(1,nw,iaer)=qxvaer(2,nw,iaer)
-                  qxvaer(2*nlayermx+1,nw,iaer)=0.
+                  qxvaer(2*nlayer+1,nw,iaer)=0.
 
                   qsvaer(1,nw,iaer)=qsvaer(2,nw,iaer)
-                  qsvaer(2*nlayermx+1,nw,iaer)=0.
+                  qsvaer(2*nlayer+1,nw,iaer)=0.
 
                   gvaer(1,nw,iaer)=gvaer(2,nw,iaer)
-                  gvaer(2*nlayermx+1,nw,iaer)=0.
+                  gvaer(2*nlayer+1,nw,iaer)=0.
 
                end do
@@ -356,23 +360,23 @@
 !     longwave
                DO nw=1,L_NSPECTI 
-                  do l=1,nlayermx
-
-                     temp1=QIRsQREF3d(ig,nlayermx+1-l,nw,iaer)         &
-                          *QREFir3d(ig,nlayermx+1-l,iaer)
-
-                     temp2=QIRsQREF3d(ig,max(nlayermx-l,1),nw,iaer)    &
-                          *QREFir3d(ig,max(nlayermx-l,1),iaer)
+                  do l=1,nlayer
+
+                     temp1=QIRsQREF3d(ig,nlayer+1-l,nw,iaer)         &
+                          *QREFir3d(ig,nlayer+1-l,iaer)
+
+                     temp2=QIRsQREF3d(ig,max(nlayer-l,1),nw,iaer)    &
+                          *QREFir3d(ig,max(nlayer-l,1),iaer)
 
                      qxiaer(2*l,nw,iaer)  = temp1
                      qxiaer(2*l+1,nw,iaer)=(temp1+temp2)/2
 
-                     temp1=temp1*omegair3d(ig,nlayermx+1-l,nw,iaer)
-                     temp2=temp2*omegair3d(ig,max(nlayermx-l,1),nw,iaer)
+                     temp1=temp1*omegair3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=temp2*omegair3d(ig,max(nlayer-l,1),nw,iaer)
 
                      qsiaer(2*l,nw,iaer)  = temp1
                      qsiaer(2*l+1,nw,iaer)=(temp1+temp2)/2
 
-                     temp1=gir3d(ig,nlayermx+1-l,nw,iaer)
-                     temp2=gir3d(ig,max(nlayermx-l,1),nw,iaer)
+                     temp1=gir3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=gir3d(ig,max(nlayer-l,1),nw,iaer)
 
                      giaer(2*l,nw,iaer)  = temp1
@@ -382,11 +386,11 @@
 
                   qxiaer(1,nw,iaer)=qxiaer(2,nw,iaer)
-                  qxiaer(2*nlayermx+1,nw,iaer)=0.
+                  qxiaer(2*nlayer+1,nw,iaer)=0.
 
                   qsiaer(1,nw,iaer)=qsiaer(2,nw,iaer)
-                  qsiaer(2*nlayermx+1,nw,iaer)=0.
+                  qsiaer(2*nlayer+1,nw,iaer)=0.
 
                   giaer(1,nw,iaer)=giaer(2,nw,iaer)
-                  giaer(2*nlayermx+1,nw,iaer)=0.
+                  giaer(2*nlayer+1,nw,iaer)=0.
 
                end do
@@ -481,5 +485,5 @@
       elseif(varfixed)then
 
-         do l=1,nlayermx        ! here we will assign fixed water vapour profiles globally
+         do l=1,nlayer        ! here we will assign fixed water vapour profiles globally
             RH = satval * ((pplay(ig,l)/pplev(ig,1) - 0.02) / 0.98)
             if(RH.lt.0.0) RH=0.0
@@ -507,5 +511,5 @@
 !         call watersat(Ttemp,ptemp,qsat)
 
-         qvar(2*nlayermx+1)= RH * qsat ! ~realistic profile (e.g. 80% saturation at ground)
+         qvar(2*nlayer+1)= RH * qsat ! ~realistic profile (e.g. 80% saturation at ground)
  
       else
@@ -541,5 +545,5 @@
       
             muvarrad(1) = muvarrad(2)
-            muvarrad(2*nlayermx+1)=muvar(ig,1)
+            muvarrad(2*nlayer+1)=muvar(ig,1)
 
             print*,'Recalculating qvar with VARIABLE epsi for kastprof'
@@ -579,5 +583,5 @@
       
          muvarrad(1) = muvarrad(2)
-         muvarrad(2*nlayermx+1)=muvar(ig,1)         
+         muvarrad(2*nlayer+1)=muvar(ig,1)         
       endif
       
@@ -607,5 +611,5 @@
 
       tlevrad(1) = tlevrad(2)
-      tlevrad(2*nlayermx+1)=tsurf(ig)
+      tlevrad(2*nlayer+1)=tsurf(ig)
       
       tmid(1) = tlevrad(2)
@@ -866,8 +870,12 @@
         IF( ALLOCATED( gasi ) ) DEALLOCATE( gasi )
         IF( ALLOCATED( gasv ) ) DEALLOCATE( gasv )
+!$OMP BARRIER
+!$OMP MASTER
         IF( ALLOCATED( pgasref ) ) DEALLOCATE( pgasref )
         IF( ALLOCATED( tgasref ) ) DEALLOCATE( tgasref )
         IF( ALLOCATED( wrefvar ) ) DEALLOCATE( wrefvar )
         IF( ALLOCATED( pfgasref ) ) DEALLOCATE( pfgasref )
+!$OMP END MASTER
+!$OMP BARRIER	
         IF ( ALLOCATED(reffrad)) DEALLOCATE(reffrad)
         IF ( ALLOCATED(nueffrad)) DEALLOCATE(nueffrad)
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callkeys.h
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callkeys.h	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callkeys.h	(revision 227)
@@ -117,2 +117,4 @@
       real J2
       real MassPlanet
+      
+      logical :: iscallphys=.false.!existence of callphys.def
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callsedim.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callsedim.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/callsedim.F	(revision 227)
@@ -28,6 +28,6 @@
 c   -------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -65,8 +65,9 @@
       real epaisseur (ngrid,nlay) ! Layer thickness (m)
       real wq(ngrid,nlay+1) ! displaced tracer mass (kg.m-2)
-c      real dens(ngrid,nlayermx) ! Mean density of the ice part. accounting for dust core
+c      real dens(ngrid,nlay) ! Mean density of the ice part. accounting for dust core
 
 
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
 
 c    ** un petit test de coherence
@@ -125,5 +126,5 @@
           if (water.and.(iq.eq.igcm_h2o_ice)) then
             ! compute radii for h2o_ice 
-             call h2o_reffrad(ngrid,zqi(1,1,igcm_h2o_ice),zt,
+             call h2o_reffrad(ngrid,nlay,zqi(1,1,igcm_h2o_ice),zt,
      &                reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
             ! call sedimentation for h2o_ice
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comdiurn_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comdiurn_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comdiurn_h.F90	(revision 227)
@@ -6,4 +6,5 @@
        real, allocatable, dimension(:) :: sinlon, coslon, sinlat, coslat
        logical :: ldiurn
+!$OMP THREADPRIVATE(sinlon,coslon,sinlat,coslat,ldiurn) !ldiurn is unused
 
        end module comdiurn_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comgeomfi_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comgeomfi_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comgeomfi_h.F90	(revision 227)
@@ -6,4 +6,5 @@
        REAL,ALLOCATABLE,DIMENSION(:) :: long,lati,area
        REAL :: totarea, totarea_planet
+!$OMP THREADPRIVATE(long,lati,area,totarea)
 
        end module comgeomfi_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comsaison_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comsaison_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comsaison_h.F90	(revision 227)
@@ -9,4 +9,5 @@
 
        real, allocatable, dimension(:) :: mu0,fract
+!$OMP THREADPRIVATE(isaison,callsais,dist_star,declin,mu0,fract)
 
        end module comsaison_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comsoil_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comsoil_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comsoil_h.F90	(revision 227)
@@ -14,4 +14,5 @@
        !     in physdem (or set via tabfi, or initialized in
        !                 soil_settings.F)
+!$OMP THREADPRIVATE(layer,mlayer,inertiedat,volcapa)
 
 contains
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/condense_cloud.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/condense_cloud.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/condense_cloud.F90	(revision 227)
@@ -32,5 +32,5 @@
 !     ptsrf(ngrid)          Surface temperature
 !     
-!     pdt(ngrid,nlayermx)   Time derivative before condensation/sublimation of pt
+!     pdt(ngrid,nlayer)   Time derivative before condensation/sublimation of pt
 !     pdtsrf(ngrid)         Time derivative before condensation/sublimation of ptsrf
 !     pqsurf(ngrid,nq)      Sedimentation flux at the surface (kg.m-2.s-1)
@@ -38,7 +38,7 @@
 !     Outputs
 !     -------
-!     pdpsrf(ngrid)         \  Contribution of condensation/sublimation
-!     pdtc(ngrid,nlayermx)  /  to the time derivatives of Ps, pt, and ptsrf
-!     pdtsrfc(ngrid)       /
+!     pdpsrf(ngrid)       \  Contribution of condensation/sublimation
+!     pdtc(ngrid,nlayer)  /  to the time derivatives of Ps, pt, and ptsrf
+!     pdtsrfc(ngrid)     /
 !     
 !     Both
@@ -56,8 +56,8 @@
 !==================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
-#include "comvert.h"
+!#include "comvert.h"
 #include "callkeys.h"
 
@@ -99,30 +99,30 @@
 
       REAL reffrad(ngrid,nlayer) ! radius (m) of the co2 ice particles
-      REAL*8 zt(ngrid,nlayermx)
-      REAL zq(ngrid,nlayermx,nq)
+      REAL*8 zt(ngrid,nlayer)
+      REAL zq(ngrid,nlayer,nq)
       REAL zcpi
-      REAL ztcond (ngrid,nlayermx)
-      REAL ztnuc (ngrid,nlayermx)
+      REAL ztcond (ngrid,nlayer)
+      REAL ztnuc (ngrid,nlayer)
       REAL ztcondsol(ngrid) 
       REAL zdiceco2(ngrid)
-      REAL zcondicea(ngrid,nlayermx), zcondices(ngrid)
+      REAL zcondicea(ngrid,nlayer), zcondices(ngrid)
       REAL zfallice(ngrid), Mfallice(ngrid) 
-      REAL zmflux(nlayermx+1)
-      REAL zu(nlayermx),zv(nlayermx)
+      REAL zmflux(nlayer+1)
+      REAL zu(nlayer),zv(nlayer)
       REAL ztsrf(ngrid)
-      REAL ztc(nlayermx), ztm(nlayermx+1) 
-      REAL zum(nlayermx+1) , zvm(nlayermx+1)
+      REAL ztc(nlayer), ztm(nlayer+1) 
+      REAL zum(nlayer+1) , zvm(nlayer+1)
       LOGICAL condsub(ngrid)
       REAL subptimestep
       Integer Ntime
-      real masse (ngrid,nlayermx), w(ngrid,nlayermx,nq)
-      real wq(ngrid,nlayermx+1)
+      real masse (ngrid,nlayer), w(ngrid,nlayer,nq)
+      real wq(ngrid,nlayer+1)
       real vstokes,reff
 
 !     Special diagnostic variables
-      real tconda1(ngrid,nlayermx)
-      real tconda2(ngrid,nlayermx)
-      real zdtsig (ngrid,nlayermx)
-      real zdt (ngrid,nlayermx)
+      real tconda1(ngrid,nlayer)
+      real tconda2(ngrid,nlayer)
+      real zdtsig (ngrid,nlayer)
+      real zdt (ngrid,nlayer)
 
 !-----------------------------------------------------------------------
@@ -133,6 +133,8 @@
       REAL,SAVE :: cpice=1000.
       REAL,SAVE,ALLOCATABLE,DIMENSION(:) :: emisref
+!$OMP THREADPRIVATE(latcond,ccond,cpice,emisref)
 
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
       REAL,EXTERNAL :: SSUM
 
@@ -140,4 +142,5 @@
 
       INTEGER,SAVE :: i_co2ice=0      ! co2 ice
+!$OMP THREADPRIVATE(i_co2ice)
       CHARACTER(LEN=20) :: tracername ! to temporarily store text
 
@@ -205,5 +208,5 @@
 !     zcondices(ngrid)     condensation rate on the ground  (kg/m2/s)
 !     zfallice(ngrid)      flux of ice falling on surface   (kg/m2/s)
-!     pdtc(ngrid,nlayermx) dT/dt due to phase changes       (K/s)
+!     pdtc(ngrid,nlayer) dT/dt due to phase changes       (K/s)
      
 
@@ -301,5 +304,5 @@
             
 !     sedimentation computed from radius computed from q in module radii_mod
-	 call co2_reffrad(ngrid,nq,zq,reffrad)
+	 call co2_reffrad(ngrid,nlayer,nq,zq,reffrad)
 	 
          do  ilay=1,nlayer
@@ -321,5 +324,5 @@
 !     Computing q after sedimentation
 
-         call vlz_fi(ngrid,zq(1,1,i_co2ice),2.,masse,w(1,1,i_co2ice),wq)
+         call vlz_fi(ngrid,nlayer,zq(1,1,i_co2ice),2.,masse,w(1,1,i_co2ice),wq)
 
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/convadj.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/convadj.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/convadj.F	(revision 227)
@@ -29,6 +29,6 @@
 !     ------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -57,9 +57,9 @@
       INTEGER jcnt, jadrs(ngrid)
 
-      REAL sig(nlayermx+1),sdsig(nlayermx),dsig(nlayermx)
-      REAL zu(ngrid,nlayermx),zv(ngrid,nlayermx)
-      REAL zh(ngrid,nlayermx)
-      REAL zu2(ngrid,nlayermx),zv2(ngrid,nlayermx)
-      REAL zh2(ngrid,nlayermx), zhc(ngrid,nlayermx)
+      REAL sig(nlay+1),sdsig(nlay),dsig(nlay)
+      REAL zu(ngrid,nlay),zv(ngrid,nlay)
+      REAL zh(ngrid,nlay)
+      REAL zu2(ngrid,nlay),zv2(ngrid,nlay)
+      REAL zh2(ngrid,nlay), zhc(ngrid,nlay)
       REAL zhm,zsm,zdsm,zum,zvm,zalpha,zhmc
 
@@ -67,8 +67,10 @@
       INTEGER iq,ico2
       save ico2
-      REAL zq(ngrid,nlayermx,nq), zq2(ngrid,nlayermx,nq)
+!$OMP THREADPRIVATE(ico2)
+      REAL zq(ngrid,nlay,nq), zq2(ngrid,nlay,nq)
       REAL zqm(nq),zqco2m
       real m_co2, m_noco2, A , B
       save A, B
+!$OMP THREADPRIVATE(A,B)
 
       real mtot1, mtot2 , mm1, mm2
@@ -77,4 +79,5 @@
       save firstcall
       data firstcall/.true./
+!$OMP THREADPRIVATE(firstcall)
 
 !     for conservation test
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/dimphy.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/dimphy.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/dimphy.F90	(revision 227)
@@ -2,7 +2,7 @@
   
   INTEGER,SAVE :: klon   ! number of atmospheric columns (for this OpenMP subgrid)
-  INTEGER,SAVE :: klev   ! number of atmospheric layers
-  INTEGER,SAVE :: klevp1 ! number of atmospheric layers+1
-  INTEGER,SAVE :: klevm1 ! number of atmospheric layers-1
+  INTEGER,SAVE :: klev   ! number of atmospheric layers, read by master
+  INTEGER,SAVE :: klevp1 ! number of atmospheric layers+1, read by master
+  INTEGER,SAVE :: klevm1 ! number of atmospheric layers-1, read by master
 !  INTEGER,SAVE :: kflev
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/dimphys.h
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/dimphys.h	(revision 224)
+++ 	(revision )
@@ -1,14 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimphys.h'
-
-! ngridmx : number of horizontal grid points
-! note: the -1/jjm term will be 0; unless jj=1
-      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm)   
-! nlayermx : number of atmospheric layers
-      integer, parameter :: nlayermx = llm 
-! nsoilmx : number of subterranean layers ! nsoilmx is now in comsoil_h
-      !integer, parameter :: nsoilmx = 4 ! for a test 
-      !integer, parameter :: nsoilmx = 18 ! for z1=0.0002 m, depth = 18 m => mars case 
-      !integer, parameter :: nsoilmx = 13 ! for z1=0.03 m, depth = 104.8 m => earth case
-!-----------------------------------------------------------------------
-
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/evap.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/evap.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/evap.F	(revision 227)
@@ -1,3 +1,3 @@
-      subroutine evap(ngrid,nq,dtime,pt, pq, pdq, pdt,  
+      subroutine evap(ngrid,nlayer,nq,dtime,pt, pq, pdq, pdt,  
      $     dqevap,dtevap, qevap, tevap) 
         
@@ -7,6 +7,6 @@
       implicit none
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 
@@ -24,18 +24,18 @@
 !==================================================================
 
-      INTEGER ngrid,nq
+      INTEGER ngrid,nlayer,nq
 
 ! Arguments:
-      REAL pt(ngrid,nlayermx) 
-      REAL pq(ngrid,nlayermx,nq) 
-      REAL pdt(ngrid,nlayermx) 
-      REAL pdq(ngrid,nlayermx,nq) 
-      REAL dqevap(ngrid,nlayermx)
-      REAL dtevap(ngrid,nlayermx)
-      REAL qevap(ngrid,nlayermx,nq)
+      REAL pt(ngrid,nlayer) 
+      REAL pq(ngrid,nlayer,nq) 
+      REAL pdt(ngrid,nlayer) 
+      REAL pdq(ngrid,nlayer,nq) 
+      REAL dqevap(ngrid,nlayer)
+      REAL dtevap(ngrid,nlayer)
+      REAL qevap(ngrid,nlayer,nq)
       REAL dtime
  
 ! Local:
-      REAL tevap(ngrid,nlayermx) 
+      REAL tevap(ngrid,nlayer) 
       REAL zlvdcp
       REAL zlsdcp
@@ -47,5 +47,5 @@
 !
 
-      DO l=1,nlayermx
+      DO l=1,nlayer
         DO ig=1,ngrid
          qevap(ig,l,igcm_h2o_vap)=pq(ig,l,igcm_h2o_vap)	
@@ -57,5 +57,5 @@
       ENDDO
 
-      DO l = 1, nlayermx  
+      DO l = 1, nlayer
       	DO ig = 1, ngrid
          zlvdcp=RLVTT/RCPD!/(1.0+RVTMP2*qevap(ig,l,igcm_h2o_vap))
@@ -77,4 +77,3 @@
       ENDDO
 
-      RETURN
       END
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/forceWCfn.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/forceWCfn.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/forceWCfn.F	(revision 227)
@@ -1,3 +1,3 @@
-      subroutine forceWCfn(ngrid,nq,pplev,pt,dq,dqs)
+      subroutine forceWCfn(ngrid,nlayer,nq,pplev,pt,dq,dqs)
 
       USE tracer_h
@@ -18,17 +18,17 @@
 !==================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 
-      INTEGER ngrid,nq
+      INTEGER ngrid,nlayer,nq
 
       real masse, Wtot, Wdiff
 
-      real pplev(ngrid,nlayermx+1)
+      real pplev(ngrid,nlayer+1)
       real pt(ngrid)
 
       real dqs(ngrid,nq) 
-      real dq(ngrid,nlayermx,nq)
+      real dq(ngrid,nlayer,nq)
 
       integer iq, ig, ilay
@@ -37,5 +37,5 @@
         do ig=1,ngrid
            Wtot = 0.0
-           do ilay=1,nlayermx
+           do ilay=1,nlayer
               masse = (pplev(ig,ilay) - pplev(ig,ilay+1))/g
               Wtot  = Wtot + masse*dq(ig,ilay,iq)
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/gases_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/gases_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/gases_h.F90	(revision 227)
@@ -14,5 +14,5 @@
       integer :: ngasmx
       integer :: vgas
-      character*20,allocatable,DIMENSION(:) :: gnom ! name of the gas
+      character*20,allocatable,DIMENSION(:) :: gnom ! name of the gas, read by master
       real,allocatable,DIMENSION(:) :: gfrac
 
@@ -31,4 +31,7 @@
       integer :: igas_C2H2
       integer :: igas_C2H6
+!!$OMP THREADPRIVATE(ngasmx,vgas,gnom,gfrac,&
+!	!$OMP igas_H2,igas_He,igas_H2O,igas_CO2,igas_CO,igas_N2,&
+!	!$OMP igas_O2,igas_SO2,igas_H2S,igas_CH4,igas_NH3,igas_C2H2,igas_C2H6)
 
       end module gases_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/hydrol.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/hydrol.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/hydrol.F90	(revision 227)
@@ -4,5 +4,6 @@
      pctsrf_sic,sea_ice)
 
-  use ioipsl_getincom 
+!  use ioipsl_getincom 
+  use ioipsl_getincom_p
   use watercommon_h, only: T_h2O_ice_liq, RLFTT, rhowater, mx_eau_sol
   USE surfdat_h
@@ -39,6 +40,6 @@
 !==================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -50,4 +51,5 @@
       real albedoice
       save albedoice
+!$OMP THREADPRIVATE(albedoice)
 
       real snowlayer
@@ -59,4 +61,5 @@
       logical,save :: activerunoff ! enable simple runoff scheme?
       logical,save :: oceanalbvary ! ocean albedo varies with the diurnal cycle?
+!$OMP THREADPRIVATE(oceanbulkavg,activerunoff,oceanalbvary)
 
 !     Arguments
@@ -66,4 +69,5 @@
       real totalrunoff, tsea, oceanarea
       save oceanarea
+!$OMP THREADPRIVATE(runoff,oceanarea)
 
       real ptimestep
@@ -96,6 +100,8 @@
 
       integer, save :: ivap, iliq, iice
+!$OMP THREADPRIVATE(ivap,iliq,iice)
 
       logical, save :: firstcall
+!$OMP THREADPRIVATE(firstcall)
 
       data firstcall /.true./
@@ -108,5 +114,5 @@
          write(*,*)"Activate runnoff into oceans?"
          activerunoff=.false.
-         call getin("activerunoff",activerunoff)
+         call getin_p("activerunoff",activerunoff)
          write(*,*)" activerunoff = ",activerunoff
 	 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ini_archive.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ini_archive.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ini_archive.F	(revision 227)
@@ -40,5 +40,5 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "paramet.h"
 #include "comconst.h"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/inifis.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/inifis.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/inifis.F	(revision 227)
@@ -10,4 +10,5 @@
       use comsoil_h, only: ini_comsoil_h
       use control_mod, only: ecritphy
+      use planete_mod, only: nres
       use planetwide_mod, only: planetwide_sumval
 
@@ -49,9 +50,10 @@
       use datafile_mod, only: datadir
 ! to use  'getin'
-      USE ioipsl_getincom 
+!      USE ioipsl_getincom 
+      USE ioipsl_getincom_p
       IMPLICIT NONE
-#include "dimensions.h"
-#include "dimphys.h"
-#include "planete.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
+!#include "planete.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -78,4 +80,5 @@
       real psurf,pN2 ! added by RW for Gliese 581d N2+CO2
 
+!$OMP MASTER
       rad=prad
       daysec=pdaysec
@@ -88,18 +91,10 @@
       avocado = 6.02214179e23   ! added by RW
 
-! --------------------------------------------------------
-!     The usual Tests
-!     --------------
-      IF (nlayer.NE.nlayermx) THEN
-         PRINT*,'STOP in inifis'
-         PRINT*,'Probleme de dimensions :'
-         PRINT*,'nlayer     = ',nlayer
-         PRINT*,'nlayermx   = ',nlayermx
-         STOP
-      ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
 
       ! read in 'ecritphy' (frequency of calls to physics, in dynamical steps)
       ! (also done in dyn3d/defrun_new but not in LMDZ.COMMON)
-      call getin("ecritphy",ecritphy)
+      call getin_p("ecritphy",ecritphy)
 
 ! --------------------------------------------------------------
@@ -107,10 +102,15 @@
 ! --------------------------------------------------------------
      
+!$OMP MASTER     
       ! check that 'callphys.def' file is around
       OPEN(99,file='callphys.def',status='old',form='formatted'
      &     ,iostat=ierr)
       CLOSE(99)
+      IF(ierr.EQ.0) iscallphys=.true. !iscallphys initialised as false in callkeys.h
+!$OMP END MASTER
+!$OMP BARRIER
       
-      IF(ierr.EQ.0) THEN
+!!!      IF(ierr.EQ.0) THEN
+      IF(iscallphys) THEN
          PRINT*
          PRINT*
@@ -121,10 +121,10 @@
          write(*,*) "Directory where external input files are:"
          ! default 'datadir' is set in "datadir_mod"
-         call getin("datadir",datadir) ! default path
+         call getin_p("datadir",datadir) ! default path
          write(*,*) " datadir = ",trim(datadir)
 
          write(*,*) "Run with or without tracer transport ?"
          tracer=.false. ! default value
-         call getin("tracer",tracer)
+         call getin_p("tracer",tracer)
          write(*,*) " tracer = ",tracer
 
@@ -132,5 +132,5 @@
      &      " due to tracer evaporation/condensation?"
          mass_redistrib=.false. ! default value
-         call getin("mass_redistrib",mass_redistrib)
+         call getin_p("mass_redistrib",mass_redistrib)
          write(*,*) " mass_redistrib = ",mass_redistrib
 
@@ -138,5 +138,5 @@
          write(*,*) "(if diurnal=false, diurnal averaged solar heating)"
          diurnal=.true. ! default value
-         call getin("diurnal",diurnal)
+         call getin_p("diurnal",diurnal)
          write(*,*) " diurnal = ",diurnal
 
@@ -145,25 +145,25 @@
      &   "set in 'start'"
          season=.true. ! default value
-         call getin("season",season)
+         call getin_p("season",season)
          write(*,*) " season = ",season
 
          write(*,*) "Tidally resonant rotation ?"
          tlocked=.false. ! default value
-         call getin("tlocked",tlocked)
+         call getin_p("tlocked",tlocked)
          write(*,*) "tlocked = ",tlocked
 
          write(*,*) "Saturn ring shadowing ?"
          rings_shadow = .false.
-         call getin("rings_shadow", rings_shadow)
+         call getin_p("rings_shadow", rings_shadow)
          write(*,*) "rings_shadow = ", rings_shadow
          
          write(*,*) "Compute latitude-dependent gravity field?"
          oblate = .false.
-         call getin("oblate", oblate)
+         call getin_p("oblate", oblate)
          write(*,*) "oblate = ", oblate
 
          write(*,*) "Flattening of the planet (a-b)/a "
          flatten = 0.0
-         call getin("flatten", flatten)
+         call getin_p("flatten", flatten)
          write(*,*) "flatten = ", flatten
          
@@ -171,15 +171,15 @@
          write(*,*) "Needed if oblate=.true.: J2"
          J2 = 0.0
-         call getin("J2", J2)
+         call getin_p("J2", J2)
          write(*,*) "J2 = ", J2
          
          write(*,*) "Needed if oblate=.true.: Planet mass (*1e24 kg)"
          MassPlanet = 0.0
-         call getin("MassPlanet", MassPlanet)
+         call getin_p("MassPlanet", MassPlanet)
          write(*,*) "MassPlanet = ", MassPlanet         
 
          write(*,*) "Needed if oblate=.true.: Planet mean radius (m)"
          Rmean = 0.0
-         call getin("Rmean", Rmean)
+         call getin_p("Rmean", Rmean)
          write(*,*) "Rmean = ", Rmean
          
@@ -193,40 +193,40 @@
          write(*,*) "Tidal resonance ratio ?"
          nres=0          ! default value
-         call getin("nres",nres)
+         call getin_p("nres",nres)
          write(*,*) "nres = ",nres
 
          write(*,*) "Write some extra output to the screen ?"
          lwrite=.false. ! default value
-         call getin("lwrite",lwrite)
+         call getin_p("lwrite",lwrite)
          write(*,*) " lwrite = ",lwrite
 
          write(*,*) "Save statistics in file stats.nc ?"
          callstats=.true. ! default value
-         call getin("callstats",callstats)
+         call getin_p("callstats",callstats)
          write(*,*) " callstats = ",callstats
 
          write(*,*) "Test energy conservation of model physics ?"
          enertest=.false. ! default value
-         call getin("enertest",enertest)
+         call getin_p("enertest",enertest)
          write(*,*) " enertest = ",enertest
 
          write(*,*) "Check to see if cpp values used match gases.def ?"
          check_cpp_match=.true. ! default value
-         call getin("check_cpp_match",check_cpp_match)
+         call getin_p("check_cpp_match",check_cpp_match)
          write(*,*) " check_cpp_match = ",check_cpp_match
 
          write(*,*) "call radiative transfer ?"
          callrad=.true. ! default value
-         call getin("callrad",callrad)
+         call getin_p("callrad",callrad)
          write(*,*) " callrad = ",callrad
 
          write(*,*) "call correlated-k radiative transfer ?"
          corrk=.true. ! default value
-         call getin("corrk",corrk)
+         call getin_p("corrk",corrk)
          write(*,*) " corrk = ",corrk
 
          write(*,*) "prohibit calculations outside corrk T grid?"
          strictboundcorrk=.true. ! default value
-         call getin("strictboundcorrk",strictboundcorrk)
+         call getin_p("strictboundcorrk",strictboundcorrk)
          write(*,*) "strictboundcorrk = ",strictboundcorrk
 
@@ -234,5 +234,5 @@
      &              "(matters only if callrad=T)"
          callgasvis=.false. ! default value
-         call getin("callgasvis",callgasvis)
+         call getin_p("callgasvis",callgasvis)
          write(*,*) " callgasvis = ",callgasvis
         
@@ -240,30 +240,30 @@
      &              "(matters only if callrad=T)"
          continuum=.true. ! default value
-         call getin("continuum",continuum)
+         call getin_p("continuum",continuum)
          write(*,*) " continuum = ",continuum
 
          write(*,*) "use analytic function for H2O continuum ?"
          H2Ocont_simple=.false. ! default value
-         call getin("H2Ocont_simple",H2Ocont_simple)
+         call getin_p("H2Ocont_simple",H2Ocont_simple)
          write(*,*) " H2Ocont_simple = ",H2Ocont_simple
  
          write(*,*) "call turbulent vertical diffusion ?"
          calldifv=.true. ! default value
-         call getin("calldifv",calldifv)
+         call getin_p("calldifv",calldifv)
          write(*,*) " calldifv = ",calldifv
 
          write(*,*) "use turbdiff instead of vdifc ?"
          UseTurbDiff=.true. ! default value
-         call getin("UseTurbDiff",UseTurbDiff)
+         call getin_p("UseTurbDiff",UseTurbDiff)
          write(*,*) " UseTurbDiff = ",UseTurbDiff
 
          write(*,*) "call convective adjustment ?"
          calladj=.true. ! default value
-         call getin("calladj",calladj)
+         call getin_p("calladj",calladj)
          write(*,*) " calladj = ",calladj
 
          write(*,*) "call CO2 condensation ?"
          co2cond=.false. ! default value
-         call getin("co2cond",co2cond)
+         call getin_p("co2cond",co2cond)
          write(*,*) " co2cond = ",co2cond
 ! Test of incompatibility
@@ -275,10 +275,10 @@
          write(*,*) "CO2 supersaturation level ?"
          co2supsat=1.0 ! default value
-         call getin("co2supsat",co2supsat)
+         call getin_p("co2supsat",co2supsat)
          write(*,*) " co2supsat = ",co2supsat
 
          write(*,*) "Radiative timescale for Newtonian cooling ?"
          tau_relax=30. ! default value
-         call getin("tau_relax",tau_relax)
+         call getin_p("tau_relax",tau_relax)
          write(*,*) " tau_relax = ",tau_relax
          tau_relax=tau_relax*24*3600 ! convert Earth days --> seconds
@@ -286,5 +286,5 @@
          write(*,*)"call thermal conduction in the soil ?"
          callsoil=.true. ! default value
-         call getin("callsoil",callsoil)
+         call getin_p("callsoil",callsoil)
          write(*,*) " callsoil = ",callsoil
          
@@ -292,40 +292,40 @@
      &             " physical timestep"
          iradia=1 ! default value
-         call getin("iradia",iradia)
+         call getin_p("iradia",iradia)
          write(*,*)" iradia = ",iradia
        
          write(*,*)"Rayleigh scattering ?"
          rayleigh=.false.
-         call getin("rayleigh",rayleigh)
+         call getin_p("rayleigh",rayleigh)
          write(*,*)" rayleigh = ",rayleigh
 
          write(*,*) "Use blackbody for stellar spectrum ?"
          stelbbody=.false. ! default value
-         call getin("stelbbody",stelbbody)
+         call getin_p("stelbbody",stelbbody)
          write(*,*) " stelbbody = ",stelbbody
 
          write(*,*) "Stellar blackbody temperature ?"
          stelTbb=5800.0 ! default value
-         call getin("stelTbb",stelTbb)
+         call getin_p("stelTbb",stelTbb)
          write(*,*) " stelTbb = ",stelTbb
 
          write(*,*)"Output mean OLR in 1D?"
          meanOLR=.false.
-         call getin("meanOLR",meanOLR)
+         call getin_p("meanOLR",meanOLR)
          write(*,*)" meanOLR = ",meanOLR
 
          write(*,*)"Output spectral OLR in 3D?"
          specOLR=.false.
-         call getin("specOLR",specOLR)
+         call getin_p("specOLR",specOLR)
          write(*,*)" specOLR = ",specOLR
 
          write(*,*)"Operate in kastprof mode?"
          kastprof=.false.
-         call getin("kastprof",kastprof)
+         call getin_p("kastprof",kastprof)
          write(*,*)" kastprof = ",kastprof
 
          write(*,*)"Uniform absorption in radiative transfer?"
          graybody=.false.
-         call getin("graybody",graybody)
+         call getin_p("graybody",graybody)
          write(*,*)" graybody = ",graybody
 
@@ -333,15 +333,15 @@
          write(*,*) "Use slab-ocean ?"
          ok_slab_ocean=.false.         ! default value
-         call getin("ok_slab_ocean",ok_slab_ocean)
+         call getin_p("ok_slab_ocean",ok_slab_ocean)
          write(*,*) "ok_slab_ocean = ",ok_slab_ocean
 
          write(*,*) "Use slab-sea-ice ?"
          ok_slab_sic=.true.         ! default value
-         call getin("ok_slab_sic",ok_slab_sic)
+         call getin_p("ok_slab_sic",ok_slab_sic)
          write(*,*) "ok_slab_sic = ",ok_slab_sic
 
          write(*,*) "Use heat transport for the ocean ?"
          ok_slab_heat_transp=.true.   ! default value
-         call getin("ok_slab_heat_transp",ok_slab_heat_transp)
+         call getin_p("ok_slab_heat_transp",ok_slab_heat_transp)
          write(*,*) "ok_slab_heat_transp = ",ok_slab_heat_transp
 
@@ -357,10 +357,10 @@
          write(*,*)"Stratospheric temperature for kastprof mode?"
          Tstrat=167.0
-         call getin("Tstrat",Tstrat)
+         call getin_p("Tstrat",Tstrat)
          write(*,*)" Tstrat = ",Tstrat
 
          write(*,*)"Remove lower boundary?"
          nosurf=.false.
-         call getin("nosurf",nosurf)
+         call getin_p("nosurf",nosurf)
          write(*,*)" nosurf = ",nosurf
 
@@ -375,10 +375,10 @@
      .             "... matters only if callsoil=F"
          intheat=0.
-         call getin("intheat",intheat)
+         call getin_p("intheat",intheat)
          write(*,*)" intheat = ",intheat
 
          write(*,*)"Use Newtonian cooling for radiative transfer?"
          newtonian=.false.
-         call getin("newtonian",newtonian)
+         call getin_p("newtonian",newtonian)
          write(*,*)" newtonian = ",newtonian
 
@@ -399,5 +399,5 @@
          write(*,*)"Test physics timescale in 1D?"
          testradtimes=.false.
-         call getin("testradtimes",testradtimes)
+         call getin_p("testradtimes",testradtimes)
          write(*,*)" testradtimes = ",testradtimes
 
@@ -411,15 +411,15 @@
          write(*,*)"Default planetary temperature?"
          tplanet=215.0
-         call getin("tplanet",tplanet)
+         call getin_p("tplanet",tplanet)
          write(*,*)" tplanet = ",tplanet
 
          write(*,*)"Which star?"
          startype=1 ! default value = Sol
-         call getin("startype",startype)
+         call getin_p("startype",startype)
          write(*,*)" startype = ",startype
 
          write(*,*)"Value of stellar flux at 1 AU?"
          Fat1AU=1356.0 ! default value = Sol today
-         call getin("Fat1AU",Fat1AU)
+         call getin_p("Fat1AU",Fat1AU)
          write(*,*)" Fat1AU = ",Fat1AU
 
@@ -429,15 +429,15 @@
          write(*,*)"Varying H2O cloud fraction?"
          CLFvarying=.false.     ! default value
-         call getin("CLFvarying",CLFvarying)
+         call getin_p("CLFvarying",CLFvarying)
          write(*,*)" CLFvarying = ",CLFvarying
 
          write(*,*)"Value of fixed H2O cloud fraction?"
          CLFfixval=1.0                ! default value
-         call getin("CLFfixval",CLFfixval)
+         call getin_p("CLFfixval",CLFfixval)
          write(*,*)" CLFfixval = ",CLFfixval
 
          write(*,*)"fixed radii for Cloud particles?"
          radfixed=.false. ! default value
-         call getin("radfixed",radfixed)
+         call getin_p("radfixed",radfixed)
          write(*,*)" radfixed = ",radfixed
 
@@ -448,40 +448,40 @@
 	 write(*,*)"Number mixing ratio of CO2 ice particles:"
          Nmix_co2=1.e6 ! default value
-         call getin("Nmix_co2",Nmix_co2)
+         call getin_p("Nmix_co2",Nmix_co2)
          write(*,*)" Nmix_co2 = ",Nmix_co2
 
 !         write(*,*)"Number of radiatively active aerosols:"
 !         naerkind=0. ! default value
-!         call getin("naerkind",naerkind)
+!         call getin_p("naerkind",naerkind)
 !         write(*,*)" naerkind = ",naerkind
 
          write(*,*)"Opacity of dust (if used):"
          dusttau=0. ! default value
-         call getin("dusttau",dusttau)
+         call getin_p("dusttau",dusttau)
          write(*,*)" dusttau = ",dusttau
 
          write(*,*)"Radiatively active CO2 aerosols?"
          aeroco2=.false.     ! default value
-         call getin("aeroco2",aeroco2)
+         call getin_p("aeroco2",aeroco2)
          write(*,*)" aeroco2 = ",aeroco2
 
          write(*,*)"Fixed CO2 aerosol distribution?"
          aerofixco2=.false.     ! default value
-         call getin("aerofixco2",aerofixco2)
+         call getin_p("aerofixco2",aerofixco2)
          write(*,*)" aerofixco2 = ",aerofixco2
 
          write(*,*)"Radiatively active water ice?"
          aeroh2o=.false.     ! default value
-         call getin("aeroh2o",aeroh2o)
+         call getin_p("aeroh2o",aeroh2o)
          write(*,*)" aeroh2o = ",aeroh2o
 
          write(*,*)"Fixed H2O aerosol distribution?"
          aerofixh2o=.false.     ! default value
-         call getin("aerofixh2o",aerofixh2o)
+         call getin_p("aerofixh2o",aerofixh2o)
          write(*,*)" aerofixh2o = ",aerofixh2o
 
          write(*,*)"Radiatively active sulfuric acid aersols?"
          aeroh2so4=.false.     ! default value
-         call getin("aeroh2so4",aeroh2so4)
+         call getin_p("aeroh2so4",aeroh2so4)
          write(*,*)" aeroh2so4 = ",aeroh2so4
 	 
@@ -490,5 +490,5 @@
 	 write(*,*)"Radiatively active two-layer aersols?"
          aeroback2lay=.false.     ! default value
-         call getin("aeroback2lay",aeroback2lay)
+         call getin_p("aeroback2lay",aeroback2lay)
          write(*,*)" aeroback2lay = ",aeroback2lay
 
@@ -496,5 +496,5 @@
      &              "in the tropospheric layer (visible)"
          obs_tau_col_tropo=8.D0
-         call getin("obs_tau_col_tropo",obs_tau_col_tropo)
+         call getin_p("obs_tau_col_tropo",obs_tau_col_tropo)
          write(*,*)" obs_tau_col_tropo = ",obs_tau_col_tropo
 
@@ -502,25 +502,25 @@
      &              "in the stratospheric layer (visible)"
          obs_tau_col_strato=0.08D0
-         call getin("obs_tau_col_strato",obs_tau_col_strato)
+         call getin_p("obs_tau_col_strato",obs_tau_col_strato)
          write(*,*)" obs_tau_col_strato = ",obs_tau_col_strato
 
          write(*,*)"TWOLAY AEROSOL: pres_bottom_tropo? in pa"
          pres_bottom_tropo=66000.0
-         call getin("pres_bottom_tropo",pres_bottom_tropo)
+         call getin_p("pres_bottom_tropo",pres_bottom_tropo)
          write(*,*)" pres_bottom_tropo = ",pres_bottom_tropo
 
          write(*,*)"TWOLAY AEROSOL: pres_top_tropo? in pa"
          pres_top_tropo=18000.0
-         call getin("pres_top_tropo",pres_top_tropo)
+         call getin_p("pres_top_tropo",pres_top_tropo)
          write(*,*)" pres_top_tropo = ",pres_top_tropo
 
          write(*,*)"TWOLAY AEROSOL: pres_bottom_strato? in pa"
          pres_bottom_strato=2000.0
-         call getin("pres_bottom_strato",pres_bottom_strato)
+         call getin_p("pres_bottom_strato",pres_bottom_strato)
          write(*,*)" pres_bottom_strato = ",pres_bottom_strato
 
          write(*,*)"TWOLAY AEROSOL: pres_top_strato? in pa"
          pres_top_strato=100.0
-         call getin("pres_top_strato",pres_top_strato)
+         call getin_p("pres_top_strato",pres_top_strato)
          write(*,*)" pres_top_strato = ",pres_top_strato
 
@@ -528,5 +528,5 @@
      &              "tropospheric layer, in meters"
          size_tropo=2.e-6
-         call getin("size_tropo",size_tropo)
+         call getin_p("size_tropo",size_tropo)
          write(*,*)" size_tropo = ",size_tropo
 
@@ -534,5 +534,5 @@
      &              "stratospheric layer, in meters"
          size_strato=1.e-7
-         call getin("size_strato",size_strato)
+         call getin_p("size_strato",size_strato)
          write(*,*)" size_strato = ",size_strato
 
@@ -541,5 +541,5 @@
          write(*,*)"Cloud pressure level (with kastprof only):"
          cloudlvl=0. ! default value
-         call getin("cloudlvl",cloudlvl)
+         call getin_p("cloudlvl",cloudlvl)
          write(*,*)" cloudlvl = ",cloudlvl
 
@@ -547,15 +547,15 @@
          Tstrat=167.0
          varactive=.false.
-         call getin("varactive",varactive)
+         call getin_p("varactive",varactive)
          write(*,*)" varactive = ",varactive
 
          write(*,*)"Is the variable gas species distribution set?"
          varfixed=.false.
-         call getin("varfixed",varfixed)
+         call getin_p("varfixed",varfixed)
          write(*,*)" varfixed = ",varfixed
 
          write(*,*)"What is the saturation % of the variable species?"
          satval=0.8
-         call getin("satval",satval)
+         call getin_p("satval",satval)
          write(*,*)" satval = ",satval
 
@@ -570,10 +570,10 @@
          write(*,*) "Gravitationnal sedimentation ?"
          sedimentation=.false. ! default value
-         call getin("sedimentation",sedimentation)
+         call getin_p("sedimentation",sedimentation)
          write(*,*) " sedimentation = ",sedimentation
 
          write(*,*) "Compute water cycle ?"
          water=.false. ! default value
-         call getin("water",water)
+         call getin_p("water",water)
          write(*,*) " water = ",water
          
@@ -587,5 +587,5 @@
          write(*,*) "Include water condensation ?"
          watercond=.false. ! default value
-         call getin("watercond",watercond)
+         call getin_p("watercond",watercond)
          write(*,*) " watercond = ",watercond
 
@@ -599,40 +599,40 @@
          write(*,*) "Include water precipitation ?"
          waterrain=.false. ! default value
-         call getin("waterrain",waterrain)
+         call getin_p("waterrain",waterrain)
          write(*,*) " waterrain = ",waterrain
 
          write(*,*) "Include surface hydrology ?"
          hydrology=.false. ! default value
-         call getin("hydrology",hydrology)
+         call getin_p("hydrology",hydrology)
          write(*,*) " hydrology = ",hydrology
 
          write(*,*) "Evolve surface water sources ?"
          sourceevol=.false. ! default value
-         call getin("sourceevol",sourceevol)
+         call getin_p("sourceevol",sourceevol)
          write(*,*) " sourceevol = ",sourceevol
 
          write(*,*) "Ice evolution timestep ?"
          icetstep=100.0 ! default value
-         call getin("icetstep",icetstep)
+         call getin_p("icetstep",icetstep)
          write(*,*) " icetstep = ",icetstep
 
          write(*,*) "Snow albedo ?"
          albedosnow=0.5         ! default value
-         call getin("albedosnow",albedosnow)
+         call getin_p("albedosnow",albedosnow)
          write(*,*) " albedosnow = ",albedosnow
 
          write(*,*) "Maximum ice thickness ?"
          maxicethick=2.0         ! default value
-         call getin("maxicethick",maxicethick)
+         call getin_p("maxicethick",maxicethick)
          write(*,*) " maxicethick = ",maxicethick
 
          write(*,*) "Freezing point of seawater ?"
          Tsaldiff=-1.8          ! default value
-         call getin("Tsaldiff",Tsaldiff)
+         call getin_p("Tsaldiff",Tsaldiff)
          write(*,*) " Tsaldiff = ",Tsaldiff
 
          write(*,*) "Does user want to force cpp and mugaz?"
          force_cpp=.false. ! default value
-         call getin("force_cpp",force_cpp)
+         call getin_p("force_cpp",force_cpp)
          write(*,*) " force_cpp = ",force_cpp
 
@@ -640,5 +640,5 @@
            mugaz = -99999.
            PRINT *,'MEAN MOLECULAR MASS in g mol-1 ?'
-           call getin("mugaz",mugaz)
+           call getin_p("mugaz",mugaz)
            IF (mugaz.eq.-99999.) THEN
                PRINT *, "mugaz must be set if force_cpp = T"
@@ -649,5 +649,5 @@
            cpp = -99999.
            PRINT *,'SPECIFIC HEAT CAPACITY in J K-1 kg-1 ?'
-           call getin("cpp",cpp)
+           call getin_p("cpp",cpp)
            IF (cpp.eq.-99999.) THEN
                PRINT *, "cpp must be set if force_cpp = T"
@@ -711,5 +711,8 @@
       ENDDO
 
+!$OMP MASTER
       pi=2.*asin(1.) ! NB: pi is a common in comcstfi.h
+!$OMP END MASTER
+!$OMP BARRIER
 
       ! allocate "comsoil_h" arrays
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniorbit.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniorbit.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniorbit.F	(revision 227)
@@ -1,4 +1,7 @@
       SUBROUTINE iniorbit
      $     (papoastr,pperiastr,pyear_day,pperi_day,pobliq)
+      
+      USE planete_mod, only: apoastr, periastr, year_day, obliquit,
+     &                       peri_day, e_elips, p_elips, timeperi
       IMPLICIT NONE
 
@@ -19,5 +22,5 @@
 c   ----------
 c   - Doit etre appele avant d'utiliser orbite.
-c   - initialise une partie du common planete.h
+c   - initialise une partie du common planete_mod
 c
 c   Arguments:
@@ -35,5 +38,5 @@
 c   -------------
 
-#include "planete.h"
+!#include "planete.h"
 #include "comcstfi.h"
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniphysiq.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniphysiq.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniphysiq.F90	(revision 227)
@@ -17,6 +17,9 @@
                        rlatd ! latitudes
 use infotrac, only : nqtot ! number of advected tracers
+use planete_mod, only: ini_planete_mod
 
 implicit none
+include "dimensions.h"
+include "comvert.h"
 
 real,intent(in) :: prad ! radius of the planet (m)
@@ -58,6 +61,6 @@
 ENDIF
 
-!$OMP PARALLEL PRIVATE(ibegin,iend) 
-!$OMP+         SHARED(parea,pcu,pcv,plon,plat)
+!$OMP PARALLEL PRIVATE(ibegin,iend) & 
+	!$OMP SHARED(parea,pcu,pcv,plon,plat)
       
 offset=0
@@ -67,4 +70,7 @@
 rlond(1:klon_omp)=plon(offset+klon_omp_begin:offset+klon_omp_end)
 rlatd(1:klon_omp)=plat(offset+klon_omp_begin:offset+klon_omp_end)
+
+! copy over preff , ap() and bp() 
+call ini_planete_mod(nlayer,preff,ap,bp)
 
 ! copy some fundamental parameters to physics 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/initracer.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/initracer.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/initracer.F	(revision 227)
@@ -24,5 +24,5 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniwrite_specIR.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniwrite_specIR.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniwrite_specIR.F	(revision 227)
@@ -34,5 +34,5 @@
 #include "netcdf.inc"
 #include "serre.h"
-#include"dimphys.h"
+!#include"dimphys.h"
 
 c   Arguments:
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniwrite_specVI.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniwrite_specVI.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iniwrite_specVI.F	(revision 227)
@@ -34,5 +34,5 @@
 #include "netcdf.inc"
 #include "serre.h"
-#include"dimphys.h"
+!#include"dimphys.h"
 
 c   Arguments:
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2H2.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2H2.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2H2.F90	(revision 227)
@@ -43,5 +43,5 @@
       logical firstcall
 
-      save wn_arr, temp_arr, abs_arr
+      save wn_arr, temp_arr, abs_arr !read by master
 
       character*100 dt_file
@@ -72,4 +72,5 @@
          dt_file=TRIM(datadir)//'/continuum_data/H2-H2_norm_2011.cia'
 
+!$OMP MASTER
          open(33,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
@@ -102,4 +103,6 @@
          endif
          close(33)
+!$OMP END MASTER
+!$OMP BARRIER
 
          print*,'interpolateH2H2: At wavenumber ',wn,' cm^-1'
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2He.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2He.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2He.F90	(revision 227)
@@ -45,5 +45,5 @@
       logical firstcall
 
-      save wn_arr, temp_arr, abs_arr
+      save wn_arr, temp_arr, abs_arr !read by master
 
       character*100 dt_file
@@ -73,5 +73,6 @@
 !     1.1 Open the ASCII files
          dt_file=TRIM(datadir)//'/continuum_data/H2-He_norm_2011.cia'
-
+	 
+!$OMP MASTER
          open(33,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
@@ -104,4 +105,6 @@
          endif
          close(33)
+!$OMP END MASTER
+!$OMP BARRIER
 
          print*,'interpolateH2He: At wavenumber ',wn,' cm^-1'
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2Ocont_CKD.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2Ocont_CKD.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateH2Ocont_CKD.F90	(revision 227)
@@ -43,5 +43,5 @@
       logical firstcall
 
-      save wn_arr, temp_arr, abs_arrS, abs_arrF
+      save wn_arr, temp_arr, abs_arrS, abs_arrF !read by master
 
       character*100 dt_file
@@ -57,4 +57,5 @@
 !     1.1 Open the ASCII files
 
+!$OMP MASTER
          ! nu array
          dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_NU.dat'
@@ -129,4 +130,6 @@
          print*,'   H2O pressure ',presS,' Pa'
          print*,'   air pressure ',presF,' Pa'
+!$OMP END MASTER
+!$OMP BARRIER
 	 
       endif
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateN2H2.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateN2H2.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateN2H2.F90	(revision 227)
@@ -44,5 +44,5 @@
   logical firstcall
 
-  save wn_arr, temp_arr, abs_arr
+  save wn_arr, temp_arr, abs_arr !read by master
 
   character*100 dt_file
@@ -72,4 +72,5 @@
      dt_file=TRIM(datadir)//'/continuum_data/N2-H2_2011.cia'
 
+!$OMP MASTER
      open(33,file=dt_file,form='formatted',status='old',iostat=ios)
      if (ios.ne.0) then        ! file not found
@@ -102,4 +103,6 @@
      endif
      close(33)
+!$OMP END MASTER
+!$OMP BARRIER
 
      print*,'interpolateN2H2: At wavenumber ',wn,' cm^-1'
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateN2N2.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateN2N2.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/interpolateN2N2.F90	(revision 227)
@@ -43,5 +43,5 @@
   logical firstcall
 
-  save wn_arr, temp_arr, abs_arr
+  save wn_arr, temp_arr, abs_arr !read by master
 
   character*100 dt_file
@@ -70,4 +70,5 @@
      dt_file=TRIM(datadir)//'/continuum_data/N2-N2_2011.cia'
 
+!$OMP MASTER
      open(33,file=dt_file,form='formatted',status='old',iostat=ios)
      if (ios.ne.0) then        ! file not found
@@ -100,4 +101,6 @@
      endif
      close(33)
+!$OMP END MASTER
+!$OMP BARRIER
 
      print*,'interpolateN2N2: At wavenumber ',wn,' cm^-1'
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iostart.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iostart.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/iostart.F90	(revision 227)
@@ -5,4 +5,5 @@
     INTEGER,SAVE :: nid_start ! NetCDF file identifier for startfi.nc file
     INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file
+!$OMP THREADPRIVATE(nid_start,nid_restart)
     
     ! restartfi.nc file dimension identifiers: (see open_restartphy())
@@ -16,4 +17,5 @@
     INTEGER,SAVE :: idim8 ! "ocean_layers" dimension
     INTEGER,SAVE :: timeindex ! current time index (for time-dependent fields)
+!$OMP THREADPRIVATE(idim1,idim2,idim3,idim4,idim5,idim6,idim7,timeindex)
     INTEGER,PARAMETER :: length=100 ! size of tab_cntrl array
     
@@ -473,4 +475,5 @@
     INTEGER                     :: ierr
     LOGICAL,SAVE :: already_created=.false.
+!$OMP THREADPRIVATE(already_created)
     
     IF (is_master) THEN
@@ -956,4 +959,5 @@
      INTEGER :: idim1d
      logical,save :: firsttime=.true.
+!$OMP THREADPRIVATE(firsttime)
          
     IF (is_master) THEN
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/kcm1d.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/kcm1d.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/kcm1d.F90	(revision 227)
@@ -7,4 +7,5 @@
   use ioipsl_getincom, only: getin
   use comsaison_h, only: mu0, fract, dist_star
+  use planete_mod
 !  use control_mod
 
@@ -30,8 +31,8 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "callkeys.h"
 #include "comcstfi.h"
-#include "planete.h"
+!#include "planete.h"
 !#include "control.h"
 
@@ -42,8 +43,8 @@
   integer nlayer,nlevel,nq
   integer ilay,ilev,iq,iw,iter
-  real play(nlayermx)     ! Pressure at the middle of the layers [Pa]
-  real zlay(nlayermx)     ! Altitude at middle of the layers [km]
-  real plev(nlayermx+1)   ! Intermediate pressure levels [Pa]
-  real temp(nlayermx)     ! temperature at the middle of the layers [K]
+  real play(llm)     ! Pressure at the middle of the layers [Pa]
+  real zlay(llm)     ! Altitude at middle of the layers [km]
+  real plev(llm+1)   ! Intermediate pressure levels [Pa]
+  real temp(llm)     ! temperature at the middle of the layers [K]
   real,allocatable :: q(:,:)   ! tracer mixing ratio [kg/kg]
   real,allocatable :: vmr(:,:) ! tracer mixing ratio [mol/mol]
@@ -53,8 +54,8 @@
   real emis, albedo
 
-  real muvar(nlayermx+1)
-
-  real dtsw(nlayermx) ! heating rate (K/s) due to SW
-  real dtlw(nlayermx) ! heating rate (K/s) due to LW
+  real muvar(llm+1)
+
+  real dtsw(llm) ! heating rate (K/s) due to SW
+  real dtlw(llm) ! heating rate (K/s) due to LW
   real fluxsurf_lw   ! incident LW flux to surf (W/m2)
   real fluxtop_lw    ! outgoing LW flux to space (W/m2)
@@ -64,12 +65,12 @@
 
   ! not used
-  real reffrad(nlayermx,naerkind)
-  real nueffrad(nlayermx,naerkind)
-  real cloudfrac(nlayermx)
+  real reffrad(llm,naerkind)
+  real nueffrad(llm,naerkind)
+  real cloudfrac(llm)
   real totcloudfrac
   real tau_col
 
   real dTstrat
-  real aerosol(nlayermx,naerkind) ! aerosol tau (kg/kg)
+  real aerosol(llm,naerkind) ! aerosol tau (kg/kg)
   real OLR_nu(1,L_NSPECTI)
   real OSR_nu(1,L_NSPECTV)
@@ -93,5 +94,5 @@
 
 
-  nlayer=nlayermx
+  nlayer=llm
   nlevel=nlayer+1
 
@@ -225,6 +226,6 @@
         ! allocate arrays which depend on number of tracers
         allocate(nametrac(nq))
-        allocate(q(nlayermx,nq))
-        allocate(vmr(nlayermx,nq))
+        allocate(q(nlayer,nq))
+        allocate(vmr(nlayer,nq))
         allocate(qsurf(nq))
 
@@ -268,5 +269,5 @@
 
      !    Create vertical profiles
-     call kcmprof_fn(psurf,qsurf(1),tsurf,    &
+     call kcmprof_fn(nlayer,psurf,qsurf(1),tsurf,    &
           tstrat,play,plev,zlay,temp,q(:,1),muvar(1))
 
@@ -316,5 +317,5 @@
   ! Calculate total atmospheric energy
   Eatmtot=0.0
-  !  call calcenergy_kcm(tsurf,temp,play,plev,qsurf,&
+  !  call calcenergy_kcm(nlayer,tsurf,temp,play,plev,qsurf,&
   !     q(:,1),muvar,Eatmtot)
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/kcmprof_fn.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/kcmprof_fn.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/kcmprof_fn.F90	(revision 227)
@@ -1,3 +1,3 @@
-subroutine kcmprof_fn(psurf_rcm,qsurf_rcm,Tsurf_rcm,Tstra_rcm,P_rcm,Pl_rcm,z_rcm,T_rcm,q_rcm,m_rcm)
+subroutine kcmprof_fn(nlayer,psurf_rcm,qsurf_rcm,Tsurf_rcm,Tstra_rcm,P_rcm,Pl_rcm,z_rcm,T_rcm,q_rcm,m_rcm)
 
 use params_h
@@ -12,6 +12,6 @@
 !     ----------------------------------------------------------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -21,13 +21,14 @@
 
   ! rcm inputs
+  integer nlayer
   real Tsurf_rcm,Tstra_rcm
 
   ! rcm outputs
   real psurf_rcm,qsurf_rcm
-  real P_rcm(1:nlayermx)
-  real Pl_rcm(1:nlayermx+1)
-  real z_rcm(1:nlayermx)
-  real T_rcm(1:nlayermx),q_rcm(1:nlayermx)
-  real m_rcm(1:nlayermx+1)
+  real P_rcm(1:nlayer)
+  real Pl_rcm(1:nlayer+1)
+  real z_rcm(1:nlayer)
+  real T_rcm(1:nlayer),q_rcm(1:nlayer)
+  real m_rcm(1:nlayer+1)
 
   ! rcm for interpolation (should really use log coords?)
@@ -161,13 +162,13 @@
 
   ! define fine pressure grid
-  dlogp_rcm = -(log(psurf_rcm)-log(ptop))/nlayermx
+  dlogp_rcm = -(log(psurf_rcm)-log(ptop))/nlayer
 
   P_rcm(1)  = psurf_rcm*exp(dlogp_rcm)
-  do ilay_rcm=1,nlayermx-1
+  do ilay_rcm=1,nlayer-1
      P_rcm(ilay_rcm+1) = P_rcm(ilay_rcm)*exp(dlogp_rcm)
   enddo
 
   Pl_rcm(1) = psurf_rcm
-  do ilev_rcm=2,nlayermx
+  do ilev_rcm=2,nlayer
      ! log-linear interpolation
      Pl_rcm(ilev_rcm) = exp( log( P_rcm(ilev_rcm)*P_rcm(ilev_rcm-1) )/2 )
@@ -318,5 +319,5 @@
   do ilay=2,nlay
 
-     if(ilay_rcm.le.nlayermx)then
+     if(ilay_rcm.le.nlayer)then
      ! interpolate rcm variables
 
@@ -349,10 +350,10 @@
 
   ifinal_rcm=ilay_rcm-1
-  if(ifinal_rcm.lt.nlayermx)then
+  if(ifinal_rcm.lt.nlayer)then
      if(verbose)then
         print*,'Interpolation in kcmprof stopped at layer',ilay_rcm,'!'
      endif
 
-     do ilay_rcm=ifinal_rcm+1,nlayermx
+     do ilay_rcm=ifinal_rcm+1,nlayer
 
         z_rcm(ilay_rcm) = z_rcm(ilay_rcm-1)
@@ -364,5 +365,5 @@
   endif
 
-  do ilay=2,nlayermx
+  do ilay=2,nlayer
      if(T_rcm(ilay).lt.Ttop)then
         T_rcm(ilay)=Ttop
@@ -373,5 +374,5 @@
   if(co2cond)then
      print*,'CO2 condensation haircut - assumes CO2-dominated atmosphere!'
-     do ilay=2,nlayermx
+     do ilay=2,nlayer
         if(P_rcm(ilay).lt.518000.)then
            TCO2cond = (-3167.8)/(log(.01*P_rcm(ilay))-23.23) ! Fanale's formula
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/largescale.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/largescale.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/largescale.F90	(revision 227)
@@ -1,8 +1,9 @@
-      subroutine largescale(ngrid,nq,ptimestep, pplev, pplay, pt, pq,   &
-                        pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
+      subroutine largescale(ngrid,nlayer,nq,ptimestep, pplev, pplay,    &
+                    pt, pq, pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
 
 
 !     to use  'getin'
-      use ioipsl_getincom 
+!      use ioipsl_getincom 
+      use ioipsl_getincom_p
       use watercommon_h, only : RLVTT, RCPD, RVTMP2,  &
           T_h2O_ice_clouds,T_h2O_ice_liq,Psat_waterDP,Lcpdqsat_waterDP
@@ -23,28 +24,29 @@
 !==================================================================
 
-#include "dimensions.h" 
-#include "dimphys.h"
+!#include "dimensions.h" 
+!#include "dimphys.h"
 #include "comcstfi.h"
 
 #include "callkeys.h"
 
-      INTEGER ngrid,nq
+      INTEGER ngrid,nlayer,nq
 
 !     Arguments
       REAL ptimestep                 ! intervalle du temps (s)
-      REAL pplev(ngrid,nlayermx+1) ! pression a inter-couche
-      REAL pplay(ngrid,nlayermx)   ! pression au milieu de couche
-      REAL pt(ngrid,nlayermx)      ! temperature (K)
-      REAL pq(ngrid,nlayermx,nq) ! tracer mixing ratio (kg/kg)
-      REAL pdt(ngrid,nlayermx)     ! physical temperature tenedency (K/s)
-      REAL pdq(ngrid,nlayermx,nq)! physical tracer tenedency (K/s)
-      REAL pdtlsc(ngrid,nlayermx)  ! incrementation de la temperature (K)
-      REAL pdqvaplsc(ngrid,nlayermx) ! incrementation de la vapeur d'eau
-      REAL pdqliqlsc(ngrid,nlayermx) ! incrementation de l'eau liquide
-      REAL rneb(ngrid,nlayermx)    ! fraction nuageuse
+      REAL pplev(ngrid,nlayer+1) ! pression a inter-couche
+      REAL pplay(ngrid,nlayer)   ! pression au milieu de couche
+      REAL pt(ngrid,nlayer)      ! temperature (K)
+      REAL pq(ngrid,nlayer,nq) ! tracer mixing ratio (kg/kg)
+      REAL pdt(ngrid,nlayer)     ! physical temperature tenedency (K/s)
+      REAL pdq(ngrid,nlayer,nq)! physical tracer tenedency (K/s)
+      REAL pdtlsc(ngrid,nlayer)  ! incrementation de la temperature (K)
+      REAL pdqvaplsc(ngrid,nlayer) ! incrementation de la vapeur d'eau
+      REAL pdqliqlsc(ngrid,nlayer) ! incrementation de l'eau liquide
+      REAL rneb(ngrid,nlayer)    ! fraction nuageuse
 
 
 !     Options du programme
       REAL, SAVE :: ratqs   ! determine largeur de la distribution de vapeur
+!$OMP THREADPRIVATE(ratqs)
 
 !     Variables locales
@@ -63,10 +65,11 @@
       
 ! evaporation calculations
-      REAL dqevap(ngrid,nlayermx),dtevap(ngrid,nlayermx)     
-      REAL qevap(ngrid,nlayermx,nq)
-      REAL tevap(ngrid,nlayermx)
+      REAL dqevap(ngrid,nlayer),dtevap(ngrid,nlayer)     
+      REAL qevap(ngrid,nlayer,nq)
+      REAL tevap(ngrid,nlayer)
 
       DOUBLE PRECISION zx_q(ngrid)
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
 
 
@@ -75,5 +78,5 @@
 	 write(*,*) "value for ratqs? "
          ratqs=0.2 ! default value
-         call getin("ratqs",ratqs)
+         call getin_p("ratqs",ratqs)
          write(*,*) " ratqs = ",ratqs
 
@@ -83,13 +86,13 @@
 !     GCM -----> subroutine variables, initialisation of outputs
 
-      pdtlsc(1:ngrid,1:nlayermx)  = 0.0
-      pdqvaplsc(1:ngrid,1:nlayermx)  = 0.0
-      pdqliqlsc(1:ngrid,1:nlayermx) = 0.0
-      rneb(1:ngrid,1:nlayermx) = 0.0
+      pdtlsc(1:ngrid,1:nlayer)  = 0.0
+      pdqvaplsc(1:ngrid,1:nlayer)  = 0.0
+      pdqliqlsc(1:ngrid,1:nlayer) = 0.0
+      rneb(1:ngrid,1:nlayer) = 0.0
       Lcp=RLVTT/RCPD
 
 
       ! Evaporate cloud water/ice
-      call evap(ngrid,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
+      call evap(ngrid,nlayer,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
       ! note: we use qevap but not tevap in largescale/moistadj
             ! otherwise is a big mess
@@ -97,5 +100,5 @@
 
 !  Boucle verticale (du haut vers le bas)
-   DO k = nlayermx, 1, -1
+   DO k = nlayer, 1, -1
 
       zt(1:ngrid)=pt(1:ngrid,k)+(pdt(1:ngrid,k)+dtevap(1:ngrid,k))*ptimestep
@@ -171,7 +174,6 @@
          pdtlsc(1:ngrid,k)  = pdqliqlsc(1:ngrid,k)*real(Lcp)
 
-   Enddo ! k= nlayermx, 1, -1
+   Enddo ! k= nlayer, 1, -1
  
 
-      return
       end
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/lect_start_archive.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/lect_start_archive.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/lect_start_archive.F	(revision 227)
@@ -1,3 +1,4 @@
-      SUBROUTINE lect_start_archive(date,tsurf,tsoil,emis,q2,
+      SUBROUTINE lect_start_archive(ngrid,nlayer,
+     &     date,tsurf,tsoil,emis,q2,
      &     t,ucov,vcov,ps,h,phisold_newgrid,
      &     q,qsurf,surfith,nid,
@@ -30,5 +31,5 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 !#include "planete.h"
 #include "paramet.h"
@@ -47,4 +48,6 @@
 c=======================================================================
 
+      INTEGER,INTENT(IN) :: ngrid, nlayer
+
 c Old variables dimensions (from file)
 c------------------------------------
@@ -99,13 +102,13 @@
 c variable physique
 c------------------
-      REAL tsurf(ngridmx) ! surface temperature
-      REAL tsoil(ngridmx,nsoilmx) ! soil temperature
-      REAL co2ice(ngridmx) ! CO2 ice layer
-      REAL emis(ngridmx)
-      REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqtot)
-      REAL tslab(ngridmx,noceanmx)
-      REAL rnat(ngridmx),pctsrf_sic(ngridmx)
-      REAL tsea_ice(ngridmx),sea_ice(ngridmx)
-c     REAL phisfi(ngridmx)
+      REAL tsurf(ngrid) ! surface temperature
+      REAL tsoil(ngrid,nsoilmx) ! soil temperature
+      REAL co2ice(ngrid) ! CO2 ice layer
+      REAL emis(ngrid)
+      REAL q2(ngrid,llm+1),qsurf(ngrid,nqtot)
+      REAL tslab(ngrid,noceanmx)
+      REAL rnat(ngrid),pctsrf_sic(ngrid)
+      REAL tsea_ice(ngrid),sea_ice(ngrid)
+c     REAL phisfi(ngrid)
 
       INTEGER i,j,l
@@ -322,5 +325,5 @@
       allocate(varp1 (imold+1,jmold+1,llm+1))
 
-      write(*,*) 'q2',ngridmx,nlayermx+1
+      write(*,*) 'q2',ngrid,llm+1
       write(*,*) 'q2S',iip1,jjp1,llm+1
       write(*,*) 'q2old',imold+1,jmold+1,lmold+1
@@ -1052,5 +1055,5 @@
       call interp_horiz (tsurfold,tsurfs,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tsurfs,tsurf)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsurfs,tsurf)
 c     write(44,*) 'tsurf', tsurf
 
@@ -1059,5 +1062,5 @@
 !     &                  imold,jmold,iim,jjm,nsoilmx,
 !     &                   rlonuold,rlatvold,rlonu,rlatv)
-!      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,tsoils,tsoil)
+!      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoils,tsoil)
 c     write(45,*) 'tsoil',tsoil
 
@@ -1065,5 +1068,5 @@
       call interp_horiz (emisold,emiss,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,emiss,emis)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,emiss,emis)
 c     write(46,*) 'emis',emis
 
@@ -1201,5 +1204,5 @@
 
       ! Reshape inertiedatS to scalar grid as inertiedat
-      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,
+      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,
      &                  inertiedatS,inertiedat)
       
@@ -1287,5 +1290,5 @@
 
       ! Reshape tsoilS to scalar grid as tsoil
-       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,tsoilS,tsoil)
+       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoilS,tsoil)
 
 c-----------------------------------------------------------------------
@@ -1294,21 +1297,21 @@
       call interp_horiz (tslabold,tslabs,imold,jmold,iim,jjm,noceanmx,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tslabs,tslab)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tslabs,tslab)
 
       call interp_horiz (rnatold,rnats,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,rnats,rnat)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,rnats,rnat)
 
       call interp_horiz (pctsrf_sicold,pctsrf_sics,imold,jmold,iim,
      &                   jjm,1,rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,pctsrf_sics,pctsrf_sic)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,pctsrf_sics,pctsrf_sic)
 
       call interp_horiz (tsea_iceold,tsea_ices,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tsea_ices,tsea_ice)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsea_ices,tsea_ice)
 
       call interp_horiz (sea_iceold,sea_ices,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,sea_ices,sea_ice)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,sea_ices,sea_ice)
 
 c-----------------------------------------------------------------------
@@ -1334,5 +1337,5 @@
      &                   rlonuold,rlatvold,rlonu,rlatv)
       write (*,*) 'lect_start_archive: q2s ', q2s (1,2,1)  ! INFO
-      call gr_dyn_fi (llm+1,iim+1,jjm+1,ngridmx,q2s,q2)
+      call gr_dyn_fi (llm+1,iim+1,jjm+1,ngrid,q2s,q2)
       write (*,*) 'lect_start_archive: q2 ', q2 (1,2)  ! INFO
 c     write(47,*) 'q2',q2
@@ -1384,5 +1387,5 @@
       enddo
 
-      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngridmx,qsurfs,qsurf)
+      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngrid,qsurfs,qsurf)
 
 c traceurs 3D
@@ -1435,5 +1438,5 @@
       enddo
       
-!      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,co2ices,co2ice)
+!      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,co2ices,co2ice)
 ! no need to transfer "co2ice" any more; it is in qsurf(igcm_co2_ice)
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mass_redistribution.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mass_redistribution.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mass_redistribution.F90	(revision 227)
@@ -9,4 +9,5 @@
        USE comgeomfi_h
        USE tracer_h
+       USE planete_mod, only: bp
 
        IMPLICIT NONE
@@ -50,9 +51,9 @@
 !    ------------------
 !
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
-#include "comvert.h"
-#include "paramet.h"
+!#include "comvert.h"
+!#include "paramet.h"
 #include "callkeys.h"
 
@@ -84,20 +85,22 @@
 
 !    vertical reorganization of sigma levels
-      REAL zzu(nlayermx),zzv(nlayermx)
-      REAL zzq(nlayermx,nq),zzt(nlayermx)
+      REAL zzu(nlayer),zzv(nlayer)
+      REAL zzq(nlayer,nq),zzt(nlayer)
 !    Dummy variables      
       INTEGER n,l,ig,iq
-      REAL zdtsig(ngrid,nlayermx)
-      REAL zmass(ngrid,nlayermx),zzmass(nlayermx),w(nlayermx+1)
-      REAL zdmass_sum(ngrid,nlayermx+1)
-      REAL zmflux(nlayermx+1)
-      REAL zq1(nlayermx)
+      REAL zdtsig(ngrid,nlayer)
+      REAL zmass(ngrid,nlayer),zzmass(nlayer),w(nlayer+1)
+      REAL zdmass_sum(ngrid,nlayer+1)
+      REAL zmflux(nlayer+1)
+      REAL zq1(nlayer)
       REAL ztsrf(ngrid)
-      REAL ztm(nlayermx+1) 
-      REAL zum(nlayermx+1) , zvm(nlayermx+1)
-      REAL zqm(nlayermx+1,nq),zqm1(nlayermx+1)
+      REAL ztm(nlayer+1) 
+      REAL zum(nlayer+1) , zvm(nlayer+1)
+      REAL zqm(nlayer+1,nq),zqm1(nlayer+1)
+      REAL sigma(nlayer+1)
 
 !   local saved variables
       LOGICAL, SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
 
 !----------------------------------------------------------------------
@@ -127,6 +130,6 @@
 
       DO ig=1,ngrid
-         zdmass_sum(ig,nlayermx+1)=0.
-         DO l = nlayermx, 1, -1
+         zdmass_sum(ig,nlayer+1)=0.
+         DO l = nlayer, 1, -1
            zmass(ig,l) = (pplev(ig,l)-pplev(ig,l+1))/glat(ig)
 	   zdmass_sum(ig,l)= zdmass_sum(ig,l+1)+pdmassmr(ig,l)
@@ -181,18 +184,24 @@
 !  Correction to account for redistribution between sigma or hybrid 
 !  layers when changing surface pressure
-!  zzx quantities have dimension (nlayermx) to speed up calculation
+!  zzx quantities have dimension (nlayer) to speed up calculation
 ! *************************************************************
 
       DO ig=1,ngrid
-         zzt(1:nlayermx)  = pt(ig,1:nlayermx) + pdt(ig,1:nlayermx) * ptimestep
-         zzu(1:nlayermx)  = pu(ig,1:nlayermx) + pdu(ig,1:nlayermx) * ptimestep
-         zzv(1:nlayermx)  = pv(ig,1:nlayermx) + pdv(ig,1:nlayermx) * ptimestep
-         zzq(1:nlayermx,1:nq)=pq(ig,1:nlayermx,1:nq)+pdq(ig,1:nlayermx,1:nq)*ptimestep ! must add the water that has fallen???
+         zzt(1:nlayer)  = pt(ig,1:nlayer) + pdt(ig,1:nlayer) * ptimestep
+         zzu(1:nlayer)  = pu(ig,1:nlayer) + pdu(ig,1:nlayer) * ptimestep
+         zzv(1:nlayer)  = pv(ig,1:nlayer) + pdv(ig,1:nlayer) * ptimestep
+         zzq(1:nlayer,1:nq)=pq(ig,1:nlayer,1:nq)+pdq(ig,1:nlayer,1:nq)*ptimestep ! must add the water that has fallen???
 
 !  Mass fluxes of air through the sigma levels (kg.m-2.s-1)  (>0 when up)
 !  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
          zmflux(1) = zmassboil(ig)
+         sigma(1)=1
          DO l=1,nlayer
+           ! Ehouarn: shouldn't we rather compute sigma levels than use bp()?
+!           sigma(l+1)=pplev(ig,l+1)/pplev(ig,1)
+!           zmflux(l+1) = zmflux(l) + pdmassmr(ig,l) - &
+!                        (sigma(l)-sigma(l+1))*(zdmass_sum(ig,1)+zmflux(1))
+!            if (abs(zmflux(l+1)).lt.1E-13.OR.sigma(l+1).eq.0.) zmflux(l+1)=0.
+           ! Ehouarn: but for now leave things as before
             zmflux(l+1) = zmflux(l) + pdmassmr(ig,l) - (bp(l)-bp(l+1))*(zdmass_sum(ig,1)+zmflux(1))
 ! zmflux set to 0 if very low to avoid: top layer is disappearing in v1ld  
@@ -202,5 +211,5 @@
 ! Mass of each layer
 ! ------------------ 
-         zzmass(1:nlayermx)=zmass(ig,1:nlayermx)*(1.+pdpsrfmr(ig)*ptimestep/pplev(ig,1))
+         zzmass(1:nlayer)=zmass(ig,1:nlayer)*(1.+pdpsrfmr(ig)*ptimestep/pplev(ig,1))
 
 
@@ -219,10 +228,10 @@
 	 
 !        Van Leer scheme:
-         w(1:nlayermx+1)=-zmflux(1:nlayermx+1)*ptimestep
+         w(1:nlayer+1)=-zmflux(1:nlayer+1)*ptimestep
          call vl1d(zzt,2.,zzmass,w,ztm) 
          call vl1d(zzu ,2.,zzmass,w,zum) 
          call vl1d(zzv ,2.,zzmass,w,zvm) 
          do iq=1,nq
-           zq1(1:nlayermx)=zzq(1:nlayermx,iq)
+           zq1(1:nlayer)=zzq(1:nlayer,iq)
            zqm1(1)=zqm(1,iq)
 !		print*,iq
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_grid_phy_lmdz.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_grid_phy_lmdz.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_grid_phy_lmdz.F90	(revision 227)
@@ -12,4 +12,5 @@
   INTEGER,SAVE :: nbp_lev  ! == llm
   INTEGER,SAVE :: klon_glo
+!$OMP THREADPRIVATE(nbp_lon,nbp_lat,nbp_lev,klon_glo)
 
   INTERFACE grid1dTo2d_glo
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_phys_lmdz_mpi_data.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_phys_lmdz_mpi_data.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_phys_lmdz_mpi_data.F90	(revision 227)
@@ -16,4 +16,6 @@
   INTEGER,SAVE :: klon_mpi_end
   INTEGER,SAVE :: klon_mpi
+!!$OMP THREADPRIVATE(ii_begin,ii_end,jj_begin,jj_end,jj_nb,ij_begin,&
+!	!$OMP ij_end,ij_nb,klon_mpi_begin,klon_mpi_end,klon_mpi)
   
   INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb
@@ -31,4 +33,7 @@
   INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin
   INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end 
+!!$OMP THREADPRIVATE(jj_para_nb,jj_para_begin,jj_para_end,ii_para_begin,ii_para_end,&
+!	!$OMP ij_para_nb,ij_para_begin,ij_para_end,klon_mpi_para_nb,klon_mpi_para_begin,&
+!	!$OMP klon_mpi_para_end)
 
   
@@ -38,4 +43,5 @@
   LOGICAL,SAVE :: is_mpi_root
   LOGICAL,SAVE :: is_using_mpi
+!!$OMP THREADPRIVATE(mpi_rank,mpi_size,mpi_root,is_mpi_root,is_using_mpi)
   
   
@@ -43,4 +49,5 @@
   LOGICAL,SAVE :: is_south_pole
   INTEGER,SAVE :: COMM_LMDZ_PHY
+!!$OMP THREADPRIVATE(is_north_pole,is_south_pole,COMM_LMDZ_PHY)
 
 CONTAINS
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_phys_lmdz_para.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_phys_lmdz_para.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/mod_phys_lmdz_para.F90	(revision 227)
@@ -13,4 +13,5 @@
   
 !$OMP THREADPRIVATE(klon_loc,is_master)
+!$OMP THREADPRIVATE(is_sequential,is_parallel)
   
 CONTAINS
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/moistadj.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/moistadj.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/moistadj.F90	(revision 227)
@@ -1,6 +1,6 @@
-subroutine moistadj(ngrid, nq, pt, pq, pdq, pplev, pplay, pdtmana, pdqmana, ptimestep, rneb)
+subroutine moistadj(ngrid, nlayer, nq, pt, pq, pdq, pplev, pplay, pdtmana, pdqmana, ptimestep, rneb)
 
   use watercommon_h, only: T_h2O_ice_liq, RLVTT, RCPD, RCPV, Psat_water, Lcpdqsat_water
-  USE tracer_h
+  USE tracer_h, only: igcm_h2o_vap, igcm_h2o_ice
 
   implicit none
@@ -20,28 +20,27 @@
 !=====================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 
-      INTEGER ngrid, nq
-
-      REAL pt(ngrid,nlayermx)            ! temperature (K)
-      REAL pq(ngrid,nlayermx,nq)       ! tracer (kg/kg)
-      REAL pdq(ngrid,nlayermx,nq)
-
-      REAL pdqmana(ngrid,nlayermx,nq)  ! tendency of tracers (kg/kg.s-1)
-      REAL pdtmana(ngrid,nlayermx)       ! temperature increment
+      INTEGER,INTENT(IN) :: ngrid, nlayer, nq
+
+      REAL,INTENT(IN) :: pt(ngrid,nlayer) ! temperature (K)
+      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq) ! tracer (kg/kg)
+      REAL,INTENT(IN) :: pdq(ngrid,nlayer,nq)
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      REAL,INTENT(IN) :: pplay(ngrid,nlayer)   ! mid-layer pressure (Pa)
+      REAL,INTENT(IN) :: ptimestep ! physics timestep (s)
+      REAL,INTENT(OUT) :: pdqmana(ngrid,nlayer,nq)  ! tracer tendencies (kg/kg.s-1)
+      REAL,INTENT(OUT) :: pdtmana(ngrid,nlayer) ! temperature increment(K/s)
+      REAL,INTENT(OUT) :: rneb(ngrid,nlayer) ! cloud fraction 
 
 !     local variables
-      REAL zt(ngrid,nlayermx)      ! temperature (K)
-      REAL zq(ngrid,nlayermx)      ! humidite specifique (kg/kg)
-      REAL pplev(ngrid,nlayermx+1) ! pression a inter-couche (Pa)
-      REAL pplay(ngrid,nlayermx)   ! pression au milieu de couche (Pa)
-
-      REAL d_t(ngrid,nlayermx)     ! temperature increment
-      REAL d_q(ngrid,nlayermx)     ! incrementation pour vapeur d'eau
-      REAL d_ql(ngrid,nlayermx)    ! incrementation pour l'eau liquide
-      REAL rneb(ngrid,nlayermx) ! cloud fraction 
-      REAL ptimestep
+      REAL zt(ngrid,nlayer)      ! temperature (K)
+      REAL zq(ngrid,nlayer)      ! humidite specifique (kg/kg)
+
+      REAL d_t(ngrid,nlayer)     ! temperature increment
+      REAL d_q(ngrid,nlayer)     ! incrementation pour vapeur d'eau
+      REAL d_ql(ngrid,nlayer)    ! incrementation pour l'eau liquide
 
 !      REAL t_coup
@@ -55,12 +54,12 @@
       INTEGER k1, k1p, k2, k2p
       LOGICAL itest(ngrid)
-      REAL delta_q(ngrid, nlayermx)
-      DOUBLE PRECISION :: cp_new_t(nlayermx), v_cptt(ngrid,nlayermx)
-      REAL cp_delta_t(nlayermx)
-      DOUBLE PRECISION :: v_cptj(nlayermx), v_cptjk1, v_ssig
+      REAL delta_q(ngrid, nlayer)
+      DOUBLE PRECISION :: cp_new_t(nlayer), v_cptt(ngrid,nlayer)
+      REAL cp_delta_t(nlayer)
+      DOUBLE PRECISION :: v_cptj(nlayer), v_cptjk1, v_ssig
       REAL v_p, v_t, v_zqs,v_cptt2,v_pratio,v_dlnpsat
-      REAL zqs(ngrid,nlayermx), zdqs(ngrid,nlayermx),zpsat(ngrid,nlayermx),zdlnpsat(ngrid,nlayermx)
+      REAL zqs(ngrid,nlayer), zdqs(ngrid,nlayer),zpsat(ngrid,nlayer),zdlnpsat(ngrid,nlayer)
       REAL zq1(ngrid), zq2(ngrid)
-      DOUBLE PRECISION :: gamcpdz(ngrid,2:nlayermx)
+      DOUBLE PRECISION :: gamcpdz(ngrid,2:nlayer)
       DOUBLE PRECISION :: zdp, zdpm
 
@@ -68,5 +67,5 @@
       REAL zflo ! flotabilite
 
-      DOUBLE PRECISION :: local_q(ngrid,nlayermx),local_t(ngrid,nlayermx)
+      DOUBLE PRECISION :: local_q(ngrid,nlayer),local_t(ngrid,nlayer)
 
       REAL zdelta, zcor, zcvm5
@@ -78,9 +77,8 @@
       INTEGER,SAVE :: i_h2o=0  ! water vapour
       INTEGER,SAVE :: i_ice=0  ! water ice
-
-      LOGICAL firstcall
-      SAVE firstcall
-
-      DATA firstcall /.TRUE./
+!$OMP THREADPRIVATE(i_h2o,i_ice)
+
+      LOGICAL,SAVE :: firstcall=.TRUE.
+!$OMP THREADPRIVATE(firstcall)
 
       IF (firstcall) THEN
@@ -96,9 +94,9 @@
 
 !     GCM -----> subroutine variables
-      zq(1:ngrid,1:nlayermx)    = pq(1:ngrid,1:nlayermx,i_h2o)+ pdq(1:ngrid,1:nlayermx,i_h2o)*ptimestep
-      zt(1:ngrid,1:nlayermx)    = pt(1:ngrid,1:nlayermx)
-      pdqmana(1:ngrid,1:nlayermx,1:nq)=0.0
-
-      DO k = 1, nlayermx
+      zq(1:ngrid,1:nlayer)    = pq(1:ngrid,1:nlayer,i_h2o)+ pdq(1:ngrid,1:nlayer,i_h2o)*ptimestep
+      zt(1:ngrid,1:nlayer)    = pt(1:ngrid,1:nlayer)
+      pdqmana(1:ngrid,1:nlayer,1:nq)=0.0
+
+      DO k = 1, nlayer
        DO i = 1, ngrid
          if(zq(i,k).lt.0.)then
@@ -108,13 +106,13 @@
       ENDDO
       
-      local_q(1:ngrid,1:nlayermx) = zq(1:ngrid,1:nlayermx)
-      local_t(1:ngrid,1:nlayermx) = zt(1:ngrid,1:nlayermx)
-      rneb(1:ngrid,1:nlayermx) = 0.0
-      d_ql(1:ngrid,1:nlayermx) = 0.0
-      d_t(1:ngrid,1:nlayermx)  = 0.0
-      d_q(1:ngrid,1:nlayermx)  = 0.0
+      local_q(1:ngrid,1:nlayer) = zq(1:ngrid,1:nlayer)
+      local_t(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer)
+      rneb(1:ngrid,1:nlayer) = 0.0
+      d_ql(1:ngrid,1:nlayer) = 0.0
+      d_t(1:ngrid,1:nlayer)  = 0.0
+      d_q(1:ngrid,1:nlayer)  = 0.0
 
 !     Calculate v_cptt
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
          DO i = 1, ngrid
             v_cptt(i,k) = RCPD * local_t(i,k)
@@ -128,5 +126,5 @@
 
 !     Calculate Gamma * Cp * dz: (gamma is the critical gradient)
-      DO k = 2, nlayermx
+      DO k = 2, nlayer
          DO i = 1, ngrid
             zdp = pplev(i,k)-pplev(i,k+1)
@@ -159,5 +157,5 @@
   810 CONTINUE ! look for k1, the base of the column
       k2 = k2 + 1
-      IF (k2 .GT. nlayermx) GOTO 9999
+      IF (k2 .GT. nlayer) GOTO 9999
       zflo = v_cptt(i,k2-1) - v_cptt(i,k2) - gamcpdz(i,k2)
       zsat=(local_q(i,k2-1)-zqs(i,k2-1))*(pplev(i,k2-1)-pplev(i,k2))   &
@@ -169,5 +167,5 @@
 
   820 CONTINUE !! look for k2, the top of the column
-      IF (k2 .EQ. nlayermx) GOTO 821
+      IF (k2 .EQ. nlayer) GOTO 821
       k2p = k2 + 1
       zsat=zsat+(pplev(i,k2p)-pplev(i,k2p+1))*(local_q(i,k2p)-zqs(i,k2p))
@@ -227,5 +225,5 @@
 !      ENDDO
 
-      DO k = 2, nlayermx
+      DO k = 2, nlayer
          zdpm = pplev(i,k-1) - pplev(i,k)
          zdp = pplev(i,k) - pplev(i,k+1)
@@ -272,5 +270,5 @@
 ! a l'endroit ou la vapeur d'eau est diminuee par l'ajustement):
 
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
       DO i = 1, ngrid
          IF (itest(i)) THEN
@@ -291,5 +289,5 @@
          ENDIF
       ENDDO
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
       DO i = 1, ngrid
          IF (itest(i)) THEN
@@ -300,5 +298,5 @@
       ENDDO
       ENDDO
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
       DO i = 1, ngrid
          IF (itest(i)) THEN
@@ -308,5 +306,5 @@
       ENDDO
 
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
       DO i = 1, ngrid
           local_q(i, k) = MAX(local_q(i, k), seuil_vap)
@@ -314,5 +312,5 @@
       ENDDO
 
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
       DO i = 1, ngrid
          d_t(i,k) = local_t(i,k) - zt(i,k)
@@ -322,5 +320,5 @@
 
 !     now subroutine -----> GCM variables
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
          DO i = 1, ngrid
             
@@ -333,4 +331,3 @@
 
 
-      RETURN
    END
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newsedim.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newsedim.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newsedim.F	(revision 227)
@@ -16,6 +16,6 @@
 !   ------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 
@@ -44,10 +44,11 @@
 
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
 
 c    Traceurs :
 c    ~~~~~~~~ 
-      real traversee (ngrid,nlayermx)
-      real vstokes(ngrid,nlayermx)
-      real w(ngrid,nlayermx)
+      real traversee (ngrid,nlay)
+      real vstokes(ngrid,nlay)
+      real w(ngrid,nlay)
       real ptop, dztop, Ep, Stra
 
@@ -62,4 +63,5 @@
 c     local and saved variable
       real,save :: a,b
+!$OMP THREADPRIVATE(a,b)
 
 c    ** un petit test de coherence
@@ -191,8 +193,7 @@
       end do
 
-      call vlz_fi(ngrid,pqi,2.,masse,w,wq)
+      call vlz_fi(ngrid,nlay,pqi,2.,masse,w,wq)
 c         write(*,*) ' newsed: wq(6), wq(7), q(6)',
 c    &                wq(1,6),wq(1,7),pqi(1,6)
 
-      RETURN
       END
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newstart.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newstart.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newstart.F	(revision 227)
@@ -23,5 +23,6 @@
       use datafile_mod, only: datadir
 ! to use  'getin'
-      USE ioipsl_getincom, only: getin
+!      USE ioipsl_getincom, only: getin
+      USE ioipsl_getincom_p, only: getin_p
       use control_mod, only: day_step, iphysiq, anneeref
       use phyredem, only: physdem0, physdem1
@@ -32,6 +33,7 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
-#include "planete.h"
+!#include "dimphys.h"
+      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) 
+!#include "planete.h"
 #include "paramet.h"
 #include "comconst.h"
@@ -98,5 +100,5 @@
       real emisread             ! added by RW
       REAL,ALLOCATABLE :: qsurf(:,:)
-      REAL q2(ngridmx,nlayermx+1)
+      REAL q2(ngridmx,llm+1)
 !      REAL rnaturfi(ngridmx)
       real alb(iip1,jjp1),albfi(ngridmx) ! albedos
@@ -171,5 +173,5 @@
 
 !     added by BC for cloud fraction setup
-      REAL hice(ngridmx),cloudfrac(ngridmx,nlayermx)
+      REAL hice(ngridmx),cloudfrac(ngridmx,llm)
       REAL totalfrac(ngridmx)
 
@@ -341,6 +343,6 @@
         write(*,*) 'Reading file STARTFI'
         fichnom = 'startfi.nc'
-        CALL phyetat0 (ngridmx,fichnom,tab0,Lmodif,nsoilmx,nqtot,
-     .        day_ini,time,
+        CALL phyetat0 (ngridmx,llm,fichnom,tab0,Lmodif,nsoilmx,
+     .        nqtot,day_ini,time,
      .        tsurf,tsoil,emis,q2,qsurf,   !) ! temporary modif by RDW
      .        cloudfrac,totalfrac,hice,rnat,pctsrf_sic,tslab,tsea_ice,
@@ -480,5 +482,5 @@
 !    First get the correct value of datadir, if not already done:
         ! default 'datadir' is set in "datafile_mod"
-        call getin("datadir",datadir)
+        call getin_p("datadir",datadir)
         write(*,*) 'Available surface data files are:'
         filestring='ls '//trim(datadir)//' | grep .nc'
@@ -534,5 +536,6 @@
 
         write(*,*) 'Reading file START_ARCHIVE'
-        CALL lect_start_archive(date,tsurf,tsoil,emis,q2,
+        CALL lect_start_archive(ngridmx,llm,
+     &   date,tsurf,tsoil,emis,q2,
      &   t,ucov,vcov,ps,teta,phisold_newgrid,q,qsurf,
      &   surfith,nid,
@@ -956,5 +959,5 @@
                  ucov(1:iip1,1:jjp1,1:llm)=0.
                  vcov(1:iip1,1:jjm,1:llm)=0.
-                 q2(1:ngridmx,1:nlayermx+1)=0.
+                 q2(1:ngridmx,1:llm+1)=0.
                else
                  write(*,*)'problem reading file ',trim(txt),' !'
@@ -1296,5 +1299,5 @@
           ucov(1:iip1,1:jjp1,1:llm)=0
           vcov(1:iip1,1:jjm,1:llm)=0
-          q2(1:ngridmx,1:nlayermx+1)=0
+          q2(1:ngridmx,1:llm+1)=0
 
 c       radequi : Radiative equilibrium profile of temperatures and no winds
@@ -1326,5 +1329,5 @@
           ucov(1:iip1,1:jjp1,1:llm)=0
           vcov(1:iip1,1:jjm,1:llm)=0
-          q2(1:ngridmx,1:nlayermx+1)=0
+          q2(1:ngridmx,1:llm+1)=0
 
 c       coldstart : T set 1K above CO2 frost point and no winds
@@ -1362,5 +1365,5 @@
           ucov(1:iip1,1:jjp1,1:llm)=0
           vcov(1:iip1,1:jjm,1:llm)=0
-          q2(1:ngridmx,1:nlayermx+1)=0
+          q2(1:ngridmx,1:llm+1)=0
 
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newtrelax.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newtrelax.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/newtrelax.F90	(revision 227)
@@ -1,8 +1,8 @@
-subroutine newtrelax(ngrid,mu0,sinlat,popsk,temp,pplay,pplev,dtrad,firstcall) 
+subroutine newtrelax(ngrid,nlayer,mu0,sinlat,popsk,temp,pplay,pplev,dtrad,firstcall) 
         
   implicit none
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -21,20 +21,22 @@
 !==================================================================
  
-  integer ngrid
  
   ! Input
-  real mu0(ngrid)                    ! cosine of sun incident angle
-  real sinlat(ngrid)                 ! sine of latitude
-  real temp(ngrid,nlayermx)          ! temperature at each layer (K)
-  real pplay(ngrid,nlayermx)         ! pressure at each layer (Pa)
-  real pplev(ngrid,nlayermx+1)       ! pressure at each level (Pa)
-  real popsk(ngrid,nlayermx)         ! pot. T to T converter
+  integer,intent(in) :: ngrid, nlayer
+  logical,intent(in) :: firstcall
+  real,intent(in) :: mu0(ngrid)            ! cosine of sun incident angle
+  real,intent(in) :: sinlat(ngrid)         ! sine of latitude
+  real,intent(in) :: temp(ngrid,nlayer)    ! temperature at each layer (K)
+  real,intent(in) :: pplay(ngrid,nlayer)   ! pressure at each layer (Pa)
+  real,intent(in) :: pplev(ngrid,nlayer+1) ! pressure at each level (Pa)
+  real,intent(in) :: popsk(ngrid,nlayer)   ! pot. T to T converter
 
   ! Output
-  real dtrad(ngrid,nlayermx) 
+  real,intent(out) :: dtrad(ngrid,nlayer) 
 
   ! Internal
   real Trelax_V, Trelax_H
   real,allocatable,dimension(:,:),save :: Trelax
+!$OMP THREADPRIVATE(Trelax)
 
   real T_trop ! relaxation temperature at tropopause (K)
@@ -44,5 +46,4 @@
   real sig, f_sig, sig_trop
   integer l,ig
-  logical firstcall
 
 
@@ -53,5 +54,5 @@
   if(firstcall) then
 
-     ALLOCATE(Trelax(ngrid,nlayermx))
+     ALLOCATE(Trelax(ngrid,nlayer))
 
      print*,'-----------------------------------------------------'
@@ -66,5 +67,5 @@
            T_surf = 126. + 239.*mu0(ig)
            T_trop = 140. + 52.*mu0(ig)
-           do l=1,nlayermx
+           do l=1,nlayer
 
               if(mu0(ig).le.0.0)then ! night side
@@ -86,5 +87,5 @@
         sig_trop=(T_trop/T_surf)**(1./rcp)
 
-        do l=1,nlayermx
+        do l=1,nlayer
            do ig=1,ngrid
 
@@ -109,10 +110,8 @@
      endif
 
-     firstcall=.false.
- 
   endif
 
   ! Calculate radiative forcing
-  do l=1,nlayermx
+  do l=1,nlayer
      do ig=1,ngrid
         dtrad(ig,l) = -(temp(ig,l) - Trelax(ig,l)) / tau_relax
@@ -129,4 +128,3 @@
   !call writediagfi(ngrid,'ThetaZ','stellar zenith angle','deg',2,mu0)
 
-  return
 end subroutine newtrelax
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ocean_slab_mod.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ocean_slab_mod.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/ocean_slab_mod.F90	(revision 227)
@@ -15,6 +15,6 @@
 
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -26,7 +26,7 @@
   
   !LOGICAL, PRIVATE, SAVE  :: ok_slab_sic,ok_slab_heaT_h2O_ice_liqBS
-  !$OMP THREADPRIVATE(ok_slab_sic,ok_slab_heaT_h2O_ice_liqBS)
+  !!$OMP THREADPRIVATE(ok_slab_sic,ok_slab_heaT_h2O_ice_liqBS)
   !INTEGER, PRIVATE, SAVE                           :: slab_ekman, slab_cadj
-  !$OMP THREADPRIVATE(slab_ekman,slab_cadj)
+  !!$OMP THREADPRIVATE(slab_ekman,slab_cadj)
   INTEGER, PRIVATE, SAVE                           :: lmt_pas, julien, idayvrai
   !$OMP THREADPRIVATE(lmt_pas,julien,idayvrai)
@@ -67,6 +67,6 @@
 
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -210,6 +210,6 @@
       use slab_ice_h
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -451,6 +451,6 @@
     use slab_ice_h 
 
-#include "dimensions.h"
-#include "comcstfi.h"
+!#include "dimensions.h"
+!#include "comcstfi.h"
 !    INCLUDE "iniprint.h"
 #include "callkeys.h"
@@ -534,5 +534,5 @@
 !  Transport diffusif
 !         IF (ok_soil_hdiff) THEN
-             CALL divgrad_phy(noceanmx,tmp_tslab_loc,dtdiff_loc)
+             CALL divgrad_phy(ngrid,noceanmx,tmp_tslab_loc,dtdiff_loc)
              dtdiff_loc=dtdiff_loc*soil_hdiff*50./SUM(slabh)!*100.
  !           dtdiff_loc(:,1)=dtdiff_loc(:,1)*soil_hdiff*50./SUM(slabh)*0.8
@@ -544,5 +544,5 @@
 ! Calcul  de transport par Ekman
 
-          CALL slab_ekman2(taux_slab,tauy_slab,tslab,dtekman_loc)
+          CALL slab_ekman2(ngrid,taux_slab,tauy_slab,tslab,dtekman_loc)
 
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/orbite.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/orbite.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/orbite.F	(revision 227)
@@ -1,3 +1,5 @@
       subroutine orbite(pls,pdist_star,pdecli)
+      
+      use planete_mod, only: p_elips, e_elips, timeperi, obliquit
       implicit none
 
@@ -23,5 +25,5 @@
 c   -------------
 
-#include "planete.h"
+!#include "planete.h"
 #include "comcstfi.h"
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/phyetat0.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/phyetat0.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/phyetat0.F90	(revision 227)
@@ -1,3 +1,3 @@
-subroutine phyetat0 (ngrid,fichnom,tab0,Lmodif,nsoil,nq, &
+subroutine phyetat0 (ngrid,nlayer,fichnom,tab0,Lmodif,nsoil,nq, &
                      day_ini,time,tsurf,tsoil, &
                      emis,q2,qsurf,cloudfrac,totcloudfrac,hice, &
@@ -20,7 +20,7 @@
 !======================================================================
 #include "netcdf.inc"
-#include "dimensions.h"
-#include "dimphys.h"
-#include "planete.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
+!#include "planete.h"
 #include "comcstfi.h"
 
@@ -33,4 +33,5 @@
 !  inputs:
   integer,intent(in) :: ngrid
+  integer,intent(in) :: nlayer
   character*(*),intent(in) :: fichnom ! "startfi.nc" file
   integer,intent(in) :: tab0
@@ -45,8 +46,8 @@
   real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature
   real,intent(out) :: emis(ngrid) ! surface emissivity
-  real,intent(out) :: q2(ngrid, llm+1) ! 
+  real,intent(out) :: q2(ngrid,nlayer+1) ! 
   real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
 ! real co2ice(ngrid) ! co2 ice cover
-  real,intent(out) :: cloudfrac(ngrid,nlayermx)
+  real,intent(out) :: cloudfrac(ngrid,nlayer)
   real,intent(out) :: hice(ngrid), totcloudfrac(ngrid)
   real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,noceanmx)  
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/phyredem.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/phyredem.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/phyredem.F90	(revision 227)
@@ -17,7 +17,9 @@
                       put_var, put_field, length
   use mod_grid_phy_lmdz, only : klon_glo
+  use planete_mod, only: year_day, periastr, apoastr, peri_day, &
+                         obliquit, z0, lmixmin, emin_turb
 
   implicit none
-#include "planete.h"
+!#include "planete.h"
 #include "comcstfi.h"
   character(len=*), intent(in) :: filename
@@ -147,5 +149,5 @@
 !#include "temps.h"
 #include "comcstfi.h"
-#include "planete.h"
+!#include "planete.h"
 #include "callkeys.h"
 !======================================================================
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/physiq.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/physiq.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/physiq.F90	(revision 227)
@@ -5,5 +5,5 @@
                   pplev,pplay,pphi,        &
                   pu,pv,pt,pq,             &
-                  pw,                      &
+                  flxw,                    &
                   pdu,pdv,pdt,pdq,pdpsrf,tracerdyn)
  
@@ -12,5 +12,5 @@
       use gases_h, only: gnom, gfrac
       use radcommon_h, only: sigma, eclipse, glat, grav
-      use radii_mod, only: h2o_reffrad, co2_reffrad, h2o_cloudrad
+      use radii_mod, only: h2o_reffrad, co2_reffrad
       use aerosol_mod, only: iaero_co2, iaero_h2o
       use surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe, &
@@ -32,5 +32,6 @@
       use planetwide_mod, only: planetwide_minval,planetwide_maxval,planetwide_sumval
       use mod_phys_lmdz_para, only : is_master
-
+      use planete_mod, only: apoastr, periastr, year_day, peri_day, &
+                            obliquit, nres, z0
 
       implicit none
@@ -97,13 +98,13 @@
 !    ptdyn(ngrid,nlayer)     / corresponding variables
 !    pqdyn(ngrid,nlayer,nq) /
-!    pw(ngrid,?)           vertical velocity
+!    flxw(ngrid,nlayer)      vertical mass flux (kg/s) at layer lower boundary
 !
 !   output
 !   ------
 !
-!    pdu(ngrid,nlayermx)        \
-!    pdv(ngrid,nlayermx)         \  Temporal derivative of the corresponding
-!    pdt(ngrid,nlayermx)         /  variables due to physical processes.
-!    pdq(ngrid,nlayermx)        /
+!    pdu(ngrid,nlayer)        \
+!    pdv(ngrid,nlayer)         \  Temporal derivative of the corresponding
+!    pdt(ngrid,nlayer)         /  variables due to physical processes.
+!    pdq(ngrid,nlayer)        /
 !    pdpsrf(ngrid)             /
 !    tracerdyn                 call tracer in dynamical part of GCM ?
@@ -131,9 +132,9 @@
 !    ------------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "callkeys.h"
 #include "comcstfi.h"
-#include "planete.h"
+!#include "planete.h"
 !#include "control.h"
 #include "netcdf.inc"
@@ -160,6 +161,6 @@
       real,intent(in) :: pt(ngrid,nlayer) ! temperature (K)
       real,intent(in) :: pq(ngrid,nlayer,nq) ! tracers (.../kg_of_air)
-      real,intent(in) :: pw(ngrid,nlayer)    ! vertical velocity (m/s)
-
+      real,intent(in) :: flxw(ngrid,nlayer) ! vertical mass flux (ks/s)
+                                            ! at lower boundary of layer
 
 
@@ -179,5 +180,5 @@
 !     "longrefvis" set in dimradmars.h , for one of the "naerkind"  kind of
 !      aerosol optical properties:
-!      real aerosol(ngrid,nlayermx,naerkind) 
+!      real aerosol(ngrid,nlayer,naerkind) 
 !     this is now internal to callcorrk and hence no longer needed here
 
@@ -187,7 +188,9 @@
       real, dimension(:,:),allocatable,save ::  tsoil  ! sub-surface temperatures (K)
       real, dimension(:),allocatable,save :: albedo ! Surface albedo
+!$OMP THREADPRIVATE(tsurf,tsoil,albedo)
 
       real,dimension(:),allocatable,save :: albedo0 ! Surface albedo
       real,dimension(:),allocatable,save :: rnat ! added by BC
+!$OMP THREADPRIVATE(albedo0,rnat)
 
       real,dimension(:),allocatable,save :: emis ! Thermal IR surface emissivity
@@ -199,6 +202,8 @@
       real,dimension(:,:),allocatable,save :: qsurf ! tracer on surface (e.g. kg.m-2)
       real,dimension(:,:),allocatable,save :: q2 ! Turbulent Kinetic Energy 
+!$OMP THREADPRIVATE(emis,dtrad,fluxrad_sky,fluxrad,capcal,fluxgrd,qsurf,q2)
 
       save day_ini, icount
+!$OMP THREADPRIVATE(day_ini,icount)
 
 ! Local variables :
@@ -207,6 +212,7 @@
 !     aerosol (dust or ice) extinction optical depth  at reference wavelength 
 !     for the "naerkind" optically active aerosols:
-      real aerosol(ngrid,nlayermx,naerkind) 
-      real zh(ngrid,nlayermx)      ! potential temperature (K)
+      real aerosol(ngrid,nlayer,naerkind) 
+      real zh(ngrid,nlayer)      ! potential temperature (K)
+      real pw(ngrid,nlayer) ! vertical velocity (m/s) (>0 when downwards)
 
       character*80 fichier 
@@ -225,59 +231,61 @@
       real,dimension(:,:),allocatable,save :: zdtsw ! (K/s)
       real,dimension(:),allocatable,save :: sensibFlux ! turbulent flux given by the atm to the surface
+!$OMP THREADPRIVATE(fluxsurf_lw,fluxsurf_sw,fluxtop_lw,fluxabs_sw,fluxtop_dn,fluxdyn,OLR_nu,OSR_nu,&
+	!$OMP zdtlw,zdtsw,sensibFlux)
 
       real zls                       ! solar longitude (rad)
       real zday                      ! date (time since Ls=0, in martian days)
-      real zzlay(ngrid,nlayermx)   ! altitude at the middle of the layers
-      real zzlev(ngrid,nlayermx+1) ! altitude at layer boundaries
+      real zzlay(ngrid,nlayer)   ! altitude at the middle of the layers
+      real zzlev(ngrid,nlayer+1) ! altitude at layer boundaries
       real latvl1,lonvl1             ! Viking Lander 1 point (for diagnostic)
 
 !     Tendencies due to various processes:
       real dqsurf(ngrid,nq)
-      real cldtlw(ngrid,nlayermx)                           ! (K/s) LW heating rate for clear areas
-      real cldtsw(ngrid,nlayermx)                           ! (K/s) SW heating rate for clear areas
+      real cldtlw(ngrid,nlayer)                           ! (K/s) LW heating rate for clear areas
+      real cldtsw(ngrid,nlayer)                           ! (K/s) SW heating rate for clear areas
       real zdtsurf(ngrid)                                   ! (K/s)
-      real dtlscale(ngrid,nlayermx)
-      real zdvdif(ngrid,nlayermx),zdudif(ngrid,nlayermx)  ! (m.s-2)
-      real zdhdif(ngrid,nlayermx), zdtsdif(ngrid)         ! (K/s)
-      real zdtdif(ngrid,nlayermx)			      ! (K/s)
-      real zdvadj(ngrid,nlayermx),zduadj(ngrid,nlayermx)  ! (m.s-2)
-      real zdhadj(ngrid,nlayermx)                           ! (K/s)
-      real zdtgw(ngrid,nlayermx)                            ! (K/s)
-      real zdtmr(ngrid,nlayermx)
-      real zdugw(ngrid,nlayermx),zdvgw(ngrid,nlayermx)    ! (m.s-2)
-      real zdtc(ngrid,nlayermx),zdtsurfc(ngrid)
-      real zdvc(ngrid,nlayermx),zduc(ngrid,nlayermx)
-      real zdumr(ngrid,nlayermx),zdvmr(ngrid,nlayermx)
+      real dtlscale(ngrid,nlayer)
+      real zdvdif(ngrid,nlayer),zdudif(ngrid,nlayer)  ! (m.s-2)
+      real zdhdif(ngrid,nlayer), zdtsdif(ngrid)         ! (K/s)
+      real zdtdif(ngrid,nlayer)			      ! (K/s)
+      real zdvadj(ngrid,nlayer),zduadj(ngrid,nlayer)  ! (m.s-2)
+      real zdhadj(ngrid,nlayer)                           ! (K/s)
+      real zdtgw(ngrid,nlayer)                            ! (K/s)
+      real zdtmr(ngrid,nlayer)
+      real zdugw(ngrid,nlayer),zdvgw(ngrid,nlayer)    ! (m.s-2)
+      real zdtc(ngrid,nlayer),zdtsurfc(ngrid)
+      real zdvc(ngrid,nlayer),zduc(ngrid,nlayer)
+      real zdumr(ngrid,nlayer),zdvmr(ngrid,nlayer)
       real zdtsurfmr(ngrid)
       
-      real zdmassmr(ngrid,nlayermx),zdpsrfmr(ngrid)
+      real zdmassmr(ngrid,nlayer),zdpsrfmr(ngrid)
       real zdmassmr_col(ngrid)
 
-      real zdqdif(ngrid,nlayermx,nq), zdqsdif(ngrid,nq)
-      real zdqevap(ngrid,nlayermx)
-      real zdqsed(ngrid,nlayermx,nq), zdqssed(ngrid,nq)
-      real zdqdev(ngrid,nlayermx,nq), zdqsdev(ngrid,nq)
-      real zdqadj(ngrid,nlayermx,nq)
-      real zdqc(ngrid,nlayermx,nq)
-      real zdqmr(ngrid,nlayermx,nq),zdqsurfmr(ngrid,nq)
-      real zdqlscale(ngrid,nlayermx,nq)
+      real zdqdif(ngrid,nlayer,nq), zdqsdif(ngrid,nq)
+      real zdqevap(ngrid,nlayer)
+      real zdqsed(ngrid,nlayer,nq), zdqssed(ngrid,nq)
+      real zdqdev(ngrid,nlayer,nq), zdqsdev(ngrid,nq)
+      real zdqadj(ngrid,nlayer,nq)
+      real zdqc(ngrid,nlayer,nq)
+      real zdqmr(ngrid,nlayer,nq),zdqsurfmr(ngrid,nq)
+      real zdqlscale(ngrid,nlayer,nq)
       real zdqslscale(ngrid,nq)
-      real zdqchim(ngrid,nlayermx,nq)
+      real zdqchim(ngrid,nlayer,nq)
       real zdqschim(ngrid,nq)
 
-      real zdteuv(ngrid,nlayermx)    ! (K/s)
-      real zdtconduc(ngrid,nlayermx) ! (K/s)
-      real zdumolvis(ngrid,nlayermx)
-      real zdvmolvis(ngrid,nlayermx)
-      real zdqmoldiff(ngrid,nlayermx,nq)
+      real zdteuv(ngrid,nlayer)    ! (K/s)
+      real zdtconduc(ngrid,nlayer) ! (K/s)
+      real zdumolvis(ngrid,nlayer)
+      real zdvmolvis(ngrid,nlayer)
+      real zdqmoldiff(ngrid,nlayer,nq)
 
 !     Local variables for local calculations:
       real zflubid(ngrid)
-      real zplanck(ngrid),zpopsk(ngrid,nlayermx)
-      real zdum1(ngrid,nlayermx)
-      real zdum2(ngrid,nlayermx)
+      real zplanck(ngrid),zpopsk(ngrid,nlayer)
+      real zdum1(ngrid,nlayer)
+      real zdum2(ngrid,nlayer)
       real ztim1,ztim2,ztim3, z1,z2
       real ztime_fin
-      real zdh(ngrid,nlayermx)
+      real zdh(ngrid,nlayer)
       real gmplanet
       real taux(ngrid),tauy(ngrid)
@@ -288,21 +296,22 @@
 ! local variables only used for diagnostics (output in file "diagfi" or "stats")
 ! ------------------------------------------------------------------------------
-      real ps(ngrid), zt(ngrid,nlayermx)
-      real zu(ngrid,nlayermx),zv(ngrid,nlayermx)
-      real zq(ngrid,nlayermx,nq)
+      real ps(ngrid), zt(ngrid,nlayer)
+      real zu(ngrid,nlayer),zv(ngrid,nlayer)
+      real zq(ngrid,nlayer,nq)
       character*2 str2
       character*5 str5
-      real zdtadj(ngrid,nlayermx)
-      real zdtdyn(ngrid,nlayermx)
+      real zdtadj(ngrid,nlayer)
+      real zdtdyn(ngrid,nlayer)
       real,allocatable,dimension(:,:),save :: ztprevious
-      real reff(ngrid,nlayermx) ! effective dust radius (used if doubleq=T)
+!$OMP THREADPRIVATE(ztprevious)
+      real reff(ngrid,nlayer) ! effective dust radius (used if doubleq=T)
       real qtot1,qtot2            ! total aerosol mass
       integer igmin, lmin
       logical tdiag
 
-      real zplev(ngrid,nlayermx+1),zplay(ngrid,nlayermx)
+      real zplev(ngrid,nlayer+1),zplay(ngrid,nlayer)
       real zstress(ngrid), cd
-      real hco2(nq), tmean, zlocal(nlayermx)
-      real vmr(ngrid,nlayermx) ! volume mixing ratio
+      real hco2(nq), tmean, zlocal(nlayer)
+      real vmr(ngrid,nlayer) ! volume mixing ratio
 
       real time_phys
@@ -310,4 +319,5 @@
 !     reinstated by RW for diagnostic
       real,allocatable,dimension(:),save :: tau_col
+!$OMP THREADPRIVATE(tau_col)
       
 !     included by RW to reduce insanity of code
@@ -318,6 +328,6 @@
 
 !     included by RW for H2O precipitation
-      real zdtrain(ngrid,nlayermx)
-      real zdqrain(ngrid,nlayermx,nq)
+      real zdtrain(ngrid,nlayer)
+      real zdqrain(ngrid,nlayer,nq)
       real zdqsrain(ngrid)
       real zdqssnow(ngrid)
@@ -325,12 +335,12 @@
 
 !     included by RW for H2O Manabe scheme
-      real dtmoist(ngrid,nlayermx)
-      real dqmoist(ngrid,nlayermx,nq)
-
-      real qvap(ngrid,nlayermx)
-      real dqvaplscale(ngrid,nlayermx)
-      real dqcldlscale(ngrid,nlayermx)
-      real rneb_man(ngrid,nlayermx)
-      real rneb_lsc(ngrid,nlayermx)
+      real dtmoist(ngrid,nlayer)
+      real dqmoist(ngrid,nlayer,nq)
+
+      real qvap(ngrid,nlayer)
+      real dqvaplscale(ngrid,nlayer)
+      real dqcldlscale(ngrid,nlayer)
+      real rneb_man(ngrid,nlayer)
+      real rneb_lsc(ngrid,nlayer)
 
 !     included by RW to account for surface cooling by evaporation
@@ -339,10 +349,11 @@
 
 !     to test energy conservation (RW+JL)
-      real mass(ngrid,nlayermx),massarea(ngrid,nlayermx)
+      real mass(ngrid,nlayer),massarea(ngrid,nlayer)
       real dEtot, dEtots, AtmToSurf_TurbFlux
       real,save :: dEtotSW, dEtotsSW, dEtotLW, dEtotsLW
-      real dEzRadsw(ngrid,nlayermx),dEzRadlw(ngrid,nlayermx),dEzdiff(ngrid,nlayermx)
+!$OMP THREADPRIVATE(dEtotSW, dEtotsSW, dEtotLW, dEtotsLW)
+      real dEzRadsw(ngrid,nlayer),dEzRadlw(ngrid,nlayer),dEzdiff(ngrid,nlayer)
       real dEdiffs(ngrid),dEdiff(ngrid)
-      real madjdE(ngrid), lscaledE(ngrid),madjdEz(ngrid,nlayermx), lscaledEz(ngrid,nlayermx)
+      real madjdE(ngrid), lscaledE(ngrid),madjdEz(ngrid,nlayer), lscaledEz(ngrid,nlayer)
 !JL12 conservation test for mean flow kinetic energy has been disabled temporarily
       real dtmoist_max,dtmoist_min
@@ -351,11 +362,12 @@
 
 !     included by BC for evaporation     
-      real qevap(ngrid,nlayermx,nq)
-      real tevap(ngrid,nlayermx)
-      real dqevap1(ngrid,nlayermx)
-      real dtevap1(ngrid,nlayermx)
+      real qevap(ngrid,nlayer,nq)
+      real tevap(ngrid,nlayer)
+      real dqevap1(ngrid,nlayer)
+      real dtevap1(ngrid,nlayer)
 
 !     included by BC for hydrology
       real,allocatable,save :: hice(:)
+ !$OMP THREADPRIVATE(hice)     
 
 !     included by RW to test water conservation (by routine)
@@ -365,7 +377,8 @@
       logical watertest
       save watertest
+!$OMP THREADPRIVATE(watertest)
 
 !     included by RW for RH diagnostic
-      real qsat(ngrid,nlayermx), RH(ngrid,nlayermx), H2Omaxcol(ngrid),psat_tmp
+      real qsat(ngrid,nlayer), RH(ngrid,nlayer), H2Omaxcol(ngrid),psat_tmp
 
 !     included by RW for hydrology
@@ -378,6 +391,6 @@
 !     included by BC for double radiative transfer call
       logical clearsky
-      real zdtsw1(ngrid,nlayermx)
-      real zdtlw1(ngrid,nlayermx)
+      real zdtsw1(ngrid,nlayer)
+      real zdtlw1(ngrid,nlayer)
       real fluxsurf_lw1(ngrid)     
       real fluxsurf_sw1(ngrid)  
@@ -392,4 +405,5 @@
       real,allocatable,dimension(:,:),save :: cloudfrac
       real,allocatable,dimension(:),save :: totcloudfrac
+!$OMP THREADPRIVATE(cloudfrac,totcloudfrac)
 
 !     included by RW for vdifc water conservation test
@@ -400,22 +414,24 @@
 !      double precision qsurf_hist(ngrid,nq)
       real,allocatable,dimension(:,:),save :: qsurf_hist
+!$OMP THREADPRIVATE(qsurf_hist)
 
 !     included by RW for temp convadj conservation test
-      real playtest(nlayermx)
-      real plevtest(nlayermx)
-      real ttest(nlayermx)
-      real qtest(nlayermx)
+      real playtest(nlayer)
+      real plevtest(nlayer)
+      real ttest(nlayer)
+      real qtest(nlayer)
       integer igtest
 
 !     included by RW for runway greenhouse 1D study
-      real muvar(ngrid,nlayermx+1)
+      real muvar(ngrid,nlayer+1)
 
 !     included by RW for variable H2O particle sizes
       real,allocatable,dimension(:,:,:),save :: reffrad ! aerosol effective radius (m)
       real,allocatable,dimension(:,:,:),save :: nueffrad ! aerosol effective radius variance
-!      real :: nueffrad_dummy(ngrid,nlayermx,naerkind) !! AS. This is temporary. Check below why.
-      real :: reffh2oliq(ngrid,nlayermx) ! liquid water particles effective radius (m)
-      real :: reffh2oice(ngrid,nlayermx) ! water ice particles effective radius (m)
-   !   real reffH2O(ngrid,nlayermx)
+!$OMP THREADPRIVATE(reffrad,nueffrad)
+!      real :: nueffrad_dummy(ngrid,nlayer,naerkind) !! AS. This is temporary. Check below why.
+      real :: reffh2oliq(ngrid,nlayer) ! liquid water particles effective radius (m)
+      real :: reffh2oice(ngrid,nlayer) ! water ice particles effective radius (m)
+   !   real reffH2O(ngrid,nlayer)
       real reffcol(ngrid,naerkind)
 
@@ -427,4 +443,5 @@
       integer num_run
       logical,save :: ice_update
+!$OMP THREADPRIVATE(ice_initial,ice_min,ice_update)
 
 !     included by MS to compute the daily average of rings shadowing
@@ -445,4 +462,5 @@
       real, dimension(:),allocatable,save :: zmasq
       integer, dimension(:),allocatable,save ::knindex 
+!$OMP THREADPRIVATE(pctsrf_sic,tslab,tsea_ice,sea_ice,zmasq,knindex)
 
       real :: tsurf2(ngrid)
@@ -469,5 +487,5 @@
         ALLOCATE(rnat(ngrid))         
         ALLOCATE(emis(ngrid))   
-        ALLOCATE(dtrad(ngrid,nlayermx))
+        ALLOCATE(dtrad(ngrid,nlayer))
         ALLOCATE(fluxrad_sky(ngrid))
         ALLOCATE(fluxrad(ngrid))    
@@ -475,12 +493,12 @@
         ALLOCATE(fluxgrd(ngrid))  
         ALLOCATE(qsurf(ngrid,nq))  
-        ALLOCATE(q2(ngrid,nlayermx+1)) 
-        ALLOCATE(ztprevious(ngrid,nlayermx))
-        ALLOCATE(cloudfrac(ngrid,nlayermx))
+        ALLOCATE(q2(ngrid,nlayer+1)) 
+        ALLOCATE(ztprevious(ngrid,nlayer))
+        ALLOCATE(cloudfrac(ngrid,nlayer))
         ALLOCATE(totcloudfrac(ngrid))
         ALLOCATE(hice(ngrid))
         ALLOCATE(qsurf_hist(ngrid,nq))
-        ALLOCATE(reffrad(ngrid,nlayermx,naerkind))
-        ALLOCATE(nueffrad(ngrid,nlayermx,naerkind))
+        ALLOCATE(reffrad(ngrid,nlayer,naerkind))
+        ALLOCATE(nueffrad(ngrid,nlayer,naerkind))
         ALLOCATE(ice_initial(ngrid))
         ALLOCATE(ice_min(ngrid)) 
@@ -494,6 +512,6 @@
         ALLOCATE(OSR_nu(ngrid,L_NSPECTV))
         ALLOCATE(sensibFlux(ngrid))
-        ALLOCATE(zdtlw(ngrid,nlayermx))
-        ALLOCATE(zdtsw(ngrid,nlayermx))
+        ALLOCATE(zdtlw(ngrid,nlayer))
+        ALLOCATE(zdtsw(ngrid,nlayer))
         ALLOCATE(tau_col(ngrid))
         ALLOCATE(pctsrf_sic(ngrid))
@@ -541,5 +559,5 @@
 !        read startfi (initial parameters)
 !        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-         call phyetat0(ngrid,"startfi.nc",0,0,nsoilmx,nq,   &
+         call phyetat0(ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq,   &
                day_ini,time_phys,tsurf,tsoil,emis,q2,qsurf,   &
                cloudfrac,totcloudfrac,hice,  &
@@ -587,5 +605,5 @@
 
 
-           CALL init_masquv(zmasq)
+           CALL init_masquv(ngrid,zmasq)
 
 
@@ -628,4 +646,5 @@
          ice_update=.false.
          if(sourceevol)then
+!$OMP MASTER
             open(128,file='num_run',form='formatted', &
                      status="old",iostat=ierr)
@@ -637,4 +656,6 @@
             read(128,*) num_run 
             close(128)
+!$OMP END MASTER
+!$OMP BARRIER
         
             if(num_run.ne.0.and.mod(num_run,2).eq.0)then
@@ -721,10 +742,10 @@
 !     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
-      pdu(1:ngrid,1:nlayermx) = 0.0
-      pdv(1:ngrid,1:nlayermx) = 0.0
+      pdu(1:ngrid,1:nlayer) = 0.0
+      pdv(1:ngrid,1:nlayer) = 0.0
       if ( .not.nearco2cond ) then
-         pdt(1:ngrid,1:nlayermx) = 0.0
+         pdt(1:ngrid,1:nlayer) = 0.0
       endif
-      pdq(1:ngrid,1:nlayermx,1:nq) = 0.0
+      pdq(1:ngrid,1:nlayer,1:nq) = 0.0
       pdpsrf(1:ngrid)       = 0.0
       zflubid(1:ngrid)      = 0.0
@@ -773,6 +794,6 @@
 !     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-      zzlay(1:ngrid,1:nlayermx)=pphi(1:ngrid,1:nlayermx)
-      do l=1,nlayermx         
+      zzlay(1:ngrid,1:nlayer)=pphi(1:ngrid,1:nlayer)
+      do l=1,nlayer         
       zzlay(1:ngrid,l)= zzlay(1:ngrid,l)/glat(1:ngrid)
       enddo
@@ -802,4 +823,15 @@
       enddo
 
+     ! Compute vertical velocity (m/s) from vertical mass flux
+     ! w = F / (rho*area) and rho = r*T/P
+     ! but first linearly interpolate mass flux to mid-layers
+     do l=1,nlayer-1
+       pw(1:ngrid,l)=0.5*(flxw(1:ngrid,l)+flxw(1:ngrid,l+1))
+     enddo
+     pw(1:ngrid,nlayer)=0.5*flxw(1:ngrid,nlayer) ! since flxw(nlayer+1)=0
+     do l=1,nlayer
+       pw(1:ngrid,l)=(pw(1:ngrid,l)*pplay(1:ngrid,l)) /  &
+                     (r*pt(1:ngrid,l)*area(1:ngrid))
+     enddo
 
 !-----------------------------------------------------------------------
@@ -892,9 +924,9 @@
               endif
 	      if(water) then
-                  muvar(1:ngrid,1:nlayermx)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,1:nlayermx,igcm_h2o_vap)) 
-		  muvar(1:ngrid,nlayermx+1)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,nlayermx,igcm_h2o_vap)) 
+                  muvar(1:ngrid,1:nlayer)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,1:nlayer,igcm_h2o_vap)) 
+		  muvar(1:ngrid,nlayer+1)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,nlayer,igcm_h2o_vap)) 
 		  ! take into account water effect on mean molecular weight
 	      else
-                  muvar(1:ngrid,1:nlayermx+1)=mugaz
+                  muvar(1:ngrid,1:nlayer+1)=mugaz
 	      endif 
       
@@ -950,6 +982,6 @@
                     tau_col(ig)     = ntf*tau_col1(ig)     + tf*tau_col(ig)
                     
-                    zdtlw(ig,1:nlayermx) = ntf*zdtlw1(ig,1:nlayermx) + tf*zdtlw(ig,1:nlayermx)
-                    zdtsw(ig,1:nlayermx) = ntf*zdtsw1(ig,1:nlayermx) + tf*zdtsw(ig,1:nlayermx)
+                    zdtlw(ig,1:nlayer) = ntf*zdtlw1(ig,1:nlayer) + tf*zdtlw(ig,1:nlayer)
+                    zdtsw(ig,1:nlayer) = ntf*zdtsw1(ig,1:nlayer) + tf*zdtsw(ig,1:nlayer)
 
                     OSR_nu(ig,1:L_NSPECTV) = ntf*OSR_nu1(ig,1:L_NSPECTV) + tf*OSR_nu(ig,1:L_NSPECTV)		       
@@ -976,5 +1008,5 @@
 
 !             Net atmospheric radiative heating rate (K.s-1)
-              dtrad(1:ngrid,1:nlayermx)=zdtsw(1:ngrid,1:nlayermx)+zdtlw(1:ngrid,1:nlayermx)
+              dtrad(1:ngrid,1:nlayer)=zdtsw(1:ngrid,1:nlayer)+zdtlw(1:ngrid,1:nlayer)
 
            elseif(newtonian)then
@@ -982,5 +1014,5 @@
 !          b) Call Newtonian cooling scheme
 !          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-              call newtrelax(ngrid,mu0,sinlat,zpopsk,pt,pplay,pplev,dtrad,firstcall)
+              call newtrelax(ngrid,nlayer,mu0,sinlat,zpopsk,pt,pplay,pplev,dtrad,firstcall)
 
               zdtsurf(1:ngrid) = +(pt(1:ngrid,1)-tsurf(1:ngrid))/ptimestep
@@ -1001,5 +1033,5 @@
 
 
-              dtrad(1:ngrid,1:nlayermx)=0.0
+              dtrad(1:ngrid,1:nlayer)=0.0
               ! hence no atmospheric radiative heating
 
@@ -1015,5 +1047,5 @@
         zplanck(1:ngrid)=emis(1:ngrid)*sigma*zplanck(1:ngrid)*zplanck(1:ngrid)
         fluxrad(1:ngrid)=fluxrad_sky(1:ngrid)-zplanck(1:ngrid)
-        pdt(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)+dtrad(1:ngrid,1:nlayermx)
+        pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+dtrad(1:ngrid,1:nlayer)
 
 !-------------------------
@@ -1048,6 +1080,6 @@
          zflubid(1:ngrid)=fluxrad(1:ngrid)+fluxgrd(1:ngrid)
 
-         zdum1(1:ngrid,1:nlayermx)=0.0
-         zdum2(1:ngrid,1:nlayermx)=0.0
+         zdum1(1:ngrid,1:nlayer)=0.0
+         zdum2(1:ngrid,1:nlayer)=0.0
 
 
@@ -1066,5 +1098,5 @@
 	 else
 	 
-           zdh(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)/zpopsk(1:ngrid,1:nlayermx)
+           zdh(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer)
  
            call vdifc(ngrid,nlayer,nq,rnat,zpopsk,   &
@@ -1077,12 +1109,12 @@
               taux,tauy,lastcall)
 
-           zdtdif(1:ngrid,1:nlayermx)=zdhdif(1:ngrid,1:nlayermx)*zpopsk(1:ngrid,1:nlayermx) ! for diagnostic only
-	   zdqevap(1:ngrid,1:nlayermx)=0.
+           zdtdif(1:ngrid,1:nlayer)=zdhdif(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only
+	   zdqevap(1:ngrid,1:nlayer)=0.
 
          end if !turbdiff
 
-         pdv(1:ngrid,1:nlayermx)=pdv(1:ngrid,1:nlayermx)+zdvdif(1:ngrid,1:nlayermx)
-         pdu(1:ngrid,1:nlayermx)=pdu(1:ngrid,1:nlayermx)+zdudif(1:ngrid,1:nlayermx)
-         pdt(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)+zdtdif(1:ngrid,1:nlayermx)
+         pdv(1:ngrid,1:nlayer)=pdv(1:ngrid,1:nlayer)+zdvdif(1:ngrid,1:nlayer)
+         pdu(1:ngrid,1:nlayer)=pdu(1:ngrid,1:nlayer)+zdudif(1:ngrid,1:nlayer)
+         pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtdif(1:ngrid,1:nlayer)
          zdtsurf(1:ngrid)=zdtsurf(1:ngrid)+zdtsdif(1:ngrid)
 
@@ -1094,5 +1126,5 @@
 
          if (tracer) then 
-           pdq(1:ngrid,1:nlayermx,1:nq)=pdq(1:ngrid,1:nlayermx,1:nq)+ zdqdif(1:ngrid,1:nlayermx,1:nq)
+           pdq(1:ngrid,1:nlayer,1:nq)=pdq(1:ngrid,1:nlayer,1:nq)+ zdqdif(1:ngrid,1:nlayer,1:nq)
            dqsurf(1:ngrid,1:nq)=dqsurf(1:ngrid,1:nq) + zdqsdif(1:ngrid,1:nq)
          end if ! of if (tracer)
@@ -1171,8 +1203,8 @@
       if(calladj) then
 
-         zdh(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)/zpopsk(1:ngrid,1:nlayermx)
-         zduadj(1:ngrid,1:nlayermx)=0.0
-         zdvadj(1:ngrid,1:nlayermx)=0.0
-         zdhadj(1:ngrid,1:nlayermx)=0.0
+         zdh(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer)
+         zduadj(1:ngrid,1:nlayer)=0.0
+         zdvadj(1:ngrid,1:nlayer)=0.0
+         zdhadj(1:ngrid,1:nlayer)=0.0
 
 
@@ -1184,11 +1216,11 @@
               zdqadj)
 
-         pdu(1:ngrid,1:nlayermx) = pdu(1:ngrid,1:nlayermx) + zduadj(1:ngrid,1:nlayermx)
-         pdv(1:ngrid,1:nlayermx) = pdv(1:ngrid,1:nlayermx) + zdvadj(1:ngrid,1:nlayermx)
-         pdt(1:ngrid,1:nlayermx)    = pdt(1:ngrid,1:nlayermx) + zdhadj(1:ngrid,1:nlayermx)*zpopsk(1:ngrid,1:nlayermx)
-         zdtadj(1:ngrid,1:nlayermx) = zdhadj(1:ngrid,1:nlayermx)*zpopsk(1:ngrid,1:nlayermx) ! for diagnostic only
+         pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) + zduadj(1:ngrid,1:nlayer)
+         pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) + zdvadj(1:ngrid,1:nlayer)
+         pdt(1:ngrid,1:nlayer)    = pdt(1:ngrid,1:nlayer) + zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer)
+         zdtadj(1:ngrid,1:nlayer) = zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only
 
          if(tracer) then 
-            pdq(1:ngrid,1:nlayermx,1:nq) = pdq(1:ngrid,1:nlayermx,1:nq) + zdqadj(1:ngrid,1:nlayermx,1:nq) 
+            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqadj(1:ngrid,1:nlayer,1:nq) 
          end if
 
@@ -1240,10 +1272,10 @@
               zdqc)
 
-         pdt(1:ngrid,1:nlayermx)=pdt(1:ngrid,1:nlayermx)+zdtc(1:ngrid,1:nlayermx)
-         pdv(1:ngrid,1:nlayermx)=pdv(1:ngrid,1:nlayermx)+zdvc(1:ngrid,1:nlayermx)
-         pdu(1:ngrid,1:nlayermx)=pdu(1:ngrid,1:nlayermx)+zduc(1:ngrid,1:nlayermx)
+         pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtc(1:ngrid,1:nlayer)
+         pdv(1:ngrid,1:nlayer)=pdv(1:ngrid,1:nlayer)+zdvc(1:ngrid,1:nlayer)
+         pdu(1:ngrid,1:nlayer)=pdu(1:ngrid,1:nlayer)+zduc(1:ngrid,1:nlayer)
          zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + zdtsurfc(1:ngrid)
 
-         pdq(1:ngrid,1:nlayermx,1:nq)=pdq(1:ngrid,1:nlayermx,1:nq)+ zdqc(1:ngrid,1:nlayermx,1:nq) 
+         pdq(1:ngrid,1:nlayer,1:nq)=pdq(1:ngrid,1:nlayer,1:nq)+ zdqc(1:ngrid,1:nlayer,1:nq) 
          ! Note: we do not add surface co2ice tendency
          ! because qsurf(:,igcm_co2_ice) is updated in condens_co2cloud
@@ -1283,14 +1315,14 @@
 !             ----------------
 
-	       dqmoist(1:ngrid,1:nlayermx,1:nq)=0.
-	       dtmoist(1:ngrid,1:nlayermx)=0.
-
-	       call moistadj(ngrid,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
-
-               pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) = pdq(1:ngrid,1:nlayermx,igcm_h2o_vap)   &
-	                  +dqmoist(1:ngrid,1:nlayermx,igcm_h2o_vap)
-               pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) =pdq(1:ngrid,1:nlayermx,igcm_h2o_ice)     &
-                          +dqmoist(1:ngrid,1:nlayermx,igcm_h2o_ice)
-               pdt(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)+dtmoist(1:ngrid,1:nlayermx)
+	       dqmoist(1:ngrid,1:nlayer,1:nq)=0.
+	       dtmoist(1:ngrid,1:nlayer)=0.
+
+	       call moistadj(ngrid,nlayer,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
+
+               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)   &
+	                  +dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) =pdq(1:ngrid,1:nlayer,igcm_h2o_ice)     &
+                          +dqmoist(1:ngrid,1:nlayer,igcm_h2o_ice)
+               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtmoist(1:ngrid,1:nlayer)
 
                !-------------------------
@@ -1321,9 +1353,9 @@
 !        Large scale condensation/evaporation
 !        --------------------------------
-               call largescale(ngrid,nq,ptimestep,pplev,pplay,pt,pq,pdt,pdq,dtlscale,dqvaplscale,dqcldlscale,rneb_lsc)
-
-               pdt(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)+dtlscale(1:ngrid,1:nlayermx)
-               pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) = pdq(1:ngrid,1:nlayermx,igcm_h2o_vap)+dqvaplscale(1:ngrid,1:nlayermx)
-               pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) = pdq(1:ngrid,1:nlayermx,igcm_h2o_ice)+dqcldlscale(1:ngrid,1:nlayermx)
+               call largescale(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pq,pdt,pdq,dtlscale,dqvaplscale,dqcldlscale,rneb_lsc)
+
+               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtlscale(1:ngrid,1:nlayer)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)+dqvaplscale(1:ngrid,1:nlayer)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice)+dqcldlscale(1:ngrid,1:nlayer)
 
                !-------------------------
@@ -1363,16 +1395,16 @@
             if(waterrain)then
 
-               zdqrain(1:ngrid,1:nlayermx,1:nq) = 0.0
+               zdqrain(1:ngrid,1:nlayer,1:nq) = 0.0
                zdqsrain(1:ngrid)    = 0.0
                zdqssnow(1:ngrid)    = 0.0
 
-               call rain(ngrid,nq,ptimestep,pplev,pplay,pt,pdt,pq,pdq,            &
+               call rain(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pdt,pq,pdq,            &
                    zdtrain,zdqrain,zdqsrain,zdqssnow,cloudfrac)
 
-               pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) = pdq(1:ngrid,1:nlayermx,igcm_h2o_vap) &
-	             +zdqrain(1:ngrid,1:nlayermx,igcm_h2o_vap)
-               pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) = pdq(1:ngrid,1:nlayermx,igcm_h2o_ice) &
-	             +zdqrain(1:ngrid,1:nlayermx,igcm_h2o_ice)
-               pdt(1:ngrid,1:nlayermx) = pdt(1:ngrid,1:nlayermx)+zdtrain(1:ngrid,1:nlayermx)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap) &
+	             +zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice) &
+	             +zdqrain(1:ngrid,1:nlayer,igcm_h2o_ice)
+               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+zdtrain(1:ngrid,1:nlayer)
                dqsurf(1:ngrid,igcm_h2o_vap) = dqsurf(1:ngrid,igcm_h2o_vap)+zdqsrain(1:ngrid) ! a bug was here
                dqsurf(1:ngrid,igcm_h2o_ice) = dqsurf(1:ngrid,igcm_h2o_ice)+zdqssnow(1:ngrid)
@@ -1419,5 +1451,5 @@
 !        ------------- 
         if (sedimentation) then 
-           zdqsed(1:ngrid,1:nlayermx,1:nq) = 0.0
+           zdqsed(1:ngrid,1:nlayer,1:nq) = 0.0
            zdqssed(1:ngrid,1:nq)  = 0.0
 
@@ -1455,5 +1487,5 @@
               ! and as in rain.F90, whether it falls as rain or snow depends
               ! only on the surface temperature
-           pdq(1:ngrid,1:nlayermx,1:nq) = pdq(1:ngrid,1:nlayermx,1:nq) + zdqsed(1:ngrid,1:nlayermx,1:nq)
+           pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqsed(1:ngrid,1:nlayer,1:nq)
            dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + zdqssed(1:ngrid,1:nq)
 
@@ -1483,12 +1515,12 @@
          if(mass_redistrib) then
 
-            zdmassmr(1:ngrid,1:nlayermx) = mass(1:ngrid,1:nlayermx) * &
-	       (   zdqevap(1:ngrid,1:nlayermx)                          &
-	         + zdqrain(1:ngrid,1:nlayermx,igcm_h2o_vap)             &
-		 + dqmoist(1:ngrid,1:nlayermx,igcm_h2o_vap)             &
-		 + dqvaplscale(1:ngrid,1:nlayermx) )
+            zdmassmr(1:ngrid,1:nlayer) = mass(1:ngrid,1:nlayer) * &
+	       (   zdqevap(1:ngrid,1:nlayer)                          &
+	         + zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap)             &
+		 + dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap)             &
+		 + dqvaplscale(1:ngrid,1:nlayer) )
 
             do ig = 1, ngrid
-	       zdmassmr_col(ig)=SUM(zdmassmr(ig,1:nlayermx))
+	       zdmassmr_col(ig)=SUM(zdmassmr(ig,1:nlayer))
             enddo
             
@@ -1503,13 +1535,13 @@
 	 
 
-            pdq(1:ngrid,1:nlayermx,1:nq) = pdq(1:ngrid,1:nlayermx,1:nq) + zdqmr(1:ngrid,1:nlayermx,1:nq)
+            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqmr(1:ngrid,1:nlayer,1:nq)
             dqsurf(1:ngrid,1:nq)         = dqsurf(1:ngrid,1:nq) + zdqsurfmr(1:ngrid,1:nq)
-            pdt(1:ngrid,1:nlayermx)        = pdt(1:ngrid,1:nlayermx) + zdtmr(1:ngrid,1:nlayermx)
-            pdu(1:ngrid,1:nlayermx)        = pdu(1:ngrid,1:nlayermx) + zdumr(1:ngrid,1:nlayermx)
-            pdv(1:ngrid,1:nlayermx)        = pdv(1:ngrid,1:nlayermx) + zdvmr(1:ngrid,1:nlayermx)
+            pdt(1:ngrid,1:nlayer)        = pdt(1:ngrid,1:nlayer) + zdtmr(1:ngrid,1:nlayer)
+            pdu(1:ngrid,1:nlayer)        = pdu(1:ngrid,1:nlayer) + zdumr(1:ngrid,1:nlayer)
+            pdv(1:ngrid,1:nlayer)        = pdv(1:ngrid,1:nlayer) + zdvmr(1:ngrid,1:nlayer)
 	    pdpsrf(1:ngrid)                = pdpsrf(1:ngrid) + zdpsrfmr(1:ngrid)
             zdtsurf(1:ngrid)               = zdtsurf(1:ngrid) + zdtsurfmr(1:ngrid)
 	    
-!	    print*,'after mass redistrib, q=',pq(211,1:nlayermx,igcm_h2o_vap)+ptimestep*pdq(211,1:nlayermx,igcm_h2o_vap) 
+!	    print*,'after mass redistrib, q=',pq(211,1:nlayer,igcm_h2o_vap)+ptimestep*pdq(211,1:nlayer,igcm_h2o_vap) 
 	 endif
 
@@ -1672,14 +1704,14 @@
  
       ! temperature, zonal and meridional wind
-      zt(1:ngrid,1:nlayermx) = pt(1:ngrid,1:nlayermx) + pdt(1:ngrid,1:nlayermx)*ptimestep
-      zu(1:ngrid,1:nlayermx) = pu(1:ngrid,1:nlayermx) + pdu(1:ngrid,1:nlayermx)*ptimestep
-      zv(1:ngrid,1:nlayermx) = pv(1:ngrid,1:nlayermx) + pdv(1:ngrid,1:nlayermx)*ptimestep
+      zt(1:ngrid,1:nlayer) = pt(1:ngrid,1:nlayer) + pdt(1:ngrid,1:nlayer)*ptimestep
+      zu(1:ngrid,1:nlayer) = pu(1:ngrid,1:nlayer) + pdu(1:ngrid,1:nlayer)*ptimestep
+      zv(1:ngrid,1:nlayer) = pv(1:ngrid,1:nlayer) + pdv(1:ngrid,1:nlayer)*ptimestep
 
       ! diagnostic
-      zdtdyn(1:ngrid,1:nlayermx)     = pt(1:ngrid,1:nlayermx)-ztprevious(1:ngrid,1:nlayermx)
-      ztprevious(1:ngrid,1:nlayermx) = zt(1:ngrid,1:nlayermx)
+      zdtdyn(1:ngrid,1:nlayer)     = pt(1:ngrid,1:nlayer)-ztprevious(1:ngrid,1:nlayer)
+      ztprevious(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer)
 
       if(firstcall)then
-         zdtdyn(1:ngrid,1:nlayermx)=0.0
+         zdtdyn(1:ngrid,1:nlayer)=0.0
       endif
 
@@ -1690,5 +1722,5 @@
 
       ! tracers
-      zq(1:ngrid,1:nlayermx,1:nq) = pq(1:ngrid,1:nlayermx,1:nq) + pdq(1:ngrid,1:nlayermx,1:nq)*ptimestep
+      zq(1:ngrid,1:nlayer,1:nq) = pq(1:ngrid,1:nlayer,1:nq) + pdq(1:ngrid,1:nlayer,1:nq)*ptimestep
 
       ! surface pressure
@@ -1798,5 +1830,5 @@
          do iq=1,nq
            do ig=1,ngrid
-              qcol(ig,iq) = SUM( zq(ig,1:nlayermx,iq) * mass(ig,1:nlayermx))
+              qcol(ig,iq) = SUM( zq(ig,1:nlayer,iq) * mass(ig,1:nlayer))
            enddo
          enddo
@@ -1805,14 +1837,14 @@
          reffcol(1:ngrid,1:naerkind)=0.0
          if(co2cond.and.(iaero_co2.ne.0))then
-            call co2_reffrad(ngrid,nq,zq,reffrad(1,1,iaero_co2))
+            call co2_reffrad(ngrid,nlayer,nq,zq,reffrad(1,1,iaero_co2))
             do ig=1,ngrid
-               reffcol(ig,iaero_co2) = SUM(zq(ig,1:nlayermx,igcm_co2_ice)*reffrad(ig,1:nlayermx,iaero_co2)*mass(ig,1:nlayermx))
+               reffcol(ig,iaero_co2) = SUM(zq(ig,1:nlayer,igcm_co2_ice)*reffrad(ig,1:nlayer,iaero_co2)*mass(ig,1:nlayer))
             enddo
          endif
          if(water.and.(iaero_h2o.ne.0))then
-            call h2o_reffrad(ngrid,zq(1,1,igcm_h2o_ice),zt, &
+            call h2o_reffrad(ngrid,nlayer,zq(1,1,igcm_h2o_ice),zt, &
                              reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
             do ig=1,ngrid
-               reffcol(ig,iaero_h2o) = SUM(zq(ig,1:nlayermx,igcm_h2o_ice)*reffrad(ig,1:nlayermx,iaero_h2o)*mass(ig,1:nlayermx))
+               reffcol(ig,iaero_h2o) = SUM(zq(ig,1:nlayer,igcm_h2o_ice)*reffrad(ig,1:nlayer,iaero_h2o)*mass(ig,1:nlayer))
             enddo
          endif
@@ -1989,5 +2021,5 @@
               end do
             if (water) then
-               vmr=zq(1:ngrid,1:nlayermx,igcm_h2o_vap)*mugaz/mmol(igcm_h2o_vap)
+               vmr=zq(1:ngrid,1:nlayer,igcm_h2o_vap)*mugaz/mmol(igcm_h2o_vap)
                call wstats(ngrid,"vmr_h2ovapor",                           &
                           "H2O vapour volume mixing ratio","mol/mol",       & 
@@ -2183,6 +2215,10 @@
 
         ! deallocate gas variables
+!$OMP BARRIER
+!$OMP MASTER
         IF ( ALLOCATED( gnom ) ) DEALLOCATE( gnom )
         IF ( ALLOCATED( gfrac ) ) DEALLOCATE( gfrac )  ! both allocated in su_gases.F90
+!$OMP END MASTER
+!$OMP BARRIER
 
         ! deallocate saved arrays
@@ -2203,4 +2239,5 @@
         IF ( ALLOCATED(q2)) DEALLOCATE(q2)
         IF ( ALLOCATED(ztprevious)) DEALLOCATE(ztprevious)
+	IF ( ALLOCATED(hice)) DEALLOCATE(hice)
         IF ( ALLOCATED(cloudfrac)) DEALLOCATE(cloudfrac)
         IF ( ALLOCATED(totcloudfrac)) DEALLOCATE(totcloudfrac)
@@ -2223,4 +2260,10 @@
         IF ( ALLOCATED(zdtsw)) DEALLOCATE(zdtsw)
         IF ( ALLOCATED(tau_col)) DEALLOCATE(tau_col)
+	IF ( ALLOCATED(pctsrf_sic)) DEALLOCATE(pctsrf_sic)
+        IF ( ALLOCATED(tslab)) DEALLOCATE(tslab)
+        IF ( ALLOCATED(tsea_ice)) DEALLOCATE(tsea_ice)
+        IF ( ALLOCATED(sea_ice)) DEALLOCATE(sea_ice)
+        IF ( ALLOCATED(zmasq)) DEALLOCATE(zmasq)
+        IF ( ALLOCATED(knindex)) DEALLOCATE(knindex)
 
         !! this is defined in comsaison_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/planete.h
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/planete.h	(revision 224)
+++ 	(revision )
@@ -1,15 +1,0 @@
-!-----------------------------------------------------------------------
-! INCLUDE planet.h
-
-      COMMON/planet/apoastr,periastr,year_day,peri_day,                 &
-     &       obliquit,nres,                                             &
-     &       z0,lmixmin,emin_turb,coefvis,coefir,                       &
-     &       timeperi,e_elips,p_elips
-
-      real apoastr,periastr,year_day,peri_day,                          &
-     &     obliquit,nres,                                               &
-     &     z0,lmixmin,emin_turb,coefvis,coefir,                         &
-     &       timeperi,e_elips,p_elips
-      
-
-!-----------------------------------------------------------------------
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/planete_mod.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/planete_mod.F90	(revision 227)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/planete_mod.F90	(revision 227)
@@ -0,0 +1,45 @@
+MODULE planete_mod
+  IMPLICIT NONE
+  
+  REAL :: apoastr ! maximum star-planet distance (AU)
+  REAL :: periastr ! minimum star-planet distance (AU)
+  REAL :: year_day ! length of year (sols)
+  REAL :: peri_day ! date of periastron (sols since N. spring)
+  REAL :: obliquit ! Obliquity of the planet (deg)
+  REAL :: nres ! tidal resonance ratio
+  REAL :: z0 ! surface roughness (m)
+  REAL :: lmixmin ! mixing length
+  REAL :: emin_turb ! minimal energy
+  REAL :: coefvis
+  REAL :: coefir
+  REAL :: timeperi
+  REAL :: e_elips
+  REAL :: p_elips
+  
+  REAL :: preff ! reference surface pressure (Pa)	!read by master
+  REAL,ALLOCATABLE :: ap(:) ! hybrid coordinate at layer interface	!read by master
+  REAL,ALLOCATABLE :: bp(:) ! hybrid coordinate at layer interface 	!read by master
+  
+  CONTAINS
+  
+  subroutine ini_planete_mod(nlayer,preff_dyn,ap_dyn,bp_dyn)
+  
+  implicit none
+  integer,intent(in) :: nlayer ! number of atmospheric layers
+  real,intent(in) :: preff_dyn ! reference surface pressure (Pa)
+  real,intent(in) :: ap_dyn(nlayer+1) ! hybrid coordinate at interfaces
+  real,intent(in) :: bp_dyn(nlayer+1) ! hybrid coordinate at interfaces
+  
+!$OMP MASTER
+  allocate(ap(nlayer+1))
+  allocate(bp(nlayer+1))
+  
+  preff=preff_dyn
+  ap(:)=ap_dyn(:)
+  bp(:)=bp_dyn(:)
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  end subroutine ini_planete_mod
+  
+END MODULE planete_mod
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radcommon_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radcommon_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radcommon_h.F90	(revision 227)
@@ -61,14 +61,19 @@
 ! gIR      :  mean assymetry factor
 
-      REAL*8 BWNI(L_NSPECTI+1), WNOI(L_NSPECTI), DWNI(L_NSPECTI), WAVEI(L_NSPECTI)
-      REAL*8 BWNV(L_NSPECTV+1), WNOV(L_NSPECTV), DWNV(L_NSPECTV), WAVEV(L_NSPECTV)
+      REAL*8 BWNI(L_NSPECTI+1), WNOI(L_NSPECTI), DWNI(L_NSPECTI), WAVEI(L_NSPECTI) !BWNI read by master in setspi
+      REAL*8 BWNV(L_NSPECTV+1), WNOV(L_NSPECTV), DWNV(L_NSPECTV), WAVEV(L_NSPECTV) !BWNV read by master in setspv
       REAL*8 STELLARF(L_NSPECTV), TAURAY(L_NSPECTV), TAURAYVAR(L_NSPECTV)
+!$OMP THREADPRIVATE(WNOI,DWNI,WAVEI,&
+	!$OMP WNOV,DWNV,WAVEV,&
+	!$OMP STELLARF,TAURAY,TAURAYVAR)
 
       REAL*8 blami(L_NSPECTI+1)
       REAL*8 blamv(L_NSPECTV+1) ! these are needed by suaer.F90
+!$OMP THREADPRIVATE(blami,blamv)
 
       !! AS: introduced to avoid doing same computations again for continuum
       INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: indi
       INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: indv
+!$OMP THREADPRIVATE(indi,indv)
 
       !!! ALLOCATABLE STUFF SO THAT DIMENSIONS ARE READ in *.dat FILES -- AS 12/2011  
@@ -79,4 +84,6 @@
       real*8 pgasmin, pgasmax
       real*8 tgasmin, tgasmax
+!$OMP THREADPRIVATE(gasi,gasv,&  !wrefvar,pgasref,tgasref,pfgasref read by master in sugas_corrk
+	!$OMP FZEROI,FZEROV)     !pgasmin,pgasmax,tgasmin,tgasmax read by master in sugas_corrk
 
       real QVISsQREF(L_NSPECTV,naerkind,nsizemax)
@@ -86,4 +93,5 @@
       real omegair(L_NSPECTI,naerkind,nsizemax)
       real gir(L_NSPECTI,naerkind,nsizemax)
+!$OMP THREADPRIVATE(QVISsQREF,omegavis,gvis,QIRsQREF,omegair,gir)
 
 
@@ -102,4 +110,5 @@
 
       DOUBLE PRECISION :: radiustab(naerkind,2,nsizemax)
+!$OMP THREADPRIVATE(lamrefir,lamrefvis,radiustab) !nsize read by suaer_corrk
 
 ! Extinction coefficient at reference wavelengths;
@@ -121,4 +130,6 @@
 
       real*8 gweight(L_NGAUSS)
+!$OMP THREADPRIVATE(QREFvis,QREFir,omegaREFvis,omegaREFir,& 	! gweight read by master in sugas_corrk
+		!$OMP tstellar,planckir,PTOP,TAUREF)
 
 !     If the gas optical depth (top to the surface) is less than
@@ -137,4 +148,5 @@
       real*8 glat_ig
       save glat_ig
+!$OMP THREADPRIVATE(Cmk,glat_ig)
 
       ! extinction of incoming sunlight (Saturn's rings, eclipses, etc...)
@@ -143,4 +155,5 @@
       !Latitude-dependent gravity
       REAL, DIMENSION(:), ALLOCATABLE :: glat
+!$OMP THREADPRIVATE(glat,eclipse)
 
       end module radcommon_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radii_mod.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radii_mod.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radii_mod.F90	(revision 227)
@@ -12,4 +12,5 @@
       real, save ::  Nmix_h2o
       real, save ::  Nmix_h2o_ice
+!$OMP THREADPRIVATE(rad_h2o,rad_h2o_ice,Nmix_h2o,Nmix_h2o_ice)
       real, parameter ::  coef_chaud=0.13
       real, parameter ::  coef_froid=0.09
@@ -20,5 +21,5 @@
 
 !==================================================================
-   subroutine su_aer_radii(ngrid,reffrad,nueffrad)
+   subroutine su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
 !==================================================================
 !     Purpose
@@ -32,5 +33,6 @@
 !==================================================================
  ! to use  'getin'
-      use ioipsl_getincom 
+!      use ioipsl_getincom 
+      use ioipsl_getincom_p
       use radinc_h, only: naerkind
       use aerosol_mod
@@ -39,13 +41,15 @@
 
       include "callkeys.h"
-      include "dimensions.h"
-      include "dimphys.h"
-
-      integer,intent(in) :: ngrid
-
-      real, intent(out) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
-      real, intent(out) :: nueffrad(ngrid,nlayermx,naerkind)     !variance     
+!      include "dimensions.h"
+!      include "dimphys.h"
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(out) :: reffrad(ngrid,nlayer,naerkind)      !aerosols radii (K)
+      real, intent(out) :: nueffrad(ngrid,nlayer,naerkind)     !variance     
 
       logical, save :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
       integer :: iaer   
       
@@ -58,26 +62,26 @@
 
             if(iaer.eq.iaero_co2)then ! CO2 ice
-               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-4
-               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1 
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-4
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
             endif
 
             if(iaer.eq.iaero_h2o)then ! H2O ice
-               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-5
-               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1 
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-5
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
             endif
 
             if(iaer.eq.iaero_dust)then ! dust
-               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-5
-               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1 
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-5
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
             endif
  
             if(iaer.eq.iaero_h2so4)then ! H2O ice
-               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-6
-               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1 
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-6
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
             endif
 	    
 	    if(iaer.eq.iaero_back2lay)then ! Two-layer aerosols
-               reffrad(1:ngrid,1:nlayermx,iaer) = 2.e-6
-               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1 
+               reffrad(1:ngrid,1:nlayer,iaer) = 2.e-6
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
             endif
 
@@ -98,10 +102,10 @@
 	    write(*,*)"radius of H2O water particles:"
             rad_h2o=13. ! default value
-            call getin("rad_h2o",rad_h2o)
+            call getin_p("rad_h2o",rad_h2o)
             write(*,*)" rad_h2o = ",rad_h2o
 
 	    write(*,*)"radius of H2O ice particles:"
             rad_h2o_ice=35. ! default value
-            call getin("rad_h2o_ice",rad_h2o_ice)
+            call getin_p("rad_h2o_ice",rad_h2o_ice)
             write(*,*)" rad_h2o_ice = ",rad_h2o_ice
 
@@ -110,10 +114,10 @@
             write(*,*)"Number mixing ratio of H2O water particles:"
             Nmix_h2o=1.e6 ! default value
-            call getin("Nmix_h2o",Nmix_h2o)
+            call getin_p("Nmix_h2o",Nmix_h2o)
             write(*,*)" Nmix_h2o = ",Nmix_h2o
 
             write(*,*)"Number mixing ratio of H2O ice particles:"
             Nmix_h2o_ice=Nmix_h2o ! default value
-            call getin("Nmix_h2o_ice",Nmix_h2o_ice)
+            call getin_p("Nmix_h2o_ice",Nmix_h2o_ice)
             write(*,*)" Nmix_h2o_ice = ",Nmix_h2o_ice
 	 endif
@@ -126,5 +130,5 @@
 
 !==================================================================
-   subroutine h2o_reffrad(ngrid,pq,pt,reffrad,nueffrad)
+   subroutine h2o_reffrad(ngrid,nlayer,pq,pt,reffrad,nueffrad)
 !==================================================================
 !     Purpose
@@ -141,14 +145,15 @@
 
       include "callkeys.h"
-      include "dimensions.h"
-      include "dimphys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
       include "comcstfi.h"
 
       integer,intent(in) :: ngrid
-
-      real, intent(in) :: pq(ngrid,nlayermx) !water ice mixing ratios (kg/kg)
-      real, intent(in) :: pt(ngrid,nlayermx) !temperature (K)
-      real, intent(out) :: reffrad(ngrid,nlayermx)      !aerosol radii
-      real, intent(out) :: nueffrad(ngrid,nlayermx) ! dispersion      
+      integer,intent(in) :: nlayer
+
+      real, intent(in) :: pq(ngrid,nlayer) !water ice mixing ratios (kg/kg)
+      real, intent(in) :: pt(ngrid,nlayer) !temperature (K)
+      real, intent(out) :: reffrad(ngrid,nlayer)      !aerosol radii
+      real, intent(out) :: nueffrad(ngrid,nlayer) ! dispersion      
 
       integer :: ig,l
@@ -158,5 +163,5 @@
 
       if (radfixed) then
-         do l=1,nlayermx
+         do l=1,nlayer
             do ig=1,ngrid
                zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
@@ -167,5 +172,5 @@
          enddo
       else
-         do l=1,nlayermx
+         do l=1,nlayer
             do ig=1,ngrid
                zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
@@ -186,5 +191,5 @@
 
 !==================================================================
-   subroutine h2o_cloudrad(ngrid,pql,reffliq,reffice)
+   subroutine h2o_cloudrad(ngrid,nlayer,pql,reffliq,reffice)
 !==================================================================
 !     Purpose
@@ -201,12 +206,13 @@
 
       include "callkeys.h"
-      include "dimensions.h"
-      include "dimphys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
       include "comcstfi.h"
 
       integer,intent(in) :: ngrid
-
-      real, intent(in) :: pql(ngrid,nlayermx) !condensed water mixing ratios (kg/kg)
-      real, intent(out) :: reffliq(ngrid,nlayermx),reffice(ngrid,nlayermx)     !liquid and ice water particle radii (m)
+      integer,intent(in) :: nlayer
+
+      real, intent(in) :: pql(ngrid,nlayer) !condensed water mixing ratios (kg/kg)
+      real, intent(out) :: reffliq(ngrid,nlayer),reffice(ngrid,nlayer)     !liquid and ice water particle radii (m)
 
       real,external :: CBRT            
@@ -214,8 +220,8 @@
 
       if (radfixed) then
-	 reffliq(1:ngrid,1:nlayermx)= rad_h2o
-	 reffice(1:ngrid,1:nlayermx)= rad_h2o_ice
+	 reffliq(1:ngrid,1:nlayer)= rad_h2o
+	 reffice(1:ngrid,1:nlayer)= rad_h2o_ice
       else
-	 do k=1,nlayermx
+	 do k=1,nlayer
 	   do i=1,ngrid
 	     reffliq(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o*pi*rhowater))
@@ -234,5 +240,5 @@
 
 !==================================================================
-   subroutine co2_reffrad(ngrid,nq,pq,reffrad)
+   subroutine co2_reffrad(ngrid,nlayer,nq,pq,reffrad)
 !==================================================================
 !     Purpose
@@ -249,12 +255,12 @@
 
       include "callkeys.h"
-      include "dimensions.h"
-      include "dimphys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
       include "comcstfi.h"
 
-      integer,intent(in) :: ngrid,nq
-
-      real, intent(in) :: pq(ngrid,nlayermx,nq) !tracer mixing ratios (kg/kg)
-      real, intent(out) :: reffrad(ngrid,nlayermx)      !co2 ice particles radii (K)
+      integer,intent(in) :: ngrid,nlayer,nq
+
+      real, intent(in) :: pq(ngrid,nlayer,nq) !tracer mixing ratios (kg/kg)
+      real, intent(out) :: reffrad(ngrid,nlayer)      !co2 ice particles radii (m)
 
       integer :: ig,l
@@ -265,7 +271,7 @@
 
       if (radfixed) then
-         reffrad(1:ngrid,1:nlayermx) = 5.e-5 ! CO2 ice
+         reffrad(1:ngrid,1:nlayer) = 5.e-5 ! CO2 ice
       else
-         do l=1,nlayermx
+         do l=1,nlayer
             do ig=1,ngrid
                zrad = CBRT( 3*pq(ig,l,igcm_co2_ice)/(4*Nmix_co2*pi*rho_co2) )
@@ -281,5 +287,5 @@
 
 !==================================================================
-   subroutine dust_reffrad(ngrid,reffrad)
+   subroutine dust_reffrad(ngrid,nlayer,reffrad)
 !==================================================================
 !     Purpose
@@ -294,13 +300,14 @@
       Implicit none
 
-      include "callkeys.h"
-      include "dimensions.h"
-      include "dimphys.h"
-
-      integer,intent(in) :: ngrid
-
-      real, intent(out) :: reffrad(ngrid,nlayermx)      !dust particles radii (K)
+!      include "callkeys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(out) :: reffrad(ngrid,nlayer)      !dust particles radii (m)
             
-      reffrad(1:ngrid,1:nlayermx) = 2.e-6 ! dust
+      reffrad(1:ngrid,1:nlayer) = 2.e-6 ! dust
 
    end subroutine dust_reffrad
@@ -309,5 +316,5 @@
 
 !==================================================================
-   subroutine h2so4_reffrad(ngrid,reffrad)
+   subroutine h2so4_reffrad(ngrid,nlayer,reffrad)
 !==================================================================
 !     Purpose
@@ -322,13 +329,14 @@
       Implicit none
 
-      include "callkeys.h"
-      include "dimensions.h"
-      include "dimphys.h"
-
-      integer,intent(in) :: ngrid
-
-      real, intent(out) :: reffrad(ngrid,nlayermx)      !h2so4 particle radii (K)
+!      include "callkeys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(out) :: reffrad(ngrid,nlayer)      !h2so4 particle radii (m)
                 
-      reffrad(1:ngrid,1:nlayermx) = 1.e-6 ! h2so4
+      reffrad(1:ngrid,1:nlayer) = 1.e-6 ! h2so4
 
    end subroutine h2so4_reffrad
@@ -352,10 +360,10 @@
 
      include "callkeys.h"
-     include "dimensions.h"
-     include "dimphys.h"
-
-      integer,intent(in) :: ngrid
-
-      real, intent(out) :: reffrad(ngrid,nlayermx)      ! particle radii 
+!     include "dimensions.h"
+!     include "dimphys.h"
+
+      integer,intent(in) :: ngrid
+
+      real, intent(out) :: reffrad(ngrid,nlayer)      ! particle radii (m)
       REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
       INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radinc_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radinc_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/radinc_h.F90	(revision 227)
@@ -63,5 +63,5 @@
       ! These are set in sugas_corrk
       ! [uses allocatable arrays] -- AS 12/2011
-      integer :: L_NPREF, L_NTREF, L_REFVAR, L_PINT
+      integer :: L_NPREF, L_NTREF, L_REFVAR, L_PINT   !L_NPREF, L_NTREF, L_REFVAR, L_PINT read by master in sugas_corrk
 
       integer, parameter :: L_NGAUSS  = 17
@@ -92,7 +92,9 @@
       character (len=100) :: corrkdir
       save corrkdir
+!$OMP THREADPRIVATE(corrkdir)
 
       character (len=100) :: banddir
       save banddir
+!$OMP THREADPRIVATE(banddir)
 
       end module radinc_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/rain.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/rain.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/rain.F90	(revision 227)
@@ -1,6 +1,8 @@
-subroutine rain(ngrid,nq,ptimestep,pplev,pplay,t,pdt,pq,pdq,d_t,dqrain,dqsrain,dqssnow,rneb)
-
-
-  use ioipsl_getincom, only: getin
+subroutine rain(ngrid,nlayer,nq,ptimestep,pplev,pplay,t,pdt,pq,pdq,d_t,dqrain,dqsrain,dqssnow,rneb)
+
+
+! to use  'getin'
+!  use ioipsl_getincom 
+  use ioipsl_getincom_p
   use watercommon_h, only: T_h2O_ice_liq,T_h2O_ice_clouds, RLVTT, RCPD, RCPV, RV, RVTMP2,Psat_water,Tsat_water,rhowater
   use radii_mod, only: h2o_cloudrad
@@ -22,30 +24,31 @@
 !==================================================================
 
-  include "dimensions.h"
-  include "dimphys.h"
+!  include "dimensions.h"
+!  include "dimphys.h"
   include "comcstfi.h"
   include "callkeys.h"
 
 !     Arguments
-      integer,intent(in) :: ngrid ! number of atmospherci columns
+      integer,intent(in) :: ngrid ! number of atmospheric columns
+      integer,intent(in) :: nlayer ! number of atmospheric layers
       integer,intent(in) :: nq ! number of tracers
       real,intent(in) :: ptimestep    ! time interval
-      real,intent(in) :: pplev(ngrid,nlayermx+1) ! inter-layer pressure (Pa)
-      real,intent(in) :: pplay(ngrid,nlayermx)   ! mid-layer pressure (Pa)
-      real,intent(in) :: t(ngrid,nlayermx) ! input temperature (K)
-      real,intent(in) :: pdt(ngrid,nlayermx) ! input tendency on temperature (K/s)      
-      real,intent(in) :: pq(ngrid,nlayermx,nq)  ! tracers (kg/kg)
-      real,intent(in) :: pdq(ngrid,nlayermx,nq) ! input tendency on tracers
-      real,intent(out) :: d_t(ngrid,nlayermx) ! temperature tendency (K/s)
-      real,intent(out) :: dqrain(ngrid,nlayermx,nq) ! tendency of H2O precipitation (kg/kg.s-1)
+      real,intent(in) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      real,intent(in) :: pplay(ngrid,nlayer)   ! mid-layer pressure (Pa)
+      real,intent(in) :: t(ngrid,nlayer) ! input temperature (K)
+      real,intent(in) :: pdt(ngrid,nlayer) ! input tendency on temperature (K/s)      
+      real,intent(in) :: pq(ngrid,nlayer,nq)  ! tracers (kg/kg)
+      real,intent(in) :: pdq(ngrid,nlayer,nq) ! input tendency on tracers
+      real,intent(out) :: d_t(ngrid,nlayer) ! temperature tendency (K/s)
+      real,intent(out) :: dqrain(ngrid,nlayer,nq) ! tendency of H2O precipitation (kg/kg.s-1)
       real,intent(out) :: dqsrain(ngrid)  ! rain flux at the surface (kg.m-2.s-1)
       real,intent(out) :: dqssnow(ngrid)  ! snow flux at the surface (kg.m-2.s-1)
-      real,intent(in) :: rneb(ngrid,nlayermx) ! cloud fraction
-
-      REAL zt(ngrid,nlayermx)         ! working temperature (K)
-      REAL ql(ngrid,nlayermx)         ! liquid water (Kg/Kg)
-      REAL q(ngrid,nlayermx)          ! specific humidity (Kg/Kg)
-      REAL d_q(ngrid,nlayermx)        ! water vapor increment
-      REAL d_ql(ngrid,nlayermx)       ! liquid water / ice increment
+      real,intent(in) :: rneb(ngrid,nlayer) ! cloud fraction
+
+      REAL zt(ngrid,nlayer)         ! working temperature (K)
+      REAL ql(ngrid,nlayer)         ! liquid water (Kg/Kg)
+      REAL q(ngrid,nlayer)          ! specific humidity (Kg/Kg)
+      REAL d_q(ngrid,nlayer)        ! water vapor increment
+      REAL d_ql(ngrid,nlayer)       ! liquid water / ice increment
 
 !     Subroutine options
@@ -62,8 +65,10 @@
       REAL,PARAMETER :: Kboucher=1.19E8
       REAL,SAVE :: c1
+!$OMP THREADPRIVATE(precip_scheme,rainthreshold,cloud_sat,precip_timescale,Cboucher,c1)
 
       INTEGER,PARAMETER :: ninter=5
 
       logical,save :: evap_prec ! Does the rain evaporate?
+!$OMP THREADPRIVATE(evap_prec)
 
 !     for simple scheme
@@ -73,5 +78,5 @@
 !     Local variables
       INTEGER i, k, n
-      REAL zqs(ngrid,nlayermx),Tsat(ngrid,nlayermx), zdelta, zcor
+      REAL zqs(ngrid,nlayer),Tsat(ngrid,nlayer), zdelta, zcor
       REAL zrfl(ngrid), zrfln(ngrid), zqev, zqevt
 
@@ -80,10 +85,10 @@
       REAL zchau(ngrid),zfroi(ngrid),zfrac(ngrid),zneb(ngrid)
 
-      real reffh2oliq(ngrid,nlayermx),reffh2oice(ngrid,nlayermx)
+      real reffh2oliq(ngrid,nlayer),reffh2oice(ngrid,nlayer)
   
       real ttemp, ptemp, psat_tmp
-      real tnext(ngrid,nlayermx)
-
-      real l2c(ngrid,nlayermx)
+      real tnext(ngrid,nlayer)
+
+      real l2c(ngrid,nlayer)
       real dWtot
 
@@ -92,6 +97,8 @@
       INTEGER, SAVE :: i_vap=0  ! water vapour
       INTEGER, SAVE :: i_ice=0  ! water ice
+!$OMP THREADPRIVATE(i_vap,i_ice)
 
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
 
 !     Online functions
@@ -114,5 +121,5 @@
          write(*,*) "Precipitation scheme to use?"
          precip_scheme=1 ! default value
-         call getin("precip_scheme",precip_scheme)
+         call getin_p("precip_scheme",precip_scheme)
          write(*,*) " precip_scheme = ",precip_scheme
 
@@ -120,5 +127,5 @@
 	    write(*,*) "rainthreshold in simple scheme?"
             rainthreshold=0. ! default value
-            call getin("rainthreshold",rainthreshold)
+            call getin_p("rainthreshold",rainthreshold)
             write(*,*) " rainthreshold = ",rainthreshold
 
@@ -126,9 +133,9 @@
 	    write(*,*) "cloud water saturation level in non simple scheme?"
             cloud_sat=2.6e-4   ! default value
-            call getin("cloud_sat",cloud_sat)
+            call getin_p("cloud_sat",cloud_sat)
             write(*,*) " cloud_sat = ",cloud_sat
 	    write(*,*) "precipitation timescale in non simple scheme?"
             precip_timescale=3600.  ! default value
-            call getin("precip_timescale",precip_timescale)
+            call getin_p("precip_timescale",precip_timescale)
             write(*,*) " precip_timescale = ",precip_timescale
 
@@ -136,5 +143,5 @@
 	    write(*,*) "multiplicative constant in Boucher 95 precip scheme"
             Cboucher=1.   ! default value
-            call getin("Cboucher",Cboucher)
+            call getin_p("Cboucher",Cboucher)
             write(*,*) " Cboucher = ",Cboucher	
 	    c1=1.00*1.097/rhowater*Cboucher*Kboucher  
@@ -144,5 +151,5 @@
          write(*,*) "re-evaporate precipitations?"
          evap_prec=.true. ! default value
-         call getin("evap_prec",evap_prec)
+         call getin_p("evap_prec",evap_prec)
          write(*,*) " evap_prec = ",evap_prec
 
@@ -151,5 +158,5 @@
 
 !     GCM -----> subroutine variables
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
       DO i = 1, ngrid
 
@@ -172,12 +179,12 @@
 
 !     Initialise the outputs
-      d_t(1:ngrid,1:nlayermx) = 0.0
-      d_q(1:ngrid,1:nlayermx) = 0.0
-      d_ql(1:ngrid,1:nlayermx) = 0.0
+      d_t(1:ngrid,1:nlayer) = 0.0
+      d_q(1:ngrid,1:nlayer) = 0.0
+      d_ql(1:ngrid,1:nlayer) = 0.0
       zrfl(1:ngrid) = 0.0
       zrfln(1:ngrid) = 0.0
 
       ! calculate saturation mixing ratio
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
          DO i = 1, ngrid
             ttemp = zt(i,k) 
@@ -190,5 +197,5 @@
 
       ! get column / layer conversion factor
-      DO k = 1, nlayermx
+      DO k = 1, nlayer
          DO i = 1, ngrid
             l2c(i,k)=(pplev(i,k)-pplev(i,k+1))/g
@@ -199,5 +206,5 @@
       ! We carry the rain with us and calculate that added by warm/cold precipitation
       ! processes and that subtracted by evaporation at each level.
-      DO k = nlayermx, 1, -1
+      DO k = nlayer, 1, -1
 
          IF (evap_prec) THEN ! note no rneb dependence!
@@ -273,5 +280,5 @@
 
  !recalculate liquid water particle radii
-	   call h2o_cloudrad(ngrid,ql,reffh2oliq,reffh2oice)
+	   call h2o_cloudrad(ngrid,nlayer,ql,reffh2oliq,reffh2oice)
 
            SELECT CASE(precip_scheme)
@@ -357,5 +364,5 @@
          endif ! if precip_scheme=1
 
-      ENDDO ! of DO k = nlayermx, 1, -1
+      ENDDO ! of DO k = nlayer, 1, -1
 
 !     Rain or snow on the ground
@@ -376,11 +383,11 @@
 !     now subroutine -----> GCM variables
       if (evap_prec) then
-        dqrain(1:ngrid,1:nlayermx,i_vap)=d_q(1:ngrid,1:nlayermx)/ptimestep
-        d_t(1:ngrid,1:nlayermx)=d_t(1:ngrid,1:nlayermx)/ptimestep
+        dqrain(1:ngrid,1:nlayer,i_vap)=d_q(1:ngrid,1:nlayer)/ptimestep
+        d_t(1:ngrid,1:nlayer)=d_t(1:ngrid,1:nlayer)/ptimestep
       else
-        dqrain(1:ngrid,1:nlayermx,i_vap)=0.0
-        d_t(1:ngrid,1:nlayermx)=0.0
+        dqrain(1:ngrid,1:nlayer,i_vap)=0.0
+        d_t(1:ngrid,1:nlayer)=0.0
       endif
-      dqrain(1:ngrid,1:nlayermx,i_ice) = d_ql(1:ngrid,1:nlayermx)/ptimestep
+      dqrain(1:ngrid,1:nlayer,i_ice) = d_ql(1:ngrid,1:nlayer)/ptimestep
 
     end subroutine rain
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/setspi.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/setspi.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/setspi.F90	(revision 227)
@@ -92,4 +92,5 @@
       endif
     
+!$OMP MASTER    
       nb=0
       ierr=0
@@ -121,4 +122,6 @@
       BWNI(L_NSPECTI)  =lastband(1)
       BWNI(L_NSPECTI+1)=lastband(2)
+!$OMP END MASTER
+!$OMP BARRIER
 
       print*,''
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/setspv.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/setspv.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/setspv.F90	(revision 227)
@@ -69,5 +69,6 @@
          call abort
       endif
-    
+	
+!$OMP MASTER        
       nb=0
       ierr=0
@@ -98,5 +99,6 @@
       BWNV(L_NSPECTV)  =lastband(1)
       BWNV(L_NSPECTV+1)=lastband(2)
-
+!$OMP END MASTER
+!$OMP BARRIER
 
       print*,'setspv: VI band limits:'
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/soil.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/soil.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/soil.F	(revision 227)
@@ -17,6 +17,6 @@
 !-----------------------------------------------------------------------
 
-      include "dimensions.h"
-      include "dimphys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
 
 
@@ -45,4 +45,5 @@
       real,dimension(:,:),save,allocatable :: beta ! beta_k coefficients
       real,save :: mu
+!$OMP THREADPRIVATE(mthermdiff,thermdiff,coefq,coefd,alph,beta,mu)
             
 ! local variables:
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/start2archive.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/start2archive.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/start2archive.F	(revision 227)
@@ -27,8 +27,10 @@
 ! to use  'getin'
       USE ioipsl_getincom
+      USE planete_mod
 
       implicit none
 
 #include "dimensions.h"
+      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) 
 #include "paramet.h"
 #include "comconst.h"
@@ -41,6 +43,6 @@
 #include "ener.h"
 
-#include "dimphys.h"
-#include "planete.h"
+!#include "dimphys.h"
+!#include "planete.h"
 !#include"advtrac.h"
 #include "netcdf.inc"
@@ -69,5 +71,5 @@
       REAL tsoil(ngridmx,nsoilmx) ! Soil temperature
       REAL co2ice(ngridmx)	! CO2 ice layer
-      REAL q2(ngridmx,nlayermx+1)
+      REAL q2(ngridmx,llm+1)
       REAL,ALLOCATABLE :: qsurf(:,:)
       REAL emis(ngridmx)
@@ -80,5 +82,5 @@
 !     added by FF for cloud fraction setup
       REAL hice(ngridmx)
-      REAL cloudfrac(ngridmx,nlayermx),totalcloudfrac(ngridmx)
+      REAL cloudfrac(ngridmx,llm),totalcloudfrac(ngridmx)
 
 !     added by BC for slab ocean
@@ -199,6 +201,6 @@
 
 
-      CALL phyetat0 (ngridmx,fichnom,0,Lmodif,nsoilmx,nqtot,day_ini_fi,
-     .      timefi,
+      CALL phyetat0 (ngridmx,llm,fichnom,0,Lmodif,nsoilmx,nqtot,
+     .      day_ini_fi,timefi,
      .      tsurf,tsoil,emis,q2,qsurf,
 !       change FF 05/2011
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/stellarlong.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/stellarlong.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/stellarlong.F	(revision 227)
@@ -1,3 +1,5 @@
       SUBROUTINE stellarlong(pday,pstellong)
+      
+      USE planete_mod, ONLY: year_day, peri_day, e_elips, timeperi
       IMPLICIT NONE
 
@@ -40,5 +42,5 @@
 c   -------------
 
-#include "planete.h"
+!#include "planete.h"
 #include "comcstfi.h"
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/stokes.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/stokes.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/stokes.F90	(revision 227)
@@ -33,8 +33,10 @@
       real a,b,molrad,visc
       save a,b
+!$OMP THREADPRIVATE(a,b)
   
       LOGICAL firstcall
       SAVE firstcall
       DATA firstcall/.true./
+!$OMP THREADPRIVATE(firstcall)
 
       if (firstcall) then
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/su_gases.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/su_gases.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/su_gases.F90	(revision 227)
@@ -20,4 +20,5 @@
   !==================================================================
 
+!$OMP MASTER
   ! load gas names from file 'gases.def'
   open(90,file='gases.def',status='old',form='formatted',iostat=ierr)
@@ -122,4 +123,6 @@
   endif
   close(90)
+!$OMP END MASTER
+!$OMP BARRIER
 
 end subroutine su_gases
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/suaer_corrk.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/suaer_corrk.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/suaer_corrk.F90	(revision 227)
@@ -46,6 +46,6 @@
 #include "callkeys.h"
 !     Optical properties (read in external ASCII files)
-      INTEGER          :: nwvl  ! Number of wavelengths in
-                                ! the domain (VIS or IR)
+      INTEGER,SAVE      :: nwvl  ! Number of wavelengths in
+                                ! the domain (VIS or IR), read by master
 
 !      REAL             :: solsir ! visible to infrared ratio
@@ -53,12 +53,12 @@
 
       REAL, DIMENSION(:),&
-      ALLOCATABLE, SAVE :: wvl  ! Wavelength axis
+      ALLOCATABLE, SAVE :: wvl  ! Wavelength axis, read by master
       REAL, DIMENSION(:),&
-      ALLOCATABLE, SAVE :: radiusdyn ! Particle size axis
+      ALLOCATABLE, SAVE :: radiusdyn ! Particle size axis, read by master
 
       REAL, DIMENSION(:,:),&
-      ALLOCATABLE, SAVE :: ep,& ! Extinction coefficient Qext
-      omeg,&                    ! Single Scattering Albedo
-      gfactor                   ! Assymetry Factor
+      ALLOCATABLE, SAVE :: ep,& ! Extinction coefficient Qext, read by master
+      omeg,&                    ! Single Scattering Albedo, read by master
+      gfactor                   ! Assymetry Factor, read by master
 
 !     Local variables:
@@ -98,4 +98,5 @@
 
       CHARACTER(LEN=30), DIMENSION(naerkind,2), SAVE :: file_id
+!$OMP THREADPRIVATE(file_id)
 !---- Please indicate the names of the optical property files below
 !     Please also choose the reference wavelengths of each aerosol
@@ -203,4 +204,5 @@
 !     1.1 Open the ASCII file
 
+!$OMP MASTER
             INQUIRE(FILE=TRIM(datadir)//&
          '/'//TRIM(file_id(iaer,idomain)),&
@@ -339,4 +341,6 @@
       endif
 
+!$OMP END MASTER
+!$OMP BARRIER
 
 
@@ -432,9 +436,13 @@
 !========================================================================
 
-      DEALLOCATE(wvl)           ! wvl
-      DEALLOCATE(radiusdyn)     ! radiusdyn
-      DEALLOCATE(ep)            ! ep 
-      DEALLOCATE(omeg)          ! omeg 
-      DEALLOCATE(gfactor)       ! g
+!$OMP BARRIER
+!$OMP MASTER
+      IF (ALLOCATED(wvl)) DEALLOCATE(wvl)                 ! wvl
+      IF (ALLOCATED(radiusdyn)) DEALLOCATE(radiusdyn)     ! radiusdyn
+      IF (ALLOCATED(ep)) DEALLOCATE(ep)                   ! ep 
+      IF (ALLOCATED(omeg)) DEALLOCATE(omeg)          	  ! omeg 
+      IF (ALLOCATED(gfactor)) DEALLOCATE(gfactor)         ! g
+!$OMP END MASTER
+!$OMP BARRIER
 
       END DO                    ! Loop on iaer
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/sugas_corrk.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/sugas_corrk.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/sugas_corrk.F90	(revision 227)
@@ -28,5 +28,6 @@
 
       use gases_h
-      use ioipsl_getincom 
+!      use ioipsl_getincom
+      use ioipsl_getincom_p 
       implicit none
 
@@ -45,6 +46,6 @@
 
       ! ALLOCATABLE ARRAYS -- AS 12/2011
-      REAL*8, DIMENSION(:,:,:,:,:), ALLOCATABLE :: gasi8, gasv8
-      character*20,allocatable,DIMENSION(:) :: gastype ! for check with gnom
+      REAL*8, DIMENSION(:,:,:,:,:), ALLOCATABLE,SAVE :: gasi8, gasv8 	!read by master
+      character*20,allocatable,DIMENSION(:),SAVE :: gastype ! for check with gnom, read by master
 
       real*8 x, xi(4), yi(4), ans, p
@@ -76,4 +77,5 @@
       endif
 
+!$OMP MASTER
       ! check that database matches varactive toggle
       open(111,file=TRIM(file_path),form='formatted')
@@ -261,4 +263,6 @@
       tgasmin = tgasref(1)
       tgasmax = tgasref(L_NTREF)
+!$OMP END MASTER
+!$OMP BARRIER
 
 !-----------------------------------------------------------------------
@@ -302,5 +306,5 @@
          write(*,*)"graybody: constant absorption coefficient in visible:"
          kappa_VI=-100000.
-         call getin("kappa_VI",kappa_VI)
+         call getin_p("kappa_VI",kappa_VI)
          write(*,*)" kappa_VI = ",kappa_VI
 	 kappa_VI=kappa_VI*1.e4* mugaz * 1.672621e-27	 ! conversion from m^2/kg to cm^2/molecule         
@@ -309,5 +313,5 @@
          write(*,*)"graybody: constant absorption coefficient in InfraRed:"
          kappa_IR=-100000.
-         call getin("kappa_IR",kappa_IR)
+         call getin_p("kappa_IR",kappa_IR)
          write(*,*)" kappa_IR = ",kappa_IR	 
          kappa_IR=kappa_IR*1.e4* mugaz * 1.672621e-27	 ! conversion from m^2/kg to cm^2/molecule 
@@ -320,4 +324,5 @@
       End if
 
+!$OMP MASTER         
 !      print*,corrkdir(1:4)
       ! VISIBLE
@@ -361,10 +366,15 @@
          gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)=0.0
       endif
+!$OMP END MASTER
+!$OMP BARRIER
 
       ! INFRA-RED
       if ((corrkdir(1:4).eq.'null'))then       !.or.(TRIM(corrkdir).eq.'null_LowTeffStar')) then
          print*,'Infrared corrk gaseous absorption is set to zero if graybody=F'
+!$OMP MASTER         
          gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)=0.0
-      else  
+!$OMP END MASTER
+!$OMP BARRIER
+      else 
          file_id='/corrk_data/'//trim(adjustl(banddir))//'/corrk_gcm_IR.dat' 
          file_path=TRIM(datadir)//TRIM(file_id)
@@ -379,7 +389,10 @@
          endif
          
+!$OMP MASTER          	        
          open(111,file=TRIM(file_path),form='formatted')
          read(111,*) gasi8
          close(111)
+!$OMP END MASTER
+!$OMP BARRIER
      
          ! 'fzero' is a currently unused feature that allows optimisation
@@ -423,4 +436,5 @@
       endif
 
+!$OMP MASTER         	     
       if(nIR_limit.eq.0) then
          gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)=   &
@@ -465,4 +479,6 @@
          end do
       end do
+!$OMP END MASTER
+!$OMP BARRIER
 
 !     Interpolate the values:  first the longwave
@@ -653,8 +669,12 @@
 
 !     Deallocate local arrays
+!$OMP BARRIER
+!$OMP MASTER
       IF( ALLOCATED( gasi8 ) ) DEALLOCATE( gasi8 )
       IF( ALLOCATED( gasv8 ) ) DEALLOCATE( gasv8 )
       IF( ALLOCATED( pgasref ) ) DEALLOCATE( pgasref )
       IF( ALLOCATED( gastype ) ) DEALLOCATE( gastype )
+!$OMP END MASTER
+!$OMP BARRIER
 
       return
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surf_heat_transp_mod.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surf_heat_transp_mod.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surf_heat_transp_mod.F90	(revision 227)
@@ -7,5 +7,5 @@
 CONTAINS
 
-      SUBROUTINE divgrad_phy(nlevs,temp,delta)
+      SUBROUTINE divgrad_phy(ngrid,nlevs,temp,delta)
 
 
@@ -14,5 +14,5 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "paramet.h"
 #include "comcstfi.h"
@@ -20,12 +20,13 @@
 #include "comhdiff.h"
       
-      INTEGER nlevs, ll
-      REAL temp(ngridmx,nlevs)
+      INTEGER,INTENT(IN) :: ngrid, nlevs
+      REAL,INTENT(IN) :: temp(ngrid,nlevs)
+      REAL,INTENT(OUT) :: delta(ngrid,nlevs)
       REAL delta_2d(ip1jmp1,nlevs)
-      REAL delta(ngridmx,nlevs)
+      INTEGER :: ll
       REAL ghx(ip1jmp1,nlevs), ghy(ip1jm,nlevs)
 
 
-      CALL gr_fi_dyn(nlevs,ngridmx,iip1,jjp1,temp,delta_2d)
+      CALL gr_fi_dyn(nlevs,ngrid,iip1,jjp1,temp,delta_2d)
       CALL grad(nlevs,delta_2d,ghx,ghy)
       DO ll=1,nlevs
@@ -36,5 +37,5 @@
       END DO
       CALL diverg(nlevs,ghx,ghy,delta_2d)
-      CALL gr_dyn_fi(nlevs,iip1,jjp1,ngridmx,delta_2d,delta)
+      CALL gr_dyn_fi(nlevs,iip1,jjp1,ngrid,delta_2d,delta)
 
 
@@ -43,10 +44,10 @@
 
 
-      SUBROUTINE init_masquv(zmasq)
+      SUBROUTINE init_masquv(ngrid,zmasq)
      
       IMPLICIT NONE
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "paramet.h"
 #include "comcstfi.h"   
@@ -55,5 +56,6 @@
 
 
-      REAL zmasq(ngridmx)
+      INTEGER,INTENT(IN) :: ngrid
+      REAL zmasq(ngrid)
       REAL zmasq_2d(ip1jmp1)
       REAL ff(ip1jm)
@@ -66,5 +68,5 @@
       zmasqv=1.
 
-      CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,zmasq,zmasq_2d)
+      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,zmasq,zmasq_2d)
 
       DO i=1,ip1jmp1-1
@@ -104,5 +106,5 @@
 
 
-      SUBROUTINE slab_ekman2(tx_phy,ty_phy,ts_phy,dt_phy)
+      SUBROUTINE slab_ekman2(ngrid,tx_phy,ty_phy,ts_phy,dt_phy)
   
           use slab_ice_h 
@@ -111,5 +113,5 @@
       
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "paramet.h"
 #include "comcstfi.h"
@@ -118,4 +120,5 @@
 #include "comhdiff.h"
 
+      INTEGER,INTENT(IN) :: ngrid
       INTEGER ij
       REAL txv(ip1jm),fluxm(ip1jm),tyv(ip1jm)
@@ -123,6 +126,6 @@
       REAL tyu(ip1jmp1),txu(ip1jmp1),fluxz(ip1jmp1),fluxv(ip1jmp1)
       REAL dt(ip1jmp1,noceanmx),ts(ip1jmp1,noceanmx)
-      REAL tx_phy(ngridmx),ty_phy(ngridmx)
-      REAL dt_phy(ngridmx,noceanmx),ts_phy(ngridmx,noceanmx)
+      REAL tx_phy(ngrid),ty_phy(ngrid)
+      REAL dt_phy(ngrid,noceanmx),ts_phy(ngrid,noceanmx)
 
 
@@ -130,6 +133,6 @@
 
 ! Passage taux,y sur grilles 2d
-      CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,tx_phy,txu)
-      CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,ty_phy,tyu)
+      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,tx_phy,txu)
+      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,ty_phy,tyu)
 ! Passage grille u,v
 ! Multiplication par f ou eps.
@@ -144,5 +147,5 @@
             
 ! Calcul de T, Tdeep
-      CALL gr_fi_dyn(2,ngridmx,iip1,jjp1,ts_phy,ts)
+      CALL gr_fi_dyn(2,ngrid,iip1,jjp1,ts_phy,ts)
        
 ! Flux de masse
@@ -222,5 +225,5 @@
 
 ! Retour grille physique
-      CALL gr_dyn_fi(2,iip1,jjp1,ngridmx,dt,dt_phy)
+      CALL gr_dyn_fi(2,iip1,jjp1,ngrid,dt,dt_phy)
 
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surface_nature.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surface_nature.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surface_nature.F	(revision 227)
@@ -33,6 +33,6 @@
 !==================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surfdat_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surfdat_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surfdat_h.F90	(revision 227)
@@ -5,12 +5,16 @@
 
        real,allocatable,dimension(:) :: albedodat ! albedo of bare ground
+!$OMP THREADPRIVATE(albedodat)
        ! Ehouarn: moved inertiedat to comsoil.h
        !      real inertiedat, ! thermal inertia
        real,allocatable,dimension(:) :: phisfi ! geopotential at ground level
+!$OMP THREADPRIVATE(phisfi)
        real,dimension(2) :: albedice
        real,dimension(2) :: emisice ! ice emissivity; 1:Northern hemisphere 2:Southern hemisphere
        real emissiv
        real,dimension(2) :: iceradius, dtemisice
+!$OMP THREADPRIVATE(albedice,emisice,emissiv,iceradius,dtemisice)
        real,allocatable,dimension(:) :: zmea,zstd,zsig,zgam,zthe
+!$OMP THREADPRIVATE(zmea,zstd,zsig,zgam,zthe)
 
        real,allocatable,dimension(:) :: dryness  !"Dryness coefficient" for grnd water ice sublimation
@@ -18,4 +22,5 @@
 
        logical,allocatable,dimension(:) :: watercaptag !! was in watercap.h
+!$OMP THREADPRIVATE(dryness,watercaptag)
 
        end module surfdat_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surfini.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surfini.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/surfini.F	(revision 227)
@@ -15,6 +15,6 @@
 c   Declarations:
 c   -------------
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "callkeys.h"
 c
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/tabfi.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/tabfi.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/tabfi.F	(revision 227)
@@ -34,5 +34,5 @@
 c                              comparer avec le day_ini dynamique)
 c
-c      - lmax:    tab_cntrl(tab0+2) (pour test avec nlayermx)
+c      - lmax:    tab_cntrl(tab0+2) (pour test avec nlayer)
 c
 c      - p_rad
@@ -51,9 +51,11 @@
       use iostart, only: get_var
       use mod_phys_lmdz_para, only: is_parallel
+      use planete_mod, only: year_day, periastr, apoastr, peri_day,
+     &                       obliquit, z0, lmixmin, emin_turb
 
       implicit none
  
 #include "comcstfi.h"
-#include "planete.h"
+!#include "planete.h"
 #include "netcdf.inc"
 #include "callkeys.h"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/totalcloudfrac.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/totalcloudfrac.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/totalcloudfrac.F90	(revision 227)
@@ -1,3 +1,3 @@
-      subroutine totalcloudfrac(ngrid,nq,rneb,totalrneb,pplev,pq,tau)
+      subroutine totalcloudfrac(ngrid,nlayer,nq,rneb,totalrneb,pplev,pq,tau)
 
       use watercommon_h
@@ -19,18 +19,19 @@
 !==================================================================
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
 
       integer,intent(in) :: ngrid        ! number of atmospheric columns
+      integer,intent(in) :: nlayer       ! number of atmospheric layers
       integer,intent(in) :: nq           ! number of tracers
-      real,intent(in) :: rneb(ngrid,nlayermx)    ! cloud fraction     
+      real,intent(in) :: rneb(ngrid,nlayer)    ! cloud fraction     
       real,intent(out) :: totalrneb(ngrid)       ! total cloud fraction 
-      real,intent(in) :: pplev(ngrid,nlayermx+1) ! inter-layer pressure (Pa)
-      real,intent(in) :: pq(ngrid,nlayermx,nq)   ! tracers (.../kg_of_air)
-      real,intent(in) :: tau(ngrid,nlayermx)
+      real,intent(in) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      real,intent(in) :: pq(ngrid,nlayer,nq)   ! tracers (.../kg_of_air)
+      real,intent(in) :: tau(ngrid,nlayer)
 
-      real, dimension(nlayermx+1) :: masse
+      real, dimension(nlayer+1) :: masse
       integer, parameter          :: recovery=7
       integer ltau_max
@@ -47,5 +48,5 @@
       real clear,tau_min
       real, parameter ::  tau_c=0.1 !threshold of optical depth for the calculation of total cloud fraction 
-      real rneb2(nlayermx)
+      real rneb2(nlayer)
 
 
@@ -55,5 +56,5 @@
          if (recovery.eq.1) then
             clear = (1.-rneb(ig,1))
-            do l=2,nlayermx       
+            do l=2,nlayer      
                clear = clear*(1.-rneb(ig,l))
             enddo
@@ -62,5 +63,5 @@
          elseif (recovery.eq.2) then
             totalrneb(ig) = rneb(ig,1)
-            do l=2,14 !nlayermx       
+            do l=2,14 !nlayer    
                totalrneb(ig) = max(rneb(ig,l),totalrneb(ig))
             enddo
@@ -68,5 +69,5 @@
          elseif (recovery.eq.3) then
             totalrneb(ig) = rneb(ig,1)
-            do l=2,nlayermx       
+            do l=2,nlayer    
                totalrneb(ig) = min(rneb(ig,l),totalrneb(ig))
             enddo
@@ -77,5 +78,5 @@
          elseif (recovery.eq.5) then
             totalrneb(ig) = rneb(ig,1)            
-            do l=1,nlayermx
+            do l=1,nlayer
                masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
             enddo
@@ -85,10 +86,10 @@
          elseif (recovery.eq.6) then
             totalrneb(ig) = 0.            
-            do l=1,nlayermx
+            do l=1,nlayer
                masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
                masse(l)=max(masse(l),0.)
             enddo
             massetot=sum(masse,dim=1)
-            do l=1,nlayermx
+            do l=1,nlayer
                totalrneb(ig) = totalrneb(ig)+rneb(ig,l)*masse(l)/massetot
             enddo
@@ -96,10 +97,10 @@
          elseif (recovery.eq.7) then
 
-            rneb2(:)=rneb(ig,1:nlayermx)
-	    tau_min=MIN(tau_c,MAXVAL(tau(ig,1:nlayermx))/2.)
-            do l=1,nlayermx
+            rneb2(:)=rneb(ig,1:nlayer)
+	    tau_min=MIN(tau_c,MAXVAL(tau(ig,1:nlayer))/2.)
+            do l=1,nlayer
                if(tau(ig,l)<tau_min) rneb2(l)=0.      	
             enddo
-            totalrneb(ig)=maxval(rneb2(1:nlayermx))
+            totalrneb(ig)=maxval(rneb2(1:nlayer))
 
          endif                  ! (recovery=)   
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/tracer_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/tracer_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/tracer_h.F90	(revision 227)
@@ -19,4 +19,6 @@
       real rho_co2     ! CO2 ice density (kg.m-3)
       real ref_r0        ! for computing reff=ref_r0*r0 (in log.n. distribution)
+!$OMP THREADPRIVATE(noms,mmol,radius,rho_q,qext,alpha_lift,alpha_devil,qextrhor, &
+	!$OMP varian,r3n_q,rho_dust,rho_ice,rho_co2,ref_r0)
 
 ! tracer indexes: these are initialized in initracer and should be 0 if the
@@ -47,4 +49,7 @@
       integer :: igcm_ar_n2 ! for simulations using co2 +neutral gaz
       integer :: igcm_co2_ice ! CO2 ice 
+!$OMP THREADPRIVATE(igcm_dustbin,igcm_dust_mass,igcm_dust_number,igcm_h2o_vap,igcm_h2o_ice, &
+	!$OMP igcm_co2,igcm_co,igcm_o,igcm_o1d,igcm_o2,igcm_o3,igcm_h,igcm_h2,igcm_oh,	    &
+	!$OMP igcm_ho2,igcm_h2o2,igcm_n2,igcm_ar,igcm_ar_n2,igcm_co2_ice)
 
        end module tracer_h
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/turbdiff.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/turbdiff.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/turbdiff.F90	(revision 227)
@@ -41,6 +41,6 @@
 !     ------------
 
-      include "dimensions.h"
-      include "dimphys.h"
+!      include "dimensions.h"
+!      include "dimphys.h"
       include "comcstfi.h"
       include "callkeys.h"
@@ -48,5 +48,6 @@
 !     arguments
 !     ---------
-      INTEGER,INTENT(IN) :: ngrid,nlay
+      INTEGER,INTENT(IN) :: ngrid
+      INTEGER,INTENT(IN) :: nlay
       REAL,INTENT(IN) :: ptimestep
       REAL,INTENT(IN) :: pplay(ngrid,nlay),pplev(ngrid,nlay+1)
@@ -86,18 +87,18 @@
 
       REAL z4st,zdplanck(ngrid)
-      REAL zkv(ngrid,nlayermx+1),zkh(ngrid,nlayermx+1)
+      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
       REAL zcdv(ngrid),zcdh(ngrid)
       REAL zcdv_true(ngrid),zcdh_true(ngrid)
-      REAL zu(ngrid,nlayermx),zv(ngrid,nlayermx)
-      REAL zh(ngrid,nlayermx),zt(ngrid,nlayermx)
+      REAL zu(ngrid,nlay),zv(ngrid,nlay)
+      REAL zh(ngrid,nlay),zt(ngrid,nlay)
       REAL ztsrf(ngrid)
       REAL z1(ngrid),z2(ngrid)
-      REAL zmass(ngrid,nlayermx)
-      REAL zfluxv(ngrid,nlayermx),zfluxt(ngrid,nlayermx),zfluxq(ngrid,nlayermx)
-      REAL zb0(ngrid,nlayermx)
-      REAL zExner(ngrid,nlayermx),zovExner(ngrid,nlayermx)
-      REAL zcv(ngrid,nlayermx),zdv(ngrid,nlayermx)  !inversion coefficient for winds
-      REAL zct(ngrid,nlayermx),zdt(ngrid,nlayermx)  !inversion coefficient for temperature
-      REAL zcq(ngrid,nlayermx),zdq(ngrid,nlayermx)  !inversion coefficient for tracers
+      REAL zmass(ngrid,nlay)
+      REAL zfluxv(ngrid,nlay),zfluxt(ngrid,nlay),zfluxq(ngrid,nlay)
+      REAL zb0(ngrid,nlay)
+      REAL zExner(ngrid,nlay),zovExner(ngrid,nlay)
+      REAL zcv(ngrid,nlay),zdv(ngrid,nlay)  !inversion coefficient for winds
+      REAL zct(ngrid,nlay),zdt(ngrid,nlay)  !inversion coefficient for temperature
+      REAL zcq(ngrid,nlay),zdq(ngrid,nlay)  !inversion coefficient for tracers
       REAL zcst1
       REAL zu2!, a
@@ -106,11 +107,12 @@
 
       LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
       
 !     Tracers
 !     -------
       INTEGER iq
-      REAL zq(ngrid,nlayermx,nq)
-      REAL zqnoevap(ngrid,nlayermx) !special for water case to compute where evaporated water goes.
-      REAL pdqevap(ngrid,nlayermx) !special for water case to compute where evaporated water goes.
+      REAL zq(ngrid,nlay,nq)
+      REAL zqnoevap(ngrid,nlay) !special for water case to compute where evaporated water goes.
+      REAL pdqevap(ngrid,nlay) !special for water case to compute where evaporated water goes.
       REAL zdmassevap(ngrid)
       REAL rho(ngrid)         ! near-surface air density
@@ -123,4 +125,5 @@
 
       integer, save :: ivap, iliq, iliq_surf,iice_surf ! also make liq for clarity on surface...
+!$OMP THREADPRIVATE(ivap,iliq,iliq_surf,iice_surf)
 
       real, parameter :: karman=0.4
@@ -241,5 +244,5 @@
 !     ------------------------------------------------------ 
 
-      call vdif_kc(ngrid,ptimestep,g,pzlev,pzlay,pu,pv,zh,zcdv_true,pq2,zkv,zkh) !JL12 why not call vdif_kc with updated winds and temperature 
+      call vdif_kc(ngrid,nlay,ptimestep,g,pzlev,pzlay,pu,pv,zh,zcdv_true,pq2,zkv,zkh) !JL12 why not call vdif_kc with updated winds and temperature 
       
 !     Adding eddy mixing to mimic 3D general circulation in 1D
@@ -262,5 +265,5 @@
  
 !JL12 calculate the flux coefficients (tables multiplied elements by elements)
-      zfluxv(1:ngrid,1:nlayermx)=zkv(1:ngrid,1:nlayermx)*zb0(1:ngrid,1:nlayermx)
+      zfluxv(1:ngrid,1:nlay)=zkv(1:ngrid,1:nlay)*zb0(1:ngrid,1:nlay)
       
 !-----------------------------------------------------------------------
@@ -364,6 +367,6 @@
 !     JL12 calculate the flux coefficients (tables multiplied elements by elements)
 !     ---------------------------------------------------------------
-      zfluxq(1:ngrid,1:nlayermx)=zkh(1:ngrid,1:nlayermx)*zb0(1:ngrid,1:nlayermx) !JL12 we save zfluxq which doesn't need the Exner factor
-      zfluxt(1:ngrid,1:nlayermx)=zfluxq(1:ngrid,1:nlayermx)*zExner(1:ngrid,1:nlayermx)
+      zfluxq(1:ngrid,1:nlay)=zkh(1:ngrid,1:nlay)*zb0(1:ngrid,1:nlay) !JL12 we save zfluxq which doesn't need the Exner factor
+      zfluxt(1:ngrid,1:nlay)=zfluxq(1:ngrid,1:nlay)*zExner(1:ngrid,1:nlay)
 
       DO ig=1,ngrid
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdif_cd.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdif_cd.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdif_cd.F	(revision 227)
@@ -55,4 +55,5 @@
       DATA firstcal/.true./
       SAVE b,c,d,karman,c2b,c3bc,c3b,firstcal,umin2
+!$OMP THREADPRIVATE(b,c,d,karman,c2b,c3bc,c3b,firstcal,umin2)
 
 c-----------------------------------------------------------------------
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdif_kc.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdif_kc.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdif_kc.F	(revision 227)
@@ -1,7 +1,7 @@
-      SUBROUTINE vdif_kc(ngrid,dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn)
+      SUBROUTINE vdif_kc(ngrid,nlay,dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn)
       IMPLICIT NONE
 c.......................................................................
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 c.......................................................................
 c
@@ -28,14 +28,15 @@
 c.......................................................................
       INTEGER,INTENT(IN) :: ngrid
+      INTEGER,INTENT(IN) :: nlay
       REAL,INTENT(IN) :: dt,g
-      REAL,INTENT(IN) :: zlev(ngrid,nlayermx+1)
-      REAL,INTENT(IN) :: zlay(ngrid,nlayermx)
-      REAL,INTENT(IN) :: u(ngrid,nlayermx)
-      REAL,INTENT(IN) :: v(ngrid,nlayermx)
-      REAL,INTENT(IN) :: teta(ngrid,nlayermx)
+      REAL,INTENT(IN) :: zlev(ngrid,nlay+1)
+      REAL,INTENT(IN) :: zlay(ngrid,nlay)
+      REAL,INTENT(IN) :: u(ngrid,nlay)
+      REAL,INTENT(IN) :: v(ngrid,nlay)
+      REAL,INTENT(IN) :: teta(ngrid,nlay)
       REAL,INTENT(IN) :: cd(ngrid)
-      REAL,INTENT(INOUT) :: q2(ngrid,nlayermx+1)
-      REAL,INTENT(OUT) :: km(ngrid,nlayermx+1)
-      REAL,INTENT(OUT) :: kn(ngrid,nlayermx+1)
+      REAL,INTENT(INOUT) :: q2(ngrid,nlay+1)
+      REAL,INTENT(OUT) :: km(ngrid,nlay+1)
+      REAL,INTENT(OUT) :: kn(ngrid,nlay+1)
 c.......................................................................
 c
@@ -50,9 +51,8 @@
 c
 c.......................................................................
-      INTEGER,PARAMETER :: nlay=nlayermx
-      INTEGER,PARAMETER :: nlev=nlayermx+1
-      REAL unsdz(ngrid,nlayermx)
-      REAL unsdzdec(ngrid,nlayermx+1)
-      REAL q(ngrid,nlayermx+1)
+      INTEGER :: nlev
+      REAL unsdz(ngrid,nlay)
+      REAL unsdzdec(ngrid,nlay+1)
+      REAL q(ngrid,nlay+1)
 c.......................................................................
 c
@@ -64,5 +64,5 @@
 c
 c.......................................................................
-      REAL kmpre(ngrid,nlayermx+1)
+      REAL kmpre(ngrid,nlay+1)
       REAL qcstat
       REAL q2cstat
@@ -72,5 +72,5 @@
 c
 c.......................................................................
-      REAL long(ngrid,nlayermx+1)
+      REAL long(ngrid,nlay+1)
 c.......................................................................
 c
@@ -95,8 +95,8 @@
       REAL mcstat
       REAL m2cstat
-      REAL m(ngrid,nlayermx+1)
-      REAL mpre(ngrid,nlayermx+1)
-      REAL m2(ngrid,nlayermx+1)
-      REAL n2(ngrid,nlayermx+1)
+      REAL m(ngrid,nlay+1)
+      REAL mpre(ngrid,nlay+1)
+      REAL m2(ngrid,nlay+1)
+      REAL n2(ngrid,nlay+1)
 c.......................................................................
 c
@@ -120,9 +120,9 @@
       LOGICAL gnsup
       REAL gm
-c      REAL ri(ngrid,nlayermx+1)
-      REAL sn(ngrid,nlayermx+1)
-      REAL snq2(ngrid,nlayermx+1)
-      REAL sm(ngrid,nlayermx+1)
-      REAL smq2(ngrid,nlayermx+1)
+c      REAL ri(ngrid,nlaye+1)
+      REAL sn(ngrid,nlay+1)
+      REAL snq2(ngrid,nlay+1)
+      REAL sm(ngrid,nlay+1)
+      REAL smq2(ngrid,nlay+1)
 c.......................................................................
 c
@@ -179,4 +179,5 @@
 
 ! initialization of local variables:
+      nlev=nlay+1
       long(:,:)=0.
       n2(:,:)=0.
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdifc.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdifc.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vdifc.F	(revision 227)
@@ -38,6 +38,6 @@
 !     ------------
 
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -77,17 +77,17 @@
 
       REAL z4st,zdplanck(ngrid)
-      REAL zkv(ngrid,nlayermx+1),zkh(ngrid,nlayermx+1)
+      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
       REAL zcdv(ngrid),zcdh(ngrid)
       REAL zcdv_true(ngrid),zcdh_true(ngrid)
-      REAL zu(ngrid,nlayermx),zv(ngrid,nlayermx)
-      REAL zh(ngrid,nlayermx)
+      REAL zu(ngrid,nlay),zv(ngrid,nlay)
+      REAL zh(ngrid,nlay)
       REAL ztsrf2(ngrid)
       REAL z1(ngrid),z2(ngrid)
-      REAL za(ngrid,nlayermx),zb(ngrid,nlayermx)
-      REAL zb0(ngrid,nlayermx)
-      REAL zc(ngrid,nlayermx),zd(ngrid,nlayermx)
+      REAL za(ngrid,nlay),zb(ngrid,nlay)
+      REAL zb0(ngrid,nlay)
+      REAL zc(ngrid,nlay),zd(ngrid,nlay)
       REAL zcst1
       REAL zu2!, a
-      REAL zcq(ngrid,nlayermx),zdq(ngrid,nlayermx)
+      REAL zcq(ngrid,nlay),zdq(ngrid,nlay)
       REAL evap(ngrid)
       REAL zcq0(ngrid),zdq0(ngrid)
@@ -96,4 +96,5 @@
       LOGICAL firstcall
       SAVE firstcall
+!$OMP THREADPRIVATE(firstcall)
       
       LOGICAL lastcall
@@ -101,8 +102,9 @@
 !     variables added for CO2 condensation
 !     ------------------------------------
-      REAL hh                   !, zhcond(ngrid,nlayermx)
+      REAL hh                   !, zhcond(ngrid,nlay)
 !     REAL latcond,tcond1mb
 !     REAL acond,bcond
 !     SAVE acond,bcond
+!!$OMP THREADPRIVATE(acond,bcond)
 !     DATA latcond,tcond1mb/5.9e5,136.27/
 
@@ -110,5 +112,5 @@
 !     -------
       INTEGER iq
-      REAL zq(ngrid,nlayermx,nq)
+      REAL zq(ngrid,nlay,nq)
       REAL zq1temp(ngrid)
       REAL rho(ngrid)         ! near-surface air density
@@ -123,6 +125,6 @@
       real z1_T(ngrid), z2_T(ngrid)
       real zb_T(ngrid)
-      real zc_T(ngrid,nlayermx)
-      real zd_T(ngrid,nlayermx)
+      real zc_T(ngrid,nlay)
+      real zd_T(ngrid,nlay)
       real lat1(ngrid), lat2(ngrid)
       real surfh2otot
@@ -132,4 +134,5 @@
       integer ivap, iice ! also make liq for clarity on surface...
       save ivap, iice
+!$OMP THREADPRIVATE(ivap,iice)
 
       real, parameter :: karman=0.4
@@ -249,5 +252,5 @@
 !     ------------------------------------------------------ 
 
-      call vdif_kc(ngrid,ptimestep,g,pzlev,pzlay
+      call vdif_kc(ngrid,nlay,ptimestep,g,pzlev,pzlay
      &     ,pu,pv,ph,zcdv_true
      &     ,pq2,zkv,zkh)
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vlz_fi.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vlz_fi.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/vlz_fi.F	(revision 227)
@@ -1,3 +1,3 @@
-      SUBROUTINE vlz_fi(ngrid,q,pente_max,masse,w,wq)
+      SUBROUTINE vlz_fi(ngrid,nlayer,q,pente_max,masse,w,wq)
 c
 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
@@ -16,6 +16,6 @@
       IMPLICIT NONE
 c
-#include "dimensions.h"
-#include "dimphys.h"
+!#include "dimensions.h"
+!#include "dimphys.h"
 
 c
@@ -23,9 +23,9 @@
 c   Arguments:
 c   ----------
-      integer ngrid
-      real masse(ngrid,llm),pente_max
-      REAL q(ngrid,llm)
-      REAL w(ngrid,llm)
-      REAL wq(ngrid,llm+1)
+      integer,intent(in) :: ngrid, nlayer
+      real,intent(in) :: masse(ngrid,nlayer),pente_max
+      REAL,INTENT(INOUT) :: q(ngrid,nlayer)
+      REAL,INTENT(INOUT) :: w(ngrid,nlayer)
+      REAL,INTENT(OUT) :: wq(ngrid,nlayer+1)
 c
 c      Local 
@@ -35,5 +35,6 @@
 c
 
-      real dzq(ngrid,llm),dzqw(ngrid,llm),adzqw(ngrid,llm),dzqmax
+      real dzq(ngrid,nlayer),dzqw(ngrid,nlayer),adzqw(ngrid,nlayer)
+      real dzqmax
       real newmasse
       real sigw, Mtot, MQtot
@@ -47,5 +48,5 @@
 c    sens de W
 
-      do l=2,llm
+      do l=2,nlayer
          do ij=1,ngrid
             dzqw(ij,l)=q(ij,l-1)-q(ij,l)
@@ -54,5 +55,5 @@
       enddo
 
-      do l=2,llm-1
+      do l=2,nlayer-1
          do ij=1,ngrid
 #ifdef CRAY
@@ -73,5 +74,5 @@
       do ij=1,ngrid
          dzq(ij,1)=0.
-         dzq(ij,llm)=0.
+         dzq(ij,nlayer)=0.
       enddo
 c ---------------------------------------------------------------
@@ -83,5 +84,5 @@
 c      No flux at the model top:
        do ij=1,ngrid
-          wq(ij,llm+1)=0.
+          wq(ij,nlayer+1)=0.
        enddo
 
@@ -89,5 +90,5 @@
 c      ===============================
 
-       do l = 1,llm          ! loop different than when w<0
+       do l = 1,nlayer          ! loop different than when w<0
         do ij=1,ngrid
 
@@ -107,13 +108,13 @@
             Mtot = masse(ij,m)
             MQtot = masse(ij,m)*q(ij,m)
-            if(m.ge.llm)goto 88
+            if(m.ge.nlayer)goto 88
             do while(w(ij,l).gt.(Mtot+masse(ij,m+1)))
                 m=m+1
                 Mtot = Mtot + masse(ij,m)
                 MQtot = MQtot + masse(ij,m)*q(ij,m)
-                if(m.ge.llm)goto 88
+                if(m.ge.nlayer)goto 88
             end do
  88         continue
-            if (m.lt.llm) then
+            if (m.lt.nlayer) then
                 sigw=(w(ij,l)-Mtot)/masse(ij,m+1)
                 wq(ij,l)=(MQtot + (w(ij,l)-Mtot)*
@@ -137,5 +138,5 @@
        end do
 
-       do l = 1,llm-1  ! loop different than when w>0
+       do l = 1,nlayer-1  ! loop different than when w>0
         do ij=1,ngrid
          if(w(ij,l+1).le.0)then
@@ -176,5 +177,5 @@
  99    continue
 
-      do l=1,llm
+      do l=1,nlayer
          do ij=1,ngrid
 
@@ -191,5 +192,3 @@
 
 
-
-      return
       end
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/watercommon_h.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/watercommon_h.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/watercommon_h.F90	(revision 227)
@@ -19,4 +19,5 @@
 
       real, save :: epsi, RCPD, RCPV, RV, RVTMP2
+!$OMP THREADPRIVATE(epsi,RCPD,RCPV,RV,RVTMP2)
       
       contains
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagfi.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagfi.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagfi.F	(revision 227)
@@ -68,4 +68,5 @@
 
       real*4,save :: date
+!$OMP THREADPRIVATE(date)
 
       REAL phis(ip1jmp1)
@@ -78,7 +79,9 @@
       integer,save :: zitau=0
       character(len=20),save :: firstnom='1234567890'
+!$OMP THREADPRIVATE(zitau,firstnom)
 
 ! Ajouts
       integer, save :: ntime=0
+!$OMP THREADPRIVATE(ntime)
       integer :: idim,varid
       integer :: nid
@@ -95,4 +98,5 @@
       character(len=120),save :: nom_def(n_nom_def_max)
       logical,save :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall) 	!diagfi_def,n_nom_def,nom_def read in diagfi.def
       
 #ifndef MESOSCALE
@@ -128,4 +132,5 @@
          firstcall=.false.
 
+!$OMP MASTER
   !      Open diagfi.def definition file if there is one:
          open(99,file="diagfi.def",status='old',form='formatted',
@@ -151,4 +156,6 @@
             diagfi_def=.false.
          endif
+!$OMP END MASTER
+!$OMP BARRIER
       END IF ! of IF (firstcall)
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagsoil.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagsoil.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagsoil.F90	(revision 227)
@@ -46,4 +46,5 @@
 character(len=20),save :: firstname="1234567890"
 integer,save :: zitau=0
+!$OMP THREADPRIVATE(date,isample,ntime,firstname,zitau)
 
 character(len=30) :: filename="diagsoil.nc"
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagspecIR.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagspecIR.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagspecIR.F	(revision 227)
@@ -54,5 +54,5 @@
 ! Commons
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "paramet.h"
 !#include "control.h"
@@ -91,7 +91,9 @@
       data firstnom /'1234567890'/
       data zitau /0/
+!$OMP THREADPRIVATE(firstnom,zitau,date)
 
 ! Ajouts
       integer, save :: ntime=0
+!$OMP THREADPRIVATE(ntime)
       integer :: idim,varid
       integer :: nid
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagspecVI.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagspecVI.F	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagspecVI.F	(revision 227)
@@ -54,5 +54,5 @@
 ! Commons
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "paramet.h"
 !#include "control.h"
@@ -91,7 +91,9 @@
       data firstnom /'1234567890'/
       data zitau /0/
+!$OMP THREADPRIVATE(firstnom,zitau,date)
 
 ! Ajouts
       integer, save :: ntime=0
+!$OMP THREADPRIVATE(ntime)
       integer :: idim,varid
       integer :: nid
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/wstats.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/wstats.F90	(revision 224)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/wstats.F90	(revision 227)
@@ -7,5 +7,5 @@
 
 #include "dimensions.h"
-#include "dimphys.h"
+!#include "dimphys.h"
 #include "comconst.h"
 #include "statto.h"
@@ -22,4 +22,5 @@
 character (len=50) :: namebis
 character (len=50), save :: firstvar
+!$OMP THREADPRIVATE(firstvar)
 integer :: ierr,varid,nbdim,nid
 integer :: meanid,sdid
@@ -30,4 +31,5 @@
 
 integer, save :: step=0
+!$OMP THREADPRIVATE(firstcall,indx,step)
 
 ! Added to work in parallel mode
@@ -293,5 +295,5 @@
 
 include "dimensions.h"
-include "dimphys.h"
+!include "dimphys.h"
 include "netcdf.inc"
 
