Index: LMDZ6/trunk/libf/phylmd/lmdz_lscp_subgridvarq.f90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_lscp_subgridvarq.f90	(revision 6006)
+++ LMDZ6/trunk/libf/phylmd/lmdz_lscp_subgridvarq.f90	(revision 6007)
@@ -32,15 +32,13 @@
 !=======================================================================
 SUBROUTINE ratqs_main(klon,klev,nbsrf,is_ter,is_lic,          &
-           iflag_cld_th,fact_cldcon,pdtphys,                  &
+           iflag_cld_th,pdtphys,                              &
            pctsrf,s_pblh,zstd, wake_s, wake_deltaq,           &
-           ptconv, clwcon0th, rnebcon0th,                     &
            paprs,pplay,t_seri,q_seri,                         &
            qtc_cv, sigt_cv,detrain_cv,fm_cv,fqd,fqcomp,       &
            sigd,qsat,                                         &
            fm_therm,entr_therm,detr_therm,cell_area,          &
-           ratqs,ratqsc,ratqs_inter_,sigma_qtherm)
-
-
-USE clouds_gno_mod,     ONLY: clouds_gno
+           ratqsc,ratqs,ratqs_inter_,sigma_qtherm)
+
+
 USE lmdz_lscp_ini,      ONLY: prt_level, lunout, iflag_ratqs
 USE lmdz_lscp_ini,      ONLY: ratqsbas, ratqshaut
@@ -54,7 +52,11 @@
 ! that is, sigma=ratqs*qmean
 ! Various options controled by flags iflag_cld_th and iflag_ratqs
-! by default, a vertical arctan profile of ratqs is prescribed
-! new options consider an interactive computation of ratqs
-! depending on other physical parameterizations and relief
+! This routine consists in 2 steps.
+! First the "stratiform" ratqs (ratqss, corresponding to stratiform clouds)
+! is computed
+! Then the total ratqs is calculated either taken equal to ratqss or 
+! calculated as a combination of ratqss and 
+! that corresponding to deep convective clouds ratqsc
+! (input of the routine, from the deep convection part).
 ! contact: Frederic Hourdin, frederic.hourdin@lmd.ipsl.fr
 !
@@ -71,5 +73,4 @@
 integer, intent(in) :: nbsrf,is_ter,is_lic ! number of subgrid tiles and indices for land and landice
 integer, intent(in) :: iflag_cld_th        ! flag that controls cloud properties in presence of thermals
-real,intent(in)     :: fact_cldcon         ! factor for convective clouds [-]
 real,intent(in)     :: pdtphys             ! physics time step [s]
 real, dimension(klon,klev+1), intent(in) :: paprs ! pressure at layer interfaces [Pa]
@@ -89,6 +90,4 @@
 
 real, dimension(klon,klev+1), intent(in) :: fm_therm    ! convective mass flux of thermals [kg/s/m2]
-logical, dimension(klon,klev), intent(in) :: ptconv     ! convective grid points
-real, dimension(klon,klev), intent(in)   :: clwcon0th   ! condensed water in thermals updrafts [kg/kg]
 real, dimension(klon,klev),intent(in)    :: wake_deltaq ! difference in humidity between wakes and environment [kg/kg]
 real, dimension(klon),intent(in)         :: wake_s    ! wake fraction area [-]
@@ -97,13 +96,10 @@
 real, dimension(klon),intent(in)         :: s_pblh    ! boundary layer height [m]
 real, dimension(klon),intent(in)         :: zstd      ! sub grid orography standard deviation [m]
+real, dimension(klon,klev), intent(in)   :: ratqsc   ! convective ratqs
                                                         
-! Inout
-real, dimension(klon,klev), intent(inout) :: ratqs    ! ratqs i.e. factor for subgrid standard deviation of humidit
-real, dimension(klon,klev), intent(inout) :: ratqsc   ! convective ratqs
-
 ! Output
+real, dimension(klon,klev), intent(out) :: ratqs    ! ratqs i.e. factor for subgrid standard deviation of humidit
 real, dimension(klon,klev), intent(out) :: ratqs_inter_  ! interactive ratqs
 real, dimension(klon,klev), intent(out) :: sigma_qtherm  ! standard deviation of humidity in thermals [kg/kg]
-real, dimension(klon,klev), intent(out)   :: rnebcon0th  ! cloud fraction associated with thermal updrafts (old method) [-]
 
 
@@ -111,42 +107,22 @@
 integer                    :: i,k
 real, dimension(klon,klev) :: ratqss
-logical, dimension(klon,klev) :: ptconvthfalse
 real                       :: facteur,zfratqs1,zfratqs2
 real, dimension(klon,klev) :: ratqs_oro_
 real                       :: resol, fact
 
-! Ratqs computation
-!------------------
-
-!   old-style convective ratqs computation as a function of q(z=0)-q / q
-!   the ratqsc computed by clouds_gno is replaced
-      if (iflag_cld_th.eq.1) then
-         do k=1,klev
-         do i=1,klon
-            if(ptconv(i,k)) then
-              ratqsc(i,k)=ratqsbas &
-              +fact_cldcon*(q_seri(i,1)-q_seri(i,k))/q_seri(i,k)
-            else
-               ratqsc(i,k)=0.
-            endif
-         enddo
-         enddo
-
-!  through log-normal distribution inversion
-      else if (iflag_cld_th.eq.4) then
-         ptconvthfalse(:,:)=.false.
-         ratqsc(:,:)=0.
-         if(prt_level.ge.9) print*,'avant clouds_gno thermique'
-         call clouds_gno &
-         (klon,klev,q_seri,qsat,clwcon0th,ptconvthfalse,ratqsc,rnebcon0th)
-         if(prt_level.ge.9) print*,' CLOUDS_GNO OK'
-       
-       endif
-
-!   stratiform ratqs
-      if (iflag_ratqs.eq.0) then
-
-! iflag_ratqs=0 corresponds to IPCC 2005 version of the model.
-         do k=1,klev
+
+! First step: stratiform clouds ratqs (ratqss) computation
+!---------------------------------------------------------
+! for all options, the background ratqss is computed as a
+! function increasing from a value at the ground surface
+! (0 or ratqsbas) and a value for the high atmosphere
+! (ratqshaut)
+      
+    if (iflag_ratqs.eq.0) then
+
+      ! iflag_ratqs=0 corresponds to LMDZ4 version of the model
+      ! with a linear function of pressure  
+        
+       do k=1,klev
             do i=1, klon
                ratqss(i,k)=ratqsbas+(ratqshaut-ratqsbas)* &
@@ -155,7 +131,8 @@
          enddo
 
-! for iflag_ratqs = 1 or 2, ratqs is constant above 300 hPa (ratqshaut), 
-! and then linearly varies between  600 and 300 hPa and it is either constant (ratqsbas) for iflag_ratqs=1
-! or lineary varies (between ratqsbas and 0 at the surface) for iflag_ratqs=2
+      ! for iflag_ratqs = 1 or 2, ratqss is constant above 300 hPa (ratqshaut), 
+      ! and then linearly varies between  600 and 300 hPa and it is either constant (ratqsbas)
+      ! for iflag_ratqs=1 or lineary varies (between ratqsbas and 0 at the surface) for iflag_ratqs=2
+      ! iflag_ratqs=2 was the option retained for LMDZ5A (see Hourdin et al. 2013)
 
       else if (iflag_ratqs.eq.1) then
@@ -187,4 +164,6 @@
          enddo
 
+      ! quadratic dependency upon pressure
+
       else if (iflag_ratqs==3) then
          do k=1,klev
@@ -193,4 +172,9 @@
          enddo
 
+      ! atan dependency on pressure, ratqsp0 being the pressure
+      ! where the transition occurs and ratqsdp controls
+      ! the sharpness of the transition. This is the version used 
+      ! in LMDZ6A (see Madeleine et al. 2020, fig 2).
+
       else if (iflag_ratqs==4) then 
          do k=1,klev
@@ -201,6 +185,6 @@
 
       else if (iflag_ratqs==5) then
-! Dependency of ratqs on model resolution (dependency on sqrt(cell_area) 
-! according to high-tropo aircraft obs, A. Borella PhD)
+         ! Dependency of ratqs on model resolution (dependency on sqrt(cell_area) 
+         ! according to high-tropo aircraft obs, A. Borella PhD)
          do k=1,klev
             do i=1,klon
@@ -213,12 +197,13 @@
 
 
-       else if (iflag_ratqs .GE. 10) then
+      else if (iflag_ratqs .GE. 10) then
  
-       ! interactive ratqs calculations that depend on cold pools, orography
-       ! This should help getting a more realistic ratqs in the low and mid troposphere
-       ! We however need a "background" ratqs to account for subgrid distribution of qt (or qt/qs)
-       ! in the high troposphere
+      ! interactive ratqss calculations that depend on cold pools, orography
+      ! This should help getting a more realistic ratqs in the low and mid troposphere
+      ! We however need a "background" ratqs to account for subgrid distribution of qt (or qt/qs)
+      ! in the high troposphere.
+      ! work of Louis d'Alecon, PhD
        
-       ! background ratqs and initialisations
+      ! background atan ratqs and initialisations
           do k=1,klev
              do i=1,klon
@@ -247,20 +232,13 @@
       endif
 
-!  final ratqs 
-!--------------
+!  Second step: total ratqs calculation 
+!----------------------------------------
 
       if (iflag_cld_th.eq.1 .or.iflag_cld_th.eq.2.or.iflag_cld_th.eq.4) then
-         ! We add a small constant value to ratqsc*2 to account for small-scale fluctuations
-         do k=1,klev
-            do i=1,klon
-               if ((fm_therm(i,k)>1.e-10)) then
-                  ratqsc(i,k)=sqrt(ratqsc(i,k)**2+0.05**2)
-               endif
-            enddo
-         enddo
-
-!   ratqs are a combination of ratqss et ratqsc
+         
+         ! ratqs are a combination of ratqss et ratqsc
+
          if(prt_level.ge.9) write(lunout,*)'PHYLMD NEW TAU_RATQS ',tau_ratqs
-
+         
          if (tau_ratqs>1.e-10) then
             facteur=exp(-pdtphys/tau_ratqs)
@@ -270,11 +248,16 @@
          ratqs(:,:)=ratqsc(:,:)*(1.-facteur)+ratqs(:,:)*facteur
          ratqs(:,:)=max(ratqs(:,:),ratqss(:,:))
+      
       else if (iflag_cld_th<=6) then
-        ! we only keep the stable ratqs for lscp
+       
+         ! ratqs is taken equal to ratqss
          ratqs(:,:)=ratqss(:,:)
+
       else
-          zfratqs1=exp(-pdtphys/10800.)
-          zfratqs2=exp(-pdtphys/10800.)
-          do k=1,klev
+
+         ! additional exploratory combinations of ratqss and ratqsc     
+         zfratqs1=exp(-pdtphys/10800.)
+         zfratqs2=exp(-pdtphys/10800.)
+         do k=1,klev
              do i=1,klon
                 if (ratqsc(i,k).gt.1.e-10) then
@@ -283,5 +266,5 @@
                 ratqs(i,k)=min(ratqs(i,k)*zfratqs1+ratqss(i,k)*(1.-zfratqs1),0.5)
              enddo
-          enddo
+         enddo
       endif
 
Index: LMDZ6/trunk/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 6006)
+++ LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 6007)
@@ -109,5 +109,5 @@
     USE lmdz_thermcell_dtke, ONLY : thermcell_dtke
     USE lmdz_blowing_snow_ini, ONLY : blowing_snow_ini , qbst_bs
-    USE lmdz_lscp_ini, ONLY : lscp_ini
+    USE lmdz_lscp_ini, ONLY : lscp_ini, ratqsbas
     USE lmdz_lscp_subgridvarq, ONLY : ratqs_main, ratqs_main_first
     USE lmdz_cloud_optics_prop_ini, ONLY : cloud_optics_prop_ini
@@ -1972,8 +1972,4 @@
           pbl_eps(:,:,is_ave) = 0.
        ENDIF
-       !IM begin
-       print*,'physiq: clwcon rnebcon ratqs',clwcon(1,1),rnebcon(1,1) &
-            ,ratqs(1,1)
-       !IM end
 
 
@@ -3421,9 +3417,9 @@
           ENDIF
 
-          ! =================================================================== c
-          ! Calcul des proprietes des nuages convectifs
-          !
-
-          !   calcul des proprietes des nuages convectifs
+          ! ========================================================================
+          ! Calculation of deep convective clouds properties
+          ! that is, the convective ratqs (ratqsc) and the convective cloud fraction
+          ! ========================================================================
+
           clwcon0(:,:)=fact_cldcon*clwcon0(:,:)
           IF (iflag_cld_cv == 0) THEN
@@ -3435,6 +3431,37 @@
           ENDIF
 
-
-          ! =================================================================== c
+          ! old-style convective ratqs computation as a function of q(z=0)-q / q
+          ! the ratqsc computed by clouds_gno is replaced
+          if (iflag_cld_th.eq.1) then
+            do k=1,klev
+               do i=1,klon
+                  if (ptconv(i,k)) then
+                      ratqsc(i,k)=ratqsbas &
+                      +fact_cldcon*(q_seri(i,1)-q_seri(i,k))/q_seri(i,k)
+                  else
+                      ratqsc(i,k)=0.
+                  endif
+               enddo
+             enddo
+          ! through log-normal distribution inversion
+          else if (iflag_cld_th.eq.4) then
+             ptconvth(:,:)=.false.
+             ratqsc(:,:)=0.
+             call clouds_gno &
+             (klon,klev,q_seri,zqsat,clwcon0th,ptconvth,ratqsc,rnebcon0th)
+          endif
+
+          if (iflag_cld_th.eq.1 .or.iflag_cld_th.eq.2.or.iflag_cld_th.eq.4) then
+          ! We add a small constant value to ratqsc*2 to account for small-scale fluctuations
+            do k=1,klev
+               do i=1,klon
+                  if ((fm_therm(i,k)>1.e-10)) then
+                     ratqsc(i,k)=sqrt(ratqsc(i,k)**2+0.05**2)
+                  endif
+               enddo
+            enddo
+          endif
+
+          ! ======================================================================== 
 
           DO i = 1, klon
@@ -3932,11 +3959,10 @@
     CALL ratqs_main_first(klon, cell_area)
     CALL ratqs_main(klon,klev,nbsrf,is_ter,is_lic,        &
-         iflag_cld_th,fact_cldcon, pdtphys,  &
+         iflag_cld_th, pdtphys,  &
          pctsrf,s_pblh,zstd, wake_s, wake_deltaq,   &
-         ptconv, clwcon0th, rnebcon0th,     &
          paprs,pplay,t_seri,q_seri, &
          qtc_cv, sigt_cv,detrain_cv,fm_cv,fqd,fqcomp,sigd,zqsat, &
          fm_therm,entr_therm,detr_therm,cell_area, &
-         ratqs,ratqsc,ratqs_inter_,sigma_qtherm)
+         ratqsc,ratqs,ratqs_inter_,sigma_qtherm)
 
 
Index: LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 6006)
+++ LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 6007)
@@ -108,5 +108,5 @@
     USE lmdz_thermcell_dtke, ONLY : thermcell_dtke
     USE lmdz_blowing_snow_ini, ONLY : blowing_snow_ini , qbst_bs
-    USE lmdz_lscp_ini, ONLY : lscp_ini
+    USE lmdz_lscp_ini, ONLY : lscp_ini, ratqsbas
     USE lmdz_lscp_subgridvarq, ONLY : ratqs_main, ratqs_main_first
     USE lmdz_cloud_optics_prop_ini, ONLY : cloud_optics_prop_ini
@@ -4222,21 +4222,53 @@
           enddo
        ENDIF
-
-       ! =================================================================== c
-       ! Calcul des proprietes des nuages convectifs
-       !
-
-       !   calcul des proprietes des nuages convectifs
-       clwcon0(:,:)=fact_cldcon*clwcon0(:,:)
-       IF (iflag_cld_cv == 0) THEN
-          CALL clouds_gno &
-               (klon,klev,q_seri,zqsat,clwcon0,ptconv,ratqsc,rnebcon0)
-       ELSE
-          CALL clouds_bigauss &
-               (klon,klev,q_seri,zqsat,qtc_cv,sigt_cv,ptconv,ratqsc,rnebcon0)
-       ENDIF
-
-
-       ! =================================================================== c
+         
+          ! =========================================================================
+          ! Calculation of deep convective clouds properties
+          ! that is, the convective ratqs (raqtsc) and the convective cloud fraction
+          ! =========================================================================
+
+          clwcon0(:,:)=fact_cldcon*clwcon0(:,:)
+          IF (iflag_cld_cv == 0) THEN
+             CALL clouds_gno &
+                  (klon,klev,q_seri,zqsat,clwcon0,ptconv,ratqsc,rnebcon0)
+          ELSE
+             CALL clouds_bigauss &
+                  (klon,klev,q_seri,zqsat,qtc_cv,sigt_cv,ptconv,ratqsc,rnebcon0)
+          ENDIF
+
+          ! old-style convective ratqs computation as a function of q(z=0)-q / q
+          ! the ratqsc computed by clouds_gno is replaced
+          if (iflag_cld_th.eq.1) then
+            do k=1,klev
+               do i=1,klon
+                  if (ptconv(i,k)) then
+                      ratqsc(i,k)=ratqsbas &
+                      +fact_cldcon*(q_seri(i,1)-q_seri(i,k))/q_seri(i,k)
+                  else
+                      ratqsc(i,k)=0.
+                  endif
+               enddo
+             enddo
+          ! through log-normal distribution inversion
+          else if (iflag_cld_th.eq.4) then
+             ptconvth(:,:)=.false.
+             ratqsc(:,:)=0.
+             call clouds_gno &
+             (klon,klev,q_seri,zqsat,clwcon0th,ptconvth,ratqsc,rnebcon0th)
+          endif
+
+          if (iflag_cld_th.eq.1 .or.iflag_cld_th.eq.2.or.iflag_cld_th.eq.4) then
+          ! We add a small constant value to ratqsc*2 to account for small-scale fluctuations
+            do k=1,klev
+               do i=1,klon
+                  if ((fm_therm(i,k)>1.e-10)) then
+                     ratqsc(i,k)=sqrt(ratqsc(i,k)**2+0.05**2)
+                  endif
+               enddo
+            enddo
+          endif
+
+          ! ======================================================================= 
+
 
        DO i = 1, klon
@@ -5096,11 +5128,10 @@
     CALL ratqs_main_first(klon, cell_area)
     CALL ratqs_main(klon,klev,nbsrf,is_ter,is_lic,  &
-         iflag_cld_th,fact_cldcon,pdtphys,          &
+         iflag_cld_th,pdtphys,          &
          pctsrf,s_pblh,zstd, wake_s, wake_deltaq,   &
-         ptconv,clwcon0th, rnebcon0th,     &
          paprs,pplay,t_seri,q_seri, &
          qtc_cv, sigt_cv,detrain_cv,fm_cv,fqd,fqcomp,sigd,zqsat, &
          fm_therm,entr_therm,detr_therm,cell_area, &
-         ratqs,ratqsc,ratqs_inter_,sigma_qtherm)
+         ratqss,ratqs,ratqs_inter_,sigma_qtherm)
 
     !
