Ignore:
Timestamp:
Apr 13, 2025, 7:10:19 PM (13 months ago)
Author:
aborella
Message:
  • changed treatment of prognostic variables for prognostic clouds
  • adapted sedimentation and autoconversion for prognostic cirrus clouds
  • cloud mixing, ice sedimentation and ISSR diagnosis are now consistent with the water vapor PDF
  • simplified assumptions for ice crystals deposition / sublimation
  • first version of the coupling between prognostic cirrus clouds and deep convection
  • added persistent contrail cirrus clouds in radiative diagnostics
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/contrails/libf/phylmd/lmdz_lscp_condensation.f90

    r5602 r5609  
    9494!**********************************************************************************
    9595SUBROUTINE condensation_ice_supersat( &
    96       klon, dtime, pplay, paprsdn, paprsup, cldfracv, qcondcv, &
    97       cldfra_in, qvc_in, qliq_in, qice_in, shear, pbl_eps, cell_area, stratomask, &
    98       temp, qtot_in, qsat, gamma_cond, ratqs, keepgoing, &
    99       cldfra, qincld, qvc, issrfra, qissr, dcf_sub, dcf_con, dcf_mix, &
    100       dqi_adj, dqi_sub, dqi_con, dqi_mix, dqvc_adj, dqvc_sub, dqvc_con, dqvc_mix, &
    101       contfra_in, qcont_in, flight_dist, flight_h2o, contfra, qcont, &
    102       Tcritcont, qcritcont, potcontfraP, potcontfraNP, &
     96      klon, dtime, pplay, paprsdn, paprsup, cfcon, &
     97      cldfra_in, qvc_in, qliq_in, qice_in, shear, pbl_eps, cell_area, &
     98      temp, qtot_in, qsat, gamma_cond, ratqs, keepgoing, pt_pron_clds, &
     99      cldfra_above, icesed_flux, &
     100      cldfra, qincld, qvc, issrfra, qissr, dcf_sub, dcf_con, dcf_mix, dcf_sed, &
     101      dqi_adj, dqi_sub, dqi_con, dqi_mix, dqi_sed, &
     102      dqvc_adj, dqvc_sub, dqvc_con, dqvc_mix, dqvc_sed, &
     103      contfra_in, perscontfra_in, qva_in, qia_in, flight_dist, flight_h2o, &
     104      contfra, perscontfra, qcont, Tcritcont, qcritcont, potcontfraP, potcontfraNP, &
    103105      dcfa_ini, dqia_ini, dqta_ini, dcfa_sub, dqia_sub, dqta_sub, &
    104106      dcfa_cir, dqta_cir, dcfa_mix, dqia_mix, dqta_mix)
     
    118120
    119121USE lmdz_lscp_tools, ONLY: calc_qsat_ecmwf, calc_gammasat, GAMMAINC
    120 USE lmdz_lscp_ini,   ONLY: RCPD, RLSTT, RLVTT, RLMLT, RVTMP2, RTT, RD, RG, RV, RPI, EPS_W
    121 USE lmdz_lscp_ini,   ONLY: eps, temp_nowater, ok_weibull_warm_clouds
    122 USE lmdz_lscp_ini,   ONLY: ok_unadjusted_clouds, ok_no_issr_strato
    123 
    124 USE lmdz_lscp_ini,   ONLY: depo_coef_cirrus, capa_cond_cirrus, std_subl_pdf_lscp
    125 USE lmdz_lscp_ini,   ONLY: beta_pdf_lscp, temp_thresh_pdf_lscp
     122USE lmdz_lscp_ini,   ONLY: RLSTT, RTT, RD, RG, RV, RPI, EPS_W
     123USE lmdz_lscp_ini,   ONLY: eps, temp_nowater, ok_unadjusted_clouds
     124
     125USE lmdz_lscp_ini,   ONLY: depo_coef_cirrus, capa_cond_cirrus, rho_ice
     126USE lmdz_lscp_ini,   ONLY: mu_subl_pdf_lscp, beta_pdf_lscp, temp_thresh_pdf_lscp
    126127USE lmdz_lscp_ini,   ONLY: std100_pdf_lscp, k0_pdf_lscp, kappa_pdf_lscp
    127128USE lmdz_lscp_ini,   ONLY: coef_mixing_lscp, coef_shear_lscp
     
    143144REAL,     INTENT(IN)   , DIMENSION(klon) :: paprsdn       ! pressure at the lower interface [Pa]
    144145REAL,     INTENT(IN)   , DIMENSION(klon) :: paprsup       ! pressure at the upper interface [Pa]
    145 REAL,     INTENT(IN)   , DIMENSION(klon) :: cldfracv      ! cloud fraction from deep convection [-]
    146 REAL,     INTENT(IN)   , DIMENSION(klon) :: qcondcv       ! in-cloud condensed specific humidity from deep convection [kg/kg]
     146REAL,     INTENT(IN)   , DIMENSION(klon) :: cfcon         ! cloud fraction from deep convection [-]
    147147REAL,     INTENT(IN)   , DIMENSION(klon) :: cldfra_in     ! cloud fraction [-]
    148148REAL,     INTENT(IN)   , DIMENSION(klon) :: qvc_in        ! gridbox-mean water vapor in cloud [kg/kg]
     
    152152REAL,     INTENT(IN)   , DIMENSION(klon) :: pbl_eps       ! TKE dissipation [m2/s3]
    153153REAL,     INTENT(IN)   , DIMENSION(klon) :: cell_area     ! cell area [m2]
    154 REAL,     INTENT(IN)   , DIMENSION(klon) :: stratomask    ! fraction of stratosphere in the mesh (1 or 0)
    155154REAL,     INTENT(IN)   , DIMENSION(klon) :: temp          ! temperature [K]
    156155REAL,     INTENT(IN)   , DIMENSION(klon) :: qtot_in       ! total specific humidity (without precip) [kg/kg]
     
    159158REAL,     INTENT(IN)   , DIMENSION(klon) :: ratqs         ! ratio between the variance of the total water distribution and its average [-]
    160159LOGICAL,  INTENT(IN)   , DIMENSION(klon) :: keepgoing     ! .TRUE. if a new condensation loop should be computed
     160LOGICAL,  INTENT(IN)   , DIMENSION(klon) :: pt_pron_clds  ! .TRUE. if clouds are prognostic in this mesh
     161REAL,     INTENT(IN)   , DIMENSION(klon) :: cldfra_above  ! cloud fraction IN THE LAYER ABOVE [-]
     162REAL,     INTENT(IN)   , DIMENSION(klon) :: icesed_flux   ! sedimentated ice flux [kg/s/m2]
    161163!
    162164! Input for aviation
    163165!
    164166REAL,     INTENT(IN)   , DIMENSION(klon) :: contfra_in    ! input linear contrails fraction [-]
    165 REAL,     INTENT(IN)   , DIMENSION(klon) :: qcont_in      ! input linear contrails total specific humidity [kg/kg]
     167REAL,     INTENT(IN)   , DIMENSION(klon) :: perscontfra_in! input contrail induced cirrus fraction [-]
     168REAL,     INTENT(IN)   , DIMENSION(klon) :: qva_in        ! input linear contrails total specific humidity [kg/kg]
     169REAL,     INTENT(IN)   , DIMENSION(klon) :: qia_in        ! input linear contrails total specific humidity [kg/kg]
    166170REAL,     INTENT(IN)   , DIMENSION(klon) :: flight_dist   ! aviation distance flown concentration [m/s/m3]
    167171REAL,     INTENT(IN)   , DIMENSION(klon) :: flight_h2o    ! aviation emitted H2O concentration [kgH2O/s/m3]
     
    186190REAL,     INTENT(INOUT), DIMENSION(klon) :: dcf_con  ! cloud fraction tendency because of condensation [s-1]
    187191REAL,     INTENT(INOUT), DIMENSION(klon) :: dcf_mix  ! cloud fraction tendency because of cloud mixing [s-1]
     192REAL,     INTENT(INOUT), DIMENSION(klon) :: dcf_sed  ! cloud fraction tendency because of sedimentation [s-1]
    188193REAL,     INTENT(INOUT), DIMENSION(klon) :: dqi_adj  ! specific ice content tendency because of temperature adjustment [kg/kg/s]
    189194REAL,     INTENT(INOUT), DIMENSION(klon) :: dqi_sub  ! specific ice content tendency because of sublimation [kg/kg/s]
    190195REAL,     INTENT(INOUT), DIMENSION(klon) :: dqi_con  ! specific ice content tendency because of condensation [kg/kg/s]
    191196REAL,     INTENT(INOUT), DIMENSION(klon) :: dqi_mix  ! specific ice content tendency because of cloud mixing [kg/kg/s]
     197REAL,     INTENT(INOUT), DIMENSION(klon) :: dqi_sed  ! specific ice content tendency because of sedimentation [kg/kg/s]
    192198REAL,     INTENT(INOUT), DIMENSION(klon) :: dqvc_adj ! specific cloud water vapor tendency because of temperature adjustment [kg/kg/s]
    193199REAL,     INTENT(INOUT), DIMENSION(klon) :: dqvc_sub ! specific cloud water vapor tendency because of sublimation [kg/kg/s]
    194200REAL,     INTENT(INOUT), DIMENSION(klon) :: dqvc_con ! specific cloud water vapor tendency because of condensation [kg/kg/s]
    195201REAL,     INTENT(INOUT), DIMENSION(klon) :: dqvc_mix ! specific cloud water vapor tendency because of cloud mixing [kg/kg/s]
     202REAL,     INTENT(INOUT), DIMENSION(klon) :: dqvc_sed ! specific cloud water vapor tendency because of sedimentation [kg/kg/s]
    196203!
    197204!  Diagnostics for aviation
     
    199206!
    200207REAL,     INTENT(INOUT), DIMENSION(klon) :: contfra      ! linear contrail fraction [-]
     208REAL,     INTENT(INOUT), DIMENSION(klon) :: perscontfra  ! linear contrail induced cirrus fraction [-]
    201209REAL,     INTENT(INOUT), DIMENSION(klon) :: qcont        ! linear contrail specific humidity [kg/kg]
    202210REAL,     INTENT(INOUT), DIMENSION(klon) :: Tcritcont    ! critical temperature for contrail formation [K]
     
    220228INTEGER :: i
    221229LOGICAL :: ok_warm_cloud
    222 REAL, DIMENSION(klon) :: qtot, qcld, qzero
     230REAL, DIMENSION(klon) :: qcld, qzero
    223231REAL, DIMENSION(klon) :: clrfra, qclr
    224232!
     
    228236!
    229237! for unadjusted clouds
    230 REAL :: qvapincld, qiceincld, qvapincld_new
    231 !
    232 ! for sublimation
    233 REAL :: dqt_sub
     238REAL :: qiceincld, qvapincld, qvapincld_new
     239!
     240! for deposition / sublimation
     241REAL :: pres_sat, kappa_depsub, tau_depsub
     242REAL :: air_thermal_conduct, water_vapor_diff
     243REAL :: N_ice
     244!
     245! for dissipation
     246REAL :: pdf_shape
    234247!
    235248! for condensation
    236249REAL, DIMENSION(klon) :: qsatl, dqsatl
    237 REAL, DIMENSION(klon) :: pdf_alpha, pdf_scale, pdf_loc
    238 REAL :: rhl_clr
    239 REAL :: pdf_ratqs, pdf_skew
    240 REAL :: pdf_x, pdf_y, pdf_T
    241 REAL :: pdf_e3, pdf_e4
    242 REAL :: cf_cond, qt_cond, dqt_con
     250REAL, DIMENSION(klon) :: pdf_alpha, pdf_scale, pdf_gamma
     251REAL :: rhl_clr, pdf_loc
     252REAL :: pdf_e3, pdf_x, pdf_y
     253REAL :: dqt_con
     254!
     255! for sedimentation
     256REAL, DIMENSION(klon) :: qice_sedim
     257REAL :: clrfra_sed
    243258!
    244259! for mixing
    245260REAL :: a_mix, bovera, Povera, N_cld_mix, L_mix
    246 REAL :: clrfra_mix, sigma_mix
     261REAL :: cldfra_mix, clrfra_mix, sigma_mix
    247262REAL :: L_shear, shear_fra
    248 REAL :: qvapinclr_lim
     263REAL :: qiceinmix, qvapinmix_lim, qvapinclr_lim
    249264REAL :: pdf_fra_above_nuc, pdf_q_above_nuc
    250265REAL :: pdf_fra_above_lim, pdf_q_above_lim
    251 REAL :: pdf_fra_below_lim
     266REAL :: pdf_fra_below_lim, pdf_q_below_lim
     267REAL :: mixed_fraction
    252268!
    253269! for cell properties
    254 REAL, DIMENSION(klon) :: dz
     270REAL :: rho, rhodz, dz
     271!
     272! for contrails
     273REAL :: perscontfra_ratio
     274REAL :: contrails_conversion_factor
    255275
    256276qzero(:) = 0.
    257 qtot = qtot_in
    258277
    259278!--Calculation of qsat w.r.t. liquid
     
    269288  !--formed elsewhere)
    270289  IF (keepgoing(i)) THEN
    271 
    272     !--Initialisation
    273     issrfra(i)  = 0.
    274     qissr(i)    = 0.
    275     contfra(i)  = 0.
    276     qcont(i)    = 0.
    277290
    278291    !--If the temperature is higher than the threshold below which
     
    281294    !--If ok_weibull_warm_clouds = .TRUE., the Weibull law is used for
    282295    !--all clouds, and the lognormal scheme is not activated
    283     IF ( ( ( temp(i) .GT. temp_nowater ) .AND. .NOT. ok_weibull_warm_clouds ) .OR. &
    284          ( ok_no_issr_strato .AND. ( stratomask(i) .EQ. 1. ) ) ) THEN
    285 
    286       pdf_std   = ratqs(i) * qtot(i)
    287       pdf_k     = -SQRT( LOG( 1. + (pdf_std / qtot(i))**2 ) )
    288       pdf_delta = LOG( qtot(i) / ( gamma_cond(i) * qsat(i) ) )
     296    IF ( .NOT. pt_pron_clds(i) ) THEN
     297
     298      pdf_std   = ratqs(i) * qtot_in(i)
     299      pdf_k     = -SQRT( LOG( 1. + (pdf_std / qtot_in(i))**2 ) )
     300      pdf_delta = LOG( qtot_in(i) / ( gamma_cond(i) * qsat(i) ) )
    289301      pdf_a     = pdf_delta / ( pdf_k * SQRT(2.) )
    290302      pdf_b     = pdf_k / (2. * SQRT(2.))
     
    303315      ELSE
    304316        cldfra(i) = 0.5 * pdf_e1
    305         qincld(i) = qtot(i) * pdf_e2 / pdf_e1
     317        qincld(i) = qtot_in(i) * pdf_e2 / pdf_e1
    306318        qvc(i) = qsat(i) * cldfra(i)
    307319      ENDIF
     
    319331      ok_warm_cloud = ( temp(i) .GT. temp_nowater )
    320332
    321       !--We remove the convection water from the total available water
    322       qtot(i) = qtot(i) - ( qcondcv(i) + qsat(i) ) * cldfracv(i)
    323 
    324333      !--The following barriers ensure that the traced cloud properties
    325334      !--are consistent. In some rare cases, i.e. the cloud water vapor
    326335      !--can be greater than the total water in the gridbox
    327       cldfra(i) = MAX(0., MIN(1. - cldfracv(i), cldfra_in(i)))
    328       qcld(i)   = MAX(0., MIN(qtot(i), qliq_in(i) + qice_in(i) + qvc_in(i)))
     336      cldfra(i) = MAX(0., MIN(1. - cfcon(i), cldfra_in(i)))
     337      qcld(i)   = MAX(0., MIN(qtot_in(i), qliq_in(i) + qice_in(i) + qvc_in(i)))
    329338      qvc(i)    = MAX(0., MIN(qcld(i), qvc_in(i)))
    330339
    331340      !--Initialise clear fraction properties
    332       clrfra(i) = ( 1. - cldfracv(i) ) - cldfra(i)
    333       qclr(i) = qtot(i) - qcld(i)
     341      clrfra(i) = MAX(0., MIN(1., ( 1. - cfcon(i) ) - cldfra(i)))
     342      qclr(i) = qtot_in(i) - qcld(i)
    334343
    335344      dcf_sub(i)  = 0.
     
    344353      dqi_mix(i)  = 0.
    345354      dqvc_mix(i) = 0.
     355      dcf_sed(i)  = 0.
     356      dqi_sed(i)  = 0.
     357      dqvc_sed(i) = 0.
     358
     359      IF ( icesed_flux(i) .GT. 0. ) THEN
     360        !--If ice sedimentation is activated, the quantity of sedimentated ice was added
     361        !--to the total water vapor in the precipitation routine. Here we remove it
     362        !--(it will be reincluded later)
     363        qice_sedim(i) = icesed_flux(i) / ( paprsdn(i) - paprsup(i) ) * RG * dtime
     364        qclr(i) = qclr(i) - qice_sedim(i)
     365      ENDIF
    346366
    347367      !--Initialisation of the cell properties
    348368      !--Dry density [kg/m3]
    349       !rho = pplay(i) / temp(i) / RD
     369      rho = pplay(i) / temp(i) / RD
    350370      !--Dry air mass [kg/m2]
    351       !rhodz = ( paprsdn(i) - paprsup(i) ) / RG
     371      rhodz = ( paprsdn(i) - paprsup(i) ) / RG
    352372      !--Cell thickness [m]
    353       !dz = rhodz / rho
    354       dz(i) = ( paprsdn(i) - paprsup(i) ) / pplay(i) * temp(i) * RD / RG
     373      dz = rhodz / rho
     374
     375      !--If ok_unadjusted_clouds is set to TRUE, then the saturation adjustment
     376      !--hypothesis is lost, and the vapor in the cloud is purely prognostic.
     377      !
     378      !--The deposition equation is
     379      !-- dmi/dt = alpha*4pi*C*Svi / ( R_v*T/esi/Dv + Ls/ka/T * (Ls/R_v/T - 1) )
     380      !--from Lohmann et al. (2016), where
     381      !--alpha is the deposition coefficient [-]
     382      !--mi is the mass of one ice crystal [kg]
     383      !--C is the capacitance of an ice crystal [m]
     384      !--Svi is the supersaturation ratio equal to (qvc - qsat)/qsat [-]
     385      !--R_v is the specific gas constant for humid air [J/kg/K]
     386      !--T is the temperature [K]
     387      !--esi is the saturation pressure w.r.t. ice [Pa]
     388      !--Dv is the diffusivity of water vapor [m2/s]
     389      !--Ls is the specific latent heat of sublimation [J/kg/K]
     390      !--ka is the thermal conductivity of dry air [J/m/s/K]
     391      !
     392      !--alpha is a coefficient to take into account the fact that during deposition, a water
     393      !--molecule cannot join the crystal from everywhere, it must do so that the crystal stays
     394      !--coherent (with the same structure). It has no impact for sublimation.
     395      !--We fix alpha = depo_coef_cirrus (=0.5 by default following Lohmann et al. (2016))
     396      !--during deposition, and alpha = 1. during sublimation.
     397      !--The capacitance of the ice crystals is proportional to a parameter capa_cond_cirrus
     398      !-- C = capa_cond_cirrus * rm_ice
     399      !
     400      !--We have qice = Nice * mi, where Nice is the ice crystal
     401      !--number concentration per kg of moist air
     402      !--HYPOTHESIS 1: the ice crystals are spherical, therefore
     403      !-- mi = 4/3 * pi * rm_ice**3 * rho_ice
     404      !--HYPOTHESIS 2: the ice crystals are monodisperse with the
     405      !--initial radius rm_ice_0.
     406      !--NB. this is notably different than the assumption
     407      !--of a distributed qice in the cloud made in the sublimation process;
     408      !--should it be consistent?
     409      !
     410      !--As the deposition process does not create new ice crystals,
     411      !--and because we assume a same rm_ice value for all crystals
     412      !--therefore the sublimation process does not destroy ice crystals
     413      !--(or, in a limit case, it destroys all ice crystals), then
     414      !--Nice is a constant during the sublimation/deposition process.
     415      !-- dmi = dqi, et Nice = qi_0 / ( 4/3 RPI rm_ice_0**3 rho_ice )
     416      !
     417      !--The deposition equation then reads:
     418      !-- dqi/dt = alpha*4pi*capa_cond_cirrus*rm_ice*(qvc-qsat)/qsat / ( R_v*T/esi/Dv + Ls/ka/T * (Ls/R_v/T - 1) ) * Nice
     419      !-- dqi/dt = alpha*4pi*capa_cond_cirrus* (qi / qi_0)**(1/3) *rm_ice_0*(qvc-qsat)/qsat &
     420      !--             / ( R_v*T/esi/Dv + Ls/ka/T * (Ls*R_v/T - 1) ) &
     421      !--                         * qi_0 / ( 4/3 RPI rm_ice_0**3 rho_ice )
     422      !-- dqi/dt = qi**(1/3) * (qvc - qsat) * qi_0**(2/3) &
     423      !--  *alpha/qsat*capa_cond_cirrus/ (R_v*T/esi/Dv + Ls/ka/T*(Ls*R_v/T - 1)) / ( 1/3 rm_ice_0**2 rho_ice )
     424      !--and we have
     425      !-- dqvc/dt = - qi**(1/3) * (qvc - qsat) / kappa * alpha * qi_0**(2/3) / rm_ice_0**2
     426      !-- dqi/dt  =   qi**(1/3) * (qvc - qsat) / kappa * alpha * qi_0**(2/3) / rm_ice_0**2
     427      !--where kappa = 1/3*rho_ice/capa_cond_cirrus*qsat*(R_v*T/esi/Dv + Ls/ka/T*(Ls/R_v/T - 1))
     428      !
     429      !--This system of equations can be resolved with an exact
     430      !--explicit numerical integration, having one variable resolved
     431      !--explicitly, the other exactly. The exactly resolved variable is
     432      !--the one decreasing, so it is qvc if the process is
     433      !--condensation, qi if it is sublimation.
     434      !
     435      !--kappa is computed as an initialisation constant, as it depends only
     436      !--on temperature and other pre-computed values
     437      pres_sat = qsat(i) / ( EPS_W + ( 1. - EPS_W ) * qsat(i) ) * pplay(i)
     438      !--This formula for air thermal conductivity comes from Beard and Pruppacher (1971)
     439      air_thermal_conduct = ( 5.69 + 0.017 * ( temp(i) - RTT ) ) * 1.e-3 * 4.184
     440      !--This formula for water vapor diffusivity comes from Hall and Pruppacher (1976)
     441      water_vapor_diff = 0.211 * ( temp(i) / RTT )**1.94 * ( 101325. / pplay(i) ) * 1.e-4
     442      !--Median ice crystal concentration [#/m3] in cirrus clouds from Kramer et al (2020)
     443      N_ice = 0.003 * 1e6
     444      !--NB. the greater kappa_depsub, the lower the efficiency of the
     445      !--deposition/sublimation process
     446      kappa_depsub = ( 4. / 3. * RPI * N_ice / rho * rho_ice )**(1./3.) &
     447                   * qsat(i) / ( 4. * RPI * capa_cond_cirrus * N_ice / rho ) &
     448                   * ( RV * temp(i) / water_vapor_diff / pres_sat &
     449                     + RLSTT / air_thermal_conduct / temp(i) * ( RLSTT / RV / temp(i) - 1. ) )
    355450
    356451      !--If contrails are activated
    357452      IF ( ok_plane_contrail ) THEN
    358         contfra(i) = contfra_in(i)
    359         qcont(i) = qcont_in(i)
     453        contfra(i) = MAX(0., MIN(cldfra(i), contfra_in(i)))
     454        perscontfra(i) = MAX(0., MIN(cldfra(i), perscontfra_in(i)))
     455        qcont(i) = MAX(0., MIN(qcld(i), qva_in(i) + qia_in(i)))
    360456
    361457        dcfa_ini(i) = 0.
     
    370466        dqia_mix(i) = 0.
    371467        dqta_mix(i) = 0.
     468      ELSE
     469        contfra(i) = 0.
     470        perscontfra(i) = 0.
     471        qcont(i) = 0.
    372472      ENDIF
    373473
     
    379479      !--If there is a contrail
    380480      IF ( contfra(i) .GT. eps ) THEN
     481        !--We remove contrails from the main class
     482        cldfra(i) = cldfra(i) - contfra(i)
     483        qcld(i) = qcld(i) - qcont(i)
     484        qvc(i) = qvc(i) - qsat(i) * contfra(i)
     485
    381486        !--The contrail is always adjusted to saturation
    382487        qiceincld = ( qcont(i) / contfra(i) - qsat(i) )
    383488       
    384489        !--If the ice water content is too low, the cloud is purely sublimated
    385         IF ( qiceincld .LT. eps ) THEN
     490        IF ( qiceincld .LT. ( 0.005 * qsat(i) ) ) THEN
    386491          dcfa_sub(i) = - contfra(i)
    387492          dqia_sub(i) = - qiceincld * contfra(i)
     
    389494          contfra(i) = 0.
    390495          qcont(i) = 0.
    391           clrfra(i) = clrfra(i) + dcfa_sub(i)
    392           qclr(i) = qclr(i) + dqta_sub(i)
    393         ELSE
    394           !--We remove contrails from the main class
    395           cldfra(i) = cldfra(i) - contfra(i)
    396           qcld(i) = qcld(i) - qcont(i)
    397           qvc(i) = qvc(i) - qsat(i) * contfra(i)
     496          clrfra(i) = MIN(1., clrfra(i) - dcfa_sub(i))
     497          qclr(i) = qclr(i) - dqta_sub(i)
    398498        ENDIF   ! qiceincld .LT. eps
    399499      ENDIF ! contfra(i) .GT. eps
     500
     501      !--If there is a contrail induced cirrus, we save the ratio
     502      perscontfra_ratio = perscontfra(i) / MAX(eps, cldfra(i))
    400503
    401504
     
    421524          qcld(i) = 0.
    422525          qvc(i) = 0.
    423           clrfra(i) = clrfra(i) - dcf_sub(i)
     526          clrfra(i) = MIN(1., clrfra(i) - dcf_sub(i))
    424527          qclr(i) = qclr(i) - dqvc_sub(i) - dqi_sub(i)
    425 
    426           !--If all the ice has been sublimated, we sublimate
    427           !--completely the cloud and do not activate the sublimation
    428           !--process
    429           qvapincld_new = 0.
    430528
    431529        !--Else, the cloud is adjusted and sublimated
    432530        ELSE
    433531
    434           !--The vapor in cloud cannot be higher than the
    435           !--condensation threshold
    436           qvapincld = MIN(qvapincld, gamma_cond(i) * qsat(i))
    437           qiceincld = ( qcld(i) / cldfra(i) - qvapincld )
     532          !IF ( qiceincld .LT. ( 0.005 * qsat(i) ) ) THEN
     533          !  dcf_sub(i) = ( qiceincld / ( 0.005 * qsat(i) ) - 1. ) * cldfra(i)
     534          !  dqvc_sub(i) = qvapincld * dcf_sub(i)
     535
     536          !  cldfra(i) = cldfra(i) + dcf_sub(i)
     537          !  qcld(i) = qcld(i) + dqvc_sub(i)
     538          !  qvc(i) = qvc(i) + dqvc_sub(i)
     539          !  clrfra(i) = MIN(1., clrfra(i) - dcf_sub(i))
     540          !  qclr(i) = qclr(i) - dqvc_sub(i)
     541          !ENDIF
    438542
    439543          IF ( ok_unadjusted_clouds .AND. .NOT. ok_warm_cloud ) THEN
    440             qvapincld_new = QVAPINCLD_DEPSUB( &
    441                 qvapincld, qiceincld, temp(i), qsat(i), pplay(i), dtime)
    442             IF ( qvapincld_new .EQ. 0. ) THEN
    443               !--If all the ice has been sublimated, we sublimate
    444               !--completely the cloud and do not activate the dissipation
    445               !--process
    446               !--Tendencies and diagnostics
    447               dcf_sub(i) = - cldfra(i)
    448               dqvc_sub(i) = - qvc(i)
    449               dqi_sub(i) = - ( qcld(i) - qvc(i) )
    450 
    451               cldfra(i) = 0.
    452               qcld(i) = 0.
    453               qvc(i) = 0.
    454               clrfra(i) = clrfra(i) - dcf_sub(i)
    455               qclr(i) = qclr(i) - dqvc_sub(i) - dqi_sub(i)
    456             ENDIF
     544            IF ( qvapincld .GE. qsat(i) ) THEN
     545              !--If the cloud is initially supersaturated
     546              !--Exact explicit integration (qvc exact, qice explicit)
     547              tau_depsub = 1. / ( depo_coef_cirrus * qiceincld**(1./3.) * kappa_depsub )
     548            ELSE
     549              !--If the cloud is initially subsaturated
     550              !--Exact explicit integration (qvc exact, qice explicit)
     551              !--Same but depo_coef_cirrus = 1
     552              tau_depsub = 1. / ( qiceincld**(1./3.) * kappa_depsub )
     553            ENDIF ! qvapincld .GT. qsat
     554            qvapincld_new = qsat(i) + ( qvapincld - qsat(i) ) * EXP( - dtime / tau_depsub )
     555            !--If all the ice is sublimated
     556            IF ( qvapincld_new .GE. ( qvapincld + qiceincld ) ) qvapincld_new = 0.
    457557          ELSE
    458558            !--We keep the saturation adjustment hypothesis, and the vapor in the
    459559            !--cloud is set equal to the saturation vapor
    460             qvapincld_new = qsat(i)
     560            IF ( ( qvapincld + qiceincld ) .GT. qsat(i) ) THEN
     561              qvapincld_new = qsat(i)
     562            ELSE
     563              qvapincld_new = 0.
     564            ENDIF
    461565          ENDIF ! ok_unadjusted_clouds
    462          
    463           !--Adjustment of the IWC to the new vapor in cloud
    464           !--(this can be either positive or negative)
    465           dqvc_adj(i) = ( qvapincld_new * cldfra(i) - qvc(i) )
    466           dqi_adj(i) = - dqvc_adj(i)
    467 
    468           !--Add tendencies
    469           !--The vapor in the cloud is updated, but not qcld as it is constant
    470           !--through this process, as well as cldfra which is unmodified
    471           qvc(i) = MAX(0., MIN(qcld(i), qvc(i) + dqvc_adj(i)))
    472566         
    473567
     
    477571
    478572          !--If the dissipation process must be activated
    479           IF ( qvapincld_new .GT. 0. ) THEN
    480             !--Normal distribution around qvapincld + qiceincld with width
    481             !--constant in the RHi space
    482             pdf_y = ( qvapincld_new - qvapincld - qiceincld ) &
    483                   / ( std_subl_pdf_lscp / 100. * qsat(i))
    484             pdf_e1 = 0.5 * ( 1. + ERF( pdf_y / SQRT(2.) ) )
    485             pdf_e2 = EXP( - pdf_y**2 / 2. ) / SQRT( 2. * RPI )
    486 
    487             dcf_sub(i) = - cldfra(i) * pdf_e1
    488             dqt_sub    = - cldfra(i) * ( ( qvapincld + qiceincld ) * pdf_e1 &
    489                                        - std_subl_pdf_lscp / 100. * qsat(i) * pdf_e2 )
     573          !IF ( cldfra(i) .GT. eps ) THEN
     574          IF ( qvapincld_new .GT. qvapincld ) THEN
     575            !--Gamma distribution starting at qvapincld
     576            pdf_shape = ( mu_subl_pdf_lscp + 1. ) / qiceincld
     577            pdf_y = pdf_shape * ( qvapincld_new - qvapincld )
     578            pdf_e1 = GAMMAINC ( mu_subl_pdf_lscp + 1. , pdf_y )
     579            pdf_e2 = GAMMAINC ( mu_subl_pdf_lscp + 2. , pdf_y )
    490580
    491581            !--Tendencies and diagnostics
    492             dqvc_sub(i) = dqt_sub
     582            dcf_sub(i)  = - cldfra(i) * pdf_e1
     583            dqi_sub(i)  = - cldfra(i) * pdf_e2 / pdf_shape
     584            dqvc_sub(i) = dcf_sub(i) * qvapincld
    493585
    494586            !--Add tendencies
    495             cldfra(i) = cldfra(i) + dcf_sub(i)
    496             qcld(i)   = qcld(i) + dqt_sub
     587            cldfra(i) = MAX(0., cldfra(i) + dcf_sub(i))
     588            qcld(i)   = qcld(i) + dqvc_sub(i) + dqi_sub(i)
    497589            qvc(i)    = qvc(i) + dqvc_sub(i)
    498             clrfra(i) = clrfra(i) - dcf_sub(i)
    499             qclr(i)   = qclr(i) - dqt_sub
     590            clrfra(i) = MIN(1., clrfra(i) - dcf_sub(i))
     591            qclr(i)   = qclr(i) - dqvc_sub(i) - dqi_sub(i)
    500592          ENDIF ! qvapincld_new .GT. 0.
     593
     594
     595          !------------------------------------
     596          !--       PHASE ADJUSTMENT        --
     597          !------------------------------------
     598
     599          IF ( qvapincld_new .EQ. 0. ) THEN
     600            !--If all the ice has been sublimated, we sublimate
     601            !--completely the cloud and do not activate the dissipation
     602            !--process
     603            !--Tendencies and diagnostics
     604            dcf_sub(i) = - cldfra(i)
     605            dqvc_sub(i) = - qvc(i)
     606            dqi_sub(i) = - ( qcld(i) - qvc(i) )
     607
     608            cldfra(i) = 0.
     609            qcld(i) = 0.
     610            qvc(i) = 0.
     611            clrfra(i) = MIN(1., clrfra(i) - dcf_sub(i))
     612            qclr(i) = qclr(i) - dqvc_sub(i) - dqi_sub(i)
     613          ELSE
     614            !--Adjustment of the IWC to the new vapor in cloud
     615            !--(this can be either positive or negative)
     616            dqvc_adj(i) = ( qvapincld_new * cldfra(i) - qvc(i) )
     617            dqi_adj(i) = - dqvc_adj(i)
     618
     619            !--Add tendencies
     620            !--The vapor in the cloud is updated, but not qcld as it is constant
     621            !--through this process, as well as cldfra which is unmodified
     622            qvc(i) = MAX(0., MIN(qcld(i), qvc(i) + dqvc_adj(i)))
     623          ENDIF
    501624
    502625        ENDIF   ! qiceincld .LT. eps
    503626      ENDIF ! cldfra(i) .GT. eps
     627
     628      !--If there is a contrail induced cirrus, we restore it
     629      perscontfra(i) = perscontfra_ratio * cldfra(i)
    504630
    505631
     
    519645        !--Calculation of the properties of the PDF
    520646        !--Parameterization from IAGOS observations
    521         !--pdf_e1 and pdf_e2 will be reused below
     647        !--pdf_alpha, pdf_scale and pdf_gamma will be reused below
    522648
    523649        !--Coefficient for standard deviation:
     
    537663        pdf_alpha(i) = EXP( rhl_clr / 100. ) * pdf_e3
    538664       
    539         IF ( ok_warm_cloud ) THEN
    540           !--If the statistical scheme is activated, the standard deviation is adapted
    541           !--to depend on the pressure level. It is multiplied by ratqs, so that near the
    542           !--surface std is almost 0, and upper than about 450 hPa the std is left untouched
    543           pdf_std = pdf_std * ratqs(i)
    544         ENDIF
    545 
    546         pdf_e2 = GAMMA(1. + 1. / pdf_alpha(i))
    547         pdf_scale(i) = MAX(eps, pdf_std / SQRT( GAMMA(1. + 2. / pdf_alpha(i)) - pdf_e2**2 ))
    548         pdf_loc(i) = rhl_clr - pdf_scale(i) * pdf_e2
     665        !IF ( ok_warm_cloud ) THEN
     666        !  !--If the statistical scheme is activated, the standard deviation is adapted
     667        !  !--to depend on the pressure level. It is multiplied by ratqs, so that near the
     668        !  !--surface std is almost 0, and upper than about 450 hPa the std is left untouched
     669        !  pdf_std = pdf_std * ratqs(i)
     670        !ENDIF
     671
     672        pdf_gamma(i) = GAMMA(1. + 1. / pdf_alpha(i))
     673        pdf_scale(i) = MAX(eps, pdf_std / SQRT( &
     674                                    GAMMA(1. + 2. / pdf_alpha(i)) - pdf_gamma(i)**2 ))
     675        pdf_loc = rhl_clr - pdf_scale(i) * pdf_gamma(i)
    549676
    550677        !--Calculation of the newly condensed water and fraction (pronostic)
     
    553680
    554681        pdf_x = gamma_cond(i) * qsat(i) / qsatl(i) * 100.
    555         pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
     682        pdf_y = ( MAX( pdf_x - pdf_loc, 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    556683        pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    557         pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
    558         cf_cond = EXP( - pdf_y )
    559         qt_cond = ( pdf_e3 + pdf_loc(i) * cf_cond ) * qsatl(i) / 100.
    560 
    561         IF ( cf_cond .GT. eps ) THEN
    562 
    563           dcf_con(i) = clrfra(i) * cf_cond
    564           dqt_con = clrfra(i) * qt_cond
     684        pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_gamma(i)
     685        pdf_fra_above_nuc = EXP( - pdf_y )
     686        pdf_q_above_nuc = ( pdf_e3 + pdf_loc * pdf_fra_above_nuc ) * qsatl(i) / 100.
     687
     688        IF ( pdf_fra_above_nuc .GT. eps ) THEN
     689
     690          dcf_con(i) = clrfra(i) * pdf_fra_above_nuc
     691          dqt_con = clrfra(i) * pdf_q_above_nuc
    565692
    566693          !--Barriers (should be useless
     
    574701            qvapincld = gamma_cond(i) * qsat(i)
    575702            qiceincld = dqt_con / dcf_con(i) - gamma_cond(i) * qsat(i)
    576             qvapincld_new = QVAPINCLD_DEPSUB( &
    577                 qvapincld, qiceincld, temp(i), qsat(i), pplay(i), dtime / 2.)
    578             qvapincld = qvapincld_new
     703            tau_depsub = 1. / ( depo_coef_cirrus * qiceincld**(1./3.) * kappa_depsub )
     704            qvapincld_new = qsat(i) + ( qvapincld - qsat(i) ) * EXP( - dtime / 2. / tau_depsub )
    579705          ELSE
    580706            !--We keep the saturation adjustment hypothesis, and the vapor in the
    581707            !--newly formed cloud is set equal to the saturation vapor.
    582             qvapincld = qsat(i)
     708            qvapincld_new = qsat(i)
    583709          ENDIF
    584710
    585711          !--Tendency on cloud vapor and diagnostic
    586           dqvc_con(i) = qvapincld * dcf_con(i)
     712          dqvc_con(i) = qvapincld_new * dcf_con(i)
    587713          dqi_con(i) = dqt_con - dqvc_con(i)
    588714
    589715          !--Add tendencies
    590           cldfra(i)  = cldfra(i) + dcf_con(i)
     716          cldfra(i)  = MIN(1., cldfra(i) + dcf_con(i))
    591717          qcld(i)    = qcld(i) + dqt_con
    592718          qvc(i)     = qvc(i) + dqvc_con(i)
    593           clrfra(i)  = clrfra(i) - dcf_con(i)
     719          clrfra(i)  = MAX(0., clrfra(i) - dcf_con(i))
    594720          qclr(i)    = qclr(i) - dqt_con
    595721
     
    597723      ENDIF ! ( 1. - cldfra(i) ) .GT. eps
    598724
     725
     726      !--If there is a contrail induced cirrus, we save the ratio
     727      perscontfra_ratio = perscontfra(i) / MAX(eps, cldfra(i))
    599728
    600729      !--------------------------------------
     
    658787        clrfra_mix = N_cld_mix * RPI / cell_area(i) &
    659788                   * ( a_mix * ( 1. + bovera ) * L_mix + L_mix**2 )
     789        !--The fraction of clear sky mixed is
     790        !-- N_cld_mix * ( a * b - (a - L_mix) * (b - L_mix) ) * RPI / cell_area
     791        cldfra_mix = N_cld_mix * RPI / cell_area(i) &
     792                   * ( a_mix * ( 1. + bovera ) * L_mix - L_mix**2 )
    660793
    661794
     
    666799        !--semi-major axis (a_mix), on the entire cell heigh dz.
    667800        !--The increase in size is
    668         L_shear = coef_shear_lscp * shear(i) * dz(i) * dtime
     801        L_shear = coef_shear_lscp * shear(i) * dz * dtime
    669802        !--therefore, the fraction of clear sky mixed is
    670803        !-- N_cld_mix * ( (a + L_shear) * b - a * b ) * RPI / 2. / cell_area
     
    678811        !--mixed clouds are different.
    679812        clrfra_mix = clrfra_mix + shear_fra
    680 
     813        cldfra_mix = cldfra_mix + shear_fra
    681814
    682815        !-- PART 3 - CALCULATION OF THE MIXING PROPERTIES
    683816
    684         clrfra_mix = MIN( clrfra_mix, clrfra(i) )
     817        clrfra_mix = MAX(eps, MIN(clrfra(i), clrfra_mix))
     818        cldfra_mix = MAX(eps, MIN(cldfra(i), cldfra_mix))
    685819
    686820        !--We compute the limit vapor in clear sky where the mixed cloud could not
     
    690824        !--diagnostic, and if the cloud size is increased, we add the new vapor to the
    691825        !--cloud's vapor without condensing or sublimating ice crystals
    692         qvapinclr_lim = ( ( cldfra(i) + clrfra_mix ) * qsat(i) - qcld(i) ) / clrfra_mix
     826        IF ( ok_unadjusted_clouds .AND. .NOT. ok_warm_cloud ) THEN
     827          qiceinmix = ( qcld(i) - qvc(i) ) / cldfra(i) / ( 1. + clrfra_mix / cldfra_mix )
     828          tau_depsub = 1. / ( qiceinmix**(1./3.) * kappa_depsub )
     829          qvapinmix_lim = qsat(i) - qiceinmix / ( 1. - EXP( - dtime / tau_depsub ) )
     830          qvapinclr_lim = qvapinmix_lim * ( 1. + cldfra_mix / clrfra_mix ) &
     831                        - qvc(i) / cldfra(i) * cldfra_mix / clrfra_mix
     832        ELSE
     833          !--NB. if tau_depsub = 0, we get the same result as above
     834          qvapinclr_lim = qsat(i) * ( 1. + cldfra_mix / clrfra_mix ) &
     835                        - qcld(i) / cldfra(i) * cldfra_mix / clrfra_mix
     836        ENDIF
    693837
    694838        IF ( qvapinclr_lim .LT. 0. ) THEN
     
    696840          dcf_mix(i)  = clrfra_mix
    697841          dqvc_mix(i) = clrfra_mix * qclr(i) / clrfra(i)
    698           dqi_mix(i)  = 0.
    699842        ELSE
    700843          !--We then calculate the clear sky part where the humidity is lower than
     
    704847          !--because the clear sky fraction can only be reduced by condensation.
    705848          !--Thus the `pdf_xxx` variables are well defined.
    706           pdf_x = gamma_cond(i) * qsat(i) / qsatl(i) * 100.
    707           pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
     849
     850          rhl_clr = qclr(i) / clrfra(i) / qsatl(i) * 100.
     851          pdf_loc = rhl_clr - pdf_scale(i) * pdf_gamma(i)
     852          pdf_x = qvapinclr_lim / qsatl(i) * 100.
     853          pdf_y = ( MAX( pdf_x - pdf_loc, 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    708854          pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    709           pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
    710           pdf_fra_above_nuc = EXP( - pdf_y ) * clrfra(i)
    711           pdf_q_above_nuc = ( pdf_e3 * clrfra(i) &
    712                           + pdf_loc(i) * pdf_fra_above_nuc ) * qsatl(i) / 100.
    713 
    714           pdf_x = qvapinclr_lim / qsatl(i) * 100.
    715           pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    716           pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    717           pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
     855          pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_gamma(i)
    718856          pdf_fra_above_lim = EXP( - pdf_y ) * clrfra(i)
    719857          pdf_q_above_lim = ( pdf_e3 * clrfra(i) &
    720                           + pdf_loc(i) * pdf_fra_above_lim ) * qsatl(i) / 100.
     858                          + pdf_loc * pdf_fra_above_lim ) * qsatl(i) / 100.
    721859
    722860          pdf_fra_below_lim = clrfra(i) - pdf_fra_above_lim
    723           pdf_fra_above_lim = pdf_fra_above_lim - pdf_fra_above_nuc
    724           pdf_q_above_lim = pdf_q_above_lim - pdf_q_above_nuc
     861          pdf_q_below_lim = qclr(i) - pdf_q_above_lim
    725862
    726863          !--sigma_mix is the ratio of the surroundings of the clouds where mixing
     
    733870            dcf_mix(i)  = clrfra_mix * sigma_mix
    734871            dqvc_mix(i) = clrfra_mix * sigma_mix * pdf_q_above_lim / pdf_fra_above_lim
    735             dqi_mix(i)  = 0.
    736872          ENDIF
    737873
    738874          IF ( pdf_fra_below_lim .GT. eps ) THEN
    739             dcf_mix(i)  = dcf_mix(i)  - cldfra(i) * ( 1. - sigma_mix )
    740             dqvc_mix(i) = dqvc_mix(i) - cldfra(i) * ( 1. - sigma_mix ) &
    741                                                   * qvc(i) / cldfra(i)
    742             dqi_mix(i)  = dqi_mix(i)  - cldfra(i) * ( 1. - sigma_mix ) &
    743                                                   * ( qcld(i) - qvc(i) ) / cldfra(i)
     875            dcf_mix(i)  = dcf_mix(i)  - cldfra_mix * ( 1. - sigma_mix )
     876            dqvc_mix(i) = dqvc_mix(i) - cldfra_mix * ( 1. - sigma_mix ) &
     877                                      * qvc(i) / cldfra(i)
     878            dqi_mix(i)  = dqi_mix(i)  - cldfra_mix * ( 1. - sigma_mix ) &
     879                                      * ( qcld(i) - qvc(i) ) / cldfra(i)
    744880          ENDIF
     881
    745882        ENDIF
    746 
    747         !--Add tendencies
    748         cldfra(i)  = cldfra(i) + dcf_mix(i)
    749         qcld(i)    = qcld(i) + dqvc_mix(i) + dqi_mix(i)
    750         qvc(i)     = qvc(i) + dqvc_mix(i)
    751         clrfra(i)  = clrfra(i) - dcf_mix(i)
    752         qclr(i)    = qclr(i) - dqvc_mix(i) - dqi_mix(i)
    753      
    754883      ENDIF ! ( cldfra(i) .GT. eps ) .AND. ( clrfra(i) .GT. eps )
    755884
     
    812941        clrfra_mix = N_cld_mix * RPI / cell_area(i) &
    813942                   * ( a_mix * ( 1. + bovera ) * L_mix + L_mix**2 )
     943        !--The fraction of clear sky mixed is
     944        !-- N_cld_mix * ( a * b - (a - L_mix) * (b - L_mix) ) * RPI / cell_area
     945        cldfra_mix = N_cld_mix * RPI / cell_area(i) &
     946                   * ( a_mix * ( 1. + bovera ) * L_mix - L_mix**2 )
    814947       
    815948       
     
    823956        !--With this, the clouds increase in size along b only, by a factor
    824957        !--L_shear * SQRT(2.) / 2. (to account for the 45 degrees orientation of the wind)
    825         L_shear = coef_shear_contrails * shear(i) * dz(i) * dtime
     958        L_shear = coef_shear_contrails * shear(i) * dz * dtime
    826959        !--therefore, the fraction of clear sky mixed is
    827960        !-- N_cld_mix * ( a * (b + L_shear * SQRT(2.) / 2.) - a * b ) * RPI / 2. / cell_area
     
    835968        !--mixed clouds are different.
    836969        clrfra_mix = clrfra_mix + shear_fra
     970        cldfra_mix = cldfra_mix + shear_fra
    837971       
    838972       
    839973        !-- PART 3 - CALCULATION OF THE MIXING PROPERTIES
    840974       
    841         clrfra_mix = MIN( clrfra_mix, clrfra(i) )
     975        clrfra_mix = MAX(eps, MIN(clrfra(i), clrfra_mix))
     976        cldfra_mix = MAX(eps, MIN(cldfra(i), cldfra_mix))
    842977       
    843978        !--We compute the limit vapor in clear sky where the mixed cloud could not
     
    847982        !--diagnostic, and if the cloud size is increased, we add the new vapor to the
    848983        !--cloud's vapor without condensing or sublimating ice crystals
    849         qvapinclr_lim = ( ( contfra(i) + clrfra_mix ) * qsat(i) - qcont(i) ) / clrfra_mix
     984        qvapinclr_lim = qsat(i) * ( 1. + cldfra_mix / clrfra_mix ) &
     985                      - qcont(i) / contfra(i) * cldfra_mix / clrfra_mix
    850986
    851987        IF ( qvapinclr_lim .LT. 0. ) THEN
     
    853989          dcfa_mix(i) = clrfra_mix
    854990          dqta_mix(i) = clrfra_mix * qclr(i) / clrfra(i)
    855           dqia_mix(i) = 0.
    856991        ELSE
    857992          !--We then calculate the clear sky part where the humidity is lower than
     
    861996          !--because the clear sky fraction can only be reduced by condensation.
    862997          !--Thus the `pdf_xxx` variables are well defined.
    863           pdf_x = gamma_cond(i) * qsat(i) / qsatl(i) * 100.
    864           pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
     998
     999          rhl_clr = qclr(i) / clrfra(i) / qsatl(i) * 100.
     1000          pdf_loc = rhl_clr - pdf_scale(i) * pdf_gamma(i)
     1001          pdf_x = qvapinclr_lim / qsatl(i) * 100.
     1002          pdf_y = ( MAX( pdf_x - pdf_loc, 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    8651003          pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    866           pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
    867           pdf_fra_above_nuc = EXP( - pdf_y ) * clrfra(i)
    868           pdf_q_above_nuc = ( pdf_e3 * clrfra(i) &
    869                           + pdf_loc(i) * pdf_fra_above_nuc ) * qsatl(i) / 100.
    870 
    871           pdf_x = qvapinclr_lim / qsatl(i) * 100.
    872           pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    873           pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    874           pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
     1004          pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_gamma(i)
    8751005          pdf_fra_above_lim = EXP( - pdf_y ) * clrfra(i)
    8761006          pdf_q_above_lim = ( pdf_e3 * clrfra(i) &
    877                           + pdf_loc(i) * pdf_fra_above_lim ) * qsatl(i) / 100.
     1007                          + pdf_loc * pdf_fra_above_lim ) * qsatl(i) / 100.
    8781008
    8791009          pdf_fra_below_lim = clrfra(i) - pdf_fra_above_lim
    880           pdf_fra_above_lim = pdf_fra_above_lim - pdf_fra_above_nuc
    881           pdf_q_above_lim = pdf_q_above_lim - pdf_q_above_nuc
    8821010
    8831011          !--sigma_mix is the ratio of the surroundings of the clouds where mixing
     
    8931021            dcfa_mix(i) = clrfra_mix * sigma_mix
    8941022            dqta_mix(i) = clrfra_mix * sigma_mix * pdf_q_above_lim / pdf_fra_above_lim
    895             dqia_mix(i) = 0.
    8961023          ENDIF
    8971024
    8981025          IF ( pdf_fra_below_lim .GT. eps ) THEN
    899             dcfa_mix(i) = dcfa_mix(i) - contfra(i) * ( 1. - sigma_mix )
    900             dqta_mix(i) = dqta_mix(i) - contfra(i) * ( 1. - sigma_mix ) &
    901                                       * qcont(i) / contfra(i)
    902             dqia_mix(i) = dqia_mix(i) - contfra(i) * ( 1. - sigma_mix ) &
    903                                       * ( qcont(i) / contfra(i) - qsat(i) )
     1026            qvapincld = qcont(i) / contfra(i)
     1027            qiceincld = qvapincld - qsat(i)
     1028            dcfa_mix(i) = dcfa_mix(i) - cldfra_mix * ( 1. - sigma_mix )
     1029            dqta_mix(i) = dqta_mix(i) - cldfra_mix * ( 1. - sigma_mix ) * qvapincld
     1030            dqia_mix(i) = dqia_mix(i) - cldfra_mix * ( 1. - sigma_mix ) * qiceincld
    9041031          ENDIF
     1032
     1033        ENDIF
     1034      ENDIF ! ( contfra(i) .GT. eps ) .AND. ( clrfra(i) .GT.  eps )
     1035
     1036      IF ( contfra(i) .GT. eps ) THEN
     1037        !--We balance the mixing tendencies between the different cloud classes
     1038        mixed_fraction = dcf_mix(i) + dcfa_mix(i)
     1039        IF ( mixed_fraction .GT. clrfra(i) ) THEN
     1040          mixed_fraction = clrfra(i) / mixed_fraction
     1041          dcf_mix(i)  = dcf_mix(i)  * mixed_fraction
     1042          dqvc_mix(i) = dqvc_mix(i) * mixed_fraction
     1043          dqi_mix(i)  = dqi_mix(i)  * mixed_fraction
     1044          dcfa_mix(i) = dcfa_mix(i) * mixed_fraction
     1045          dqta_mix(i) = dqta_mix(i) * mixed_fraction
    9051046        ENDIF
    9061047
     
    9101051        clrfra(i)  = clrfra(i) - dcfa_mix(i)
    9111052        qclr(i)    = qclr(i) - dqta_mix(i)
    912 
    913       ENDIF ! ( contfra(i) .GT. eps ) .AND. ( clrfra(i) .GT.  eps )
     1053      ENDIF
     1054
     1055      !--Add tendencies
     1056      cldfra(i)  = cldfra(i) + dcf_mix(i)
     1057      qcld(i)    = qcld(i) + dqvc_mix(i) + dqi_mix(i)
     1058      qvc(i)     = qvc(i) + dqvc_mix(i)
     1059      clrfra(i)  = clrfra(i) - dcf_mix(i)
     1060      qclr(i)    = qclr(i) - dqvc_mix(i) - dqi_mix(i)
     1061
     1062      !--If there is a contrail induced cirrus, we restore it
     1063      perscontfra(i) = perscontfra_ratio * cldfra(i)
     1064
     1065
     1066      !---------------------------------------
     1067      !--         ICE SEDIMENTATION         --
     1068      !---------------------------------------
     1069      !
     1070      !--If ice supersaturation is activated, the cloud properties are prognostic.
     1071      !--The falling ice is then considered a new cloud in the gridbox.
     1072      !--BEWARE with this parameterisation, we can create a new cloud with a much
     1073      !--different ice water content and water vapor content than the existing cloud
     1074      !--(if it exists). This implies than unphysical fluxes of ice and vapor
     1075      !--occur between the existing cloud and the newly formed cloud (from sedimentation).
     1076      !--Note also that currently, the precipitation scheme assume a maximum
     1077      !--random overlap, meaning that the new formed clouds will not be affected
     1078      !--by vertical wind shear.
     1079      !
     1080      IF ( icesed_flux(i) .GT. 0. ) THEN
     1081
     1082        clrfra_sed = MIN(clrfra(i), cldfra_above(i) - cldfra(i))
     1083
     1084        IF ( ( clrfra_sed .GT. eps ) .AND. ( clrfra(i) .GT. eps ) ) THEN
     1085
     1086          qiceincld = qice_sedim(i) / cldfra_above(i)
     1087          IF ( ok_unadjusted_clouds .AND. .NOT. ok_warm_cloud ) THEN
     1088            tau_depsub = 1. / ( qiceincld**(1./3.) * kappa_depsub )
     1089            qvapinclr_lim = qsat(i) - qiceincld / ( 1. - EXP( - dtime / tau_depsub ) )
     1090          ELSE
     1091            qvapinclr_lim = qsat(i) - qiceincld
     1092          ENDIF
     1093
     1094          rhl_clr = qclr(i) / clrfra(i) / qsatl(i) * 100.
     1095          pdf_loc = rhl_clr - pdf_scale(i) * pdf_gamma(i)
     1096          pdf_x = qvapinclr_lim / qsatl(i) * 100.
     1097          pdf_y = ( MAX( pdf_x - pdf_loc, 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
     1098          pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
     1099          pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_gamma(i)
     1100          pdf_fra_above_lim = EXP( - pdf_y ) * clrfra(i)
     1101          pdf_q_above_lim = ( pdf_e3 * clrfra(i) &
     1102                          + pdf_loc * pdf_fra_above_lim ) * qsatl(i) / 100.
     1103
     1104          IF ( pdf_fra_above_lim .GT. eps ) THEN
     1105            dcf_sed(i)  = clrfra_sed * pdf_fra_above_lim / clrfra(i)
     1106            dqvc_sed(i) = dcf_sed(i) * pdf_q_above_lim / pdf_fra_above_lim
     1107            !--We include the sedimentated ice:
     1108            dqi_sed(i)  = qiceincld &    !--We include the sedimentated ice:
     1109                        * ( dcf_sed(i) & !--the part that falls in the newly formed cloud and
     1110                          + cldfra(i) )  !--the part that falls in the existing cloud
     1111                       
     1112          ENDIF
     1113
     1114        ELSE
     1115
     1116          dqi_sed(i) = qice_sedim(i)
     1117
     1118        ENDIF ! clrfra(i) .GT. eps
     1119
     1120        !--Add tendencies
     1121        cldfra(i)  = MIN(1., cldfra(i) + dcf_sed(i))
     1122        qcld(i)    = qcld(i) + dqvc_sed(i) + dqi_sed(i)
     1123        qvc(i)     = qvc(i) + dqvc_sed(i)
     1124        clrfra(i)  = MAX(0., clrfra(i) - dcf_sed(i))
     1125        !--We re-include sublimated sedimentated ice into clear sky water vapor
     1126        qclr(i)    = qclr(i) - dqvc_sed(i) + qice_sedim(i) - dqi_sed(i)
     1127
     1128      ENDIF ! qice_sedim(i) .GT. 0.
     1129
    9141130
    9151131      !--We put back contrails in the clouds class
     
    9191135
    9201136
    921       !--Diagnostics
    922       dcf_sub(i)  = dcf_sub(i)  / dtime
    923       dcf_con(i)  = dcf_con(i)  / dtime
    924       dcf_mix(i)  = dcf_mix(i)  / dtime
    925       dqi_adj(i)  = dqi_adj(i)  / dtime
    926       dqi_sub(i)  = dqi_sub(i)  / dtime
    927       dqi_con(i)  = dqi_con(i)  / dtime
    928       dqi_mix(i)  = dqi_mix(i)  / dtime
    929       dqvc_adj(i) = dqvc_adj(i) / dtime
    930       dqvc_sub(i) = dqvc_sub(i) / dtime
    931       dqvc_con(i) = dqvc_con(i) / dtime
    932       dqvc_mix(i) = dqvc_mix(i) / dtime
    933        
    9341137      !--Diagnose ISSRs
    9351138      IF ( clrfra(i) .GT. eps ) THEN
    936         !--We then calculate the part that is greater than qsat
    937         !--and lower than gamma_cond * qsat, which is the ice supersaturated region
    938         pdf_x = gamma_cond(i) * qsat(i) / qsatl(i) * 100.
    939         pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
     1139        rhl_clr = qclr(i) / clrfra(i) / qsatl(i) * 100.
     1140        pdf_loc = rhl_clr - pdf_scale(i) * pdf_gamma(i)
     1141        pdf_x = qsat(i) / qsatl(i) * 100.
     1142        pdf_y = ( MAX( pdf_x - pdf_loc, 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    9401143        pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    941         pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
    942         pdf_fra_above_nuc = EXP( - pdf_y ) * clrfra(i)
    943         pdf_q_above_nuc = ( pdf_e3 * clrfra(i) &
    944                         + pdf_loc(i) * pdf_fra_above_nuc ) * qsatl(i) / 100.
    945 
    946         pdf_x = qsat(i) / qsatl(i) * 100.
    947         pdf_y = ( MAX( pdf_x - pdf_loc(i), 0. ) / pdf_scale(i) ) ** pdf_alpha(i)
    948         pdf_e3 = GAMMAINC ( 1. + 1. / pdf_alpha(i) , pdf_y )
    949         pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_e2
     1144        pdf_e3 = pdf_scale(i) * ( 1. - pdf_e3 ) * pdf_gamma(i)
    9501145        issrfra(i) = EXP( - pdf_y ) * clrfra(i)
    951         qissr(i) = ( pdf_e3 * clrfra(i) + pdf_loc(i) * issrfra(i) ) * qsatl(i) / 100.
    952 
    953         issrfra(i) = issrfra(i) - pdf_fra_above_nuc
    954         qissr(i) = qissr(i) - pdf_q_above_nuc
     1146        qissr(i) = ( pdf_e3 * clrfra(i) + pdf_loc * issrfra(i) ) * qsatl(i) / 100.
     1147      ELSE
     1148        issrfra(i) = 0.
     1149        qissr(i) = 0.
    9551150      ENDIF
    9561151
     
    9691164      ENDIF ! cldfra .LT. eps
    9701165
     1166      !--Diagnostics
     1167      dcf_sub(i)  = dcf_sub(i)  / dtime
     1168      dcf_con(i)  = dcf_con(i)  / dtime
     1169      dcf_mix(i)  = dcf_mix(i)  / dtime
     1170      dcf_sed(i)  = dcf_sed(i)  / dtime
     1171      dqi_adj(i)  = dqi_adj(i)  / dtime
     1172      dqi_sub(i)  = dqi_sub(i)  / dtime
     1173      dqi_con(i)  = dqi_con(i)  / dtime
     1174      dqi_mix(i)  = dqi_mix(i)  / dtime
     1175      dqi_sed(i)  = dqi_sed(i)  / dtime
     1176      dqvc_adj(i) = dqvc_adj(i) / dtime
     1177      dqvc_sub(i) = dqvc_sub(i) / dtime
     1178      dqvc_con(i) = dqvc_con(i) / dtime
     1179      dqvc_mix(i) = dqvc_mix(i) / dtime
     1180      dqvc_sed(i) = dqvc_sed(i) / dtime
     1181
    9711182    ENDIF ! ( temp(i) .GT. temp_nowater ) .AND. .NOT. ok_weibull_warm_clouds
    9721183
     
    9831194  CALL contrails_formation( &
    9841195      klon, dtime, pplay, temp, qsat, qsatl, gamma_cond, &
    985       flight_dist, clrfra, pdf_loc, pdf_scale, pdf_alpha, keepgoing, &
     1196      flight_dist, clrfra, qclr, pdf_scale, pdf_alpha, pdf_gamma, &
     1197      keepgoing, pt_pron_clds, &
    9861198      Tcritcont, qcritcont, potcontfraP, potcontfraNP, &
    9871199      dcfa_ini, dqia_ini, dqta_ini)
    9881200
    9891201  DO i = 1, klon
    990     IF ( keepgoing(i) .AND. ( temp(i) .LE. temp_nowater ) ) THEN
     1202    IF ( keepgoing(i) .AND. pt_pron_clds(i) ) THEN
    9911203
    9921204      !--Convert existing contrail fraction into "natural" cirrus cloud fraction
    993       dcfa_cir(i) = contfra(i) * ( EXP( - dtime / linear_contrails_lifetime ) - 1. )
    994       dqta_cir(i) = qcont(i)   * ( EXP( - dtime / linear_contrails_lifetime ) - 1. )
     1205      IF ( cldfra(i) .GE. ( 1. - cfcon(i) - eps ) ) THEN
     1206        contrails_conversion_factor = 1.
     1207      ELSE
     1208        contrails_conversion_factor = ( 1. - &
     1209            !--First, the linear contrails are continuously degraded in induced cirrus
     1210            EXP( - dtime / linear_contrails_lifetime ) &
     1211            !--Second, if the cloud fills the entire gridbox, the linear contrails
     1212            !--cannot exist. The exponent is set so that this only happens for
     1213            !--very cloudy gridboxes
     1214            * ( 1. - cldfra(i) / ( 1. - cfcon(i) ) )**0.1 )
     1215      ENDIF
     1216      dcfa_cir(i) = - contrails_conversion_factor * contfra(i)
     1217      dqta_cir(i) = - contrails_conversion_factor * qcont(i)
    9951218
    9961219      !--Add tendencies
    9971220      issrfra(i) = MAX(0., issrfra(i) - dcfa_ini(i))
    9981221      qissr(i)   = MAX(0., qissr(i) - dqta_ini(i))
    999       cldfra(i)  = MAX(0., MIN(1. - cldfracv(i), cldfra(i) + dcfa_ini(i)))
    1000       qcld(i)    = MAX(0., MIN(qtot(i), qcld(i) + dqta_ini(i)))
     1222      clrfra(i)  = MAX(0., clrfra(i) - dcfa_ini(i))
     1223      qclr(i)    = MAX(0., qclr(i) - dqta_ini(i))
     1224
     1225      cldfra(i)  = MAX(0., MIN(1. - cfcon(i), cldfra(i) + dcfa_ini(i)))
     1226      qcld(i)    = MAX(0., MIN(qtot_in(i), qcld(i) + dqta_ini(i)))
    10011227      qvc(i)     = MAX(0., MIN(qcld(i), qvc(i) + dcfa_ini(i) * qsat(i)))
    10021228      contfra(i) = MAX(0., MIN(cldfra(i), contfra(i) + dcfa_cir(i) + dcfa_ini(i)))
    10031229      qcont(i)   = MAX(0., MIN(qcld(i), qcont(i) + dqta_cir(i) + dqta_ini(i)))
     1230      perscontfra(i) = perscontfra(i) - dcfa_cir(i)
    10041231
    10051232      !--Diagnostics
     
    10241251        cldfra(i) = 0.
    10251252        contfra(i)= 0.
     1253        perscontfra(i) = 0.
    10261254        qcld(i)   = 0.
    10271255        qvc(i)    = 0.
     1256        qcont(i)  = 0.
    10281257        qincld(i) = qsat(i)
    10291258      ELSE
     
    10361265      ENDIF
    10371266
     1267      IF ( perscontfra(i) .LT. eps ) perscontfra(i) = 0.
     1268
    10381269    ENDIF ! keepgoing
    10391270  ENDDO
     
    10441275!**********************************************************************************
    10451276
    1046 FUNCTION QVAPINCLD_DEPSUB( &
    1047     qvapincld, qiceincld, temp, qsat, pplay, dtime)
    1048 
    1049 USE lmdz_lscp_ini, ONLY: RV, RLSTT, RTT, RD, EPS_W
    1050 USE lmdz_lscp_ini, ONLY: depo_coef_cirrus, capa_cond_cirrus, rho_ice
    1051 USE lmdz_lscp_ini, ONLY: eps
    1052 
    1053 IMPLICIT NONE
    1054 
    1055 ! inputs
    1056 REAL :: qvapincld     !
    1057 REAL :: qiceincld     !
    1058 REAL :: temp          !
    1059 REAL :: qsat          !
    1060 REAL :: pplay         !
    1061 REAL :: dtime         ! time step [s]
    1062 ! outpu
    1063 REAL :: qvapincld_depsub
    1064 
    1065 !
    1066 ! local
    1067 REAL :: pres_sat, rho, kappa
    1068 REAL :: air_thermal_conduct, water_vapor_diff
    1069 REAL :: iwc
    1070 REAL :: iwc_log_inf100, iwc_log_sup100
    1071 REAL :: iwc_inf100, alpha_inf100, coef_inf100
    1072 REAL :: mu_sup100, sigma_sup100, coef_sup100
    1073 REAL :: Dm_ice, rm_ice
    1074 
    1075 !--If ok_unadjusted_clouds is set to TRUE, then the saturation adjustment
    1076 !--hypothesis is lost, and the vapor in the cloud is purely prognostic.
    1077 !
    1078 !--The deposition equation is
    1079 !-- dmi/dt = alpha*4pi*C*Svi / ( R_v*T/esi/Dv + Ls/ka/T * (Ls/R_v/T - 1) )
    1080 !--from Lohmann et al. (2016), where
    1081 !--alpha is the deposition coefficient [-]
    1082 !--mi is the mass of one ice crystal [kg]
    1083 !--C is the capacitance of an ice crystal [m]
    1084 !--Svi is the supersaturation ratio equal to (qvc - qsat)/qsat [-]
    1085 !--R_v is the specific gas constant for humid air [J/kg/K]
    1086 !--T is the temperature [K]
    1087 !--esi is the saturation pressure w.r.t. ice [Pa]
    1088 !--Dv is the diffusivity of water vapor [m2/s]
    1089 !--Ls is the specific latent heat of sublimation [J/kg/K]
    1090 !--ka is the thermal conductivity of dry air [J/m/s/K]
    1091 !
    1092 !--alpha is a coefficient to take into account the fact that during deposition, a water
    1093 !--molecule cannot join the crystal from everywhere, it must do so that the crystal stays
    1094 !--coherent (with the same structure). It has no impact for sublimation.
    1095 !--We fix alpha = depo_coef_cirrus (=0.5 by default following Lohmann et al. (2016))
    1096 !--during deposition, and alpha = 1. during sublimation.
    1097 !--The capacitance of the ice crystals is proportional to a parameter capa_cond_cirrus
    1098 !-- C = capa_cond_cirrus * rm_ice
    1099 !
    1100 !--We have qice = Nice * mi, where Nice is the ice crystal
    1101 !--number concentration per kg of moist air
    1102 !--HYPOTHESIS 1: the ice crystals are spherical, therefore
    1103 !-- mi = 4/3 * pi * rm_ice**3 * rho_ice
    1104 !--HYPOTHESIS 2: the ice crystals are monodisperse with the
    1105 !--initial radius rm_ice_0.
    1106 !--NB. this is notably different than the assumption
    1107 !--of a distributed qice in the cloud made in the sublimation process;
    1108 !--should it be consistent?
    1109 !
    1110 !--As the deposition process does not create new ice crystals,
    1111 !--and because we assume a same rm_ice value for all crystals
    1112 !--therefore the sublimation process does not destroy ice crystals
    1113 !--(or, in a limit case, it destroys all ice crystals), then
    1114 !--Nice is a constant during the sublimation/deposition process.
    1115 !-- dmi = dqi, et Nice = qi_0 / ( 4/3 RPI rm_ice_0**3 rho_ice )
    1116 !
    1117 !--The deposition equation then reads:
    1118 !-- dqi/dt = alpha*4pi*capa_cond_cirrus*rm_ice*(qvc-qsat)/qsat / ( R_v*T/esi/Dv + Ls/ka/T * (Ls/R_v/T - 1) ) * Nice
    1119 !-- dqi/dt = alpha*4pi*capa_cond_cirrus* (qi / qi_0)**(1/3) *rm_ice_0*(qvc-qsat)/qsat &
    1120 !--             / ( R_v*T/esi/Dv + Ls/ka/T * (Ls*R_v/T - 1) ) &
    1121 !--                         * qi_0 / ( 4/3 RPI rm_ice_0**3 rho_ice )
    1122 !-- dqi/dt = qi**(1/3) * (qvc - qsat) * qi_0**(2/3) &
    1123 !--  *alpha/qsat*capa_cond_cirrus/ (R_v*T/esi/Dv + Ls/ka/T*(Ls*R_v/T - 1)) / ( 1/3 rm_ice_0**2 rho_ice )
    1124 !--and we have
    1125 !-- dqvc/dt = - qi**(1/3) * (qvc - qsat) / kappa * alpha * qi_0**(2/3) / rm_ice_0**2
    1126 !-- dqi/dt  =   qi**(1/3) * (qvc - qsat) / kappa * alpha * qi_0**(2/3) / rm_ice_0**2
    1127 !--where kappa = 1/3*rho_ice/capa_cond_cirrus*qsat*(R_v*T/esi/Dv + Ls/ka/T*(Ls/R_v/T - 1))
    1128 !
    1129 !--This system of equations can be resolved with an exact
    1130 !--explicit numerical integration, having one variable resolved
    1131 !--explicitly, the other exactly. The exactly resolved variable is
    1132 !--the one decreasing, so it is qvc if the process is
    1133 !--condensation, qi if it is sublimation.
    1134 !
    1135 !--kappa is computed as an initialisation constant, as it depends only
    1136 !--on temperature and other pre-computed values
    1137 pres_sat = qsat / ( EPS_W + ( 1. - EPS_W ) * qsat ) * pplay
    1138 !--This formula for air thermal conductivity comes from Beard and Pruppacher (1971)
    1139 air_thermal_conduct = ( 5.69 + 0.017 * ( temp - RTT ) ) * 1.e-3 * 4.184
    1140 !--This formula for water vapor diffusivity comes from Hall and Pruppacher (1976)
    1141 water_vapor_diff = 0.211 * ( temp / RTT )**1.94 * ( 101325. / pplay ) * 1.e-4
    1142 kappa = 1. / 3. * rho_ice / capa_cond_cirrus * qsat &
    1143       * ( RV * temp / water_vapor_diff / pres_sat &
    1144         + RLSTT / air_thermal_conduct / temp * ( RLSTT / RV / temp - 1. ) )
    1145 !--NB. the greater kappa, the lower the efficiency of the deposition/sublimation process
    1146 
    1147 !--Dry density [kg/m3]
    1148 rho = pplay / temp / RD
    1149 
    1150 !--Here, the initial vapor in the cloud is qvapincld, and we compute
    1151 !--the new vapor qvapincld_new
    1152 
    1153 !--rm_ice formula from McFarquhar and Heymsfield (1997)
    1154 iwc = qiceincld * rho * 1e3
    1155 iwc_inf100 = MIN(iwc, 0.252 * iwc**0.837)
    1156 iwc_log_inf100 = LOG10( MAX(eps, iwc_inf100) )
    1157 iwc_log_sup100 = LOG10( MAX(eps, iwc - iwc_inf100) )
    1158 
    1159 alpha_inf100 = - 4.99E-3 - 0.0494 * iwc_log_inf100
    1160 coef_inf100 = iwc_inf100 * alpha_inf100**3 / 120.
    1161 
    1162 mu_sup100 = ( 5.2 + 0.0013 * ( temp - RTT ) ) &
    1163           + ( 0.026 - 1.2E-3 * ( temp - RTT ) ) * iwc_log_sup100
    1164 sigma_sup100 = ( 0.47 + 2.1E-3 * ( temp - RTT ) ) &
    1165              + ( 0.018 - 2.1E-4 * ( temp - RTT ) ) * iwc_log_sup100
    1166 coef_sup100 = ( iwc - iwc_inf100 ) / EXP( 3. * mu_sup100 + 4.5 * sigma_sup100**2 )
    1167 
    1168 Dm_ice = ( 2. / alpha_inf100 * coef_inf100 + EXP( mu_sup100 + 0.5 * sigma_sup100**2 ) &
    1169        * coef_sup100 ) / ( coef_inf100 + coef_sup100 )
    1170 rm_ice = Dm_ice / 2. * 1.E-6
    1171 
    1172 IF ( qvapincld .GE. qsat ) THEN
    1173   !--If the cloud is initially supersaturated
    1174   !--Exact explicit integration (qvc exact, qice explicit)
    1175   qvapincld_depsub = qsat + ( qvapincld - qsat ) &
    1176                    * EXP( - depo_coef_cirrus * dtime * qiceincld / kappa / rm_ice**2 )
    1177 ELSE
    1178   !--If the cloud is initially subsaturated
    1179   !--Exact explicit integration (qvc exact, qice explicit)
    1180   !--Same but depo_coef_cirrus = 1
    1181   qvapincld_depsub = qsat + ( qvapincld - qsat ) &
    1182                    * EXP( - dtime * qiceincld / kappa / rm_ice**2 )
    1183   IF ( qvapincld_depsub .GE. ( qvapincld + qiceincld ) ) &
    1184                    qvapincld_depsub = 0.
    1185 ENDIF ! qvapincld .GT. qsat
    1186 
    1187 END FUNCTION QVAPINCLD_DEPSUB
    1188 
    11891277END MODULE lmdz_lscp_condensation
Note: See TracChangeset for help on using the changeset viewer.