Index: LMDZ5/trunk/libf/phylmd/cv3_routines.F
===================================================================
--- LMDZ5/trunk/libf/phylmd/cv3_routines.F	(revision 1510)
+++ LMDZ5/trunk/libf/phylmd/cv3_routines.F	(revision 1515)
@@ -38,7 +38,7 @@
       CHARACTER (LEN=20) :: modname='cv3_param'
       CHARACTER (LEN=80) :: abort_message
-      LOGICAL, SAVE :: FIRST=.TRUE.
-!$OMP THREADPRIVATE(FIRST)
-
+
+      LOGICAL,SAVE :: first=.true.
+c$OMP THREADPRIVATE(first)
 
 c noff: integer limit for convection (nd-noff)
@@ -53,12 +53,15 @@
       nlm=nl-1
 
+      IF (first) THEN
+
 c -- "microphysical" parameters:
        sigdz=0.01
-c      sigd=0.003
-c     sigd   = 0.01
-cCR:test sur la fraction des descentes precipitantes
       spfac  = 0.15
       pbcrit = 150.0
       ptcrit = 500.0
+cIM beg: ajout fis. reglage ep
+      flag_epKEorig=0
+      elcrit=0.0011
+      tlcrit=-55.0
 cIM lu dans physiq.def via conf_phys.F90     epmax  = 0.993
 
@@ -71,4 +74,5 @@
 ccc      dttrig = 5.   ! (loose) condition for triggering
       dttrig = 10.   ! (loose) condition for triggering
+      wb = 1.   ! (m/s) adiab updraught speed at LFC (used in cv3p1_closure)
 
 c -- rate of approach to quasi-equilibrium:
@@ -85,5 +89,5 @@
       betad=10.0   ! original value (from convect 4.3)
 
-      OPEN(99,file='conv_param.data',status='old',
+       OPEN(99,file='conv_param.data',status='old',
      $          form='formatted',err=9999)
       READ(99,*,end=9998) dpbase
@@ -93,8 +97,8 @@
       READ(99,*,end=9998) spfac
       READ(99,*,end=9998) tau
+      READ(99,*,end=9998) wb
 9998  Continue
       CLOSE(99)
 9999  Continue
-      if (first) then
         WRITE(*,*)'dpbase=',dpbase
         WRITE(*,*)'pbcrit=',pbcrit
@@ -103,12 +107,31 @@
         WRITE(*,*)'spfac=',spfac
         WRITE(*,*)'tau=',tau
-        first = .false.
-      endif
+        WRITE(*,*)'wb =',wb
+
+cIM Lecture du fichier ep_param.data
+      OPEN(79,file='ep_param.data',status='old',
+     $          form='formatted',err=7999)
+      READ(79,*,end=7998) flag_epKEorig
+      READ(79,*,end=7998) elcrit
+      READ(79,*,end=7998) tlcrit
+7998  Continue
+      CLOSE(79)
+7999  Continue
+      WRITE(*,*)'flag_epKEorig',flag_epKEorig
+      WRITE(*,*)'elcrit=',elcrit
+      WRITE(*,*)'tlcrit=',tlcrit
+cIM end: ajout fis. reglage ep
+
+       first = .false.
+      ENDIF
 
       beta   = 1.0 - delt/tau
       alpha1 = 1.5e-3
+cjyg    Correction bug alpha
+      alpha1  = alpha1*1.5
       alpha  = alpha1 * delt/tau
-c increase alpha to compensate W decrease:
-      alpha  = alpha*1.5
+cjyg    Bug
+ccc increase alpha to compensate W decrease:
+cc      alpha  = alpha*1.5
 
       return
@@ -942,9 +965,4 @@
       logical lcape(nloc)
       integer iposit(nloc)
-      real elcrit, tlcrit, sigs
-      parameter(sigs=0.15)
-      integer flag_epKEorig
-      LOGICAL, SAVE :: FIRST=.TRUE.
-!$OMP THREADPRIVATE(FIRST)
 
 !=====================================================================
@@ -1055,24 +1073,4 @@
 ! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I)
 !=====================================================================
-cIM beg: ajout fis. reglage ep
-      flag_epKEorig=0
-      elcrit=0.0011
-      tlcrit=-55.0
-cIM Lecture du fichier ep_param.data
-      OPEN(99,file='ep_param.data',status='old',
-     $          form='formatted',err=9999)
-      READ(99,*,end=9998) flag_epKEorig
-      READ(99,*,end=9998) elcrit
-      READ(99,*,end=9998) tlcrit
-9998  Continue
-      CLOSE(99)
-9999  Continue
-      if (first) then
-        WRITE(*,*)'flag_epKEorig',flag_epKEorig
-        WRITE(*,*)'elcrit=',elcrit
-        WRITE(*,*)'tlcrit=',tlcrit
-        first=.false.
-      endif
-cIM end: ajout fis. reglage ep
 
       if(flag_epKEorig.ne.1) THEN
@@ -1081,6 +1079,6 @@
            pden=ptcrit-pbcrit
            ep(i,k)=(plcl(i)-p(i,k)-pbcrit)/pden*epmax
-           ep(i,k)=amax1(ep(i,k),0.0)
-           ep(i,k)=amin1(ep(i,k),epmax)
+           ep(i,k)=max(ep(i,k),0.0)
+           ep(i,k)=min(ep(i,k),epmax)
            sigp(i,k)=spfac
  310    continue
@@ -1100,5 +1098,5 @@
               ep(i,k)=max(ep(i,k),0.0 )
               ep(i,k)=min(ep(i,k),epmax )
-              sigp(i,k)=sigs
+              sigp(i,k)=spfac
           endif
  315    continue
