Index: LMDZ6/trunk/libf/phylmdiso/calcratqs.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/calcratqs.F90	(revision 4612)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../phylmd/calcratqs.F90
Index: LMDZ6/trunk/libf/phylmdiso/calcratqs_multi_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/calcratqs_multi_mod.F90	(revision 4612)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../phylmd/calcratqs_multi_mod.F90
Index: LMDZ6/trunk/libf/phylmdiso/concvl.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/concvl.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/concvl.F90	(revision 4613)
@@ -3,5 +3,5 @@
                   t, q, t_wake, q_wake, s_wake, u, v, tra, ntra, &
                   Ale, Alp, sig1, w01, &
-                  d_t, d_q, d_u, d_v, d_tra, &
+                  d_t, d_q, d_qcomp, d_u, d_v, d_tra, &
                   rain, snow, kbas, ktop, sigd, &
                   cbmf, plcl, plfc, wbeff, convoccur, &
@@ -16,5 +16,5 @@
                   dd_t, dd_q, lalim_conv, wght_th, &                 ! RomP
                   evap, ep, epmlmMm, eplaMm, &                       ! RomP
-                  wdtrainA, wdtrainS, wdtrainM, wght, qtc, sigt, &
+                  wdtrainA, wdtrainS, wdtrainM, wght, qtc, sigt, detrain, &
                   tau_cld_cv, coefw_cld_cv, &                           ! RomP+RL, AJ
 !RomP <<<
@@ -138,5 +138,5 @@
   REAL, DIMENSION(klon,klev),   INTENT(INOUT)   :: sig1, w01
 
-  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: d_t, d_q, d_u, d_v
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: d_t, d_q, d_qcomp, d_u, d_v
   REAL, DIMENSION(klon,klev, nbtr),INTENT(OUT)  :: d_tra
   REAL, DIMENSION(klon),        INTENT(OUT)     :: rain, snow
@@ -186,5 +186,5 @@
   REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: wght                       !RL
   REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: qtc
-  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: sigt
+  REAL, DIMENSION(klon,klev),   INTENT(OUT)     :: sigt, detrain
   REAL,                         INTENT(OUT)     :: tau_cld_cv, coefw_cld_cv
   REAL, DIMENSION(klon),        INTENT(OUT)     :: epmax_diag                ! epmax_cape
@@ -588,5 +588,5 @@
                     Ale, Alp, omega, &
                     em_sig1feed, em_sig2feed, em_wght, &
-                    iflag, d_t, d_q, d_u, d_v, d_tra, rain, kbas, ktop, &
+                    iflag, d_t, d_q, d_qcomp, d_u, d_v, d_tra, rain, kbas, ktop, &
                     cbmf, plcl, plfc, wbeff, sig1, w01, ptop2, sigd, &
                     Ma, mip, Vprecip, Vprecipi, upwd, dnwd, dnwdbis, qcondc, wd, &
@@ -599,5 +599,5 @@
                     da, phi, mp, phii, d1a, dam, sij, wght, &           ! RomP+RL
                     qta, clw, elij, evap, ep, epmlmMm, eplaMm, &        ! RomP+RL
-                    wdtrainA, wdtrainS, wdtrainM, qtc, sigt, &
+                    wdtrainA, wdtrainS, wdtrainM, qtc, sigt, detrain, &
                     tau_cld_cv, coefw_cld_cv, &                         ! RomP,AJ
 !AC!+!RomP+jyg
Index: LMDZ6/trunk/libf/phylmdiso/cv3_routines.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/cv3_routines.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/cv3_routines.F90	(revision 4613)
@@ -4720,9 +4720,9 @@
                      tv, tvp, wghti, &
                      iflag, precip, Vprecip, Vprecipi, &     ! jyg: Vprecipi
-                     ft, fr, fu, fv, ftra, &                 ! jyg
+                     ft, fr, fr_comp, fu, fv, ftra, &                 ! jyg
                      cbmf, upwd, dnwd, dnwd0, ma, mip, &
 !!                     tls, tps,                             ! useless . jyg
                      qcondc, wd, &
-                     ftd, fqd, qta, qtc, sigt, tau_cld_cv, coefw_cld_cv &
+                     ftd, fqd, qta, qtc, sigt, detrain, tau_cld_cv, coefw_cld_cv &
 #ifdef ISO
      &                    ,xt,xt_wake,xtclw,xtp,xtwater,xtice,xtevap &
@@ -4816,5 +4816,5 @@
 !outputs:
       REAL, DIMENSION (nloc), INTENT (OUT)               :: precip
-      REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: ft, fr, fu, fv
+      REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: ft, fr, fu, fv , fr_comp
       REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: ftd, fqd
       REAL, DIMENSION (nloc, nd, ntra), INTENT (OUT)     :: ftra
@@ -4826,4 +4826,5 @@
       REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: qcondc                      ! cld
       REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: qtc, sigt                   ! cld
+      REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: detrain                     ! Louis : pour le calcul de Klein du terme de variance qui détraine dans lenvironnement
       REAL, DIMENSION (nloc), INTENT (OUT)               :: wd                          ! gust
       REAL, DIMENSION (nloc), INTENT (OUT)               :: cbmf
@@ -4852,4 +4853,5 @@
       REAL, DIMENSION (nloc)                             :: esum, fsum, gsum, hsum
       REAL, DIMENSION (nloc, nd)                         :: th_wake
+      REAL, DIMENSION (nloc, nd, nd)                     :: qdet
       REAL, DIMENSION (nloc)                             :: alpha_qpos, alpha_qpos1
       REAL, DIMENSION (nloc, nd)                         :: qcond, nqcond, wa           ! cld
@@ -4940,4 +4942,5 @@
       ft(il, i) = 0.0
       fr(il, i) = 0.0
+      fr_comp(il,i) = 0.0
       fu(il, i) = 0.0
       fv(il, i) = 0.0
@@ -4950,4 +4953,6 @@
       sigment(il, i) = 0.0 ! cld
       sigt(il, i) = 0.0 ! cld
+      qdet(il,i,:) = 0.0 ! cld
+      detrain(il, i) = 0.0 ! cld
       nqcond(il, i) = 0.0 ! cld
 #ifdef ISO
@@ -5358,4 +5363,5 @@
       IF (j<=inb(il) .AND. iflag(il)<=1) THEN
         fr(il, 1) = fr(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(qent(il,j,1)-rr(il,1))
+        fr_comp(il,1) = fr_comp(il,1) + 0.01*grav*work(il)*ment(il, j, 1)*(qent(il,j,1)-rr(il,1))
 
 #ifdef ISO
@@ -5627,4 +5633,5 @@
       IF (i<=inb(il) .AND. iflag(il)<=1) num1 = num1 + 1
     END DO
+        qdet(il,i,i) = qent(il,i,i)                                            ! cld Louis : specific humidity in detraining water
     IF (num1<=0) GO TO 500
 
@@ -6243,4 +6250,5 @@
           fr(il, i) = fr(il, i) + 0.01*grav*dpinv*ment(il, k, i) * &
                                                        (qent(il,k,i)-awat(il)-rr(il,i))
+          fr_comp(il,i) = fr_comp(il,i) + 0.01*grav*dpinv*ment(il, k, i)*(qent(il,k,i)-awat(il)-rr(il,i))
 
 #ifdef ISO
@@ -6313,4 +6321,5 @@
 ! (saturated updrafts resulting from mixing)                                   ! cld
           qcond(il, i) = qcond(il, i) + (elij(il,k,i)-awat(il))                ! cld
+          qdet(il,k,i) = (qent(il,k,i)-awat(il))                               ! cld Louis : specific humidity in detraining water
           qtment(il, i) = qtment(il, i) + qent(il,k,i)                         ! cld
           nqcond(il, i) = nqcond(il, i) + 1.                                   ! cld
@@ -6460,4 +6469,5 @@
 ! (saturated downdrafts resulting from mixing)                                 ! cld
           qcond(il, i) = qcond(il, i) + elij(il, k, i)                         ! cld
+          qdet(il,k,i) = qent(il,k,i)                                          ! cld Louis : specific humidity in detraining water
           qtment(il, i) = qent(il,k,i) + qtment(il,i)                          ! cld
           nqcond(il, i) = nqcond(il, i) + 1.                                   ! cld
@@ -7255,4 +7265,5 @@
         IF  (k<=inb(il) .AND. i<=inb(il) .AND. iflag(il)<=1) THEN   ! cld
           sument(il) =sument(il) + abs(ment(il,k,i))
+          detrain(il,i) = detrain(il,i) + abs(ment(il,k,i))*(qdet(il,k,i) - rr(il,i))*(qdet(il,k,i) - rr(il,i)) ! Louis terme de détrainement dans le bilan de variance
         ENDIF
       ENDDO     ! il
Index: LMDZ6/trunk/libf/phylmdiso/cv3a_uncompress.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/cv3a_uncompress.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/cv3a_uncompress.F90	(revision 4613)
@@ -2,5 +2,5 @@
                            iflag, kbas, ktop, &
                            precip, cbmf, plcl, plfc, wbeff, sig, w0, ptop2, &
-                           ft, fq, fu, fv, ftra,  &
+                           ft, fq, fqcomp, fu, fv, ftra,  &
                            sigd, ma, mip, vprecip, vprecipi, upwd, dnwd, dnwd0, &
                            qcondc, wd, cape, cin, &
@@ -12,9 +12,9 @@
                            qta, clw, elij, evap, ep, epmlmMm, eplaMm, &         ! RomP+jyg
                            wdtrainA, wdtrainS, wdtrainM, &                      ! RomP
-                           qtc, sigt,          &
+                           qtc, sigt, detrain,         &
                            epmax_diag, & ! epmax_cape
                            iflag1, kbas1, ktop1, &
                            precip1, cbmf1, plcl1, plfc1, wbeff1, sig1, w01, ptop21, &
-                           ft1, fq1, fu1, fv1, ftra1, &
+                           ft1, fq1, fqcomp1, fu1, fv1, ftra1, &
                            sigd1, ma1, mip1, vprecip1, vprecipi1, upwd1, dnwd1, dnwd01, &
                            qcondc1, wd1, cape1, cin1, &
@@ -26,5 +26,5 @@
                            qta1, clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, &  ! RomP+jyg
                            wdtrainA1, wdtrainS1, wdtrainM1, &                   ! RomP
-                           qtc1, sigt1, &
+                           qtc1, sigt1, detrain1, &
                            epmax_diag1  & ! epmax_cape
 #ifdef ISO
@@ -72,5 +72,5 @@
   REAL, DIMENSION (nloc), INTENT (IN)                :: ptop2
   REAL, DIMENSION (nloc), INTENT (IN)                :: epmax_diag
-  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: ft, fq, fu, fv
+  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: ft, fq, fqcomp, fu, fv
   REAL, DIMENSION (nloc, nd, ntra), INTENT (IN)      :: ftra
   REAL, DIMENSION (nloc), INTENT (IN)                :: sigd
@@ -99,5 +99,5 @@
   REAL, DIMENSION (nloc, nd, nd), INTENT (IN)        :: epmlmMm                !RomP+jyg
   REAL, DIMENSION (nloc, nd), INTENT (IN)            :: eplamM                 !RomP+jyg
-  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: qtc, sigt              !RomP
+  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: qtc, sigt, detrain              !RomP
   REAL, DIMENSION (nloc, nd), INTENT (IN)            :: wdtrainA, wdtrainS, wdtrainM     !RomP
 
@@ -120,5 +120,5 @@
   REAL, DIMENSION (len), INTENT (OUT)                :: epmax_diag1 ! epmax_cape
   REAL, DIMENSION (len), INTENT (OUT)                :: ptop21
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ft1, fq1, fu1, fv1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: ft1, fq1, fqcomp1, fu1, fv1
   REAL, DIMENSION (len, nd, ntra), INTENT (OUT)      :: ftra1
   REAL, DIMENSION (len), INTENT (OUT)                :: sigd1
@@ -147,5 +147,5 @@
   REAL, DIMENSION (len, nd, nd), INTENT (OUT)        :: epmlmMm1               !RomP+jyg
   REAL, DIMENSION (len, nd), INTENT (OUT)            :: eplamM1                !RomP+jyg
-  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qtc1, sigt1            !RomP
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: qtc1, sigt1, detrain1            !RomP
   REAL, DIMENSION (len, nd), INTENT (OUT)            :: wdtrainA1, wdtrainS1, wdtrainM1   !RomP
 
@@ -244,4 +244,5 @@
         ft1(idcum(i), k) = ft(i, k)
         fq1(idcum(i), k) = fq(i, k)
+        fqcomp1(idcum(i), k) = fqcomp(i, k)
         fu1(idcum(i), k) = fu(i, k)
         fv1(idcum(i), k) = fv(i, k)
@@ -273,4 +274,5 @@
         qtc1(idcum(i), k) = qtc(i, k)
         sigt1(idcum(i), k) = sigt(i, k)
+        detrain1(idcum(i), k) = detrain(i, k)
    
 #ifdef ISO
@@ -418,4 +420,5 @@
       ft1(:, 1:nl) = ft(:, 1:nl)
       fq1(:, 1:nl) = fq(:, 1:nl)
+      fqcomp1(:, 1:nl) = fqcomp(:, 1:nl)
       fu1(:, 1:nl) = fu(:, 1:nl)
       fv1(:, 1:nl) = fv(:, 1:nl)
@@ -447,4 +450,5 @@
       qtc1(:, 1:nl) = qtc(:, 1:nl)
       sigt1(:, 1:nl) = sigt(:, 1:nl)
+      detrain1(:, 1:nl) = detrain(:, 1:nl)
 !
       ma1(:, nlp) = 0.
Index: LMDZ6/trunk/libf/phylmdiso/cva_driver.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/cva_driver.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/cva_driver.F90	(revision 4613)
@@ -11,5 +11,5 @@
                       Ale1, Alp1, omega1, &
                       sig1feed1, sig2feed1, wght1, &
-                      iflag1, ft1, fq1, fu1, fv1, ftra1, &
+                      iflag1, ft1, fq1, fqcomp1, fu1, fv1, ftra1, &
                       precip1, kbas1, ktop1, &
                       cbmf1, plcl1, plfc1, wbeff1, &
@@ -26,5 +26,5 @@
                       da1, phi1, mp1, phi21, d1a1, dam1, sigij1, wghti1, & ! RomP, RL
                       qta1, clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, &  ! RomP, RL
-                      wdtrainA1, wdtrainS1, wdtrainM1, qtc1, sigt1, tau_cld_cv, &     !!jygprl
+                      wdtrainA1, wdtrainS1, wdtrainM1, qtc1, sigt1, detrain1, tau_cld_cv, &     !!jygprl
                       coefw_cld_cv, &                                      ! RomP, AJ
                       epmax_diag1 &  ! epmax_cape
@@ -88,4 +88,5 @@
 ! ntra          Integer        Input        number of tracors
 ! nloc          Integer        Input        dimension of arrays for compressed fields
+! fqcomp1       Real           Output       spec hum tend (only mixed draughts)
 ! k_upper       Integer        Input        upmost level for vertical loops
 ! iflag_con     Integer        Input        version of convect (3/4)
@@ -135,4 +136,5 @@
 ! upwd1         Real           Output       total upward mass flux (adiab+mixed)
 ! dnwd1         Real           Output       saturated downward mass flux (mixed)
+! detrain1      Real           Output     detrainment terme klein
 ! dnwd01        Real           Output       unsaturated downward mass flux
 ! qcondc1       Real           Output       in-cld mixing ratio of condensed water
@@ -209,4 +211,5 @@
   LOGICAL, INTENT (IN)                               :: ok_conserv_q
   REAL, INTENT (IN)                                  :: tau_cld_cv
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: fqcomp1
   REAL, INTENT (IN)                                  :: coefw_cld_cv
   REAL, INTENT (IN)                                  :: delt
@@ -248,4 +251,5 @@
   REAL, DIMENSION (len), INTENT (OUT)                :: cbmf1
   REAL, DIMENSION (len), INTENT (OUT)                :: plcl1
+  REAL, DIMENSION (len, nd), INTENT (OUT)            :: detrain1   ! detrainement term of mixed draughts in environment
   REAL, DIMENSION (len), INTENT (OUT)                :: plfc1
   REAL, DIMENSION (len), INTENT (OUT)                :: wbeff1
@@ -572,5 +576,5 @@
   REAL, DIMENSION(len,nd)     :: ice, fondue, b
   REAL, DIMENSION(len,nd)     :: frac_a, frac_s, faci               !!jygprl
-  REAL ft(nloc, nd), fq(nloc, nd)
+  REAL ft(nloc, nd), fq(nloc, nd), fqcomp(nloc, nd)
   REAL ftd(nloc, nd), fqd(nloc, nd)
   REAL fu(nloc, nd), fv(nloc, nd)
@@ -598,4 +602,5 @@
   REAL qtc(nloc, nd)         ! cld
   REAL sigt(nloc, nd)        ! cld
+  REAL detrain(nloc, nd)     ! cld
  
 ! RomP >>>
@@ -706,4 +711,5 @@
   ft1(:, :) = 0.0
   fq1(:, :) = 0.0
+  fqcomp1(:, :) = 0.0
   fu1(:, :) = 0.0
   fv1(:, :) = 0.0
@@ -766,4 +772,5 @@
 ! RomP >>>
   sigt1(:, :) = 0.
+  detrain1(:, :) = 0.
   qtc1(:, :) = 0.
   wdtrainA1(:, :) = 0.
@@ -1561,4 +1568,5 @@
         if (prt_level >= 9) &
              PRINT *, 'cva_driver -> cv3_yield'
+
       CALL cv3_yield(nloc, ncum, nd, nd, ntra, ok_conserv_q, &                      ! na->nd
                      icb, inb, delt, &
@@ -1570,10 +1578,10 @@
                      nent, elij, traent, sig, &
                      tv, tvp, wghti, &
-                     iflag, precip, Vprecip, Vprecipi, ft, fq, fu, fv, ftra, &      ! jyg
+                     iflag, precip, Vprecip, Vprecipi, ft, fq, fqcomp, fu, fv, ftra, &      ! jyg
                      cbmf, upwd, dnwd, dnwd0, ma, mip, &
 !!                     tls, tps, &                            ! useless . jyg
                      qcondc, wd, &
 !!                     ftd, fqd, qnk, qtc, sigt, tau_cld_cv, coefw_cld_cv)
-                     ftd, fqd, qta, qtc, sigt, tau_cld_cv, coefw_cld_cv &  !!jygprl
+                     ftd, fqd, qta, qtc, sigt,detrain,tau_cld_cv, coefw_cld_cv &  !!jygprl
 #ifdef ISO
      &                     ,xt,xt_wake,xtclw,xtp,xtwater,xtice,xtevap &
@@ -1673,5 +1681,5 @@
                            iflag, icb, inb, &
                            precip, cbmf, plcl, plfc, wbeff, sig, w0, ptop2, &
-                           ft, fq, fu, fv, ftra, &
+                           ft, fq, fqcomp, fu, fv, ftra, &
                            sigd, ma, mip, vprecip, vprecipi, upwd, dnwd, dnwd0, &
                            qcondc, wd, cape, cin, &
@@ -1683,8 +1691,8 @@
                            qta, clw, elij, evap, ep, epmlmMm, eplaMm, &  ! RomP
                            wdtrainA, wdtrainS, wdtrainM, &                         ! RomP
-                           qtc, sigt, epmax_diag, & ! epmax_cape
+                           qtc, sigt, detrain, epmax_diag, & ! epmax_cape
                            iflag1, kbas1, ktop1, &
                            precip1, cbmf1, plcl1, plfc1, wbeff1, sig1, w01, ptop21, &
-                           ft1, fq1, fu1, fv1, ftra1, &
+                           ft1, fq1, fqcomp1, fu1, fv1, ftra1, &
                            sigd1, ma1, mip1, vprecip1, vprecipi1, upwd1, dnwd1, dnwd01, &
                            qcondc1, wd1, cape1, cin1, &
@@ -1696,5 +1704,5 @@
                            qta1, clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, & ! RomP
                            wdtrainA1, wdtrainS1, wdtrainM1,                  & ! RomP
-                           qtc1, sigt1, epmax_diag1 & ! epmax_cape
+                           qtc1, sigt1,detrain1,epmax_diag1 & ! epmax_cape
 #ifdef ISO
      &          ,xtprecip,fxt,fxtd, xtVprecip,xtVprecipi, xtclw,xtevap,xtwdtraina       &
Index: LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_ini.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_ini.F90	(revision 4613)
+++ LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_ini.F90	(revision 4613)
@@ -0,0 +1,1 @@
+link ../phylmd/lmdz_ratqs_ini.F90
Index: LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_main.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_main.F90	(revision 4613)
+++ LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_main.F90	(revision 4613)
@@ -0,0 +1,1 @@
+link ../phylmd/lmdz_ratqs_main.F90
Index: LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_multi.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_multi.F90	(revision 4613)
+++ LMDZ6/trunk/libf/phylmdiso/lmdz_ratqs_multi.F90	(revision 4613)
@@ -0,0 +1,1 @@
+link ../phylmd/lmdz_ratqs_multi.F90
Index: LMDZ6/trunk/libf/phylmdiso/phyetat0_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/phyetat0_mod.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/phyetat0_mod.F90	(revision 4613)
@@ -36,5 +36,5 @@
        zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
        ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, dter, dser, &
-       dt_ds, ratqs_inter
+       dt_ds, ratqs_inter_
 !FC
   USE geometry_mod,     ONLY: longitude_deg, latitude_deg
@@ -510,5 +510,5 @@
 
 ! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
-  found=phyetat0_get(ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
+  found=phyetat0_get(ratqs_inter_,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
 
 !===========================================
Index: LMDZ6/trunk/libf/phylmdiso/phyredem.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/phyredem.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/phyredem.F90	(revision 4613)
@@ -30,5 +30,5 @@
                                 du_gwd_rando, du_gwd_front, u10m, v10m, &
                                 treedrg, solswfdiff, delta_sal, ds_ns, dt_ns, &
-                                delta_sst, ratqs_inter, dter, dser, dt_ds
+                                delta_sst, ratqs_inter_, dter, dser, dt_ds
 #ifdef ISO
   USE phys_state_var_mod, ONLY: xtsol, fxtevap,xtrain_fall, xtsnow_fall,     &
@@ -347,5 +347,5 @@
 
     ! fisrtilp/clouds
-    CALL put_field(pass,"RATQS_INTER","Relative width of the lsc sugrid scale water",ratqs_inter)
+    CALL put_field(pass,"RATQS_INTER","Relative width of the lsc sugrid scale water",ratqs_inter_)
 
 
Index: LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 4612)
+++ LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 4613)
@@ -87,4 +87,6 @@
     USE blowing_snow_ini_mod, ONLY : blowing_snow_ini , qbst_bs 
     USE lscp_ini_mod, ONLY : lscp_ini
+    USE lmdz_ratqs_main, ONLY : ratqs_main
+    USE lmdz_ratqs_ini, ONLY : ratqs_ini
 
     !USE cmp_seri_mod
@@ -519,7 +521,7 @@
     SAVE seuil_inversion
     !$OMP THREADPRIVATE(seuil_inversion)
-    INTEGER iflag_ratqs
-    SAVE iflag_ratqs
-    !$OMP THREADPRIVATE(iflag_ratqs)
+    
+    
+    
     real facteur
 
@@ -1401,5 +1403,5 @@
             solarlong0,seuil_inversion, &
             fact_cldcon, facttemps,ok_newmicro,iflag_radia, &
-            iflag_cld_th,iflag_ratqs,ratqsbas,ratqshaut,tau_ratqs, &
+            iflag_cld_th,ratqsbas,ratqshaut,tau_ratqs, &
             ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan, flag_volc_surfstrat, aerosol_couple, &
             chemistry_couple, flag_aerosol, flag_aerosol_strat, flag_aer_feedback, &
@@ -1917,4 +1919,5 @@
        CALL thermcell_ini(iflag_thermals,prt_level,tau_thermals,lunout, &
    &    RG,RD,RCPD,RKAPPA,RLVTT,RETV)
+       CALL ratqs_ini(klon,klev,iflag_thermals,lunout,nbsrf,is_lic,is_ter,RG,RV,RD,RCPD,RLSTT,RLVTT,RTT)
        CALL lscp_ini(pdtphys,ok_ice_sursat,RCPD, RLSTT, RLVTT, RLMLT, RVTMP2, RTT,RD,RG)
        CALL blowing_snow_ini(prt_level,lunout, &
@@ -3777,5 +3780,5 @@
                ALE,ALP, &
                sig1,w01, &
-               d_t_con,d_q_con,d_u_con,d_v_con,d_tr, &
+               d_t_con,d_q_con,fqcomp,d_u_con,d_v_con,d_tr, &
                rain_con, snow_con, ibas_con, itop_con, sigd, &
                ema_cbmf,plcl,plfc,wbeff,convoccur,upwd,dnwd,dnwd0, &
@@ -3788,5 +3791,5 @@
                ftd,fqd,lalim_conv,wght_th, &
                ev, ep,epmlmMm,eplaMm, &
-               wdtrainA, wdtrainS, wdtrainM,wght_cvfd,qtc_cv,sigt_cv, &
+               wdtrainA, wdtrainS, wdtrainM,wght_cvfd,qtc_cv,sigt_cv,detrain_cv, &
                tau_cld_cv,coefw_cld_cv,epmax_diag &
 #ifdef ISO
@@ -3840,4 +3843,5 @@
           clwcon0=qcondc
           pmfu(:,:)=upwd(:,:)+dnwd(:,:)
+          fm_cv(:,:)=upwd(:,:)+dnwd(:,:)+dnwd0(:,:)
           !
           !jyg<
@@ -4688,12 +4692,15 @@
     ENDDO
 
-    CALL  calcratqs(klon,klev,prt_level,lunout,        &
+    CALL ratqs_main(klon,klev,nbsrf,prt_level,lunout,        &
          iflag_ratqs,iflag_con,iflag_cld_th,pdtphys,  &
          ratqsbas,ratqshaut,ratqsp0, ratqsdp, &
+         pctsrf,s_pblh,zstd, &
          tau_ratqs,fact_cldcon,wake_s, wake_deltaq,   &
          ptconv,ptconvth,clwcon0th, rnebcon0th,     &
-         paprs,pplay,t_seri,q_seri, qtc_cv, sigt_cv, zqsat, &
-         pbl_tke(:,:,is_ave),tke_dissip_ave,l_mix_ave,wprime_ave,t2m,q2m,fm_therm,cell_area, &
-         ratqs,ratqsc,ratqs_inter)
+         paprs,pplay,t_seri,q_seri, &
+         qtc_cv, sigt_cv,detrain_cv,fm_cv,fqd,fqcomp,sigd,zqsat, &
+         omega,pbl_tke(:,:,is_ave),tke_dissip_ave,l_mix_ave,wprime_ave, &
+         t2m,q2m,fm_therm,entr_therm,detr_therm,cell_area, &
+         ratqs,ratqsc,ratqs_inter_)
 
     !
@@ -6206,4 +6213,5 @@
 #endif
 
+
 !===============================================================
 !            Additional tendency of TKE due to orography
