Ignore:
Timestamp:
Dec 6, 2022, 12:01:16 AM (22 months ago)
Author:
lguez
Message:

Sync latest trunk changes to Ocean_skin

Location:
LMDZ6/branches/Ocean_skin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Ocean_skin

  • LMDZ6/branches/Ocean_skin/libf/phylmd/cloudth_mod.F90

    r4013 r4368  
    2424#include "YOETHF.h"
    2525#include "FCTTRE.h"
    26 #include "thermcell.h"
    2726#include "nuage.h"
    2827
     
    269268#include "YOETHF.h"
    270269#include "FCTTRE.h"
    271 #include "thermcell.h"
    272270#include "nuage.h"
    273271     
     
    609607#include "YOETHF.h"
    610608#include "FCTTRE.h"
    611 #include "thermcell.h"
    612609#include "nuage.h"
    613610
     
    833830#include "YOETHF.h"
    834831#include "FCTTRE.h"
    835 #include "thermcell.h"
    836832#include "nuage.h"
    837833     
     
    11501146
    11511147      ELSE IF (iflag_cloudth_vert == 5) THEN
    1152       sigma1s=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5)+ratqs(ind1,ind2)*po(ind1) !Environment
     1148         sigma1s=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5) &
     1149              /(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5) &
     1150              +ratqs(ind1,ind2)*po(ind1) !Environment
    11531151      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
    11541152      !sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
     
    12951293#include "YOETHF.h"
    12961294#include "FCTTRE.h"
    1297 #include "thermcell.h"
    12981295#include "nuage.h"
    12991296
     
    14191416        !--------------------------------------------
    14201417      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)
    1421       sigma_env=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5)+ratqs(ind1,ind2)*po(ind1)
     1418      sigma_env=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5) &
     1419           /(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5) &
     1420           +ratqs(ind1,ind2)*po(ind1)
    14221421      xth=sth/(sqrt2*sigma_th)
    14231422      xenv=senv/(sqrt2*sigma_env)
     
    15391538
    15401539!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    1541 SUBROUTINE cloudth_mpc(klon,klev,ind2,mpc_bl_points,                     &
     1540SUBROUTINE cloudth_mpc(klon,klev,ind2,mpc_bl_points,                        &
    15421541&           temp,ztv,po,zqta,fraca,zpspsk,paprs,pplay,ztla,zthl,            &
    15431542&           ratqs,zqs,snowflux,qcloud,qincloud,icefrac,ctot,ctot_vol)
     
    15541553      USE ioipsl_getin_p_mod, ONLY : getin_p
    15551554      USE phys_output_var_mod, ONLY : cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
    1556       USE lscp_tools_mod, ONLY: CALC_QSAT_ECMWF, ICEFRAC_LSCP
    1557       USE phys_local_var_mod, ONLY : qlth, qith
     1555      USE lscp_tools_mod, ONLY: CALC_QSAT_ECMWF, FALLICE_VELOCITY
     1556      USE phys_local_var_mod, ONLY : qlth, qith, qsith, wiceth
    15581557
    15591558      IMPLICIT NONE
     
    15621561#include "YOETHF.h"
    15631562#include "FCTTRE.h"
    1564 #include "thermcell.h"
    15651563#include "nuage.h"
    15661564     
     
    15731571
    15741572      INTEGER, INTENT(IN)                         :: klon,klev,ind2
    1575       INTEGER, DIMENSION(klon,klev), INTENT(INOUT)   ::  mpc_bl_points ! 1 where BL MPC, 0 otherwise
     1573     
    15761574
    15771575      REAL, DIMENSION(klon,klev), INTENT(IN)      ::  temp          ! Temperature [K]
     
    15891587      REAL, DIMENSION(klon,klev+1), INTENT(IN)    ::  snowflux      ! snow flux at the interface of the layer [kg/m2/s]
    15901588
    1591 
     1589      INTEGER, DIMENSION(klon,klev), INTENT(INOUT) :: mpc_bl_points  ! grid points with convective (thermals) mixed phase clouds
     1590     
    15921591      REAL, DIMENSION(klon,klev), INTENT(OUT)      ::  ctot         ! Cloud fraction [0-1]
    15931592      REAL, DIMENSION(klon,klev), INTENT(OUT)      ::  ctot_vol     ! Volume cloud fraction [0-1]
     
    16001599
    16011600      INTEGER itap,ind1,l,ig,iter,k
    1602       LOGICAL flag_topthermals
    1603 
    1604 
    1605       REAL zqsatth(klon,klev), zqsatenv(klon,klev)
     1601      INTEGER iflag_topthermals, niter
     1602      LOGICAL falseklon(klon)
     1603
     1604      REAL zqsatth(klon), zqsatenv(klon), zqsatenvonly(klon)
    16061605      REAL sigma1(klon,klev)                                                         
    16071606      REAL sigma2(klon,klev)
     
    16141613      REAL cenv_vol(klon,klev)
    16151614      REAL rneb(klon,klev)
    1616       REAL zqenv(klon)   
    1617 
     1615      REAL zqenv(klon), zqth(klon), zqenvonly(klon)
    16181616      REAL qsatmmussig1,qsatmmussig2,sqrtpi,sqrt2,sqrt2pi,pi
    16191617      REAL rdd,cppd,Lv
     
    16241622      REAL xth1,xth2,xenv1,xenv2,deltasth, deltasenv
    16251623      REAL IntJ,IntI1,IntI2,IntI3,IntJ_CF,IntI1_CF,IntI3_CF,coeffqlenv,coeffqlth
    1626       REAL Tbef,zdelta,qsatbef,zcor
    1627       REAL qlbef,dqsatdt
     1624      REAL zdelta,qsatbef,zcor
     1625      REAL Tbefth(klon), Tbefenv(klon), Tbefenvonly(klon), rhoth(klon)
     1626      REAL qlbef
     1627      REAL dqsatenv(klon), dqsatth(klon), dqsatenvonly(klon)
    16281628      REAL erf
    16291629      REAL zpdf_sig(klon),zpdf_k(klon),zpdf_delta(klon)
     
    16321632      REAL zrho(klon,klev)
    16331633      REAL dz(klon,klev)
    1634       REAL qslth, qsith, qslenv, alenvl, aenvl
    1635       REAL sthi, sthl, althl, athl
     1634      REAL qslenv(klon), qslth(klon)
     1635      REAL alenvl, aenvl
     1636      REAL sthi, sthl, sthil, althl, athl, althi, athi, sthlc, deltasthc, sigma2sc
    16361637      REAL senvi, senvl, qbase, sbase, qliqth, qiceth
    1637       REAL qimax, ttarget, stmp, cout, coutref
     1638      REAL qmax, ttarget, stmp, cout, coutref, fraci
    16381639      REAL maxi, mini, pas, temp_lim
    1639       REAL deltazlev_mpc(klev),qth_mpc(klev), temp_mpc(klev), pres_mpc(klev), fraca_mpc(klev+1), snowf_mpc(klev+1)
    1640 
    1641       INTEGER, SAVE :: niter=20
     1640      REAL deltazlev_mpc(klev), temp_mpc(klev), pres_mpc(klev), fraca_mpc(klev+1), snowf_mpc(klev+1)
    16421641
    16431642      ! Modifty the saturation deficit PDF in thermals
     
    16451644      REAL,SAVE :: C_mpc
    16461645      !$OMP THREADPRIVATE(C_mpc)
     1646      REAL, SAVE    :: Ni,C_cap,Ei,d_top
     1647      !$OMP THREADPRIVATE(Ni,C_cap,Ei,d_top)
    16471648      ! Change the width of the PDF used for vertical subgrid scale heterogeneity
    16481649      ! (J Jouhaud, JL Dufresne, JB Madeleine)
     
    16921693      qlth(:,ind2)=0.
    16931694      qith(:,ind2)=0.
     1695      wiceth(:,ind2)=0.
    16941696      rneb(:,:)=0.
    16951697      qcloud(:)=0.
     
    17001702      cenv_vol(:,:)=0.
    17011703      ctot_vol(:,:)=0.
     1704      falseklon(:)=.false.
    17021705      qsatmmussig1=0.
    17031706      qsatmmussig2=0.
     
    17091712      sqrtpi=sqrt(pi)
    17101713      icefrac(:,ind2)=0.
     1714      althl=0.
     1715      althi=0.
     1716      athl=0.
     1717      athi=0.
     1718      senvl=0.
     1719      senvi=0.
     1720      sthi=0.
     1721      sthl=0.
     1722      sthil=0.
    17111723
    17121724
     
    17411753        WRITE(*,*) 'iflag_cloudth_vert_noratqs = ', iflag_cloudth_vert_noratqs
    17421754        ! Modifies the PDF in thermals when ice crystals are present
    1743         C_mpc=1.e2
     1755        C_mpc=1.e4
    17441756        CALL getin_p('C_mpc',C_mpc)
    17451757        WRITE(*,*) 'C_mpc = ', C_mpc
     1758        Ni=2.0e3
     1759        CALL getin_p('Ni', Ni)
     1760        WRITE(*,*) 'Ni = ', Ni
     1761        Ei=0.5
     1762        CALL getin_p('Ei', Ei)
     1763        WRITE(*,*) 'Ei = ', Ei
     1764        C_cap=0.5
     1765        CALL getin_p('C_cap', C_cap)
     1766        WRITE(*,*) 'C_cap = ', C_cap
     1767        d_top=1.2
     1768        CALL getin_p('d_top', d_top)
     1769        WRITE(*,*) 'd_top = ', d_top
    17461770
    17471771        firstcall=.FALSE.
     
    17591783      DO ind1=1,klon
    17601784            IF ((temp(ind1,ind2) .LT. RTT) .AND. (temp(ind1,ind2) .GT. temp_lim) &
    1761             .AND. (iflag_mpc_bl .GE. 2) .AND. (ind2<=klev-2)  &
     1785            .AND. (iflag_mpc_bl .GE. 1) .AND. (ind2<=klev-2)  &
    17621786            .AND. (ztv(ind1,1).GT.ztv(ind1,2)) .AND.(fraca(ind1,ind2).GT.1.e-10)) THEN
    17631787                mpc_bl_points(ind1,ind2)=1
     
    17721796!------------------------------------------------------------------------------- 
    17731797
    1774     DO ind1=1,klon
     1798! calculation of temperature, humidity and saturation specific humidity
     1799
     1800Tbefenv(:)=zthl(:,ind2)*zpspsk(:,ind2)
     1801Tbefth(:)=ztla(:,ind2)*zpspsk(:,ind2)
     1802Tbefenvonly(:)=temp(:,ind2)
     1803rhoth(:)=paprs(:,ind2)/Tbefth(:)/RD
     1804
     1805zqenv(:)=(po(:)-fraca(:,ind2)*zqta(:,ind2))/(1.-fraca(:,ind2)) !qt = a*qtth + (1-a)*qtenv
     1806zqth(:)=zqta(:,ind2)
     1807zqenvonly(:)=po(:)
     1808
     1809
     1810CALL CALC_QSAT_ECMWF(klon,Tbefenvonly,zqenvonly,paprs(:,ind2),RTT,0,.false.,zqsatenvonly,dqsatenv)
     1811
     1812CALL CALC_QSAT_ECMWF(klon,Tbefenv,zqenv,paprs(:,ind2),RTT,0,.false.,zqsatenv,dqsatenv)
     1813CALL CALC_QSAT_ECMWF(klon,Tbefenv,zqenv,paprs(:,ind2),RTT,1,.false.,qslenv,dqsatenv)
     1814
     1815CALL CALC_QSAT_ECMWF(klon,Tbefth,zqth,paprs(:,ind2),RTT,1,.false.,qslth,dqsatth)
     1816CALL CALC_QSAT_ECMWF(klon,Tbefth,zqth,paprs(:,ind2),RTT,2,.false.,qsith(:,ind2),dqsatth)
     1817CALL CALC_QSAT_ECMWF(klon,Tbefth,zqth,paprs(:,ind2),RTT,0,.false.,zqsatth,dqsatth)
     1818
     1819
     1820  DO ind1=1,klon
    17751821
    17761822
     
    17801826! Environment:
    17811827
    1782         zqenv(ind1)=(po(ind1)-fraca(ind1,ind2)*zqta(ind1,ind2))/(1.-fraca(ind1,ind2)) !qt = a*qtth + (1-a)*qtenv
    1783         Tbef=zthl(ind1,ind2)*zpspsk(ind1,ind2)
    1784            
    1785         CALL CALC_QSAT_ECMWF(Tbef,0.,paprs(ind1,ind2),RTT,0,.false.,qsatbef,dqsatdt)
    1786         zqsatenv(ind1,ind2)=qsatbef
    1787 
    1788         IF (Tbef .GE. RTT) THEN
     1828
     1829        IF (Tbefenv(ind1) .GE. RTT) THEN
    17891830               Lv=RLVTT
    17901831        ELSE
     
    17931834       
    17941835
    1795         alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)     !qsl, p84
     1836        alenv=(0.622*Lv*zqsatenv(ind1))/(rdd*zthl(ind1,ind2)**2)     !qsl, p84
    17961837        aenv=1./(1.+(alenv*Lv/cppd))                                      !al, p84
    1797         senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))                          !s, p84
     1838        senv=aenv*(po(ind1)-zqsatenv(ind1))                          !s, p84
    17981839     
    17991840        ! For MPCs:
    18001841        IF (mpc_bl_points(ind1,ind2) .EQ. 1) THEN
    1801         CALL CALC_QSAT_ECMWF(Tbef,0.,paprs(ind1,ind2),RTT,1,.false.,qslenv,dqsatdt)
    1802         alenvl=(0.622*RLVTT*qslenv)/(rdd*zthl(ind1,ind2)**2)     
     1842        alenvl=(0.622*RLVTT*qslenv(ind1))/(rdd*zthl(ind1,ind2)**2)     
    18031843        aenvl=1./(1.+(alenv*Lv/cppd))         
    1804         senvl=aenvl*(po(ind1)-qslenv)   
     1844        senvl=aenvl*(po(ind1)-qslenv(ind1))   
     1845        senvi=senv
    18051846        ENDIF
    18061847
     
    18081849! Thermals:
    18091850
    1810         Tbef=ztla(ind1,ind2)*zpspsk(ind1,ind2)
    1811         CALL CALC_QSAT_ECMWF(Tbef,0.,paprs(ind1,ind2),RTT,0,.false.,qsatbef,dqsatdt)
    1812         zqsatth(ind1,ind2)=qsatbef
    1813 
    1814         IF (Tbef .GE. RTT) THEN
     1851
     1852        IF (Tbefth(ind1) .GE. RTT) THEN
    18151853            Lv=RLVTT
    18161854        ELSE
     
    18191857
    18201858       
    1821         alth=(0.622*Lv*zqsatth(ind1,ind2))/(rdd*ztla(ind1,ind2)**2)       
     1859        alth=(0.622*Lv*zqsatth(ind1))/(rdd*ztla(ind1,ind2)**2)       
    18221860        ath=1./(1.+(alth*Lv/cppd))                                                         
    1823         sth=ath*(zqta(ind1,ind2)-zqsatth(ind1,ind2))                     
     1861        sth=ath*(zqta(ind1,ind2)-zqsatth(ind1))                     
    18241862
    18251863       ! For MPCs:
    18261864        IF (mpc_bl_points(ind1,ind2) .GT. 0) THEN
    1827          CALL CALC_QSAT_ECMWF(Tbef,0.,paprs(ind1,ind2),RTT,1,.false.,qslth,dqsatdt)
    1828          CALL CALC_QSAT_ECMWF(Tbef,0.,paprs(ind1,ind2),RTT,2,.false.,qsith,dqsatdt)
    1829          althl=(0.622*RLVTT*qslth)/(rdd*ztla(ind1,ind2)**2)                   
    1830          athl=1./(1.+(alth*RLVTT/cppd))                                       
    1831          sthl=athl*(zqta(ind1,ind2)-qslth)   
    1832          sthi=athl*(zqta(ind1,ind2)-qsith) 
     1865         althi=alth
     1866         althl=(0.622*RLVTT*qslth(ind1))/(rdd*ztla(ind1,ind2)**2)                   
     1867         athl=1./(1.+(alth*RLVTT/cppd))
     1868         athi=alth     
     1869         sthl=athl*(zqta(ind1,ind2)-qslth(ind1))   
     1870         sthi=athi*(zqta(ind1,ind2)-qsith(ind1,ind2)) 
     1871         sthil=athi*(zqta(ind1,ind2)-qslth(ind1))
    18331872        ENDIF     
    18341873
     
    19231962                ctot(ind1,ind2)=0.
    19241963                ctot_vol(ind1,ind2)=0.
    1925                 qcloud(ind1)=zqsatenv(ind1,ind2)
     1964                qcloud(ind1)=zqsatenv(ind1)
    19261965                qincloud(ind1)=0.
    19271966            ELSE               
     
    19411980            !...........
    19421981
     1982            qiceth=0.
    19431983            deltazlev_mpc=dz(ind1,:)
    19441984            temp_mpc=ztla(ind1,:)*zpspsk(ind1,:)
     
    19461986            fraca_mpc=fraca(ind1,:)
    19471987            snowf_mpc=snowflux(ind1,:)
    1948             qth_mpc=zqta(ind1,:)
    1949             flag_topthermals=.FALSE.
     1988            iflag_topthermals=0
    19501989            IF ((mpc_bl_points(ind1,ind2) .EQ. 1) .AND. (mpc_bl_points(ind1,ind2+1) .EQ. 0))  THEN
    1951                 flag_topthermals = .TRUE.
     1990                iflag_topthermals = 1
     1991            ELSE IF ((mpc_bl_points(ind1,ind2) .EQ. 1) .AND. (mpc_bl_points(ind1,ind2+1) .EQ. 1) &
     1992                    .AND. (mpc_bl_points(ind1,ind2+2) .EQ. 0) ) THEN
     1993                iflag_topthermals = 2
     1994            ELSE
     1995                iflag_topthermals = 0
    19521996            ENDIF
    19531997
    1954             CALL ICE_MPC_BL_CLOUDS(ind1,ind2,klev,flag_topthermals,temp_mpc,pres_mpc,qth_mpc,qlth(ind1,:),qith(ind1,:),deltazlev_mpc,snowf_mpc,fraca_mpc,qiceth)
    1955 
    1956 
    1957 
    1958             ! We account for the effect of ice crystals in thermals on sthl
    1959             ! and on the width of the distribution
    1960 
    1961             sthl=sthl*1./(1.+C_mpc*qiceth)  &
    1962                 + (1.-1./(1.+C_mpc*qiceth)) * athl*(zqta(ind1,ind2)-(qsith+qiceth)) 
    1963 
    1964             sthi=sthi*1./(1.+C_mpc*qiceth)  &
    1965                 + (1.-1./(1.+C_mpc*qiceth)) * athl*(zqta(ind1,ind2)-(qsith+qiceth)) 
    1966 
    1967            ! standard deviation of the water distribution in thermals
    1968             sth=sthl
    1969             senv=senvl
    1970             sigma2s=(sigma2s_factor*((MAX((sth-senv),0.)**2)**0.5)/((fraca(ind1,ind2)+0.02)**sigma2s_power))+0.002*zqta(ind1,ind2)
     1998            CALL ICE_MPC_BL_CLOUDS(ind1,ind2,klev,Ni,Ei,C_cap,d_top,iflag_topthermals,temp_mpc,pres_mpc,zqta(ind1,:), &
     1999                                   qsith(ind1,:),qlth(ind1,:),deltazlev_mpc,wiceth(ind1,:),fraca_mpc,qith(ind1,:))
     2000
     2001            ! qmax calculation
     2002            sigma2s=(sigma2s_factor*((MAX((sthl-senvl),0.)**2)**0.5)/((fraca(ind1,ind2)+0.02)**sigma2s_power))+0.002*zqta(ind1,ind2)
    19712003            deltasth=athl*vert_alpha_th*sigma2s
    1972      
    1973             ! Liquid phase
    1974             !.............
    19752004            xth1=-(sthl+deltasth)/(sqrt(2.)*sigma2s)
    1976             xth2=-(sthl-deltasth)/(sqrt(2.)*sigma2s)           
     2005            xth2=-(sthl-deltasth)/(sqrt(2.)*sigma2s)
    19772006            exp_xth1 = exp(-1.*xth1**2)
    19782007            exp_xth2 = exp(-1.*xth2**2)
     
    19842013            IntI1_CF=((sthl+deltasth)*(erf(xth2)-erf(xth1)))/(4*deltasth)
    19852014            IntI3_CF=(sqrt2*sigma2s*(exp_xth1-exp_xth2))/(4*sqrtpi*deltasth)
    1986             qliqth=IntJ+IntI1+IntI2+IntI3
    1987 
    1988             ! qimax calculation
    1989             xth1=-(sthi+deltasth)/(sqrt(2.)*sigma2s)
    1990             xth2=-(sthi-deltasth)/(sqrt(2.)*sigma2s)           
     2015            qmax=MAX(IntJ+IntI1+IntI2+IntI3,0.)
     2016
     2017
     2018            ! Liquid phase
     2019            !................
     2020            ! We account for the effect of ice crystals in thermals on sthl
     2021            ! and on the width of the distribution
     2022
     2023            sthlc=sthl*1./(1.+C_mpc*qith(ind1,ind2))  &
     2024                + (1.-1./(1.+C_mpc*qith(ind1,ind2))) * athl*(qsith(ind1,ind2)-qslth(ind1)) 
     2025
     2026            sigma2sc=(sigma2s_factor*((MAX((sthlc-senvl),0.)**2)**0.5) &
     2027                 /((fraca(ind1,ind2)+0.02)**sigma2s_power)) &
     2028                 +0.002*zqta(ind1,ind2)
     2029            deltasthc=athl*vert_alpha_th*sigma2sc
     2030     
     2031           
     2032            xth1=-(sthlc+deltasthc)/(sqrt(2.)*sigma2sc)
     2033            xth2=-(sthlc-deltasthc)/(sqrt(2.)*sigma2sc)           
    19912034            exp_xth1 = exp(-1.*xth1**2)
    19922035            exp_xth2 = exp(-1.*xth2**2)
    1993             IntJ=0.5*sthi*(1-erf(xth2))+(sigma2s/sqrt2pi)*exp_xth2
     2036            IntJ=0.5*sthlc*(1-erf(xth2))+(sigma2sc/sqrt2pi)*exp_xth2
    19942037            IntJ_CF=0.5*(1.-1.*erf(xth2))
    1995             IntI1=(((sthi+deltasth)**2+(sigma2s)**2)/(8*deltasth))*(erf(xth2)-erf(xth1))
    1996             IntI2=(sigma2s**2/(4*deltasth*sqrtpi))*(xth1*exp_xth1-xth2*exp_xth2)
    1997             IntI3=((sqrt2*sigma2s*(sthi+deltasth))/(4*sqrtpi*deltasth))*(exp_xth1-exp_xth2)
    1998             IntI1_CF=((sthi+deltasth)*(erf(xth2)-erf(xth1)))/(4*deltasth)
    1999             IntI3_CF=(sqrt2*sigma2s*(exp_xth1-exp_xth2))/(4*sqrtpi*deltasth)
    2000             qimax=IntJ+IntI1+IntI2+IntI3
    2001             qimax=qimax-qliqth
    2002 
     2038            IntI1=(((sthlc+deltasthc)**2+(sigma2sc)**2)/(8*deltasthc))*(erf(xth2)-erf(xth1))
     2039            IntI2=(sigma2sc**2/(4*deltasthc*sqrtpi))*(xth1*exp_xth1-xth2*exp_xth2)
     2040            IntI3=((sqrt2*sigma2sc*(sthlc+deltasthc))/(4*sqrtpi*deltasthc))*(exp_xth1-exp_xth2)
     2041            IntI1_CF=((sthlc+deltasthc)*(erf(xth2)-erf(xth1)))/(4*deltasthc)
     2042            IntI3_CF=(sqrt2*sigma2sc*(exp_xth1-exp_xth2))/(4*sqrtpi*deltasthc)
     2043            qliqth=IntJ+IntI1+IntI2+IntI3
     2044           
     2045            qlth(ind1,ind2)=MAX(0.,qliqth)
    20032046
    20042047            ! Condensed water
    2005             ! Guarantee the consistency between qiceth and the subgrid scale PDF of total water
    2006             qlth(ind1,ind2)=MAX(0.,qliqth)
    2007             qith(ind1,ind2)=MAX(0.,MIN(qiceth,qimax))
     2048           
    20082049            qcth(ind1,ind2)=qlth(ind1,ind2)+qith(ind1,ind2)
    20092050
     2051
     2052            ! consistency with subgrid distribution
     2053           
     2054             IF ((qcth(ind1,ind2) .GT. qmax) .AND. (qcth(ind1,ind2) .GT. 0)) THEN
     2055                 fraci=qith(ind1,ind2)/qcth(ind1,ind2)
     2056                 qcth(ind1,ind2)=qmax
     2057                 qith(ind1,ind2)=fraci*qmax
     2058                 qlth(ind1,ind2)=(1.-fraci)*qmax
     2059             ENDIF
     2060
     2061            ! Cloud Fraction
     2062            !...............
    20102063            ! calculation of qbase which is the value of the water vapor within mixed phase clouds
    20112064            ! such that the total water in cloud = qbase+qliqth+qiceth
     
    20152068           
    20162069            ttarget=qcth(ind1,ind2)
    2017             mini=athl*(qsith-qslth)
    2018             maxi=0.
     2070            mini= athl*(qsith(ind1,ind2)-qslth(ind1))
     2071            maxi= 0. !athl*(3.*sqrt(sigma2s))
     2072            niter=20
    20192073            pas=(maxi-mini)/niter
    20202074            stmp=mini
     
    20312085                ENDIF
    20322086            ENDDO
    2033             qbase=MAX(0., sbase/athl+qslth)
     2087            qbase=MAX(0., sbase/athl+qslth(ind1))
    20342088
    20352089            ! surface cloud fraction in thermals
     
    20532107              IntI1=(((sthl+deltasth-sbase)**2+(sigma2s)**2)/(8*deltasth))*(erf(xth2)-erf(xth1))
    20542108              IntI2=(sigma2s**2/(4*deltasth*sqrtpi))*(xth1*exp_xth1-xth2*exp_xth2)
    2055               IntI3=((sqrt2*sigma2s*(sth+deltasth))/(4*sqrtpi*deltasth))*(exp_xth1-exp_xth2)
     2109              IntI3=((sqrt2*sigma2s*(sthl+deltasth))/(4*sqrtpi*deltasth))*(exp_xth1-exp_xth2)
    20562110              IntI1_CF=((sthl-sbase+deltasth)*(erf(xth2)-erf(xth1)))/(4*deltasth)
    20572111              IntI3_CF=(sqrt2*sigma2s*(exp_xth1-exp_xth2))/(4*sqrtpi*deltasth)
     
    20592113            ENDIF
    20602114              cth_vol(ind1,ind2)=MIN(MAX(0.,cth_vol(ind1,ind2)),1.)
     2115
     2116
    20612117
    20622118            ! Environment
     
    21102166
    21112167           
    2112             ! Thermals + environment
     2168            ! Thermals + environment
     2169            ! =======================
    21132170            ctot(ind1,ind2)=fraca(ind1,ind2)*cth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv(ind1,ind2)
    21142171            qctot(ind1,ind2)=fraca(ind1,ind2)*qcth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qcenv(ind1,ind2)
    21152172            ctot_vol(ind1,ind2)=fraca(ind1,ind2)*cth_vol(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv_vol(ind1,ind2)
    21162173            IF (qcth(ind1,ind2) .GT. 0) THEN
    2117                 icefrac(ind1,ind2)=fraca(ind1,ind2)*qith(ind1,ind2)/(fraca(ind1,ind2)*qcth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qcenv(ind1,ind2))
     2174               icefrac(ind1,ind2)=fraca(ind1,ind2)*qith(ind1,ind2) &
     2175                    /(fraca(ind1,ind2)*qcth(ind1,ind2) &
     2176                    +(1.-1.*fraca(ind1,ind2))*qcenv(ind1,ind2))
    21182177                icefrac(ind1,ind2)=MAX(MIN(1.,icefrac(ind1,ind2)),0.)
    21192178            ELSE
     
    21252184                ctot_vol(ind1,ind2)=0.
    21262185                qincloud(ind1)=0.
    2127                 qcloud(ind1)=zqsatenv(ind1,ind2)
     2186                qcloud(ind1)=zqsatenv(ind1)
    21282187            ELSE               
    21292188                qcloud(ind1)=fraca(ind1,ind2)*(qcth(ind1,ind2)/cth(ind1,ind2)+qbase) &
    2130                             +(1.-1.*fraca(ind1,ind2))*(qcenv(ind1,ind2)/cenv(ind1,ind2)+qslenv)
     2189                            +(1.-1.*fraca(ind1,ind2))*(qcenv(ind1,ind2)/cenv(ind1,ind2)+qslenv(ind1))
    21312190                qincloud(ind1)=MAX(fraca(ind1,ind2)*(qcth(ind1,ind2)/cth(ind1,ind2)) &
    21322191                            +(1.-1.*fraca(ind1,ind2))*(qcenv(ind1,ind2)/cenv(ind1,ind2)),0.)
     
    21392198
    21402199     
    2141         zqenv(ind1)=po(ind1)
    2142         Tbef=temp(ind1,ind2)
    2143 
    2144         CALL CALC_QSAT_ECMWF(Tbef,0.,paprs(ind1,ind2),RTT,0,.false.,qsatbef,dqsatdt)
    2145         zqsatenv(ind1,ind2)=qsatbef
    2146 
    2147         IF (Tbef .GE. RTT) THEN
     2200
     2201
     2202        IF (Tbefenvonly(ind1) .GE. RTT) THEN
    21482203                Lv=RLVTT
    21492204        ELSE
     
    21532208
    21542209        zthl(ind1,ind2)=temp(ind1,ind2)*(101325./paprs(ind1,ind2))**(rdd/cppd)
    2155         alenv=(0.622*Lv*zqsatenv(ind1,ind2))/(rdd*zthl(ind1,ind2)**2)
     2210        alenv=(0.622*Lv*zqsatenvonly(ind1))/(rdd*zthl(ind1,ind2)**2)
    21562211        aenv=1./(1.+(alenv*Lv/cppd))
    2157         senv=aenv*(po(ind1)-zqsatenv(ind1,ind2))
     2212        senv=aenv*(po(ind1)-zqsatenvonly(ind1))
    21582213        sth=0.
    21592214     
    2160         sigma1s=ratqs(ind1,ind2)*zqenv(ind1)
     2215        sigma1s=ratqs(ind1,ind2)*zqenvonly(ind1)
    21612216        sigma2s=0.
    21622217
     
    21692224        IF (ctot(ind1,ind2).LT.1.e-3) THEN
    21702225          ctot(ind1,ind2)=0.
    2171           qcloud(ind1)=zqsatenv(ind1,ind2)
     2226          qcloud(ind1)=zqsatenvonly(ind1)
    21722227          qincloud(ind1)=0.
    21732228        ELSE
    2174           qcloud(ind1)=qctot(ind1,ind2)/ctot(ind1,ind2)+zqsatenv(ind1,ind2)
     2229          qcloud(ind1)=qctot(ind1,ind2)/ctot(ind1,ind2)+zqsatenvonly(ind1)
    21752230          qincloud(ind1)=MAX(qctot(ind1,ind2)/ctot(ind1,ind2),0.)
    21762231        ENDIF
     
    21862241
    21872242
    2188     ENDDO       !loop on klon
     2243    ENDDO       !loop on klon
     2244
     2245    ! Calcule ice fall velocity in thermals
     2246
     2247    CALL FALLICE_VELOCITY(klon,qith(:,ind2),Tbefth(:),rhoth(:),paprs(:,ind2),falseklon(:),wiceth(:,ind2))
    21892248
    21902249RETURN
     
    21942253
    21952254!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2196 SUBROUTINE ICE_MPC_BL_CLOUDS(ind1,ind2,klev,flag_topthermals,temp,pres,qth,qlth,qith,deltazlev,snowf,fraca,qi)
     2255SUBROUTINE ICE_MPC_BL_CLOUDS(ind1,ind2,klev,Ni,Ei,C_cap,d_top,iflag_topthermals,temp,pres,qth,qsith,qlth,deltazlev,vith,fraca,qith)
    21972256
    21982257! parameterization of ice for boundary
     
    22542313!=============================================================================
    22552314
    2256     USE lscp_tools_mod, ONLY: CALC_QSAT_ECMWF
    22572315    USE ioipsl_getin_p_mod, ONLY : getin_p
    22582316    USE phys_state_var_mod, ONLY : fm_therm, detr_therm, entr_therm
     
    22602318    IMPLICIT none
    22612319
    2262 
    22632320    INCLUDE "YOMCST.h"
    22642321    INCLUDE "nuage.h"
    22652322
    2266     INTEGER, INTENT(IN) :: ind1,ind2, klev ! horizontal and vertical indices and dimensions
    2267     LOGICAL, INTENT(IN) :: flag_topthermals ! uppermost layer of thermals ?
     2323    INTEGER, INTENT(IN) :: ind1,ind2, klev           ! horizontal and vertical indices and dimensions
     2324    INTEGER, INTENT(IN) :: iflag_topthermals         ! uppermost layer of thermals ?
     2325    REAL, INTENT(IN)    :: Ni                        ! ice number concentration [m-3]
     2326    REAL, INTENT(IN)    :: Ei                        ! ice-droplet collision efficiency
     2327    REAL, INTENT(IN)    :: C_cap                     ! ice crystal capacitance
     2328    REAL, INTENT(IN)    :: d_top                     ! cloud-top ice crystal mixing parameter
    22682329    REAL,  DIMENSION(klev), INTENT(IN) :: temp       ! temperature [K] within thermals
    22692330    REAL,  DIMENSION(klev), INTENT(IN) :: pres       ! pressure [Pa]
    22702331    REAL,  DIMENSION(klev), INTENT(IN) :: qth        ! mean specific water content in thermals [kg/kg]
     2332    REAL,  DIMENSION(klev), INTENT(IN) :: qsith        ! saturation specific humidity wrt ice in thermals [kg/kg]
    22712333    REAL,  DIMENSION(klev), INTENT(IN) :: qlth       ! condensed liquid water in thermals, approximated value [kg/kg]
    2272     REAL,  DIMENSION(klev), INTENT(IN) :: qith       ! condensed ice water , thermals [kg/kg]
    22732334    REAL,  DIMENSION(klev), INTENT(IN) :: deltazlev  ! layer thickness [m]
    2274     REAL,  DIMENSION(klev+1), INTENT(IN) :: snowf      ! snow flux at the upper inferface
     2335    REAL,  DIMENSION(klev), INTENT(IN) :: vith       ! ice crystal fall velocity [m/s]
    22752336    REAL,  DIMENSION(klev+1), INTENT(IN) :: fraca      ! fraction of the mesh covered by thermals
    2276 
    2277     REAL,  INTENT(OUT) :: qi        ! ice cloud specific content [kg/kg]
    2278 
    2279 
    2280     REAL, SAVE    :: Ni,  C_cap, Ei, d_top
    2281     !$OMP THREADPRIVATE(Ni, C_cap,Ei, d_top)
    2282     LOGICAL, SAVE :: firstcall = .TRUE.
    2283     !$OMP THREADPRIVATE(firstcall)
     2337    REAL,  DIMENSION(klev), INTENT(INOUT) :: qith       ! condensed ice water , thermals [kg/kg]
    22842338
    22852339
     
    22872341    REAL rho(klev)
    22882342    REAL unsurtaudet, unsurtaustardep, unsurtaurim
    2289     REAL qsl, qsi, dqs, AA, BB, Ka, Dv, rhoi
    2290     REAL  p0, t0
     2343    REAL qi, AA, BB, Ka, Dv, rhoi
     2344    REAL p0, t0, fp1, fp2
    22912345    REAL alpha, flux_term
    22922346    REAL det_term, precip_term, rim_term, dep_term
    22932347
    2294  
    2295     IF (firstcall) THEN
    2296         Ni=2.0e3
    2297         CALL getin_p('Ni', Ni)
    2298         WRITE(*,*) 'Ni = ', Ni
    2299 
    2300         Ei=0.5
    2301         CALL getin_p('Ei', Ei)
    2302         WRITE(*,*) 'Ei = ', Ei
    2303 
    2304         C_cap=0.5
    2305         CALL getin_p('C_cap', C_cap)
    2306         WRITE(*,*) 'C_cap = ', C_cap
    2307 
    2308         d_top=0.8
    2309         CALL getin_p('d_top', d_top)
    2310         WRITE(*,*) 'd_top = ', d_top
    2311 
    2312 
    2313         firstcall=.FALSE.
    2314     ENDIF
    2315 
    23162348
    23172349    ind2p1=ind2+1
    23182350    ind2p2=ind2+2
    2319 
    2320     ! Liquid water content:
    2321     !=====================
    2322     ! the liquid water content is not calculated in this routine
    2323 
    2324     ! Ice water content
    2325     ! ==================
    23262351
    23272352    rho=pres/temp/RD  ! air density kg/m3
     
    23342359
    23352360
    2336     IF (flag_topthermals) THEN ! uppermost thermals level, solve a third order polynomial with Cardan's method
     2361    IF (iflag_topthermals .GT. 0) THEN ! uppermost thermals levels
    23372362
    23382363    Dv=0.0001*0.211*(p0/pres(ind2))*((temp(ind2)/T0)**1.94) ! water vapor diffusivity in air, SI
    23392364
    23402365    ! Detrainment term:
     2366
    23412367    unsurtaudet=detr_therm(ind1,ind2)/rho(ind2)/deltazlev(ind2)
    23422368 
    2343     ! vertical flux
    2344    
    2345     flux_term=d_top*fm_therm(ind1,ind2)/deltazlev(ind2)
    23462369
    23472370    ! Deposition term
    2348     CALL CALC_QSAT_ECMWF(temp(ind2),0.,pres(ind2),RTT,2,.false.,qsi,dqs)
    2349     CALL CALC_QSAT_ECMWF(temp(ind2),0.,pres(ind2),RTT,1,.false.,qsl,dqs)
    23502371    AA=RLSTT/Ka/temp(ind2)*(RLSTT/RV/temp(ind2)-1.)
    2351     BB=1./(rho(ind2)*Dv*qsi)
    2352     unsurtaustardep=C_cap*(Ni**0.66)*(qsl-qsi)/qsi*4.*RPI/(AA+BB)*(6.*rho(ind2)/rhoi/RPI/Gamma(4.))**(0.33)
     2372    BB=1./(rho(ind2)*Dv*qsith(ind2))
     2373    unsurtaustardep=C_cap*(Ni**0.66)*(qth(ind2)-qsith(ind2))/qsith(ind2) &
     2374                    *4.*RPI/(AA+BB)*(6.*rho(ind2)/rhoi/RPI/Gamma(4.))**(0.33)
    23532375
    23542376    ! Riming term  neglected at this level
    23552377    !unsurtaurim=rho(ind2)*alpha*3./rhoi/2.*Ei*qlth(ind2)*((p0/pres(ind2))**0.4)
    23562378
    2357     qi=rho(ind2)*unsurtaustardep/MAX((rho(ind2)*unsurtaudet-flux_term),1E-12)
     2379    qi=fraca(ind2)*unsurtaustardep/MAX((d_top*unsurtaudet),1E-12)
    23582380    qi=MAX(qi,0.)**(3./2.)
    23592381
     
    23702392    ! Deposition term
    23712393
    2372     CALL CALC_QSAT_ECMWF(temp(ind2p1),0.,pres(ind2p1),RTT,2,.false.,qsi,dqs)
    2373     CALL CALC_QSAT_ECMWF(temp(ind2p1),0.,pres(ind2p1),RTT,1,.false.,qsl,dqs)
    23742394    AA=RLSTT/Ka/temp(ind2p1)*(RLSTT/RV/temp(ind2p1)-1.)
    2375     BB=1./(rho(ind2p1)*Dv*qsi)
    2376     unsurtaustardep=C_cap*(Ni**0.66)*(qsl-qsi)/qsi*4.*RPI/(AA+BB)*(6.*rho(ind2p1)/rhoi/RPI/Gamma(4.))**(0.33)
    2377     dep_term=rho(ind2p1)*(qith(ind2p1)**0.33)*unsurtaustardep
     2395    BB=1./(rho(ind2p1)*Dv*qsith(ind2p1))
     2396    unsurtaustardep=C_cap*(Ni**0.66)*(qth(ind2p1)-qsith(ind2p1)) &
     2397         /qsith(ind2p1)*4.*RPI/(AA+BB) &
     2398         *(6.*rho(ind2p1)/rhoi/RPI/Gamma(4.))**(0.33)
     2399    dep_term=rho(ind2p1)*fraca(ind2p1)*(qith(ind2p1)**0.33)*unsurtaustardep
    23782400 
    23792401    ! Riming term
    23802402
    23812403    unsurtaurim=rho(ind2p1)*alpha*3./rhoi/2.*Ei*qlth(ind2p1)*((p0/pres(ind2p1))**0.4)
    2382     rim_term=rho(ind2p1)*qith(ind2p1)*unsurtaurim
     2404    rim_term=rho(ind2p1)*fraca(ind2p1)*qith(ind2p1)*unsurtaurim
    23832405
    23842406    ! Precip term
    23852407
    2386     !precip_term=-1./deltazlev(ind2p1)*(fraca(ind2p2)*snowf(ind2p2)-fraca(ind2p1)*snowf(ind2p1))
    2387     ! We assume that there is no solid precipitation outside thermals (so no multiplication by fraca)
    2388     precip_term=-1./deltazlev(ind2p1)*(snowf(ind2p2)-snowf(ind2p1))
     2408    ! We assume that there is no solid precipitation outside thermals
     2409    ! so the precipitation flux within thermals is equal to the precipitation flux
     2410    ! at mesh-scale divided by  thermals fraction
     2411   
     2412    fp2=0.
     2413    fp1=0.
     2414    IF (fraca(ind2p1) .GT. 0.) THEN
     2415    fp2=-qith(ind2p2)*rho(ind2p2)*vith(ind2p2)*fraca(ind2p2)! flux defined positive upward
     2416    fp1=-qith(ind2p1)*rho(ind2p1)*vith(ind2p1)*fraca(ind2p1)
     2417    ENDIF
     2418
     2419    precip_term=-1./deltazlev(ind2p1)*(fp2-fp1)
    23892420
    23902421    ! Calculation in a top-to-bottom loop
    23912422
    23922423    IF (fm_therm(ind1,ind2p1) .GT. 0.) THEN
    2393        qi= 1./fm_therm(ind1,ind2p1)* &
    2394           (deltazlev(ind2p1)*(-rim_term-dep_term-det_term-precip_term) + &
    2395           fm_therm(ind1,ind2p2)*(qith(ind2p1)))
    2396     ELSE
    2397        qi=0.
    2398     ENDIF
    2399 
    2400     ENDIF ! flag_topthermals
    2401  
    2402     qi=MAX(0.,qi)
     2424          qi= 1./fm_therm(ind1,ind2p1)* &
     2425              (deltazlev(ind2p1)*(-rim_term-dep_term-det_term-precip_term) + &
     2426              fm_therm(ind1,ind2p2)*(qith(ind2p1)))
     2427    END IF
     2428
     2429    ENDIF ! top thermals
     2430
     2431    qith(ind2)=MAX(0.,qi)
    24032432
    24042433    RETURN
Note: See TracChangeset for help on using the changeset viewer.