Index: LMDZ6/branches/Ocean_skin/libf/phylmd/cva_driver.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/cva_driver.F90	(revision 3428)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/cva_driver.F90	(revision 3605)
@@ -25,6 +25,6 @@
 !!                      elij1,evap1,ep1,epmlmMm1,eplaMm1, &                ! RomP
                       da1, phi1, mp1, phi21, d1a1, dam1, sigij1, wghti1, & ! RomP, RL
-                      clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, &        ! RomP, RL
-                      wdtrainA1, wdtrainM1, qtc1, sigt1, tau_cld_cv, &
+                      qta1, clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, &  ! RomP, RL
+                      wdtrainA1, wdtrainS1, wdtrainM1, qtc1, sigt1, tau_cld_cv, &     !!jygprl
                       coefw_cld_cv, &                                      ! RomP, AJ
                       epmax_diag1)  ! epmax_cape
@@ -124,5 +124,7 @@
 !                                      of dimension ND, defined at same grid levels as T, Q, QS and P.
 
-! wdtrainA1     Real           Output   precipitation detrained from adiabatic draught;
+! wdtrainA1     Real           Output   precipitation ejected from adiabatic draught;
+!                                         should be used in tracer transport (cvltr)
+! wdtrainS1     Real           Output   precipitation detrained from shedding of adiabatic draught;
 !                                         used in tracer transport (cvltr)
 ! wdtrainM1     Real           Output   precipitation detrained from mixed draughts;
@@ -248,5 +250,5 @@
 
 ! RomP >>>
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: wdtrainA1, wdtrainM1 ! precipitation sources (extensive)
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: wdtrainA1, wdtrainS1, wdtrainM1 ! precipitation sources (extensive)
   REAL, DIMENSION (len, nd), INTENT (OUT)            :: mp1  ! unsat. mass flux (staggered grid)
   REAL, DIMENSION (len, nd), INTENT (OUT)            :: da1  ! detrained mass flux of adiab. asc. air (extensive)
@@ -258,4 +260,5 @@
   REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: sigij1 ! mass fraction of env. air in mixed draughts (intensive) 
   REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: elij1! cond. water per unit mass of mixed draughts (intensive) 
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qta1 ! total water per unit mass of the adiab. asc. (intensive)
   REAL, DIMENSION (len, nd), INTENT (OUT)            :: clw1 ! cond. water per unit mass of the adiab. asc. (intensive) 
 !JYG,RL
@@ -467,4 +470,5 @@
   REAL tv_wake(nloc, nd)
   REAL clw(nloc, nd)
+  REAL, DIMENSION(nloc, nd)    :: qta, qpreca                       !!jygprl
   REAL dph(nloc, nd)
   REAL pbase(nloc), buoybase(nloc), th(nloc, nd)
@@ -477,4 +481,5 @@
   REAL cin(nloc)
   REAL m(nloc, nd)
+  REAL mm(nloc, nd)
   REAL ment(nloc, nd, nd), sigij(nloc, nd, nd)
   REAL qent(nloc, nd, nd)
@@ -494,5 +499,5 @@
   REAL, DIMENSION(len,nd)     :: wt, water, evap
   REAL, DIMENSION(len,nd)     :: ice, fondue, b
-  REAL, DIMENSION(len,nd)     :: frac, faci
+  REAL, DIMENSION(len,nd)     :: frac_a, frac_s, faci               !!jygprl
   REAL ft(nloc, nd), fq(nloc, nd)
   REAL ftd(nloc, nd), fqd(nloc, nd)
@@ -523,5 +528,5 @@
  
 ! RomP >>>
-  REAL wdtrainA(nloc, nd), wdtrainM(nloc, nd)
+  REAL wdtrainA(nloc, nd), wdtrainS(nloc, nd), wdtrainM(nloc, nd)   !!jygprl
   REAL da(len, nd), phi(len, nd, nd)
   REAL epmlmMm(nloc, nd, nd), eplaMm(nloc, nd)
@@ -613,4 +618,7 @@
   asupmaxmin1(:) = 0.
 
+  tvp(:, :) = 0. !ym missing init, need to have a look by developpers
+  tv(:, :) = 0. !ym missing init, need to have a look by developpers
+
   DO il = 1, len
     cin1(il) = -100000.
@@ -633,4 +641,5 @@
   qtc1(:, :) = 0.
   wdtrainA1(:, :) = 0.
+  wdtrainS1(:, :) = 0.
   wdtrainM1(:, :) = 0.
   da1(:, :) = 0.
@@ -643,4 +652,5 @@
   sigij1(:, :, :) = 0.
   elij1(:, :, :) = 0.
+  qta1(:,:) = 0.
   clw1(:,:) = 0.
   wghti1(:,:) = 0.
@@ -903,5 +913,5 @@
                          p, ph, h, tv, lv, lf, pbase, buoybase, plcl, &
                          inb, tp, tvp, clw, hp, ep, sigp, buoy, &
-                         frac)
+                         frac_a, frac_s, qpreca, qta)                        !!jygprl
     END IF
 
@@ -912,5 +922,5 @@
                         tnk, qnk, gznk, t, q, qs, gz, &
                         p, dph, h, tv, lv, &
-                        inb, inbis, tp, tvp, clw, hp, ep, sigp, frac)
+                        inb, inbis, tp, tvp, clw, hp, ep, sigp, frac_s)
     END IF
 
@@ -920,5 +930,5 @@
              PRINT *, 'cva_driver -> cv3_epmax_cape'
     call cv3_epmax_fn_cape(nloc,ncum,nd &
-                , ep,hp,icb,inb,clw,nk,t,h,hnk,lv,lf,frac &
+                , ep,hp,icb,inb,clw,nk,t,h,hnk,lv,lf,frac_s &
                 , pbase, p, ph, tv, buoy, sig, w0,iflag &
                 , epmax_diag)
@@ -938,5 +948,6 @@
              PRINT *, 'cva_driver -> cv3p_mixing'
         CALL cv3p_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb, &           ! na->nd
-                         ph, t, q, qs, u, v, tra, h, lv, lf, frac, qnk, &
+!!                         ph, t, q, qs, u, v, tra, h, lv, lf, frac, qnk, &
+                         ph, t, q, qs, u, v, tra, h, lv, lf, frac_s, qta, &      !!jygprl
                          unk, vnk, hp, tv, tvp, ep, clw, sig, &
                          ment, qent, hent, uent, vent, nent, &
@@ -1018,10 +1029,16 @@
              PRINT *, 'cva_driver -> cv3_mixing'
         CALL cv3_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb, &             ! na->nd
-                        ph, t, q, qs, u, v, tra, h, lv, lf, frac, qnk, &
+                        ph, t, q, qs, u, v, tra, h, lv, lf, frac_s, qnk, &
                         unk, vnk, hp, tv, tvp, ep, clw, m, sig, &
                         ment, qent, uent, vent, nent, sigij, elij, ments, qents, traent)
         CALL zilch(hent, nloc*nd*nd)
       ELSE
-        CALL cv3_mixscale(nloc, ncum, nd, ment, m)
+!!jyg:  Essais absurde pour voir
+!!        mm(:,1) = 0.
+!!        DO  i = 2,nd
+!!          mm(:,i) = m(:,i)*(1.-qta(:,i-1))
+!!        ENDDO
+        mm(:,:) = m(:,:)
+        CALL cv3_mixscale(nloc, ncum, nd, ment, mm)
         IF (debut) THEN
           PRINT *, ' cv3_mixscale-> '
@@ -1059,9 +1076,10 @@
                      t_wake, q_wake, qs_wake, gz, u, v, tra, p, ph, &
                      th_wake, tv_wake, lv_wake, lf_wake, cpn_wake, &
-                     ep, sigp, clw, &
+                     ep, sigp, clw, frac_s, qpreca, frac_a, qta, &                    !!jygprl
                      m, ment, elij, delt, plcl, coef_clos, &
                      mp, qp, up, vp, trap, wt, water, evap, fondue, ice, &
                      faci, b, sigd, &
-                     wdtrainA, wdtrainM)                                       ! RomP
+!!                     wdtrainA, wdtrainM)                                       ! RomP
+                     wdtrainA, wdtrainS, wdtrainM)                               !!jygprl
 !
       IF (prt_level >= 10) THEN
@@ -1072,8 +1090,8 @@
            evap(igout,k), fondue(igout,k)
         ENDDO
-        Print *, 'cva_driver after cv3_unsat: wdtrainA, wdtrainM '
+        Print *, 'cva_driver after cv3_unsat: wdtrainA, wdtrainS, wdtrainM '     !!jygprl
         DO k = 1,nd
-        write (6, '(i4,2(1x,e13.6))'), &
-           k, wdtrainA(igout,k), wdtrainM(igout,k)
+        write (6, '(i4,3(1x,e13.6))'), &
+           k, wdtrainA(igout,k), wdtrainS(igout,k), wdtrainM(igout,k)            !!jygprl
         ENDDO
       ENDIF
@@ -1109,5 +1127,5 @@
                      t, q, t_wake, q_wake, s_wake, u, v, tra, &
                      gz, p, ph, h, hp, lv, lf, cpn, th, th_wake, &
-                     ep, clw, m, tp, mp, qp, up, vp, trap, &
+                     ep, clw, qpreca, m, tp, mp, qp, up, vp, trap, &
                      wt, water, ice, evap, fondue, faci, b, sigd, &
                      ment, qent, hent, iflag_mix, uent, vent, &
@@ -1118,5 +1136,8 @@
 !!                     tls, tps, &                            ! useless . jyg
                      qcondc, wd, &
-                     ftd, fqd, qnk, qtc, sigt, tau_cld_cv, coefw_cld_cv)
+!!                     ftd, fqd, qnk, qtc, sigt, tau_cld_cv, coefw_cld_cv)
+                     ftd, fqd, qta, qtc, sigt, tau_cld_cv, coefw_cld_cv)         !!jygprl
+!
+!         Test conseravtion de l'eau
 !
       IF (debut) THEN
@@ -1139,5 +1160,5 @@
                      t, q, u, v, &
                      gz, p, ph, h, hp, lv, cpn, &
-                     ep, clw, frac, m, mp, qp, up, vp, &
+                     ep, clw, frac_s, m, mp, qp, up, vp, &
                      wt, water, evap, &
                      ment, qent, uent, vent, nent, elij, &
@@ -1184,6 +1205,6 @@
                            asupmaxmin, &
                            da, phi, mp, phi2, d1a, dam, sigij, &         ! RomP
-                           clw, elij, evap, ep, epmlmMm, eplaMm, &       ! RomP
-                           wdtrainA, wdtrainM, &                         ! RomP
+                           qta, clw, elij, evap, ep, epmlmMm, eplaMm, &  ! RomP
+                           wdtrainA, wdtrainS, wdtrainM, &                         ! RomP
                            qtc, sigt, epmax_diag, & ! epmax_cape
                            iflag1, kbas1, ktop1, &
@@ -1196,7 +1217,7 @@
                            Plim11, plim21, asupmax1, supmax01, &
                            asupmaxmin1, &
-                           da1, phi1, mp1, phi21, d1a1, dam1, sigij1,  & ! RomP
-                           clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, & ! RomP
-                           wdtrainA1, wdtrainM1,                       & ! RomP
+                           da1, phi1, mp1, phi21, d1a1, dam1, sigij1,  &       ! RomP
+                           qta1, clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, & ! RomP
+                           wdtrainA1, wdtrainS1, wdtrainM1,                  & ! RomP
                            qtc1, sigt1, epmax_diag1) ! epmax_cape
 !   
