Index: LMDZ5/trunk/libf/phylmd/conflx.F
===================================================================
--- LMDZ5/trunk/libf/phylmd/conflx.F	(revision 1907)
+++ LMDZ5/trunk/libf/phylmd/conflx.F	(revision 1923)
@@ -18,8 +18,8 @@
 c         et lessivage des traceurs passifs.
 c======================================================================
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
 c Entree:
       REAL dtime            ! pas d'integration (s)
@@ -77,5 +77,5 @@
       REAL zdelta, zqsat
 c
-#include "FCTTRE.h"
+      include "FCTTRE.h"
 c
 c initialiser les variables de sortie (pour securite)
@@ -207,5 +207,5 @@
 
       RETURN
-      END
+      END subroutine conflx
 c--------------------------------------------------------------------
       SUBROUTINE flxmain(pdtime, pten, pqen, pqsen, pqhfl, pap, paph,
@@ -218,9 +218,9 @@
       IMPLICIT none
 C     ------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
-#include "YOECUMF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
+      include "YOECUMF.h"
 C     ----------------------------------------------------------------
       REAL pten(klon,klev), pqen(klon,klev), pqsen(klon,klev)
@@ -502,5 +502,5 @@
  1000 CONTINUE
       RETURN
-      END
+      END SUBROUTINE flxmain
       SUBROUTINE flxini(pten, pqen, pqsen, pgeo, paph, pgeoh, ptenh,
      .           pqenh, pqsenh, ptu, pqu, ptd, pqd, pmfd, pmfds, pmfdq,
@@ -514,8 +514,8 @@
 C AND INITIALIZES VALUES FOR UPDRAFTS
 C----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
 C
       REAL pten(klon,klev)   ! temperature (environnement)
@@ -630,5 +630,5 @@
 C
       RETURN
-      END
+      END SUBROUTINE flxini
       SUBROUTINE flxbase(ptenh, pqenh, pgeoh, paph,
      *     ptu, pqu, plu, ldcum, kcbot, klab)
@@ -646,8 +646,8 @@
 C (NON ENTRAINING PLUME,I.E.CONSTANT MASSFLUX)
 C----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
 C       ----------------------------------------------------------------
       REAL ptenh(klon,klev), pqenh(klon,klev)
@@ -712,5 +712,5 @@
 c
       RETURN
-      END
+      END SUBROUTINE flxbase
       SUBROUTINE flxasc(pdtime, ptenh, pqenh, pten, pqen, pqsen,
      .     pgeo, pgeoh, pap, paph, pqte, pvervel,
@@ -725,9 +725,9 @@
 C FOR CUMULUS PARAMETERIZATION
 C----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
-#include "YOECUMF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
+      include "YOECUMF.h"
 C
       REAL pdtime
@@ -763,4 +763,5 @@
       REAL zwmax(klon), zzzmb
       INTEGER klwmin(klon) ! level of maximum vertical velocity
+      real fact
 C----------------------------------------------------------------------
       ztglace = RTT - 13.
@@ -835,8 +836,9 @@
       DO 480 k = klev-1,3,-1
 c
-      IF (LMFMID .AND. k.LT.klev-1 .AND. k.GT.klev/2) THEN
+      IF (LMFMID .AND. k.LT.klev-1) THEN
          DO i = 1, klon
          IF (.NOT.ldcum(i) .AND. klab(i,k+1).EQ.0 .AND.
-     .       pqen(i,k).GT.0.9*pqsen(i,k)) THEN
+     .       pqen(i,k).GT.0.9*pqsen(i,k)
+     $           .and. pap(i, k) / paph(i, klev + 1)> 0.4) THEN
             ptu(i,k+1) = pten(i,k) +(pgeo(i,k)-pgeoh(i,k+1))/RCPD
             pqu(i,k+1) = pqen(i,k)
@@ -893,9 +895,8 @@
          llo1=pen_u(i,k).GT.0..AND.(ktype(i).EQ.1.OR.ktype(i).EQ.2)
          IF(llo1) THEN
-            zentr=zentr*(1.+3.*(1.-MIN(1.,(zpbot(i)-pap(i,k))/1.5E4)))
-            pen_u(i,k)=pen_u(i,k)*(1.+3.*(1.-MIN(1.,
-     .                 (zpbot(i)-pap(i,k))/1.5E4)))
-            pde_u(i,k)=pde_u(i,k)*(1.+3.*(1.-MIN(1.,
-     .                 (zpbot(i)-pap(i,k))/1.5E4)))
+            fact=1.+3.*(1.-MIN(1.,(zpbot(i)-pap(i,k))/1.5E4))
+            zentr=zentr*fact
+            pen_u(i,k)=pen_u(i,k)*fact
+            pde_u(i,k)=pde_u(i,k)*fact
          ENDIF
          IF(llo2.AND.pqenh(i,k+1).GT.1.E-5)
@@ -1017,5 +1018,5 @@
   800 CONTINUE
       RETURN
-      END
+      END SUBROUTINE flxasc
       SUBROUTINE flxflux(pdtime, pqen, pqsen, ptenh, pqenh, pap
      .  ,  paph, ldland, pgeoh, kcbot, kctop, lddraf, kdtop
@@ -1030,9 +1031,10 @@
 C FLUXES IN THE CLOUD LAYER AND IN THE SUBCLOUD LAYER
 C----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
-#include "YOECUMF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
+      include "YOECUMF.h"
+      include "iniprint.h"
 C
       REAL cevapcu(klon,klev)
@@ -1068,5 +1070,5 @@
       INTEGER kdtop(klon)
 c
-#include "FCTTRE.h"
+      include "FCTTRE.h"
 c
       DO 101 k=1,klev
@@ -1255,5 +1257,5 @@
             pdpmel(i,k) = 0.0
          ENDIF         
-         if (pmflxr(i,k) + pmflxs(i,k).lt.-1.e-26) 
+         if (pmflxr(i,k) + pmflxs(i,k) < -1.e-26 .and. prt_level >= 1) 
      .    write(*,*) 'precip. < 1e-16 ',pmflxr(i,k) + pmflxs(i,k)
       ENDIF
@@ -1267,5 +1269,5 @@
 c
       RETURN
-      END
+      END SUBROUTINE flxflux
       SUBROUTINE flxdtdq(pdtime, ktopm2, paph, ldcum, pten
      .  ,  pmfus, pmfds, pmfuq, pmfdq, pmful, pdmfup, pdmfdp
@@ -1276,9 +1278,9 @@
 c calculer les tendances T et Q
 c----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
-#include "YOECUMF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
+      include "YOECUMF.h"
 C     -----------------------------------------------------------------
       LOGICAL  llo1
@@ -1339,5 +1341,5 @@
 C
       RETURN
-      END
+      END SUBROUTINE flxdtdq
       SUBROUTINE flxdlfs(ptenh, pqenh, pgeoh, paph, ptu, pqu,
      .     ldcum, kcbot, kctop, pmfub, prfl, ptd, pqd,
@@ -1361,9 +1363,9 @@
 C MOIST ENVIRONMENTAL AIR AND CLOUD AIR.
 C----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
-#include "YOECUMF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
+      include "YOECUMF.h"
 C
       REAL ptenh(klon,klev)
@@ -1451,5 +1453,5 @@
 C
       RETURN
-      END
+      END SUBROUTINE flxdlfs
       SUBROUTINE flxddraf(ptenh, pqenh, pgeoh, paph, prfl,
      .           ptd, pqd, pmfd, pmfds, pmfdq, pdmfdp,
@@ -1473,9 +1475,9 @@
 C
 C----------------------------------------------------------------------
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
-#include "YOETHF.h"
-#include "YOECUMF.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
+      include "YOETHF.h"
+      include "YOECUMF.h"
 C
       REAL ptenh(klon,klev), pqenh(klon,klev)
@@ -1569,5 +1571,5 @@
   180 CONTINUE
       RETURN
-      END
+      END SUBROUTINE flxddraf
       SUBROUTINE flxadjtq(pp, pt, pq, ldflag, kcall)
       USE dimphy
@@ -1581,7 +1583,7 @@
 C        kcall=2  EVAPORATION IN DOWNDRAFTS (E.G. CUDLFS,CUDDRAF)
 C
-cym#include "dimensions.h"
-cym#include "dimphy.h"
-#include "YOMCST.h"
+c     yminclude "dimensions.h"
+c     yminclude "dimphy.h"
+      include "YOMCST.h"
 C
       REAL pt(klon), pq(klon), pp(klon)
@@ -1593,6 +1595,6 @@
       REAL zdelta, zcvm5, zldcp, zqsat, zcor
       INTEGER is, i
-#include "YOETHF.h"
-#include "FCTTRE.h"
+      include "YOETHF.h"
+      include "FCTTRE.h"
 C
       z5alvcp = r5les*RLVTT/RCPD
@@ -1648,5 +1650,5 @@
   230 CONTINUE
       RETURN
-      END
+      END SUBROUTINE flxadjtq
       SUBROUTINE flxsetup
       IMPLICIT none
@@ -1654,5 +1656,5 @@
 C     THIS ROUTINE DEFINES DISPOSABLE PARAMETERS FOR MASSFLUX SCHEME
 C
-#include "YOECUMF.h"
+      include "YOECUMF.h"
 C
       ENTRPEN=1.0E-4  ! ENTRAINMENT RATE FOR PENETRATIVE CONVECTION
@@ -1674,3 +1676,3 @@
 c
       RETURN
-      END
+      END SUBROUTINE flxsetup
