Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/YOMCST.inc
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/YOMCST.inc	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/YOMCST.inc	(revision 230)
@@ -20,13 +20,7 @@
       REAL :: RALPD,RBETD,RGAMD
 !
-      COMMON/YOMCST/RPI   ,RCLUM ,RHPLA ,RKBOL ,RNAVO &
-     &      ,RDAY  ,REA   ,REPSM ,RSIYEA,RSIDAY,ROMEGA &
-     &      ,R_ecc, R_peri, R_incl &
-     &      ,RA    ,RG    ,R1SA &
-     &      ,RSIGMA,RI0 &
-     &      ,R     ,RMD   ,RMV   ,RD    ,RV    ,RCPD &
-     &      ,RCPV  ,RCVD  ,RCVV  ,RKAPPA,RETV &
-     &      ,RCW   ,RCS &
-     &      ,RLVTT ,RLSTT ,RLMLT ,RTT   ,RATM &
-     &      ,RESTT ,RALPW ,RBETW ,RGAMW ,RALPS ,RBETS ,RGAMS &
-     &      ,RALPD ,RBETD ,RGAMD
+      COMMON/YOMCST/RPI ,RCLUM, RHPLA, RKBOL, RNAVO ,RDAY  ,REA &
+     & ,REPSM ,RSIYEA,RSIDAY,ROMEGA ,R_ecc, R_peri, R_incl, RA    ,RG &
+     & ,R1SA ,RSIGMA,RI0,R ,RMD   ,RMV   ,RD    ,RV    ,RCPD ,RCPV,RCVD &
+     & ,RCVV  ,RKAPPA,RETV ,RCW   ,RCS ,RLVTT ,RLSTT ,RLMLT ,RTT ,RATM &
+     & ,RESTT ,RALPW ,RBETW ,RGAMW ,RALPS ,RBETS ,RGAMS ,RALPD ,RBETD ,RGAMD
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/clmain.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/clmain.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/clmain.F	(revision 230)
@@ -1,2 +1,6 @@
+c
+c $Header$
+c
+
       SUBROUTINE clmain(dtime,itap,date0,pctsrf,
      .                  t,q,u,v,
@@ -728,5 +732,4 @@
       ENDDO
       ENDDO
-
       DO i = 1, knon
          zx_buf1(i) = zx_coef(i,klev) + delp(i,klev)
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/condsurf.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/condsurf.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/condsurf.F	(revision 230)
@@ -1,2 +1,4 @@
+c $Header$
+c
       SUBROUTINE condsurf( jour, jourvrai, pctsrf,
      s                    lmt_sst,lmt_alb,lmt_rug,lmt_bils )
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/conflx.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/conflx.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/conflx.F	(revision 230)
@@ -103,6 +103,6 @@
       DO k = 1, klev+1
       DO i = 1, klon
-         pmflxr(i,k) = 0.0
-         pmflxs(i,k) = 0.0
+         zmflxr(i,k) = 0.0
+         zmflxs(i,k) = 0.0
       ENDDO
       ENDDO
@@ -981,4 +981,6 @@
       ENDDO
 c
+      ldcum(1)=ldcum(1)
+c
       is = 0
       DO i = 1, klon
@@ -1039,10 +1041,12 @@
       REAL plude(klon,klev)
       REAL pdmfup(klon,klev), pdpmel(klon,klev)
-      REAL pdmfdp(klon,klev)
+cjq The variable maxpdmfdp(klon) has been introduced by Olivier Boucher
+cjq 14/11/00 to fix the problem with the negative precipitation.      
+      REAL pdmfdp(klon,klev), maxpdmfdp(klon,klev) 
       REAL prfl(klon), psfl(klon)
       REAL pmflxr(klon,klev+1), pmflxs(klon,klev+1)
       INTEGER  kcbot(klon), kctop(klon), ktype(klon)
       LOGICAL  ldland(klon), ldcum(klon)
-      INTEGER k, i
+      INTEGER k, kp, i
       REAL zcons1, zcons2, zcucov, ztmelp2
       REAL pdtime, zdp, zzp, zfac, zsnmlt, zrfl, zrnew
@@ -1160,7 +1164,9 @@
          ENDIF
          IF (pten(i,k).GT.RTT) THEN
-           pmflxr(i,k+1)=pmflxr(i,k)+pdmfup(i,k)+pdmfdp(i,k)+pdpmel(i,k)
+         pmflxr(i,k+1)=pmflxr(i,k)+pdmfup(i,k)+pdmfdp(i,k)+pdpmel(i,k)
+         pmflxs(i,k+1)=pmflxs(i,k)-pdpmel(i,k)
          ELSE
-           pmflxs(i,k+1)=pmflxs(i,k)+pdmfup(i,k)+pdmfdp(i,k)-pdpmel(i,k)
+           pmflxs(i,k+1)=pmflxs(i,k)+pdmfup(i,k)+pdmfdp(i,k)
+           pmflxr(i,k+1)=pmflxr(i,k)
          ENDIF
 c        si la precipitation est negative, on ajuste le plux du
@@ -1176,4 +1182,26 @@
       ENDDO
 c
+cjq The new variable is initialized here.
+cjq It contains the humidity which is fed to the downdraft
+cjq by evaporation of precipitation in the column below the base
+cjq of convection.
+cjq 
+cjq In the former version, this term has been subtracted from precip
+cjq as well as the evaporation.
+cjq      
+      DO k = 1, klev
+      DO i = 1, klon 
+         maxpdmfdp(i,k)=0.0
+      ENDDO
+      ENDDO
+      DO k = 1, klev
+       DO kp = k, klev
+        DO i = 1, klon
+         maxpdmfdp(i,k)=maxpdmfdp(i,k)+pdmfdp(i,kp)
+        ENDDO
+       ENDDO
+      ENDDO
+cjq End of initialization
+c      
       DO k = ktopm2, klev
       DO i = 1, klon
@@ -1189,4 +1217,11 @@
             zrfln=MAX(zrnew,0.)
             zdrfl=MIN(0.,zrfln-zrfl)
+cjq At least the amount of precipiation needed to feed the downdraft
+cjq with humidity below the base of convection has to be left and can't
+cjq be evaporated (surely the evaporation can't be positive):            
+            zdrfl=MAX(zdrfl,
+     .            MIN(-pmflxr(i,k)-pmflxs(i,k)-maxpdmfdp(i,k),0.0))
+cjq End of insertion
+c            
             zdenom=1.0/MAX(1.0E-20,pmflxr(i,k)+pmflxs(i,k))
             IF (pten(i,k).GT.RTT) THEN
@@ -1207,5 +1242,7 @@
             pdmfdp(i,k) = 0.0
             pdpmel(i,k) = 0.0
-         ENDIF
+         ENDIF         
+         if (pmflxr(i,k) + pmflxs(i,k).lt.-1.e-26) 
+     .    write(*,*) 'precip. < 1e-16 ',pmflxr(i,k) + pmflxs(i,k)
       ENDIF
       ENDDO
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/fisrtilp_tr.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/fisrtilp_tr.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/fisrtilp_tr.F	(revision 230)
@@ -1,3 +1,5 @@
-      SUBROUTINE fisrtilp_tr(dtime,paprs,pplay,t,q,
+c $Header$
+c
+      SUBROUTINE fisrtilp_tr(dtime,paprs,pplay,t,q,ratqs,
      s                   d_t, d_q, d_ql, rneb, radliq, rain, snow,
      s                   pfrac_impa, pfrac_nucl, pfrac_1nucl,
@@ -66,5 +68,5 @@
       PARAMETER (coef_eva=2.0E-05)
       LOGICAL calcrat ! calculer ratqs au lieu de fixer sa valeur
-      REAL ratqs ! determine la largeur de distribution de vapeur
+      REAL ratqs(klon,klev) ! determine la largeur de distribution de vapeur
       PARAMETER (calcrat=.TRUE.)
       REAL zx_min, rat_max
@@ -281,12 +283,5 @@
          DO i = 1, klon
 c
-            zx = pplay(i,k)/paprs(i,1)
-            zx = (zx_max-zx)/(zx_max-zx_min)
-            zx = MIN(MAX(zx,0.0),1.0)
-            zx = zx * zx * zx
-            ratqs = zx * (rat_max-rat_min) + rat_min
-            IF (.NOT.calcrat) ratqs=0.05
-c
-            zdelq = ratqs * zq(i)
+            zdelq = ratqs(i,k) * zq(i)
             rneb(i,k) = (zq(i)+zdelq-zqs(i)) / (2.0*zdelq)
             zqn(i) = (zq(i)+zdelq+zqs(i))/2.0
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/indicesol.inc
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/indicesol.inc	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/indicesol.inc	(revision 230)
@@ -1,3 +1,3 @@
-      INTEGER,parameter :: nbsrf=4
+      INTEGER, parameter :: nbsrf=4
       INTEGER, parameter :: is_oce=3 !ocean
       INTEGER, parameter :: is_sic = 4 ! glace de mer
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/initphysto.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/initphysto.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/initphysto.F	(revision 230)
@@ -1,2 +1,5 @@
+C
+C $Header$
+C
       subroutine initphysto
      .  (infile,
@@ -133,4 +136,10 @@
      .                "once", t_ops, t_wrt)
 
+C T 
+C
+      call histdef(fileid, 't', 'Temperature', 'K',
+     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             32, 'inst(X)', t_ops, t_wrt)
+        write(*,*) 'apres t ds initphysto'
 C mfu 
 C
@@ -234,5 +243,11 @@
      .             32, "inst(X)", t_ops, t_wrt)
 	
-	
+c
+c rain
+c
+        call histdef(fileid, "rain", " ", " ",
+     .             iim, jjm+1, nhoriid, 1, 1,1, -99,
+     .             32, "inst(X)", t_ops, t_wrt)
+
 c
 c psrf1
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/physiq.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/physiq.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/physiq.F	(revision 230)
@@ -281,4 +281,35 @@
       SAVE agesno                 ! age de la neige
 c
+      REAL alb_neig(klon)
+      SAVE alb_neig               ! albedo de la neige
+cKE43
+c Variables liees a la convection de K. Emanuel (sb):
+c
+      REAL ema_workcbmf(klon)   ! cloud base mass flux
+      SAVE ema_workcbmf
+
+      REAL ema_cbmf(klon)       ! cloud base mass flux
+      SAVE ema_cbmf
+
+      REAL ema_pcb(klon)        ! cloud base pressure
+      SAVE ema_pcb
+
+      REAL ema_pct(klon)        ! cloud top pressure
+      SAVE ema_pct
+
+      REAL bas, top             ! cloud base and top levels
+      SAVE bas
+      SAVE top
+
+      REAL Ma(klon,klev)        ! undilute upward mass flux
+      SAVE Ma
+      REAL ema_work1(klon, klev), ema_work2(klon, klev)
+      SAVE ema_work1, ema_work2
+      REAL wdn(klon), tdn(klon), qdn(klon)
+c Variables locales pour la couche limite (al1):
+c
+cAl1      REAL pblh(klon)           ! Hauteur de couche limite
+cAl1      SAVE pblh
+c34EK
 c
 c Variables locales:
@@ -346,4 +377,6 @@
       EXTERNAL condsurf  ! lire les conditions aux limites
       EXTERNAL conlmd    ! convection (schema LMD)
+cKE43
+      EXTERNAL conema  ! convect4.3
       EXTERNAL fisrtilp  ! schema de condensation a grande echelle (pluie)
 cAA 
@@ -426,4 +459,32 @@
 c
       REAL zphi(klon,klev)
+      REAL zx_tmp_x(iim), zx_tmp_yjjmp1
+      REAL zx_relief(iim,jjmp1)
+      REAL zx_aire(iim,jjmp1)
+cKE43
+c Variables locales pour la convection de K. Emanuel (sb):
+c
+      REAL upwd(klon,klev)      ! saturated updraft mass flux
+      REAL dnwd(klon,klev)      ! saturated downdraft mass flux
+      REAL dnwd0(klon,klev)     ! unsaturated downdraft mass flux
+      REAL tvp(klon,klev)       ! virtual temp of lifted parcel
+      REAL cape(klon)           ! CAPE
+      SAVE cape
+      REAL pbase(klon)          ! cloud base pressure
+      SAVE pbase
+      REAL bbase(klon)          ! cloud base buoyancy
+      SAVE bbase
+      REAL rflag(klon)          ! flag fonctionnement de convect
+c -- convect43:
+      INTEGER ntra              ! nb traceurs pour convect4.3
+      REAL pori_con(klon)    ! pressure at the origin level of lifted parcel
+      REAL plcl_con(klon),dtma_con(klon),dtlcl_con(klon)
+      REAL dtvpdt1(klon,klev), dtvpdq1(klon,klev)
+      REAL dplcldt(klon), dplcldr(klon)
+c?     .     condm_con(klon,klev),conda_con(klon,klev),
+c?     .     mr_con(klon,klev),ep_con(klon,klev)
+c?     .    ,sadiab(klon,klev),wadiab(klon,klev)
+c --
+c34EK
 c
 c Variables du changement
@@ -460,4 +521,8 @@
       REAL d_u_lif(klon,klev), d_v_lif(klon,klev)
       REAL d_t_lif(klon,klev)
+
+      REAL ratqs(klon,klev)
+      LOGICAL zpt_conv(klon,klev)
+
 c
 c Variables liees a l'ecriture de la bande histoire physique
@@ -595,4 +660,21 @@
          PRINT*, "Clef pour la convection, iflag_con=", iflag_con
 c
+cKE43
+c Initialisation pour la convection de K.E. (sb):
+         IF (iflag_con.EQ.4) THEN
+
+         PRINT*, "*** Convection de Kerry Emanuel 4.3  "
+         PRINT*, "On va utiliser le melange convectif des traceurs qui"
+         PRINT*, "est calcule dans convect4.3"
+         PRINT*, " !!! penser aux logical flags de phytrac"
+
+          DO i = 1, klon
+           ema_cbmf(i) = 0.
+           ema_pcb(i)  = 0.
+           ema_pct(i)  = 0.
+           ema_workcbmf(i) = 0.
+          ENDDO
+         ENDIF
+c34EK
          IF (ok_orodr) THEN
          DO i=1,klon
@@ -665,8 +747,8 @@
      .                 1,iim,1,jjmp1, 0, zjulian, dtime, 
      .                 nhori, nid_day)
-c         CALL histvert(nid_day, "presnivs", "Vertical levels", "mb",
-c     .                 klev, presnivs, nvert)
-         call histvert(nid_day, 'sig_s', 'Niveaux sigma','-',
-     .              klev, znivsig, nvert)
+         CALL histvert(nid_day, "presnivs", "Vertical levels", "mb",
+     .                 klev, presnivs, nvert)
+c        call histvert(nid_day, 'sig_s', 'Niveaux sigma','-',
+c    .              klev, znivsig, nvert)
 c
          zsto = dtime
@@ -888,8 +970,8 @@
      .                 1,iim,1,jjmp1, 0, zjulian, dtime, 
      .                 nhori, nid_mth)
-c         CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
-c     .                 klev, presnivs, nvert)
-         call histvert(nid_mth, 'sig_s', 'Niveaux sigma','-',
-     .              klev, znivsig, nvert)
+         CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
+     .                 klev, presnivs, nvert)
+c        call histvert(nid_mth, 'sig_s', 'Niveaux sigma','-',
+c    .              klev, znivsig, nvert)
 c
          zsto = dtime
@@ -1097,4 +1179,27 @@
      .                "ave(X)", zsto,zout)
 c
+cKE43
+      IF (iflag_con .EQ. 4) THEN ! sb
+c
+         CALL histdef(nid_mth, "cape", "Conv avlbl pot ener", "J/Kg",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto,zout)
+c
+         CALL histdef(nid_mth, "pbase", "Cld base pressure", "hPa",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto,zout)
+c
+         CALL histdef(nid_mth, "ptop", "Cld top pressure", "hPa",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto,zout)
+c
+         CALL histdef(nid_mth, "fbase", "Cld base mass flux", "Kg/m2/s",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto,zout)
+c
+c
+      ENDIF
+c34EK
+c
 c Champs 3D:
 c
@@ -1178,4 +1283,13 @@
      .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
+
+         CALL histdef(nid_mth, "ptconv", "POINTS CONVECTIFS"," ",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+
+         CALL histdef(nid_mth, "ratqs", "RATQS"," ",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+
 c
          CALL histdef(nid_mth, "dtajs", "Dry adjust. dT", "K/s",
@@ -1250,4 +1364,26 @@
          ENDIF
 c
+cKE43
+      IF (iflag_con.EQ.4) THEN ! (sb)
+c
+         CALL histdef(nid_mth, "upwd", "saturated updraft", "Kg/m2/s",
+     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+c
+         CALL histdef(nid_mth, "dnwd", "saturated downdraft","Kg/m2/s",
+     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+c
+         CALL histdef(nid_mth, "dnwd0", "unsat. downdraft", "Kg/m2/s",
+     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+c
+         CALL histdef(nid_mth,"Ma","undilute adiab updraft","Kg/m2/s",
+     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+c
+c
+      ENDIF
+c34EK
          CALL histend(nid_mth)
 c
@@ -1275,8 +1411,8 @@
      .                 1,iim,1,jjmp1, 0, zjulian, dtime,
      .                 nhori, nid_ins)
-c         CALL histvert(nid_ins, "presnivs", "Vertical levels", "mb",
-c     .                 klev, presnivs, nvert)
-         call histvert(nid_ins, 'sig_s', 'Niveaux sigma','-',
-     .              klev, znivsig, nvert)
+         CALL histvert(nid_ins, "presnivs", "Vertical levels", "mb",
+     .                 klev, presnivs, nvert)
+c        call histvert(nid_ins, 'sig_s', 'Niveaux sigma','-',
+c    .              klev, znivsig, nvert)
 c
 c
@@ -1685,7 +1821,7 @@
 c
       DO nsrf = 1, nbsrf
-      DO i = 1, klon
-         IF (pctsrf(i,nsrf).LT.epsfra) ftsol(i,nsrf) = zxtsol(i)
-      ENDDO
+        DO i = 1, klon
+          IF (pctsrf(i,nsrf) .LT. epsfra) ftsol(i,nsrf) = zxtsol(i)
+        ENDDO
       ENDDO
 
@@ -1750,7 +1886,45 @@
 c    s             d_t_con, d_q_con, 
 c    s             rain_con, snow_con, ibas_con, itop_con)
+cKE43
+      ELSE IF (iflag_con.EQ.4) THEN
+c nb of tracers for the KE convection:
+          if (nqmax .GE. 4) then
+              ntra = nbtr
+          else
+              ntra = 1 
+          endif
+cke43 (arguments inutiles enleves => des SAVE dans conema43?)
+c$$$          CALL conema43(dtime,paprs,pplay,t_seri,q_seri,
+c$$$     $        u_seri,v_seri,tr_seri,nbtr,
+c$$$     .        ema_workcbmf,
+c$$$     .        d_t_con,d_q_con,d_u_con,d_v_con,d_tr,
+c$$$     .        wdn, tdn, qdn,
+c$$$     .        rain_con, snow_con, ibas_con, itop_con,
+c$$$     .        upwd,dnwd,dnwd0,bas,top,Ma,cape,tvp,rflag,
+c$$$     .        pbase
+c$$$     .        ,bbase,dtvpdt1,dtvpdq1,dplcldt,dplcldr,
+c$$$     .        pori_con,plcl_con,dtma_con,dtlcl_con)
+          CALL conema (dtime,paprs,pplay,t_seri,q_seri,
+     $        u_seri,v_seri,tr_seri,nbtr,
+     .        ema_work1,ema_work2,
+     .        d_t_con,d_q_con,d_u_con,d_v_con,d_tr,
+c$$$     .        wdn, tdn, qdn,
+     .        rain_con, snow_con, ibas_con, itop_con,
+     .        upwd,dnwd,dnwd0,bas,top,Ma,cape,tvp,rflag,
+     .        pbase
+     .        ,bbase,dtvpdt1,dtvpdq1,dplcldt,dplcldr)
+c$$$     .        pori_con,plcl_con,dtma_con,dtlcl_con)
+          DO i = 1, klon
+            ema_pcb(i)  = pbase(i)
+          ENDDO
+          DO i = 1, klon
+            ema_pct(i)  = paprs(i,itop_con(i))
+          ENDDO
+          DO i = 1, klon
+            ema_cbmf(i) = ema_workcbmf(i)
+          ENDDO      
       ELSE
-      PRINT*, "iflag_con non-prevu", iflag_con
-      CALL abort
+          PRINT*, "iflag_con non-prevu", iflag_con
+          CALL abort
       ENDIF
 
@@ -1766,37 +1940,37 @@
       ENDDO
       IF (check) THEN
-         za = qcheck(klon,klev,paprs,q_seri,ql_seri,paire)
-         PRINT*, "aprescon=", za
-         zx_t = 0.0
-         za = 0.0
-         DO i = 1, klon
+          za = qcheck(klon,klev,paprs,q_seri,ql_seri,paire)
+          PRINT*, "aprescon=", za
+          zx_t = 0.0
+          za = 0.0
+          DO i = 1, klon
             za = za + paire(i)/FLOAT(klon)
             zx_t = zx_t + (rain_con(i)+snow_con(i))*paire(i)/FLOAT(klon)
-        ENDDO
-         zx_t = zx_t/za*dtime
-         PRINT*, "Precip=", zx_t
+          ENDDO
+          zx_t = zx_t/za*dtime
+          PRINT*, "Precip=", zx_t
       ENDIF
       IF (zx_ajustq) THEN
-         DO i = 1, klon
+          DO i = 1, klon
             z_apres(i) = 0.0
-         ENDDO
-         DO k = 1, klev
-         DO i = 1, klon
-            z_apres(i) = z_apres(i) + (q_seri(i,k)+ql_seri(i,k))
-     .                        *(paprs(i,k)-paprs(i,k+1))/RG
-         ENDDO
-         ENDDO
-         DO i = 1, klon
-         z_factor(i) = (z_avant(i)-(rain_con(i)+snow_con(i))*dtime)
-     .                /z_apres(i)
-         ENDDO
-         DO k = 1, klev
-         DO i = 1, klon
-         IF (z_factor(i).GT.(1.0+1.0E-08) .OR.
-     .       z_factor(i).LT.(1.0-1.0E-08)) THEN
-               q_seri(i,k) = q_seri(i,k) * z_factor(i)
-         ENDIF
-         ENDDO
-         ENDDO
+          ENDDO
+          DO k = 1, klev
+            DO i = 1, klon
+              z_apres(i) = z_apres(i) + (q_seri(i,k)+ql_seri(i,k))
+     .            *(paprs(i,k)-paprs(i,k+1))/RG
+            ENDDO
+          ENDDO
+          DO i = 1, klon
+            z_factor(i) = (z_avant(i)-(rain_con(i)+snow_con(i))*dtime)
+     .          /z_apres(i)
+          ENDDO
+          DO k = 1, klev
+            DO i = 1, klon
+              IF (z_factor(i).GT.(1.0+1.0E-08) .OR.
+     .            z_factor(i).LT.(1.0-1.0E-08)) THEN
+                  q_seri(i,k) = q_seri(i,k) * z_factor(i)
+              ENDIF
+            ENDDO
+          ENDDO
       ENDIF
       zx_ajustq=.FALSE.
@@ -1804,9 +1978,11 @@
       IF (nqmax.GT.2) THEN !--melange convectif de traceurs
 c
-      IF (iflag_con.NE.2) THEN
-         PRINT*, "Pour l instant, seul conflx fonctionne avec traceurs"
-         PRINT*,' Mettre iflag_con = 2  dans  run.def et repasser  !'
-         CALL abort
-      ENDIF
+          IF (iflag_con .NE. 2 .AND.  iflag_con .NE. 4 ) THEN 
+              PRINT*, 'Pour l instant, seul conflx fonctionne ',
+     $            'avec traceurs', iflag_con
+              PRINT*,' Mettre iflag_con', 
+     $            ' = 2  ou 4 dans run.def et repasser'
+              CALL abort
+              ENDIF 
 c
       ENDIF !--nqmax.GT.2
@@ -1821,4 +1997,9 @@
       ENDDO
       ENDDO
+
+c   RATQS
+      call calcratqs (
+     I            paprs,pplay,q_seri,d_t_con,d_t_ajs
+     O           ,ratqs,zpt_conv)
 c
 c Appeler le processus de condensation a grande echelle
@@ -1826,5 +2007,5 @@
 c
       CALL fisrtilp_tr(dtime,paprs,pplay,
-     .           t_seri, q_seri,
+     .           t_seri, q_seri,ratqs,
      .           d_t_lsc, d_q_lsc, d_ql_lsc, rneb, cldliq,
      .           rain_lsc, snow_lsc,
@@ -2060,9 +2241,25 @@
 c   Calcul  des tendances traceurs
 c====================================================================
+C Pascale : il faut quand meme apeller phytrac car il gere les sorties
+cKE43       des traceurs => il faut donc mettre des flags a .false.
+      IF (iflag_con.EQ.4) THEN
+c           on ajoute les tendances calculees par KE43
+        DO iq=1, nqmax-2 ! Sandrine a -3 ???
+        DO k = 1, nlev
+        DO i = 1, klon
+          tr_seri(i,k,iq) = tr_seri(i,k,iq) + d_tr(i,k,iq)
+        ENDDO
+        ENDDO
+        WRITE(iqn,'(i2.2)') iq
+        CALL minmaxqfi(tr_seri(1,1,iq),0.,1.e33,'couche lim iq='//iqn)
+        ENDDO
 CMAF modif pour garder info du nombre de traceurs auxquels
 C la physique s'applique
+      ELSE
+CMAF modif pour garder info du nombre de traceurs auxquels
+C la physique s'applique
 C
       call phytrac (rnpb,
-     I                   debut,
+     I                   debut,lafin,
      I                   nqmax-2,
      I                   nlon,nlev,dtime,
@@ -2073,4 +2270,5 @@
      I                   rlon,presnivs,paire,pphis,
      O                   tr_seri)
+      ENDIF 
 
       IF (offline) THEN
@@ -2078,9 +2276,9 @@
 	 call phystokenc (
      I                   nlon,nlev,pdtphys,rlon,rlat,
-     I                   pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
+     I                   t,pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
      I                   ycoefh,yu1,yv1,ftsol,pctsrf,
      I                   frac_impa, frac_nucl,
-     I                   pphis,paire,dtime,itap,
-     O                   physid)
+     I                   pphis,paire,dtime,itap)
+
 
       ENDIF
@@ -2475,4 +2673,22 @@
       CALL gr_fi_ecrit(1, klon,iim,jjmp1, vq,zx_tmp_2d)
       CALL histwrite(nid_mth,"vq",itap,zx_tmp_2d,iim*jjmp1,ndex2d)
+cKE43
+      IF (iflag_con .EQ. 4) THEN ! sb
+c
+      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cape,zx_tmp_2d)
+      CALL histwrite(nid_mth,"cape",itap,zx_tmp_2d,iim*jjmp1,ndex2d)
+c
+      CALL gr_fi_ecrit(1, klon,iim,jjmp1,pbase,zx_tmp_2d)
+      CALL histwrite(nid_mth,"pbase",itap,zx_tmp_2d,iim*jjmp1,ndex2d)
+c
+      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_pct,zx_tmp_2d)
+      CALL histwrite(nid_mth,"ptop",itap,zx_tmp_2d,iim*jjmp1,ndex2d)
+c
+      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_cbmf,zx_tmp_2d)
+      CALL histwrite(nid_mth,"fbase",itap,zx_tmp_2d,iim*jjmp1,ndex2d)
+c
+c
+      ENDIF
+c34EK
 c
 c Champs 3D:
@@ -2557,4 +2773,12 @@
       CALL histwrite(nid_mth,"dqeva",itap,zx_tmp_3d,
      .                                   iim*jjmp1*klev,ndex3d)
+c
+      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, zpt_conv, zx_tmp_3d)
+      CALL histwrite(nid_mth,"ptconv",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex3d)
+c
+      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, ratqs, zx_tmp_3d)
+      CALL histwrite(nid_mth,"ratqs",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex3d)
 c
       CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_ajs, zx_tmp_3d)
@@ -2628,4 +2852,26 @@
       ENDDO
       ENDIF
+cKE43
+      IF (iflag_con.EQ.4) THEN ! (sb)
+c
+      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, upwd, zx_tmp_3d)
+      CALL histwrite(nid_mth,"upwd",itap,zx_tmp_3d,
+     .                                   iim*jjmp1*klev,ndex3d)
+c
+      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd, zx_tmp_3d)
+      CALL histwrite(nid_mth,"dnwd",itap,zx_tmp_3d,
+     .                                   iim*jjmp1*klev,ndex3d)
+c
+      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd0, zx_tmp_3d)
+      CALL histwrite(nid_mth,"dnwd0",itap,zx_tmp_3d,
+     .                                   iim*jjmp1*klev,ndex3d)
+c
+      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, Ma, zx_tmp_3d)
+      CALL histwrite(nid_mth,"Ma",itap,zx_tmp_3d,
+     .                                   iim*jjmp1*klev,ndex3d)
+c
+c
+      ENDIF
+c34EK
 c
       if (ok_sync) then
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/phystokenc.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/phystokenc.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/phystokenc.F	(revision 230)
@@ -1,9 +1,11 @@
+c
+c $Header$
+c
       SUBROUTINE phystokenc (
      I                   nlon,nlev,pdtphys,rlon,rlat,
-     I                   pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
+     I                   pt,pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
      I                   pcoefh,yu1,yv1,ftsol,pctsrf,
-     I                   frac_impa,frac_nucl,
-     I                   pphis,paire,dtime,itap,
-     O                   physid)
+     I                   pfrac_impa,pfrac_nucl,
+     I                   pphis,paire,dtime,itap)
       USE ioipsl
       USE histcom
@@ -36,6 +38,5 @@
       real pdtphys ! pas d'integration pour la physique (seconde)
 c
-      integer physid, itap
-      integer ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
+      integer physid, itap,ndex(1)
 
 c   convection:
@@ -48,4 +49,5 @@
       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)
 c
       REAL rlon(klon), rlat(klon), dtime
@@ -62,6 +64,6 @@
 c   ----------
 c
-      REAL frac_impa(klon,klev)
-      REAL frac_nucl(klon,klev)
+      REAL pfrac_impa(klon,klev)
+      REAL pfrac_nucl(klon,klev)
 c
 c Arguments necessaires pour les sources et puits de traceur
@@ -80,4 +82,8 @@
       REAL de_d(klon,klev) ! flux detraine dans le panache descendant
       REAL coefh(klon,klev) ! flux detraine dans le panache descendant
+	REAL t(klon,klev)
+      REAL frac_impa(klon,klev)
+      REAL frac_nucl(klon,klev)
+      REAL rain(klon)
 
       REAL pyu1(klon),pyv1(klon)
@@ -90,8 +96,8 @@
       integer iadvtr,irec
       real zmin,zmax
-      logical ok_sync
- 
-      save mfu,mfd,en_u,de_u,en_d,de_d,coefh,dtcum
+
+      save t,mfu,mfd,en_u,de_u,en_d,de_d,coefh,dtcum
       save iadvtr,irec
+      save frac_impa,frac_nucl,rain
       save pyu1,pyv1,pftsol,ppsrf
 
@@ -101,9 +107,7 @@
 c======================================================================
 
-      ok_sync = .true.
-
-c     print*,'iadvtr= ',iadvtr
-c     print*,'istphy= ',istphy
-c     print*,'istdyn= ',istdyn
+      print*,'iadvtr= ',iadvtr
+      print*,'istphy= ',istphy
+      print*,'istdyn= ',istdyn
 
       IF (iadvtr.eq.0) THEN
@@ -112,156 +116,28 @@
      . rlon,rlat,dtime, dtime*istphy,dtime*istphy,nqmx,physid)
   	
-c	write(*,*) 'apres initphysto ds phystokenc' 
-
+	write(*,*) 'apres initphysto ds phystokenc' 
+
+       ndex(1) = 0
+         i=itap 
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
+         CALL histwrite(physid,"phis",i,zx_tmp_2d,iim*(jjm+1),ndex)
+c
+         i=itap
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
+         CALL histwrite(physid,"aire",i,zx_tmp_2d,iim*(jjm+1),ndex)
 	
       ENDIF
 c
-      ndex2d = 0
-      ndex3d = 0
-      i=itap 
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
-      CALL histwrite(physid,"phis",i,zx_tmp_2d,iim*(jjm+1),ndex2d)
-c
-      i=itap
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
-      CALL histwrite(physid,"aire",i,zx_tmp_2d,iim*(jjm+1),ndex2d)
-
       iadvtr=iadvtr+1
 c
-      IF(mod(iadvtr,istphy).eq.0) THEN 
-c
-c   normalisation par le temps cumule
+c
+c   reinitialisation des champs cumules
+      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)=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
-            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
-         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfu, zx_tmp_3d)
-      CALL histwrite(physid,"mfu",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-	CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfd, zx_tmp_3d)
-      CALL histwrite(physid,"mfd",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_u, zx_tmp_3d)
-      CALL histwrite(physid,"en_u",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_u, zx_tmp_3d)
-      CALL histwrite(physid,"de_u",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_d, zx_tmp_3d)
-      CALL histwrite(physid,"en_d",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_d, zx_tmp_3d)       
-      CALL histwrite(physid,"de_d",itap,zx_tmp_3d,    
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, coefh, zx_tmp_3d)         
-      CALL histwrite(physid,"coefh",itap,zx_tmp_3d,    
-     .                                   iim*(jjm+1)*klev,ndex3d)	
-cccc
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_impa,zx_tmp_3d)
-        CALL histwrite(physid,"frac_impa",itap,zx_tmp_3d,
-     .  iim*(jjm+1)*klev,ndex3d)
-
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_nucl,zx_tmp_3d)
-        CALL histwrite(physid,"frac_nucl",itap,zx_tmp_3d,
-     .  iim*(jjm+1)*klev,ndex3d)
- 
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyu1,zx_tmp_2d)
-      CALL histwrite(physid,"pyu1",itap,zx_tmp_2d,iim*(jjm+1),
-     .                                                ndex2d)
-	
-	CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyv1,zx_tmp_2d)
-      CALL histwrite(physid,"pyv1",itap,zx_tmp_2d,iim*(jjm+1)
-     .                                                ,ndex2d)
-	
-	CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol1, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol1",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol2, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol2",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-          CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol3, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol3",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol4, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol4",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf1, zx_tmp_2d)
-      CALL histwrite(physid,"psrf1",itap,zx_tmp_2d,   
-     .                                   iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf2, zx_tmp_2d)
-      CALL histwrite(physid,"psrf2",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf3, zx_tmp_2d)
-      CALL histwrite(physid,"psrf3",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf4, zx_tmp_2d)
-      CALL histwrite(physid,"psrf4",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-
-      if (ok_sync) call histsync(physid)
-	
-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
-      if (mod(iadvtr,istphy).eq.1) then
-         do k=1,klev
-            do i=1,klon
+               frac_impa(i,k)=1.
+               frac_nucl(i,k)=1.
                mfu(i,k)=0.
                mfd(i,k)=0.
@@ -271,7 +147,9 @@
                de_d(i,k)=0.
                coefh(i,k)=0.
+		t(i,k)=0.
             enddo
          enddo
          do i=1,klon
+            rain(i)=0.
             pyv1(i)=0.
             pyu1(i)=0.
@@ -289,4 +167,6 @@
       do k=1,klev
          do i=1,klon
+            frac_impa(i,k)=frac_impa(i,k)*pfrac_impa(i,k)
+            frac_nucl(i,k)=frac_nucl(i,k)*pfrac_nucl(i,k)
             mfu(i,k)=mfu(i,k)+pmfu(i,k)*pdtphys
             mfd(i,k)=mfd(i,k)+pmfd(i,k)*pdtphys
@@ -296,4 +176,5 @@
             de_d(i,k)=de_d(i,k)+pde_d(i,k)*pdtphys
             coefh(i,k)=coefh(i,k)+pcoefh(i,k)*pdtphys
+		t(i,k)=t(i,k)+pt(i,k)*pdtphys
          enddo
       enddo
@@ -310,4 +191,151 @@
 
       dtcum=dtcum+pdtphys
+c
+      IF(mod(iadvtr,istphy).eq.0) THEN
+c
+c   normalisation par le temps cumule
+         do k=1,klev
+            do i=1,klon
+c              frac_impa=frac_impa : c'est la fraction cumulee qu'on stoke
+c              frac_nucl=frac_nucl : c'est la fraction cumulee qu'on stoke
+               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
+            enddo
+         enddo
+         do i=1,klon
+            rain(i)=rain(i)/dtcum
+            pyv1(i)=pyv1(i)/dtcum
+            pyu1(i)=pyu1(i)/dtcum
+         end do
+c modif abderr 23 11 00         do k=1,nbsrf
+             do i=1,klon
+	      do k=1,nbsrf
+               pftsol(i,k)=pftsol(i,k)/dtcum
+	       ppsrf(i,k)=ppsrf(i,k)/dtcum
+	      enddo
+               pftsol1(i) = pftsol(i,1)
+               pftsol2(i) = pftsol(i,2)
+               pftsol3(i) = pftsol(i,3)
+               pftsol4(i) = pftsol(i,4)
+
+c               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
+c         enddo
+c
+c   ecriture des champs
+c
+         irec=irec+1
+
+ccccc
+      print*,'AVANT ECRITURE'
+         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, t, zx_tmp_3d)
+         CALL histwrite(physid,"t",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+      print*,'APRES ECRITURE'
+
+         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfu, zx_tmp_3d)
+      CALL histwrite(physid,"mfu",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfd, zx_tmp_3d)
+      CALL histwrite(physid,"mfd",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_u, zx_tmp_3d)
+      CALL histwrite(physid,"en_u",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_u, zx_tmp_3d)
+      CALL histwrite(physid,"de_u",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_d, zx_tmp_3d)
+      CALL histwrite(physid,"en_d",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_d, zx_tmp_3d)
+      CALL histwrite(physid,"de_d",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, coefh, zx_tmp_3d)
+      CALL histwrite(physid,"coefh",itap,zx_tmp_3d,
+     .                                   iim*(jjm+1)*klev,ndex)
+cccc
+       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_impa,zx_tmp_3d)
+        CALL histwrite(physid,"frac_impa",itap,zx_tmp_3d,
+     .  iim*(jjm+1)*klev,ndex)
+
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_nucl,zx_tmp_3d)
+        CALL histwrite(physid,"frac_nucl",itap,zx_tmp_3d,
+     .  iim*(jjm+1)*klev,ndex)
+
+        CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyu1,zx_tmp_2d)
+      CALL histwrite(physid,"pyu1",itap,zx_tmp_2d,iim*(jjm+1),ndex)
+
+        CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyv1,zx_tmp_2d)
+      CALL histwrite(physid,"pyv1",itap,zx_tmp_2d,iim*(jjm+1),ndex)
+
+        CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol1, zx_tmp_2d)
+      CALL histwrite(physid,"ftsol1",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol2, zx_tmp_2d)
+      CALL histwrite(physid,"ftsol2",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+          CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol3, zx_tmp_2d)
+      CALL histwrite(physid,"ftsol3",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+
+c
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol4, zx_tmp_2d)
+      CALL histwrite(physid,"ftsol4",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+
+        CALL gr_fi_ecrit(1,klon,iim,jjm+1, rain, zx_tmp_2d)
+      CALL histwrite(physid,"rain",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+
+        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf1, zx_tmp_2d)
+      CALL histwrite(physid,"psrf1",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf2, zx_tmp_2d)
+      CALL histwrite(physid,"psrf2",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf3, zx_tmp_2d)
+      CALL histwrite(physid,"psrf3",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf4, zx_tmp_2d)
+      CALL histwrite(physid,"psrf4",itap,zx_tmp_2d,
+     .                                   iim*(jjm+1),ndex)
+
+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
+
 
       RETURN
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/phytrac.F
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/phytrac.F	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/phytrac.F	(revision 230)
@@ -1,4 +1,7 @@
+c
+c $Header$
+c
       SUBROUTINE phytrac (rnpb,
-     I                   debutphy,
+     I                   debutphy,lafin,
      I                   nqmax,
      I                   nlon,nlev,pdtphys,
@@ -29,6 +32,6 @@
 #include "dimphy.h"
 #include "indicesol.h"
+#include "temps.h"
 #include "control.h"
-#include "temps.h"
 c======================================================================
 
@@ -50,8 +53,9 @@
       real pplay(nlon,nlev)  ! pression pour le mileu de chaque couche (en Pa)
       real presnivs(klev) ! pressions approximat. des milieux couches ( en PA)
-      real znivsig(klev) ! niveaux sigma
       real paire(klon)
       real pphis(klon)
       logical debutphy       ! le flag de l'initialisation de la physique
+      logical lafin          ! le flag de la fin de la physique
+
       integer ll
 c
@@ -92,5 +96,8 @@
       real ftsol(nlon,nbsrf)  ! Temperature du sol (surf)(Kelvin)
       real pctsrf(nlon,nbsrf) ! Pourcentage de sol f(nature du sol)
-
+c abder
+      real pftsol1(nlon),pftsol2(nlon),pftsol3(nlon),pftsol4(nlon)
+      real ppsrf1(nlon),ppsrf2(nlon),ppsrf3(nlon),ppsrf4(nlon)
+c fin
 cAA ----------------------------
 cAA  VARIABLES LOCALES TRACEURS
@@ -133,5 +140,6 @@
       INTEGER nid_tra
       SAVE nid_tra
-      INTEGER ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
+c     REAL x(klon,klev,nbtr+2) ! traceurs 
+      INTEGER ndex(1)
       REAL zx_tmp_2d(iim,jjm+1), zx_tmp_3d(iim,jjm+1,klev)
       REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
@@ -161,6 +169,6 @@
 c
 c--modif convection tiedtke
-      INTEGER i, k, it
-
+      INTEGER i, k, it,itap
+	save itap
       REAL delp(klon,klev)
 c--end modif
@@ -208,8 +216,9 @@
 c        print*,'DANS PHYTRAC debutphy=',debutphy
 
-         ecrit_tra = NINT(86400./pdtphys *ecritphy)   
-         zsto = pdtphys
-         zout = pdtphys * FLOAT(ecrit_tra)
          if (debutphy) then
+
+          print*,'dans phytrac ',pdtphys,ecritphy,ecrit_tra
+          ecrit_tra = NINT(86400./pdtphys/2.) ! tous les 12H
+c         ecrit_tra = NINT(86400./pdtphys) ! tous les 24H
 
          if(nbtr.lt.nqmax) then
@@ -223,4 +232,5 @@
          PRINT*, 'La frequence de sortie traceurs est  ', ecrit_tra
          itra=0
+	 itap=0
 C         
          CALL ymds2ju(anne_ini, 1, 1, 0.0, zjulian)
@@ -239,9 +249,8 @@
      .                 1,iim,1,jjm+1, 0, zjulian, pdtphys,
      .                 nhori, nid_tra)
-         call histvert(nid_tra, 'sig_s', 'Niveaux sigma','-',
-     .              klev, znivsig, nvert)
-C
-C         CALL histvert(nid_tra, "presnivs", "Vertical levels", "mb",
-C     .                 klev, presnivs, nvert)
+         CALL histvert(nid_tra, "presnivs", "Vertical levels", "mb",
+     .                 klev, presnivs, nvert)
+         zsto = pdtphys
+         zout = pdtphys * FLOAT(ecrit_tra)
 c
          CALL histdef(nid_tra, "phis", "Surface geop. height", "-",
@@ -252,4 +261,66 @@
      .                iim,jjm+1,nhori, 1,1,1, -99, 32,
      .                "once",  zsto,zout)
+
+	goto 666
+         CALL histdef(nid_tra, "pyu1", "Vent niv 1", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+
+         CALL histdef(nid_tra, "pyv1", "Vent niv 1", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "psrf1", "nature sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "psrf2", "nature sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "psrf3", "nature sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "psrf4", "nature sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "ftsol1", "temper sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "ftsol2", "temper sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "ftsol3", "temper sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst",  zsto,zout)
+         CALL histdef(nid_tra, "ftsol4", "temper sol", "-",
+     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zsto,zout)
+         CALL histdef(nid_tra, "pplay", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "inst(X)", zsto,zout)
+         CALL histdef(nid_tra, "t", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "inst(X)", zsto,zout)
+         CALL histdef(nid_tra, "mfu", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "mfd", "flux u decen","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "en_u", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "en_d", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "de_u", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "de_d", "flux u mont","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "coefh", "turbulent coef","-",
+     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+
+666	continue
 c
          DO it=1,nqmax
@@ -271,4 +342,13 @@
          ENDDO
          CALL histend(nid_tra)
+         ndex(1) = 0
+c
+         i = NINT(zout/zsto)
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
+         CALL histwrite(nid_tra,"phis",i,zx_tmp_2d,iim*(jjm+1),ndex)
+C
+         i = NINT(zout/zsto)
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
+         CALL histwrite(nid_tra,"aire",i,zx_tmp_2d,iim*(jjm+1),ndex)
 
 c======================================================================
@@ -284,4 +364,11 @@
             enddo
          END DO
+
+         open (99,file='starttrac',status='old',
+     .         err=999,form='formatted')
+         read(99,*) (trs(i,1),i=1,klon)
+999      close(99)
+         print*, 'apres starttrac'
+
 c Initialisation de la fraction d'aerosols lessivee
 c
@@ -317,11 +404,75 @@
          inirnpb=.false.
       endif
+      if(nqmax.gt.2) aerosol(3)=.true.
+
+
+c  abder
+	goto 777
+            do i=1,nlon
+               pftsol1(i) = ftsol(i,1)
+               pftsol2(i) = ftsol(i,2)
+               pftsol3(i) = ftsol(i,3)
+               pftsol4(i) = ftsol(i,4)
+
+               ppsrf1(i) = pctsrf(i,1)
+               ppsrf2(i) = pctsrf(i,2)
+               ppsrf3(i) = pctsrf(i,3)
+               ppsrf4(i) = pctsrf(i,4)
+
+            enddo
+	 ndex(1)=0
+	 itap=itap+1
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yu1,zx_tmp_2d)
+         CALL histwrite(nid_tra,"pyu1",itap,zx_tmp_2d,
+     s                                  iim*(jjm+1),ndex)
+         
+	 CALL gr_fi_ecrit(1,klon,iim,jjm+1,yv1,zx_tmp_2d)
+         CALL histwrite(nid_tra,"pyv1",itap,zx_tmp_2d,
+     s                                  iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol1,zx_tmp_2d)
+         CALL histwrite(nid_tra,"ftsol1",itap,zx_tmp_2d,
+     s                                       iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol2,zx_tmp_2d)
+         CALL histwrite(nid_tra,"ftsol2",itap,zx_tmp_2d,
+     s                                       iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol3,zx_tmp_2d)
+         CALL histwrite(nid_tra,"ftsol3",itap,zx_tmp_2d,
+     s                                      iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol4,zx_tmp_2d)
+         CALL histwrite(nid_tra,"ftsol4",itap,zx_tmp_2d,
+     s                                      iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf1,zx_tmp_2d)
+         CALL histwrite(nid_tra,"psrf1",itap,zx_tmp_2d,
+     s                                     iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf2,zx_tmp_2d)
+         CALL histwrite(nid_tra,"psrf2",itap,zx_tmp_2d, 
+     s                                     iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf3,zx_tmp_2d)
+         CALL histwrite(nid_tra,"psrf3",itap,zx_tmp_2d,
+     s                                     iim*(jjm+1),ndex)
+
+         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf4,zx_tmp_2d)
+         CALL histwrite(nid_tra,"psrf4",itap,zx_tmp_2d,
+     s                                     iim*(jjm+1),ndex)
+777	continue
 c======================================================================
 c   Calcul de l'effet de la convection
 c======================================================================
+	print*,'Avant convection'
+      do it=1,nqmax
+         WRITE(itn,'(i1)') it
+c        call diagtracphy(tr_seri(:,:,it),paprs,'Avant conv'//itn)
+      enddo
 
       if (convection) then
 
-c     print*,'Pas de temps dans phytrac : ',pdtphys
+      print*,'Pas de temps dans phytrac : ',pdtphys
       DO it=1, nqmax
       CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
@@ -332,17 +483,26 @@
       ENDDO
       ENDDO
-      WRITE(itn,'(i1)') it
-      CALL minmaxqfi(tr_seri(1,1,it),0.,1.e33,'convection it='//itn)
-      ENDDO
-c     print*,'apres nflxtr'
+c      WRITE(itn,'(i1)') it
+c      CALL minmaxqfi(tr_seri(1,1,it),0.,1.e33,'convection it='//itn)
+      ENDDO
+c      print*,'apres nflxtr'
 
 
       endif ! convection
+c        print*,'Apres convection'
+c      do it=1,nqmax
+c         WRITE(itn,'(i1)') it
+c        call diagtracphy(tr_seri(:,:,it),paprs,'Avant conv'//itn)
+c      enddo
 
 c======================================================================
 c   Calcul de l'effet de la couche limite
 c======================================================================
-
-c     print*,'avant couchelimite'
+c	print *,'Avant couchelimite'
+c      do it=1,nqmax
+c         WRITE(itn,'(i1)') it
+c        call diagtracphy(tr_seri(:,:,it),paprs,'Avant CL  '//itn)
+c      enddo
+
       if (couchelimite) then
 
@@ -403,5 +563,9 @@
       endif ! couche limite
 
-c     print*,'apres couchelimite'
+c      print*,'Apres couchelimite'
+c      do it=1,nqmax
+c         WRITE(itn,'(i1)') it
+c        call diagtracphy(tr_seri(:,:,it),paprs,'Avant CL  '//itn)
+c      enddo
 
 c======================================================================
@@ -432,4 +596,5 @@
 c======================================================================
 
+      print*,'LESSIVAGE =',lessivage
       IF (lessivage) THEN
 
@@ -464,14 +629,20 @@
 c Mise a jour due a l'impaction et a la nucleation
 c
+c      call dump2d(iim,jjm-1,frac_impa(2:klon-1,10),'FRACIMPA')
+c      call dump2d(iim,jjm-1,frac_nucl(2:klon-1,10),'FRACNUCL')
+c      call dump2d(iim,jjm-1,tr_seri(2:klon-1,10,3),'TRACEUR3')
        DO it = 1, nqmax
+c         print*,'IT=',it,aerosol(it)
          IF (aerosol(it)) THEN
+c           print*,'IT=',it,' On lessive'
            DO k = 1, nlev
               DO i = 1, klon
-               tr_seri(i,k,it) = tr_seri(i,k,it) *
-     s              ( frac_impa(i,k) + frac_nucl(i,k) - 1. )    
+               tr_seri(i,k,it)=tr_seri(i,k,it)
+     s         *frac_impa(i,k)*frac_nucl(i,k)
               ENDDO
            ENDDO
          ENDIF
        ENDDO
+c      call dump2d(iim,jjm-1,tr_seri(2:klon-1,10,3),'TRACEUR3B')
 c
 c Flux lessivage total 
@@ -507,16 +678,5 @@
       ENDDO
       itra=itra+1
-
-C
-C Sorties IOIPSL
-      ndex2d = 0
-      ndex3d = 0
-c
-c     write(*,*)'sorties ioipsl phytrac',zsto,zout
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_tra,"phis",itra,zx_tmp_2d,iim*(jjm+1),ndex2d)
-C
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
-      CALL histwrite(nid_tra,"aire",itra,zx_tmp_2d,iim*(jjm+1),ndex2d)
+      ndex(1) = 0
       DO it=1,nqmax
       IF (it.LE.99) THEN
@@ -525,10 +685,10 @@
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
        CALL histwrite(nid_tra,"tr"//str2,itra,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-       IF (lessivage) THEN
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,flestottr(1,1,it),zx_tmp_3d)
-       CALL histwrite(nid_tra,"fl"//str2,itra,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-      ENDIF
+     .                                   iim*(jjm+1)*klev,ndex)
+c      IF (lessivage) THEN
+c      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,flestottr(1,1,it),zx_tmp_3d)
+c      CALL histwrite(nid_tra,"fl"//str2,itra,zx_tmp_3d,
+c    .                                   iim*(jjm+1)*klev,ndex)
+c     ENDIF
       ELSE
          PRINT*, "Trop de traceurs"
@@ -536,5 +696,55 @@
       ENDIF
       ENDDO
-      if (ok_sync) call histsync(nid_tra)
+
+	goto 888
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay,zx_tmp_3d)
+        CALL histwrite(nid_tra,"pplay",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri,zx_tmp_3d)
+        CALL histwrite(nid_tra,"t",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfu,zx_tmp_3d)
+        CALL histwrite(nid_tra,"mfu",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfd,zx_tmp_3d)
+        CALL histwrite(nid_tra,"mfd",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_u,zx_tmp_3d)
+        CALL histwrite(nid_tra,"en_u",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_d,zx_tmp_3d)
+        CALL histwrite(nid_tra,"en_d",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_d,zx_tmp_3d)
+        CALL histwrite(nid_tra,"de_d",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_u,zx_tmp_3d)
+        CALL histwrite(nid_tra,"de_u",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,coefh,zx_tmp_3d)
+        CALL histwrite(nid_tra,"coefh",itra,zx_tmp_3d,
+     .                  iim*(jjm+1)*klev,ndex)
+
+888	continue
+
+c	print*,'Sortie phytrac'
+c      do it=1,nqmax
+c         WRITE(itn,'(i1)') it
+c        call diagtracphy(tr_seri(:,:,it),paprs,'Fin Phys  '//itn)
+c      enddo
+
+      if (lafin) then
+         print*, 'c est la fin de la physique'
+         open (99,file='restarttrac',  form='formatted')
+         do i=1,klon
+             write(99,*) trs(i,1)
+         enddo
+         PRINT*, 'Ecriture du fichier restarttrac'
+         close(99)
+      else
+         print*, 'physique pas fini'
+      endif
+
 
       RETURN
Index: /LMDZ.3.3/branches/rel-LF/libf/phylmd/raddim.h
===================================================================
--- /LMDZ.3.3/branches/rel-LF/libf/phylmd/raddim.h	(revision 229)
+++ /LMDZ.3.3/branches/rel-LF/libf/phylmd/raddim.h	(revision 230)
@@ -1,2 +1,16 @@
       INTEGER kdlon, kflev
-      PARAMETER (kdlon=149,kflev=klev)
+c
+ccc      PARAMETER (kdlon=klon,kflev=klev)
+c
+c resolution 72 45:
+      PARAMETER (kdlon=317,kflev=klev)
+c resolution 64 32:
+ccc      PARAMETER (kdlon=331,kflev=klev)
+c resolution 96 49:
+ccc      PARAMETER (kdlon=461,kflev=klev)
+c resolution 144 73:
+ccc      PARAMETER (kdlon=610,kflev=klev)
+c resolution 96 72:
+c      PARAMETER (kdlon=487,kflev=klev)
+c resolution 128 64:
+ccc       PARAMETER (kdlon=4033,kflev=klev)
