Index: LMDZ6/trunk/libf/phylmd/lmdz_lscp.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_lscp.F90	(revision 4879)
+++ LMDZ6/trunk/libf/phylmd/lmdz_lscp.F90	(revision 4910)
@@ -12,6 +12,6 @@
      radocond, radicefrac, rain, snow,                  &
      frac_impa, frac_nucl, beta,                        &
-     prfl, psfl, rhcl, zqta, fraca,                     &
-     ztv, zpspsk, ztla, zthl, iflag_cld_th,             &
+     prfl, psfl, rhcl, qta, fraca,                     &
+     tv, pspsk, tla, thl, iflag_cld_th,             &
      iflag_ice_thermo, ok_ice_sursat, qsatl, qsats,     &
      distcltop,temp_cltop,                              &
@@ -104,9 +104,9 @@
 USE lmdz_lscp_ini, ONLY : prt_level, lunout
 USE lmdz_lscp_ini, ONLY : seuil_neb, niter_lscp, iflag_evap_prec, t_coup, DDT0, ztfondue, rain_int_min
-USE lmdz_lscp_ini, ONLY : iflag_mpc_bl, ok_radocond_snow, a_tr_sca, cld_expo_con, cld_expo_lsc
+USE lmdz_lscp_ini, ONLY : ok_radocond_snow, a_tr_sca, cld_expo_con, cld_expo_lsc
 USE lmdz_lscp_ini, ONLY : iflag_cloudth_vert, iflag_rain_incloud_vol, iflag_t_glace, t_glace_min 
 USE lmdz_lscp_ini, ONLY : coef_eva, coef_sub,cld_tau_lsc, cld_tau_con, cld_lc_lsc, cld_lc_con
 USE lmdz_lscp_ini, ONLY : iflag_bergeron, iflag_fisrtilp_qsat, iflag_vice, cice_velo, dice_velo
-USE lmdz_lscp_ini, ONLY : iflag_autoconversion, ffallv_con, ffallv_lsc
+USE lmdz_lscp_ini, ONLY : iflag_autoconversion, ffallv_con, ffallv_lsc, min_frac_th_cld
 USE lmdz_lscp_ini, ONLY : RCPD, RLSTT, RLVTT, RLMLT, RVTMP2, RTT, RD, RG
 USE lmdz_lscp_ini, ONLY : ok_poprecip, ok_bug_fonte_lscp
@@ -138,14 +138,14 @@
   !Inputs associated with thermal plumes
 
-  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: ztv             ! virtual potential temperature [K]
-  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: zqta            ! specific humidity within thermals [kg/kg]
-  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: fraca           ! fraction of thermals within the mesh [-]
-  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: zpspsk          ! exner potential (p/100000)**(R/cp) 
-  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: ztla            ! liquid temperature within thermals [K]
+  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: tv             ! virtual potential temperature [K]
+  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: qta            ! specific humidity within thermals [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: fraca          ! fraction of thermals within the mesh [-]
+  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: pspsk          ! exner potential (p/100000)**(R/cp) 
+  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: tla            ! liquid temperature within thermals [K]
 
   ! INPUT/OUTPUT variables
   !------------------------
   
-  REAL, DIMENSION(klon,klev),      INTENT(INOUT)   :: zthl         ! liquid potential temperature [K]
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)   :: thl          ! liquid potential temperature [K]
   REAL, DIMENSION(klon,klev),      INTENT(INOUT)   :: ratqs        ! function of pressure that sets the large-scale
 
@@ -236,5 +236,5 @@
   REAL, DIMENSION(klon) :: Zpdf_a,zpdf_b,zpdf_e1,zpdf_e2
   REAL :: erf
-  REAL, DIMENSION(klon,klev) :: icefrac_mpc
+  REAL, DIMENSION(klon) :: zfice_th
   REAL, DIMENSION(klon) :: qcloud, qincloud_mpc
   REAL, DIMENSION(klon) :: zrfl, zrfln
@@ -713,12 +713,14 @@
 
         IF (iflag_cld_th.GE.5) THEN
-
-             IF (iflag_mpc_bl .LT. 1) THEN 
-
-                IF (iflag_cloudth_vert.LE.2) THEN
-
-                    CALL cloudth(klon,klev,k,ztv,                  &
-                         zq,zqta,fraca,                            &
-                         qcloud,ctot,zpspsk,paprs,pplay,ztla,zthl, &
+               ! Cloud cover and content in meshes affected by shallow convection, 
+               ! are retrieved from a bi-gaussian distribution of the saturation deficit
+               ! following Jam et al. 2013
+
+               IF (iflag_cloudth_vert.LE.2) THEN
+                  ! Old version of Arnaud Jam
+
+                    CALL cloudth(klon,klev,k,tv,                  &
+                         zq,qta,fraca,                            &
+                         qcloud,ctot,pspsk,paprs,pplay,tla,thl, &
                          ratqs,zqs,temp,                              &
                          cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
@@ -726,35 +728,33 @@
 
                 ELSEIF (iflag_cloudth_vert.GE.3 .AND. iflag_cloudth_vert.LE.5) THEN
-
-                    CALL cloudth_v3(klon,klev,k,ztv,                        &
-                         zq,zqta,fraca,                                     &
-                         qcloud,ctot,ctot_vol,zpspsk,paprs,pplay,ztla,zthl, &
+                   ! Default version of Arnaud Jam
+                        
+                    CALL cloudth_v3(klon,klev,k,tv,                        &
+                         zq,qta,fraca,                                     &
+                         qcloud,ctot,ctot_vol,pspsk,paprs,pplay,tla,thl, &
                          ratqs,zqs,temp, &
                          cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
 
-                !Jean Jouhaud's version, Decembre 2018 
-                !-------------------------------------
 
                 ELSEIF (iflag_cloudth_vert.EQ.6) THEN
-
-                    CALL cloudth_v6(klon,klev,k,ztv,                        &
-                         zq,zqta,fraca,                                     &
-                         qcloud,ctot,ctot_vol,zpspsk,paprs,pplay,ztla,zthl, &
+                   ! Jean Jouhaud's version, with specific separation between surface and volume
+                   ! cloud fraction Decembre 2018 
+
+                    CALL cloudth_v6(klon,klev,k,tv,                        &
+                         zq,qta,fraca,                                     &
+                         qcloud,ctot,ctot_vol,pspsk,paprs,pplay,tla,thl, &
                          ratqs,zqs,temp, &
                          cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
 
-                ENDIF
-
-         ELSE 
-                ! cloudth_v3 + cold microphysical considerations 
-                ! + stationary mixed-phase cloud model
-
-                    CALL cloudth_mpc(klon,klev,k,iflag_mpc_bl,mpc_bl_points, &
-                         temp,ztv,zq,zqta,fraca, zpspsk,                      &
-                         paprs,pplay,ztla,zthl,ratqs,zqs,psfl,             &
-                         qcloud,qincloud_mpc,icefrac_mpc,ctot,ctot_vol,    &
-                         cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
-
-         ENDIF ! iflag_mpc_bl
+                ELSEIF (iflag_cloudth_vert .EQ. 7) THEN
+                   ! Updated version of Arnaud Jam (correction by E. Vignon) + adapted treatment
+                   ! for boundary-layer mixed phase clouds following Vignon et al.  
+                    CALL cloudth_mpc(klon,klev,k,mpc_bl_points,zt,zq,qta(:,k),fraca(:,k), &
+                                     pspsk(:,k),paprs(:,k+1),paprs(:,k),pplay(:,k), tla(:,k), &
+                                     ratqs(:,k),qcloud,qincloud_mpc,zfice_th,ctot(:,k),ctot_vol(:,k), &
+                                     cloudth_sth(:,k),cloudth_senv(:,k),cloudth_sigmath(:,k),cloudth_sigmaenv(:,k))
+
+                ENDIF
+
 
                 DO i=1,klon
@@ -774,5 +774,5 @@
             
                 ! lognormal distribution when no thermals 
-            lognormale = fraca(:,k) < 1e-10
+            lognormale = fraca(:,k) < min_frac_th_cld
 
         ELSE
@@ -934,7 +934,6 @@
             temp_cltop(:,k)=temp_cltop1D(:)
         ENDIF   
-
         ! Partition function in stratiform clouds (will be overwritten in boundary-layer MPCs)
-        CALL icefrac_lscp(klon,zt,iflag_ice_thermo,distcltop1D,temp_cltop1D,zfice, dzfice)
+        CALL icefrac_lscp(klon,zt,iflag_ice_thermo,distcltop1D,temp_cltop1D,zfice,dzfice)
 
 
@@ -943,4 +942,5 @@
 
             IF (mpc_bl_points(i,k) .GT. 0) THEN
+               
                 zcond(i) = MAX(0.0,qincloud_mpc(i))*rneb(i,k)
                 ! following line is very strange and probably wrong
@@ -948,5 +948,5 @@
                 ! water vapor update and partition function if thermals
                 zq(i) = zq(i) - zcond(i)        
-                zfice(i)=icefrac_mpc(i,k)
+                zfice(i)=zfice_th(i)
 
             ELSE
@@ -1314,4 +1314,5 @@
     ENDIF
 
+
     ENDIF ! ok_poprecip
 
