Index: /LMDZ5/branches/testing/libf/phylmd/cloudth.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cloudth.F90	(revision 2542)
+++ /LMDZ5/branches/testing/libf/phylmd/cloudth.F90	(revision 2543)
@@ -20,4 +20,10 @@
 #include "FCTTRE.h"
 #include "thermcell.h"
+
+#include "nuage.h"
+
+
+
+
 
       INTEGER itap,ind1,ind2
@@ -62,8 +68,7 @@
       REAL erf
 
-      REAL, SAVE :: iflag_cloudth_vert, iflag_cloudth_vert_omp=0
-
-
-      LOGICAL, SAVE :: first=.true.
+
+
+!      LOGICAL, SAVE :: first=.true.
 
 
@@ -75,21 +80,21 @@
 ! de converger sur une version nouvelle
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      IF (first) THEN
-     !$OMP MASTER
-     CALL getin('iflag_cloudth_vert',iflag_cloudth_vert_omp)
-     !$OMP END MASTER
-     !$OMP BARRIER
-     iflag_cloudth_vert=iflag_cloudth_vert_omp
-      first=.false.
-      ENDIF
-       IF (iflag_cloudth_vert==1) THEN
-       CALL cloudth_vert(ngrid,klev,ind2,  &
+!      IF (first) THEN
+!     !$OMP MASTER
+!     CALL getin('iflag_cloudth_vert',iflag_cloudth_vert_omp)
+!     !$OMP END MASTER
+!     !$OMP BARRIER
+!     iflag_cloudth_vert=iflag_cloudth_vert_omp
+!      first=.false.
+!      ENDIF
+
+      IF (iflag_cloudth_vert.GE.1) THEN
+      CALL cloudth_vert(ngrid,klev,ind2,  &
      &           ztv,po,zqta,fraca, & 
      &           qcloud,ctot,zpspsk,paprs,ztla,zthl, &
      &           ratqs,zqs,t)
-       RETURN
-       ENDIF
+      RETURN
+      ENDIF
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
 
 
@@ -285,4 +290,9 @@
 #include "thermcell.h"
 
+
+#include "nuage.h"
+
+
+      
       INTEGER itap,ind1,ind2
       INTEGER ngrid,klev,klon,l,ig 
@@ -438,4 +448,10 @@
 
 
+
+
+
+
+
+       IF (iflag_cloudth_vert == 1) THEN
 !-------------------------------------------------------------------------------
 !  Version 2: Modification selon J.-Louis. On condense ?? partir de qsat-ratqs
@@ -479,5 +495,65 @@
       qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
 
+
+
+
+
+      ELSE IF (iflag_cloudth_vert == 2) THEN
+
+!-------------------------------------------------------------------------------
+!  Version 3: Modification Jean Jouhaud. On condense a partir de -delta s
+!-------------------------------------------------------------------------------
+!      deltasenv=aenv*ratqs(ind1,ind2)*po(ind1)
+!      deltasth=ath*ratqs(ind1,ind2)*zqta(ind1,ind2)
+!      deltasenv=aenv*ratqs(ind1,ind2)*zqsatenv(ind1,ind2)
+!      deltasth=ath*ratqs(ind1,ind2)*zqsatth(ind1,ind2)
+      deltasenv=aenv*0.5*sigma1s
+      deltasth=ath*0.5*sigma2s
+      
+      xenv1=-(senv+deltasenv)/(sqrt(2.)*sigma1s)
+      xenv2=-(senv-deltasenv)/(sqrt(2.)*sigma1s)
+      xth1=-(sth+deltasth)/(sqrt(2.)*sigma2s)
+      xth2=-(sth-deltasth)/(sqrt(2.)*sigma2s)
+!     coeffqlenv=(sigma1s)**2/(2*sqrtpi*deltasenv)
+!     coeffqlth=(sigma2s)**2/(2*sqrtpi*deltasth)
+      
+      cth(ind1,ind2)=0.5*(1.-1.*erf(xth1))
+      cenv(ind1,ind2)=0.5*(1.-1.*erf(xenv1))
+      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)
+
+      IntJ=0.5*senv*(1-erf(xenv2))+(sigma1s/sqrt2pi)*exp(-1.*xenv2**2)
+      IntI1=(((senv+deltasenv)**2+(sigma1s)**2)/(8*deltasenv))*(erf(xenv2)-erf(xenv1))
+      IntI2=(sigma1s**2/(4*deltasenv*sqrtpi))*(xenv1*exp(-1.*xenv1**2)-xenv2*exp(-1.*xenv2**2))
+      IntI3=((sqrt2*sigma1s*(senv+deltasenv))/(4*sqrtpi*deltasenv))*(exp(-1.*xenv1**2)-exp(-1.*xenv2**2))
+
+!      IntI1=0.5*(0.5*sqrtpi*(erf(xenv2)-erf(xenv1))+xenv1*exp(-1.*xenv1**2)-xenv2*exp(-1.*xenv2**2))
+!      IntI2=xenv2*(exp(-1.*xenv2**2)-exp(-1.*xenv1**2))
+!      IntI3=0.5*sqrtpi*xenv2**2*(erf(xenv2)-erf(xenv1))
+
+      qlenv(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
+!      qlenv(ind1,ind2)=IntJ 
+!      print*, qlenv(ind1,ind2),'VERIF EAU'
+
+      IntJ=0.5*sth*(1-erf(xth2))+(sigma2s/sqrt2pi)*exp(-1.*xth2**2)
+      IntI1=(((sth+deltasth)**2+(sigma2s)**2)/(8*deltasth))*(erf(xth2)-erf(xth1))
+      IntI2=(sigma2s**2/(4*deltasth*sqrtpi))*(xth1*exp(-1.*xth1**2)-xth2*exp(-1.*xth2**2))
+      IntI3=((sqrt2*sigma2s*(sth+deltasth))/(4*sqrtpi*deltasth))*(exp(-1.*xth1**2)-exp(-1.*xth2**2))
+      
+      qlth(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
+!      qlth(ind1,ind2)=IntJ
+!      print*, IntJ,IntI1,IntI2,IntI3,qlth(ind1,ind2),'VERIF EAU2'
+      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
+      
+
+
+
+      ENDIF ! of if (iflag_cloudth_vert==1 or 2)
+
+
+
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+
       if (cenv(ind1,ind2).lt.1.e-10.or.cth(ind1,ind2).lt.1.e-10) then
       ctot(ind1,ind2)=0.
Index: /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 2542)
+++ /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 2543)
@@ -165,4 +165,11 @@
     INTEGER,SAVE :: iflag_ice_thermo_omp
     INTEGER,SAVE :: iflag_t_glace_omp
+
+
+
+    INTEGER,SAVE :: iflag_cloudth_vert_omp
+
+
+    
     REAL,SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
     REAL,SAVE :: t_glace_min_omp, t_glace_max_omp
@@ -1160,4 +1167,26 @@
     call getin('iflag_t_glace',iflag_t_glace_omp)
 
+
+
+
+
+    !
+    !Config Key  = iflag_cloudth_vert
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_cloudth_vert_omp = 0
+    call getin('iflag_cloudth_vert',iflag_cloudth_vert_omp)
+
+
+
+
+
+
+
+
+
+
     !
     !Config Key  = iflag_ice_thermo
@@ -2044,4 +2073,10 @@
     exposant_glace = exposant_glace_omp
     iflag_t_glace = iflag_t_glace_omp
+
+
+    iflag_cloudth_vert=iflag_cloudth_vert_omp
+
+
+
     iflag_ice_thermo = iflag_ice_thermo_omp
     rei_min = rei_min_omp
@@ -2361,4 +2396,11 @@
     write(lunout,*)' exposant_glace = ',exposant_glace
     write(lunout,*)' iflag_t_glace = ',iflag_t_glace
+
+
+
+    write(lunout,*)' iflag_cloudth_vert = ',iflag_cloudth_vert
+
+
+
     write(lunout,*)' iflag_ice_thermo = ',iflag_ice_thermo
     write(lunout,*)' rei_min = ',rei_min
Index: /LMDZ5/branches/testing/libf/phylmd/nuage.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/nuage.h	(revision 2542)
+++ /LMDZ5/branches/testing/libf/phylmd/nuage.h	(revision 2543)
@@ -9,9 +9,10 @@
       REAL tmax_fonte_cv
 
-      INTEGER iflag_t_glace,iflag_cld_cv
+      INTEGER iflag_t_glace, iflag_cloudth_vert, iflag_cld_cv
 
       common /nuagecom/ rad_froid,rad_chau1, rad_chau2,t_glace_max,     &
      &                  t_glace_min,exposant_glace,rei_min,rei_max,     &
      &                  tau_cld_cv,coefw_cld_cv,                        &
-     &                  iflag_t_glace,iflag_cld_cv,tmax_fonte_cv
+     &                  iflag_t_glace,iflag_cloudth_vert,iflag_cld_cv,  &
+     &                  tmax_fonte_cv
 !$OMP THREADPRIVATE(/nuagecom/)
