Index: LMDZ5/trunk/libf/phylmd/ini_histrac.h
===================================================================
--- LMDZ5/trunk/libf/phylmd/ini_histrac.h	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/ini_histrac.h	(revision 1813)
@@ -147,5 +147,5 @@
 
 ! TD COUCHE-LIMITE
-      IF (couchelimite) THEN
+      IF (iflag_vdf_trac>=0) THEN
         CALL histdef(nid_tra, "d_tr_cl_"//tname(iiq),      &
              "tendance couche limite"// ttext(iiq), "?",   &
Index: LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 1813)
@@ -1049,4 +1049,19 @@
   TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_trac(:)
   TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_trac_cum(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_vdf(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_the(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_con(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_lessi_impa(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_lessi_nucl(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_insc(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_bcscav(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_evapls(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_ls(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_trsp(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_sscav(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_sat(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_uscav(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_dry(:)
+
   TYPE(ctrl_out), SAVE :: o_rsu = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
 	'rsu', 'SW upward radiation', 'W m-2', (/ ('', i=1, 6) /))
Index: LMDZ5/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phys_output_mod.F90	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/phys_output_mod.F90	(revision 1813)
@@ -1,4 +1,11 @@
 ! $Id$
 !
+
+MODULE phys_output_mod 
+  USE indice_sol_mod
+  USE phys_output_var_mod
+  USE aero_mod, only : naero_spc,name_aero
+  USE phys_output_write_mod, ONLY : phys_output_write
+
 ! Abderrahmane 12 2007
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -9,11 +16,4 @@
 ! histins.nc : valeurs instantanees
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-MODULE phys_output_mod 
-  USE indice_sol_mod
-  USE phys_output_var_mod
-  USE aero_mod, only : naero_spc,name_aero
-
-  IMPLICIT NONE
 
 CONTAINS
@@ -41,5 +41,4 @@
     USE mod_phys_lmdz_para
     USE aero_mod, only : naero_spc,name_aero
-    USE phys_output_write_mod
     USE phys_output_ctrlout_mod
 
@@ -124,4 +123,10 @@
     IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
     IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
+    ALLOCATE(o_dtr_the(nqtot),o_dtr_con(nqtot),o_dtr_lessi_impa(nqtot))
+    ALLOCATE(o_dtr_lessi_nucl(nqtot),o_dtr_insc(nqtot),o_dtr_bcscav(nqtot))
+    ALLOCATE(o_dtr_evapls(nqtot),o_dtr_ls(nqtot),o_dtr_trsp(nqtot))
+    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
+    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
+
 
     levmax = (/ klev, klev, klev, klev, klev, klev /)
@@ -330,4 +335,47 @@
             o_trac(iq-2) = ctrl_out((/ 4, 5, 1, 1, 1, 10 /),tname(iiq),'Tracer '//ttext(iiq), "-",&
                   (/ '', '', '', '', '', '' /))
+
+            o_dtr_vdf(iq-2) = ctrl_out((/ 5, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_vdf' &
+               ,'Tendance tracer '//ttext(iiq), "-" , (/ '', '', '', '', '', '' /))
+
+            o_dtr_the(iq-2) = ctrl_out((/ 5, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_the' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_con(iq-2) = ctrl_out((/ 5, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_con' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_lessi_impa(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_lessi_impa' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_lessi_nucl(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_lessi_nucl' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_insc(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_insc' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_bcscav(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_bcscav' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_evapls(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_evapls' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_ls(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_ls' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_trsp(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_trsp' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_sscav(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_sscav' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_sat(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_sat' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_uscav(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'d'//trim(tname(iq))//'_uscav' &
+               ,'Tendance tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
+            o_dtr_dry(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10 /),'cum'//'d'//trim(tname(iq))//'_dry' &
+               ,'tracer tendency dry deposition'//ttext(iiq), "-", (/ '', '', '', '', '', '' /) )
+
             o_trac_cum(iq-2) = ctrl_out((/ 3, 4, 10, 10, 10, 10 /),'cum'//tname(iiq),&
                   'Cumulated tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /))
Index: LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 1813)
@@ -3,4 +3,9 @@
 !
 MODULE phys_output_write_mod
+
+    USE phytrac_mod, ONLY : d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
+        d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
+        d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
+
 
 ! Author: Abderrahmane IDELKADI (original include file)
@@ -79,5 +84,893 @@
 
 ! On procède à l'écriture ou à la définition des nombreuses variables:
-#include "phys_output_write_F90.h"
+!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      CALL histwrite_phy(o_phis, pphis)
+      CALL histwrite_phy(o_aire, airephy)
+
+IF (itap > 0) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
+      ENDDO
+ENDIF
+
+      CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
+      CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
+      CALL histwrite_phy(o_aireTER, paire_ter)
+!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      CALL histwrite_phy(o_flat, zxfluxlat)
+      CALL histwrite_phy(o_slp, slp)
+      CALL histwrite_phy(o_tsol, zxtsol)
+      CALL histwrite_phy(o_t2m, zt2m)
+      CALL histwrite_phy(o_t2m_min, zt2m)
+      CALL histwrite_phy(o_t2m_max, zt2m)
+
+IF (itap > 0) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      DO i = 1, klon
+         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
+      CALL histwrite_phy(o_q2m, zq2m)
+      CALL histwrite_phy(o_ustar, zustar)
+      CALL histwrite_phy(o_u10m, zu10m)
+      CALL histwrite_phy(o_v10m, zv10m)
+
+IF (itap > 0) THEN
+      DO i = 1, klon
+         zx_tmp_fi2d(i) = paprs(i,1)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_psol, zx_tmp_fi2d)
+      CALL histwrite_phy(o_mass, zmasse)
+      CALL histwrite_phy(o_qsurf, zxqsurf)
+
+IF (.NOT. ok_veget) THEN
+      CALL histwrite_phy(o_qsol, qsol)
+ENDIF
+
+IF (itap > 0) THEN
+       DO i = 1, klon
+         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
+       ENDDO
+ENDIF
+
+      CALL histwrite_phy(o_precip, zx_tmp_fi2d)
+      CALL histwrite_phy(o_ndayrain, nday_rain)
+
+IF (itap > 0) THEN
+       DO i = 1, klon
+         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
+       ENDDO
+ENDIF
+      CALL histwrite_phy(o_plul, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      DO i = 1, klon
+         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
+      CALL histwrite_phy(o_snow, snow_fall)
+      CALL histwrite_phy(o_msnow, snow_o)
+      CALL histwrite_phy(o_fsnow, zfra_o)
+      CALL histwrite_phy(o_evap, evap)
+      CALL histwrite_phy(o_tops, topsw)
+      CALL histwrite_phy(o_tops0, topsw0)
+      CALL histwrite_phy(o_topl, toplw)
+      CALL histwrite_phy(o_topl0, toplw0)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(:) = topsw(:)-toplw(:)
+ENDIF
+      CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
+      CALL histwrite_phy(o_SWup200, SWup200)
+      CALL histwrite_phy(o_SWup200clr, SWup200clr)
+      CALL histwrite_phy(o_SWdn200, SWdn200)
+      CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
+      CALL histwrite_phy(o_LWup200, LWup200)
+      CALL histwrite_phy(o_LWup200clr, LWup200clr)
+      CALL histwrite_phy(o_LWdn200, LWdn200)
+      CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
+      CALL histwrite_phy(o_sols, solsw)
+      CALL histwrite_phy(o_sols0, solsw0)
+      CALL histwrite_phy(o_soll, sollw)
+      CALL histwrite_phy(o_radsol, radsol)
+      CALL histwrite_phy(o_soll0, sollw0)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
+ENDIF
+      CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
+      CALL histwrite_phy(o_LWdnSFC, sollwdown)
+
+IF (itap > 0) THEN
+       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
+      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
+ENDIF
+      CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
+      CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
+      CALL histwrite_phy(o_bils, bils)
+      CALL histwrite_phy(o_bils_diss, bils_diss)
+      CALL histwrite_phy(o_bils_ec, bils_ec)
+      CALL histwrite_phy(o_bils_tke, bils_tke)
+      CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
+      CALL histwrite_phy(o_bils_latent, bils_latent)
+      CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
+ENDIF
+      CALL histwrite_phy(o_sens, zx_tmp_fi2d)
+      CALL histwrite_phy(o_fder, fder)
+      CALL histwrite_phy(o_ffonte, zxffonte)
+      CALL histwrite_phy(o_fqcalving, zxfqcalving)
+      CALL histwrite_phy(o_fqfonte, zxfqfonte)
+IF (itap > 0) THEN
+      zx_tmp_fi2d=0.
+      DO nsrf=1,nbsrf
+        zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_taux, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      zx_tmp_fi2d=0.
+      DO nsrf=1,nbsrf
+          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
+
+
+         DO nsrf = 1, nbsrf
+IF (itap > 0)             zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
+      CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)           zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
+      CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
+      CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
+      CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
+      CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
+      CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)       zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
+      CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
+      CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
+      CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
+      CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)       zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
+      CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
+      CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
+      CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
+      CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
+      CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
+      CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0)         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
+      CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
+
+      IF (iflag_pbl > 1) THEN
+      CALL histwrite_phy(o_tke_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
+      CALL histwrite_phy(o_tke_max_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
+      ENDIF
+
+      ENDDO
+      CALL histwrite_phy(o_cdrm, cdragm)
+      CALL histwrite_phy(o_cdrh, cdragh)
+      CALL histwrite_phy(o_cldl, cldl)
+      CALL histwrite_phy(o_cldm, cldm)
+      CALL histwrite_phy(o_cldh, cldh)
+      CALL histwrite_phy(o_cldt, cldt)
+      CALL histwrite_phy(o_cldq, cldq)
+IF (itap > 0)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
+      CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
+IF (itap > 0)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
+      CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
+      CALL histwrite_phy(o_ue, ue)
+      CALL histwrite_phy(o_ve, ve)
+      CALL histwrite_phy(o_uq, uq)
+      CALL histwrite_phy(o_vq, vq)
+      IF(iflag_con.GE.3) THEN ! sb
+      CALL histwrite_phy(o_cape, cape)
+      CALL histwrite_phy(o_pbase, ema_pcb)
+      CALL histwrite_phy(o_ptop, ema_pct)
+      CALL histwrite_phy(o_fbase, ema_cbmf)
+        if (iflag_con /= 30) then
+      CALL histwrite_phy(o_plcl, plcl)
+      CALL histwrite_phy(o_plfc, plfc)
+      CALL histwrite_phy(o_wbeff, wbeff)
+        end if
+
+      CALL histwrite_phy(o_cape_max, cape)
+
+      CALL histwrite_phy(o_upwd, upwd)
+      CALL histwrite_phy(o_Ma, Ma)
+      CALL histwrite_phy(o_dnwd, dnwd)
+      CALL histwrite_phy(o_dnwd0, dnwd0)
+IF (itap > 0)         zx_tmp_fi2d=float(itau_con)/float(itap)
+      CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
+IF (itap > 0) THEN
+      IF(iflag_thermals>=1)THEN
+         zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm(:,1:klev)
+      ELSE
+         zx_tmp_fi3d=dnwd+dnwd0+upwd
+      ENDIF
+ENDIF
+      CALL histwrite_phy(o_mc, zx_tmp_fi3d)
+      ENDIF !iflag_con .GE. 3
+      CALL histwrite_phy(o_prw, prw)
+      CALL histwrite_phy(o_s_pblh, s_pblh)
+      CALL histwrite_phy(o_s_pblt, s_pblt)
+      CALL histwrite_phy(o_s_lcl, s_lcl)
+      CALL histwrite_phy(o_s_therm, s_therm)
+!IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
+!       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_capCL%name,itau_w,s_capCL)
+!       ENDIF
+!       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_oliqCL%name,itau_w,s_oliqCL)
+!       ENDIF
+!       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_cteiCL%name,itau_w,s_cteiCL)
+!       ENDIF
+!       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_trmb1%name,itau_w,s_trmb1)
+!       ENDIF
+!       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_trmb2%name,itau_w,s_trmb2)
+!       ENDIF
+!       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_trmb3%name,itau_w,s_trmb3)
+!       ENDIF
+
+
+
+! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
+! Champs interpolles sur des niveaux de pression
+      DO iff=1, nfiles
+        ll=0
+        DO k=1, nlevSTD
+         bb2=clevSTD(k) 
+         IF(bb2.EQ."850".OR.bb2.EQ."700".OR. &
+            bb2.EQ."500".OR.bb2.EQ."200".OR. &
+            bb2.EQ."100".OR. &
+            bb2.EQ."50".OR.bb2.EQ."10") THEN
+
+! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+          ll=ll+1
+      CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
+
+       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
+       ENDDO
+       ENDDO
+
+
+
+IF (itap > 0) THEN
+      DO i=1, klon
+       IF (pctsrf(i,is_oce).GT.epsfra.OR. &
+           pctsrf(i,is_sic).GT.epsfra) THEN
+        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+ &
+                         ftsol(i, is_sic) * pctsrf(i,is_sic))/ &
+                         (pctsrf(i,is_oce)+pctsrf(i,is_sic))
+       ELSE
+        zx_tmp_fi2d(i) = 273.15
+       ENDIF
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
+
+! Couplage convection-couche limite
+      IF (iflag_con.GE.3) THEN
+      IF (iflag_coupl>=1) THEN
+      CALL histwrite_phy(o_ale_bl, ale_bl)
+      CALL histwrite_phy(o_alp_bl, alp_bl)
+      ENDIF !iflag_coupl>=1
+      ENDIF !(iflag_con.GE.3)
+! Wakes
+      IF (iflag_con.EQ.3) THEN
+      IF (iflag_wake>=1) THEN
+      CALL histwrite_phy(o_ale_wk, ale_wake)
+      CALL histwrite_phy(o_alp_wk, alp_wake)
+      CALL histwrite_phy(o_ale, ale)
+      CALL histwrite_phy(o_alp, alp)
+      CALL histwrite_phy(o_cin, cin)
+      CALL histwrite_phy(o_WAPE, wake_pe)
+      CALL histwrite_phy(o_wake_h, wake_h)
+      CALL histwrite_phy(o_wake_s, wake_s)
+      CALL histwrite_phy(o_wake_deltat, wake_deltat)
+      CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
+      CALL histwrite_phy(o_wake_omg, wake_omg)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev) &
+                                              /pdtphys
+      CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
+      ENDIF ! iflag_wake>=1
+      CALL histwrite_phy(o_Vprecip, Vprecip)
+      CALL histwrite_phy(o_ftd, ftd)
+      CALL histwrite_phy(o_fqd, fqd)
+      ELSEIF (iflag_con.EQ.30) THEN
+! sortie RomP convection descente insaturee iflag_con=30
+      CALL histwrite_phy(o_Vprecip, Vprecip)
+      CALL histwrite_phy(o_wdtrainA, wdtrainA)
+      CALL histwrite_phy(o_wdtrainM, wdtrainM)
+      ENDIF !(iflag_con.EQ.3.or.iflag_con.EQ.30)
+!!! nrlmd le 10/04/2012
+        IF (iflag_trig_bl>=1) THEN
+      CALL histwrite_phy(o_n2, n2)
+      CALL histwrite_phy(o_s2, s2)
+      CALL histwrite_phy(o_proba_notrig, proba_notrig)
+      CALL histwrite_phy(o_random_notrig, random_notrig)
+      CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
+      CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
+       ENDIF  !(iflag_trig_bl>=1)
+        IF (iflag_clos_bl>=1) THEN
+      CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
+      CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
+      CALL histwrite_phy(o_alp_bl_fluct_tke,  &
+       alp_bl_fluct_tke)
+      CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
+      CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
+       ENDIF  !(iflag_clos_bl>=1)
+!!! fin nrlmd le 10/04/2012
+      IF (type_ocean=='slab ') THEN
+      CALL histwrite_phy(o_slab_bils, slab_wfbils)
+      ENDIF !type_ocean == force/slab
+      CALL histwrite_phy(o_weakinv, weak_inversion)
+      CALL histwrite_phy(o_dthmin, dthmin)
+      CALL histwrite_phy(o_cldtau, cldtau)
+      CALL histwrite_phy(o_cldemi, cldemi)
+      CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
+      CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
+      CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
+      CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
+      CALL histwrite_phy(o_re, re)
+      CALL histwrite_phy(o_fl, fl)
+IF (itap > 0) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
+
+IF (itap > 0) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
+
+      CALL histwrite_phy(o_qsat2m, qsat2m)
+      CALL histwrite_phy(o_tpot, tpot)
+      CALL histwrite_phy(o_tpote, tpote)
+IF (itap > 0) zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
+      CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
+IF (itap > 0) zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
+      CALL histwrite_phy(o_SWdownOR,  zx_tmp_fi2d)
+      CALL histwrite_phy(o_LWdownOR, sollwdown)
+      CALL histwrite_phy(o_snowl, snow_lsc)
+      CALL histwrite_phy(o_solldown, sollwdown)
+      CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
+      CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
+      CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
+      CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
+      CALL histwrite_phy(o_rugs, zxrugs)
+! OD550 per species
+      IF (new_aod .and. (.not. aerosol_couple)) THEN
+          IF (ok_ade.OR.ok_aie) THEN
+      CALL histwrite_phy(o_od550aer, od550aer)
+      CALL histwrite_phy(o_od865aer, od865aer)
+      CALL histwrite_phy(o_absvisaer, absvisaer)
+      CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
+      CALL histwrite_phy(o_sconcso4, sconcso4)
+      CALL histwrite_phy(o_sconcoa, sconcoa)
+      CALL histwrite_phy(o_sconcbc, sconcbc)
+      CALL histwrite_phy(o_sconcss, sconcss)
+      CALL histwrite_phy(o_sconcdust, sconcdust)
+      CALL histwrite_phy(o_concso4, concso4)
+      CALL histwrite_phy(o_concoa, concoa)
+      CALL histwrite_phy(o_concbc, concbc)
+      CALL histwrite_phy(o_concss, concss)
+      CALL histwrite_phy(o_concdust, concdust)
+      CALL histwrite_phy(o_loadso4, loadso4)
+      CALL histwrite_phy(o_loadoa, loadoa)
+      CALL histwrite_phy(o_loadbc, loadbc)
+      CALL histwrite_phy(o_loadss, loadss)
+      CALL histwrite_phy(o_loaddust, loaddust)
+!--STRAT AER
+          ENDIF
+          IF (ok_ade.OR.ok_aie.OR.flag_aerosol_strat) THEN
+          DO naero = 1, naero_spc
+      CALL histwrite_phy(o_tausumaero(naero), &
+       tausum_aero(:,2,naero) )
+          END DO
+          ENDIF
+      ENDIF
+       IF (ok_ade) THEN
+      CALL histwrite_phy(o_topswad, topswad_aero)
+      CALL histwrite_phy(o_topswad0, topswad0_aero)
+      CALL histwrite_phy(o_solswad, solswad_aero)
+      CALL histwrite_phy(o_solswad0, solswad0_aero)
+!====MS forcing diagnostics
+        if (new_aod) then
+      CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:,1))
+      CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:,1))
+      CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:,1))
+      CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:,1))
+!ant
+      CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:,2))
+      CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:,2))
+      CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:,2))
+      CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:,2))
+!cf
+        if (.not. aerosol_couple) then
+      CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:,1))
+      CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:,1))
+      CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:,2))
+      CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:,2))
+      CALL histwrite_phy(o_swtoacf_zero,topswcf_aero(:,3))
+      CALL histwrite_phy(o_swsrfcf_zero,solswcf_aero(:,3))
+        endif
+    endif ! new_aod
+!====MS forcing diagnostics
+       ENDIF
+       IF (ok_aie) THEN
+      CALL histwrite_phy(o_topswai, topswai_aero)
+      CALL histwrite_phy(o_solswai, solswai_aero)
+      CALL histwrite_phy(o_scdnc, scdnc)
+      CALL histwrite_phy(o_cldncl, cldncl)
+      CALL histwrite_phy(o_reffclws, reffclws)
+      CALL histwrite_phy(o_reffclwc, reffclwc)
+      CALL histwrite_phy(o_cldnvi, cldnvi)
+      CALL histwrite_phy(o_lcc, lcc)
+      CALL histwrite_phy(o_lcc3d, lcc3d)
+      CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
+      CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
+      CALL histwrite_phy(o_reffclwtop, reffclwtop)
+       ENDIF
+! Champs 3D:
+       IF (ok_ade .OR. ok_aie) then
+      CALL histwrite_phy(o_ec550aer, ec550aer)
+       ENDIF
+      CALL histwrite_phy(o_lwcon, flwc)
+      CALL histwrite_phy(o_iwcon, fiwc)
+      CALL histwrite_phy(o_temp, t_seri)
+      CALL histwrite_phy(o_theta, theta)
+      CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
+      CALL histwrite_phy(o_ovap, q_seri)
+      CALL histwrite_phy(o_oliq, ql_seri)
+      CALL histwrite_phy(o_geop, zphi)
+      CALL histwrite_phy(o_vitu, u_seri)
+      CALL histwrite_phy(o_vitv, v_seri)
+      CALL histwrite_phy(o_vitw, omega)
+      CALL histwrite_phy(o_pres, pplay)
+      CALL histwrite_phy(o_paprs, paprs(:,1:klev))
+IF (itap > 0) THEN
+         DO i=1, klon
+          zx_tmp_fi3d1(i,1)= pphis(i)/RG
+!020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
+         ENDDO
+         DO k=1, klev
+!020611        DO k=1, klev-1
+         DO i=1, klon
+!020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD * 
+          zx_tmp_fi3d1(i,k+1)= zx_tmp_fi3d1(i,k) - (t_seri(i,k) *RD *  &
+          (paprs(i,k+1) - paprs(i,k))) / ( pplay(i,k) * RG ) 
+         ENDDO
+         ENDDO
+ENDIF
+      CALL histwrite_phy(o_zfull,zx_tmp_fi3d1(:,2:klevp1))
+!020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
+
+IF (itap > 0)  THEN
+         DO i=1, klon
+          zx_tmp_fi3d(i,1)= pphis(i)/RG - ( &
+          (t_seri(i,1)+zxtsol(i))/2. *RD * &
+          (pplay(i,1) - paprs(i,1)))/( (paprs(i,1)+pplay(i,1))/2.* RG)
+         ENDDO
+         DO k=1, klev-1
+         DO i=1, klon
+          zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - ( &
+          (t_seri(i,k)+t_seri(i,k+1))/2. *RD *  &
+          (pplay(i,k+1) - pplay(i,k))) / ( paprs(i,k) * RG ) 
+         ENDDO
+         ENDDO
+ENDIF
+      CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
+      CALL histwrite_phy(o_rneb, cldfra)
+      CALL histwrite_phy(o_rnebcon, rnebcon)
+      CALL histwrite_phy(o_rnebls, rneb)
+      CALL histwrite_phy(o_rhum, zx_rh)
+      CALL histwrite_phy(o_ozone, &
+       wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
+
+      IF (read_climoz == 2) THEN
+      CALL histwrite_phy(o_ozone_light, &
+       wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
+      ENDIF
+
+      CALL histwrite_phy(o_dtphy, d_t)
+      CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
+        DO nsrf=1, nbsrf
+IF (itap > 0) zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
+      CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0) zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
+      CALL histwrite_phy(o_rugs_srf(nsrf), zx_tmp_fi2d)
+IF (itap > 0) zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
+      CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
+        ENDDO !nsrf=1, nbsrf
+      CALL histwrite_phy(o_alb1, albsol1)
+      CALL histwrite_phy(o_alb2, albsol2)
+!FH Sorties pour la couche limite
+      if (iflag_pbl>1) then
+      zx_tmp_fi3d=0.
+IF (itap > 0) THEN
+      do nsrf=1,nbsrf
+         do k=1,klev
+          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
+          +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
+         enddo
+      enddo
+ENDIF
+      CALL histwrite_phy(o_tke, zx_tmp_fi3d)
+
+      CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
+      ENDIF
+
+      CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
+
+      CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
+
+      CALL histwrite_phy(o_clwcon, clwcon0)
+      CALL histwrite_phy(o_dtdyn, d_t_dyn)
+      CALL histwrite_phy(o_dqdyn, d_q_dyn)
+      CALL histwrite_phy(o_dudyn, d_u_dyn)
+      CALL histwrite_phy(o_dvdyn, d_v_dyn)
+
+IF (itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
+      if(iflag_thermals.eq.1)then
+IF (itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
+                                 d_t_ajsb(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
+      else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
+IF (itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
+                                 d_t_ajs(1:klon,1:klev)/pdtphys + &
+                                 d_t_wake(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
+      endif
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
+
+      IF(iflag_thermals.EQ.1) THEN
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
+        CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
+      ELSE IF(iflag_thermals.GT.1.AND.iflag_wake.EQ.1) THEN
+IF (itap > 0) THEN
+         zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys + &
+                                     d_q_ajs(1:klon,1:klev)/pdtphys + &
+                                     d_q_wake(1:klon,1:klev)/pdtphys
+ENDIF
+         CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
+      ENDIF
+
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+ &
+                                 d_t_eva(1:klon,1:klev))/pdtphys
+      CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
+      CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Sorties specifiques a la separation thermiques/non thermiques
+       if (iflag_thermals>=1) then
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
+      CALL histwrite_phy(o_plulth, plul_th)
+      CALL histwrite_phy(o_plulst, plul_st)
+IF (itap > 0) THEN
+      do k=1,klev
+      do i=1,klon
+          if (ptconvth(i,k)) then
+           zx_tmp_fi3d(i,k)=1.
+          else
+           zx_tmp_fi3d(i,k)=0.
+          endif
+      enddo
+      enddo
+ENDIF
+      CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
+IF (itap > 0) THEN
+      do i=1,klon
+           zx_tmp_fi2d(1:klon)=lmax_th(:)
+      enddo
+ENDIF
+      CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
+      endif ! iflag_thermals>=1
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
+IF (itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
+      zpt_conv = 0.
+      WHERE (ptconv) zpt_conv = 1.
+      CALL histwrite_phy(o_ptconv, zpt_conv)
+      CALL histwrite_phy(o_ratqs, ratqs)
+IF (itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys - &
+                                 d_t_ajsb(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
+       IF (iflag_thermals>=1) THEN
+! Pour l instant 0 a y reflichir pour les thermiques
+         zx_tmp_fi2d=0. 
+      CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
+      CALL histwrite_phy(o_f_th, fm_therm)
+      CALL histwrite_phy(o_e_th, entr_therm)
+      CALL histwrite_phy(o_w_th, zw2)
+      CALL histwrite_phy(o_q_th, zqasc)
+      CALL histwrite_phy(o_a_th, fraca)
+      CALL histwrite_phy(o_d_th, detr_therm)
+      CALL histwrite_phy(o_f0_th, f0)
+      CALL histwrite_phy(o_zmax_th, zmax_th)
+IF (itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys - &
+                                 d_q_ajsb(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
+      ENDIF !iflag_thermals
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
+       IF (ok_orodr) THEN
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
+       ENDIF
+        IF (ok_orolf) THEN
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
+       ENDIF
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
+
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
+
+       IF (ok_hines) THEN
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_duhin, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvhin, zx_tmp_fi3d)
+IF(itap > 0) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
+        ENDIF
+      CALL histwrite_phy(o_rsu, swup)
+      CALL histwrite_phy(o_rsd, swdn)
+      CALL histwrite_phy(o_rlu, lwup)
+      CALL histwrite_phy(o_rld, lwdn)
+      CALL histwrite_phy(o_rsucs, swup0)
+      CALL histwrite_phy(o_rsdcs, swdn0)
+      CALL histwrite_phy(o_rlucs, lwup0)
+      CALL histwrite_phy(o_rldcs, lwdn0)
+IF(itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+ &
+      d_t_dyn(1:klon,1:klev)
+ENDIF
+      CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
+IF(itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY - &
+      cool(1:klon,1:klev)/RDAY
+ENDIF
+      CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
+IF(itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+ &
+                                   d_t_eva(1:klon,1:klev)+ &
+                                   d_t_vdf(1:klon,1:klev))/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
+IF(itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+ &
+      d_q_dyn(1:klon,1:klev)
+ENDIF
+      CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
+IF(itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+ &
+                                 d_q_eva(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
+      CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
+IF(itap > 0) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+ &
+                                 ql_seri(1:klon,1:klev) 
+ENDIF
+      CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
+       if (iflag_con >= 3) then
+IF(itap > 0) THEN
+             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+ &
+                  dnwd0(1:klon,1:klev)) 
+ENDIF
+      CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
+IF(itap > 0) THEN
+             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) + &
+                  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev) 
+ENDIF
+      CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
+       else if (iflag_con == 2) then
+      CALL histwrite_phy(o_mcd,  pmfd)
+      CALL histwrite_phy(o_dmc,  pmfu + pmfd)
+       end if
+      CALL histwrite_phy(o_ref_liq, ref_liq)
+      CALL histwrite_phy(o_ref_ice, ref_ice)
+      if (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR. &
+       RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR. &
+       RCFC12_per.NE.RCFC12_act) THEN
+IF(itap > 0) zx_tmp_fi2d(1 : klon) = swupp ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
+IF(itap > 0) zx_tmp_fi2d(1 : klon) = lwupp ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
+IF(itap > 0) zx_tmp_fi2d(1 : klon) = swup0p ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
+IF(itap > 0) zx_tmp_fi2d(1 : klon) = lwup0p ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
+      CALL histwrite_phy(o_rsu4co2, swupp)
+      CALL histwrite_phy(o_rlu4co2, lwupp)
+      CALL histwrite_phy(o_rsucs4co2, swup0p)
+      CALL histwrite_phy(o_rlucs4co2, lwup0p)
+      CALL histwrite_phy(o_rsd4co2, swdnp)
+      CALL histwrite_phy(o_rld4co2, lwdnp)
+      CALL histwrite_phy(o_rsdcs4co2, swdn0p)
+      CALL histwrite_phy(o_rldcs4co2, lwdn0p)
+      ENDIF
+        IF (nqtot.GE.3) THEN
+         DO iq=3,nqtot
+             CALL histwrite_phy(o_trac(iq-2), qx(:,:,iq))
+             CALL histwrite_phy(o_dtr_vdf(iq-2),d_tr_cl(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_the(iq-2),d_tr_th(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_con(iq-2),d_tr_cv(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_lessi_impa(iq-2),d_tr_lessi_impa(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_lessi_nucl(iq-2),d_tr_lessi_nucl(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_insc(iq-2),d_tr_insc(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_bcscav(iq-2),d_tr_bcscav(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_evapls(iq-2),d_tr_evapls(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_ls(iq-2),d_tr_ls(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_trsp(iq-2),d_tr_trsp(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_sscav(iq-2),d_tr_sscav(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_sat(iq-2),d_tr_sat(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_uscav(iq-2),d_tr_uscav(:,:,iq-2))
+         zx_tmp_fi2d=0.
+IF(itap > 0) THEN
+         DO k=1,klev
+            zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*qx(:,k,iq)
+         ENDDO
+ENDIF
+            CALL histwrite_phy(o_trac_cum(iq-2), zx_tmp_fi2d)
+         ENDDO
+        ENDIF
+
 
     IF(vars_defined) THEN
Index: LMDZ5/trunk/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phys_state_var_mod.F90	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/phys_state_var_mod.F90	(revision 1813)
@@ -332,6 +332,6 @@
       REAL,SAVE,ALLOCATABLE :: newsst(:)
 !$OMP THREADPRIVATE(newsst)
-      REAL,SAVE,ALLOCATABLE :: ustar(:,:),u10m(:,:), v10m(:,:)
-!$OMP THREADPRIVATE(ustar,u10m,v10m)
+      REAL,SAVE,ALLOCATABLE :: ustar(:,:),u10m(:,:), v10m(:,:),wstar(:,:)
+!$OMP THREADPRIVATE(ustar,u10m,v10m,wstar)
 !
 ! ok_ade=T -ADE=topswad-topsw
@@ -508,5 +508,5 @@
       ALLOCATE(rlonPOS(klon))
       ALLOCATE(newsst(klon))
-      ALLOCATE(ustar(klon,nbsrf),u10m(klon,nbsrf), v10m(klon,nbsrf))
+      ALLOCATE(ustar(klon,nbsrf),u10m(klon,nbsrf), v10m(klon,nbsrf),wstar(klon,nbsrf+1))
       ALLOCATE(topswad(klon), solswad(klon))
       ALLOCATE(topswai(klon), solswai(klon))
@@ -619,5 +619,5 @@
       deallocate(rlonPOS)
       deallocate(newsst)
-      deallocate(ustar,u10m, v10m)
+      deallocate(ustar,u10m, v10m,wstar)
       deallocate(topswad, solswad)
       deallocate(topswai, solswai)
Index: LMDZ5/trunk/libf/phylmd/physiq.F
===================================================================
--- LMDZ5/trunk/libf/phylmd/physiq.F	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/physiq.F	(revision 1813)
@@ -50,4 +50,5 @@
 #endif
       USE indice_sol_mod
+      USE phytrac_mod, ONLY : phytrac
 
 !IM stations CFMIP
@@ -1523,8 +1524,10 @@
 c$OMP BARRIER
 
+#undef histISCCP
 #ifdef histISCCP
 #include "ini_histISCCP.h"
 #endif
 
+#undef histNMC
 #ifdef histNMC
 #include "ini_histhfNMC.h"
@@ -3637,4 +3640,5 @@
        END IF
 
+      wstar=0. ! FH 2013/07/22 a corriger des que dans pbl_surface_mod
       call phytrac (
      I     itap,     days_elapsed+1,    jH_cur,   debut,
@@ -3642,7 +3646,8 @@
      I     paprs,    pplay,     pmfu,     pmfd,
      I     pen_u,    pde_u,     pen_d,    pde_d,
-     I     cdragh,   coefh(:,:,is_ave),     fm_therm, entr_therm,
+     I     cdragh,   coefh(:,:,is_ave),   fm_therm, entr_therm,
      I     u1,       v1,        ftsol,    pctsrf,
-     I     ustar,     u10m,      v10m,
+     I     zustar,   zu10m,     zv10m,
+     I     wstar(:,is_ave),    ale_bl_stat,         ale_wake,
      I     rlat,     rlon,
      I     frac_impa,frac_nucl, beta_prec_fisrt,beta_prec,
Index: LMDZ5/trunk/libf/phylmd/phytrac_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phytrac_mod.F90	(revision 1813)
+++ LMDZ5/trunk/libf/phylmd/phytrac_mod.F90	(revision 1813)
@@ -0,0 +1,758 @@
+!$Id $
+!$Id $
+MODULE phytrac_mod
+!=================================================================================
+! Interface between the LMDZ physical package and tracer computation.
+! Chemistry modules (INCA, Reprobus or the more specific traclmdz routine)
+! are called from phytrac.
+!
+!======================================================================
+! Auteur(s) FH
+! Objet: Moniteur general des tendances traceurs
+!
+! iflag_vdf_trac : Options for activating transport by vertical diffusion :
+!     1. notmal
+!     0. emission is injected in the first layer only, without diffusion
+!    -1  no emission & no diffusion
+! Modification 2013/07/22 : transformed into a module to pass tendencies to
+!     physics outputs. Additional keys for controling activation of sub processes.
+! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
+! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
+!=================================================================================
+
+!
+! Tracer tendencies, for outputs
+!-------------------------------
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_cl  ! Td couche limite/traceur
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_dec                            !RomP
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_cv  ! Td convection/traceur
+! RomP >>>
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_insc
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_bcscav
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_evapls
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_ls
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_trsp
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_sscav
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_sat
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_uscav
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qPr,qDi ! concentration tra dans pluie,air descente insaturee
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qPa,qMel
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qTrdi,dtrcvMA ! conc traceur descente air insaturee et td convective MA
+! RomP <<<
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_th  ! Td thermique
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_lessi_impa ! Td du lessivage par impaction
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_lessi_nucl ! Td du lessivage par nucleation
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE      :: qPrls      !jyg: concentration tra dans pluie LS a la surf.
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE      :: d_tr_dry ! Td depot sec/traceur (1st layer),ALLOCATABLE,SAVE  jyg
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE      :: flux_tr_dry ! depot sec/traceur (surface),ALLOCATABLE,SAVE    jyg
+
+!$OMP THREADPRIVATE(qPa,qMel,qTrdi,dtrcvMA,d_tr_th,d_tr_lessi_impa,d_tr_lessi_nucl)
+!$OMP THREADPRIVATE(d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qPr,qDi)
+!$OMP THREADPRIVATE(d_tr_insc,d_tr_bcscav,d_tr_evapls,d_tr_ls,qPrls)
+!$OMP THREADPRIVATE(d_tr,d_tr_cl,d_tr_dry,flux_tr_dry,d_tr_dec,d_tr_cv)
+
+
+CONTAINS
+
+SUBROUTINE phytrac(                            &
+     nstep,     julien,   gmtime,   debutphy,  &
+     lafin,     pdtphys,  u, v,     t_seri,    &
+     paprs,     pplay,    pmfu,     pmfd,      &
+     pen_u,     pde_u,    pen_d,    pde_d,     &
+     cdragh,    coefh,    fm_therm, entr_therm,&
+     yu1,       yv1,      ftsol,    pctsrf,    &
+     ustar,     u10m,      v10m,               &
+     wstar,     ale_bl,      ale_wake,         &
+     xlat,      xlon,                          &
+     frac_impa,frac_nucl,beta_fisrt,beta_v1,   &
+     presnivs,  pphis,    pphi,     albsol,    &
+     sh,        rh,       cldfra,   rneb,      &
+     diafra,    cldliq,   itop_con, ibas_con,  &
+     pmflxr,    pmflxs,   prfl,     psfl,      &
+     da,        phi,      mp,       upwd,      &
+     phi2,      d1a,      dam,      sij,       &   ! RomP
+     wdtrainA,  wdtrainM, sigd,     clw,elij,  &   ! RomP 
+     evap,      ep,       epmlmMm,  eplaMm,    &   ! RomP
+     dnwd,      aerosol_couple,     flxmass_w, &
+     tau_aero,  piz_aero,  cg_aero, ccm,       &
+     rfname,                                   &
+     d_tr_dyn,                                 &   ! RomP
+     tr_seri)         
+!
+!======================================================================
+! Auteur(s) FH
+! Objet: Moniteur general des tendances traceurs
+! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
+! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
+!======================================================================
+
+  USE ioipsl
+  USE phys_cal_mod, only : hour
+  USE dimphy
+  USE infotrac
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  USE comgeomphy
+  USE iophy
+  USE traclmdz_mod
+  USE tracinca_mod
+  USE tracreprobus_mod
+  USE control_mod
+  USE indice_sol_mod
+
+  IMPLICIT NONE
+
+  INCLUDE "YOMCST.h"
+  INCLUDE "dimensions.h"
+  INCLUDE "clesphys.h"
+  INCLUDE "temps.h"
+  INCLUDE "paramet.h"
+  INCLUDE "thermcell.h"
+  INCLUDE "iniprint.h"
+!==========================================================================
+!                   -- ARGUMENT DESCRIPTION --
+!==========================================================================
+
+! Input arguments
+!----------------
+!Configuration grille,temps:
+  INTEGER,INTENT(IN) :: nstep      ! Appel physique
+  INTEGER,INTENT(IN) :: julien     ! Jour julien
+  REAL,INTENT(IN)    :: gmtime     ! Heure courante
+  REAL,INTENT(IN)    :: pdtphys    ! Pas d'integration pour la physique (seconde)
+  LOGICAL,INTENT(IN) :: debutphy   ! le flag de l'initialisation de la physique
+  LOGICAL,INTENT(IN) :: lafin      ! le flag de la fin de la physique
+  
+  REAL,DIMENSION(klon),INTENT(IN) :: xlat    ! latitudes pour chaque point 
+  REAL,DIMENSION(klon),INTENT(IN) :: xlon    ! longitudes pour chaque point 
+!
+!Physique: 
+!--------
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
+  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
+  REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay   ! pression pour le mileu de chaque couche (en Pa)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pphi    ! geopotentiel
+  REAL,DIMENSION(klon),INTENT(IN)        :: pphis
+  REAL,DIMENSION(klev),INTENT(IN)        :: presnivs 
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau liquide nuageuse
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldfra  ! fraction nuageuse (tous les nuages)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: rneb    ! fraction nuageuse (grande echelle)
+!
+  REAL                                   :: ql_incl ! contenu en eau liquide nuageuse dans le nuage ! ql_incl=oliq/rneb
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: beta_fisrt ! taux de conversion de l'eau cond (de fisrtilp)
+  REAL,DIMENSION(klon,klev),INTENT(out)  :: beta_v1    ! -- (originale version)
+
+!
+  INTEGER,DIMENSION(klon),INTENT(IN)     :: itop_con
+  INTEGER,DIMENSION(klon),INTENT(IN)     :: ibas_con
+  REAL,DIMENSION(klon),INTENT(IN)        :: albsol  ! albedo surface
+!
+!Dynamique
+!--------
+  REAL,DIMENSION(klon,klev,nbtr),INTENT(IN)    :: d_tr_dyn
+!
+!Convection:
+!----------
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfu  ! flux de masse dans le panache montant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfd  ! flux de masse dans le panache descendant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_u ! flux entraine dans le panache montant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_u ! flux detraine dans le panache montant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_d ! flux entraine dans le panache descendant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_d ! flux detraine dans le panache descendant
+
+!...Tiedke     
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: pmflxr, pmflxs ! Flux precipitant de pluie, neige aux interfaces [convection]
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: prfl, psfl ! Flux precipitant de pluie, neige aux interfaces [large-scale]
+
+  LOGICAL,INTENT(IN)                       :: aerosol_couple
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: flxmass_w
+  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: tau_aero
+  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: piz_aero
+  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: cg_aero
+  CHARACTER(len=4),DIMENSION(9),INTENT(IN) :: rfname 
+  REAL,DIMENSION(klon,klev,2),INTENT(IN)   :: ccm 
+!... K.Emanuel
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: da
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN):: phi
+! RomP >>>
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: d1a,dam
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: phi2
+!
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainA
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainM
+  REAL,DIMENSION(klon),INTENT(IN)           :: sigd
+! ---- RomP flux entraine, detraine et precipitant kerry Emanuel
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: evap
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: ep
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: sij
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: elij
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: epmlmMm
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: eplaMm
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: clw
+! RomP <<<
+
+!
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: mp
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: upwd      ! saturated updraft mass flux
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: dnwd      ! saturated downdraft mass flux
+!
+!Thermiques:
+!----------
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: fm_therm
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: entr_therm
+!
+!Couche limite:
+!--------------
+!
+!
+  REAL,DIMENSION(:),INTENT(IN)   :: cdragh          ! (klon) coeff drag pour T et Q
+  REAL,DIMENSION(:,:),INTENT(IN) :: coefh           ! (klon,klev) coeff melange CL (m**2/s)
+  REAL,DIMENSION(:),INTENT(IN)   :: ustar,u10m,v10m ! (klon) u* & vent a 10m (m/s)
+  REAL,DIMENSION(:),INTENT(IN)   :: wstar,ale_bl,ale_wake ! (klon) w* and Avail. Lifting Ener.
+  REAL,DIMENSION(:),INTENT(IN)   :: yu1             ! (klon) vents au premier niveau
+  REAL,DIMENSION(:),INTENT(IN)   :: yv1             ! (klon) vents au premier niveau
+
+!
+!Lessivage:
+!----------
+!
+! pour le ON-LINE
+!
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_impa ! fraction d'aerosols non impactes
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_nucl ! fraction d'aerosols non nuclees
+
+! Arguments necessaires pour les sources et puits de traceur:
+  REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: ftsol  ! Temperature du sol (surf)(Kelvin)
+  REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol (nature du sol)
+
+
+! Output argument
+!----------------
+  REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT) :: tr_seri ! Concentration Traceur [U/KgA]
+  REAL,DIMENSION(klon,klev)                    :: sourceBE 
+!=======================================================================================
+!                        -- LOCAL VARIABLES --
+!=======================================================================================
+
+  INTEGER :: i, k, it
+  INTEGER :: nsplit
+
+!Sources et Reservoirs de traceurs (ex:Radon):
+!--------------------------------------------
+!
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE :: source  ! a voir lorsque le flux de surface est prescrit
+!$OMP THREADPRIVATE(source)
+
+!
+!Entrees/Sorties: (cf ini_histrac.h et write_histrac.h)  
+!---------------
+  INTEGER                   :: iiq, ierr
+  INTEGER                   :: nhori, nvert
+  REAL                      :: zsto, zout, zjulian
+  INTEGER,SAVE              :: nid_tra     ! pointe vers le fichier histrac.nc         
+!$OMP THREADPRIVATE(nid_tra)
+  REAL,DIMENSION(klon)      :: zx_tmp_fi2d ! variable temporaire grille physique
+  INTEGER                   :: itau_w      ! pas de temps ecriture = nstep + itau_phy
+  LOGICAL,PARAMETER         :: ok_sync=.TRUE.
+!$OMP THREADPRIVATE(chtratimestep)
+!
+! Nature du traceur
+!------------------
+  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: aerosol  ! aerosol(it) = true  => aerosol => lessivage
+!$OMP THREADPRIVATE(aerosol)                        ! aerosol(it) = false => gaz
+  REAL,DIMENSION(klon,klev)             :: delp     ! epaisseur de couche (Pa)
+!
+! Tendances de traceurs (Td) et flux de traceurs:
+!------------------------
+  REAL,DIMENSION(klon,klev)      :: d_tr     ! Td dans l'atmosphere
+  REAL,DIMENSION(klon,klev)      :: Mint
+  REAL,DIMENSION(klon,klev,nbtr) :: zmfd1a
+  REAL,DIMENSION(klon,klev,nbtr) :: zmfdam
+  REAL,DIMENSION(klon,klev,nbtr) :: zmfphi2
+! Physique
+!---------- 
+  REAL,DIMENSION(klon,klev,nbtr) :: flestottr ! flux de lessivage dans chaque couche 
+  REAL,DIMENSION(klon,klev)      :: zmasse    ! densité atmosphérique Kg/m2
+  REAL,DIMENSION(klon,klev)      :: ztra_th
+!PhH
+  REAL,DIMENSION(klon,klev)      :: zrho
+  REAL,DIMENSION(klon,klev)      :: zdz
+  REAL                           :: evaplsc,dx,beta ! variable pour lessivage Genthon
+  REAL,DIMENSION(klon)           :: his_dh          ! ---
+! in-cloud scav variables
+  REAL           :: ql_incloud_ref     ! ref value of in-cloud condensed water content
+  
+!Controles:
+!---------
+  INTEGER,SAVE :: iflag_vdf_trac,iflag_con_trac,iflag_the_trac
+  INTEGER :: iflag_con_trac_omp, iflag_vdf_trac_omp,iflag_the_trac_omp
+!$OMP THREADPRIVATE(iflag_lscav,convscav,iflag_the_trac)
+
+  LOGICAL,SAVE :: lessivage
+!$OMP THREADPRIVATE(lessivage)
+
+  CHARACTER(len=8),DIMENSION(nbtr) :: solsym
+!RomP >>>
+  INTEGER,SAVE  :: iflag_lscav_omp,iflag_lscav
+  LOGICAL,SAVE  :: convscav_omp,convscav
+!$OMP THREADPRIVATE(iflag_lscav,convscav)
+!RomP <<<
+!######################################################################
+!                    -- INITIALIZATION --
+!######################################################################
+IF (debutphy) THEN
+ALLOCATE(d_tr_cl(klon,klev,nbtr),d_tr_dry(klon,nbtr))
+ALLOCATE(flux_tr_dry(klon,nbtr),d_tr_dec(klon,klev,nbtr),d_tr_cv(klon,klev,nbtr))
+ALLOCATE(d_tr_insc(klon,klev,nbtr),d_tr_bcscav(klon,klev,nbtr))
+ALLOCATE(d_tr_evapls(klon,klev,nbtr),d_tr_ls(klon,klev,nbtr))
+ALLOCATE(qPrls(klon,nbtr),d_tr_trsp(klon,klev,nbtr))
+ALLOCATE(d_tr_sscav(klon,klev,nbtr),d_tr_sat(klon,klev,nbtr))
+ALLOCATE(d_tr_uscav(klon,klev,nbtr),qPr(klon,klev,nbtr),qDi(klon,klev,nbtr))
+ALLOCATE(qPa(klon,klev,nbtr),qMel(klon,klev,nbtr))
+ALLOCATE(qTrdi(klon,klev,nbtr),dtrcvMA(klon,klev,nbtr))
+ALLOCATE(d_tr_th(klon,klev,nbtr))
+ALLOCATE(d_tr_lessi_impa(klon,klev,nbtr),d_tr_lessi_nucl(klon,klev,nbtr))
+ENDIF
+
+  DO k=1,klev
+     DO i=1,klon
+      sourceBE(i,k)=0.
+      Mint(i,k)=0.
+      zrho(i,k)=0.
+      zdz(i,k)=0.
+     END DO
+  END DO
+
+  DO it=1, nbtr
+   DO k=1,klev
+    DO i=1,klon
+    d_tr_insc(i,k,it)=0.
+    d_tr_bcscav(i,k,it)=0.
+    d_tr_evapls(i,k,it)=0.
+    d_tr_ls(i,k,it)=0.
+    d_tr_cv(i,k,it)=0.
+    d_tr_cl(i,k,it)=0.
+    d_tr_trsp(i,k,it)=0.
+    d_tr_sscav(i,k,it)=0.
+    d_tr_sat(i,k,it)=0.
+    d_tr_uscav(i,k,it)=0.
+    d_tr_lessi_impa(i,k,it)=0.
+    d_tr_lessi_nucl(i,k,it)=0.
+    qDi(i,k,it)=0.
+    qPr(i,k,it)=0.
+    qPa(i,k,it)=0.
+    qMel(i,k,it)=0.
+    qTrdi(i,k,it)=0.
+    dtrcvMA(i,k,it)=0.
+    zmfd1a(i,k,it)=0.
+    zmfdam(i,k,it)=0.
+    zmfphi2(i,k,it)=0.
+    END DO
+   END DO
+  END DO
+  IF (debutphy) THEN
+!!jyg
+!$OMP BARRIER
+   ecrit_tra=86400. ! frequence de stokage en dur
+                    ! obsolete car remplace par des ecritures dans phys_output_write
+!RomP >>>
+!
+!Config Key  = convscav
+!Config Desc = Convective scavenging switch: 0=off, 1=on.
+!Config Def  = .false.
+!Config Help = 
+!
+!$OMP MASTER
+  convscav_omp=.false.
+  call getin('convscav', convscav_omp)
+  iflag_vdf_trac_omp=1
+  call getin('iflag_vdf_trac', iflag_vdf_trac_omp)
+  iflag_con_trac_omp=1
+  call getin('iflag_con_trac', iflag_con_trac_omp)
+  iflag_the_trac_omp=1
+  call getin('iflag_the_trac', iflag_the_trac_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+  convscav=convscav_omp
+  iflag_vdf_trac=iflag_vdf_trac_omp
+  iflag_con_trac=iflag_con_trac_omp
+  iflag_the_trac=iflag_the_trac_omp
+  print*,'phytrac passage dans routine conv avec lessivage', convscav
+!
+!Config Key  = iflag_lscav
+!Config Desc = Large scale scavenging parametrization: 0=none, 1=old(Genthon92),
+!              2=1+PHeinrich, 3=Reddy_Boucher2004, 4=3+RPilon.
+!Config Def  = 1
+!Config Help = 
+!
+!$OMP MASTER
+  iflag_lscav_omp=1
+  call getin('iflag_lscav', iflag_lscav_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+  iflag_lscav=iflag_lscav_omp
+!
+  SELECT CASE(iflag_lscav)
+  CASE(0)
+   PRINT*, 'Large scale scavenging: none'
+  CASE(1)
+   PRINT*, 'Large scale scavenging: C. Genthon, Tellus(1992), 44B, 371-389'
+  CASE(2)
+   PRINT*, 'Large scale scavenging: C. Genthon, modified P. Heinrich'
+  CASE(3)
+   PRINT*, 'Large scale scavenging: M. Shekkar Reddy and O. Boucher, JGR(2004), 109, D14202'
+  CASE(4)
+   PRINT*, 'Large scale scavenging: Reddy and Boucher, modified R. Pilon'
+  END SELECT
+!RomP <<<
+     WRITE(*,*) 'FIRST TIME IN PHYTRAC : pdtphys(sec) = ',pdtphys,'ecrit_tra (sec) = ',ecrit_tra
+     ALLOCATE( source(klon,nbtr), stat=ierr)
+     IF (ierr /= 0) CALL abort_gcm('phytrac', 'pb in allocation 1',1)
+     
+     ALLOCATE( aerosol(nbtr), stat=ierr)
+     IF (ierr /= 0) CALL abort_gcm('phytrac', 'pb in allocation 2',1)
+     
+
+     ! Initialize module for specific tracers
+     SELECT CASE(type_trac)
+     CASE('lmdz')
+        CALL traclmdz_init(pctsrf, xlat, xlon, ftsol, tr_seri, t_seri, pplay, sh, pdtphys, aerosol, lessivage)
+     CASE('inca')
+        source(:,:)=0.
+        CALL tracinca_init(aerosol,lessivage)
+     CASE('repr')
+        source(:,:)=0.
+     END SELECT
+!
+! Initialize diagnostic output
+! ----------------------------
+#ifdef CPP_IOIPSL
+!     INCLUDE "ini_histrac.h"
+#endif
+  END IF ! of IF (debutphy)
+!############################################ END INITIALIZATION #######
+
+  DO k=1,klev
+     DO i=1,klon
+        zmasse(i,k)=(paprs(i,k)-paprs(i,k+1))/rg
+     END DO
+  END DO
+!
+  IF (id_be .GT. 0) THEN
+  DO k=1,klev
+     DO i=1,klon
+        sourceBE(i,k)=srcbe(i,k)       !RomP  -> pour sortie histrac
+     END DO
+  END DO
+  ENDIF
+
+!===============================================================================
+!    -- Do specific treatment according to chemestry model or local LMDZ tracers
+!      
+!===============================================================================
+  SELECT CASE(type_trac)
+  CASE('lmdz')
+     !    -- Traitement des traceurs avec traclmdz
+     CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
+          cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon,iflag_vdf_trac>=0,sh, &
+           rh, pphi, ustar, wstar, ale_bl, ale_wake,  u10m, v10m, &
+           tr_seri, source, solsym, d_tr_cl,d_tr_dec, zmasse)               !RomP
+
+  CASE('inca')
+     !    -- CHIMIE INCA  config_inca = aero or chem --
+
+     CALL tracinca(&
+          nstep,    julien,   gmtime,         lafin,     &
+          pdtphys,  t_seri,   paprs,          pplay,     &
+          pmfu,     ftsol,    pctsrf,         pphis,     &
+          pphi,     albsol,   sh,             rh,        &
+          cldfra,   rneb,     diafra,         cldliq,    &
+          itop_con, ibas_con, pmflxr,         pmflxs,    &
+          prfl,     psfl,     aerosol_couple, flxmass_w, &
+          tau_aero, piz_aero, cg_aero,        ccm,       &
+          rfname,                                        &
+          tr_seri,  source,   solsym)      
+
+  CASE('repr')
+     !   -- CHIMIE REPROBUS --
+
+     CALL tracreprobus(pdtphys, gmtime, debutphy, julien, &
+          presnivs, xlat, xlon, pphis, pphi, &
+          t_seri, pplay, paprs, sh , &
+          tr_seri, solsym)
+     
+  END SELECT
+!======================================================================
+!       -- Calcul de l'effet de la convection --
+!======================================================================
+
+  IF (iflag_con_trac==1) THEN
+     DO it=1, nbtr
+        IF ( conv_flg(it) == 0 ) CYCLE
+        IF (iflag_con.LT.2) THEN
+           d_tr_cv(:,:,it)=0.
+        ELSE IF (iflag_con.EQ.2) THEN
+!..Tiedke
+           CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
+                pplay, paprs, tr_seri(:,:,it), d_tr_cv(:,:,it))
+! RomP >>>                
+        ELSE   
+!..K.Emanuel                  !RomP modif arg
+        if (convscav.and.aerosol(it)) then    ! lessivage convectif pour aerosol
+!
+          CALL cvltr(pdtphys, da, phi,phi2,d1a,dam, mp,ep,              &
+               sigd,sij,clw,elij,epmlmMm,eplaMm,                        &
+               pmflxr,pmflxs,evap,t_seri,wdtrainA,wdtrainM,             &   
+               paprs,it,tr_seri,upwd,dnwd,itop_con,ibas_con,            &
+               d_tr_cv,d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qDi,qPr,&
+               qPa,qMel,qTrdi,dtrcvMA,Mint,                             &
+               zmfd1a,zmfphi2,zmfdam)
+        else  !pas de lessivage convectif ou n'est pas un aerosol
+           CALL cvltrorig(it,pdtphys, da, phi,mp,paprs,pplay,tr_seri,&
+                    upwd,dnwd,d_tr_cv)
+        endif
+        END IF
+! RomP <<<
+
+        DO k = 1, klev
+           DO i = 1, klon        
+              tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cv(i,k,it)
+           END DO
+        END DO
+
+        CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'convection it = '//solsym(it))
+             
+     END DO ! nbtr
+  END IF ! convection
+
+!======================================================================
+!    -- Calcul de l'effet des thermiques --
+!======================================================================
+
+  DO it=1,nbtr
+     DO k=1,klev
+        DO i=1,klon
+           d_tr_th(i,k,it)=0.
+           tr_seri(i,k,it)=MAX(tr_seri(i,k,it),0.)
+           tr_seri(i,k,it)=MIN(tr_seri(i,k,it),1.e10)
+        END DO
+     END DO
+  END DO
+  
+  IF (iflag_thermals.GT.0.AND.iflag_the_trac>0) THEN   
+     nsplit=10
+     DO it=1, nbtr
+        DO isplit=1,nsplit
+
+           CALL dqthermcell(klon,klev,pdtphys/nsplit, &
+                fm_therm,entr_therm,zmasse, &
+                tr_seri(1:klon,1:klev,it),d_tr,ztra_th)
+
+           DO k=1,klev
+              DO i=1,klon
+                 d_tr(i,k)=pdtphys*d_tr(i,k)/nsplit
+                 d_tr_th(i,k,it)=d_tr_th(i,k,it)+d_tr(i,k)
+                 tr_seri(i,k,it)=MAX(tr_seri(i,k,it)+d_tr(i,k),0.)
+              END DO
+           END DO
+        END DO ! nsplit
+     END DO ! it
+  END IF ! Thermiques
+
+!======================================================================
+!     -- Calcul de l'effet de la couche limite --
+!======================================================================
+
+  DO k = 1, klev
+     DO i = 1, klon
+        delp(i,k) = paprs(i,k)-paprs(i,k+1)
+     END DO
+  END DO
+
+  IF (iflag_vdf_trac==1) THEN
+     DO it=1, nbtr
+        print*,'trac pbl ',it,pbl_flg(it)
+        IF( pbl_flg(it) /= 0 ) THEN
+           CALL cltrac(pdtphys, coefh,t_seri,       &
+                tr_seri(:,:,it), source(:,it),      &
+                paprs, pplay, delp,                 &
+                d_tr_cl(:,:,it),d_tr_dry(:,it),flux_tr_dry(:,it))
+           tr_seri(:,:,it)=tr_seri(:,:,it)+d_tr_cl(:,:,it)
+        END IF
+     END DO
+  ELSE IF (iflag_vdf_trac==0) THEN
+!   Injection of source in the first model layer
+    DO it=1,nbtr
+       d_tr_cl(:,1,it)=source(:,it)*rg/delp(:,1)*pdtphys
+    ENDDO
+    tr_seri(:,1,it)=tr_seri(:,1,it)+d_tr_cl(:,1,it)
+    d_tr_cl(:,2:klev,1:nbtr)=0.
+  ELSE IF (iflag_vdf_trac==-1) THEN
+    d_tr_cl=0.
+  ELSE
+    CALL abort_gcm('iflag_vdf_trac', 'cas non prevu',1)
+  END IF ! couche limite
+
+
+
+!======================================================================
+!   Calcul de l'effet de la precipitation grande echelle
+!======================================================================
+  IF (lessivage) THEN
+
+   ql_incloud_ref = 10.e-4
+   ql_incloud_ref =  5.e-4
+
+
+! calcul du contenu en eau liquide au sein du nuage
+     ql_incl = ql_incloud_ref
+! choix du lessivage
+!
+  IF (iflag_lscav .EQ. 3 .OR. iflag_lscav .EQ. 4) THEN
+! ********  Olivier Boucher version (3) possibly with modified ql_incl (4)
+!
+   DO it = 1, nbtr
+!  incloud scavenging and removal by large scale rain ! orig : ql_incl was replaced by 0.5e-3 kg/kg
+! the value 0.5e-3 kg/kg is from Giorgi and Chameides (1986), JGR
+! Liu (2001) proposed to use 1.5e-3 kg/kg
+
+    CALL lsc_scav(pdtphys,it,iflag_lscav,ql_incl,prfl,psfl,rneb,beta_fisrt,  &
+                  beta_v1,pplay,paprs,t_seri,tr_seri,d_tr_insc,   &
+                  d_tr_bcscav,d_tr_evapls,qPrls)
+
+!large scale scavenging tendency
+   DO k = 1, klev
+    DO i = 1, klon
+    d_tr_ls(i,k,it)=d_tr_insc(i,k,it)+d_tr_bcscav(i,k,it)+d_tr_evapls(i,k,it)
+    tr_seri(i,k,it)=tr_seri(i,k,it)+d_tr_ls(i,k,it)
+    ENDDO
+   ENDDO
+     CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'lsc scav it = '//solsym(it))
+   END DO  !tr
+
+ ELSE IF (iflag_lscav .EQ. 2) THEN ! frac_impa, frac_nucl
+! *********   modified  old version
+
+     d_tr_lessi_nucl(:,:,:) = 0. 
+     d_tr_lessi_impa(:,:,:) = 0.
+     flestottr(:,:,:) = 0. 
+! Tendance des aerosols nuclees et impactes 
+     DO it = 1, nbtr
+        IF (aerosol(it)) THEN
+        his_dh(:)=0.
+           DO k = 1, klev
+              DO i = 1, klon
+!PhH
+              zrho(i,k)=pplay(i,k)/t_seri(i,k)/RD
+              zdz(i,k)=(paprs(i,k)-paprs(i,k+1))/zrho(i,k)/RG
+!
+              END DO
+           END DO
+
+          DO k=klev-1, 1, -1
+            DO i=1, klon
+!             d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.)
+             dx=d_tr_ls(i,k,it)
+             his_dh(i)=his_dh(i)-dx*zrho(i,k)*zdz(i,k)/pdtphys !  kg/m2/s
+             evaplsc = prfl(i,k) - prfl(i,k+1) + psfl(i,k) - psfl(i,k+1)
+! Evaporation Partielle -> Liberation Partielle 0.5*evap
+            IF ( evaplsc .LT.0..and.abs(prfl(i,k+1)+psfl(i,k+1)).gt.1.e-10) THEN
+                evaplsc = (-evaplsc)/(prfl(i,k+1)+psfl(i,k+1))
+! evaplsc est donc positif, his_dh(i) est positif
+!--------------  
+             d_tr_evapls(i,k,it)=0.5*evaplsc*(d_tr_lessi_nucl(i,k+1,it) &
+                                  +d_tr_lessi_impa(i,k+1,it))
+!-------------   d_tr_evapls(i,k,it)=-0.5*evaplsc*(d_tr_lsc(i,k+1,it))
+             beta=0.5*evaplsc
+              if ((prfl(i,k)+psfl(i,k)).lt.1.e-10) THEN
+               beta=1.0*evaplsc
+              endif
+            dx=beta*his_dh(i)/zrho(i,k)/zdz(i,k)*pdtphys
+            his_dh(i)=(1.-beta)*his_dh(i)   ! tracer from
+            d_tr_evapls(i,k,it)=dx
+            ENDIF
+            d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.) &
+                            +d_tr_evapls(i,k,it)
+
+!--------------
+                 d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
+                      ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
+                 d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
+                      ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
+!
+! Flux lessivage total 
+                 flestottr(i,k,it) = flestottr(i,k,it) -   &
+                      ( d_tr_lessi_nucl(i,k,it)   +        &
+                      d_tr_lessi_impa(i,k,it) ) *          &
+                      ( paprs(i,k)-paprs(i,k+1) ) /        &
+                      (RG * pdtphys)
+!! Mise a jour des traceurs due a l'impaction,nucleation 
+!                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
+!!  calcul de la tendance liee au lessivage stratiforme
+!                 d_tr_ls(i,k,it)=tr_seri(i,k,it)*&
+!                                (1.-1./(frac_impa(i,k)*frac_nucl(i,k)))
+!--------------
+              END DO
+           END DO
+        END IF
+     END DO
+! *********   end modified old version
+
+ ELSE IF (iflag_lscav .EQ. 1) THEN ! frac_impa, frac_nucl
+! *********    old version
+
+     d_tr_lessi_nucl(:,:,:) = 0. 
+     d_tr_lessi_impa(:,:,:) = 0.
+     flestottr(:,:,:) = 0. 
+!=========================
+! LESSIVAGE LARGE SCALE : 
+!=========================
+
+! Tendance des aerosols nuclees et impactes 
+! -----------------------------------------
+     DO it = 1, nbtr
+        IF (aerosol(it)) THEN
+           DO k = 1, klev
+              DO i = 1, klon
+                 d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
+                      ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
+                 d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
+                      ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
+
+!
+! Flux lessivage total 
+! ------------------------------------------------------------
+                 flestottr(i,k,it) = flestottr(i,k,it) -   &
+                      ( d_tr_lessi_nucl(i,k,it)   +        &
+                      d_tr_lessi_impa(i,k,it) ) *          &
+                      ( paprs(i,k)-paprs(i,k+1) ) /        &
+                      (RG * pdtphys)
+!
+! Mise a jour des traceurs due a l'impaction,nucleation 
+! ----------------------------------------------------------------------
+                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
+              END DO
+           END DO
+        END IF
+     END DO
+     
+! *********   end old version
+  ENDIF  !  iflag_lscav . EQ. 1, 2, 3 or 4
+!
+  END IF !  lessivage
+
+!=============================================================
+!   Ecriture des sorties
+!=============================================================
+#ifdef CPP_IOIPSL
+! INCLUDE "write_histrac.h"
+#endif
+
+END SUBROUTINE phytrac
+
+END MODULE
Index: LMDZ5/trunk/libf/phylmd/traclmdz_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/traclmdz_mod.F90	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/traclmdz_mod.F90	(revision 1813)
@@ -337,5 +337,5 @@
   SUBROUTINE traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
        cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon, couchelimite, sh, &
-       rh, pphi, ustar, zu10m, zv10m, &
+       rh, pphi, ustar, wstar, ale_bl, ale_wake,  zu10m, zv10m, &
 !!          tr_seri, source, solsym, d_tr_cl, zmasse)                      !RomP
           tr_seri, source, solsym, d_tr_cl,d_tr_dec, zmasse)               !RomP
@@ -385,4 +385,5 @@
     REAL,DIMENSION(klon,klev),INTENT(IN) :: pphi    ! geopotentie
     REAL,DIMENSION(klon),INTENT(IN)      :: ustar   ! ustar (m/s)
+    REAL,DIMENSION(klon),INTENT(IN)      :: wstar,ale_bl,ale_wake   ! wstar (m/s) and Avail. Lifti. Energ.
     REAL,DIMENSION(klon),INTENT(IN)      :: zu10m   ! vent zonal 10m (m/s)
     REAL,DIMENSION(klon),INTENT(IN)      :: zv10m   ! vent zonal 10m (m/s)
Index: LMDZ5/trunk/libf/phylmd/write_histrac.h
===================================================================
--- LMDZ5/trunk/libf/phylmd/write_histrac.h	(revision 1811)
+++ LMDZ5/trunk/libf/phylmd/write_histrac.h	(revision 1813)
@@ -45,5 +45,5 @@
 
 ! TD COUCHE-LIMITE
-      IF (couchelimite) THEN
+      IF (iflag_vdf_trac>=0) THEN
         CALL histwrite_phy(nid_tra,.FALSE.,"d_tr_cl_"//tname(iiq),itau_w,d_tr_cl(:,:,it))
         CALL histwrite_phy(nid_tra,.FALSE.,"d_tr_dry_"//tname(iiq),itau_w,d_tr_dry(:,it))
