Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/ener.h
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/ener.h	(revision 1446)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/ener.h	(revision 1447)
@@ -1,14 +1,18 @@
 !
-! $Header$
+! $Id$
 !
-c-----------------------------------------------------------------------
-c INCLUDE 'ener.h'
+!  ATTENTION!!!!: ce fichier include est compatible format fixe/format libre
+!                 veillez à n'utiliser que des ! pour les commentaires
+!                 et à bien positionner les & des lignes de continuation 
+!                 (les placer en colonne 6 et en colonne 73)
+!
+! INCLUDE 'ener.h'
 
-      COMMON/ener/ang0,etot0,ptot0,ztot0,stot0,
-     *            ang,etot,ptot,ztot,stot,rmsdpdt ,
-     *            rmsv,gtot(llmm1)
+      COMMON/ener/ang0,etot0,ptot0,ztot0,stot0,                         &
+     &            ang,etot,ptot,ztot,stot,rmsdpdt ,                     &
+     &            rmsv,gtot(llmm1)
 
-      REAL ang0,etot0,ptot0,ztot0,stot0,
-     s     ang,etot,ptot,ztot,stot,rmsdpdt,rmsv,gtot
+      REAL ang0,etot0,ptot0,ztot0,stot0,                                &
+     &     ang,etot,ptot,ztot,stot,rmsdpdt,rmsv,gtot
 
-c-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/ener.h
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/ener.h	(revision 1446)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/ener.h	(revision 1447)
@@ -1,14 +1,18 @@
 !
-! $Header$
+! $Id$
 !
-c-----------------------------------------------------------------------
-c INCLUDE 'ener.h'
+!  ATTENTION!!!!: ce fichier include est compatible format fixe/format libre
+!                 veillez à n'utiliser que des ! pour les commentaires
+!                 et à bien positionner les & des lignes de continuation 
+!                 (les placer en colonne 6 et en colonne 73)
+!
+! INCLUDE 'ener.h'
 
-      COMMON/ener/ang0,etot0,ptot0,ztot0,stot0,
-     *            ang,etot,ptot,ztot,stot,rmsdpdt ,
-     *            rmsv,gtot(llmm1)
+      COMMON/ener/ang0,etot0,ptot0,ztot0,stot0,                         &
+     &            ang,etot,ptot,ztot,stot,rmsdpdt ,                     &
+     &            rmsv,gtot(llmm1)
 
-      REAL ang0,etot0,ptot0,ztot0,stot0,
-     s     ang,etot,ptot,ztot,stot,rmsdpdt,rmsv,gtot
+      REAL ang0,etot0,ptot0,ztot0,stot0,                                &
+     &     ang,etot,ptot,ztot,stot,rmsdpdt,rmsv,gtot
 
-c-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
Index: DZ5/branches/LMDZ5V1.0-dev/libf/phylmd/initphysto.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/initphysto.F	(revision 1446)
+++ 	(revision )
@@ -1,305 +1,0 @@
-!
-! $Id$
-!
-C
-C
-      subroutine initphysto
-     .  (infile,
-     .  rlon, rlat, tstep,t_ops,t_wrt,nq,fileid)
-       
-       USE dimphy
-       USE mod_phys_lmdz_para
-       USE IOIPSL
-       USE iophy
-       USE control_mod
-
-      implicit none
-
-C
-C   Routine d'initialisation des ecritures des fichiers histoires LMDZ
-C   au format IOIPSL
-C
-C   Appels succesifs des routines: histbeg
-C                                  histhori
-C                                  histver
-C                                  histdef
-C                                  histend
-C
-C   Entree:
-C
-C      infile: nom du fichier histoire a creer
-C      day0,anne0: date de reference
-C      tstep: duree du pas de temps en seconde
-C      t_ops: frequence de l'operation pour IOIPSL
-C      t_wrt: frequence d'ecriture sur le fichier
-C      nq: nombre de traceurs
-C
-C   Sortie:
-C      fileid: ID du fichier netcdf cree
-C      filevid:ID du fichier netcdf pour la grille v
-C
-C   L. Fairhead, LMD, 03/99
-C
-C =====================================================================
-C
-C   Declarations
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
-#include "description.h"
-#include "serre.h"
-#include "indicesol.h"
-cym#include "dimphy.h"
-
-C   Arguments
-      character*(*) infile
-      integer nhoriid, i
-      real tstep, t_ops, t_wrt
-      integer fileid, filevid
-      integer nq,l
-      real nivsigs(llm)
-
-C   Variables locales
-C
-      integer tau0
-      real zjulian
-      character*3 str
-      character*10 ctrac
-      integer iq
-      integer uhoriid, vhoriid, thoriid, zvertiid
-      integer ii,jj
-      integer zan, idayref
-      logical ok_sync
-      REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
-C
-      REAL rlon(klon), rlat(klon)
-
-C  Initialisations
-C
-      pi = 4. * atan (1.)
-      str='q  '
-      ctrac = 'traceur   '
-      ok_sync= .true.
-C
-C  Appel a histbeg: creation du fichier netcdf et initialisations diverses
-C         
-
-      zan = annee_ref
-      idayref = day_ref
-      CALL ymds2ju(zan, 1, idayref, 0.0, zjulian)
-      tau0 = 0
-	
-cym	CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlon,zx_lon)
-cym         DO i = 1, iim
-cym            zx_lon(i,1) = rlon(i+1)
-cym            zx_lon(i,jjm+1) = rlon(i+1)
-cym         ENDDO
-cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlat,zx_lat)
-
-
-      call histbeg_phy(infile,tau0, zjulian, tstep,
-     .                 nhoriid, fileid)
-
-c$OMP MASTER	
-C  Appel a histvert pour la grille verticale
-C
-	DO l=1,llm
-            nivsigs(l)=REAL(l)
-         ENDDO
-
-	write(*,*) 'avant histvert ds initphysto'
-
-      call histvert(fileid, 'sig_s', 'Niveaux sigma',
-     . 'sigma_level',
-     .              llm, nivsigs, zvertiid)
-C
-C  Appels a histdef pour la definition des variables a sauvegarder
-C
-	write(*,*) 'apres histvert ds initphysto'
-
-       CALL histdef(fileid, "phis", "Surface geop. height", "-",
-     .                iim,jj_nb,nhoriid, 1,1,1, -99, 32,
-     .                "once", t_ops, t_wrt)
-c
-	write(*,*) 'apres phis ds initphysto'
-
-         CALL histdef(fileid, "aire", "Grid area", "-",
-     .                iim,jj_nb,nhoriid, 1,1,1, -99, 32,
-     .                "once", t_ops, t_wrt)
-         write(*,*) 'apres aire ds initphysto'
-
-cym     Attention dtime et istphy ne sont pas �rit ---> a �iminer ?
-         CALL histdef(fileid, "dtime", "tps phys ", "s",
-     .                1,1,nhoriid, 1,1,1, -99, 32,
-     .                "once", t_ops, t_wrt)
-	
-	 CALL histdef(fileid, "istphy", "tps stock", "s",
-     .                1,1,nhoriid, 1,1,1, -99, 32,
-     .                "once", t_ops, t_wrt)
-
-C T 
-C
-      call histdef(fileid, 't', 'Temperature', 'K',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-        write(*,*) 'apres t ds initphysto'
-C mfu 
-C
-      call histdef(fileid, 'mfu', 'flx m. pan. mt', 'kg m/s',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-        write(*,*) 'apres mfu ds initphysto'
-C
-C mfd 
-C
-      call histdef(fileid, 'mfd', 'flx m. pan. des', 'kg m/s',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-
-C
-C en_u 
-C
-      call histdef(fileid, 'en_u', 'flx ent pan mt', 'kg m/s',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-               write(*,*) 'apres en_u ds initphysto'
-C
-C de_u 
-C
-      call histdef(fileid, 'de_u', 'flx det pan mt', 'kg m/s',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-
-C
-C en_d 
-C
-      call histdef(fileid, 'en_d', 'flx ent pan dt', 'kg m/s',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-C
-
-C
-C de_d 
-C
-      call histdef(fileid, 'de_d', 'flx det pan dt', 'kg m/s',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-
-c coefh frac_impa,frac_nucl
-	
-	call histdef(fileid, "coefh", " ", " ",
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, "inst(X)", t_ops, t_wrt)
-
-c abderrahmane le 16 09 02
-        call histdef(fileid, "fm_th", " ", " ",
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, "inst(X)", t_ops, t_wrt)
-
-        call histdef(fileid, "en_th", " ", " ",
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, "inst(X)", t_ops, t_wrt)
-c fin aj
-	
-	write(*,*) 'apres coefh ds initphysto'	
-
-	call histdef(fileid, 'frac_impa', ' ', ' ',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-	
-	call histdef(fileid, 'frac_nucl', ' ', ' ',
-     .             iim, jj_nb, nhoriid, llm, 1, llm, zvertiid,
-     .             32, 'inst(X)', t_ops, t_wrt)
-
-c
-c pyu1
-c
-      CALL histdef(fileid, "pyu1", " ", " ",
-     .                iim,jj_nb,nhoriid, 1,1,1, -99, 32,
-     .                "inst(X)", t_ops, t_wrt)
-
-c
-c pyv1
-c
-	CALL histdef(fileid, "pyv1", " ", " ",
-     .                iim,jj_nb,nhoriid, 1,1,1, -99, 32,
-     .                "inst(X)", t_ops, t_wrt)
-	
-	write(*,*) 'apres pyv1 ds initphysto'
-c
-c ftsol1
-c
-	call histdef(fileid, "ftsol1", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1,1, -99,32,
-     .             "inst(X)", t_ops, t_wrt)
-
-c
-c ftsol2
-c
-        call histdef(fileid, "ftsol2", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1,1, -99,32,
-     .             "inst(X)", t_ops, t_wrt)
-
-c
-c ftsol3
-c
-        call histdef(fileid, "ftsol3", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1,1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-
-c
-c ftsol4
-c
-        call histdef(fileid, "ftsol4", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1,1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-	
-c
-c rain
-c
-        call histdef(fileid, "rain", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1,1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-
-c
-c psrf1
-c
-	call histdef(fileid, "psrf1", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1, 1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-	
-c
-c psrf2
-c
-        call histdef(fileid, "psrf2", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1, 1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-
-c
-c psrf3
-c
-        call histdef(fileid, "psrf3", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1, 1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-
-c
-c psrf4
-c
-        call histdef(fileid, "psrf4", " ", " ",
-     .             iim, jj_nb, nhoriid, 1, 1, 1, -99,
-     .             32, "inst(X)", t_ops, t_wrt)
-	
-	write(*,*) 'avant histend ds initphysto'	
-
-      call histend(fileid)
-c     if (ok_sync) call histsync(fileid)
-      if (ok_sync) call histsync
-c$OMP END MASTER
-	
-
-      return
-      end
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/initphysto.F90
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/initphysto.F90	(revision 1447)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/initphysto.F90	(revision 1447)
@@ -0,0 +1,216 @@
+!
+! $Id$
+!
+SUBROUTINE initphysto(infile,tstep,t_ops,t_wrt,fileid)
+  
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE IOIPSL
+  USE iophy
+  USE control_mod
+  
+  IMPLICIT NONE
+
+!
+!   Routine d'initialisation des ecritures des fichiers histoires LMDZ
+!   au format IOIPSL
+!
+!   Appels succesifs des routines: histbeg
+!                                  histhori
+!                                  histver
+!                                  histdef
+!                                  histend
+!
+!   Entree:
+!
+!      infile: nom du fichier histoire a creer
+!      day0,anne0: date de reference
+!      tstep: duree du pas de temps en seconde
+!      t_ops: frequence de l'operation pour IOIPSL
+!      t_wrt: frequence d'ecriture sur le fichier
+!
+!   Sortie:
+!      fileid: ID du fichier netcdf cree
+!
+!   L. Fairhead, LMD, 03/99
+!
+! =====================================================================
+!
+!   Declarations
+  INCLUDE "dimensions.h"
+  INCLUDE "paramet.h"
+  INCLUDE "comconst.h"
+  INCLUDE "comgeom.h"
+  INCLUDE "temps.h"
+  INCLUDE "logic.h"
+  INCLUDE "description.h"
+  INCLUDE "serre.h"
+  INCLUDE "indicesol.h"
+
+!   Arguments
+  CHARACTER(len=*), INTENT(IN) :: infile
+  REAL, INTENT(IN)             :: tstep
+  REAL, INTENT(IN)             :: t_ops
+  REAL, INTENT(IN)             :: t_wrt
+  INTEGER, INTENT(OUT)         :: fileid
+
+! Variables locales
+  INTEGER nhoriid, i
+  INTEGER l,k
+  REAL nivsigs(llm)
+  INTEGER tau0
+  REAL zjulian
+  INTEGER iq
+  INTEGER uhoriid, vhoriid, thoriid, zvertiid
+  INTEGER ii,jj
+  INTEGER zan, idayref
+  LOGICAL ok_sync
+  REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
+  CHARACTER(len=12) :: nvar
+
+!  Initialisations
+!
+  pi = 4. * ATAN (1.)
+  ok_sync= .TRUE.
+!
+!  Appel a histbeg: creation du fichier netcdf et initialisations diverses
+!         
+
+  zan = annee_ref
+  idayref = day_ref
+  CALL ymds2ju(zan, 1, idayref, 0.0, zjulian)
+  tau0 = 0
+  
+  CALL histbeg_phy(infile,tau0, zjulian, tstep, &
+       nhoriid, fileid)
+
+!$OMP MASTER	
+!  Appel a histvert pour la grille verticale
+!
+  DO l=1,llm
+     nivsigs(l)=REAL(l)
+  ENDDO
+  
+  CALL histvert(fileid, 'sig_s', 'Niveaux sigma', &
+       'sigma_level', &
+       llm, nivsigs, zvertiid)
+!
+!  Appels a histdef pour la definition des variables a sauvegarder
+!
+  CALL histdef(fileid, "phis", "Surface geop. height", "-", &
+       iim,jj_nb,nhoriid, 1,1,1, -99, 32, &
+       "once", t_ops, t_wrt)
+  
+  CALL histdef(fileid, "aire", "Grid area", "-", &
+       iim,jj_nb,nhoriid, 1,1,1, -99, 32, &
+       "once", t_ops, t_wrt)
+
+  CALL histdef(fileid, "longitudes", "longitudes", "-", &
+       iim,jj_nb,nhoriid, 1,1,1, -99, 32, &
+       "once", t_ops, t_wrt)
+
+  CALL histdef(fileid, "latitudes", "latitudes", "-", &
+       iim,jj_nb,nhoriid, 1,1,1, -99, 32, &
+       "once", t_ops, t_wrt)
+! T 
+  CALL histdef(fileid, 't', 'Temperature', 'K', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! mfu 
+  CALL histdef(fileid, 'mfu', 'flx m. pan. mt', 'kg m/s',iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, 'inst(X)', t_ops, t_wrt)
+! mfd 
+  CALL histdef(fileid, 'mfd', 'flx m. pan. des', 'kg m/s',iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! en_u 
+  CALL histdef(fileid, 'en_u', 'flx ent pan mt', 'kg m/s', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, 'inst(X)', t_ops, t_wrt)
+! de_u 
+  CALL histdef(fileid, 'de_u', 'flx det pan mt', 'kg m/s',iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, 'inst(X)', t_ops, t_wrt)
+! en_d 
+  CALL histdef(fileid, 'en_d', 'flx ent pan dt', 'kg m/s', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, 'inst(X)', t_ops, t_wrt)
+! de_d 
+  CALL histdef(fileid, 'de_d', 'flx det pan dt', 'kg m/s', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! coefh
+  CALL histdef(fileid, "coefh", " ", " ", iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, "inst(X)", t_ops, t_wrt)
+! fm_th
+  CALL histdef(fileid, "fm_th", " ", " ",iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, "inst(X)", t_ops, t_wrt)
+! en_th
+  CALL histdef(fileid, "en_th", " ", " ",iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, "inst(X)", t_ops, t_wrt)
+! frac_impa
+  CALL histdef(fileid, 'frac_impa', ' ', ' ',iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, 'inst(X)', t_ops, t_wrt)
+! frac_nucl
+  CALL histdef(fileid, 'frac_nucl', ' ', ' ',iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid,32, 'inst(X)', t_ops, t_wrt)
+! pyu1
+  CALL histdef(fileid, "pyu1", " ", " ", iim,jj_nb,nhoriid, &
+       1,1,1, -99, 32, "inst(X)", t_ops, t_wrt)
+! pyv1
+  CALL histdef(fileid, "pyv1", " ", " ", iim,jj_nb,nhoriid, &
+       1,1,1, -99, 32,"inst(X)", t_ops, t_wrt)    
+! ftsol1
+  CALL histdef(fileid, "ftsol1", " ", " ",iim, jj_nb, nhoriid, &
+       1, 1,1, -99,32, "inst(X)", t_ops, t_wrt)
+! ftsol2
+  CALL histdef(fileid, "ftsol2", " ", " ",iim, jj_nb, nhoriid, &
+       1, 1,1, -99,32, "inst(X)", t_ops, t_wrt)
+! ftsol3
+  CALL histdef(fileid, "ftsol3", " ", " ", iim, jj_nb, nhoriid, &
+       1, 1,1, -99,32, "inst(X)", t_ops, t_wrt)
+! ftsol4
+  CALL histdef(fileid, "ftsol4", " ", " ",iim, jj_nb, nhoriid, &
+       1, 1,1, -99, 32, "inst(X)", t_ops, t_wrt)
+! psrf1
+  CALL histdef(fileid, "psrf1", " ", " ",iim, jj_nb, nhoriid, &
+       1, 1, 1, -99,32, "inst(X)", t_ops, t_wrt)
+! psrf2
+  CALL histdef(fileid, "psrf2", " ", " ",iim, jj_nb, nhoriid, &
+       1, 1, 1, -99, 32, "inst(X)", t_ops, t_wrt)
+! psrf3
+  CALL histdef(fileid, "psrf3", " ", " ",iim, jj_nb, nhoriid, &
+       1, 1, 1, -99, 32, "inst(X)", t_ops, t_wrt)
+! psrf4
+  CALL histdef(fileid, "psrf4", " ", " ", iim, jj_nb, nhoriid, &
+       1, 1, 1, -99,32, "inst(X)", t_ops, t_wrt)
+! sh
+  CALL histdef(fileid, 'sh', '', '', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! da
+  CALL histdef(fileid, 'da', '', '', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! mp
+  CALL histdef(fileid, 'mp', '', '', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! upwd
+  CALL histdef(fileid, 'upwd', '', '', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+! dnwd
+  CALL histdef(fileid, 'dnwd', '', '', iim, jj_nb, nhoriid, &
+       llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+
+! phi
+  DO k=1,llm
+     IF (k<10) THEN
+        WRITE(nvar,'(i1)') k
+     ELSE IF (k<100) THEN
+        WRITE(nvar,'(i2)') k
+     ELSE
+        WRITE(nvar,'(i3)') k
+     END IF
+     nvar='phi_lev'//trim(nvar)
+     
+     CALL histdef(fileid, nvar, '', '', iim, jj_nb, nhoriid, &
+          llm, 1, llm, zvertiid, 32, 'inst(X)', t_ops, t_wrt)
+  END DO
+
+  CALL histend(fileid)
+  IF (ok_sync) CALL histsync
+!$OMP END MASTER
+	
+END SUBROUTINE initphysto
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phyetat0.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phyetat0.F	(revision 1446)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phyetat0.F	(revision 1447)
@@ -134,37 +134,12 @@
 
        
-
-         IF( clesphy0(1).NE.tab_cntrl( 5 ) )  THEN
-             clesphy0(1)=tab_cntrl( 5 )
-         ENDIF
-
-         IF( clesphy0(2).NE.tab_cntrl( 6 ) )  THEN
-             clesphy0(2)=tab_cntrl( 6 )
-         ENDIF
-
-         IF( clesphy0(3).NE.tab_cntrl( 7 ) )  THEN
-             clesphy0(3)=tab_cntrl( 7 )
-         ENDIF
-
-         IF( clesphy0(4).NE.tab_cntrl( 8 ) )  THEN
-             clesphy0(4)=tab_cntrl( 8 )
-         ENDIF
-
-         IF( clesphy0(5).NE.tab_cntrl( 9 ) )  THEN
-             clesphy0(5)=tab_cntrl( 9 )
-         ENDIF
-
-         IF( clesphy0(6).NE.tab_cntrl( 10 ) )  THEN
-             clesphy0(6)=tab_cntrl( 10 )
-         ENDIF
-
-         IF( clesphy0(7).NE.tab_cntrl( 11 ) )  THEN
-             clesphy0(7)=tab_cntrl( 11 )
-         ENDIF
-
-         IF( clesphy0(8).NE.tab_cntrl( 12 ) )  THEN
-             clesphy0(8)=tab_cntrl( 12 )
-         ENDIF
-
+      clesphy0(1)=tab_cntrl( 5 )
+      clesphy0(2)=tab_cntrl( 6 )
+      clesphy0(3)=tab_cntrl( 7 )
+      clesphy0(4)=tab_cntrl( 8 )
+      clesphy0(5)=tab_cntrl( 9 )
+      clesphy0(6)=tab_cntrl( 10 )
+      clesphy0(7)=tab_cntrl( 11 )
+      clesphy0(8)=tab_cntrl( 12 )
 
 c
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/physiq.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/physiq.F	(revision 1446)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/physiq.F	(revision 1447)
@@ -3376,5 +3376,6 @@
      I                   cdragh,coefh,u1,v1,ftsol,pctsrf,
      I                   frac_impa, frac_nucl,
-     I                   pphis,airephy,dtime,itap)
+     I                   pphis,airephy,dtime,itap,
+     I                   rlon,rlat,qx(:,:,ivap),da,phi,mp,upwd,dnwd)
 
 
Index: DZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phystokenc.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phystokenc.F	(revision 1446)
+++ 	(revision )
@@ -1,435 +1,0 @@
-!
-c
-c
-      SUBROUTINE phystokenc (
-     I                   nlon,nlev,pdtphys,rlon,rlat,
-     I                   pt,pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
-     I                   pfm_therm,pentr_therm,
-     I                   cdragh, pcoefh,yu1,yv1,ftsol,pctsrf,
-     I                   frac_impa,frac_nucl,
-     I                   pphis,paire,dtime,itap)
-      USE ioipsl
-      USE dimphy
-      USE infotrac, ONLY : nqtot
-      USE iophy
-      USE control_mod
-
-      IMPLICIT none
-
-c======================================================================
-c Auteur(s) FH
-c Objet: Moniteur general des tendances traceurs
-c
-
-c======================================================================
-#include "dimensions.h"
-#include "tracstoke.h"
-#include "indicesol.h"
-c======================================================================
-
-c Arguments:
-c
-c   EN ENTREE:
-c   ==========
-c
-c   divers:
-c   -------
-c
-      integer nlon ! nombre de points horizontaux
-      integer nlev ! nombre de couches verticales
-      real pdtphys ! pas d'integration pour la physique (seconde)
-c
-      integer physid, itap
-      save physid
-c$OMP THREADPRIVATE(physid)
-      integer ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
-
-c   convection:
-c   -----------
-c
-      REAL pmfu(klon,klev)  ! flux de masse dans le panache montant
-      REAL pmfd(klon,klev)  ! flux de masse dans le panache descendant
-      REAL pen_u(klon,klev) ! flux entraine dans le panache montant
-      REAL pde_u(klon,klev) ! flux detraine dans le panache montant
-      REAL pen_d(klon,klev) ! flux entraine dans le panache descendant
-      REAL pde_d(klon,klev) ! flux detraine dans le panache descendant
-      real pt(klon,klev)
-      REAL,allocatable,save :: t(:,:)
-c$OMP THREADPRIVATE(t)
-c
-      REAL rlon(klon), rlat(klon), dtime
-      REAL zx_tmp_3d(iim,jjm+1,klev),zx_tmp_2d(iim,jjm+1)
-
-c   Couche limite:
-c   --------------
-c
-      REAL cdragh(klon)          ! cdrag
-      REAL pcoefh(klon,klev)     ! coeff melange CL
-      REAL pcoefh_buf(klon,klev) ! coeff melange CL + cdrag
-      REAL yv1(klon)
-      REAL yu1(klon),pphis(klon),paire(klon)
-
-c   Les Thermiques : (Abderr 25 11 02)
-c   ---------------
-      REAL pfm_therm(klon,klev+1)
-      real fm_therm1(klon,klev)
-      REAL pentr_therm(klon,klev)
-    
-      REAL,allocatable,save :: entr_therm(:,:)
-      REAL,allocatable,save :: fm_therm(:,:)
-c$OMP THREADPRIVATE(entr_therm)
-c$OMP THREADPRIVATE(fm_therm)
-c
-c   Lessivage:
-c   ----------
-c
-      REAL frac_impa(klon,klev)
-      REAL frac_nucl(klon,klev)
-c
-c Arguments necessaires pour les sources et puits de traceur
-C
-      real ftsol(klon,nbsrf)  ! Temperature du sol (surf)(Kelvin)
-      real pctsrf(klon,nbsrf) ! Pourcentage de sol f(nature du sol)
-c======================================================================
-c
-      INTEGER i, k
-c
-      REAL,allocatable,save :: mfu(:,:)  ! flux de masse dans le panache montant
-      REAL,allocatable,save :: mfd(:,:)  ! flux de masse dans le panache descendant
-      REAL,allocatable,save :: en_u(:,:) ! flux entraine dans le panache montant
-      REAL,allocatable,save :: de_u(:,:) ! flux detraine dans le panache montant
-      REAL,allocatable,save :: en_d(:,:) ! flux entraine dans le panache descendant
-      REAL,allocatable,save :: de_d(:,:) ! flux detraine dans le panache descendant
-      REAL,allocatable,save :: coefh(:,:) ! flux detraine dans le panache descendant
-
-      REAL,allocatable,save :: pyu1(:)
-      REAL,allocatable,save :: pyv1(:)
-      REAL,allocatable,save :: pftsol(:,:)
-      REAL,allocatable,save :: ppsrf(:,:)
-c$OMP THREADPRIVATE(mfu,mfd,en_u,de_u,en_d,de_d,coefh)
-c$OMP THREADPRIVATE(pyu1,pyv1,pftsol,ppsrf)
-      real pftsol1(klon),pftsol2(klon),pftsol3(klon),pftsol4(klon)
-      real ppsrf1(klon),ppsrf2(klon),ppsrf3(klon),ppsrf4(klon)
-
-      REAL dtcum
-
-      integer iadvtr,irec
-      real zmin,zmax
-      logical ok_sync
- 
-      save dtcum
-      save iadvtr,irec
-c$OMP THREADPRIVATE(dtcum,iadvtr,irec)
-      data iadvtr,irec/0,1/
-      logical,save :: first=.true.
-c$OMP THREADPRIVATE(first)
-c
-c   Couche limite:
-c======================================================================
-
-c Dans le meme vecteur on recombine le drag et les coeff d'echange
-      pcoefh_buf(:,1)      = cdragh(:)
-      pcoefh_buf(:,2:klev) = pcoefh(:,2:klev)
-
-      ok_sync = .true.
-	print*,'Dans phystokenc.F'
-      print*,'iadvtr= ',iadvtr
-      print*,'istphy= ',istphy
-      print*,'istdyn= ',istdyn
-
-      if (first) then
-      
-        allocate( t(klon,klev))
-        allocate( mfu(klon,klev))  
-        allocate( mfd(klon,klev))  
-        allocate( en_u(klon,klev)) 
-        allocate( de_u(klon,klev)) 
-        allocate( en_d(klon,klev)) 
-        allocate( de_d(klon,klev)) 
-        allocate( coefh(klon,klev)) 
-        allocate( entr_therm(klon,klev))
-        allocate( fm_therm(klon,klev))
-        allocate( pyu1(klon))
-        allocate( pyv1(klon))
-        allocate( pftsol(klon,nbsrf))
-        allocate( ppsrf(klon,nbsrf))
-  
-        first=.false.
-      endif
-      
-      IF (iadvtr.eq.0) THEN
-	
-	CALL initphysto('phystoke',
-     . rlon,rlat,dtime, dtime*istphy,dtime*istphy,nqtot,physid)
-  	
-	write(*,*) 'apres initphysto ds phystokenc' 
-
-	
-      ENDIF
-c
-      ndex2d = 0
-      ndex3d = 0
-      i=itap 
-cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
-      CALL histwrite_phy(physid,"phis",i,pphis)
-c
-      i=itap
-cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
-      CALL histwrite_phy(physid,"aire",i,paire)
-
-      iadvtr=iadvtr+1
-c
-      if (mod(iadvtr,istphy).eq.1.or.istphy.eq.1) then
-	print*,'reinitialisation des champs cumules 
-     s          a iadvtr=',iadvtr
-         do k=1,klev
-            do i=1,klon
-               mfu(i,k)=0.
-               mfd(i,k)=0.
-               en_u(i,k)=0.
-               de_u(i,k)=0.
-               en_d(i,k)=0.
-               de_d(i,k)=0.
-               coefh(i,k)=0.
-                t(i,k)=0.
-		fm_therm(i,k)=0.
-               entr_therm(i,k)=0.
-            enddo
-         enddo
-         do i=1,klon
-            pyv1(i)=0.
-            pyu1(i)=0.
-         end do
-         do k=1,nbsrf
-             do i=1,klon
-               pftsol(i,k)=0.
-               ppsrf(i,k)=0.
-            enddo
-         enddo
-
-         dtcum=0.
-      endif
-
-      do k=1,klev
-         do i=1,klon
-            mfu(i,k)=mfu(i,k)+pmfu(i,k)*pdtphys
-            mfd(i,k)=mfd(i,k)+pmfd(i,k)*pdtphys
-            en_u(i,k)=en_u(i,k)+pen_u(i,k)*pdtphys
-            de_u(i,k)=de_u(i,k)+pde_u(i,k)*pdtphys
-            en_d(i,k)=en_d(i,k)+pen_d(i,k)*pdtphys
-            de_d(i,k)=de_d(i,k)+pde_d(i,k)*pdtphys
-            coefh(i,k)=coefh(i,k)+pcoefh_buf(i,k)*pdtphys
-                t(i,k)=t(i,k)+pt(i,k)*pdtphys
-       fm_therm(i,k)=fm_therm(i,k)+pfm_therm(i,k)*pdtphys
-       entr_therm(i,k)=entr_therm(i,k)+pentr_therm(i,k)*pdtphys
-         enddo
-      enddo
-         do i=1,klon
-            pyv1(i)=pyv1(i)+yv1(i)*pdtphys
-            pyu1(i)=pyu1(i)+yu1(i)*pdtphys
-         end do
-         do k=1,nbsrf
-             do i=1,klon
-               pftsol(i,k)=pftsol(i,k)+ftsol(i,k)*pdtphys
-               ppsrf(i,k)=ppsrf(i,k)+pctsrf(i,k)*pdtphys
-            enddo
-         enddo
-
-      dtcum=dtcum+pdtphys
-
-      IF(mod(iadvtr,istphy).eq.0) THEN 
-c
-c   normalisation par le temps cumule
-         do k=1,klev
-            do i=1,klon
-               mfu(i,k)=mfu(i,k)/dtcum
-               mfd(i,k)=mfd(i,k)/dtcum
-               en_u(i,k)=en_u(i,k)/dtcum
-               de_u(i,k)=de_u(i,k)/dtcum
-               en_d(i,k)=en_d(i,k)/dtcum
-               de_d(i,k)=de_d(i,k)/dtcum
-               coefh(i,k)=coefh(i,k)/dtcum
-c Unitel a enlever
-	      t(i,k)=t(i,k)/dtcum	
-               fm_therm(i,k)=fm_therm(i,k)/dtcum
-	       entr_therm(i,k)=entr_therm(i,k)/dtcum
-            enddo
-         enddo
-         do i=1,klon
-            pyv1(i)=pyv1(i)/dtcum
-            pyu1(i)=pyu1(i)/dtcum
-         end do
-         do k=1,nbsrf
-             do i=1,klon
-               pftsol(i,k)=pftsol(i,k)/dtcum
-               pftsol1(i) = pftsol(i,1)
-               pftsol2(i) = pftsol(i,2)
-               pftsol3(i) = pftsol(i,3)
-               pftsol4(i) = pftsol(i,4)
-
-               ppsrf(i,k)=ppsrf(i,k)/dtcum
-               ppsrf1(i) = ppsrf(i,1)
-               ppsrf2(i) = ppsrf(i,2)
-               ppsrf3(i) = ppsrf(i,3)
-               ppsrf4(i) = ppsrf(i,4)
-
-            enddo
-         enddo
-c
-c   ecriture des champs
-c
-         irec=irec+1
-
-ccccc
-cym         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, t, zx_tmp_3d)
-         CALL histwrite_phy(physid,"t",itap,t)
-
-cym         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfu, zx_tmp_3d)
-      CALL histwrite_phy(physid,"mfu",itap,mfu)
-cym	CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfd, zx_tmp_3d)
-      CALL histwrite_phy(physid,"mfd",itap,mfd)
-cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_u, zx_tmp_3d)
-      CALL histwrite_phy(physid,"en_u",itap,en_u)
-cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_u, zx_tmp_3d)
-      CALL histwrite_phy(physid,"de_u",itap,de_u)
-cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_d, zx_tmp_3d)
-      CALL histwrite_phy(physid,"en_d",itap,en_d)
-cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_d, zx_tmp_3d)       
-      CALL histwrite_phy(physid,"de_d",itap,de_d)
-cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, coefh, zx_tmp_3d)         
-      CALL histwrite_phy(physid,"coefh",itap,coefh)	
-
-c ajou...
-	do k=1,klev
-           do i=1,klon
-	 fm_therm1(i,k)=fm_therm(i,k)	
-	   enddo
-	enddo
-
-cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, fm_therm1, zx_tmp_3d)
-      CALL histwrite_phy(physid,"fm_th",itap,fm_therm1)
-c
-cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, entr_therm, zx_tmp_3d)
-      CALL histwrite_phy(physid,"en_th",itap,entr_therm)
-cccc
-cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_impa,zx_tmp_3d)
-        CALL histwrite_phy(physid,"frac_impa",itap,frac_impa)
-
-cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_nucl,zx_tmp_3d)
-        CALL histwrite_phy(physid,"frac_nucl",itap,frac_nucl)
- 
-cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyu1,zx_tmp_2d)
-      CALL histwrite_phy(physid,"pyu1",itap,pyu1)
-	
-cym	CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyv1,zx_tmp_2d)
-      CALL histwrite_phy(physid,"pyv1",itap,pyv1)
-	
-cym	CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol1, zx_tmp_2d)
-      CALL histwrite_phy(physid,"ftsol1",itap,pftsol1)
-cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol2, zx_tmp_2d)
-      CALL histwrite_phy(physid,"ftsol2",itap,pftsol2)
-cym          CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol3, zx_tmp_2d)
-      CALL histwrite_phy(physid,"ftsol3",itap,pftsol3)
-cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol4, zx_tmp_2d)
-      CALL histwrite_phy(physid,"ftsol4",itap,pftsol4)
-
-cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf1, zx_tmp_2d)
-      CALL histwrite_phy(physid,"psrf1",itap,ppsrf1)
-cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf2, zx_tmp_2d)
-      CALL histwrite_phy(physid,"psrf2",itap,ppsrf2)
-cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf3, zx_tmp_2d)
-      CALL histwrite_phy(physid,"psrf3",itap,ppsrf3)
-cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf4, zx_tmp_2d)
-      CALL histwrite_phy(physid,"psrf4",itap,ppsrf4)
-
-c$OMP MASTER
-      if (ok_sync) call histsync(physid)
-c$OMP END MASTER
-c     if (ok_sync) call histsync
-	
-c
-cAA Test sur la valeur des coefficients de lessivage 
-c
-         zmin=1e33
-         zmax=-1e33
-         do k=1,klev
-            do i=1,klon
-                  zmax=max(zmax,frac_nucl(i,k))
-                  zmin=min(zmin,frac_nucl(i,k))
-            enddo
-         enddo
-         Print*,'------ coefs de lessivage (min et max) --------'
-         Print*,'facteur de nucleation ',zmin,zmax
-         zmin=1e33
-         zmax=-1e33
-         do k=1,klev
-            do i=1,klon
-                  zmax=max(zmax,frac_impa(i,k))
-                  zmin=min(zmin,frac_impa(i,k))
-            enddo
-         enddo
-         Print*,'facteur d impaction ',zmin,zmax
-
-      ENDIF 
-
-c   reinitialisation des champs cumules
-	go to 768
-      if (mod(iadvtr,istphy).eq.1) then
-         do k=1,klev
-            do i=1,klon
-               mfu(i,k)=0.
-               mfd(i,k)=0.
-               en_u(i,k)=0.
-               de_u(i,k)=0.
-               en_d(i,k)=0.
-               de_d(i,k)=0.
-               coefh(i,k)=0.
-	       t(i,k)=0.
-               fm_therm(i,k)=0.
-	       entr_therm(i,k)=0.
-            enddo
-         enddo
-         do i=1,klon
-            pyv1(i)=0.
-            pyu1(i)=0.
-         end do
-         do k=1,nbsrf
-             do i=1,klon
-               pftsol(i,k)=0.
-               ppsrf(i,k)=0.
-            enddo
-         enddo
-
-         dtcum=0.
-      endif
-
-      do k=1,klev
-         do i=1,klon
-            mfu(i,k)=mfu(i,k)+pmfu(i,k)*pdtphys
-            mfd(i,k)=mfd(i,k)+pmfd(i,k)*pdtphys
-            en_u(i,k)=en_u(i,k)+pen_u(i,k)*pdtphys
-            de_u(i,k)=de_u(i,k)+pde_u(i,k)*pdtphys
-            en_d(i,k)=en_d(i,k)+pen_d(i,k)*pdtphys
-            de_d(i,k)=de_d(i,k)+pde_d(i,k)*pdtphys
-            coefh(i,k)=coefh(i,k)+pcoefh_buf(i,k)*pdtphys
-		t(i,k)=t(i,k)+pt(i,k)*pdtphys
-       fm_therm(i,k)=fm_therm(i,k)+pfm_therm(i,k)*pdtphys
-       entr_therm(i,k)=entr_therm(i,k)+pentr_therm(i,k)*pdtphys
-         enddo
-      enddo
-         do i=1,klon
-            pyv1(i)=pyv1(i)+yv1(i)*pdtphys
-            pyu1(i)=pyu1(i)+yu1(i)*pdtphys
-         end do
-         do k=1,nbsrf
-             do i=1,klon
-               pftsol(i,k)=pftsol(i,k)+ftsol(i,k)*pdtphys
-               ppsrf(i,k)=ppsrf(i,k)+pctsrf(i,k)*pdtphys
-            enddo
-         enddo
-
-      dtcum=dtcum+pdtphys
-768   continue
-
-      RETURN
-      END
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phystokenc.F90
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phystokenc.F90	(revision 1447)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phystokenc.F90	(revision 1447)
@@ -0,0 +1,362 @@
+SUBROUTINE phystokenc (nlon,nlev,pdtphys,rlon,rlat, &
+     pt,pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
+     pfm_therm,pentr_therm, &
+     cdragh, pcoefh,yu1,yv1,ftsol,pctsrf, &
+     frac_impa,frac_nucl, &
+     pphis,paire,dtime,itap, &
+     psh, pda, pphi, pmp, pupwd, pdnwd)
+  
+  USE ioipsl
+  USE dimphy
+  USE infotrac, ONLY : nqtot
+  USE iophy
+  USE control_mod
+  
+  IMPLICIT NONE
+  
+!======================================================================
+! Auteur(s) FH
+! Objet: Ecriture des variables pour transport offline
+!
+!======================================================================
+  INCLUDE "dimensions.h"
+  INCLUDE "tracstoke.h"
+  INCLUDE "indicesol.h"
+  INCLUDE "iniprint.h"
+!======================================================================
+
+! Arguments:
+!
+  REAL,DIMENSION(klon,klev), INTENT(IN)     :: psh   ! humidite specifique
+  REAL,DIMENSION(klon,klev), INTENT(IN)     :: pda
+  REAL,DIMENSION(klon,klev,klev), INTENT(IN):: pphi
+  REAL,DIMENSION(klon,klev), INTENT(IN)     :: pmp
+  REAL,DIMENSION(klon,klev), INTENT(IN)     :: pupwd ! saturated updraft mass flux
+  REAL,DIMENSION(klon,klev), INTENT(IN)     :: pdnwd ! saturated downdraft mass flux
+
+!   EN ENTREE:
+!   ==========
+!
+!   divers:
+!   -------
+!
+  INTEGER nlon ! nombre de points horizontaux
+  INTEGER nlev ! nombre de couches verticales
+  REAL pdtphys ! pas d'integration pour la physique (seconde)
+  INTEGER itap
+  INTEGER, SAVE :: physid
+!$OMP THREADPRIVATE(physid)
+
+!   convection:
+!   -----------
+!
+  REAL pmfu(klon,klev)  ! flux de masse dans le panache montant
+  REAL pmfd(klon,klev)  ! flux de masse dans le panache descendant
+  REAL pen_u(klon,klev) ! flux entraine dans le panache montant
+  REAL pde_u(klon,klev) ! flux detraine dans le panache montant
+  REAL pen_d(klon,klev) ! flux entraine dans le panache descendant
+  REAL pde_d(klon,klev) ! flux detraine dans le panache descendant
+  REAL pt(klon,klev)
+  REAL,ALLOCATABLE,SAVE :: t(:,:)
+!$OMP THREADPRIVATE(t)
+!
+  REAL rlon(klon), rlat(klon), dtime
+  REAL zx_tmp_3d(iim,jjm+1,klev),zx_tmp_2d(iim,jjm+1)
+
+!   Couche limite:
+!   --------------
+!
+  REAL cdragh(klon)          ! cdrag
+  REAL pcoefh(klon,klev)     ! coeff melange CL
+  REAL pcoefh_buf(klon,klev) ! coeff melange CL + cdrag
+  REAL yv1(klon)
+  REAL yu1(klon),pphis(klon),paire(klon)
+
+!   Les Thermiques : (Abderr 25 11 02)
+!   ---------------
+  REAL, INTENT(IN) ::  pfm_therm(klon,klev+1)
+  REAL pentr_therm(klon,klev)
+  
+  REAL,ALLOCATABLE,SAVE :: entr_therm(:,:)
+  REAL,ALLOCATABLE,SAVE :: fm_therm(:,:)
+!$OMP THREADPRIVATE(entr_therm)
+!$OMP THREADPRIVATE(fm_therm)
+!
+!   Lessivage:
+!   ----------
+!
+  REAL frac_impa(klon,klev)
+  REAL frac_nucl(klon,klev)
+!
+! Arguments necessaires pour les sources et puits de traceur
+!
+  REAL ftsol(klon,nbsrf)  ! Temperature du sol (surf)(Kelvin)
+  REAL pctsrf(klon,nbsrf) ! Pourcentage de sol f(nature du sol)
+!======================================================================
+!
+  INTEGER i, k, kk
+  REAL,ALLOCATABLE,SAVE :: mfu(:,:)  ! flux de masse dans le panache montant
+  REAL,ALLOCATABLE,SAVE :: mfd(:,:)  ! flux de masse dans le panache descendant
+  REAL,ALLOCATABLE,SAVE :: en_u(:,:) ! flux entraine dans le panache montant
+  REAL,ALLOCATABLE,SAVE :: de_u(:,:) ! flux detraine dans le panache montant
+  REAL,ALLOCATABLE,SAVE :: en_d(:,:) ! flux entraine dans le panache descendant
+  REAL,ALLOCATABLE,SAVE :: de_d(:,:) ! flux detraine dans le panache descendant
+  REAL,ALLOCATABLE,SAVE :: coefh(:,:) ! flux detraine dans le panache descendant
+  
+  REAL,ALLOCATABLE,SAVE :: pyu1(:)
+  REAL,ALLOCATABLE,SAVE :: pyv1(:)
+  REAL,ALLOCATABLE,SAVE :: pftsol(:,:)
+  REAL,ALLOCATABLE,SAVE :: ppsrf(:,:)
+!$OMP THREADPRIVATE(mfu,mfd,en_u,de_u,en_d,de_d,coefh)
+!$OMP THREADPRIVATE(pyu1,pyv1,pftsol,ppsrf)
+
+
+  REAL,DIMENSION(:,:), ALLOCATABLE,SAVE     :: sh  
+  REAL,DIMENSION(:,:), ALLOCATABLE,SAVE     :: da
+  REAL,DIMENSION(:,:,:), ALLOCATABLE,SAVE   :: phi
+  REAL,DIMENSION(:,:), ALLOCATABLE,SAVE     :: mp
+  REAL,DIMENSION(:,:), ALLOCATABLE,SAVE     :: upwd
+  REAL,DIMENSION(:,:), ALLOCATABLE,SAVE     :: dnwd
+  
+  REAL, SAVE :: dtcum
+  INTEGER, SAVE:: iadvtr=0
+!$OMP THREADPRIVATE(dtcum,iadvtr)
+  REAL zmin,zmax
+  LOGICAL ok_sync
+  CHARACTER(len=12) :: nvar
+!
+!======================================================================
+
+  iadvtr=iadvtr+1
+
+! Dans le meme vecteur on recombine le drag et les coeff d'echange
+  pcoefh_buf(:,1)      = cdragh(:)
+  pcoefh_buf(:,2:klev) = pcoefh(:,2:klev)
+  
+  ok_sync = .TRUE.
+
+! Initialization done only once
+!======================================================================
+  IF (iadvtr==1) THEN
+     ALLOCATE( t(klon,klev))
+     ALLOCATE( mfu(klon,klev))  
+     ALLOCATE( mfd(klon,klev))  
+     ALLOCATE( en_u(klon,klev)) 
+     ALLOCATE( de_u(klon,klev)) 
+     ALLOCATE( en_d(klon,klev)) 
+     ALLOCATE( de_d(klon,klev)) 
+     ALLOCATE( coefh(klon,klev)) 
+     ALLOCATE( entr_therm(klon,klev))
+     ALLOCATE( fm_therm(klon,klev))
+     ALLOCATE( pyu1(klon))
+     ALLOCATE( pyv1(klon))
+     ALLOCATE( pftsol(klon,nbsrf))
+     ALLOCATE( ppsrf(klon,nbsrf))
+     
+     ALLOCATE(sh(klon,klev)) 
+     ALLOCATE(da(klon,klev)) 
+     ALLOCATE(phi(klon,klev,klev)) 
+     ALLOCATE(mp(klon,klev)) 
+     ALLOCATE(upwd(klon,klev)) 
+     ALLOCATE(dnwd(klon,klev)) 
+
+     CALL initphysto('phystoke', dtime, dtime*istphy,dtime*istphy,physid)
+     
+     ! Write field phis and aire only once
+     CALL histwrite_phy(physid,"phis",itap,pphis)
+     CALL histwrite_phy(physid,"aire",itap,paire)
+     CALL histwrite_phy(physid,"longitudes",itap,rlon)
+     CALL histwrite_phy(physid,"latitudes",itap,rlat)
+
+  END IF
+  
+  
+! Set to zero cumulating fields
+!======================================================================
+  IF (MOD(iadvtr,istphy)==1.OR.istphy==1) THEN
+     WRITE(lunout,*)'reinitialisation des champs cumules a iadvtr=',iadvtr
+     mfu(:,:)=0.
+     mfd(:,:)=0.
+     en_u(:,:)=0.
+     de_u(:,:)=0.
+     en_d(:,:)=0.
+     de_d(:,:)=0.
+     coefh(:,:)=0.
+     t(:,:)=0.
+     fm_therm(:,:)=0.
+     entr_therm(:,:)=0.
+     pyv1(:)=0.
+     pyu1(:)=0.
+     pftsol(:,:)=0.
+     ppsrf(:,:)=0.
+     sh(:,:)=0.
+     da(:,:)=0.
+     phi(:,:,:)=0.
+     mp(:,:)=0.
+     upwd(:,:)=0.
+     dnwd(:,:)=0.
+     dtcum=0.
+  ENDIF
+  
+
+! Cumulate fields at each time step
+!======================================================================
+  DO k=1,klev
+     DO i=1,klon
+        mfu(i,k)=mfu(i,k)+pmfu(i,k)*pdtphys
+        mfd(i,k)=mfd(i,k)+pmfd(i,k)*pdtphys
+        en_u(i,k)=en_u(i,k)+pen_u(i,k)*pdtphys
+        de_u(i,k)=de_u(i,k)+pde_u(i,k)*pdtphys
+        en_d(i,k)=en_d(i,k)+pen_d(i,k)*pdtphys
+        de_d(i,k)=de_d(i,k)+pde_d(i,k)*pdtphys
+        coefh(i,k)=coefh(i,k)+pcoefh_buf(i,k)*pdtphys
+        t(i,k)=t(i,k)+pt(i,k)*pdtphys
+        fm_therm(i,k)=fm_therm(i,k)+pfm_therm(i,k)*pdtphys
+        entr_therm(i,k)=entr_therm(i,k)+pentr_therm(i,k)*pdtphys
+        sh(i,k) = sh(i,k) + psh(i,k)*pdtphys
+        da(i,k) = da(i,k) + pda(i,k)*pdtphys
+        mp(i,k) = mp(i,k) + pmp(i,k)*pdtphys
+        upwd(i,k) = upwd(i,k) + pupwd(i,k)*pdtphys
+        dnwd(i,k) = dnwd(i,k) + pdnwd(i,k)*pdtphys
+     ENDDO
+  ENDDO
+
+  DO kk=1,klev
+     DO k=1,klev
+        DO i=1,klon
+           phi(i,k,kk) = phi(i,k,kk) + pphi(i,k,kk)*pdtphys
+        END DO
+     END DO
+  END DO
+
+  DO i=1,klon
+     pyv1(i)=pyv1(i)+yv1(i)*pdtphys
+     pyu1(i)=pyu1(i)+yu1(i)*pdtphys
+  END DO
+  DO k=1,nbsrf
+     DO i=1,klon
+        pftsol(i,k)=pftsol(i,k)+ftsol(i,k)*pdtphys
+        ppsrf(i,k)=ppsrf(i,k)+pctsrf(i,k)*pdtphys
+     ENDDO
+  ENDDO
+  
+! Add time step to cumulated time
+  dtcum=dtcum+pdtphys
+  
+
+! Write fields to file, if it is time to do so
+!======================================================================
+  IF(MOD(iadvtr,istphy)==0) THEN 
+
+     ! normalize with time period
+     DO k=1,klev
+        DO i=1,klon
+           mfu(i,k)=mfu(i,k)/dtcum
+           mfd(i,k)=mfd(i,k)/dtcum
+           en_u(i,k)=en_u(i,k)/dtcum
+           de_u(i,k)=de_u(i,k)/dtcum
+           en_d(i,k)=en_d(i,k)/dtcum
+           de_d(i,k)=de_d(i,k)/dtcum
+           coefh(i,k)=coefh(i,k)/dtcum
+           t(i,k)=t(i,k)/dtcum	
+           fm_therm(i,k)=fm_therm(i,k)/dtcum
+           entr_therm(i,k)=entr_therm(i,k)/dtcum
+           sh(i,k)=sh(i,k)/dtcum
+           da(i,k)=da(i,k)/dtcum
+           mp(i,k)=mp(i,k)/dtcum
+           upwd(i,k)=upwd(i,k)/dtcum
+           dnwd(i,k)=dnwd(i,k)/dtcum
+        ENDDO
+     ENDDO
+     DO kk=1,klev
+        DO k=1,klev
+           DO i=1,klon
+              phi(i,k,kk) = phi(i,k,kk)/dtcum
+           END DO
+        END DO
+     END DO
+     DO i=1,klon
+        pyv1(i)=pyv1(i)/dtcum
+        pyu1(i)=pyu1(i)/dtcum
+     END DO
+     DO k=1,nbsrf
+        DO i=1,klon
+           pftsol(i,k)=pftsol(i,k)/dtcum
+           ppsrf(i,k)=ppsrf(i,k)/dtcum
+        ENDDO
+     ENDDO
+
+     ! write fields
+     CALL histwrite_phy(physid,"t",itap,t)
+     CALL histwrite_phy(physid,"mfu",itap,mfu)
+     CALL histwrite_phy(physid,"mfd",itap,mfd)
+     CALL histwrite_phy(physid,"en_u",itap,en_u)
+     CALL histwrite_phy(physid,"de_u",itap,de_u)
+     CALL histwrite_phy(physid,"en_d",itap,en_d)
+     CALL histwrite_phy(physid,"de_d",itap,de_d)
+     CALL histwrite_phy(physid,"coefh",itap,coefh)	
+     CALL histwrite_phy(physid,"fm_th",itap,fm_therm)
+     CALL histwrite_phy(physid,"en_th",itap,entr_therm)
+     CALL histwrite_phy(physid,"frac_impa",itap,frac_impa)
+     CALL histwrite_phy(physid,"frac_nucl",itap,frac_nucl)
+     CALL histwrite_phy(physid,"pyu1",itap,pyu1)
+     CALL histwrite_phy(physid,"pyv1",itap,pyv1)
+     CALL histwrite_phy(physid,"ftsol1",itap,pftsol(:,1))
+     CALL histwrite_phy(physid,"ftsol2",itap,pftsol(:,2))
+     CALL histwrite_phy(physid,"ftsol3",itap,pftsol(:,3))
+     CALL histwrite_phy(physid,"ftsol4",itap,pftsol(:,4))
+     CALL histwrite_phy(physid,"psrf1",itap,ppsrf(:,1))
+     CALL histwrite_phy(physid,"psrf2",itap,ppsrf(:,2))
+     CALL histwrite_phy(physid,"psrf3",itap,ppsrf(:,3))
+     CALL histwrite_phy(physid,"psrf4",itap,ppsrf(:,4))
+     CALL histwrite_phy(physid,"sh",itap,sh)
+     CALL histwrite_phy(physid,"da",itap,da)
+     CALL histwrite_phy(physid,"mp",itap,mp)
+     CALL histwrite_phy(physid,"upwd",itap,upwd)
+     CALL histwrite_phy(physid,"dnwd",itap,dnwd)
+
+
+! phi
+     DO k=1,klev
+        IF (k<10) THEN
+           WRITE(nvar,'(i1)') k
+        ELSE IF (k<100) THEN
+           WRITE(nvar,'(i2)') k
+        ELSE
+           WRITE(nvar,'(i3)') k
+        END IF
+        nvar='phi_lev'//trim(nvar)
+        
+        CALL histwrite_phy(physid,nvar,itap,phi(:,:,k))
+     END DO
+     
+     ! Syncronize file
+!$OMP MASTER
+     IF (ok_sync) CALL histsync(physid)
+!$OMP END MASTER
+     
+     
+     ! Calculate min and max values for some fields (coefficients de lessivage)
+     zmin=1e33
+     zmax=-1e33
+     DO k=1,klev
+        DO i=1,klon
+           zmax=MAX(zmax,frac_nucl(i,k))
+           zmin=MIN(zmin,frac_nucl(i,k))
+        ENDDO
+     ENDDO
+     WRITE(lunout,*)'------ coefs de lessivage (min et max) --------'
+     WRITE(lunout,*)'facteur de nucleation ',zmin,zmax
+     zmin=1e33
+     zmax=-1e33
+     DO k=1,klev
+        DO i=1,klon
+           zmax=MAX(zmax,frac_impa(i,k))
+           zmin=MIN(zmin,frac_impa(i,k))
+        ENDDO
+     ENDDO
+     WRITE(lunout,*)'facteur d impaction ',zmin,zmax
+     
+  ENDIF ! IF(MOD(iadvtr,istphy)==0)
+
+END SUBROUTINE phystokenc
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phytrac.F90
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phytrac.F90	(revision 1446)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phytrac.F90	(revision 1447)
@@ -66,6 +66,6 @@
 !--------
   REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: u       ! 
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: v       ! 
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: u       ! variable not used
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: v       ! variable not used
   REAL,DIMENSION(klon,klev),INTENT(IN)   :: sh      ! humidite specifique
   REAL,DIMENSION(klon,klev),INTENT(IN)   :: rh      ! humidite relative
@@ -118,5 +118,5 @@
 !--------------
 !
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: cdragh ! coeff drag pour T et Q
+  REAL,DIMENSION(klon),INTENT(IN)      :: cdragh ! coeff drag pour T et Q
   REAL,DIMENSION(klon,klev),INTENT(IN) :: coefh  ! coeff melange CL (m**2/s)
   REAL,DIMENSION(klon),INTENT(IN)      :: yu1    ! vents au premier niveau
@@ -213,5 +213,4 @@
      SELECT CASE(type_trac)
      CASE('lmdz')
-!IM ajout t_seri, pplay, sh    CALL traclmdz_init(pctsrf, ftsol, tr_seri, aerosol, lessivage)
         CALL traclmdz_init(pctsrf, ftsol, tr_seri, t_seri, pplay, sh, pdtphys, aerosol, lessivage)
      CASE('inca')
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/traclmdz_mod.F90
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/traclmdz_mod.F90	(revision 1446)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/traclmdz_mod.F90	(revision 1447)
@@ -313,5 +313,5 @@
 !--------------
 !
-    REAL,DIMENSION(klon,klev),INTENT(IN) :: cdragh     ! coeff drag pour T et Q
+    REAL,DIMENSION(klon),INTENT(IN)      :: cdragh     ! coeff drag pour T et Q
     REAL,DIMENSION(klon,klev),INTENT(IN) :: coefh      ! coeff melange CL (m**2/s)
     REAL,DIMENSION(klon),INTENT(IN)      :: yu1        ! vents au premier niveau
