Changeset 5614 for LMDZ6/trunk


Ignore:
Timestamp:
Apr 14, 2025, 9:21:07 PM (8 weeks ago)
Author:
evignon
Message:

Commission liée à un update majeur de la routine de condensation grande echelle suite au travail
de Lea, Audran et Etienne
Elle inclue une restructuration des routines pour clarifier le role "moniteur" de la routine lscp_main,
une mise à jour de la parametrisation de partitionnement de phase de Lea pour inclure les nuages de couche limite,
ainsi que des corrections des routines de precipitations "poprecip".
Convergence numerique verifiee en prod et debug pour les physiques NPv6.3 et 7.0.1c

Location:
LMDZ6/trunk
Files:
1 added
6 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/DefLists/field_def_lmdz.xml

    r5605 r5614  
    731731        <field id="sigma2_icefracturb"    long_name="Variance of the diagnostic supersaturation distribution (icefrac_turb)"    unit="-" />
    732732        <field id="mean_icefracturb"     long_name="Mean of the diagnostic supersaturation distribution (icefrac_turb)"    unit="-" />
     733        <field id="cldfraliqth"          long_name="Fraction of liquid cloud in thermals"    unit="-" />
     734        <field id="sigma2_icefracturbth"    long_name="Variance of the diagnostic supersaturation distribution in thermals (icefrac_turb)"    unit="-" />
     735        <field id="mean_icefracturbth"     long_name="Mean of the diagnostic supersaturation distribution in thermals (icefrac_turb)"    unit="-" />
    733736        <field id="rnebcon"    long_name="Convective Cloud Fraction"    unit="-" />
    734737        <field id="rnebls"    long_name="LS Cloud fraction"    unit="-" />
  • LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.f90

    r5526 r5614  
    176176  reice_pi = 0.
    177177
    178   IF (iflag_t_glace.EQ.0) THEN
     178  IF ((.NOT. ok_new_lscp) .AND. iflag_t_glace.EQ.0) THEN
    179179    DO k = 1, klev
    180180      DO i = 1, klon
     
    202202
    203203      DO i = 1, klon
    204        
     204
    205205        IF ((.NOT. ptconv(i,k)) .AND. ok_new_lscp .AND. ok_icefra_lscp) THEN
    206206        ! EV: take the ice fraction directly from the lscp code
  • LMDZ6/trunk/libf/phylmd/lmdz_lscp_condensation.f90

    r5440 r5614  
    909909!**********************************************************************************
    910910
     911!**********************************************************************************
    911912SUBROUTINE deposition_sublimation( &
    912913    qvapincld, qiceincld, temp, qsat, pplay, dtime, &
     
    10641065END SUBROUTINE deposition_sublimation
    10651066
     1067
     1068!**********************************************************************************
     1069
     1070!**********************************************************************************
     1071SUBROUTINE  condensation_cloudth(klon,                     &
     1072&           temp,qt,qt_th,frac_th,zpspsk,play,thetal_th,   &
     1073&           ratqs,sigma_qtherm,qsth,qsenv,qcloud,ctot,ctotth,ctot_vol,  &
     1074&           cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
     1075! This routine computes the condensation of clouds in convective boundary layers
     1076! with thermals assuming two separate distribution of the saturation deficit in
     1077! the thermal plumes and in the environment
     1078! It is based on the work of Arnaud Jam (Jam et al. 2013, BLM)
     1079! Author : Etienne Vignon (LMDZ/CNRS)
     1080! Date: February 2025
     1081! Date: Adapted from cloudth_vert_v3 in 2023 by Arnaud Otavio Jam
     1082! IMPORTANT NOTE: we assume iflag_cloudth_vert=7
     1083!-----------------------------------------------------------------------------------
     1084
     1085      use lmdz_lscp_ini,    only: iflag_cloudth_vert,iflag_ratqs,iflag_cloudth_vert_noratqs
     1086      use lmdz_lscp_ini,    only: vert_alpha, vert_alpha_th ,sigma1s_factor,sigma1s_power,sigma2s_factor,sigma2s_power,cloudth_ratqsmin
     1087      use lmdz_lscp_ini,    only: RTT, RG, RPI, RD, RV, RCPD, RLVTT, RLSTT, temp_nowater, min_frac_th_cld, min_neb_th
     1088
     1089      IMPLICIT NONE
     1090
     1091
     1092!------------------------------------------------------------------------------
     1093! Declarations
     1094!------------------------------------------------------------------------------
     1095
     1096! INPUT/OUTPUT
     1097
     1098      INTEGER, INTENT(IN)                         :: klon
     1099     
     1100
     1101      REAL, DIMENSION(klon),      INTENT(IN)      ::  temp          ! Temperature (liquid temperature) in the mesh [K] : has seen evap of precip
     1102      REAL, DIMENSION(klon),      INTENT(IN)      ::  qt            ! total water specific humidity in the mesh [kg/kg]: has seen evap of precip
     1103      REAL, DIMENSION(klon),      INTENT(IN)      ::  qt_th         ! total water specific humidity in thermals [kg/kg]: has not seen evap of precip
     1104      REAL, DIMENSION(klon),      INTENT(IN)      ::  thetal_th     ! Liquid potential temperature in thermals [K]: has not seen the evap of precip
     1105      REAL, DIMENSION(klon),      INTENT(IN)      ::  frac_th       ! Fraction of the mesh covered by thermals [0-1]
     1106      REAL, DIMENSION(klon),      INTENT(IN)      ::  zpspsk        ! Exner potential
     1107      REAL, DIMENSION(klon),      INTENT(IN)      ::  play          ! Pressure of layers [Pa]
     1108      REAL, DIMENSION(klon),      INTENT(IN)      ::  ratqs         ! Parameter that determines the width of the water distrib     [-]
     1109      REAL, DIMENSION(klon),      INTENT(IN)      ::  sigma_qtherm  ! Parameter determining the width of the distrib in thermals   [-]
     1110      REAL, DIMENSION(klon),      INTENT(IN)      ::  qsth          ! Saturation specific humidity in thermals
     1111      REAL, DIMENSION(klon),      INTENT(IN)      ::  qsenv         ! Saturation specific humidity in environment
     1112     
     1113      REAL, DIMENSION(klon),      INTENT(INOUT)      ::  ctot         ! Cloud fraction [0-1]
     1114      REAL, DIMENSION(klon),      INTENT(INOUT)      ::  ctotth       ! Cloud fraction [0-1] in thermals
     1115      REAL, DIMENSION(klon),      INTENT(INOUT)      ::  ctot_vol     ! Volume cloud fraction [0-1]
     1116      REAL, DIMENSION(klon),      INTENT(INOUT)      ::  qcloud       ! In cloud total water content [kg/kg]
     1117      REAL, DIMENSION(klon),      INTENT(OUT)      ::  cloudth_sth    ! mean saturation deficit in thermals
     1118      REAL, DIMENSION(klon),      INTENT(OUT)      ::  cloudth_senv   ! mean saturation deficit in environment
     1119      REAL, DIMENSION(klon),      INTENT(OUT)      ::  cloudth_sigmath  ! std of saturation deficit in thermals
     1120      REAL, DIMENSION(klon),      INTENT(OUT)      ::  cloudth_sigmaenv ! std of saturation deficit in environment
     1121
     1122
     1123! LOCAL VARIABLES
     1124
     1125      INTEGER itap,ind1,l,ig,iter,k
     1126      INTEGER iflag_topthermals, niter
     1127
     1128      REAL qcth(klon)
     1129      REAL qcenv(klon)
     1130      REAL qctot(klon)
     1131      REAL cth(klon)
     1132      REAL cenv(klon)   
     1133      REAL cth_vol(klon)
     1134      REAL cenv_vol(klon)
     1135      REAL qt_env(klon), thetal_env(klon)
     1136      REAL sqrtpi,sqrt2,sqrt2pi
     1137      REAL alth,alenv,ath,aenv
     1138      REAL sth,senv,sigma1s,sigma2s,sigma1s_fraca,sigma1s_ratqs
     1139      REAL inverse_rho,beta,a_Brooks,b_Brooks,A_Maj_Brooks,Dx_Brooks,f_Brooks
     1140      REAL xth,xenv,exp_xenv1,exp_xenv2,exp_xth1,exp_xth2
     1141      REAL xth1,xth2,xenv1,xenv2,deltasth, deltasenv
     1142      REAL IntJ,IntI1,IntI2,IntI3,IntJ_CF,IntI1_CF,IntI3_CF,coeffqlenv,coeffqlth
     1143      REAL zdelta,qsatbef,zcor
     1144      REAL Tbefth(klon), Tbefenv(klon)
     1145      REAL qlbef
     1146      REAL dqsatenv(klon), dqsatth(klon)
     1147      REAL zpdf_sig(klon),zpdf_k(klon),zpdf_delta(klon)
     1148      REAL zpdf_a(klon),zpdf_b(klon),zpdf_e1(klon),zpdf_e2(klon)
     1149      REAL qincloud(klon)
     1150      REAL alenvl, aenvl
     1151      REAL sthi, sthl, sthil, althl, athl, althi, athi, sthlc, deltasthc, sigma2sc
     1152
     1153
     1154!------------------------------------------------------------------------------
     1155! Initialisation
     1156!------------------------------------------------------------------------------
     1157
     1158
     1159      sqrt2pi=sqrt(2.*rpi)
     1160      sqrt2=sqrt(2.)
     1161      sqrtpi=sqrt(rpi)
     1162
     1163!-------------------------------------------------------------------------------
     1164! Thermal fraction calculation and standard deviation of the distribution
     1165!------------------------------------------------------------------------------- 
     1166
     1167! initialisations and calculation of temperature, humidity and saturation specific humidity
     1168
     1169cloudth_senv(:) = 0.
     1170cloudth_sth(:) = 0.
     1171cloudth_sigmaenv(:) = 0.
     1172cloudth_sigmath(:) = 0.
     1173
     1174
     1175DO ind1=1,klon
     1176 
     1177   Tbefenv(ind1) = temp(ind1)
     1178   thetal_env(ind1) = Tbefenv(ind1)/zpspsk(ind1)
     1179   Tbefth(ind1)  = thetal_th(ind1)*zpspsk(ind1)
     1180   qt_env(ind1)  = (qt(ind1)-frac_th(ind1)*qt_th(ind1))/(1.-frac_th(ind1)) !qt = a*qtth + (1-a)*qtenv
     1181
     1182ENDDO
     1183
     1184
     1185
     1186DO ind1=1,klon
     1187
     1188
     1189    IF (frac_th(ind1).GT.min_frac_th_cld) THEN !Thermal and environnement
     1190
     1191! Environment:
     1192
     1193
     1194        alenv=(RD/RV*RLVTT*qsenv(ind1))/(rd*thetal_env(ind1)**2)     
     1195        aenv=1./(1.+(alenv*RLVTT/rcpd))                             
     1196        senv=aenv*(qt_env(ind1)-qsenv(ind1))                           
     1197     
     1198
     1199! Thermals:
     1200
     1201
     1202        alth=(RD/RV*RLVTT*qsth(ind1))/(rd*thetal_th(ind1)**2)       
     1203        ath=1./(1.+(alth*RLVTT/rcpd))                                                         
     1204        sth=ath*(qt_th(ind1)-qsth(ind1))                     
     1205
     1206
     1207! Standard deviation of the distributions
     1208
     1209           ! environment
     1210           sigma1s_fraca = (sigma1s_factor**0.5)*(frac_th(ind1)**sigma1s_power) / &
     1211           &                (1-frac_th(ind1))*((sth-senv)**2)**0.5
     1212
     1213           IF (cloudth_ratqsmin>0.) THEN
     1214             sigma1s_ratqs = cloudth_ratqsmin*qt(ind1)
     1215           ELSE
     1216             sigma1s_ratqs = ratqs(ind1)*qt(ind1)
     1217           ENDIF
     1218           sigma1s = sigma1s_fraca + sigma1s_ratqs
     1219
     1220           IF (iflag_ratqs.eq.10.or.iflag_ratqs.eq.11) then
     1221              sigma1s = ratqs(ind1)*qt(ind1)*aenv
     1222           ENDIF
     1223
     1224           ! thermals
     1225           sigma2s=(sigma2s_factor*(((sth-senv)**2)**0.5)/((frac_th(ind1)+0.02)**sigma2s_power))+0.002*qt_th(ind1)
     1226
     1227          IF (iflag_ratqs.eq.10.and.sigma_qtherm(ind1).ne.0) then
     1228             sigma2s = sigma_qtherm(ind1)*ath
     1229          ENDIF
     1230
     1231 
     1232! surface cloud fraction
     1233
     1234           deltasenv=aenv*vert_alpha*sigma1s
     1235           deltasth=ath*vert_alpha_th*sigma2s
     1236
     1237           xenv1=-(senv+deltasenv)/(sqrt(2.)*sigma1s)
     1238           xenv2=-(senv-deltasenv)/(sqrt(2.)*sigma1s)
     1239           exp_xenv1 = exp(-1.*xenv1**2)
     1240           exp_xenv2 = exp(-1.*xenv2**2)
     1241           xth1=-(sth+deltasth)/(sqrt(2.)*sigma2s)
     1242           xth2=-(sth-deltasth)/(sqrt(2.)*sigma2s)
     1243           exp_xth1 = exp(-1.*xth1**2)
     1244           exp_xth2 = exp(-1.*xth2**2)
     1245           cth(ind1)=0.5*(1.-1.*erf(xth1))
     1246           cenv(ind1)=0.5*(1.-1.*erf(xenv1))
     1247           ctot(ind1)=frac_th(ind1)*cth(ind1)+(1.-1.*frac_th(ind1))*cenv(ind1)
     1248           ctotth(ind1)=frac_th(ind1)*cth(ind1)
     1249       
     1250
     1251!volume cloud fraction and condensed water
     1252
     1253            !environnement
     1254
     1255            IntJ=0.5*senv*(1-erf(xenv2))+(sigma1s/sqrt2pi)*exp_xenv2
     1256            IntJ_CF=0.5*(1.-1.*erf(xenv2))
     1257
     1258            IF (deltasenv .LT. 1.e-10) THEN
     1259              qcenv(ind1)=IntJ
     1260              cenv_vol(ind1)=IntJ_CF
     1261            ELSE
     1262              IntI1=(((senv+deltasenv)**2+(sigma1s)**2)/(8*deltasenv))*(erf(xenv2)-erf(xenv1))
     1263              IntI2=(sigma1s**2/(4*deltasenv*sqrtpi))*(xenv1*exp_xenv1-xenv2*exp_xenv2)
     1264              IntI3=((sqrt2*sigma1s*(senv+deltasenv))/(4*sqrtpi*deltasenv))*(exp_xenv1-exp_xenv2)
     1265              IntI1_CF=((senv+deltasenv)*(erf(xenv2)-erf(xenv1)))/(4*deltasenv)
     1266              IntI3_CF=(sqrt2*sigma1s*(exp_xenv1-exp_xenv2))/(4*sqrtpi*deltasenv)
     1267              qcenv(ind1)=IntJ+IntI1+IntI2+IntI3
     1268              cenv_vol(ind1)=IntJ_CF+IntI1_CF+IntI3_CF
     1269            ENDIF
     1270             
     1271
     1272
     1273            !thermals
     1274
     1275            IntJ=0.5*sth*(1-erf(xth2))+(sigma2s/sqrt2pi)*exp_xth2
     1276            IntJ_CF=0.5*(1.-1.*erf(xth2))
     1277     
     1278            IF (deltasth .LT. 1.e-10) THEN
     1279              qcth(ind1)=IntJ
     1280              cth_vol(ind1)=IntJ_CF
     1281            ELSE
     1282              IntI1=(((sth+deltasth)**2+(sigma2s)**2)/(8*deltasth))*(erf(xth2)-erf(xth1))
     1283              IntI2=(sigma2s**2/(4*deltasth*sqrtpi))*(xth1*exp_xth1-xth2*exp_xth2)
     1284              IntI3=((sqrt2*sigma2s*(sth+deltasth))/(4*sqrtpi*deltasth))*(exp_xth1-exp_xth2)
     1285              IntI1_CF=((sth+deltasth)*(erf(xth2)-erf(xth1)))/(4*deltasth)
     1286              IntI3_CF=(sqrt2*sigma2s*(exp_xth1-exp_xth2))/(4*sqrtpi*deltasth)
     1287              qcth(ind1)=IntJ+IntI1+IntI2+IntI3
     1288              cth_vol(ind1)=IntJ_CF+IntI1_CF+IntI3_CF
     1289            ENDIF
     1290
     1291            ! total
     1292
     1293            qctot(ind1)=frac_th(ind1)*qcth(ind1)+(1.-1.*frac_th(ind1))*qcenv(ind1)
     1294            ctot_vol(ind1)=frac_th(ind1)*cth_vol(ind1)+(1.-1.*frac_th(ind1))*cenv_vol(ind1)
     1295
     1296            IF (cenv(ind1).LT.min_neb_th.and.cth(ind1).LT.min_neb_th) THEN
     1297                ctot(ind1)=0.
     1298                ctot_vol(ind1)=0.
     1299                qcloud(ind1)=qsenv(ind1)
     1300                qincloud(ind1)=0.
     1301            ELSE             
     1302                qincloud(ind1)=qctot(ind1)/ctot(ind1)
     1303                !to prevent situations with cloud condensed water greater than available total water
     1304                qincloud(ind1)=min(qincloud(ind1),qt(ind1)/ctot(ind1))
     1305                ! we assume that water vapor in cloud is qsenv
     1306                qcloud(ind1)=qincloud(ind1)+qsenv(ind1)
     1307            ENDIF
     1308
     1309
     1310
     1311           ! Outputs used to check the PDFs
     1312           cloudth_senv(ind1) = senv
     1313           cloudth_sth(ind1) = sth
     1314           cloudth_sigmaenv(ind1) = sigma1s
     1315           cloudth_sigmath(ind1) = sigma2s
     1316
     1317      ENDIF       ! selection of grid points concerned by thermals
     1318
     1319
     1320    ENDDO       !loop on klon
     1321
     1322
     1323RETURN
     1324
     1325
     1326END SUBROUTINE condensation_cloudth
     1327
     1328
     1329!*****************************************************************************************
     1330!*****************************************************************************************
     1331! pre-cmip7 routines are below and are becoming obsolete
     1332!*****************************************************************************************
     1333!*****************************************************************************************
     1334
     1335
     1336       SUBROUTINE cloudth(ngrid,klev,ind2,  &
     1337     &           ztv,po,zqta,fraca, &
     1338     &           qcloud,ctot,zpspsk,paprs,pplay,ztla,zthl, &
     1339     &           ratqs,zqs,t, &
     1340     &           cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
     1341
     1342
     1343      use lmdz_lscp_ini, only: iflag_cloudth_vert,iflag_ratqs
     1344
     1345      USE yomcst_mod_h
     1346      USE yoethf_mod_h
     1347IMPLICIT NONE
     1348
     1349
     1350!===========================================================================
     1351! Auteur : Arnaud Octavio Jam (LMD/CNRS)
     1352! Date : 25 Mai 2010
     1353! Objet : calcule les valeurs de qc et rneb dans les thermiques
     1354!===========================================================================
     1355
     1356      INCLUDE "FCTTRE.h"
     1357
     1358      INTEGER itap,ind1,ind2
     1359      INTEGER ngrid,klev,klon,l,ig
     1360      real, dimension(ngrid,klev), intent(out) :: cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
     1361     
     1362      REAL ztv(ngrid,klev)
     1363      REAL po(ngrid)
     1364      REAL zqenv(ngrid)   
     1365      REAL zqta(ngrid,klev)
     1366         
     1367      REAL fraca(ngrid,klev+1)
     1368      REAL zpspsk(ngrid,klev)
     1369      REAL paprs(ngrid,klev+1)
     1370      REAL pplay(ngrid,klev)
     1371      REAL ztla(ngrid,klev)
     1372      REAL zthl(ngrid,klev)
     1373
     1374      REAL zqsatth(ngrid,klev)
     1375      REAL zqsatenv(ngrid,klev)
     1376     
     1377     
     1378      REAL sigma1(ngrid,klev)
     1379      REAL sigma2(ngrid,klev)
     1380      REAL qlth(ngrid,klev)
     1381      REAL qlenv(ngrid,klev)
     1382      REAL qltot(ngrid,klev)
     1383      REAL cth(ngrid,klev) 
     1384      REAL cenv(ngrid,klev)   
     1385      REAL ctot(ngrid,klev)
     1386      REAL rneb(ngrid,klev)
     1387      REAL t(ngrid,klev)
     1388      REAL qsatmmussig1,qsatmmussig2,sqrt2pi,pi
     1389      REAL rdd,cppd,Lv
     1390      REAL alth,alenv,ath,aenv
     1391      REAL sth,senv,sigma1s,sigma2s,xth,xenv
     1392      REAL Tbef,zdelta,qsatbef,zcor
     1393      REAL qlbef 
     1394      REAL ratqs(ngrid,klev) ! determine la largeur de distribution de vapeur
     1395     
     1396      REAL zpdf_sig(ngrid),zpdf_k(ngrid),zpdf_delta(ngrid)
     1397      REAL zpdf_a(ngrid),zpdf_b(ngrid),zpdf_e1(ngrid),zpdf_e2(ngrid)
     1398      REAL zqs(ngrid), qcloud(ngrid)
     1399
     1400
     1401
     1402
     1403!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1404! Gestion de deux versions de cloudth
     1405!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1406
     1407      IF (iflag_cloudth_vert.GE.1) THEN
     1408      CALL cloudth_vert(ngrid,klev,ind2,  &
     1409     &           ztv,po,zqta,fraca, &
     1410     &           qcloud,ctot,zpspsk,paprs,pplay,ztla,zthl, &
     1411     &           ratqs,zqs,t)
     1412      RETURN
     1413      ENDIF
     1414!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1415
     1416
     1417!-------------------------------------------------------------------------------
     1418! Initialisation des variables r?elles
     1419!-------------------------------------------------------------------------------
     1420      sigma1(:,ind2)=0.
     1421      sigma2(:,ind2)=0.
     1422      qlth(:,ind2)=0.
     1423      qlenv(:,ind2)=0. 
     1424      qltot(:,ind2)=0.
     1425      rneb(:,ind2)=0.
     1426      qcloud(:)=0.
     1427      cth(:,ind2)=0.
     1428      cenv(:,ind2)=0.
     1429      ctot(:,ind2)=0.
     1430      qsatmmussig1=0.
     1431      qsatmmussig2=0.
     1432      rdd=287.04
     1433      cppd=1005.7
     1434      pi=3.14159
     1435      Lv=2.5e6
     1436      sqrt2pi=sqrt(2.*pi)
     1437
     1438
     1439
     1440!-------------------------------------------------------------------------------
     1441! Calcul de la fraction du thermique et des ?cart-types des distributions
     1442!-------------------------------------------------------------------------------                 
     1443      do ind1=1,ngrid
     1444
     1445      if ((ztv(ind1,1).gt.ztv(ind1,2)).and.(fraca(ind1,ind2).gt.1.e-10)) then
     1446
     1447      zqenv(ind1)=(po(ind1)-fraca(ind1,ind2)*zqta(ind1,ind2))/(1.-fraca(ind1,ind2))
     1448
     1449
     1450!      zqenv(ind1)=po(ind1)
     1451      Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
     1452      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     1453      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     1454      qsatbef=MIN(0.5,qsatbef)
     1455      zcor=1./(1.-retv*qsatbef)
     1456      qsatbef=qsatbef*zcor
     1457      zqsatenv(ind1,ind2)=qsatbef
     1458
     1459
     1460
     1461
     1462      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2) 
     1463      aenv=1./(1.+(alenv*Lv/cppd))
     1464      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     1465
     1466
     1467
     1468
     1469      Tbef=ztla(ind1,ind2)*zpspsk(ind1,ind2)
     1470      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     1471      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     1472      qsatbef=MIN(0.5,qsatbef)
     1473      zcor=1./(1.-retv*qsatbef)
     1474      qsatbef=qsatbef*zcor
     1475      zqsatth(ind1,ind2)=qsatbef
     1476           
     1477      alth=(0.622*Lv*zqsatth(ind1,ind2))/(rdd*ztla(ind1,ind2)**2)   
     1478      ath=1./(1.+(alth*Lv/cppd))
     1479      sth=ath*(zqta(ind1,ind2)-zqsatth(ind1,ind2))
     1480     
     1481     
     1482
     1483!------------------------------------------------------------------------------
     1484! Calcul des ?cart-types pour s
     1485!------------------------------------------------------------------------------
     1486
     1487!      sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+ratqs(ind1,ind2)*po(ind1)
     1488!      sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.02)**0.4+0.002*zqta(ind1,ind2)
     1489!       if (paprs(ind1,ind2).gt.90000) then
     1490!       ratqs(ind1,ind2)=0.002
     1491!       else
     1492!       ratqs(ind1,ind2)=0.002+0.0*(90000-paprs(ind1,ind2))/20000
     1493!       endif
     1494       sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
     1495       sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.01)**0.4+0.002*zqta(ind1,ind2)
     1496!       sigma1s=ratqs(ind1,ind2)*po(ind1)
     1497!      sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.02)**0.4+0.00003 
     1498 
     1499!------------------------------------------------------------------------------
     1500! Calcul de l'eau condens?e et de la couverture nuageuse
     1501!------------------------------------------------------------------------------
     1502      sqrt2pi=sqrt(2.*pi)
     1503      xth=sth/(sqrt(2.)*sigma2s)
     1504      xenv=senv/(sqrt(2.)*sigma1s)
     1505      cth(ind1,ind2)=0.5*(1.+1.*erf(xth))
     1506      cenv(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     1507      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)   
     1508
     1509      qlth(ind1,ind2)=sigma2s*((exp(-1.*xth**2)/sqrt2pi)+xth*sqrt(2.)*cth(ind1,ind2))
     1510      qlenv(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt(2.)*cenv(ind1,ind2))   
     1511      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     1512
     1513!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1514      if (ctot(ind1,ind2).lt.1.e-10) then
     1515      ctot(ind1,ind2)=0.
     1516      qcloud(ind1)=zqsatenv(ind1,ind2)
     1517
     1518      else   
     1519               
     1520      ctot(ind1,ind2)=ctot(ind1,ind2)
     1521      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqs(ind1)
     1522
     1523      endif                           
     1524     
     1525         
     1526
     1527
     1528      else  ! gaussienne environnement seule
     1529     
     1530      zqenv(ind1)=po(ind1)
     1531      Tbef=t(ind1,ind2)
     1532      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     1533      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     1534      qsatbef=MIN(0.5,qsatbef)
     1535      zcor=1./(1.-retv*qsatbef)
     1536      qsatbef=qsatbef*zcor
     1537      zqsatenv(ind1,ind2)=qsatbef
     1538     
     1539
     1540!      qlbef=Max(po(ind1)-zqsatenv(ind1,ind2),0.)
     1541      zthl(ind1,ind2)=t(ind1,ind2)*(101325/paprs(ind1,ind2))**(rdd/cppd)
     1542      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2) 
     1543      aenv=1./(1.+(alenv*Lv/cppd))
     1544      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     1545     
     1546
     1547      sigma1s=ratqs(ind1,ind2)*zqenv(ind1)
     1548
     1549      sqrt2pi=sqrt(2.*pi)
     1550      xenv=senv/(sqrt(2.)*sigma1s)
     1551      ctot(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     1552      qltot(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt(2.)*cenv(ind1,ind2))
     1553     
     1554      if (ctot(ind1,ind2).lt.1.e-3) then
     1555      ctot(ind1,ind2)=0.
     1556      qcloud(ind1)=zqsatenv(ind1,ind2)
     1557
     1558      else   
     1559               
     1560      ctot(ind1,ind2)=ctot(ind1,ind2)
     1561      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqsatenv(ind1,ind2)
     1562
     1563      endif   
     1564 
     1565 
     1566 
     1567 
     1568 
     1569 
     1570      endif   
     1571      enddo
     1572     
     1573      return
     1574!     end
     1575END SUBROUTINE cloudth
     1576
     1577
     1578
     1579!===========================================================================
     1580     SUBROUTINE cloudth_vert(ngrid,klev,ind2,  &
     1581     &           ztv,po,zqta,fraca, &
     1582     &           qcloud,ctot,zpspsk,paprs,pplay,ztla,zthl, &
     1583     &           ratqs,zqs,t)
     1584
     1585!===========================================================================
     1586! Auteur : Arnaud Octavio Jam (LMD/CNRS)
     1587! Date : 25 Mai 2010
     1588! Objet : calcule les valeurs de qc et rneb dans les thermiques
     1589!===========================================================================
     1590
     1591
     1592USE yoethf_mod_h
     1593            use lmdz_lscp_ini, only: iflag_cloudth_vert, vert_alpha
     1594
     1595      USE yomcst_mod_h
     1596IMPLICIT NONE
     1597
     1598
     1599      INCLUDE "FCTTRE.h"
     1600     
     1601      INTEGER itap,ind1,ind2
     1602      INTEGER ngrid,klev,klon,l,ig
     1603     
     1604      REAL ztv(ngrid,klev)
     1605      REAL po(ngrid)
     1606      REAL zqenv(ngrid)   
     1607      REAL zqta(ngrid,klev)
     1608         
     1609      REAL fraca(ngrid,klev+1)
     1610      REAL zpspsk(ngrid,klev)
     1611      REAL paprs(ngrid,klev+1)
     1612      REAL pplay(ngrid,klev)
     1613      REAL ztla(ngrid,klev)
     1614      REAL zthl(ngrid,klev)
     1615
     1616      REAL zqsatth(ngrid,klev)
     1617      REAL zqsatenv(ngrid,klev)
     1618     
     1619     
     1620      REAL sigma1(ngrid,klev)                                                         
     1621      REAL sigma2(ngrid,klev)
     1622      REAL qlth(ngrid,klev)
     1623      REAL qlenv(ngrid,klev)
     1624      REAL qltot(ngrid,klev)
     1625      REAL cth(ngrid,klev) 
     1626      REAL cenv(ngrid,klev)   
     1627      REAL ctot(ngrid,klev)
     1628      REAL rneb(ngrid,klev)
     1629      REAL t(ngrid,klev)                                                                 
     1630      REAL qsatmmussig1,qsatmmussig2,sqrt2pi,pi
     1631      REAL rdd,cppd,Lv,sqrt2,sqrtpi
     1632      REAL alth,alenv,ath,aenv
     1633      REAL sth,senv,sigma1s,sigma2s,xth,xenv
     1634      REAL xth1,xth2,xenv1,xenv2,deltasth, deltasenv
     1635      REAL IntJ,IntI1,IntI2,IntI3,coeffqlenv,coeffqlth
     1636      REAL Tbef,zdelta,qsatbef,zcor
     1637      REAL qlbef 
     1638      REAL ratqs(ngrid,klev) ! determine la largeur de distribution de vapeur
     1639      ! Change the width of the PDF used for vertical subgrid scale heterogeneity
     1640      ! (J Jouhaud, JL Dufresne, JB Madeleine)
     1641     
     1642      REAL zpdf_sig(ngrid),zpdf_k(ngrid),zpdf_delta(ngrid)
     1643      REAL zpdf_a(ngrid),zpdf_b(ngrid),zpdf_e1(ngrid),zpdf_e2(ngrid)
     1644      REAL zqs(ngrid), qcloud(ngrid)
     1645
     1646!------------------------------------------------------------------------------
     1647! Initialisation des variables r?elles
     1648!------------------------------------------------------------------------------
     1649      sigma1(:,ind2)=0.
     1650      sigma2(:,ind2)=0.
     1651      qlth(:,ind2)=0.
     1652      qlenv(:,ind2)=0. 
     1653      qltot(:,ind2)=0.
     1654      rneb(:,ind2)=0.
     1655      qcloud(:)=0.
     1656      cth(:,ind2)=0.
     1657      cenv(:,ind2)=0.
     1658      ctot(:,ind2)=0.
     1659      qsatmmussig1=0.
     1660      qsatmmussig2=0.
     1661      rdd=287.04
     1662      cppd=1005.7
     1663      pi=3.14159
     1664      Lv=2.5e6
     1665      sqrt2pi=sqrt(2.*pi)
     1666      sqrt2=sqrt(2.)
     1667      sqrtpi=sqrt(pi)
     1668
     1669!-------------------------------------------------------------------------------
     1670! Calcul de la fraction du thermique et des ?cart-types des distributions
     1671!-------------------------------------------------------------------------------                 
     1672      do ind1=1,ngrid
     1673
     1674      if ((ztv(ind1,1).gt.ztv(ind1,2)).and.(fraca(ind1,ind2).gt.1.e-10)) then
     1675
     1676      zqenv(ind1)=(po(ind1)-fraca(ind1,ind2)*zqta(ind1,ind2))/(1.-fraca(ind1,ind2))
     1677
     1678
     1679!      zqenv(ind1)=po(ind1)
     1680      Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
     1681      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     1682      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     1683      qsatbef=MIN(0.5,qsatbef)
     1684      zcor=1./(1.-retv*qsatbef)
     1685      qsatbef=qsatbef*zcor
     1686      zqsatenv(ind1,ind2)=qsatbef
     1687
     1688
     1689
     1690
     1691      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2) 
     1692      aenv=1./(1.+(alenv*Lv/cppd))
     1693      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     1694
     1695
     1696
     1697
     1698      Tbef=ztla(ind1,ind2)*zpspsk(ind1,ind2)
     1699      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     1700      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     1701      qsatbef=MIN(0.5,qsatbef)
     1702      zcor=1./(1.-retv*qsatbef)
     1703      qsatbef=qsatbef*zcor
     1704      zqsatth(ind1,ind2)=qsatbef
     1705           
     1706      alth=(0.622*Lv*zqsatth(ind1,ind2))/(rdd*ztla(ind1,ind2)**2)   
     1707      ath=1./(1.+(alth*Lv/cppd))
     1708      sth=ath*(zqta(ind1,ind2)-zqsatth(ind1,ind2))
     1709     
     1710     
     1711
     1712!------------------------------------------------------------------------------
     1713! Calcul des ?cart-types pour s
     1714!------------------------------------------------------------------------------
     1715
     1716      sigma1s=(0.92**0.5)*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+ratqs(ind1,ind2)*po(ind1)
     1717      sigma2s=0.09*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.02)**0.5+0.002*zqta(ind1,ind2)
     1718!       if (paprs(ind1,ind2).gt.90000) then
     1719!       ratqs(ind1,ind2)=0.002
     1720!       else
     1721!       ratqs(ind1,ind2)=0.002+0.0*(90000-paprs(ind1,ind2))/20000
     1722!       endif
     1723!       sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
     1724!       sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.01)**0.4+0.002*zqta(ind1,ind2)
     1725!       sigma1s=ratqs(ind1,ind2)*po(ind1)
     1726!      sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.02)**0.4+0.00003 
     1727 
     1728!------------------------------------------------------------------------------
     1729! Calcul de l'eau condens?e et de la couverture nuageuse
     1730!------------------------------------------------------------------------------
     1731      sqrt2pi=sqrt(2.*pi)
     1732      xth=sth/(sqrt(2.)*sigma2s)
     1733      xenv=senv/(sqrt(2.)*sigma1s)
     1734      cth(ind1,ind2)=0.5*(1.+1.*erf(xth))
     1735      cenv(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     1736      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)   
     1737
     1738      qlth(ind1,ind2)=sigma2s*((exp(-1.*xth**2)/sqrt2pi)+xth*sqrt(2.)*cth(ind1,ind2))
     1739      qlenv(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt(2.)*cenv(ind1,ind2))   
     1740      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     1741     
     1742       IF (iflag_cloudth_vert == 1) THEN
     1743!-------------------------------------------------------------------------------
     1744!  Version 2: Modification selon J.-Louis. On condense ?? partir de qsat-ratqs
     1745!-------------------------------------------------------------------------------
     1746!      deltasenv=aenv*ratqs(ind1,ind2)*po(ind1)
     1747!      deltasth=ath*ratqs(ind1,ind2)*zqta(ind1,ind2)
     1748      deltasenv=aenv*ratqs(ind1,ind2)*zqsatenv(ind1,ind2)
     1749      deltasth=ath*ratqs(ind1,ind2)*zqsatth(ind1,ind2)
     1750!      deltasenv=aenv*0.01*po(ind1)
     1751!     deltasth=ath*0.01*zqta(ind1,ind2)   
     1752      xenv1=(senv-deltasenv)/(sqrt(2.)*sigma1s)
     1753      xenv2=(senv+deltasenv)/(sqrt(2.)*sigma1s)
     1754      xth1=(sth-deltasth)/(sqrt(2.)*sigma2s)
     1755      xth2=(sth+deltasth)/(sqrt(2.)*sigma2s)
     1756      coeffqlenv=(sigma1s)**2/(2*sqrtpi*deltasenv)
     1757      coeffqlth=(sigma2s)**2/(2*sqrtpi*deltasth)
     1758     
     1759      cth(ind1,ind2)=0.5*(1.+1.*erf(xth2))
     1760      cenv(ind1,ind2)=0.5*(1.+1.*erf(xenv2))
     1761      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)   
     1762
     1763      IntJ=sigma1s*(exp(-1.*xenv1**2)/sqrt2pi)+0.5*senv*(1+erf(xenv1))
     1764      IntI1=coeffqlenv*0.5*(0.5*sqrtpi*(erf(xenv2)-erf(xenv1))+xenv1*exp(-1.*xenv1**2)-xenv2*exp(-1.*xenv2**2))
     1765      IntI2=coeffqlenv*xenv2*(exp(-1.*xenv2**2)-exp(-1.*xenv1**2))
     1766      IntI3=coeffqlenv*0.5*sqrtpi*xenv2**2*(erf(xenv2)-erf(xenv1))
     1767
     1768      qlenv(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     1769!      qlenv(ind1,ind2)=IntJ
     1770!      print*, qlenv(ind1,ind2),'VERIF EAU'
     1771
     1772
     1773      IntJ=sigma2s*(exp(-1.*xth1**2)/sqrt2pi)+0.5*sth*(1+erf(xth1))
     1774!      IntI1=coeffqlth*((0.5*xth1-xth2)*exp(-1.*xth1**2)+0.5*xth2*exp(-1.*xth2**2))
     1775!      IntI2=coeffqlth*0.5*sqrtpi*(0.5+xth2**2)*(erf(xth2)-erf(xth1))
     1776      IntI1=coeffqlth*0.5*(0.5*sqrtpi*(erf(xth2)-erf(xth1))+xth1*exp(-1.*xth1**2)-xth2*exp(-1.*xth2**2))
     1777      IntI2=coeffqlth*xth2*(exp(-1.*xth2**2)-exp(-1.*xth1**2))
     1778      IntI3=coeffqlth*0.5*sqrtpi*xth2**2*(erf(xth2)-erf(xth1))
     1779      qlth(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     1780!      qlth(ind1,ind2)=IntJ
     1781!      print*, IntJ,IntI1,IntI2,IntI3,qlth(ind1,ind2),'VERIF EAU2'
     1782      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     1783
     1784      ELSE IF (iflag_cloudth_vert == 2) THEN
     1785
     1786!-------------------------------------------------------------------------------
     1787!  Version 3: Modification Jean Jouhaud. On condense a partir de -delta s
     1788!-------------------------------------------------------------------------------
     1789!      deltasenv=aenv*ratqs(ind1,ind2)*po(ind1)
     1790!      deltasth=ath*ratqs(ind1,ind2)*zqta(ind1,ind2)
     1791!      deltasenv=aenv*ratqs(ind1,ind2)*zqsatenv(ind1,ind2)
     1792!      deltasth=ath*ratqs(ind1,ind2)*zqsatth(ind1,ind2)
     1793      deltasenv=aenv*vert_alpha*sigma1s
     1794      deltasth=ath*vert_alpha*sigma2s
     1795     
     1796      xenv1=-(senv+deltasenv)/(sqrt(2.)*sigma1s)
     1797      xenv2=-(senv-deltasenv)/(sqrt(2.)*sigma1s)
     1798      xth1=-(sth+deltasth)/(sqrt(2.)*sigma2s)
     1799      xth2=-(sth-deltasth)/(sqrt(2.)*sigma2s)
     1800!     coeffqlenv=(sigma1s)**2/(2*sqrtpi*deltasenv)
     1801!     coeffqlth=(sigma2s)**2/(2*sqrtpi*deltasth)
     1802     
     1803      cth(ind1,ind2)=0.5*(1.-1.*erf(xth1))
     1804      cenv(ind1,ind2)=0.5*(1.-1.*erf(xenv1))
     1805      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)
     1806
     1807      IntJ=0.5*senv*(1-erf(xenv2))+(sigma1s/sqrt2pi)*exp(-1.*xenv2**2)
     1808      IntI1=(((senv+deltasenv)**2+(sigma1s)**2)/(8*deltasenv))*(erf(xenv2)-erf(xenv1))
     1809      IntI2=(sigma1s**2/(4*deltasenv*sqrtpi))*(xenv1*exp(-1.*xenv1**2)-xenv2*exp(-1.*xenv2**2))
     1810      IntI3=((sqrt2*sigma1s*(senv+deltasenv))/(4*sqrtpi*deltasenv))*(exp(-1.*xenv1**2)-exp(-1.*xenv2**2))
     1811
     1812!      IntI1=0.5*(0.5*sqrtpi*(erf(xenv2)-erf(xenv1))+xenv1*exp(-1.*xenv1**2)-xenv2*exp(-1.*xenv2**2))
     1813!      IntI2=xenv2*(exp(-1.*xenv2**2)-exp(-1.*xenv1**2))
     1814!      IntI3=0.5*sqrtpi*xenv2**2*(erf(xenv2)-erf(xenv1))
     1815
     1816      qlenv(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     1817!      qlenv(ind1,ind2)=IntJ
     1818!      print*, qlenv(ind1,ind2),'VERIF EAU'
     1819
     1820      IntJ=0.5*sth*(1-erf(xth2))+(sigma2s/sqrt2pi)*exp(-1.*xth2**2)
     1821      IntI1=(((sth+deltasth)**2+(sigma2s)**2)/(8*deltasth))*(erf(xth2)-erf(xth1))
     1822      IntI2=(sigma2s**2/(4*deltasth*sqrtpi))*(xth1*exp(-1.*xth1**2)-xth2*exp(-1.*xth2**2))
     1823      IntI3=((sqrt2*sigma2s*(sth+deltasth))/(4*sqrtpi*deltasth))*(exp(-1.*xth1**2)-exp(-1.*xth2**2))
     1824     
     1825      qlth(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     1826!      qlth(ind1,ind2)=IntJ
     1827!      print*, IntJ,IntI1,IntI2,IntI3,qlth(ind1,ind2),'VERIF EAU2'
     1828      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     1829     
     1830
     1831
     1832
     1833      ENDIF ! of if (iflag_cloudth_vert==1 or 2)
     1834
     1835!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1836
     1837      if (cenv(ind1,ind2).lt.1.e-10.or.cth(ind1,ind2).lt.1.e-10) then
     1838      ctot(ind1,ind2)=0.
     1839      qcloud(ind1)=zqsatenv(ind1,ind2)
     1840
     1841      else
     1842               
     1843      ctot(ind1,ind2)=ctot(ind1,ind2)
     1844      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqs(ind1)
     1845!      qcloud(ind1)=fraca(ind1,ind2)*qlth(ind1,ind2)/cth(ind1,ind2) &
     1846!    &             +(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)/cenv(ind1,ind2)+zqs(ind1)
     1847
     1848      endif 
     1849                       
     1850     
     1851         
     1852!     print*,sth,sigma2s,qlth(ind1,ind2),ctot(ind1,ind2),qltot(ind1,ind2),'verif'
     1853
     1854
     1855      else  ! gaussienne environnement seule
     1856     
     1857      zqenv(ind1)=po(ind1)
     1858      Tbef=t(ind1,ind2)
     1859      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     1860      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     1861      qsatbef=MIN(0.5,qsatbef)
     1862      zcor=1./(1.-retv*qsatbef)
     1863      qsatbef=qsatbef*zcor
     1864      zqsatenv(ind1,ind2)=qsatbef
     1865     
     1866
     1867!      qlbef=Max(po(ind1)-zqsatenv(ind1,ind2),0.)
     1868      zthl(ind1,ind2)=t(ind1,ind2)*(101325/paprs(ind1,ind2))**(rdd/cppd)
     1869      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2) 
     1870      aenv=1./(1.+(alenv*Lv/cppd))
     1871      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     1872     
     1873
     1874      sigma1s=ratqs(ind1,ind2)*zqenv(ind1)
     1875
     1876      sqrt2pi=sqrt(2.*pi)
     1877      xenv=senv/(sqrt(2.)*sigma1s)
     1878      ctot(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     1879      qltot(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt(2.)*cenv(ind1,ind2))
     1880     
     1881      if (ctot(ind1,ind2).lt.1.e-3) then
     1882      ctot(ind1,ind2)=0.
     1883      qcloud(ind1)=zqsatenv(ind1,ind2)
     1884
     1885      else   
     1886               
     1887      ctot(ind1,ind2)=ctot(ind1,ind2)
     1888      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqsatenv(ind1,ind2)
     1889
     1890      endif   
     1891 
     1892 
     1893 
     1894 
     1895 
     1896 
     1897      endif   
     1898      enddo
     1899     
     1900      return
     1901!     end
     1902END SUBROUTINE cloudth_vert
     1903
     1904
     1905
     1906
     1907       SUBROUTINE cloudth_v3(ngrid,klev,ind2,  &
     1908     &           ztv,po,zqta,fraca, &
     1909     &           qcloud,ctot,ctot_vol,zpspsk,paprs,pplay,ztla,zthl, &
     1910     &           ratqs,sigma_qtherm,zqs,t, &
     1911     &           cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
     1912
     1913      use lmdz_lscp_ini, only: iflag_cloudth_vert
     1914
     1915      USE yomcst_mod_h
     1916      USE yoethf_mod_h
     1917IMPLICIT NONE
     1918
     1919
     1920!===========================================================================
     1921! Author : Arnaud Octavio Jam (LMD/CNRS)
     1922! Date : 25 Mai 2010
     1923! Objet : calcule les valeurs de qc et rneb dans les thermiques
     1924!===========================================================================
     1925      INCLUDE "FCTTRE.h"
     1926
     1927      integer, intent(in) :: ind2
     1928      integer, intent(in) :: ngrid,klev
     1929     
     1930      real, dimension(ngrid,klev), intent(in) :: ztv
     1931      real, dimension(ngrid), intent(in) :: po
     1932      real, dimension(ngrid,klev), intent(in) :: zqta
     1933      real, dimension(ngrid,klev+1), intent(in) :: fraca
     1934      real, dimension(ngrid), intent(out) :: qcloud
     1935      real, dimension(ngrid,klev), intent(out) :: ctot
     1936      real, dimension(ngrid,klev), intent(out) :: ctot_vol
     1937      real, dimension(ngrid,klev), intent(in) :: zpspsk
     1938      real, dimension(ngrid,klev+1), intent(in) :: paprs
     1939      real, dimension(ngrid,klev), intent(in) :: pplay
     1940      real, dimension(ngrid,klev), intent(in) :: ztla
     1941      real, dimension(ngrid,klev), intent(inout) :: zthl
     1942      real, dimension(ngrid,klev), intent(in) :: ratqs,sigma_qtherm
     1943      real, dimension(ngrid), intent(in) :: zqs
     1944      real, dimension(ngrid,klev), intent(in) :: t
     1945      real, dimension(ngrid,klev), intent(out) :: cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
     1946
     1947
     1948      REAL zqenv(ngrid)   
     1949      REAL zqsatth(ngrid,klev)
     1950      REAL zqsatenv(ngrid,klev)
     1951     
     1952      REAL sigma1(ngrid,klev)                                                         
     1953      REAL sigma2(ngrid,klev)
     1954      REAL qlth(ngrid,klev)
     1955      REAL qlenv(ngrid,klev)
     1956      REAL qltot(ngrid,klev)
     1957      REAL cth(ngrid,klev)
     1958      REAL cenv(ngrid,klev)   
     1959      REAL cth_vol(ngrid,klev)
     1960      REAL cenv_vol(ngrid,klev)
     1961      REAL rneb(ngrid,klev)     
     1962      REAL qsatmmussig1,qsatmmussig2,sqrt2pi,sqrt2,sqrtpi,pi
     1963      REAL rdd,cppd,Lv
     1964      REAL alth,alenv,ath,aenv
     1965      REAL sth,senv,sigma1s,sigma2s,xth,xenv, exp_xenv1, exp_xenv2,exp_xth1,exp_xth2
     1966      REAL inverse_rho,beta,a_Brooks,b_Brooks,A_Maj_Brooks,Dx_Brooks,f_Brooks
     1967      REAL Tbef,zdelta,qsatbef,zcor
     1968      REAL qlbef 
     1969      REAL zpdf_sig(ngrid),zpdf_k(ngrid),zpdf_delta(ngrid)
     1970      REAL zpdf_a(ngrid),zpdf_b(ngrid),zpdf_e1(ngrid),zpdf_e2(ngrid)
     1971
     1972
     1973      INTEGER :: ind1,l, ig
     1974
     1975      IF (iflag_cloudth_vert.GE.1) THEN
     1976      CALL cloudth_vert_v3(ngrid,klev,ind2,  &
     1977     &           ztv,po,zqta,fraca, &
     1978     &           qcloud,ctot,ctot_vol,zpspsk,paprs,pplay,ztla,zthl, &
     1979     &           ratqs,sigma_qtherm,zqs,t, &
     1980     &           cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
     1981      RETURN
     1982      ENDIF
     1983!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1984
     1985
     1986!-------------------------------------------------------------------------------
     1987! Initialisation des variables r?elles
     1988!-------------------------------------------------------------------------------
     1989      sigma1(:,ind2)=0.
     1990      sigma2(:,ind2)=0.
     1991      qlth(:,ind2)=0.
     1992      qlenv(:,ind2)=0. 
     1993      qltot(:,ind2)=0.
     1994      rneb(:,ind2)=0.
     1995      qcloud(:)=0.
     1996      cth(:,ind2)=0.
     1997      cenv(:,ind2)=0.
     1998      ctot(:,ind2)=0.
     1999      cth_vol(:,ind2)=0.
     2000      cenv_vol(:,ind2)=0.
     2001      ctot_vol(:,ind2)=0.
     2002      qsatmmussig1=0.
     2003      qsatmmussig2=0.
     2004      rdd=287.04
     2005      cppd=1005.7
     2006      pi=3.14159
     2007      Lv=2.5e6
     2008      sqrt2pi=sqrt(2.*pi)
     2009      sqrt2=sqrt(2.)
     2010      sqrtpi=sqrt(pi)
     2011
     2012
     2013!-------------------------------------------------------------------------------
     2014! Cloud fraction in the thermals and standard deviation of the PDFs
     2015!-------------------------------------------------------------------------------                 
     2016      do ind1=1,ngrid
     2017
     2018      if ((ztv(ind1,1).gt.ztv(ind1,2)).and.(fraca(ind1,ind2).gt.1.e-10)) then
     2019
     2020      zqenv(ind1)=(po(ind1)-fraca(ind1,ind2)*zqta(ind1,ind2))/(1.-fraca(ind1,ind2))
     2021
     2022      Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
     2023      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2024      qsatbef= R2ES*FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2025      qsatbef=MIN(0.5,qsatbef)
     2026      zcor=1./(1.-retv*qsatbef)
     2027      qsatbef=qsatbef*zcor
     2028      zqsatenv(ind1,ind2)=qsatbef
     2029
     2030
     2031      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)     !qsl, p84
     2032      aenv=1./(1.+(alenv*Lv/cppd))                                      !al, p84
     2033      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))                          !s, p84
     2034
     2035!po = qt de l'environnement ET des thermique
     2036!zqenv = qt environnement
     2037!zqsatenv = qsat environnement
     2038!zthl = Tl environnement
     2039
     2040
     2041      Tbef=ztla(ind1,ind2)*zpspsk(ind1,ind2)
     2042      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2043      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2044      qsatbef=MIN(0.5,qsatbef)
     2045      zcor=1./(1.-retv*qsatbef)
     2046      qsatbef=qsatbef*zcor
     2047      zqsatth(ind1,ind2)=qsatbef
     2048           
     2049      alth=(0.622*Lv*zqsatth(ind1,ind2))/(rdd*ztla(ind1,ind2)**2)       !qsl, p84
     2050      ath=1./(1.+(alth*Lv/cppd))                                        !al, p84
     2051      sth=ath*(zqta(ind1,ind2)-zqsatth(ind1,ind2))                      !s, p84
     2052     
     2053!zqta = qt thermals
     2054!zqsatth = qsat thermals
     2055!ztla = Tl thermals
     2056
     2057!------------------------------------------------------------------------------
     2058! s standard deviations
     2059!------------------------------------------------------------------------------
     2060
     2061!     tests
     2062!     sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
     2063!     sigma1s=(0.92*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5))+ratqs(ind1,ind2)*po(ind1)
     2064!     sigma2s=(0.09*(((sth-senv)**2)**0.5)/((fraca(ind1,ind2)+0.02)**0.5))+0.002*zqta(ind1,ind2)
     2065!     final option
     2066      sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+ratqs(ind1,ind2)*po(ind1)
     2067      sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.01)**0.4+0.002*zqta(ind1,ind2)
     2068 
     2069!------------------------------------------------------------------------------
     2070! Condensed water and cloud cover
     2071!------------------------------------------------------------------------------
     2072      xth=sth/(sqrt2*sigma2s)
     2073      xenv=senv/(sqrt2*sigma1s)
     2074      cth(ind1,ind2)=0.5*(1.+1.*erf(xth))       !4.18 p 111, l.7 p115 & 4.20 p 119 thesis Arnaud Jam
     2075      cenv(ind1,ind2)=0.5*(1.+1.*erf(xenv))     !4.18 p 111, l.7 p115 & 4.20 p 119 thesis Arnaud Jam
     2076      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)
     2077      ctot_vol(ind1,ind2)=ctot(ind1,ind2)
     2078
     2079      qlth(ind1,ind2)=sigma2s*((exp(-1.*xth**2)/sqrt2pi)+xth*sqrt2*cth(ind1,ind2))
     2080      qlenv(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt2*cenv(ind1,ind2))
     2081      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     2082
     2083      if (ctot(ind1,ind2).lt.1.e-10) then
     2084      ctot(ind1,ind2)=0.
     2085      qcloud(ind1)=zqsatenv(ind1,ind2)
     2086      else
     2087      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqs(ind1)
     2088      endif
     2089
     2090      else  ! Environnement only, follow the if l.110
     2091     
     2092      zqenv(ind1)=po(ind1)
     2093      Tbef=t(ind1,ind2)
     2094      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2095      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2096      qsatbef=MIN(0.5,qsatbef)
     2097      zcor=1./(1.-retv*qsatbef)
     2098      qsatbef=qsatbef*zcor
     2099      zqsatenv(ind1,ind2)=qsatbef
     2100
     2101!     qlbef=Max(po(ind1)-zqsatenv(ind1,ind2),0.)
     2102      zthl(ind1,ind2)=t(ind1,ind2)*(101325/paprs(ind1,ind2))**(rdd/cppd)
     2103      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2) 
     2104      aenv=1./(1.+(alenv*Lv/cppd))
     2105      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     2106     
     2107      sigma1s=ratqs(ind1,ind2)*zqenv(ind1)
     2108
     2109      xenv=senv/(sqrt2*sigma1s)
     2110      ctot(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     2111      ctot_vol(ind1,ind2)=ctot(ind1,ind2)
     2112      qltot(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt2*cenv(ind1,ind2))
     2113
     2114      if (ctot(ind1,ind2).lt.1.e-3) then
     2115      ctot(ind1,ind2)=0.
     2116      qcloud(ind1)=zqsatenv(ind1,ind2)
     2117      else   
     2118      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqsatenv(ind1,ind2)
     2119      endif
     2120
     2121
     2122      endif       ! From the separation (thermal/envrionnement) et (environnement) only, l.110 et l.183
     2123      enddo       ! from the loop on ngrid l.108
     2124      return
     2125!     end
     2126END SUBROUTINE cloudth_v3
     2127
     2128
     2129
     2130!===========================================================================
     2131     SUBROUTINE cloudth_vert_v3(ngrid,klev,ind2,  &
     2132     &           ztv,po,zqta,fraca, &
     2133     &           qcloud,ctot,ctot_vol,zpspsk,paprs,pplay,ztla,zthl, &
     2134     &           ratqs,sigma_qtherm,zqs,t, &
     2135     &           cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
     2136
     2137!===========================================================================
     2138! Auteur : Arnaud Octavio Jam (LMD/CNRS)
     2139! Date : 25 Mai 2010
     2140! Objet : calcule les valeurs de qc et rneb dans les thermiques
     2141!===========================================================================
     2142
     2143      use yoethf_mod_h
     2144      use lmdz_lscp_ini, only : iflag_cloudth_vert,iflag_ratqs
     2145      use lmdz_lscp_ini, only : vert_alpha,vert_alpha_th, sigma1s_factor, sigma1s_power , sigma2s_factor , sigma2s_power , cloudth_ratqsmin , iflag_cloudth_vert_noratqs
     2146
     2147      USE yomcst_mod_h
     2148IMPLICIT NONE
     2149
     2150
     2151
     2152
     2153      INCLUDE "FCTTRE.h"
     2154     
     2155      INTEGER itap,ind1,ind2
     2156      INTEGER ngrid,klev,klon,l,ig
     2157      real, dimension(ngrid,klev), intent(out) :: cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
     2158     
     2159      REAL ztv(ngrid,klev)
     2160      REAL po(ngrid)
     2161      REAL zqenv(ngrid)   
     2162      REAL zqta(ngrid,klev)
     2163         
     2164      REAL fraca(ngrid,klev+1)
     2165      REAL zpspsk(ngrid,klev)
     2166      REAL paprs(ngrid,klev+1)
     2167      REAL pplay(ngrid,klev)
     2168      REAL ztla(ngrid,klev)
     2169      REAL zthl(ngrid,klev)
     2170
     2171      REAL zqsatth(ngrid,klev)
     2172      REAL zqsatenv(ngrid,klev)
     2173     
     2174      REAL sigma1(ngrid,klev)                                                         
     2175      REAL sigma2(ngrid,klev)
     2176      REAL qlth(ngrid,klev)
     2177      REAL qlenv(ngrid,klev)
     2178      REAL qltot(ngrid,klev)
     2179      REAL cth(ngrid,klev)
     2180      REAL cenv(ngrid,klev)   
     2181      REAL ctot(ngrid,klev)
     2182      REAL cth_vol(ngrid,klev)
     2183      REAL cenv_vol(ngrid,klev)
     2184      REAL ctot_vol(ngrid,klev)
     2185      REAL rneb(ngrid,klev)
     2186      REAL t(ngrid,klev)                                                                 
     2187      REAL qsatmmussig1,qsatmmussig2,sqrtpi,sqrt2,sqrt2pi,pi
     2188      REAL rdd,cppd,Lv
     2189      REAL alth,alenv,ath,aenv
     2190      REAL sth,senv,sigma1s,sigma2s,sigma1s_fraca,sigma1s_ratqs
     2191      REAL inverse_rho,beta,a_Brooks,b_Brooks,A_Maj_Brooks,Dx_Brooks,f_Brooks
     2192      REAL xth,xenv,exp_xenv1,exp_xenv2,exp_xth1,exp_xth2
     2193      REAL xth1,xth2,xenv1,xenv2,deltasth, deltasenv
     2194      REAL IntJ,IntI1,IntI2,IntI3,IntJ_CF,IntI1_CF,IntI3_CF,coeffqlenv,coeffqlth
     2195      REAL Tbef,zdelta,qsatbef,zcor
     2196      REAL qlbef 
     2197      REAL ratqs(ngrid,klev),sigma_qtherm(ngrid,klev) ! determine la largeur de distribution de vapeur
     2198      ! Change the width of the PDF used for vertical subgrid scale heterogeneity
     2199      ! (J Jouhaud, JL Dufresne, JB Madeleine)
     2200
     2201      REAL zpdf_sig(ngrid),zpdf_k(ngrid),zpdf_delta(ngrid)
     2202      REAL zpdf_a(ngrid),zpdf_b(ngrid),zpdf_e1(ngrid),zpdf_e2(ngrid)
     2203      REAL zqs(ngrid), qcloud(ngrid)
     2204
     2205      REAL rhodz(ngrid,klev)
     2206      REAL zrho(ngrid,klev)
     2207      REAL dz(ngrid,klev)
     2208
     2209      DO ind1 = 1, ngrid
     2210        !Layer calculation
     2211        rhodz(ind1,ind2) = (paprs(ind1,ind2)-paprs(ind1,ind2+1))/rg !kg/m2
     2212        zrho(ind1,ind2) = pplay(ind1,ind2)/t(ind1,ind2)/rd !kg/m3
     2213        dz(ind1,ind2) = rhodz(ind1,ind2)/zrho(ind1,ind2) !m : epaisseur de la couche en metre
     2214      END DO
     2215
     2216!------------------------------------------------------------------------------
     2217! Initialize
     2218!------------------------------------------------------------------------------
     2219
     2220      sigma1(:,ind2)=0.
     2221      sigma2(:,ind2)=0.
     2222      qlth(:,ind2)=0.
     2223      qlenv(:,ind2)=0. 
     2224      qltot(:,ind2)=0.
     2225      rneb(:,ind2)=0.
     2226      qcloud(:)=0.
     2227      cth(:,ind2)=0.
     2228      cenv(:,ind2)=0.
     2229      ctot(:,ind2)=0.
     2230      cth_vol(:,ind2)=0.
     2231      cenv_vol(:,ind2)=0.
     2232      ctot_vol(:,ind2)=0.
     2233      qsatmmussig1=0.
     2234      qsatmmussig2=0.
     2235      rdd=287.04
     2236      cppd=1005.7
     2237      pi=3.14159
     2238      Lv=2.5e6
     2239      sqrt2pi=sqrt(2.*pi)
     2240      sqrt2=sqrt(2.)
     2241      sqrtpi=sqrt(pi)
     2242
     2243
     2244
     2245!-------------------------------------------------------------------------------
     2246! Calcul de la fraction du thermique et des ecart-types des distributions
     2247!-------------------------------------------------------------------------------                 
     2248      do ind1=1,ngrid
     2249
     2250      if ((ztv(ind1,1).gt.ztv(ind1,2)).and.(fraca(ind1,ind2).gt.1.e-10)) then !Thermal and environnement
     2251
     2252      zqenv(ind1)=(po(ind1)-fraca(ind1,ind2)*zqta(ind1,ind2))/(1.-fraca(ind1,ind2)) !qt = a*qtth + (1-a)*qtenv
     2253
     2254
     2255      Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
     2256      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2257      qsatbef= R2ES*FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2258      qsatbef=MIN(0.5,qsatbef)
     2259      zcor=1./(1.-retv*qsatbef)
     2260      qsatbef=qsatbef*zcor
     2261      zqsatenv(ind1,ind2)=qsatbef
     2262
     2263
     2264      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)     !qsl, p84
     2265      aenv=1./(1.+(alenv*Lv/cppd))                                      !al, p84
     2266      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))                          !s, p84
     2267
     2268!zqenv = qt environnement
     2269!zqsatenv = qsat environnement
     2270!zthl = Tl environnement
     2271
     2272
     2273      Tbef=ztla(ind1,ind2)*zpspsk(ind1,ind2)
     2274      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2275      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2276      qsatbef=MIN(0.5,qsatbef)
     2277      zcor=1./(1.-retv*qsatbef)
     2278      qsatbef=qsatbef*zcor
     2279      zqsatth(ind1,ind2)=qsatbef
     2280           
     2281      alth=(0.622*Lv*zqsatth(ind1,ind2))/(rdd*ztla(ind1,ind2)**2)       !qsl, p84
     2282      ath=1./(1.+(alth*Lv/cppd))                                        !al, p84
     2283      sth=ath*(zqta(ind1,ind2)-zqsatth(ind1,ind2))                      !s, p84
     2284     
     2285     
     2286!zqta = qt thermals
     2287!zqsatth = qsat thermals
     2288!ztla = Tl thermals
     2289!------------------------------------------------------------------------------
     2290! s standard deviation
     2291!------------------------------------------------------------------------------
     2292
     2293      sigma1s_fraca = (sigma1s_factor**0.5)*(fraca(ind1,ind2)**sigma1s_power) / &
     2294     &                (1-fraca(ind1,ind2))*((sth-senv)**2)**0.5
     2295!     sigma1s_fraca = (1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5
     2296      IF (cloudth_ratqsmin>0.) THEN
     2297         sigma1s_ratqs = cloudth_ratqsmin*po(ind1)
     2298      ELSE
     2299         sigma1s_ratqs = ratqs(ind1,ind2)*po(ind1)
     2300      ENDIF
     2301      sigma1s = sigma1s_fraca + sigma1s_ratqs
     2302      sigma2s=(sigma2s_factor*(((sth-senv)**2)**0.5)/((fraca(ind1,ind2)+0.02)**sigma2s_power))+0.002*zqta(ind1,ind2)
     2303      IF (iflag_ratqs.eq.10.or.iflag_ratqs.eq.11) then
     2304         sigma1s = ratqs(ind1,ind2)*po(ind1)*aenv
     2305         IF (iflag_ratqs.eq.10.and.sigma_qtherm(ind1,ind2).ne.0) then
     2306            sigma2s = sigma_qtherm(ind1,ind2)*ath
     2307         ENDIF
     2308      ENDIF
     2309     
     2310!      tests
     2311!      sigma1s=(0.92**0.5)*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+ratqs(ind1,ind2)*po(ind1)
     2312!      sigma1s=(0.92*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5))+0.002*zqenv(ind1)
     2313!      sigma2s=0.09*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.02)**0.5+0.002*zqta(ind1,ind2)
     2314!      sigma2s=(0.09*(((sth-senv)**2)**0.5)/((fraca(ind1,ind2)+0.02)**0.5))+ratqs(ind1,ind2)*zqta(ind1,ind2)
     2315!       if (paprs(ind1,ind2).gt.90000) then
     2316!       ratqs(ind1,ind2)=0.002
     2317!       else
     2318!       ratqs(ind1,ind2)=0.002+0.0*(90000-paprs(ind1,ind2))/20000
     2319!       endif
     2320!       sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
     2321!       sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.01)**0.4+0.002*zqta(ind1,ind2)
     2322!       sigma1s=ratqs(ind1,ind2)*po(ind1)
     2323!      sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.02)**0.4+0.00003 
     2324 
     2325       IF (iflag_cloudth_vert == 1) THEN
     2326!-------------------------------------------------------------------------------
     2327!  Version 2: Modification from Arnaud Jam according to JL Dufrense. Condensate from qsat-ratqs
     2328!-------------------------------------------------------------------------------
     2329
     2330      deltasenv=aenv*ratqs(ind1,ind2)*zqsatenv(ind1,ind2)
     2331      deltasth=ath*ratqs(ind1,ind2)*zqsatth(ind1,ind2)
     2332
     2333      xenv1=(senv-deltasenv)/(sqrt(2.)*sigma1s)
     2334      xenv2=(senv+deltasenv)/(sqrt(2.)*sigma1s)
     2335      xth1=(sth-deltasth)/(sqrt(2.)*sigma2s)
     2336      xth2=(sth+deltasth)/(sqrt(2.)*sigma2s)
     2337      coeffqlenv=(sigma1s)**2/(2*sqrtpi*deltasenv)
     2338      coeffqlth=(sigma2s)**2/(2*sqrtpi*deltasth)
     2339     
     2340      cth(ind1,ind2)=0.5*(1.+1.*erf(xth2))
     2341      cenv(ind1,ind2)=0.5*(1.+1.*erf(xenv2))
     2342      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)   
     2343
     2344      ! Environment
     2345      IntJ=sigma1s*(exp(-1.*xenv1**2)/sqrt2pi)+0.5*senv*(1+erf(xenv1))
     2346      IntI1=coeffqlenv*0.5*(0.5*sqrtpi*(erf(xenv2)-erf(xenv1))+xenv1*exp(-1.*xenv1**2)-xenv2*exp(-1.*xenv2**2))
     2347      IntI2=coeffqlenv*xenv2*(exp(-1.*xenv2**2)-exp(-1.*xenv1**2))
     2348      IntI3=coeffqlenv*0.5*sqrtpi*xenv2**2*(erf(xenv2)-erf(xenv1))
     2349
     2350      qlenv(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     2351
     2352      ! Thermal
     2353      IntJ=sigma2s*(exp(-1.*xth1**2)/sqrt2pi)+0.5*sth*(1+erf(xth1))
     2354      IntI1=coeffqlth*0.5*(0.5*sqrtpi*(erf(xth2)-erf(xth1))+xth1*exp(-1.*xth1**2)-xth2*exp(-1.*xth2**2))
     2355      IntI2=coeffqlth*xth2*(exp(-1.*xth2**2)-exp(-1.*xth1**2))
     2356      IntI3=coeffqlth*0.5*sqrtpi*xth2**2*(erf(xth2)-erf(xth1))
     2357      qlth(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     2358      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     2359
     2360      ELSE IF (iflag_cloudth_vert >= 3) THEN
     2361      IF (iflag_cloudth_vert < 5) THEN
     2362!-------------------------------------------------------------------------------
     2363!  Version 3: Changes by J. Jouhaud; condensation for q > -delta s
     2364!-------------------------------------------------------------------------------
     2365!      deltasenv=aenv*ratqs(ind1,ind2)*po(ind1)
     2366!      deltasth=ath*ratqs(ind1,ind2)*zqta(ind1,ind2)
     2367!      deltasenv=aenv*ratqs(ind1,ind2)*zqsatenv(ind1,ind2)
     2368!      deltasth=ath*ratqs(ind1,ind2)*zqsatth(ind1,ind2)
     2369      IF (iflag_cloudth_vert == 3) THEN
     2370        deltasenv=aenv*vert_alpha*sigma1s
     2371        deltasth=ath*vert_alpha_th*sigma2s
     2372      ELSE IF (iflag_cloudth_vert == 4) THEN
     2373        IF (iflag_cloudth_vert_noratqs == 1) THEN
     2374          deltasenv=vert_alpha*max(sigma1s_fraca,1e-10)
     2375          deltasth=vert_alpha_th*sigma2s
     2376        ELSE
     2377          deltasenv=vert_alpha*sigma1s
     2378          deltasth=vert_alpha_th*sigma2s
     2379        ENDIF
     2380      ENDIF
     2381     
     2382      xenv1=-(senv+deltasenv)/(sqrt(2.)*sigma1s)
     2383      xenv2=-(senv-deltasenv)/(sqrt(2.)*sigma1s)
     2384      exp_xenv1 = exp(-1.*xenv1**2)
     2385      exp_xenv2 = exp(-1.*xenv2**2)
     2386      xth1=-(sth+deltasth)/(sqrt(2.)*sigma2s)
     2387      xth2=-(sth-deltasth)/(sqrt(2.)*sigma2s)
     2388      exp_xth1 = exp(-1.*xth1**2)
     2389      exp_xth2 = exp(-1.*xth2**2)
     2390     
     2391      !CF_surfacique
     2392      cth(ind1,ind2)=0.5*(1.-1.*erf(xth1))
     2393      cenv(ind1,ind2)=0.5*(1.-1.*erf(xenv1))
     2394      ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)
     2395
     2396
     2397      !CF_volumique & eau condense
     2398      !environnement
     2399      IntJ=0.5*senv*(1-erf(xenv2))+(sigma1s/sqrt2pi)*exp_xenv2
     2400      IntJ_CF=0.5*(1.-1.*erf(xenv2))
     2401      if (deltasenv .lt. 1.e-10) then
     2402      qlenv(ind1,ind2)=IntJ
     2403      cenv_vol(ind1,ind2)=IntJ_CF
     2404      else
     2405      IntI1=(((senv+deltasenv)**2+(sigma1s)**2)/(8*deltasenv))*(erf(xenv2)-erf(xenv1))
     2406      IntI2=(sigma1s**2/(4*deltasenv*sqrtpi))*(xenv1*exp_xenv1-xenv2*exp_xenv2)
     2407      IntI3=((sqrt2*sigma1s*(senv+deltasenv))/(4*sqrtpi*deltasenv))*(exp_xenv1-exp_xenv2)
     2408      IntI1_CF=((senv+deltasenv)*(erf(xenv2)-erf(xenv1)))/(4*deltasenv)
     2409      IntI3_CF=(sqrt2*sigma1s*(exp_xenv1-exp_xenv2))/(4*sqrtpi*deltasenv)
     2410      qlenv(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     2411      cenv_vol(ind1,ind2)=IntJ_CF+IntI1_CF+IntI3_CF
     2412      endif
     2413
     2414      !thermique
     2415      IntJ=0.5*sth*(1-erf(xth2))+(sigma2s/sqrt2pi)*exp_xth2
     2416      IntJ_CF=0.5*(1.-1.*erf(xth2))
     2417      if (deltasth .lt. 1.e-10) then
     2418      qlth(ind1,ind2)=IntJ
     2419      cth_vol(ind1,ind2)=IntJ_CF
     2420      else
     2421      IntI1=(((sth+deltasth)**2+(sigma2s)**2)/(8*deltasth))*(erf(xth2)-erf(xth1))
     2422      IntI2=(sigma2s**2/(4*deltasth*sqrtpi))*(xth1*exp_xth1-xth2*exp_xth2)
     2423      IntI3=((sqrt2*sigma2s*(sth+deltasth))/(4*sqrtpi*deltasth))*(exp_xth1-exp_xth2)
     2424      IntI1_CF=((sth+deltasth)*(erf(xth2)-erf(xth1)))/(4*deltasth)
     2425      IntI3_CF=(sqrt2*sigma2s*(exp_xth1-exp_xth2))/(4*sqrtpi*deltasth)
     2426      qlth(ind1,ind2)=IntJ+IntI1+IntI2+IntI3
     2427      cth_vol(ind1,ind2)=IntJ_CF+IntI1_CF+IntI3_CF
     2428      endif
     2429
     2430      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     2431      ctot_vol(ind1,ind2)=fraca(ind1,ind2)*cth_vol(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv_vol(ind1,ind2)
     2432
     2433      ELSE IF (iflag_cloudth_vert == 5) THEN
     2434         sigma1s=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5) &
     2435              /(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5) &
     2436              +ratqs(ind1,ind2)*po(ind1) !Environment
     2437      sigma2s=(0.03218+0.000092655*dz(ind1,ind2))/((fraca(ind1,ind2)+0.02)**0.5)*(((sth-senv)**2)**0.5)+0.002*zqta(ind1,ind2)                   !Thermals
     2438      !sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
     2439      !sigma2s=0.11*((sth-senv)**2)**0.5/(fraca(ind1,ind2)+0.01)**0.4+0.002*zqta(ind1,ind2)
     2440      xth=sth/(sqrt(2.)*sigma2s)
     2441      xenv=senv/(sqrt(2.)*sigma1s)
     2442
     2443      !Volumique
     2444      cth_vol(ind1,ind2)=0.5*(1.+1.*erf(xth))
     2445      cenv_vol(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     2446      ctot_vol(ind1,ind2)=fraca(ind1,ind2)*cth_vol(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv_vol(ind1,ind2)
     2447      !print *,'jeanjean_CV=',ctot_vol(ind1,ind2)
     2448
     2449      qlth(ind1,ind2)=sigma2s*((exp(-1.*xth**2)/sqrt2pi)+xth*sqrt(2.)*cth_vol(ind1,ind2))
     2450      qlenv(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt(2.)*cenv_vol(ind1,ind2)) 
     2451      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     2452
     2453      !Surfacique
     2454      !Neggers
     2455      !beta=0.0044
     2456      !inverse_rho=1.+beta*dz(ind1,ind2)
     2457      !print *,'jeanjean : beta=',beta
     2458      !cth(ind1,ind2)=cth_vol(ind1,ind2)*inverse_rho
     2459      !cenv(ind1,ind2)=cenv_vol(ind1,ind2)*inverse_rho
     2460      !ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)
     2461
     2462      !Brooks
     2463      a_Brooks=0.6694
     2464      b_Brooks=0.1882
     2465      A_Maj_Brooks=0.1635 !-- sans shear
     2466      !A_Maj_Brooks=0.17   !-- ARM LES
     2467      !A_Maj_Brooks=0.18   !-- RICO LES
     2468      !A_Maj_Brooks=0.19   !-- BOMEX LES
     2469      Dx_Brooks=200000.
     2470      f_Brooks=A_Maj_Brooks*(dz(ind1,ind2)**(a_Brooks))*(Dx_Brooks**(-b_Brooks))
     2471      !print *,'jeanjean_f=',f_Brooks
     2472
     2473      cth(ind1,ind2)=1./(1.+exp(-1.*f_Brooks)*((1./max(1.e-15,min(cth_vol(ind1,ind2),1.)))- 1.))
     2474      cenv(ind1,ind2)=1./(1.+exp(-1.*f_Brooks)*((1./max(1.e-15,min(cenv_vol(ind1,ind2),1.)))- 1.))
     2475      ctot(ind1,ind2)=1./(1.+exp(-1.*f_Brooks)*((1./max(1.e-15,min(ctot_vol(ind1,ind2),1.)))- 1.))
     2476      !print *,'JJ_ctot_1',ctot(ind1,ind2)
     2477
     2478
     2479
     2480
     2481
     2482      ENDIF ! of if (iflag_cloudth_vert<5)
     2483      ENDIF ! of if (iflag_cloudth_vert==1 or 3 or 4)
     2484
     2485!      if (ctot(ind1,ind2).lt.1.e-10) then
     2486      if (cenv(ind1,ind2).lt.1.e-10.or.cth(ind1,ind2).lt.1.e-10) then
     2487      ctot(ind1,ind2)=0.
     2488      ctot_vol(ind1,ind2)=0.
     2489      qcloud(ind1)=zqsatenv(ind1,ind2)
     2490
     2491      else
     2492               
     2493      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqs(ind1)
     2494!      qcloud(ind1)=fraca(ind1,ind2)*qlth(ind1,ind2)/cth(ind1,ind2) &
     2495!    &             +(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)/cenv(ind1,ind2)+zqs(ind1)
     2496
     2497      endif 
     2498
     2499      else  ! gaussienne environnement seule
     2500     
     2501
     2502      zqenv(ind1)=po(ind1)
     2503      Tbef=t(ind1,ind2)
     2504      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2505      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2506      qsatbef=MIN(0.5,qsatbef)
     2507      zcor=1./(1.-retv*qsatbef)
     2508      qsatbef=qsatbef*zcor
     2509      zqsatenv(ind1,ind2)=qsatbef
     2510     
     2511
     2512!      qlbef=Max(po(ind1)-zqsatenv(ind1,ind2),0.)
     2513      zthl(ind1,ind2)=t(ind1,ind2)*(101325/paprs(ind1,ind2))**(rdd/cppd)
     2514      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)
     2515      aenv=1./(1.+(alenv*Lv/cppd))
     2516      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     2517      sth=0.
     2518     
     2519
     2520      sigma1s=ratqs(ind1,ind2)*zqenv(ind1)
     2521      sigma2s=0.
     2522
     2523      sqrt2pi=sqrt(2.*pi)
     2524      xenv=senv/(sqrt(2.)*sigma1s)
     2525      ctot(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     2526      ctot_vol(ind1,ind2)=ctot(ind1,ind2)
     2527      qltot(ind1,ind2)=sigma1s*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt(2.)*cenv(ind1,ind2))
     2528     
     2529      if (ctot(ind1,ind2).lt.1.e-3) then
     2530      ctot(ind1,ind2)=0.
     2531      qcloud(ind1)=zqsatenv(ind1,ind2)
     2532
     2533      else   
     2534               
     2535!      ctot(ind1,ind2)=ctot(ind1,ind2)
     2536      qcloud(ind1)=qltot(ind1,ind2)/ctot(ind1,ind2)+zqsatenv(ind1,ind2)
     2537
     2538      endif 
     2539 
     2540
     2541
     2542
     2543      endif       ! From the separation (thermal/envrionnement) et (environnement) only, l.335 et l.492
     2544      ! Outputs used to check the PDFs
     2545      cloudth_senv(ind1,ind2) = senv
     2546      cloudth_sth(ind1,ind2) = sth
     2547      cloudth_sigmaenv(ind1,ind2) = sigma1s
     2548      cloudth_sigmath(ind1,ind2) = sigma2s
     2549
     2550      enddo       ! from the loop on ngrid l.333
     2551      return
     2552!     end
     2553END SUBROUTINE cloudth_vert_v3
     2554!
     2555
     2556
     2557
     2558
     2559
     2560
     2561
     2562
     2563
     2564
     2565
     2566       SUBROUTINE cloudth_v6(ngrid,klev,ind2,  &
     2567     &           ztv,po,zqta,fraca, &
     2568     &           qcloud,ctot_surf,ctot_vol,zpspsk,paprs,pplay,ztla,zthl, &
     2569     &           ratqs,zqs,T, &
     2570     &           cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv)
     2571
     2572      USE yoethf_mod_h
     2573      USE lmdz_lscp_ini, only: iflag_cloudth_vert
     2574
     2575      USE yomcst_mod_h
     2576IMPLICIT NONE
     2577
     2578
     2579
     2580      INCLUDE "FCTTRE.h"
     2581
     2582
     2583        !Domain variables
     2584      INTEGER ngrid !indice Max lat-lon
     2585      INTEGER klev  !indice Max alt
     2586      real, dimension(ngrid,klev), intent(out) :: cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
     2587      INTEGER ind1  !indice in [1:ngrid]
     2588      INTEGER ind2  !indice in [1:klev]
     2589        !thermal plume fraction
     2590      REAL fraca(ngrid,klev+1)   !thermal plumes fraction in the gridbox
     2591        !temperatures
     2592      REAL T(ngrid,klev)       !temperature
     2593      REAL zpspsk(ngrid,klev)  !factor (p/p0)**kappa (used for potential variables)
     2594      REAL ztv(ngrid,klev)     !potential temperature (voir thermcell_env.F90)
     2595      REAL ztla(ngrid,klev)    !liquid temperature in the thermals (Tl_th)
     2596      REAL zthl(ngrid,klev)    !liquid temperature in the environment (Tl_env)
     2597        !pressure
     2598      REAL paprs(ngrid,klev+1)   !pressure at the interface of levels
     2599      REAL pplay(ngrid,klev)     !pressure at the middle of the level
     2600        !humidity
     2601      REAL ratqs(ngrid,klev)   !width of the total water subgrid-scale distribution
     2602      REAL po(ngrid)           !total water (qt)
     2603      REAL zqenv(ngrid)        !total water in the environment (qt_env)
     2604      REAL zqta(ngrid,klev)    !total water in the thermals (qt_th)
     2605      REAL zqsatth(ngrid,klev)   !water saturation level in the thermals (q_sat_th)
     2606      REAL zqsatenv(ngrid,klev)  !water saturation level in the environment (q_sat_env)
     2607      REAL qlth(ngrid,klev)    !condensed water in the thermals
     2608      REAL qlenv(ngrid,klev)   !condensed water in the environment
     2609      REAL qltot(ngrid,klev)   !condensed water in the gridbox
     2610        !cloud fractions
     2611      REAL cth_vol(ngrid,klev)   !cloud fraction by volume in the thermals
     2612      REAL cenv_vol(ngrid,klev)  !cloud fraction by volume in the environment
     2613      REAL ctot_vol(ngrid,klev)  !cloud fraction by volume in the gridbox
     2614      REAL cth_surf(ngrid,klev)  !cloud fraction by surface in the thermals
     2615      REAL cenv_surf(ngrid,klev) !cloud fraction by surface in the environment 
     2616      REAL ctot_surf(ngrid,klev) !cloud fraction by surface in the gridbox
     2617        !PDF of saturation deficit variables
     2618      REAL rdd,cppd,Lv
     2619      REAL Tbef,zdelta,qsatbef,zcor
     2620      REAL alth,alenv,ath,aenv
     2621      REAL sth,senv              !saturation deficits in the thermals and environment
     2622      REAL sigma_env,sigma_th    !standard deviations of the biGaussian PDF
     2623        !cloud fraction variables
     2624      REAL xth,xenv
     2625      REAL inverse_rho,beta                                  !Neggers et al. (2011) method
     2626      REAL a_Brooks,b_Brooks,A_Maj_Brooks,Dx_Brooks,f_Brooks !Brooks et al. (2005) method
     2627        !Incloud total water variables
     2628      REAL zqs(ngrid)    !q_sat
     2629      REAL qcloud(ngrid) !eau totale dans le nuage
     2630        !Some arithmetic variables
     2631      REAL  pi,sqrt2,sqrt2pi
     2632        !Depth of the layer
     2633      REAL dz(ngrid,klev)    !epaisseur de la couche en metre
     2634      REAL rhodz(ngrid,klev)
     2635      REAL zrho(ngrid,klev)
     2636      DO ind1 = 1, ngrid
     2637        rhodz(ind1,ind2) = (paprs(ind1,ind2)-paprs(ind1,ind2+1))/rg ![kg/m2]
     2638        zrho(ind1,ind2) = pplay(ind1,ind2)/T(ind1,ind2)/rd          ![kg/m3]
     2639        dz(ind1,ind2) = rhodz(ind1,ind2)/zrho(ind1,ind2)            ![m]
     2640      END DO
     2641
     2642!------------------------------------------------------------------------------
     2643! Initialization
     2644!------------------------------------------------------------------------------
     2645      qlth(:,ind2)=0.
     2646      qlenv(:,ind2)=0. 
     2647      qltot(:,ind2)=0.
     2648      cth_vol(:,ind2)=0.
     2649      cenv_vol(:,ind2)=0.
     2650      ctot_vol(:,ind2)=0.
     2651      cth_surf(:,ind2)=0.
     2652      cenv_surf(:,ind2)=0.
     2653      ctot_surf(:,ind2)=0.
     2654      qcloud(:)=0.
     2655      rdd=287.04
     2656      cppd=1005.7
     2657      pi=3.14159
     2658      Lv=2.5e6
     2659      sqrt2=sqrt(2.)
     2660      sqrt2pi=sqrt(2.*pi)
     2661
     2662
     2663      DO ind1=1,ngrid
     2664!-------------------------------------------------------------------------------
     2665!Both thermal and environment in the gridbox
     2666!-------------------------------------------------------------------------------
     2667      IF ((ztv(ind1,1).gt.ztv(ind1,2)).and.(fraca(ind1,ind2).gt.1.e-10)) THEN
     2668        !--------------------------------------------
     2669        !calcul de qsat_env
     2670        !--------------------------------------------
     2671      Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
     2672      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2673      qsatbef= R2ES*FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2674      qsatbef=MIN(0.5,qsatbef)
     2675      zcor=1./(1.-retv*qsatbef)
     2676      qsatbef=qsatbef*zcor
     2677      zqsatenv(ind1,ind2)=qsatbef
     2678        !--------------------------------------------
     2679        !calcul de s_env
     2680        !--------------------------------------------
     2681      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)     !qsl, p84 these Arnaud Jam
     2682      aenv=1./(1.+(alenv*Lv/cppd))                                      !al, p84 these Arnaud Jam
     2683      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))                          !s, p84 these Arnaud Jam
     2684        !--------------------------------------------
     2685        !calcul de qsat_th
     2686        !--------------------------------------------
     2687      Tbef=ztla(ind1,ind2)*zpspsk(ind1,ind2)
     2688      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2689      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2690      qsatbef=MIN(0.5,qsatbef)
     2691      zcor=1./(1.-retv*qsatbef)
     2692      qsatbef=qsatbef*zcor
     2693      zqsatth(ind1,ind2)=qsatbef
     2694        !--------------------------------------------
     2695        !calcul de s_th 
     2696        !--------------------------------------------
     2697      alth=(0.622*Lv*zqsatth(ind1,ind2))/(rdd*ztla(ind1,ind2)**2)       !qsl, p84 these Arnaud Jam
     2698      ath=1./(1.+(alth*Lv/cppd))                                        !al, p84 these Arnaud Jam
     2699      sth=ath*(zqta(ind1,ind2)-zqsatth(ind1,ind2))                      !s, p84 these Arnaud Jam
     2700        !--------------------------------------------
     2701        !calcul standard deviations bi-Gaussian PDF
     2702        !--------------------------------------------
     2703      sigma_th=(0.03218+0.000092655*dz(ind1,ind2))/((fraca(ind1,ind2)+0.01)**0.5)*(((sth-senv)**2)**0.5)+0.002*zqta(ind1,ind2)
     2704      sigma_env=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5) &
     2705           /(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5) &
     2706           +ratqs(ind1,ind2)*po(ind1)
     2707      xth=sth/(sqrt2*sigma_th)
     2708      xenv=senv/(sqrt2*sigma_env)
     2709        !--------------------------------------------
     2710        !Cloud fraction by volume CF_vol
     2711        !--------------------------------------------
     2712      cth_vol(ind1,ind2)=0.5*(1.+1.*erf(xth))
     2713      cenv_vol(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     2714      ctot_vol(ind1,ind2)=fraca(ind1,ind2)*cth_vol(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv_vol(ind1,ind2)
     2715        !--------------------------------------------
     2716        !Condensed water qc
     2717        !--------------------------------------------
     2718      qlth(ind1,ind2)=sigma_th*((exp(-1.*xth**2)/sqrt2pi)+xth*sqrt2*cth_vol(ind1,ind2))
     2719      qlenv(ind1,ind2)=sigma_env*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt2*cenv_vol(ind1,ind2)) 
     2720      qltot(ind1,ind2)=fraca(ind1,ind2)*qlth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qlenv(ind1,ind2)
     2721        !--------------------------------------------
     2722        !Cloud fraction by surface CF_surf
     2723        !--------------------------------------------
     2724        !Method Neggers et al. (2011) : ok for cumulus clouds only
     2725      !beta=0.0044 (Jouhaud et al.2018)
     2726      !inverse_rho=1.+beta*dz(ind1,ind2)
     2727      !ctot_surf(ind1,ind2)=ctot_vol(ind1,ind2)*inverse_rho
     2728        !Method Brooks et al. (2005) : ok for all types of clouds
     2729      a_Brooks=0.6694
     2730      b_Brooks=0.1882
     2731      A_Maj_Brooks=0.1635 !-- sans dependence au cisaillement de vent
     2732      Dx_Brooks=200000.   !-- si l'on considere des mailles de 200km de cote
     2733      f_Brooks=A_Maj_Brooks*(dz(ind1,ind2)**(a_Brooks))*(Dx_Brooks**(-b_Brooks))
     2734      ctot_surf(ind1,ind2)=1./(1.+exp(-1.*f_Brooks)*((1./max(1.e-15,min(ctot_vol(ind1,ind2),1.)))- 1.))
     2735        !--------------------------------------------
     2736        !Incloud Condensed water qcloud
     2737        !--------------------------------------------
     2738      if (ctot_surf(ind1,ind2) .lt. 1.e-10) then
     2739      ctot_vol(ind1,ind2)=0.
     2740      ctot_surf(ind1,ind2)=0.
     2741      qcloud(ind1)=zqsatenv(ind1,ind2)
     2742      else
     2743      qcloud(ind1)=qltot(ind1,ind2)/ctot_vol(ind1,ind2)+zqs(ind1)
     2744      endif
     2745
     2746
     2747
     2748!-------------------------------------------------------------------------------
     2749!Environment only in the gridbox
     2750!-------------------------------------------------------------------------------
     2751      ELSE
     2752        !--------------------------------------------
     2753        !calcul de qsat_env
     2754        !--------------------------------------------
     2755      Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
     2756      zdelta=MAX(0.,SIGN(1.,RTT-Tbef))
     2757      qsatbef= R2ES * FOEEW(Tbef,zdelta)/paprs(ind1,ind2)
     2758      qsatbef=MIN(0.5,qsatbef)
     2759      zcor=1./(1.-retv*qsatbef)
     2760      qsatbef=qsatbef*zcor
     2761      zqsatenv(ind1,ind2)=qsatbef
     2762        !--------------------------------------------
     2763        !calcul de s_env
     2764        !--------------------------------------------
     2765      alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)     !qsl, p84 these Arnaud Jam
     2766      aenv=1./(1.+(alenv*Lv/cppd))                                      !al, p84 these Arnaud Jam
     2767      senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))                          !s, p84 these Arnaud Jam
     2768        !--------------------------------------------
     2769        !calcul standard deviations Gaussian PDF
     2770        !--------------------------------------------
     2771      zqenv(ind1)=po(ind1)
     2772      sigma_env=ratqs(ind1,ind2)*zqenv(ind1)
     2773      xenv=senv/(sqrt2*sigma_env)
     2774        !--------------------------------------------
     2775        !Cloud fraction by volume CF_vol
     2776        !--------------------------------------------
     2777      ctot_vol(ind1,ind2)=0.5*(1.+1.*erf(xenv))
     2778        !--------------------------------------------
     2779        !Condensed water qc
     2780        !--------------------------------------------
     2781      qltot(ind1,ind2)=sigma_env*((exp(-1.*xenv**2)/sqrt2pi)+xenv*sqrt2*ctot_vol(ind1,ind2))
     2782        !--------------------------------------------
     2783        !Cloud fraction by surface CF_surf
     2784        !--------------------------------------------
     2785        !Method Neggers et al. (2011) : ok for cumulus clouds only
     2786      !beta=0.0044 (Jouhaud et al.2018)
     2787      !inverse_rho=1.+beta*dz(ind1,ind2)
     2788      !ctot_surf(ind1,ind2)=ctot_vol(ind1,ind2)*inverse_rho
     2789        !Method Brooks et al. (2005) : ok for all types of clouds
     2790      a_Brooks=0.6694
     2791      b_Brooks=0.1882
     2792      A_Maj_Brooks=0.1635 !-- sans dependence au shear
     2793      Dx_Brooks=200000.
     2794      f_Brooks=A_Maj_Brooks*(dz(ind1,ind2)**(a_Brooks))*(Dx_Brooks**(-b_Brooks))
     2795      ctot_surf(ind1,ind2)=1./(1.+exp(-1.*f_Brooks)*((1./max(1.e-15,min(ctot_vol(ind1,ind2),1.)))- 1.))
     2796        !--------------------------------------------
     2797        !Incloud Condensed water qcloud
     2798        !--------------------------------------------
     2799      if (ctot_surf(ind1,ind2) .lt. 1.e-8) then
     2800      ctot_vol(ind1,ind2)=0.
     2801      ctot_surf(ind1,ind2)=0.
     2802      qcloud(ind1)=zqsatenv(ind1,ind2)
     2803      else
     2804      qcloud(ind1)=qltot(ind1,ind2)/ctot_vol(ind1,ind2)+zqsatenv(ind1,ind2)
     2805      endif
     2806
     2807
     2808      END IF  ! From the separation (thermal/envrionnement) et (environnement only)
     2809
     2810      ! Outputs used to check the PDFs
     2811      cloudth_senv(ind1,ind2) = senv
     2812      cloudth_sth(ind1,ind2) = sth
     2813      cloudth_sigmaenv(ind1,ind2) = sigma_env
     2814      cloudth_sigmath(ind1,ind2) = sigma_th
     2815
     2816      END DO  ! From the loop on ngrid
     2817      return
     2818
     2819END SUBROUTINE cloudth_v6
     2820
     2821
     2822
    10662823END MODULE lmdz_lscp_condensation
  • LMDZ6/trunk/libf/phylmd/lmdz_lscp_ini.f90

    r5437 r5614  
    99  !$OMP THREADPRIVATE(RCPD, RLSTT, RLVTT, RLMLT, RVTMP2, RTT, RD, RV, RG, RPI, EPS_W)
    1010 
    11   REAL, SAVE, PROTECTED :: seuil_neb=0.001      ! cloud fraction threshold: a cloud can precipitate when exceeded
     11  INTEGER, SAVE, PROTECTED :: iflag_ratqs        ! control of ratqs option
     12  !$OMP THREADPRIVATE(iflag_ratqs)
     13 
     14  REAL, SAVE, PROTECTED :: seuil_neb=0.001       ! cloud fraction threshold: a cloud can precipitate when exceeded
    1215  !$OMP THREADPRIVATE(seuil_neb)
    1316
     
    6770  !$OMP THREADPRIVATE(iflag_t_glace)
    6871
    69   INTEGER, SAVE, PROTECTED :: iflag_cloudth_vert=0          ! option for determining cloud fraction and content in convective boundary layers
    70   !$OMP THREADPRIVATE(iflag_cloudth_vert)
    71 
    7272  INTEGER, SAVE, PROTECTED :: iflag_gammasat=0              ! which threshold for homogeneous nucleation below -40oC
    7373  !$OMP THREADPRIVATE(iflag_gammasat)
     
    133133  !$OMP THREADPRIVATE(expo_sub)
    134134
    135   REAL, SAVE, PROTECTED :: cice_velo=1.645                  ! factor in the ice fall velocity formulation
     135  REAL, SAVE, PROTECTED :: cice_velo=1.645                  ! factor in the ice fall velocity formulation. It is half the value of
     136                                                            ! Heymsfield and Donner 1990 to concur with previous LMDZ versions
    136137  !$OMP THREADPRIVATE(cice_velo)
    137138
     
    205206  !--End of the parameters for condensation and ice supersaturation
    206207
    207   !--Parameters for poprecip
     208  !--Parameters for poprecip and cloud phase
    208209  LOGICAL, SAVE, PROTECTED :: ok_poprecip=.FALSE.           ! use the processes-oriented formulation of precipitations
    209210  !$OMP THREADPRIVATE(ok_poprecip)
     
    212213  !$OMP THREADPRIVATE(ok_corr_vap_evasub)
    213214
     215  LOGICAL, SAVE, PROTECTED :: ok_growth_precip_deposition=.FALSE. ! allows growth of snowfall through vapor deposition in supersat. regions
     216  !$OMP THREADPRIVATE(ok_growth_precip_deposition)
     217
    214218  REAL, SAVE, PROTECTED :: cld_lc_lsc_snow=2.e-5            ! snow autoconversion coefficient, stratiform. default from  Chaboureau and PInty 2006
    215219  !$OMP THREADPRIVATE(cld_lc_lsc_snow)
     
    233237  !$OMP THREADPRIVATE(gamma_snwretro)
    234238
     239  REAL, SAVE, PROTECTED :: gamma_mixth = 1.                 ! Tuning coeff for mixing with thermals/env in lscp_icefrac_turb [-]
     240  !$OMP THREADPRIVATE(gamma_mixth)
     241
    235242  REAL, SAVE, PROTECTED :: gamma_taud = 1.                  ! Tuning coeff for Lagrangian decorrelation timescale in lscp_icefrac_turb [-]
    236243  !$OMP THREADPRIVATE(gamma_taud)
     
    254261  !$OMP THREADPRIVATE(rho_rain)
    255262
    256   REAL, SAVE, PROTECTED :: rho_ice=920.                     ! Ice density [kg/m3]
     263  REAL, SAVE, PROTECTED :: rho_ice=920.                     ! Ice crystal density (assuming spherical geometry) [kg/m3]
    257264  !$OMP THREADPRIVATE(rho_ice)
    258265
     
    268275  REAL, SAVE, PROTECTED :: tau_auto_snow_max=1000.          ! Snow autoconversion minimal timescale (when only ice) [s]
    269276  !$OMP THREADPRIVATE(tau_auto_snow_max)
     277
     278  REAL, SAVE, PROTECTED :: expo_tau_auto_snow=0.1          ! Snow autoconversion timescale exponent for icefrac dependency
     279  !$OMP THREADPRIVATE(expo_tau_auto_snow)
    270280
    271281  REAL, SAVE, PROTECTED :: eps=1.E-10                       ! Treshold 0 [-]
     
    297307  !--End of the parameters for poprecip
    298308
    299 ! Two parameters used for lmdz_lscp_old only
     309  ! Parameters for cloudth routines
     310  LOGICAL, SAVE, PROTECTED :: ok_lscp_mergecond=.false.     ! more consistent condensation stratiform and shallow convective clouds
     311  !$OMP THREADPRIVATE(ok_lscp_mergecond)
     312 
     313  INTEGER, SAVE, PROTECTED :: iflag_cloudth_vert=0          ! option for determining cloud fraction and content in convective boundary layers
     314  !$OMP THREADPRIVATE(iflag_cloudth_vert)
     315
     316  INTEGER, SAVE, PROTECTED :: iflag_cloudth_vert_noratqs=0  ! option to control the width of gaussian distrib in a specific case
     317  !$OMP THREADPRIVATE(iflag_cloudth_vert_noratqs)
     318
     319  REAL, SAVE, PROTECTED :: cloudth_ratqsmin=-1.             ! minimum ratqs in cloudth
     320  !$OMP THREADPRIVATE(cloudth_ratqsmin)
     321
     322  REAL, SAVE, PROTECTED :: sigma1s_factor=1.1               ! factor for standard deviation of gaussian distribution of environment
     323  !$OMP THREADPRIVATE(sigma1s_factor)
     324
     325  REAL, SAVE, PROTECTED :: sigma2s_factor=0.09              ! factor for standard deviation of gaussian distribution of thermals
     326  !$OMP THREADPRIVATE(sigma2s_factor)
     327
     328
     329  REAL, SAVE, PROTECTED :: sigma1s_power=0.6                ! exponent for standard deviation of gaussian distribution of environment
     330  !$OMP THREADPRIVATE(sigma1s_power)
     331   
     332  REAL, SAVE, PROTECTED :: sigma2s_power=0.5                ! exponent for standard deviation of gaussian distribution of thermals
     333  !$OMP THREADPRIVATE(sigma2s_power)
     334
     335  REAL, SAVE, PROTECTED :: vert_alpha=0.5                   ! tuning coefficient for standard deviation of gaussian distribution of thermals
     336  !$OMP THREADPRIVATE(vert_alpha)
     337
     338  REAL, SAVE, PROTECTED :: vert_alpha_th=0.5                ! tuning coefficient for standard deviation of gaussian distribution of thermals
     339  !$OMP THREADPRIVATE(vert_alpha_th)
     340  ! End of parameters for cloudth routines
     341
     342  ! Two parameters used for lmdz_lscp_old only
    300343  INTEGER, SAVE, PROTECTED :: iflag_oldbug_fisrtilp=0, fl_cor_ebil
    301344  !$OMP THREADPRIVATE(iflag_oldbug_fisrtilp,fl_cor_ebil)
     
    303346CONTAINS
    304347
    305 SUBROUTINE lscp_ini(dtime,lunout_in,prt_level_in,ok_ice_supersat_in, iflag_ratqs, fl_cor_ebil_in, &
     348SUBROUTINE lscp_ini(dtime,lunout_in,prt_level_in,ok_ice_supersat_in, iflag_ratqs_in, fl_cor_ebil_in, &
    306349                    RCPD_in, RLSTT_in, RLVTT_in, RLMLT_in, RVTMP2_in, &
    307350                    RTT_in, RD_in, RV_in, RG_in, RPI_in, EPS_W_in)
     
    309352
    310353   USE ioipsl_getin_p_mod, ONLY : getin_p
    311    USE lmdz_cloudth_ini, ONLY : cloudth_ini
    312354
    313355   REAL, INTENT(IN)      :: dtime
    314    INTEGER, INTENT(IN)   :: lunout_in,prt_level_in,iflag_ratqs,fl_cor_ebil_in
     356   INTEGER, INTENT(IN)   :: lunout_in,prt_level_in,iflag_ratqs_in,fl_cor_ebil_in
    315357   LOGICAL, INTENT(IN)   :: ok_ice_supersat_in
    316358
     
    324366    prt_level=prt_level_in
    325367    fl_cor_ebil=fl_cor_ebil_in
    326 
     368    iflag_ratqs=iflag_ratqs_in
    327369    ok_ice_supersat=ok_ice_supersat_in
    328370
     
    351393    CALL getin_p('iflag_vice',iflag_vice)
    352394    CALL getin_p('iflag_t_glace',iflag_t_glace)
    353     CALL getin_p('iflag_cloudth_vert',iflag_cloudth_vert)
    354395    CALL getin_p('iflag_gammasat',iflag_gammasat)
    355396    CALL getin_p('iflag_rain_incloud_vol',iflag_rain_incloud_vol)
     
    369410    CALL getin_p('ffallv_lsc',ffallv_lsc)
    370411    CALL getin_p('ffallv_lsc',ffallv_con)
     412    ! for poprecip and cloud phase
    371413    CALL getin_p('coef_eva',coef_eva)
    372414    coef_sub=coef_eva
     
    383425    CALL getin_p('gamma_snwretro',gamma_snwretro)
    384426    CALL getin_p('gamma_taud',gamma_taud)
     427    CALL getin_p('gamma_mixth',gamma_mixth)
    385428    CALL getin_p('iflag_oldbug_fisrtilp',iflag_oldbug_fisrtilp)
    386429    CALL getin_p('temp_nowater',temp_nowater)
    387430    CALL getin_p('ok_bug_phase_lscp',ok_bug_phase_lscp)
    388     ! for poprecip
    389431    CALL getin_p('ok_poprecip',ok_poprecip)
    390432    CALL getin_p('ok_corr_vap_evasub',ok_corr_vap_evasub)
     433    CALL getin_p('ok_growth_precip_deposition',ok_growth_precip_deposition)
    391434    CALL getin_p('rain_int_min',rain_int_min)
    392435    CALL getin_p('gamma_agg',gamma_agg)
     
    397440    CALL getin_p('tau_auto_snow_max',tau_auto_snow_max)
    398441    CALL getin_p('tau_auto_snow_min',tau_auto_snow_min)
     442    CALL getin_p('expo_tau_auto_snow', expo_tau_auto_snow)
     443    CALL getin_p('alpha_freez',alpha_freez)
     444    CALL getin_p('beta_freez',beta_freez)
    399445    CALL getin_p('r_snow',r_snow)
    400446    CALL getin_p('rain_fallspeed',rain_fallspeed)
     
    427473    CALL getin_p('coef_shear_lscp',coef_shear_lscp)
    428474    CALL getin_p('chi_mixing_lscp',chi_mixing_lscp)
    429 
    430 
     475    ! for cloudth routines
     476    CALL getin_p('ok_lscp_mergecond',ok_lscp_mergecond)
     477    CALL getin_p('iflag_cloudth_vert',iflag_cloudth_vert)
     478    CALL getin_p('cloudth_ratqsmin',cloudth_ratqsmin)
     479    CALL getin_p('cloudth_sigma1s_factor',sigma1s_factor)
     480    CALL getin_p('cloudth_sigma1s_power',sigma1s_power)
     481    CALL getin_p('cloudth_sigma2s_factor',sigma2s_factor)
     482    CALL getin_p('cloudth_sigma2s_power',sigma2s_power)
     483    CALL getin_p('cloudth_vert_alpha',vert_alpha)
     484    vert_alpha_th=vert_alpha
     485    CALL getin_p('cloudth_vert_alpha_th',vert_alpha_th)
     486    CALL getin_p('iflag_cloudth_vert_noratqs',iflag_cloudth_vert_noratqs)
    431487
    432488    WRITE(lunout,*) 'lscp_ini, niter_lscp:', niter_lscp
     
    439495    WRITE(lunout,*) 'lscp_ini, iflag_vice:', iflag_vice
    440496    WRITE(lunout,*) 'lscp_ini, iflag_t_glace:', iflag_t_glace
    441     WRITE(lunout,*) 'lscp_ini, iflag_cloudth_vert:', iflag_cloudth_vert
    442497    WRITE(lunout,*) 'lscp_ini, iflag_gammasat:', iflag_gammasat
    443498    WRITE(lunout,*) 'lscp_ini, iflag_rain_incloud_vol:', iflag_rain_incloud_vol
     
    467522    WRITE(lunout,*) 'lscp_ini, naero5', naero5
    468523    WRITE(lunout,*) 'lscp_ini, gamma_snwretro', gamma_snwretro
     524    WRITE(lunout,*) 'lscp_ini, gamma_mixth', gamma_mixth
    469525    WRITE(lunout,*) 'lscp_ini, gamma_taud', gamma_taud
    470526    WRITE(lunout,*) 'lscp_ini, iflag_oldbug_fisrtilp', iflag_oldbug_fisrtilp
     
    475531    WRITE(lunout,*) 'lscp_ini, ok_poprecip', ok_poprecip
    476532    WRITE(lunout,*) 'lscp_ini, ok_corr_vap_evasub', ok_corr_vap_evasub
     533    WRITE(lunout,*) 'lscp_ini, ok_growth_precip_deposition', ok_growth_precip_deposition
    477534    WRITE(lunout,*) 'lscp_ini, rain_int_min:', rain_int_min
    478535    WRITE(lunout,*) 'lscp_ini, gamma_agg:', gamma_agg
     
    483540    WRITE(lunout,*) 'lscp_ini, tau_auto_snow_max:',tau_auto_snow_max
    484541    WRITE(lunout,*) 'lscp_ini, tau_auto_snow_min:',tau_auto_snow_min
     542    WRITE(lunout,*) 'lscp_ini, expo_tau_auto_snow:',expo_tau_auto_snow
    485543    WRITE(lunout,*) 'lscp_ini, r_snow:', r_snow
     544    WRITE(lunout,*) 'lscp_ini, alpha_freez:', alpha_freez
     545    WRITE(lunout,*) 'lscp_ini, beta_freez:', beta_freez
    486546    WRITE(lunout,*) 'lscp_ini, rain_fallspeed_clr:', rain_fallspeed_clr
    487547    WRITE(lunout,*) 'lscp_ini, rain_fallspeed_cld:', rain_fallspeed_cld
     
    508568    WRITE(lunout,*) 'lscp_ini, coef_shear_lscp:', coef_shear_lscp
    509569    WRITE(lunout,*) 'lscp_ini, chi_mixing_lscp:', chi_mixing_lscp
    510 
    511 
    512 
    513 
     570    ! for cloudth routines
     571    WRITE(lunout,*) 'lscp_ini, ok_lscp_mergecond:', ok_lscp_mergecond
     572    WRITE(lunout,*) 'lscp_ini, iflag_cloudth_vert:', iflag_cloudth_vert
     573    WRITE(lunout,*) 'lscp_ini, cloudth_ratqsmin:', cloudth_ratqsmin
     574    WRITE(lunout,*) 'lscp_ini, cloudth_sigma1s_factor:', sigma1s_factor
     575    WRITE(lunout,*) 'lscp_ini, cloudth_sigma1s_power:', sigma1s_power
     576    WRITE(lunout,*) 'lscp_ini, cloudth_sigma2s_factor:', sigma2s_factor
     577    WRITE(lunout,*) 'lscp_ini, cloudth_sigma2s_power:', sigma2s_power
     578    WRITE(lunout,*) 'lscp_ini, cloudth_vert_alpha:', vert_alpha
     579    WRITE(lunout,*) 'lscp_ini, cloudth_vert_alpha_th:', vert_alpha_th
     580    WRITE(lunout,*) 'lscp_ini, iflag_cloudth_vert_noratqs:', iflag_cloudth_vert_noratqs
     581
     582
     583    ! check consistency for cloud phase partitioning options
     584
     585    IF ((iflag_icefrac .GE. 2) .AND. (.NOT. ok_lscp_mergecond)) THEN
     586      abort_message = 'in lscp, iflag_icefrac .GE. 2 works only if ok_lscp_mergecond=.TRUE.'
     587      CALL abort_physic (modname,abort_message,1)
     588    ENDIF
    514589
    515590    ! check for precipitation sub-time steps
     
    522597    ! and other options
    523598   
    524     IF (iflag_autoconversion .EQ. 2) THEN
     599    IF ((iflag_autoconversion .EQ. 2) .AND. .NOT. ok_poprecip) THEN
    525600        IF ((iflag_vice .NE. 0) .OR. (niter_lscp .GT. 1)) THEN
    526601           abort_message = 'in lscp, iflag_autoconversion=2 requires iflag_vice=0 and niter_lscp=1'
     
    539614      CALL abort_physic (modname,abort_message,1)
    540615    ENDIF
     616
     617    IF ( (iflag_icefrac .GE. 1) .AND. (.NOT. ok_poprecip .AND. (iflag_evap_prec .LT. 4)) ) THEN
     618      abort_message = 'in lscp, icefracturb works with poprecip or with precip evap option >=4'
     619      CALL abort_physic (modname,abort_message,1)
     620    ENDIF
     621
    541622
    542623
     
    547628    a_tr_sca(4) = -0.5
    548629   
    549     CALL cloudth_ini(iflag_cloudth_vert,iflag_ratqs)
    550630
    551631RETURN
  • LMDZ6/trunk/libf/phylmd/lmdz_lscp_old.f90

    r5480 r5614  
    7070  USE yomcst_mod_h
    7171  USE icefrac_lsc_mod ! compute ice fraction (JBM 3/14)
    72   USE lmdz_cloudth, only : cloudth, cloudth_v3, cloudth_v6
     72  USE lmdz_lscp_condensation, only : cloudth, cloudth_v3, cloudth_v6
    7373
    7474  USE lmdz_lscp_ini, ONLY: prt_level, lunout
  • LMDZ6/trunk/libf/phylmd/lmdz_lscp_precip.f90

    r5430 r5614  
    330330LOGICAL, INTENT(IN)                     :: iftop          !--if top of the column
    331331
     332
    332333REAL,    INTENT(IN),    DIMENSION(klon) :: paprsdn        !--pressure at the bottom interface of the layer [Pa]
    333334REAL,    INTENT(IN),    DIMENSION(klon) :: paprsup        !--pressure at the top interface of the layer [Pa]
     
    540541          IF (zoliqi(i) .GT. 0.) THEN
    541542            zfroi=(zoliqi(i)-((zoliqi(i)**(-dice_velo)) &
    542               +dice_velo*dtime/REAL(niter_lscp)*cice_velo/zdz(i)*ffallv)**(-1./dice_velo))
     543              +dice_velo*dtime/REAL(niter_lscp)*cice_velo/zdz(i)/zneb(i)*zrho(i)*ffallv)**(-1./dice_velo))
    543544          ELSE
    544545            zfroi=0.
     
    618619    ! Computation of DT if all the liquid precip freezes
    619620    DeltaT = RLMLT*zqprecl(i) / (zcp*(1.+coef1))
     621   
     622
    620623    ! T should not exceed the freezing point
    621624    ! that is Delta > RTT-zt(i)
     
    722725USE lmdz_lscp_ini, ONLY : RCPD, RLSTT, RLVTT, RLMLT, RVTMP2, RTT, RD, RG
    723726USE lmdz_lscp_ini, ONLY : ok_corr_vap_evasub, ok_ice_supersat, ok_unadjusted_clouds
    724 USE lmdz_lscp_ini, ONLY : eps, temp_nowater
     727USE lmdz_lscp_ini, ONLY : eps, temp_nowater, ok_growth_precip_deposition
    725728USE lmdz_lscp_tools, ONLY : calc_qsat_ecmwf
    726729
     
    792795dqreva(:) = 0.
    793796dqssub(:) = 0.
    794 dqrevap   = 0.
    795 dqssubl   = 0.
    796797
    797798!-- dhum_to_dflux = rho * dz/dt = 1 / g * dP/dt
     
    880881DO i = 1, klon
    881882
     883  dqrevap   = 0.
     884  dqssubl   = 0.
    882885  !--If there is precipitation from the layer above
    883886  IF ( ( rain(i) + snow(i) ) .GT. 0. ) THEN
     
    913916      IF ( ( 1. - precipfraccld(i) ) .GT. eps ) THEN
    914917        qvapclr = qvapclrup(i) / qtotupnew(i) * qvap(i) / ( 1. - precipfraccld(i) )
     918      ELSE
     919        qvapclr = 0.
     920      ENDIF
     921      IF (  precipfraccld(i)  .GT. eps ) THEN
     922        qvapcld = MAX(qtotupnew(i)-qvapclrup(i) , 0.) / qtotupnew(i) * qvap(i) /  precipfraccld(i)
     923      ELSE
     924        qvapcld = 0.
    915925      ENDIF
    916926    ELSE
     
    918928      !--for the evap / subl process
    919929      qvapclr = qvap(i)
     930      qvapcld = qvap(i)
    920931    ENDIF
    921932
     
    940951      !--NB. with ok_ice_supersat activated, this barrier should be useless
    941952      drainclreva = MIN(0., drainclreva)
    942 
     953     
     954      ! we set it to 0 as not sufficiently tested
     955      drainclreva = 0.
    943956
    944957      !--Sublimation of the solid precipitation coming from above
     
    986999      ENDIF
    9871000
     1001    ELSE
     1002           
     1003    !--All the precipitation is sublimated if the fraction is zero
     1004       drainclreva = - rainclr_tmp(i)
     1005       dsnowclrsub = - snowclr_tmp(i)
     1006
    9881007    ENDIF ! precipfracclr_tmp .GT. eps
    9891008
     
    9931012    !---------------------------
    9941013
    995     IF ( ok_unadjusted_clouds .AND. ( temp(i) .LE. temp_nowater ) .AND. ( precipfraccld_tmp(i) .GT. eps ) ) THEN
     1014    IF ( ok_growth_precip_deposition .AND. ( temp(i) .LE. RTT ) .AND. ( precipfraccld_tmp(i) .GT. eps ) ) THEN
    9961015      !--Evaporation of liquid precipitation coming from above
    9971016      !--in the cloud only
     
    10001019      !--Exact explicit formulation (raincld is resolved exactly, qvap explicitly)
    10011020      !--which does not need a barrier on raincld, because included in the formula
    1002       !draincldeva = precipfraccld_tmp(i) * MAX(0., &
    1003       !            - coef_eva * ( 1. - expo_eva ) * (1. - qvapcld / qsatl(i)) * dz(i) &
    1004       !            + ( raincld_tmp(i) / precipfraccld_tmp(i) )**( 1. - expo_eva ) &
    1005       !            )**( 1. / ( 1. - expo_eva ) ) - raincld_tmp(i)
    1006                
     1021     
     1022      draincldeva = precipfraccld_tmp(i) * MAX(0., &
     1023                  - coef_eva * ( 1. - expo_eva ) * (1. - qvapcld / qsatl(i)) * dz(i) &
     1024                  + ( raincld_tmp(i) / precipfraccld_tmp(i) )**( 1. - expo_eva ) &
     1025                  )**( 1. / ( 1. - expo_eva ) ) - raincld_tmp(i)
     1026
    10071027      !--Evaporation is limited by 0
    10081028      !--NB. with ok_ice_supersat activated, this barrier should be useless
    1009       !draincldeva = MIN(0., draincldeva)
    1010       draincldeva = 0.
     1029      draincldeva = MIN(0., draincldeva)
    10111030
    10121031
     
    12771296
    12781297USE lmdz_lscp_ini, ONLY : cld_lc_con, cld_tau_con, cld_expo_con, seuil_neb,    &
    1279                           cld_lc_lsc, cld_tau_lsc, cld_expo_lsc, rain_int_min, &
     1298                          cld_lc_lsc, cld_tau_lsc, cld_expo_lsc,               &
    12801299                          thresh_precip_frac, gamma_col, gamma_agg, gamma_rim, &
    12811300                          rho_rain, r_rain, r_snow, rho_ice,                   &
     1301                          expo_tau_auto_snow,                                  &
    12821302                          tau_auto_snow_min, tau_auto_snow_max,                &
    1283                           thresh_precip_frac, eps,                             &
     1303                          thresh_precip_frac, eps, rain_int_min,               &
    12841304                          gamma_melt, alpha_freez, beta_freez, temp_nowater,   &
    12851305                          iflag_cloudth_vert, iflag_rain_incloud_vol,          &
     
    13401360REAL, DIMENSION(klon) :: dhum_to_dflux
    13411361REAL, DIMENSION(klon) :: qtot                             !--includes vap, liq, ice and precip
     1362REAL                  :: min_precip                       !--minimum precip flux below which precip fraction decreases
    13421363
    13431364!--Collection, aggregation and riming
     
    15021523        !--tau for snow depends on the ice fraction in mixed-phase clouds     
    15031524        tau_auto_snow = tau_auto_snow_max &
    1504                       + ( tau_auto_snow_min - tau_auto_snow_max ) * ( 1. - icefrac(i) )
     1525                      + ( tau_auto_snow_min - tau_auto_snow_max ) * ((1. - icefrac(i))**expo_tau_auto_snow)
    15051526
    15061527        expo_auto_rain = cld_expo_con
     
    15131534        !--tau for snow depends on the ice fraction in mixed-phase clouds     
    15141535        tau_auto_snow = tau_auto_snow_max &
    1515                       + ( tau_auto_snow_min - tau_auto_snow_max ) * ( 1. - icefrac(i) )
     1536                      + ( tau_auto_snow_min - tau_auto_snow_max ) * ((1. - icefrac(i))**expo_tau_auto_snow)
    15161537
    15171538        expo_auto_rain = cld_expo_lsc
     
    15341555               - ( qice(i) / eff_cldfra / qthresh_auto_snow ) ** expo_auto_snow ) ) ) )
    15351556
    1536 
    15371557    !--Barriers so that we don't create more rain/snow
    15381558    !--than there is liquid/ice
     
    15431563    qliq(i) = qliq(i) + dqlauto
    15441564    qice(i) = qice(i) + dqiauto
     1565
    15451566    raincld(i) = raincld(i) - dqlauto * dhum_to_dflux(i)
    15461567    snowcld(i) = snowcld(i) - dqiauto * dhum_to_dflux(i)
     
    17101731  !--second: immersion freezing following (inspired by Bigg 1953)
    17111732  !--the latter is parameterized as an exponential decrease of the rain
    1712   !--water content with a homemade formulya
     1733  !--water content with a homemade formula
    17131734  !--This is based on a caracteritic time of freezing, which
    17141735  !--exponentially depends on temperature so that it is
     
    17171738  !--NB.: this process needs a temperature adjustment
    17181739  !--dqrfreez_max : maximum rain freezing so that temperature
    1719   !--              stays lower than 273 K [kg/kg]
     1740  !--               stays lower than 273 K [kg/kg]
    17201741  !--tau_freez    : caracteristic time of freezing [s]
    17211742  !--gamma_freez  : tuning parameter [s-1]
     
    17981819              * EXP( - alpha_freez * ( temp(i) - temp_nowater ) / ( RTT - temp_nowater ) ) )
    17991820
    1800 
    18011821    !--In clear air
    18021822    IF ( rainclr(i) .GT. 0. ) THEN
     
    18271847    !--Add tendencies
    18281848    !--The MAX is needed because in some cases, the flux can be slightly negative (numerical precision)
     1849   
    18291850    rainclr(i) = MAX(0., rainclr(i) + dqrclrfreez * dhum_to_dflux(i))
    18301851    raincld(i) = MAX(0., raincld(i) + dqrcldfreez * dhum_to_dflux(i))
     
    18331854
    18341855
     1856
    18351857    !--Temperature adjustment with the uptake of latent
    18361858    !--heat because of freezing
     1859
    18371860    temp(i) = temp(i) - dqrtotfreez_step2 * RLMLT / RCPD &
    18381861                      / ( 1. + RVTMP2 * qtot(i) )
    1839 
    18401862    !--Diagnostic tendencies
    18411863    dqrtotfreez = dqrtotfreez_step1 + dqrtotfreez_step2         
     
    18471869
    18481870
    1849   !--If the local flux of rain+snow in clear/cloudy air is lower than rain_int_min,
    1850   !--we reduce the precipiration fraction in the clear/cloudy air so that the new
    1851   !--local flux of rain+snow is equal to rain_int_min.
     1871  !--If the local flux of rain+snow in clear air is lower than min_precip,
     1872  !--we reduce the precipiration fraction in the clear air so that the new
     1873  !--local flux of rain+snow is equal to min_precip.
     1874  !--we apply the minimum only on the clear-sky fraction because the cloudy precip fraction
     1875  !--already decreases out of clouds
    18521876  !--Here, rain+snow is the gridbox-mean flux of precip.
    18531877  !--Therefore, (rain+snow)/precipfrac is the local flux of precip.
    1854   !--If the local flux of precip is lower than rain_int_min, i.e.,
    1855   !-- (rain+snow)/precipfrac < rain_int_min , i.e.,
    1856   !-- (rain+snow)/rain_int_min < precipfrac , then we want to reduce
    1857   !--the precip fraction to the equality, i.e., precipfrac = (rain+snow)/rain_int_min.
     1878  !--If the local flux of precip is lower than min_precip, i.e.,
     1879  !-- (rain+snow)/precipfrac < min_precip , i.e.,
     1880  !-- (rain+snow)/min_precip < precipfrac , then we want to reduce
     1881  !--the precip fraction to the equality, i.e., precipfrac = (rain+snow)/min_precip.
    18581882  !--Note that this is physically different than what is proposed in LTP thesis.
    1859   precipfracclr(i) = MIN( precipfracclr(i), ( rainclr(i) + snowclr(i) ) / rain_int_min )
    1860   precipfraccld(i) = MIN( precipfraccld(i), ( raincld(i) + snowcld(i) ) / rain_int_min )
     1883  !--min_precip is either equal to rain_int_min or calculated as a very small fraction
     1884  !--of the minimum precip flux estimated as the flux associated with the
     1885  !--autoconversion threshold mass content
     1886  !min_precip=1.e-6*(pplay(i)/RD/temp(i))*MIN(rain_fallspeed_clr*cld_lc_lsc,snow_fallspeed_clr*cld_lc_lsc_snow)
     1887  min_precip=rain_int_min
     1888  precipfracclr(i) = MIN( precipfracclr(i), ( rainclr(i) + snowclr(i) ) / min_precip )
    18611889
    18621890  !--Calculate outputs
  • LMDZ6/trunk/libf/phylmd/lmdz_lscp_tools.f90

    r5383 r5614  
    225225        ENDIF
    226226
    227         ! if temperature of cloud top <-40°C,
     227        ! if temperature or temperature of cloud top <-40°C,
    228228        IF (iflag_t_glace .GE. 4) THEN
    229229                IF ((temp_cltop(i) .LE. temp_nowater) .AND. (temp(i) .LE. t_glace_max)) THEN
     
    241241
    242242
    243 SUBROUTINE ICEFRAC_LSCP_TURB(klon, dtime, temp, pplay, paprsdn, paprsup, omega, qice_ini, snowcld, qtot_incl, cldfra, tke,   &
    244                              tke_dissip, qliq, qvap_cld, qice, icefrac, dicefracdT, cldfraliq, sigma2_icefracturb, mean_icefracturb)
     243SUBROUTINE ICEFRAC_LSCP_TURB(klon, dtime, pticefracturb, temp, pplay, paprsdn, paprsup, wvel, qice_ini, snowcld, qtot_incl, cldfra, tke,   &
     244                             tke_dissip, sursat_e, invtau_e, qliq, qvap_cld, qice, icefrac, dicefracdT, cldfraliq, sigma2_icefracturb, mean_icefracturb)
    245245!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    246246  ! Compute the liquid, ice and vapour content (+ice fraction) based
    247247  ! on turbulence (see Fields 2014, Furtado 2016, Raillard 2025)
    248248  ! L.Raillard (23/09/24)
     249  ! E.Vignon (03/2025) : additional elements for treatment of convective
     250  !                      boundary layer clouds
    249251!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    250252
     
    253255   USE lmdz_lscp_ini, ONLY : RCPD, RLSTT, RLVTT, RLMLT, RVTMP2, RTT, RD, RG, RV, RPI
    254256   USE lmdz_lscp_ini, ONLY : seuil_neb, temp_nowater
    255    USE lmdz_lscp_ini, ONLY : naero5, gamma_snwretro, gamma_taud, capa_crystal
     257   USE lmdz_lscp_ini, ONLY : naero5, gamma_snwretro, gamma_taud, capa_crystal, rho_ice
    256258   USE lmdz_lscp_ini, ONLY : eps
    257259
     
    260262   INTEGER,   INTENT(IN)                           :: klon                !--number of horizontal grid points
    261263   REAL,      INTENT(IN)                           :: dtime               !--time step [s]
    262 
     264   LOGICAL,   INTENT(IN),       DIMENSION(klon)    :: pticefracturb       !--grid points concerned by this routine 
    263265   REAL,      INTENT(IN),       DIMENSION(klon)    :: temp                !--temperature
    264266   REAL,      INTENT(IN),       DIMENSION(klon)    :: pplay               !--pressure in the middle of the layer           [Pa]
    265267   REAL,      INTENT(IN),       DIMENSION(klon)    :: paprsdn             !--pressure at the bottom interface of the layer [Pa]
    266268   REAL,      INTENT(IN),       DIMENSION(klon)    :: paprsup             !--pressure at the top interface of the layer    [Pa]
    267    REAL,      INTENT(IN),       DIMENSION(klon)    :: omega               !--resolved vertical velocity                    [Pa/s]
     269   REAL,      INTENT(IN),       DIMENSION(klon)    :: wvel                !--vertical velocity                             [m/s]
    268270   REAL,      INTENT(IN),       DIMENSION(klon)    :: qtot_incl           !--specific total cloud water in-cloud content   [kg/kg]
    269271   REAL,      INTENT(IN),       DIMENSION(klon)    :: cldfra              !--cloud fraction in gridbox                     [-]
     
    272274
    273275   REAL,      INTENT(IN),       DIMENSION(klon)    :: qice_ini            !--initial specific ice content gridbox-mean     [kg/kg]
    274    REAL,      INTENT(IN),       DIMENSION(klon)    :: snowcld
     276   REAL,      INTENT(IN),       DIMENSION(klon)    :: snowcld             !--in-cloud snowfall flux                        [kg/m2/s]
     277   REAL,      INTENT(IN),       DIMENSION(klon)    :: sursat_e            !--environment supersaturation                   [-]
     278   REAL,      INTENT(IN),       DIMENSION(klon)    :: invtau_e            !--inverse time-scale of mixing with environment [s-1]
    275279   REAL,      INTENT(OUT),      DIMENSION(klon)    :: qliq                !--specific liquid content gridbox-mean          [kg/kg]
    276280   REAL,      INTENT(OUT),      DIMENSION(klon)    :: qvap_cld            !--specific cloud vapor content, gridbox-mean    [kg/kg]
    277281   REAL,      INTENT(OUT),      DIMENSION(klon)    :: qice                !--specific ice content gridbox-mean             [kg/kg]
    278    REAL,      INTENT(OUT),      DIMENSION(klon)    :: icefrac             !--fraction of ice in condensed water            [-]
    279    REAL,      INTENT(OUT),      DIMENSION(klon)    :: dicefracdT
     282
     283   REAL,      INTENT(INOUT),    DIMENSION(klon)    :: icefrac             !--fraction of ice in condensed water            [-]
     284   REAL,      INTENT(INOUT),    DIMENSION(klon)    :: dicefracdT
    280285
    281286   REAL,      INTENT(OUT),      DIMENSION(klon)    :: cldfraliq           !--fraction of cldfra where liquid               [-]
     
    291296   REAL :: C0                                                             !--Lagrangian structure function                 [-]
    292297   REAL :: tau_dissipturb
    293    REAL :: tau_phaserelax
    294    REAL :: sigma2_pdf, mean_pdf
     298   REAL :: invtau_phaserelax
     299   REAL :: sigma2_pdf
    295300   REAL :: ai, bi, B0
    296301   REAL :: sursat_iceliq
     
    302307   REAL :: N0_PSD, lambda_PSD                                             !--parameters of the exponential PSD
    303308
    304    REAL :: rho_ice                                                        !--ice density                                   [kg/m3]
    305309   REAL :: cldfra1D
    306310   REAL :: rho_air
    307311   REAL :: psati                                                          !--saturation vapor pressure wrt ice             [Pa]
    308    
    309    REAL :: vitw                                                           !--vertical velocity                             [m/s]
     312
    310313                                                                       
     314    REAL :: tempvig1, tempvig2
     315
     316   tempvig1    = -21.06 + RTT
     317   tempvig2    = -30.35 + RTT
    311318   C0            = 10.                                                    !--value assumed in Field2014           
    312    rho_ice       = 950.
    313319   sursat_iceext = -0.1
    314320   qzero(:)      = 0.
    315321   cldfraliq(:)  = 0.
    316    icefrac(:)    = 0.
    317    dicefracdT(:) = 0.
    318 
     322   qliq(:)       = 0.
     323   qice(:)      = 0.
     324   qvap_cld(:)   = 0.
    319325   sigma2_icefracturb(:) = 0.
    320326   mean_icefracturb(:)   = 0.
     
    327333
    328334    DO i=1,klon
    329 
    330335     rho_air  = pplay(i) / temp(i) / RD
    331 
    332336     ! because cldfra is intent in, but can be locally modified due to test
    333337     cldfra1D = cldfra(i)
    334      IF (cldfra(i) .LE. 0.) THEN
    335         qvap_cld(i)   = 0.
    336         qliq(i)       = 0.
    337         qice(i)       = 0.
    338         cldfraliq(i)  = 0.
    339         icefrac(i)    = 0.
    340         dicefracdT(i) = 0.
    341 
    342      ! If there is a cloud
    343      ELSE
     338     ! activate param for concerned grid points and for cloudy conditions
     339     IF ((pticefracturb(i)) .AND. (cldfra(i) .GT. 0.)) THEN
    344340        IF (cldfra(i) .GE. 1.0) THEN
    345341           cldfra1D = 1.0
     
    364360           dicefracdT(i) = 0.
    365361
     362
    366363        !---------------------------------------------------------
    367364        !--             MIXED PHASE TEMPERATURE REGIME         
     
    374371        ELSE
    375372
    376            vitw = -omega(i) / RG / rho_air
    377            qiceini_incl  = qice_ini(i) / cldfra1D + snowcld(i) * RG * dtime / ( paprsdn(i) - paprsup(i) ) / cldfra1D
    378 
    379            !--1. No preexisting ice : if vertical motion, fully liquid
     373           qiceini_incl  = qice_ini(i) / cldfra1D + gamma_snwretro * snowcld(i) * RG * dtime / ( paprsdn(i) - paprsup(i) ) / cldfra1D
     374           ! assuming snowfall velocity = 1 m/s:
     375           !qiceini_incl  = qice_ini(i) / cldfra1D + gamma_snwretro * snowcld(i) / pplay(i) * RD * temp(i) / 1. / cldfra1D
     376
     377           !--1. No preexisting ice and no mixing with environment: if vertical motion, fully liquid
    380378           !--cloud else fully iced cloud
    381            IF ( qiceini_incl .LT. eps ) THEN
    382               IF ( (vitw .GT. eps) .OR. (tke(i) .GT. eps) ) THEN
     379           IF ( (qiceini_incl .LT. eps) .AND. (invtau_e(i) .LT. eps) ) THEN
     380              IF ( (wvel(i) .GT. eps) .OR. (tke(i) .GT. eps) ) THEN
    383381                 qvap_cld(i)   = qsatl(i) * cldfra1D
    384382                 qliq(i)       = MAX(0.,qtot_incl(i)-qsatl(i)) * cldfra1D
     
    397395           
    398396
    399            !--2. Pre-existing ice :computation of ice properties for
     397           !--2. Pre-existing ice and/or mixing with environment:computation of ice properties for
    400398           !--feedback
    401399           ELSE
    402               ai = RG / RD / temp(i) * ( RD * RLSTT / RCPD / RV / temp(i) - 1. )
    403 
    404               sursat_equ    = ai * vitw * tau_phaserelax
    405400
    406401              sursat_iceliq = qsatl(i)/qsati(i) - 1.
     
    410405              !--are computed following Morrison&Gettelman 2008
    411406              !--Ice number density is assumed equals to INP density
    412               !--which is a function of temperature (DeMott 2010) 
     407              !--which is for naero5>0 a function of temperature (DeMott 2010)   
    413408              !--bi and B0 are microphysical function characterizing
    414409              !--vapor/ice interactions
     
    416411              !--onto ice crystals
    417412
    418               nb_crystals = 1.e3 * 5.94e-5 * ( RTT - temp(i) )**3.33 * naero5**(0.0264*(RTT-temp(i))+0.0033)
    419               lambda_PSD  = ( (RPI*rho_ice*nb_crystals) / (rho_air * qiceini_incl ) ) ** (1./3.)
     413              !--For naero5<=0 INP density is derived from the empirical fit
     414              !--from MARCUS campaign from Vignon 2021
     415              !--/!\ Note that option is very specific and should be use for
     416              !--the Southern Ocean and the Antarctic
     417
     418              IF (naero5 .LE. 0) THEN
     419                 IF ( temp(i) .GT. tempvig1 ) THEN
     420                      nb_crystals = 1.e3 * 10**(-0.14*(temp(i)-tempvig1) - 2.88)
     421                 ELSE IF ( temp(i) .GT. tempvig2 ) THEN
     422                      nb_crystals = 1.e3 * 10**(-0.31*(temp(i)-tempvig1) - 2.88)
     423                 ELSE
     424                      nb_crystals = 1.e3 * 10**(0.)
     425                 ENDIF
     426              ELSE
     427                 nb_crystals = 1.e3 * 5.94e-5 * ( RTT - temp(i) )**3.33 * naero5**(0.0264*(RTT-temp(i))+0.0033)
     428              ENDIF
     429              lambda_PSD  = ( (RPI*rho_ice*nb_crystals) / (rho_air * MAX(qiceini_incl , eps) ) ) ** (1./3.)
    420430              N0_PSD      = nb_crystals * lambda_PSD
    421431              moment1_PSD = N0_PSD/lambda_PSD**2
     
    431441              B0 = 4. * RPI * capa_crystal * 1. / (  RLSTT**2 / air_thermal_conduct / RV / temp(i)**2  &
    432442                                                  +  RV * temp(i) / psati / water_vapor_diff  )
    433               tau_phaserelax = 1. / (bi * B0 * moment1_PSD )
     443              invtau_phaserelax = bi * B0 * moment1_PSD
    434444             
    435445              ai = RG / RD / temp(i) * ( RD * RLSTT / RCPD / RV / temp(i) - 1. )
    436 
    437               !--2A. No TKE : stationnary binary solution depending on omega
     446              sursat_equ    = (ai * wvel(i) + sursat_e(i)*invtau_e(i)) / (invtau_phaserelax + invtau_e(i))
     447              sursat_equ    = MAX(-1., MIN(sursat_equ , 1.))
     448              ! as sursaturation is by definition lower than -1 and
     449              ! because local supersaturation > 1 are never found in the atmosphere
     450
     451              !--2A. No TKE : stationnary binary solution depending on vertical velocity and mixing with env.
    438452              ! If Sequ > Siw liquid cloud, else ice cloud
    439453              IF ( tke_dissip(i) .LE. eps )  THEN
     454                 sigma2_icefracturb(i)= 0.
     455                 mean_icefracturb(i)  = sursat_equ
    440456                 IF (sursat_equ .GT. sursat_iceliq) THEN
    441457                    qvap_cld(i)   = qsatl(i) * cldfra1D
     
    474490
    475491                 liqfra_max = MAX(0., (MIN (1.,( qtot_incl(i) - (qice_ini(i) / cldfra1D) - qsati(i) * (1 + sursat_iceext ) ) / ( qsatl(i) - qsati(i) ) ) ) )
    476                  sigma2_pdf = 1./2. * ( ai**2 ) *  2./3. * tke(i) * tau_dissipturb * tau_phaserelax
    477                  
    478                  mean_pdf = ai * vitw * tau_phaserelax
    479                  
    480                  cldfraliq(i) = 0.5 * (1. - erf( ( sursat_iceliq - mean_pdf) / (SQRT(2.* sigma2_pdf) ) ) )
     492                 sigma2_pdf = MIN(1., 1./2. * ( ai**2 ) *  2./3. * tke(i) * tau_dissipturb / (invtau_phaserelax + invtau_e(i)))
     493                 ! sursat ranges between -1 and 1, so we prevent sigma2 so exceed 1
     494                 cldfraliq(i) = 0.5 * (1. - erf( ( sursat_iceliq - sursat_equ) / (SQRT(2.* sigma2_pdf) ) ) )
    481495                 IF (cldfraliq(i) .GT. liqfra_max) THEN
    482496                     cldfraliq(i) = liqfra_max
    483497                 ENDIF
    484498                 
    485                  qliq_incl = qsati(i) * SQRT(sigma2_pdf) / SQRT(2.*RPI) * EXP( -1.*(sursat_iceliq - mean_pdf)**2. / (2.*sigma2_pdf) )  &
    486                            - qsati(i) * cldfraliq(i) * (sursat_iceliq - mean_pdf )
     499                 qliq_incl = qsati(i) * SQRT(sigma2_pdf) / SQRT(2.*RPI) * EXP( -1.*(sursat_iceliq - sursat_equ)**2. / (2.*sigma2_pdf) )  &
     500                           - qsati(i) * cldfraliq(i) * (sursat_iceliq - sursat_equ )
    487501                 
    488502                 sigma2_icefracturb(i)= sigma2_pdf
    489                  mean_icefracturb(i)  = mean_pdf
     503                 mean_icefracturb(i)  = sursat_equ
    490504     
    491505                 !------------ SPECIFIC VAPOR CONTENT AND WATER CONSERVATION  ------------
     
    505519                 IF ( qvap_incl  .GE. qtot_incl(i) ) THEN
    506520                    qvap_incl = qsati(i)
    507                     qliq_incl = qtot_incl(i) - qvap_incl
     521                    qliq_incl = MAX(0.0,qtot_incl(i) - qvap_incl)
    508522                    qice_incl = 0.
    509523
     
    518532                 qliq(i)       = qliq_incl * cldfra1D
    519533                 qice(i)       = qice_incl * cldfra1D
    520                  icefrac(i)    = qice(i) / ( qice(i) + qliq(i) )
     534                 IF ((qice(i)+qliq(i)) .GT. 0.) THEN
     535                    icefrac(i)    = qice(i) / ( qice(i) + qliq(i) )
     536                 ELSE
     537                    icefrac(i)    = 1. ! to keep computation of qsat wrt ice in condensation loop in lmdz_lscp_main
     538                 ENDIF
    521539                 dicefracdT(i) = 0.
    522540
     
    527545        END IF ! ! MPC temperature
    528546
    529      END IF ! cldfra
     547     END IF ! pticefracturb and cldfra
    530548   
    531549   ENDDO ! klon
  • LMDZ6/trunk/libf/phylmd/phys_local_var_mod.F90

    r5605 r5614  
    623623      REAL, SAVE, ALLOCATABLE :: sigma2_icefracturb(:,:)
    624624!$OMP THREADPRIVATE(sigma2_icefracturb)
     625      REAL, SAVE, ALLOCATABLE :: cldfraliqth(:,:)
     626!$OMP THREADPRIVATE(cldfraliqth)
     627      REAL, SAVE, ALLOCATABLE ::mean_icefracturbth(:,:)
     628!$OMP THREADPRIVATE(mean_icefracturbth)
     629      REAL, SAVE, ALLOCATABLE :: sigma2_icefracturbth(:,:)
     630!$OMP THREADPRIVATE(sigma2_icefracturbth)
    625631
    626632! variables de sorties MM
     
    12011207      ALLOCATE(sigma2_icefracturb(klon,klev))
    12021208      ALLOCATE(mean_icefracturb(klon,klev))
     1209      ALLOCATE(cldfraliqth(klon,klev))
     1210      ALLOCATE(sigma2_icefracturbth(klon,klev))
     1211      ALLOCATE(mean_icefracturbth(klon,klev))
    12031212      ALLOCATE(distcltop(klon,klev))
    12041213      ALLOCATE(temp_cltop(klon,klev))
     
    16191628      DEALLOCATE(sigma2_icefracturb)
    16201629      DEALLOCATE(mean_icefracturb)
     1630      DEALLOCATE(cldfraliqth)
     1631      DEALLOCATE(sigma2_icefracturbth)
     1632      DEALLOCATE(mean_icefracturbth)
    16211633      DEALLOCATE (zxsnow,snowhgt,qsnow,to_ice,sissnow,runoff,albsol3_lic)
    16221634      DEALLOCATE(distcltop)
  • LMDZ6/trunk/libf/phylmd/phys_output_ctrlout_mod.F90

    r5605 r5614  
    15921592  TYPE(ctrl_out), SAVE :: o_rneb = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11, 11/), &
    15931593    'rneb', 'Cloud fraction', '-', (/ ('', i=1, 10) /))
     1594  TYPE(ctrl_out), SAVE :: o_distcltop = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
     1595    'distcltop', 'Distance from cloud top', 'm', (/ ('', i=1, 10) /))
     1596  TYPE(ctrl_out), SAVE :: o_tempcltop = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
     1597    'tempcltop', 'Cloud top temperature', 'K', (/ ('', i=1, 10) /))
    15941598  TYPE(ctrl_out), SAVE :: o_cldfraliq = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
    1595     'cldfraliq', 'Liquid fraction of the cloud', '-', (/ ('', i=1, 10) /))
     1599    'cldfraliq', 'Liquid fraction of the cloud part of the mesh', '-', (/ ('', i=1, 10) /))
    15961600  TYPE(ctrl_out), SAVE :: o_sigma2_icefracturb = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
    15971601    'sigma2_icefracturb', 'Variance of the diagnostic supersaturation distribution (icefrac_turb) [-]', '-', (/ ('', i=1, 10) /))
    15981602  TYPE(ctrl_out), SAVE :: o_mean_icefracturb = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
    15991603    'mean_icefracturb', 'Mean of the diagnostic supersaturation distribution (icefrac_turb) [-]', '-', (/ ('', i=1, 10) /))
    1600  
     1604   TYPE(ctrl_out), SAVE :: o_cldfraliqth = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
     1605    'cldfraliqth', 'Liquid fraction of clouds in thermals', '-', (/ ('', i=1, 10) /))
     1606  TYPE(ctrl_out), SAVE :: o_sigma2_icefracturbth = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
     1607    'sigma2_icefracturbth', 'Variance of the diagnostic supersaturation distribution in thermals (icefrac_turb) [-]', '-', (/ ('', i=1, 10) /))
     1608  TYPE(ctrl_out), SAVE :: o_mean_icefracturbth = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11/), &
     1609    'mean_icefracturbth', 'Mean of the diagnostic supersaturation distribution in thermals (icefrac_turb) [-]', '-', (/ ('', i=1, 10) /))
    16011610  TYPE(ctrl_out), SAVE :: o_rnebjn = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11,11, 11/), &     
    16021611    'rnebjn', 'Cloud fraction in day', '-', (/ ('', i=1, 10) /))
  • LMDZ6/trunk/libf/phylmd/phys_output_write_mod.F90

    r5605 r5614  
    145145         o_zfull, o_zhalf, o_rneb, o_rnebjn, o_rnebcon, &
    146146         o_rnebls, o_rneblsvol, o_rhum, o_rhl, o_rhi, o_ozone, o_ozone_light, &
     147         o_distcltop, o_tempcltop,  &
    147148         o_pfraclr, o_pfracld, o_cldfraliq, o_sigma2_icefracturb, o_mean_icefracturb,  &
     149         o_cldfraliqth, o_sigma2_icefracturbth, o_mean_icefracturbth,  &
    148150         o_qrainlsc, o_qsnowlsc, o_dqreva, o_dqrauto, o_dqrcol, o_dqrmelt, o_dqrfreez, &
    149151         o_dqssub, o_dqsauto, o_dqsagg, o_dqsrim, o_dqsmelt, o_dqsfreez, &
     
    269271         o_SAD_sulfate, o_reff_sulfate, o_sulfmmr, o_nd_mode, o_sulfmmr_mode,o_SO2_chlm
    270272
    271     USE lmdz_lscp_ini, ONLY: ok_poprecip
     273    USE lmdz_lscp_ini, ONLY: ok_poprecip, iflag_icefrac
    272274
    273275    USE phys_output_ctrlout_mod, ONLY: o_heat_volc, o_cool_volc !NL
     
    377379         zphi, u_seri, v_seri, omega, cldfra, &
    378380         rneb, rnebjn, rneblsvol,  &
    379          zx_rh, zx_rhl, zx_rhi, &
     381         zx_rh, zx_rhl, zx_rhi, distcltop, temp_cltop, &
    380382         pfraclr, pfracld, cldfraliq, sigma2_icefracturb, mean_icefracturb, &
     383         cldfraliqth, sigma2_icefracturbth, mean_icefracturbth, &
    381384         qraindiag, qsnowdiag, dqreva, dqssub, &
    382385         dqrauto,dqrcol,dqrmelt,dqrfreez, &
     
    20872090           CALL histwrite_phy(o_pfraclr, pfraclr)
    20882091           CALL histwrite_phy(o_pfracld, pfracld)
     2092           IF (iflag_icefrac .GT. 0) THEN
    20892093           CALL histwrite_phy(o_cldfraliq, cldfraliq)
    20902094           CALL histwrite_phy(o_sigma2_icefracturb, sigma2_icefracturb)
    20912095           CALL histwrite_phy(o_mean_icefracturb, mean_icefracturb)
     2096           CALL histwrite_phy(o_cldfraliqth, cldfraliqth)
     2097           CALL histwrite_phy(o_sigma2_icefracturbth, sigma2_icefracturbth)
     2098           CALL histwrite_phy(o_mean_icefracturbth, mean_icefracturbth)
     2099           ELSE
     2100           CALL histwrite_phy(o_distcltop, distcltop)
     2101           CALL histwrite_phy(o_tempcltop, temp_cltop)
     2102           ENDIF
    20922103           IF (ok_poprecip) THEN
    20932104           CALL histwrite_phy(o_qrainlsc, qraindiag)
  • LMDZ6/trunk/libf/phylmd/physiq_mod.F90

    r5597 r5614  
    7575    USE write_field_phy
    7676    use wxios_mod, ONLY: g_ctx, wxios_set_context
    77     USE lmdz_lscp, ONLY : lscp
     77    USE lmdz_lscp_main, ONLY : lscp
    7878    USE lmdz_call_cloud_optics_prop, ONLY : call_cloud_optics_prop
    7979    USE lmdz_lscp_old, ONLY : fisrtilp, fisrtilp_first
     
    323323       !
    324324       rneblsvol, &
    325        pfraclr, pfracld, cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
     325       pfraclr, pfracld, &
     326       cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
     327       cldfraliqth, sigma2_icefracturbth, mean_icefracturbth,  &
    326328       distcltop, temp_cltop,  &
    327329       !-- LSCP - condensation and ice supersaturation variables
     
    38853887         t_seri, q_seri, ql_seri_lscp, qi_seri_lscp, ptconv, ratqs, sigma_qtherm, &
    38863888         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneblsvol, &
    3887          pfraclr, pfracld, cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
     3889         pfraclr, pfracld, cldfraliq, cldfraliqth,              &
     3890         sigma2_icefracturb, sigma2_icefracturbth,              &
     3891         mean_icefracturb,  mean_icefracturbth,                 &
    38883892         radocond, picefra, rain_lsc, snow_lsc, &
    38893893         frac_impa, frac_nucl, beta_prec_fisrt, &
    38903894         prfl, psfl, rhcl,  &
    3891          zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cld_th, &
     3895         zqasc, fraca,ztv,zpspsk,ztla,zthl,zw2,iflag_cld_th, &
    38923896         iflag_ice_thermo, distcltop, temp_cltop,   &
    38933897         pbl_tke(:,:,is_ave), pbl_eps(:,:,is_ave), &
     3898         entr_therm, detr_therm, &
    38943899         cell_area, &
    38953900         cf_seri, rvc_seri, u_seri, v_seri, &
  • LMDZ6/trunk/libf/phylmdiso/lmdz_lscp_old.F90

    r5285 r5614  
    2222  USE icefrac_lsc_mod ! compute ice fraction (JBM 3/14)
    2323  USE print_control_mod, ONLY: prt_level, lunout
    24   USE lmdz_cloudth, only : cloudth, cloudth_v3, cloudth_v6
     24  USE lmdz_lscp_condensation, only : cloudth, cloudth_v3, cloudth_v6
    2525  USE ioipsl_getin_p_mod, ONLY : getin_p
    2626  USE phys_local_var_mod, ONLY: ql_seri,qs_seri
  • LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90

    r5562 r5614  
    7575    USE write_field_phy
    7676    use wxios_mod, ONLY: g_ctx, wxios_set_context
    77     USE lmdz_lscp, ONLY : lscp
     77    USE lmdz_lscp_main, ONLY : lscp
    7878    USE lmdz_call_cloud_optics_prop, ONLY : call_cloud_optics_prop
    7979    USE lmdz_lscp_old, ONLY : fisrtilp
     
    365365       rneblsvol, &
    366366       pfraclr, pfracld, cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
     367       cldfraliqth, sigma2_icefracturbth, mean_icefracturbth,  &
    367368       distcltop, temp_cltop,  &
    368369       !-- LSCP - condensation and ice supersaturation variables
     
    50815082         t_seri, q_seri, ql_seri_lscp, qi_seri_lscp, ptconv, ratqs, sigma_qtherm, &
    50825083         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneblsvol, &
    5083          pfraclr, pfracld, cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
     5084         pfraclr, pfracld, cldfraliq, cldfraliqth, &
     5085         sigma2_icefracturb, sigma2_icefracturbth, &
     5086         mean_icefracturb, mean_icefracturbth,     &
    50845087         radocond, picefra, rain_lsc, snow_lsc, &
    50855088         frac_impa, frac_nucl, beta_prec_fisrt, &
    50865089         prfl, psfl, rhcl,  &
    5087          zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cld_th, &
     5090         zqasc, fraca,ztv,zpspsk,ztla,zthl,zw2,iflag_cld_th, &
    50885091         iflag_ice_thermo, distcltop, temp_cltop,   &
    50895092         pbl_tke(:,:,is_ave), pbl_eps(:,:,is_ave), &
     5093         entr_therm, detr_therm, &
    50905094         cell_area, &
    50915095         cf_seri, rvc_seri, u_seri, v_seri, &
Note: See TracChangeset for help on using the changeset viewer.