Index: /trunk/LMDZ.GENERIC/README
===================================================================
--- /trunk/LMDZ.GENERIC/README	(revision 2091)
+++ /trunk/LMDZ.GENERIC/README	(revision 2092)
@@ -1444,2 +1444,6 @@
 - remove useless flag "iflag_thermals_alim" in thermcell_alim, thermcell_mod and thermcell_plume
 - replace watersat subroutine by Psat_water in the thermal plume model, cf. revision 1993 or 29/08/2018 JL comment.
+
+==07/02/2018 == AB
+- uncomment two "corrections" in thermcell_flux. They are used only if iflag_thermals_optflux is set to 0
+- remove useless parameter fact_shell in thermcell_mod
Index: /trunk/LMDZ.GENERIC/libf/phystd/thermcell_flux.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/thermcell_flux.F90	(revision 2091)
+++ /trunk/LMDZ.GENERIC/libf/phystd/thermcell_flux.F90	(revision 2092)
@@ -159,5 +159,5 @@
          
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-! AB : I comment the correction and replace it by an uncompromising test.
+! AB : I remove the correction and replace it by an uncompromising test.
 !      According to the previous derivations, we MUST have positive mass flux
 !      everywhere! Indeed, as soon as fm becomes negative, the plume stops.
@@ -186,34 +186,34 @@
 ! Test sur fraca constante ou croissante au-dessus de lalim
 !------------------------------------------------------------------------------
-! AB : do we have to decree that?
-!         IF (iflag_thermals_optflux.eq.0) THEN
-!            DO ig=1,ngrid
-!               IF (l.ge.lalim(ig).and.l.le.lmax(ig).and.(zw2(ig,l+1).gt.1.e-10).and.(zw2(ig,l).gt.1.e-10) ) THEN
-!                  zzz = fm(ig,l) * rhobarz(ig,l+1) * zw2(ig,l+1)              &
-!                  &   / (rhobarz(ig,l) * zw2(ig,l))
-!                  
-!                  IF (fm(ig,l+1).gt.zzz) THEN
-!                     detr(ig,l) = detr(ig,l) + fm(ig,l+1) - zzz
-!                     fm(ig,l+1) = zzz
-!                     ncorecfm4  = ncorecfm4 + 1
-!                  ENDIF
-!               ENDIF
-!            ENDDO
-!         ENDIF
+! AB : Do we have to decree that? If so, set iflag_thermals_optflux to 0
+         IF (iflag_thermals_optflux==0) THEN
+            DO ig=1,ngrid
+               IF (l.ge.lalim(ig).and.l.le.lmax(ig).and.(zw2(ig,l+1).gt.1.e-10).and.(zw2(ig,l).gt.1.e-10) ) THEN
+                  zzz = fm(ig,l) * rhobarz(ig,l+1) * zw2(ig,l+1)              &
+                  &   / (rhobarz(ig,l) * zw2(ig,l))
+                  
+                  IF (fm(ig,l+1).gt.zzz) THEN
+                     detr(ig,l) = detr(ig,l) + fm(ig,l+1) - zzz
+                     fm(ig,l+1) = zzz
+                     ncorecfm4  = ncorecfm4 + 1
+                  ENDIF
+               ENDIF
+            ENDDO
+         ENDIF
          
 !------------------------------------------------------------------------------
 ! Test sur flux de masse constant ou decroissant au-dessus de lalim
 !------------------------------------------------------------------------------
-! AB : do we have to decree that?
-!         IF (iflag_thermals_optflux==0) THEN
-!            DO ig=1,ngrid
-!               IF ((fm(ig,l+1).gt.fm(ig,l)).and.(l.gt.lalim(ig))) then
-!                  f_old = fm(ig,l+1)
-!                  fm(ig,l+1) = fm(ig,l)
-!                  detr(ig,l) = detr(ig,l) + f_old - fm(ig,l+1)
-!                  ncorecfm5  = ncorecfm5 + 1
-!               ENDIF
-!            ENDDO
-!         ENDIF
+! AB : Do we have to decree that? If so, set iflag_thermals_optflux to 0
+         IF (iflag_thermals_optflux==0) THEN
+            DO ig=1,ngrid
+               IF ((fm(ig,l+1).gt.fm(ig,l)).and.(l.gt.lalim(ig))) then
+                  f_old = fm(ig,l+1)
+                  fm(ig,l+1) = fm(ig,l)
+                  detr(ig,l) = detr(ig,l) + f_old - fm(ig,l+1)
+                  ncorecfm5  = ncorecfm5 + 1
+               ENDIF
+            ENDDO
+         ENDIF
          
 !------------------------------------------------------------------------------
@@ -488,6 +488,5 @@
       
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-! AB : test added to avoid problem when lmax = 0, which is not a
-!      fortran array index.
+! AB : test added to avoid problem when lmax = 0, which is not a fortran index.
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       IF (lmax(ig).gt.0) THEN
@@ -505,5 +504,5 @@
       IF (prt_level.ge.1) THEN
          
-! AB : those tests were removed for their uselessness.
+! AB : those outputs are commented for their uselessness.
 !         IF (ncorecfm2.ge.1) THEN
 !            print *, 'WARNING: Outgoing mass flux has negative value(s)!'
@@ -511,13 +510,13 @@
 !         ENDIF
          
-! AB : those tests were removed because I don't know if we should decree them.
-!         IF (ncorecfm4.ge.1) THEN
-!            print *, 'WARNING: Deacreasing updraft fraction above lalim!'
-!            print *, 'in', ncorecfm4, 'point(s)'
-!         ENDIF
-!         IF (ncorecfm5.ge.1) THEN
-!            print *, 'WARNING: Increasing mass flux above lalim!'
-!            print *, 'in', ncorecfm5, 'point(s)'
-!         ENDIF
+         IF (ncorecfm4.ge.1) THEN
+            print *, 'WARNING: Deacreasing updraft fraction above lalim!'
+            print *, 'in', ncorecfm4, 'point(s)'
+         ENDIF
+         
+         IF (ncorecfm5.ge.1) THEN
+            print *, 'WARNING: Increasing mass flux above lalim!'
+            print *, 'in', ncorecfm5, 'point(s)'
+         ENDIF
          
          IF (ncorecfm6.ge.1) THEN
@@ -526,5 +525,5 @@
          ENDIF
          
-! AB : that test was removed because I don't know if we should decree it.
+! AB : those outputs are commented because corresponding test is also commented.
 !         IF (ncorecfm7.ge.1) THEN
 !            print *, 'WARNING: Detrainment is greater than mass flux!'
Index: /trunk/LMDZ.GENERIC/libf/phystd/thermcell_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/thermcell_mod.F90	(revision 2091)
+++ /trunk/LMDZ.GENERIC/libf/phystd/thermcell_mod.F90	(revision 2092)
@@ -1,38 +1,37 @@
 MODULE thermcell_mod
-
-IMPLICIT NONE
-
-
+      
+      IMPLICIT NONE
+      
+      
 ! Flags for computations
-                                                            !     default
-INTEGER,PARAMETER :: iflag_thermals_optflux     = 0         !     0
-INTEGER,PARAMETER :: iflag_thermals_closure     = 2         !     2
-INTEGER,PARAMETER :: iflag_thermals             = 18        !     18
-
-! Flags for diagnoses
-
-LOGICAL,PARAMETER :: sorties                    = .false.   !     false
-INTEGER,PARAMETER :: iflag_trig_bl              = 1         !     1
-INTEGER,PARAMETER :: iflag_clos_bl              = 1         !     1
-INTEGER,PARAMETER :: iflag_coupl                = 5         !     5
-
+                                                                  !  default
+      INTEGER,PARAMETER :: iflag_thermals_optflux     = 1         !  0        !
+      INTEGER,PARAMETER :: iflag_thermals_closure     = 2         !  2        !
+      INTEGER,PARAMETER :: iflag_thermals             = 18        !  18       !
+      
+! Flags for (terrestrial) diagnoses
+      
+      LOGICAL,PARAMETER :: sorties                    = .false.   !  false
+      INTEGER,PARAMETER :: iflag_trig_bl              = 1         !  1
+      INTEGER,PARAMETER :: iflag_clos_bl              = 1         !  1
+      INTEGER,PARAMETER :: iflag_coupl                = 5         !  5
+      
 ! Physical parameters
-
-REAL,PARAMETER :: fact_thermals_ed_dz           = 0.007     !     0.007
-REAL,PARAMETER :: r_aspect_thermals             = 2.0       !     
-REAL,PARAMETER :: tau_thermals                  = 0.        !     0.
-REAL,PARAMETER :: betalpha                      = 0.9       !     0.9
-REAL,PARAMETER :: afact                         = 2./3.     !     2./3.
-REAL,PARAMETER :: fact_epsilon                  = 0.000     !     0.002
-REAL,PARAMETER :: detr_q_power                  = 0.5       !     0.5
-REAL,PARAMETER :: detr_q_coef                   = 0.012     !     0.012
-REAL,PARAMETER :: mix0                          = 0.        !     0.
-REAL,PARAMETER :: detr_min                      = 1.d-5     !     1.e-5
-REAL,PARAMETER :: entr_min                      = 1.d-5     !     1.e-5
-REAL,PARAMETER :: alphamax                      = 0.7       !     
-REAL,PARAMETER :: fomass_max                    = 0.5       !     
-REAL,PARAMETER :: fact_shell                    = 1.        !     1.
-REAL,PARAMETER :: pres_limit                    = 1.e5      !     1.e5
-
+      
+      REAL,PARAMETER :: fact_thermals_ed_dz           = 0.007     !  0.007    !
+      REAL,PARAMETER :: r_aspect_thermals             = 1.0       !           Aspect ratio of the thermals (width / height)
+      REAL,PARAMETER :: tau_thermals                  = 0.        !  0.       Relaxation time
+      REAL,PARAMETER :: betalpha                      = 0.9       !  0.9      !
+      REAL,PARAMETER :: afact                         = 2./3.     !  2./3.    !
+      REAL,PARAMETER :: fact_epsilon                  = 0.000     !  0.002    !
+      REAL,PARAMETER :: detr_q_power                  = 0.5       !  0.5      !
+      REAL,PARAMETER :: detr_q_coef                   = 0.012     !  0.012    !
+      REAL,PARAMETER :: mix0                          = 0.        !  0.       !
+      REAL,PARAMETER :: detr_min                      = 1.d-5     !  1.e-5    Minimal detrainment value
+      REAL,PARAMETER :: entr_min                      = 1.d-5     !  1.e-5    Maximal detrainment value
+      REAL,PARAMETER :: alphamax                      = 0.7       !           Maximal permitted updraft fraction
+      REAL,PARAMETER :: fomass_max                    = 0.5       !           Maximal permitted outgoing layer mass fraction
+      REAL,PARAMETER :: pres_limit                    = 1.e5      !  1.e5     !
+      
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ! AB : linf is used to set the lowest possible first level because we allow it
@@ -40,58 +39,58 @@
 !      first layer for gas giant.
 !      If there is a surface, it has to be set to 1.
-!      If someone want to call more than once the thermal plume model in one
-!      or more grid point, this variable must become a saved array of INTEGER
-!      with size ngrid. 
+!      If someone want to call more than once the thermal plume model in some
+!      grid points, this variable may become a saved array of INTEGER with size
+!      ngrid. 
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-INTEGER,PARAMETER :: linf                       = 2
-
+      INTEGER,PARAMETER :: linf                       = 2         !     1
+      
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-! AB : d_temp is an artificial virtual potential temperature added in layer
-!      linf which can be used to force convection to begin in it.
+! AB : d_temp is an artificial virtual potential temperature offset added in
+!      layer linf which can be used to force convection to begin in it.
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-REAL,PARAMETER :: d_temp                        = 10.       !     0.
-
+      REAL,PARAMETER :: d_temp                        = 0.        !     0.
+      
 ! Parameters for diagnoses
-
-REAL,PARAMETER :: alp_bl_k                      = 0.5       !     0.5
-
+      
+      REAL,PARAMETER :: alp_bl_k                      = 0.5       !     0.5
+      
 ! Physical constants
-
-REAL,SAVE :: RTT
-REAL,SAVE :: RG
-REAL,SAVE :: RKAPPA
-REAL,SAVE :: RPI
-REAL,SAVE :: RD
-
+      
+      REAL,SAVE :: RTT
+      REAL,SAVE :: RG
+      REAL,SAVE :: RKAPPA
+      REAL,SAVE :: RPI
+      REAL,SAVE :: RD
+      
 !$OMP THREADPRIVATE(RTT, RG, RKAPPA, RPI, RD)
-
+      
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ! AB : Parameters needed only for a loop in thermcell_alp (diagnoses).
 !      Maybe to be removed.
 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-INTEGER,PARAMETER :: nbsrf                      = 1
-
-
-CONTAINS
+      INTEGER,PARAMETER :: nbsrf                      = 1
+      
+      
+      CONTAINS
       
       SUBROUTINE init_thermcell_mod(g, rcp, r, pi, T_h2o_ice_liq, RV)
+         
+         IMPLICIT NONE
+         
+         REAL g
+         REAL rcp
+         REAL r
+         REAL pi
+         REAL T_h2o_ice_liq
+         REAL RV
+         
+         RTT = T_h2o_ice_liq
+         RG = g
+         RKAPPA = rcp
+         RPI = pi
+         RD = r
+         
+         RETURN
+      END SUBROUTINE init_thermcell_mod
       
-      IMPLICIT NONE
-      
-      REAL g
-      REAL rcp
-      REAL r
-      REAL pi
-      REAL T_h2o_ice_liq
-      REAL RV
-      
-      RTT = T_h2o_ice_liq
-      RG = g
-      RKAPPA = rcp
-      RPI = pi
-      RD = r
-      
-      RETURN
-      END SUBROUTINE init_thermcell_mod
-
 END MODULE thermcell_mod
