Index: LMDZ6/trunk/libf/phylmd/thermcell_down.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/thermcell_down.F90	(revision 4395)
+++ LMDZ6/trunk/libf/phylmd/thermcell_down.F90	(revision 4396)
@@ -1,3 +1,3 @@
-   SUBROUTINE thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,eup,dup,edn,ddn,masse,trac)
+   SUBROUTINE thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,eup,dup,edn,ddn,masse,trac,dtrac)
 
 !-----------------------------------------------------------------
@@ -25,6 +25,7 @@
    real,intent(in), dimension(ngrid,nlay) :: ddn ! detrainment from downdrafts * dz [same unit as flux]
    real,intent(in), dimension(ngrid,nlay) :: masse ! mass of layers = rho dz 
-   real,intent(inout), dimension(ngrid,nlay) :: trac ! tracer 
+   real,intent(in), dimension(ngrid,nlay) :: trac ! tracer 
    integer, intent(in), dimension(ngrid) :: lmax ! max level index at which downdraft are present
+   real,intent(out),dimension(ngrid,nlay) ::dtrac ! tendance du traceur
 
    
@@ -32,5 +33,5 @@
 
    real, dimension(ngrid,nlay+1) :: fup,fdn,fthu,fthd,fthe,fthtot
-   real, dimension(ngrid,nlay) :: tracu,tracd,dtrac
+   real, dimension(ngrid,nlay) :: tracu,tracd
    real :: www
    integer ig,ilay
@@ -68,5 +69,5 @@
    do ilay=1,nlay,1
       do ig=1,ngrid
-         if (ilay.le.lmax(ig) .and. lmax(ig)>1) then
+         if (ilay.lt.lmax(ig) .and. lmax(ig)>1) then
             fup(ig,ilay+1)=fup(ig,ilay)+eup(ig,ilay)-dup(ig,ilay)
             if (ilay == 1 ) then
@@ -83,5 +84,5 @@
       enddo 
    enddo
-   !Boucle pour calculer le flux up
+   !Boucle pour calculer le flux du traceur flux updraft, flux downdraft, flux compensatoire
    do ilay=2,nlay,1
      do ig=1,ngrid
@@ -95,4 +96,6 @@
        endif
        fthe(ig,ilay)=-(fup(ig,ilay)-fdn(ig,ilay))*trac(ig,ilay)
+       !! si on voulait le prendre en compte on
+       !fthe(ig,ilay)=-(fup(ig,ilay)-fdn(ig,ilay))*trac(ig,ilay-1)
        fthtot(ig,ilay)=fthu(ig,ilay)+fthd(ig,ilay)+fthe(ig,ilay)
      enddo
@@ -101,17 +104,8 @@
    do ilay=1,nlay,1
      do ig=1,ngrid
-       dtrac(ig,ilay)=(fthtot(ig,ilay)-fthtot(ig,ilay+1))*(ptimestep/masse(ig,ilay))
+       dtrac(ig,ilay)=(fthtot(ig,ilay)-fthtot(ig,ilay+1))*(1./masse(ig,ilay))
 !       trac(ig,ilay)=trac(ig,ilay) + (fthtot(ig,ilay)-fthtot(ig,ilay+1))*(ptimestep/masse(ig,ilay))
      enddo
    enddo
-   if (1==0) then
-    do ilay=1,nlay,1
-     do ig=1,ngrid
-       trac(ig,ilay)=trac(ig,ilay) + (fup(ig,ilay)*tracu(ig,ilay-1)-fup(ig,ilay+1)*tracu(ig,ilay) + &
-       & (fup(ig,ilay+1)+fdn(ig,ilay+1))*trac(ig,ilay+1) - (fup(ig,ilay)+fdn(ig,ilay))*trac(ig,ilay) + &
-       & fdn(ig,ilay+1)*tracd(ig,ilay+1)-fdn(ig,ilay)*tracd(ig,ilay))*(ptimestep/masse(ig,ilay))
-     enddo
-    enddo
-   endif
 ! Il reste a coder : 
 ! d(rho trac)/dt = - d/dz(rho w'trac')
Index: LMDZ6/trunk/libf/phylmd/thermcell_main.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/thermcell_main.F90	(revision 4395)
+++ LMDZ6/trunk/libf/phylmd/thermcell_main.F90	(revision 4396)
@@ -479,4 +479,21 @@
       endif
 
+!------------------------------------------------------------------
+! Calcul de la fraction de l'ascendance
+!------------------------------------------------------------------
+      do ig=1,ngrid
+         fraca(ig,1)=0.
+         fraca(ig,nlay+1)=0.
+      enddo
+      do l=2,nlay
+         do ig=1,ngrid
+            if (zw2(ig,l).gt.1.e-10) then
+            fraca(ig,l)=fm(ig,l)/(rhobarz(ig,l)*zw2(ig,l))
+            else
+            fraca(ig,l)=0.
+            endif
+         enddo
+      enddo
+     
 !c------------------------------------------------------------------
 !   calcul du transport vertical
@@ -485,12 +502,16 @@
         print*,'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
         print*,'WARNING !!! routine thermcell_down en cours de developpement'
-        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,0.5*detr0,0.5*entr0,masse,zthl)
-      ENDIF
+        ! on veut transporter la temperature potentielle, l'eau totale, qté de mouvement
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,0.5*detr0,0.5*entr0,masse,zthl,zdthladj)
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,0.5*detr0,0.5*entr0,masse,po,pdoadj)
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,0.5*detr0,0.5*entr0,masse,zu,pduadj)
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,0.5*detr0,0.5*entr0,masse,zv,pdvadj)
+      ELSE
       !--------------------------------------------------------------
 
-      call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
-     &                    zthl,zdthladj,zta,lev_out)
-      call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
-     &                   po,pdoadj,zoa,lev_out)
+        call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
+        &                    zthl,zdthladj,zta,lev_out)
+        call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
+        &                   po,pdoadj,zoa,lev_out)
 
 #ifdef ISO
@@ -534,22 +555,4 @@
 
 
-
-!------------------------------------------------------------------
-! Calcul de la fraction de l'ascendance
-!------------------------------------------------------------------
-      do ig=1,ngrid
-         fraca(ig,1)=0.
-         fraca(ig,nlay+1)=0.
-      enddo
-      do l=2,nlay
-         do ig=1,ngrid
-            if (zw2(ig,l).gt.1.e-10) then
-            fraca(ig,l)=fm(ig,l)/(rhobarz(ig,l)*zw2(ig,l))
-            else
-            fraca(ig,l)=0.
-            endif
-         enddo
-      enddo
-     
 !------------------------------------------------------------------
 !  calcul du transport vertical du moment horizontal
@@ -576,4 +579,5 @@
 
       endif
+    ENDIF
 
 !     print*,'13 OK convect8'
