3 !! 2015-12-10 Weiguo Wang added gfs scale-aware SAS scheme to HWRF
4 !! A description of this updated Scale-aware SAS can be found in the HWRF Scientific Documentation:
5 !! https://dtcenter.org/HurrWRF/users/docs/scientific_documents/HWRFv3.9a_ScientificDoc.pdf
8 MODULE module_cu_scalesas
12 !-----------------------------------------------------------------
13 SUBROUTINE CU_SCALESAS(DT,ITIMESTEP,STEPCU, &
14 RTHCUTEN,RQVCUTEN,RQCCUTEN,RQICUTEN, &
16 RAINCV,PRATEC,HTOP,HBOT, &
17 U3D,V3D,W,T3D,QV3D,QC3D,QI3D,PI3D,RHO3D, &
18 DZ8W,PCPS,P8W,XLAND,CU_ACT_FLAG, &
20 MOMMIX, & ! gopal's doing
21 PGCON,sas_mass_flux, &
22 pert_sas, ens_random_seed, ens_sasamp, &
23 shalconv,shal_pgcon, &
24 HPBL2D,EVAP2D,HEAT2D, & !Kwon for shallow convection
25 P_QI,P_FIRST_SCALAR, &
26 DX2D, DY, & ! Wang W for scale-aware cnv
27 SCALEFUN, SCALEFUN1, & !cnv scale functions
29 ids,ide, jds,jde, kds,kde, &
30 ims,ime, jms,jme, kms,kme, &
31 its,ite, jts,jte, kts,kte )
33 !-------------------------------------------------------------------
34 USE MODULE_GFS_MACHINE , ONLY : kind_phys
35 USE MODULE_GFS_FUNCPHYS , ONLY : gfuncphys
36 USE MODULE_GFS_PHYSCONS, grav => con_g, CP => con_CP, HVAP => con_HVAP &
37 &, RV => con_RV, FV => con_fvirt, T0C => con_T0C &
38 &, CVAP => con_CVAP, CLIQ => con_CLIQ &
39 &, EPS => con_eps, EPSM1 => con_epsm1 &
40 &, ROVCP => con_rocp, RD => con_rd
41 !-------------------------------------------------------------------
43 !-------------------------------------------------------------------
44 !-- U3D 3D u-velocity interpolated to theta points (m/s)
45 !-- V3D 3D v-velocity interpolated to theta points (m/s)
46 !-- TH3D 3D potential temperature (K)
47 !-- T3D temperature (K)
48 !-- QV3D 3D water vapor mixing ratio (Kg/Kg)
49 !-- QC3D 3D cloud mixing ratio (Kg/Kg)
50 !-- QI3D 3D ice mixing ratio (Kg/Kg)
51 !-- P8w 3D pressure at full levels (Pa)
52 !-- Pcps 3D pressure (Pa)
53 !-- PI3D 3D exner function (dimensionless)
54 !-- rr3D 3D dry air density (kg/m^3)
55 !-- RUBLTEN U tendency due to
56 ! PBL parameterization (m/s^2)
57 !-- RVBLTEN V tendency due to
58 ! PBL parameterization (m/s^2)
59 !-- RTHBLTEN Theta tendency due to
60 ! PBL parameterization (K/s)
61 !-- RQVBLTEN Qv tendency due to
62 ! PBL parameterization (kg/kg/s)
63 !-- RQCBLTEN Qc tendency due to
64 ! PBL parameterization (kg/kg/s)
65 !-- RQIBLTEN Qi tendency due to
66 ! PBL parameterization (kg/kg/s)
68 !-- MOMMIX MOMENTUM MIXING COEFFICIENT (can be set in the namelist)
69 !-- RUCUTEN U tendency due to Cumulus Momentum Mixing (gopal's doing for SAS)
70 !-- RVCUTEN V tendency due to Cumulus Momentum Mixing (gopal's doing for SAS)
72 !-- CP heat capacity at constant pressure for dry air (J/kg/K)
73 !-- GRAV acceleration due to gravity (m/s^2)
75 !-- RD gas constant for dry air (J/kg/K)
77 !-- P_QI species index for cloud ice
78 !-- dz8w dz between full levels (m)
79 !-- z height above sea level (m)
80 !-- PSFC pressure at the surface (Pa)
81 !-- UST u* in similarity theory (m/s)
82 !-- PBL PBL height (m)
83 !-- PSIM similarity stability function for momentum
84 !-- PSIH similarity stability function for heat
85 !-- HFX upward heat flux at the surface (W/m^2)
86 !-- QFX upward moisture flux at the surface (kg/m^2/s)
87 !-- TSK surface temperature (K)
88 !-- GZ1OZ0 log(z/z0) where z0 is roughness length
89 !-- WSPD wind speed at lowest model level (m/s)
90 !-- BR bulk Richardson number in surface layer
92 !-- rvovrd R_v divided by R_d (dimensionless)
93 !-- EP1 constant for virtual temperature (R_v/R_d - 1) (dimensionless)
94 !-- KARMAN Von Karman constant
95 !-- ids start index for i in domain
96 !-- ide end index for i in domain
97 !-- jds start index for j in domain
98 !-- jde end index for j in domain
99 !-- kds start index for k in domain
100 !-- kde end index for k in domain
101 !-- ims start index for i in memory
102 !-- ime end index for i in memory
103 !-- jms start index for j in memory
104 !-- jme end index for j in memory
105 !-- kms start index for k in memory
106 !-- kme end index for k in memory
107 !-- its start index for i in tile
108 !-- ite end index for i in tile
109 !-- jts start index for j in tile
110 !-- jte end index for j in tile
111 !-- kts start index for k in tile
112 !-- kte end index for k in tile
113 !-------------------------------------------------------------------
117 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde, &
118 ims,ime, jms,jme, kms,kme, &
119 its,ite, jts,jte, kts,kte, &
126 REAL, INTENT(IN) :: &
129 REAL, INTENT(IN) :: DY
130 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: DX2D
131 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: SCALEFUN,SCALEFUN1, & !updaft area fraction for deep and shallow cnv
132 SIGMU, SIGMU1 !updaft area fraction for deep and shallow cnv
135 REAL, OPTIONAL, INTENT(IN) :: PGCON,sas_mass_flux,shal_pgcon
136 INTEGER, OPTIONAL, INTENT(IN) :: shalconv
137 REAL(kind=kind_phys) :: PGCON_USE,SHAL_PGCON_USE,massf
138 logical,optional,intent(in) :: pert_sas
139 integer,optional,intent(in) :: ens_random_seed
140 real,optional,intent(in) :: ens_sasamp
141 INTEGER :: shalconv_use
142 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: &
147 REAL, DIMENSION(ims:ime, jms:jme, kms:kme), INTENT(INOUT) :: &
150 REAL, OPTIONAL, INTENT(IN) :: MOMMIX
152 REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, &
153 INTENT(IN) :: HPBL2D,EVAP2D,HEAT2D !Kwon for sha
155 REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN) :: &
158 REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT) :: &
161 REAL, DIMENSION(ims:ime, jms:jme), INTENT(OUT) :: &
165 LOGICAL, DIMENSION(IMS:IME,JMS:JME), INTENT(INOUT) :: &
169 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: &
183 !--------------------------- LOCAL VARS ------------------------------
185 REAL, DIMENSION(ims:ime, jms:jme) :: &
188 REAL, DIMENSION(its:ite, jts:jte) :: &
190 REAL, DIMENSION(its:ite, jts:jte) :: &
193 REAL (kind=kind_phys) :: &
199 REAL (kind=kind_phys), DIMENSION(its:ite) :: &
205 HPBL,EVAP,HEAT ! for shallow convection
207 REAL (kind=kind_phys), DIMENSION(its:ite) :: garea ! grid box area in m^2,
210 REAL (kind=kind_phys), DIMENSION(its:ite) :: SCALEFUN_out,SCALEFUN1_out,& !updraft area fraction for deep and shallow cnv
211 SIGMU_out,SIGMU1_out !updraft area fraction for deep and shallow cnv
214 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte+1) :: &
217 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte) :: &
230 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte) :: &
231 cnvw,cnvc,ud_mf,dd_mf,dt_mf ! *_mf not useful for HWRF. it is for transport
233 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte, 2) :: &
236 INTEGER, DIMENSION(its:ite) :: &
255 !-----------------------------------------------------------------------
257 ! write(0,*)' in scale-aware sas'
259 if(present(shalconv)) then
260 shalconv_use=shalconv
273 if(present(pgcon)) then
276 ! pgcon_use = 0.7 ! Gregory et al. (1997, QJRMS)
277 pgcon_use = 0.55 ! Zhang & Wu (2003,JAS), used in GFS (25km res spectral)
278 ! pgcon_use = 0.2 ! HWRF, for model tuning purposes
279 ! pgcon_use = 0.3 ! GFDL, or so I am told
281 ! For those attempting to tune pgcon:
283 ! The value of 0.55 comes from an observational study of
284 ! synoptic-scale deep convection and 0.7 came from an
285 ! incorrect fit to the same data. That value is likely
286 ! correct for deep convection at gridscales near that of GFS,
287 ! but is questionable in shallow convection, or for scales
288 ! much finer than synoptic scales.
290 ! Then again, the assumptions of SAS break down when the
291 ! gridscale is near the convection scale anyway. In a large
292 ! storm such as a hurricane, there is often no environment to
293 ! detrain into since adjancent gridsquares are also undergoing
294 ! active convection. Each gridsquare will no longer have many
295 ! updrafts and downdrafts. At sub-convective timescales, you
296 ! will find unstable columns for many (say, 5 second length)
297 ! timesteps in a real atmosphere during a convection cell's
298 ! lifetime, so forcing it to be neutrally stable is unphysical.
300 ! Hence, in scales near the convection scale (cells have
301 ! ~0.5-4km diameter in hurricanes), this parameter is more of a
302 ! tuning parameter to get a scheme that is inappropriate for
303 ! that resolution to do a reasonable job.
305 ! Your mileage might vary.
310 if(present(sas_mass_flux)) then
312 ! Use this to reduce the fluxes added by SAS to prevent
313 ! computational instability as a result of large fluxes.
315 massf=9e9 ! large number to disable check
318 if(present(shal_pgcon)) then
319 if(shal_pgcon>=0) then
320 shal_pgcon_use = shal_pgcon
322 ! shal_pgcon<0 means use deep pgcon
323 shal_pgcon_use = pgcon_use
326 ! Default: Same as deep convection pgcon
327 shal_pgcon_use = pgcon_use
328 ! Read the warning above though. It may be advisable for
329 ! these to be different.
334 CU_ACT_FLAG(I,J)=.TRUE.
349 PSFC(i,j)=P8w(i,kms,j)
353 if(igpvs.eq.0) CALL GFUNCPHYS
356 !------------- J LOOP (OUTER) --------------------------------------------------
358 big_outer_j_loop: DO J=jts,jte
360 ! --------------- compute zi and zl -----------------------------------------
368 ZI(I,K)=ZI(I,KM)+dz8w(i,km,j)
375 ZL(I,KM)=(ZI(I,K)+ZI(I,KM))*0.5
380 ZL(I,KTE)=2.*ZI(I,KTE)-ZL(I,KTE-1)
383 ! --------------- end compute zi and zl -------------------------------------
386 !!PS(i)=PSFC(i,j)*.001
387 PS(i)=PSFC(i,j) ! wang, in Pa
389 SLIMSK(i)=ABS(XLAND(i,j)-2.)
391 garea(I)=DX2D(i,j)*DY*2.0 ! grid box area in m^2
392 KCNV(I)=0 ! initialize KCNV
396 if(shalconv_use==1) then
398 HPBL(I) = HPBL2D(I,J) ! for shallow convection
399 EVAP(I) = EVAP2D(I,J) ! for shallow convection
400 HEAT(I) = HEAT2D(I,J) ! for shallow convection
412 !PRSL(I,K)=Pcps(i,k,j)*.001
413 PRSL(I,K)=Pcps(i,k,j) ! in Pa
414 PHIL(I,K)=ZL(I,K)*GRAV
415 !DOT(i,k)=-5.0E-4*GRAV*rho3d(i,k,j)*(w(i,k,j)+w(i,kp,j))
416 DOT(i,k)=-0.5*GRAV*rho3d(i,k,j)*(w(i,k,j)+w(i,kp,j)) ! in Pa
422 DEL(i,k)=PRSL(i,k)*GRAV/RD*dz8w(i,k,j)/T3D(i,k,j)
425 Q1(i,k)=QV3D(i,k,j)/(1.+QV3D(i,k,j))
427 QL(i,k,1)=QI3D(i,k,j)/(1.+QI3D(i,k,j))
428 QL(i,k,2)=QC3D(i,k,j)/(1.+QC3D(i,k,j))
429 !PRSLK(I,K)=(PRSL(i,k)*.01)**ROVCP
430 PRSLK(I,K)=(PRSL(i,k)*1.0e-5)**ROVCP ! prsl in Pa
437 PRSI(i,k)=PRSI(i,km)-del(i,km)
441 ! write(0,*)'dx2d=',dx2d(its,jts:jts+5)
443 ! write(0,*)'ps=',ps(its)
444 ! write(0,*)'del=',del(its,kts:kts+5)
445 ! write(0,*)'prsl=',prsl(its,kts:kts+5)
446 ! write(0,*)'dot=',dot(its,kts:kts+5)
448 ! 2016-03-22 near final version of scale-aware convection
449 call mfdeepcnv(im,im,kx,delt,del,prsl,ps,phil,ql, &
450 & q1,t1,u1,v1,cldwrk,rn,kbot,ktop,kcnv,nint(slimsk),garea, &
451 & dot,ncloud,ud_mf,dd_mf,dt_mf,cnvw,cnvc, SIGMU_out,SCALEFUN_out, &
452 & pert_sas, ens_random_seed, ens_sasamp)
455 RAINCV1(I,J)=RN(I)*1000./STEPCU
456 PRATEC1(I,J)=RN(I)*1000./(STEPCU * DT)
465 if_shallow_conv: if(shalconv_use==1) then
467 ! NMM calls the new shallow convection developed by J Han
468 ! (Added to WRF by Y.Kwon)
470 ! 2016-03-22 near final version of scale-aware convection
471 call mfshalcnv(im,im,kx,delt,del,prsl,ps,phil,ql, &
472 & q1,t1,u1,v1,rn,kbot,ktop,kcnv,nint(slimsk),garea, &
473 & dot,ncloud,hpbl,ud_mf,dt_mf,cnvw,cnvc,SIGMU1_out,SCALEFUN1_out, &
474 & pert_sas, ens_random_seed, ens_sasamp)
479 RAINCV2(I,J)=RN(I)*1000./STEPCU
480 PRATEC2(I,J)=RN(I)*1000./(STEPCU * DT)
485 ! NOTE: ARW should be able to call the new shalcnv here, but
486 ! they need to add the three new variables, so I'm leaving the
487 ! old shallow convection call here - Sam Trahan
489 !! removed CALL OLD_ARW_SHALCV(IM,IM,KX,DELT,DEL,PRSI,PRSL,PRSLK,KCNV,Q1,T1,DPSHC)
491 ! Shallow convection is untested for other cores.
494 endif if_shallow_conv
496 !! output updraft area fractions for deep and shallow cnv
498 SCALEFUN(I,J)=SCALEFUN_OUT(i)
499 SCALEFUN1(I,J)=SCALEFUN1_OUT(i)
500 SIGMU(I,J)=SIGMU_OUT(i)
501 SIGMU1(I,J)=SIGMU1_OUT(i)
506 RAINCV(I,J)= RAINCV1(I,J) + RAINCV2(I,J)
507 PRATEC(I,J)= PRATEC1(I,J) + PRATEC2(I,J)
514 RTHCUTEN(I,K,J)=(T1(I,K)-T3D(I,K,J))/PI3D(I,K,J)*RDELT
515 RQVCUTEN(I,K,J)=(Q1(I,K)/(1.-q1(i,k))-QV3D(I,K,J))*RDELT
519 !===============================================================================
520 ! ADD MOMENTUM MIXING TERM AS TENDENCIES. This is gopal's doing for SAS
521 ! MOMMIX is the reduction factor set to 0.7 by default. Because NMM has
522 ! divergence damping term, a reducion factor for cumulum mixing may be
523 ! required otherwise storms were too weak.
524 !===============================================================================
529 ! RUCUTEN(I,J,K)=MOMMIX*(U1(I,K)-U3D(I,K,J))*RDELT
530 ! RVCUTEN(I,J,K)=MOMMIX*(V1(I,K)-V3D(I,K,J))*RDELT
531 RUCUTEN(I,J,K)=(U1(I,K)-U3D(I,K,J))*RDELT
532 RVCUTEN(I,J,K)=(V1(I,K)-V3D(I,K,J))*RDELT
538 IF(P_QC .ge. P_FIRST_SCALAR)THEN
541 RQCCUTEN(I,K,J)=(QL(I,K,2)/(1.-ql(i,k,2))-QC3D(I,K,J))*RDELT
546 IF(P_QI .ge. P_FIRST_SCALAR)THEN
549 RQICUTEN(I,K,J)=(QL(I,K,1)/(1.-ql(i,k,1))-QI3D(I,K,J))*RDELT
554 ENDDO big_outer_j_loop ! Outer most J loop
556 END SUBROUTINE CU_SCALESAS
558 !====================================================================
559 SUBROUTINE scalesasinit(RTHCUTEN,RQVCUTEN,RQCCUTEN,RQICUTEN, &
561 RESTART,P_QC,P_QI,P_FIRST_SCALAR, &
563 ids, ide, jds, jde, kds, kde, &
564 ims, ime, jms, jme, kms, kme, &
565 its, ite, jts, jte, kts, kte )
566 !--------------------------------------------------------------------
568 !--------------------------------------------------------------------
569 LOGICAL , INTENT(IN) :: allowed_to_read,restart
570 INTEGER , INTENT(IN) :: ids, ide, jds, jde, kds, kde, &
571 ims, ime, jms, jme, kms, kme, &
572 its, ite, jts, jte, kts, kte
573 INTEGER , INTENT(IN) :: P_FIRST_SCALAR, P_QI, P_QC
575 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: &
580 REAL, DIMENSION( ims:ime , jms:jme , kms:kme ) , INTENT(OUT) :: &
581 RUCUTEN, & ! gopal's doing for SAS
584 INTEGER :: i, j, k, itf, jtf, ktf
592 IF(.not.restart .or. .not.allowed_to_read)THEN
593 !end of zhang's doing
608 IF (P_QC .ge. P_FIRST_SCALAR) THEN
618 IF (P_QI .ge. P_FIRST_SCALAR) THEN
629 END SUBROUTINE scalesasinit
631 !-----------------------------------------------------------------------
632 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
634 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
636 subroutine mfdeepcnv(im,ix,km,delt,delp,prslp,psp,phil,ql, &
637 & q1,t1,u1,v1,cldwrk,rn,kbot,ktop,kcnv,islimsk,garea, &
638 & dot,ncloud,ud_mf,dd_mf,dt_mf,cnvw,cnvc, sigmuout,scaldfunc, &
639 & pert_sas, ens_random_seed, ens_sasamp)
642 ! use machine , only : kind_phys
643 ! use funcphys , only : fpvs
644 ! use physcons, grav => con_g, cp => con_cp, hvap => con_hvap
645 USE MODULE_GFS_MACHINE, ONLY : kind_phys
646 USE MODULE_GFS_FUNCPHYS, ONLY : fpvs
647 USE MODULE_GFS_PHYSCONS, grav => con_g, cp => con_cp &
648 & , hvap => con_hvap &
649 &, rv => con_rv, fv => con_fvirt, t0c => con_t0c &
650 &, rd => con_rd, cvap => con_cvap, cliq => con_cliq &
651 &, eps => con_eps, epsm1 => con_epsm1
657 integer im, ix, km, ncloud, &
658 & kbot(im), ktop(im), kcnv(im)
660 real(kind=kind_phys) delt
661 real(kind=kind_phys) psp(im), delp(ix,km), prslp(ix,km)
662 real(kind=kind_phys) ps(im), del(ix,km), prsl(ix,km), &
663 & ql(ix,km,2),q1(ix,km), t1(ix,km), &
664 & u1(ix,km), v1(ix,km), &
665 ! & u1(ix,km), v1(ix,km), rcs(im),
666 & cldwrk(im), rn(im), garea(im), &
667 & dot(ix,km), phil(ix,km), &
668 & cnvw(ix,km),cnvc(ix,km), &
669 ! hchuang code change mass flux output
670 & ud_mf(im,km),dd_mf(im,km),dt_mf(im,km)
672 integer i, indx, jmn, k, kk, km1, n
673 integer, dimension(im), intent(in) :: islimsk
676 real(kind=kind_phys) clam, cxlamu, cxlamd, &
680 ! real(kind=kind_phys) detad
681 real(kind=kind_phys) adw, aup, aafac, &
682 & beta, betal, betas, &
685 & dellat, delta, desdt, dg, &
687 & dq, dqsdp, dqsdt, dt, &
688 & dt2, dtmax, dtmin, &
689 & dxcrtas, dxcrtuf, &
690 & dv1h, dv2h, dv3h, &
691 & dv1q, dv2q, dv3q, &
692 & dz, dz1, e1, edtmax, &
693 & edtmaxl, edtmaxs, el2orc, elocp, &
696 & evef, evfact, evfactl, fact1, &
698 & g, gamma, pprime, cm, &
700 & rain, rfact, shear, tfac, &
702 & w1, w1l, w1s, w2, &
703 & w2l, w2s, w3, w3l, &
704 & w3s, w4, w4l, w4s, &
707 ! & xqrch, mbdt, tem, &
708 & xqrch, tem, tem1, tem2, &
709 & ptem, ptem1, ptem2, &
712 logical,optional,intent(in) :: pert_sas
713 integer,optional,intent(in) :: ens_random_seed
714 real,optional,intent(in) :: ens_sasamp
716 integer kb(im), kbcon(im), kbcon1(im), &
717 & ktcon(im), ktcon1(im), ktconn(im), &
718 & jmin(im), lmin(im), kbmax(im), &
721 ! real(kind=kind_phys) aa1(im), acrt(im), acrtfct(im), &
722 real(kind=kind_phys) aa1(im), &
723 & umean(im), tauadv(im), gdx(im), &
724 & delhbar(im), delq(im), delq2(im), &
725 & delqbar(im), delqev(im), deltbar(im), &
726 & deltv(im), dtconv(im), edt(im), &
727 & edto(im), edtx(im), fld(im), &
728 & hcdo(im,km), hmax(im), hmin(im), &
729 & ucdo(im,km), vcdo(im,km),aa2(im), &
730 & pdot(im), po(im,km), &
731 & pwavo(im), pwevo(im), mbdt(im), &
732 & qcdo(im,km), qcond(im), qevap(im), &
733 & rntot(im), vshear(im), xaa0(im), &
734 & xk(im), xlamd(im), cina(im), &
735 & xmb(im), xmbmax(im), xpwav(im), &
736 & xpwev(im), xlamx(im), &
737 & delubar(im),delvbar(im)
739 real(kind=kind_phys) c0(im)
741 real(kind=kind_phys) cinpcr, cinpcrmx, cinpcrmn, &
742 & cinacr, cinacrmx, cinacrmn
745 ! parameters for updraft velocity calculation
746 real(kind=kind_phys) bet1, cd1, f1, gam1, &
749 !c physical parameters
750 parameter(g=grav,asolfac=0.89)
751 parameter(elocp=hvap/cp,el2orc=hvap*hvap/(rv*cp))
752 parameter(c0s=.002,c1=.002,d0=.01)
753 parameter(c0l=c0s*asolfac)
755 ! asolfac: aerosol-aware parameter based on Lim & Hong (2012)
756 ! asolfac= cx / c0s(=.002)
757 ! cx = min([-0.7 ln(Nccn) + 24]*1.e-4, c0s)
758 ! Nccn: CCN number concentration in cm^(-3)
759 ! Until a realistic Nccn is provided, typical Nccns are assumed
760 ! as Nccn=100 for sea and Nccn=7000 for land
762 parameter(cm=1.0,delta=fv)
763 parameter(fact1=(cvap-cliq)/rv,fact2=hvap/rv-fact1*t0c)
764 parameter(cthk=200.,dthk=25.)
765 parameter(cinpcrmx=180.,cinpcrmn=120.)
766 parameter(cinacrmx=-120.,cinacrmn=-120.)
767 parameter(bet1=1.875,cd1=.506,f1=2.0,gam1=.5)
768 parameter(betaw=.03,dxcrtas=8.e3,dxcrtuf=15.e3)
770 ! local variables and arrays
771 real(kind=kind_phys) pfld(im,km), to(im,km), qo(im,km), &
772 & uo(im,km), vo(im,km), qeso(im,km)
773 ! for updraft velocity calculation
774 real(kind=kind_phys) wu2(im,km), buo(im,km), drag(im,km)
775 real(kind=kind_phys) wc(im), scaldfunc(im), sigmagfm(im)
777 real(kind=kind_phys) sigmuout(im)
780 ! real(kind=kind_phys) tvo(im,km)
781 real(kind=kind_phys) qlko_ktcon(im), dellal(im,km), tvo(im,km), &
782 & dbyo(im,km), zo(im,km), &
783 & xlamue(im,km), xlamud(im,km), &
784 & fent1(im,km), fent2(im,km), frh(im,km), &
785 & heo(im,km), heso(im,km), &
786 & qrcd(im,km), dellah(im,km), dellaq(im,km), &
787 & dellau(im,km), dellav(im,km), hcko(im,km), &
788 & ucko(im,km), vcko(im,km), qcko(im,km), &
789 & eta(im,km), etad(im,km), zi(im,km), &
790 & qrcko(im,km), qrcdo(im,km), &
791 & pwo(im,km), pwdo(im,km), c0t(im,km), &
792 & tx1(im), sumx(im), cnvwt(im,km)
795 logical totflg, cnvflg(im), asqecflg(im), flg(im)
797 ! asqecflg: flag for the quasi-equilibrium assumption of Arakawa-Schubert
799 ! real(kind=kind_phys) pcrit(15), acritt(15), acrit(15)
800 !! save pcrit, acritt
801 ! data pcrit/850.,800.,750.,700.,650.,600.,550.,500.,450.,400.,
802 ! & 350.,300.,250.,200.,150./
803 ! data acritt/.0633,.0445,.0553,.0664,.075,.1082,.1521,.2216,
804 ! & .3151,.3677,.41,.5255,.7663,1.1686,1.6851/
805 !c gdas derived acrit
806 !c data acritt/.203,.515,.521,.566,.625,.665,.659,.688,
807 !c & .743,.813,.886,.947,1.138,1.377,1.896/
808 real(kind=kind_phys) tf, tcr, tcrf
809 parameter (tf=233.16, tcr=263.16, tcrf=1.0/(tcr-tf))
813 real*8 :: gasdev,ran1 !zhang
815 logical,save :: pert_sas_local !zhang
816 integer,save :: ens_random_seed_local,env_pp_local !zhang
817 integer :: ensda_physics_pert !zhang
818 real,save :: ens_sasamp_local !zhang
819 data ens_random_seed_local/0/
821 CHARACTER(len=3) :: env_memb,env_pp
822 if ( ens_random_seed_local .eq. 0 ) then
823 CALL nl_get_ensda_physics_pert(1,ensda_physics_pert)
824 ens_random_seed_local=ens_random_seed
825 env_pp_local=ensda_physics_pert
826 pert_sas_local=.false.
828 ! env_pp=1: do physics perturbations for ensda members, ens_random_seed must be 99
829 if ( env_pp_local .eq. 1 ) then
830 if ( ens_random_seed .ne. 99 ) then
831 pert_sas_local=.true.
832 ens_sasamp_local=ens_sasamp
834 ! ens_random_seed=99 do physics perturbation for ensemble forecasts, env_pp must be zero
835 ens_random_seed_local=ens_random_seed
836 pert_sas_local=pert_sas
837 ens_sasamp_local=ens_sasamp
840 ens_random_seed_local=ens_random_seed
841 pert_sas_local=pert_sas
842 ens_sasamp_local=ens_sasamp
844 print*, "DESAS ==", ens_random_seed_local,pert_sas_local,ens_sasamp_local,ensda_physics_pert
848 !c-----------------------------------------------------------------------
850 !************************************************************************
851 ! convert input Pa terms to Cb terms -- Moorthi
855 !************************************************************************
891 gdx(i) = sqrt(garea(i))
893 scaldfunc(i)=-1.0 ! initialized wang
900 if(islimsk(i) == 1) then
908 if(t1(i,k) > 273.16) then
911 tem = d0 * (t1(i,k) - 273.16)
913 c0t(i,k) = c0(i) * tem1
924 ! hchuang code change
934 ! acrit(k) = acritt(k) * (975. - pcrit(k))
940 dtmin = max(dt2, val )
943 dtmax = max(dt2, val )
944 !c model tunable parameters are all here
965 ! pgcon = 0.7 ! Gregory et al. (1997, QJRMS)
966 pgcon = 0.55 ! Zhang & Wu (2003,JAS)
977 !c define top layer for search of the downdraft originating layer
978 !c and the maximum thetae for updraft
989 if (prsl(i,k)*tx1(i) > 0.04) kmax(i) = k + 1
990 if (prsl(i,k)*tx1(i) > 0.45) kbmax(i) = k + 1
991 if (prsl(i,k)*tx1(i) > 0.70) kbm(i) = k + 1
995 kmax(i) = min(km,kmax(i))
996 kbmax(i) = min(kbmax(i),kmax(i))
997 kbm(i) = min(kbm(i),kmax(i))
1000 !c hydrostatic height assume zero terr and initially assume
1001 !c updraft entrainment rate as an inverse function of height
1005 zo(i,k) = phil(i,k) / g
1010 zi(i,k) = 0.5*(zo(i,k)+zo(i,k+1))
1011 xlamue(i,k) = clam / zi(i,k)
1012 ! xlamue(i,k) = max(xlamue(i,k), crtlamu)
1016 !c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1017 !c convert surface pressure to mb from cb
1021 if (k <= kmax(i)) then
1022 pfld(i,k) = prsl(i,k) * 10.0
1047 ! uo(i,k) = u1(i,k) * rcs(i)
1048 ! vo(i,k) = v1(i,k) * rcs(i)
1058 !c p is pressure of the layer (mb)
1059 !c t is temperature at t-dt (k)..tn
1060 !c q is mixing ratio at t-dt (kg/kg)..qn
1061 !c to is temperature at t+dt (k)... this is after advection and turbulan
1062 !c qo is mixing ratio at t+dt (kg/kg)..q1
1066 if (k <= kmax(i)) then
1067 qeso(i,k) = 0.01 * fpvs(to(i,k)) ! fpvs is in pa
1068 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
1070 qeso(i,k) = max(qeso(i,k), val1)
1072 qo(i,k) = max(qo(i,k), val2 )
1073 ! qo(i,k) = min(qo(i,k),qeso(i,k))
1074 ! tvo(i,k) = to(i,k) + delta * to(i,k) * qo(i,k)
1079 !c compute moist static energy
1083 if (k <= kmax(i)) then
1084 ! tem = g * zo(i,k) + cp * to(i,k)
1085 tem = phil(i,k) + cp * to(i,k)
1086 heo(i,k) = tem + hvap * qo(i,k)
1087 heso(i,k) = tem + hvap * qeso(i,k)
1088 !c heo(i,k) = min(heo(i,k),heso(i,k))
1093 !c determine level with largest moist static energy
1094 !c this is the level where updraft starts
1102 if (k <= kbm(i)) then
1103 if(heo(i,k) > hmax(i)) then
1113 if (k <= kmax(i)-1) then
1114 dz = .5 * (zo(i,k+1) - zo(i,k))
1115 dp = .5 * (pfld(i,k+1) - pfld(i,k))
1116 es = 0.01 * fpvs(to(i,k+1)) ! fpvs is in pa
1117 pprime = pfld(i,k+1) + epsm1 * es
1118 qs = eps * es / pprime
1119 dqsdp = - qs / pprime
1120 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
1121 dqsdt = qs * pfld(i,k+1) * desdt / (es * pprime)
1122 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
1123 dt = (g * dz + hvap * dqsdp * dp) / (cp * (1. + gamma))
1124 dq = dqsdt * dt + dqsdp * dp
1125 to(i,k) = to(i,k+1) + dt
1126 qo(i,k) = qo(i,k+1) + dq
1127 po(i,k) = .5 * (pfld(i,k) + pfld(i,k+1))
1134 if (k <= kmax(i)-1) then
1135 qeso(i,k) = 0.01 * fpvs(to(i,k)) ! fpvs is in pa
1136 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + epsm1*qeso(i,k))
1138 qeso(i,k) = max(qeso(i,k), val1)
1140 qo(i,k) = max(qo(i,k), val2 )
1141 ! qo(i,k) = min(qo(i,k),qeso(i,k))
1142 frh(i,k) = 1. - min(qo(i,k)/qeso(i,k), 1._kind_phys)
1143 heo(i,k) = .5 * g * (zo(i,k) + zo(i,k+1)) + &
1144 & cp * to(i,k) + hvap * qo(i,k)
1145 heso(i,k) = .5 * g * (zo(i,k) + zo(i,k+1)) + &
1146 & cp * to(i,k) + hvap * qeso(i,k)
1147 uo(i,k) = .5 * (uo(i,k) + uo(i,k+1))
1148 vo(i,k) = .5 * (vo(i,k) + vo(i,k+1))
1153 !c look for the level of free convection as cloud base
1161 if (flg(i) .and. k <= kbmax(i)) then
1162 if(k > kb(i) .and. heo(i,kb(i)) > heso(i,k)) then
1171 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
1176 totflg = totflg .and. (.not. cnvflg(i))
1182 ! pdot(i) = 10.* dot(i,kbcon(i))
1183 pdot(i) = 0.01 * dot(i,kbcon(i)) ! Now dot is in Pa/s
1187 !c turn off convection if pressure depth between parcel source level
1188 !c and cloud base is larger than a critical value, cinpcr
1192 if(islimsk(i) == 1) then
1203 if(pdot(i) <= w4) then
1204 tem = (pdot(i) - w4) / (w3 - w4)
1205 elseif(pdot(i) >= -w4) then
1206 tem = - (pdot(i) + w4) / (w4 - w3)
1215 ptem1= .5*(cinpcrmx-cinpcrmn)
1216 cinpcr = cinpcrmx - ptem * ptem1
1217 tem1 = pfld(i,kb(i)) - pfld(i,kbcon(i))
1219 ! randomly perturb the convection trigger
1220 !zz if( pert_sas_local .and. ens_random_seed_local .gt. 0 ) then
1221 if( pert_sas_local ) then
1222 !zz print*,"ens_random_seed==",ens_random_seed,ens_random_seed_local
1223 ens_random_seed_local=ran1(-ens_random_seed_local)*1000
1224 rr=2.0*ens_sasamp_local*ran1(-ens_random_seed_local)-ens_sasamp_local
1225 !zz print*, "zhang inde desas=a", cinpcr,ens_sasamp_local,ens_random_seed_local,cinpcr
1227 !zz print*, "zhang inde desas=b", cinpcr,ens_sasamp_local,ens_random_seed_local,cinpcr
1230 if(tem1 > cinpcr) then
1238 totflg = totflg .and. (.not. cnvflg(i))
1243 !c assume that updraft entrainment rate above cloud base is
1244 !c same as that at cloud base
1248 xlamx(i) = xlamue(i,kbcon(i))
1254 & (k > kbcon(i) .and. k < kmax(i))) then
1255 xlamue(i,k) = xlamx(i)
1260 !c specify a background (turbulent) detrainment rate for the updrafts
1264 if(cnvflg(i) .and. k < kmax(i)) then
1265 xlamud(i,k) = xlamx(i)
1266 ! xlamud(i,k) = crtlamd
1271 !c functions rapidly decreasing with height, mimicking a cloud ensemble
1272 !c (Bechtold et al., 2008)
1277 & (k > kbcon(i) .and. k < kmax(i))) then
1278 tem = qeso(i,k)/qeso(i,kbcon(i))
1285 !c final entrainment and detrainment rates as the sum of turbulent part and
1286 !c organized entrainment depending on the environmental relative humidity
1287 !c (Bechtold et al., 2008)
1291 if(cnvflg(i) .and. &
1292 & (k > kbcon(i) .and. k < kmax(i))) then
1293 tem = cxlamu * frh(i,k) * fent2(i,k)
1294 xlamue(i,k) = xlamue(i,k)*fent1(i,k) + tem
1295 ! tem1 = cxlamd * frh(i,k)
1296 ! xlamud(i,k) = xlamud(i,k) + tem1
1301 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1303 !c determine updraft mass flux for the subcloud layers
1308 if(k < kbcon(i) .and. k >= kb(i)) then
1309 dz = zi(i,k+1) - zi(i,k)
1310 tem = 0.5*(xlamud(i,k)+xlamud(i,k+1))
1311 ptem = 0.5*(xlamue(i,k)+xlamue(i,k+1))-tem
1312 eta(i,k) = eta(i,k+1) / (1. + ptem * dz)
1318 !c compute mass flux above cloud base
1326 if(k > kbcon(i) .and. k < kmax(i)) then
1327 dz = zi(i,k) - zi(i,k-1)
1328 tem = 0.5*(xlamud(i,k)+xlamud(i,k-1))
1329 ptem = 0.5*(xlamue(i,k)+xlamue(i,k-1))-tem
1330 eta(i,k) = eta(i,k-1) * (1 + ptem * dz)
1331 if(eta(i,k) <= 0.) then
1341 !c compute updraft cloud properties
1346 hcko(i,indx) = heo(i,indx)
1347 ucko(i,indx) = uo(i,indx)
1348 vcko(i,indx) = vo(i,indx)
1353 !c cloud property is modified by the entrainment process
1355 ! cm is an enhancement factor in entrainment rates for momentum
1360 if(k > kb(i) .and. k < kmax(i)) then
1361 dz = zi(i,k) - zi(i,k-1)
1362 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1363 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
1364 factor = 1. + tem - tem1
1365 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5* &
1366 & (heo(i,k)+heo(i,k-1)))/factor
1367 dbyo(i,k) = hcko(i,k) - heso(i,k)
1369 tem = 0.5 * cm * tem
1373 ucko(i,k) = ((1.-tem)*ucko(i,k-1)+ptem*uo(i,k) &
1374 & +ptem1*uo(i,k-1))/factor
1375 vcko(i,k) = ((1.-tem)*vcko(i,k-1)+ptem*vo(i,k) &
1376 & +ptem1*vo(i,k-1))/factor
1382 !c taking account into convection inhibition due to existence of
1383 !c dry layers below cloud base
1391 if (flg(i) .and. k < kmax(i)) then
1392 if(k >= kbcon(i) .and. dbyo(i,k) > 0.) then
1401 if(kbcon1(i) == kmax(i)) cnvflg(i) = .false.
1406 tem = pfld(i,kbcon(i)) - pfld(i,kbcon1(i))
1415 totflg = totflg .and. (.not. cnvflg(i))
1420 !c calculate convective inhibition
1425 if(k > kb(i) .and. k < kbcon1(i)) then
1426 dz1 = zo(i,k+1) - zo(i,k)
1427 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1428 rfact = 1. + delta * cp * gamma &
1430 cina(i) = cina(i) + &
1431 ! & dz1 * eta(i,k) * (g / (cp * to(i,k)))
1432 & dz1 * (g / (cp * to(i,k))) &
1433 & * dbyo(i,k) / (1. + gamma) &
1436 cina(i) = cina(i) + &
1437 ! & dz1 * eta(i,k) * g * delta *
1438 & dz1 * g * delta * &
1439 & max(val,(qeso(i,k) - qo(i,k)))
1447 ! if(islimsk(i) == 1) then
1458 ! if(pdot(i) <= w4) then
1459 ! tem = (pdot(i) - w4) / (w3 - w4)
1460 ! elseif(pdot(i) >= -w4) then
1461 ! tem = - (pdot(i) + w4) / (w4 - w3)
1467 ! tem = max(tem,val1)
1469 ! tem = min(tem,val2)
1471 ! tem1= .5*(cinacrmx-cinacrmn)
1472 ! cinacr = cinacrmx - tem * tem1
1475 if(cina(i) < cinacr) cnvflg(i) = .false.
1481 totflg = totflg .and. (.not. cnvflg(i))
1486 !c determine first guess cloud top as the level of zero buoyancy
1494 if (flg(i) .and. k < kmax(i)) then
1495 if(k > kbcon1(i) .and. dbyo(i,k) < 0.) then
1505 if(ktcon(i) == 1 .and. ktconn(i) > 1) then
1506 ktcon(i) = ktconn(i)
1508 tem = pfld(i,kbcon(i))-pfld(i,ktcon(i))
1509 if(tem < cthk) cnvflg(i) = .false.
1515 totflg = totflg .and. (.not. cnvflg(i))
1520 !c search for downdraft originating level above theta-e minimum
1524 hmin(i) = heo(i,kbcon1(i))
1531 if (cnvflg(i) .and. k <= kbmax(i)) then
1532 if(k > kbcon1(i) .and. heo(i,k) < hmin(i)) then
1540 !c make sure that jmin(i) is within the cloud
1544 jmin(i) = min(lmin(i),ktcon(i)-1)
1545 jmin(i) = max(jmin(i),kbcon1(i)+1)
1546 if(jmin(i) >= ktcon(i)) cnvflg(i) = .false.
1550 !c specify upper limit of mass flux at cloud base
1557 dp = 1000. * del(i,k)
1558 xmbmax(i) = dp / (g * dt2)
1559 ! mbdt(i) = 0.1 * dp / g
1561 ! tem = dp / (g * dt2)
1562 ! xmbmax(i) = min(tem, xmbmax(i))
1566 !c compute cloud moisture property and precipitation
1571 qcko(i,kb(i)) = qo(i,kb(i))
1572 qrcko(i,kb(i)) = qo(i,kb(i))
1579 if(k > kb(i) .and. k < ktcon(i)) then
1580 dz = zi(i,k) - zi(i,k-1)
1581 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1583 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1585 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1586 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
1587 factor = 1. + tem - tem1
1588 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
1589 & (qo(i,k)+qo(i,k-1)))/factor
1590 qrcko(i,k) = qcko(i,k)
1592 dq = eta(i,k) * (qcko(i,k) - qrch)
1594 ! rhbar(i) = rhbar(i) + qo(i,k) / qeso(i,k)
1596 !c check if there is excess moisture to release latent heat
1598 if(k >= kbcon(i) .and. dq > 0.) then
1599 etah = .5 * (eta(i,k) + eta(i,k-1))
1600 if(ncloud > 0 .and. k > jmin(i)) then
1601 dp = 1000. * del(i,k)
1602 ptem = c0t(i,k) + c1
1603 qlk = dq / (eta(i,k) + etah * ptem * dz)
1604 dellal(i,k) = etah * c1 * dz * qlk * g / dp
1606 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
1608 ! aa1(i) = aa1(i) - dz * g * qlk * etah
1609 ! aa1(i) = aa1(i) - dz * g * qlk
1610 buo(i,k) = buo(i,k) - g * qlk
1611 qcko(i,k) = qlk + qrch
1612 pwo(i,k) = etah * c0t(i,k) * dz * qlk
1613 pwavo(i) = pwavo(i) + pwo(i,k)
1614 ! cnvwt(i,k) = (etah*qlk + pwo(i,k)) * g / dp
1615 cnvwt(i,k) = etah * qlk * g / dp
1618 ! compute buoyancy and drag for updraft velocity
1620 if(k >= kbcon(i)) then
1621 rfact = 1. + delta * cp * gamma &
1623 buo(i,k) = buo(i,k) + (g / (cp * to(i,k))) &
1624 & * dbyo(i,k) / (1. + gamma) &
1627 buo(i,k) = buo(i,k) + g * delta * &
1628 & max(val,(qeso(i,k) - qo(i,k)))
1629 drag(i,k) = max(xlamue(i,k),xlamud(i,k))
1638 ! if(cnvflg(i)) then
1639 ! indx = ktcon(i) - kb(i) - 1
1640 ! rhbar(i) = rhbar(i) / float(indx)
1644 !c calculate cloud work function
1648 ! if (cnvflg(i)) then
1649 ! if(k >= kbcon(i) .and. k < ktcon(i)) then
1650 ! dz1 = zo(i,k+1) - zo(i,k)
1651 ! gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1652 ! rfact = 1. + delta * cp * gamma
1653 ! & * to(i,k) / hvap
1655 !! & dz1 * eta(i,k) * (g / (cp * to(i,k)))
1656 ! & dz1 * (g / (cp * to(i,k)))
1657 ! & * dbyo(i,k) / (1. + gamma)
1661 !! & dz1 * eta(i,k) * g * delta *
1662 ! & dz1 * g * delta *
1663 ! & max(val,(qeso(i,k) - qo(i,k)))
1669 ! calculate cloud work function
1679 if(k >= kbcon(i) .and. k < ktcon(i)) then
1680 dz1 = zo(i,k+1) - zo(i,k)
1681 ! aa1(i) = aa1(i) + buo(i,k) * dz1 * eta(i,k)
1682 aa1(i) = aa1(i) + buo(i,k) * dz1
1689 if(cnvflg(i) .and. aa1(i) <= 0.) cnvflg(i) = .false.
1694 totflg = totflg .and. (.not. cnvflg(i))
1699 !c estimate the onvective overshooting as the level
1700 !c where the [aafac * cloud work function] becomes zero,
1701 !c which is the final cloud top
1705 aa2(i) = aafac * aa1(i)
1716 if(k >= ktcon(i) .and. k < kmax(i)) then
1717 dz1 = zo(i,k+1) - zo(i,k)
1718 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1719 rfact = 1. + delta * cp * gamma &
1722 ! & dz1 * eta(i,k) * (g / (cp * to(i,k)))
1723 & dz1 * (g / (cp * to(i,k))) &
1724 & * dbyo(i,k) / (1. + gamma) &
1728 !! & dz1 * eta(i,k) * g * delta *
1729 ! & dz1 * g * delta *
1730 ! & max(val,(qeso(i,k) - qo(i,k)))
1731 if(aa2(i) < 0.) then
1740 !c compute cloud moisture property, detraining cloud water
1741 !c and precipitation in overshooting layers
1746 if(k >= ktcon(i) .and. k < ktcon1(i)) then
1747 dz = zi(i,k) - zi(i,k-1)
1748 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1750 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1752 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1753 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
1754 factor = 1. + tem - tem1
1755 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
1756 & (qo(i,k)+qo(i,k-1)))/factor
1757 qrcko(i,k) = qcko(i,k)
1759 dq = eta(i,k) * (qcko(i,k) - qrch)
1761 !c check if there is excess moisture to release latent heat
1764 etah = .5 * (eta(i,k) + eta(i,k-1))
1766 dp = 1000. * del(i,k)
1767 ptem = c0t(i,k) + c1
1768 qlk = dq / (eta(i,k) + etah * ptem * dz)
1769 dellal(i,k) = etah * c1 * dz * qlk * g / dp
1771 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
1773 qcko(i,k) = qlk + qrch
1774 pwo(i,k) = etah * c0t(i,k) * dz * qlk
1775 pwavo(i) = pwavo(i) + pwo(i,k)
1776 ! cnvwt(i,k) = (etah*qlk + pwo(i,k)) * g / dp
1777 cnvwt(i,k) = etah * qlk * g / dp
1784 ! compute updraft velocity square(wu2)
1786 ! bb1 = 2. * (1.+bet1*cd1)
1787 ! bb2 = 2. / (f1*(1.+gam1))
1801 tem = po(i,k) / (rd * to(i,k))
1802 wucb = -0.01 * dot(i,k) / (tem * g)
1804 wu2(i,k) = wucb * wucb
1813 if(k > kbcon1(i) .and. k < ktcon(i)) then
1814 dz = zi(i,k) - zi(i,k-1)
1815 tem = 0.25 * bb1 * (drag(i,k)+drag(i,k-1)) * dz
1816 tem1 = 0.5 * bb2 * (buo(i,k)+buo(i,k-1)) * dz
1817 ptem = (1. - tem) * wu2(i,k-1)
1819 wu2(i,k) = (ptem + tem1) / ptem1
1820 wu2(i,k) = max(wu2(i,k), 0._kind_phys)
1826 ! compute updraft velocity average over the whole cumulus
1835 if(k > kbcon1(i) .and. k < ktcon(i)) then
1836 dz = zi(i,k) - zi(i,k-1)
1837 tem = 0.5 * (sqrt(wu2(i,k)) + sqrt(wu2(i,k-1)))
1838 wc(i) = wc(i) + tem * dz
1839 sumx(i) = sumx(i) + dz
1846 if(sumx(i) == 0.) then
1849 wc(i) = wc(i) / sumx(i)
1852 if (wc(i) < val) cnvflg(i)=.false.
1856 !c exchange ktcon with ktcon1
1861 ktcon(i) = ktcon1(i)
1866 !c this section is ready for cloud water
1870 !c compute liquid and vapor separation at cloud top
1875 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1877 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1878 dq = qcko(i,k) - qrch
1880 !c check if there is excess moisture to release latent heat
1890 !ccccc if(lat.==.latd.and.lon.==.lond.and.cnvflg(i)) then
1891 !ccccc print *, ' aa1(i) before dwndrft =', aa1(i)
1894 !c------- downdraft calculations
1896 !c--- compute precipitation efficiency in terms of windshear
1906 if(k > kb(i) .and. k <= ktcon(i)) then
1907 shear= sqrt((uo(i,k)-uo(i,k-1)) ** 2 &
1908 & + (vo(i,k)-vo(i,k-1)) ** 2)
1909 vshear(i) = vshear(i) + shear
1916 vshear(i) = 1.e3 * vshear(i) / (zi(i,ktcon(i))-zi(i,kb(i)))
1917 e1=1.591-.639*vshear(i) &
1918 & +.0953*(vshear(i)**2)-.00496*(vshear(i)**3)
1921 edt(i) = min(edt(i),val)
1923 edt(i) = max(edt(i),val)
1929 !c determine detrainment rate between 1 and kbcon
1939 if(k >= 1 .and. k < kbcon(i)) then
1940 dz = zi(i,k+1) - zi(i,k)
1941 sumx(i) = sumx(i) + dz
1948 if(islimsk(i) == 1) beta = betal
1950 dz = (sumx(i)+zi(i,1))/float(kbcon(i))
1951 tem = 1./float(kbcon(i))
1952 xlamd(i) = (1.-beta**tem)/dz
1956 !c determine downdraft mass flux
1960 if (cnvflg(i) .and. k <= kmax(i)-1) then
1961 if(k < jmin(i) .and. k >= kbcon(i)) then
1962 dz = zi(i,k+1) - zi(i,k)
1963 ptem = xlamdd - xlamde
1964 etad(i,k) = etad(i,k+1) * (1. - ptem * dz)
1965 else if(k < kbcon(i)) then
1966 dz = zi(i,k+1) - zi(i,k)
1967 ptem = xlamd(i) + xlamdd - xlamde
1968 etad(i,k) = etad(i,k+1) * (1. - ptem * dz)
1974 !c--- downdraft moisture properties
1979 hcdo(i,jmn) = heo(i,jmn)
1980 qcdo(i,jmn) = qo(i,jmn)
1981 qrcdo(i,jmn)= qo(i,jmn)
1982 ucdo(i,jmn) = uo(i,jmn)
1983 vcdo(i,jmn) = vo(i,jmn)
1990 if (cnvflg(i) .and. k < jmin(i)) then
1991 dz = zi(i,k+1) - zi(i,k)
1992 if(k >= kbcon(i)) then
1994 tem1 = 0.5 * xlamdd * dz
1997 tem1 = 0.5 * (xlamd(i)+xlamdd) * dz
1999 factor = 1. + tem - tem1
2000 hcdo(i,k) = ((1.-tem1)*hcdo(i,k+1)+tem*0.5* &
2001 & (heo(i,k)+heo(i,k+1)))/factor
2002 dbyo(i,k) = hcdo(i,k) - heso(i,k)
2004 tem = 0.5 * cm * tem
2008 ucdo(i,k) = ((1.-tem)*ucdo(i,k+1)+ptem*uo(i,k+1) &
2009 & +ptem1*uo(i,k))/factor
2010 vcdo(i,k) = ((1.-tem)*vcdo(i,k+1)+ptem*vo(i,k+1) &
2011 & +ptem1*vo(i,k))/factor
2018 if (cnvflg(i) .and. k < jmin(i)) then
2019 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
2020 qrcdo(i,k) = qeso(i,k)+ &
2021 & (1./hvap)*(gamma/(1.+gamma))*dbyo(i,k)
2022 ! detad = etad(i,k+1) - etad(i,k)
2024 dz = zi(i,k+1) - zi(i,k)
2025 if(k >= kbcon(i)) then
2027 tem1 = 0.5 * xlamdd * dz
2030 tem1 = 0.5 * (xlamd(i)+xlamdd) * dz
2032 factor = 1. + tem - tem1
2033 qcdo(i,k) = ((1.-tem1)*qrcdo(i,k+1)+tem*0.5* &
2034 & (qo(i,k)+qo(i,k+1)))/factor
2036 ! pwdo(i,k) = etad(i,k+1) * qcdo(i,k+1) -
2037 ! & etad(i,k) * qrcdo(i,k)
2038 ! pwdo(i,k) = pwdo(i,k) - detad *
2039 ! & .5 * (qrcdo(i,k) + qrcdo(i,k+1))
2041 pwdo(i,k) = etad(i,k) * (qcdo(i,k) - qrcdo(i,k))
2042 pwevo(i) = pwevo(i) + pwdo(i,k)
2047 !c--- final downdraft strength dependent on precip
2048 !c--- efficiency (edt), normalized condensate (pwav), and
2049 !c--- evaporate (pwev)
2053 if(islimsk(i) == 0) edtmax = edtmaxs
2055 if(pwevo(i) < 0.) then
2056 edto(i) = -edto(i) * pwavo(i) / pwevo(i)
2057 edto(i) = min(edto(i),edtmax)
2064 !c--- downdraft cloudwork functions
2068 if (cnvflg(i) .and. k < jmin(i)) then
2069 gamma = el2orc * qeso(i,k) / to(i,k)**2
2074 dz=-1.*(zo(i,k+1)-zo(i,k))
2075 ! aa1(i)=aa1(i)+edto(i)*dz*etad(i,k)
2076 aa1(i)=aa1(i)+edto(i)*dz &
2077 & *(g/(cp*dt))*((dhh-dh)/(1.+dg)) &
2078 & *(1.+delta*cp*dg*dt/hvap)
2080 ! aa1(i)=aa1(i)+edto(i)*dz*etad(i,k)
2081 aa1(i)=aa1(i)+edto(i)*dz &
2082 & *g*delta*max(val,(qeso(i,k)-qo(i,k)))
2087 if(cnvflg(i) .and. aa1(i) <= 0.) then
2094 totflg = totflg .and. (.not. cnvflg(i))
2099 !c--- what would the change be, that a cloud with unit mass
2100 !c--- will do to the environment?
2104 if(cnvflg(i) .and. k <= kmax(i)) then
2114 dp = 1000. * del(i,1)
2115 dellah(i,1) = edto(i) * etad(i,1) * (hcdo(i,1) &
2116 & - heo(i,1)) * g / dp
2117 dellaq(i,1) = edto(i) * etad(i,1) * (qrcdo(i,1) &
2118 & - qo(i,1)) * g / dp
2119 dellau(i,1) = edto(i) * etad(i,1) * (ucdo(i,1) &
2120 & - uo(i,1)) * g / dp
2121 dellav(i,1) = edto(i) * etad(i,1) * (vcdo(i,1) &
2122 & - vo(i,1)) * g / dp
2126 !c--- changed due to subsidence and entrainment
2130 if (cnvflg(i) .and. k < ktcon(i)) then
2132 if(k <= kb(i)) aup = 0.
2134 if(k > jmin(i)) adw = 0.
2135 dp = 1000. * del(i,k)
2136 dz = zi(i,k) - zi(i,k-1)
2139 dv2h = .5 * (heo(i,k) + heo(i,k-1))
2142 dv2q = .5 * (qo(i,k) + qo(i,k-1))
2145 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1))
2146 tem1 = 0.5 * (xlamud(i,k)+xlamud(i,k-1))
2148 if(k <= kbcon(i)) then
2150 ptem1 = xlamd(i)+xlamdd
2156 dellah(i,k) = dellah(i,k) + &
2157 & ((aup*eta(i,k)-adw*edto(i)*etad(i,k))*dv1h &
2158 & - (aup*eta(i,k-1)-adw*edto(i)*etad(i,k-1))*dv3h &
2159 & - (aup*tem*eta(i,k-1)+adw*edto(i)*ptem*etad(i,k))*dv2h*dz &
2160 & + aup*tem1*eta(i,k-1)*.5*(hcko(i,k)+hcko(i,k-1))*dz &
2161 & + adw*edto(i)*ptem1*etad(i,k)*.5*(hcdo(i,k)+hcdo(i,k-1))*dz &
2164 dellaq(i,k) = dellaq(i,k) + &
2165 & ((aup*eta(i,k)-adw*edto(i)*etad(i,k))*dv1q &
2166 & - (aup*eta(i,k-1)-adw*edto(i)*etad(i,k-1))*dv3q &
2167 & - (aup*tem*eta(i,k-1)+adw*edto(i)*ptem*etad(i,k))*dv2q*dz &
2168 & + aup*tem1*eta(i,k-1)*.5*(qrcko(i,k)+qcko(i,k-1))*dz &
2169 & + adw*edto(i)*ptem1*etad(i,k)*.5*(qrcdo(i,k)+qcdo(i,k-1))*dz &
2172 tem1=eta(i,k)*(uo(i,k)-ucko(i,k))
2173 tem2=eta(i,k-1)*(uo(i,k-1)-ucko(i,k-1))
2174 ptem1=etad(i,k)*(uo(i,k)-ucdo(i,k))
2175 ptem2=etad(i,k-1)*(uo(i,k-1)-ucdo(i,k-1))
2176 dellau(i,k) = dellau(i,k) + &
2177 & (aup*(tem1-tem2)-adw*edto(i)*(ptem1-ptem2))*g/dp
2179 tem1=eta(i,k)*(vo(i,k)-vcko(i,k))
2180 tem2=eta(i,k-1)*(vo(i,k-1)-vcko(i,k-1))
2181 ptem1=etad(i,k)*(vo(i,k)-vcdo(i,k))
2182 ptem2=etad(i,k-1)*(vo(i,k-1)-vcdo(i,k-1))
2183 dellav(i,k) = dellav(i,k) + &
2184 & (aup*(tem1-tem2)-adw*edto(i)*(ptem1-ptem2))*g/dp
2195 dp = 1000. * del(i,indx)
2196 dv1h = heo(i,indx-1)
2197 dellah(i,indx) = eta(i,indx-1) * &
2198 & (hcko(i,indx-1) - dv1h) * g / dp
2200 dellaq(i,indx) = eta(i,indx-1) * &
2201 & (qcko(i,indx-1) - dv1q) * g / dp
2202 dellau(i,indx) = eta(i,indx-1) * &
2203 & (ucko(i,indx-1) - uo(i,indx-1)) * g / dp
2204 dellav(i,indx) = eta(i,indx-1) * &
2205 & (vcko(i,indx-1) - vo(i,indx-1)) * g / dp
2209 dellal(i,indx) = eta(i,indx-1) * &
2210 & qlko_ktcon(i) * g / dp
2214 !c------- final changed variable per unit mass flux
2216 ! if grid size is less than a threshold value (dxcrtas),
2217 ! the quasi-equilibrium assumption of Arakawa-Schubert is not
2221 asqecflg(i) = cnvflg(i)
2222 if(asqecflg(i) .and. gdx(i) < dxcrtas) then
2223 asqecflg(i) = .false.
2229 if (asqecflg(i) .and. k <= kmax(i)) then
2230 if(k > ktcon(i)) then
2234 if(k <= ktcon(i)) then
2235 qo(i,k) = dellaq(i,k) * mbdt(i) + q1(i,k)
2236 dellat = (dellah(i,k) - hvap * dellaq(i,k)) / cp
2237 to(i,k) = dellat * mbdt(i) + t1(i,k)
2239 qo(i,k) = max(qo(i,k), val )
2244 !c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2246 !c--- the above changed environment is now used to calulate the
2247 !c--- effect the arbitrary cloud (with unit mass flux)
2248 !c--- would have on the stability,
2249 !c--- which then is used to calculate the real mass flux,
2250 !c--- necessary to keep this change in balance with the large-scale
2251 !c--- destabilization.
2253 !c--- environmental conditions again, first heights
2257 if(asqecflg(i) .and. k <= kmax(i)) then
2258 qeso(i,k) = 0.01 * fpvs(to(i,k)) ! fpvs is in pa
2259 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k)+epsm1*qeso(i,k))
2261 qeso(i,k) = max(qeso(i,k), val )
2262 ! tvo(i,k) = to(i,k) + delta * to(i,k) * qo(i,k)
2267 !c--- moist static energy
2271 if(asqecflg(i) .and. k <= kmax(i)-1) then
2272 dz = .5 * (zo(i,k+1) - zo(i,k))
2273 dp = .5 * (pfld(i,k+1) - pfld(i,k))
2274 es = 0.01 * fpvs(to(i,k+1)) ! fpvs is in pa
2275 pprime = pfld(i,k+1) + epsm1 * es
2276 qs = eps * es / pprime
2277 dqsdp = - qs / pprime
2278 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
2279 dqsdt = qs * pfld(i,k+1) * desdt / (es * pprime)
2280 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
2281 dt = (g * dz + hvap * dqsdp * dp) / (cp * (1. + gamma))
2282 dq = dqsdt * dt + dqsdp * dp
2283 to(i,k) = to(i,k+1) + dt
2284 qo(i,k) = qo(i,k+1) + dq
2285 po(i,k) = .5 * (pfld(i,k) + pfld(i,k+1))
2291 if(asqecflg(i) .and. k <= kmax(i)-1) then
2292 qeso(i,k) = 0.01 * fpvs(to(i,k)) ! fpvs is in pa
2293 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + epsm1 * qeso(i,k))
2295 qeso(i,k) = max(qeso(i,k), val1)
2297 qo(i,k) = max(qo(i,k), val2 )
2298 ! qo(i,k) = min(qo(i,k),qeso(i,k))
2299 heo(i,k) = .5 * g * (zo(i,k) + zo(i,k+1)) + &
2300 & cp * to(i,k) + hvap * qo(i,k)
2301 heso(i,k) = .5 * g * (zo(i,k) + zo(i,k+1)) + &
2302 & cp * to(i,k) + hvap * qeso(i,k)
2307 if(asqecflg(i)) then
2309 heo(i,k) = g * zo(i,k) + cp * to(i,k) + hvap * qo(i,k)
2310 heso(i,k) = g * zo(i,k) + cp * to(i,k) + hvap * qeso(i,k)
2311 !c heo(i,k) = min(heo(i,k),heso(i,k))
2315 !c**************************** static control
2317 !c------- moisture and cloud work functions
2320 if(asqecflg(i)) then
2327 if(asqecflg(i)) then
2329 hcko(i,indx) = heo(i,indx)
2330 qcko(i,indx) = qo(i,indx)
2335 if (asqecflg(i)) then
2336 if(k > kb(i) .and. k <= ktcon(i)) then
2337 dz = zi(i,k) - zi(i,k-1)
2338 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
2339 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
2340 factor = 1. + tem - tem1
2341 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5* &
2342 & (heo(i,k)+heo(i,k-1)))/factor
2349 if (asqecflg(i)) then
2350 if(k > kb(i) .and. k < ktcon(i)) then
2351 dz = zi(i,k) - zi(i,k-1)
2352 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
2353 xdby = hcko(i,k) - heso(i,k)
2355 & + gamma * xdby / (hvap * (1. + gamma))
2357 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
2358 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
2359 factor = 1. + tem - tem1
2360 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
2361 & (qo(i,k)+qo(i,k-1)))/factor
2363 dq = eta(i,k) * (qcko(i,k) - xqrch)
2365 if(k >= kbcon(i) .and. dq > 0.) then
2366 etah = .5 * (eta(i,k) + eta(i,k-1))
2367 if(ncloud > 0 .and. k > jmin(i)) then
2368 ptem = c0t(i,k) + c1
2369 qlk = dq / (eta(i,k) + etah * ptem * dz)
2371 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
2373 if(k < ktcon1(i)) then
2374 ! xaa0(i) = xaa0(i) - dz * g * qlk * etah
2375 xaa0(i) = xaa0(i) - dz * g * qlk
2377 qcko(i,k) = qlk + xqrch
2378 xpw = etah * c0t(i,k) * dz * qlk
2379 xpwav(i) = xpwav(i) + xpw
2382 if(k >= kbcon(i) .and. k < ktcon1(i)) then
2383 dz1 = zo(i,k+1) - zo(i,k)
2384 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
2385 rfact = 1. + delta * cp * gamma &
2388 ! & + dz1 * eta(i,k) * (g / (cp * to(i,k)))
2389 & + dz1 * (g / (cp * to(i,k))) &
2390 & * xdby / (1. + gamma) &
2393 xaa0(i) = xaa0(i) + &
2394 ! & dz1 * eta(i,k) * g * delta *
2395 & dz1 * g * delta * &
2396 & max(val,(qeso(i,k) - qo(i,k)))
2402 !c------- downdraft calculations
2404 !c--- downdraft moisture properties
2407 if(asqecflg(i)) then
2409 hcdo(i,jmn) = heo(i,jmn)
2410 qcdo(i,jmn) = qo(i,jmn)
2411 qrcd(i,jmn) = qo(i,jmn)
2418 if (asqecflg(i) .and. k < jmin(i)) then
2419 dz = zi(i,k+1) - zi(i,k)
2420 if(k >= kbcon(i)) then
2422 tem1 = 0.5 * xlamdd * dz
2425 tem1 = 0.5 * (xlamd(i)+xlamdd) * dz
2427 factor = 1. + tem - tem1
2428 hcdo(i,k) = ((1.-tem1)*hcdo(i,k+1)+tem*0.5* &
2429 & (heo(i,k)+heo(i,k+1)))/factor
2436 if (asqecflg(i) .and. k < jmin(i)) then
2439 gamma = el2orc * dq / dt**2
2440 dh = hcdo(i,k) - heso(i,k)
2441 qrcd(i,k)=dq+(1./hvap)*(gamma/(1.+gamma))*dh
2442 ! detad = etad(i,k+1) - etad(i,k)
2444 dz = zi(i,k+1) - zi(i,k)
2445 if(k >= kbcon(i)) then
2447 tem1 = 0.5 * xlamdd * dz
2450 tem1 = 0.5 * (xlamd(i)+xlamdd) * dz
2452 factor = 1. + tem - tem1
2453 qcdo(i,k) = ((1.-tem1)*qrcd(i,k+1)+tem*0.5* &
2454 & (qo(i,k)+qo(i,k+1)))/factor
2456 ! xpwd = etad(i,k+1) * qcdo(i,k+1) -
2457 ! & etad(i,k) * qrcd(i,k)
2458 ! xpwd = xpwd - detad *
2459 ! & .5 * (qrcd(i,k) + qrcd(i,k+1))
2461 xpwd = etad(i,k) * (qcdo(i,k) - qrcd(i,k))
2462 xpwev(i) = xpwev(i) + xpwd
2469 if(islimsk(i) == 0) edtmax = edtmaxs
2470 if(asqecflg(i)) then
2471 if(xpwev(i) >= 0.) then
2474 edtx(i) = -edtx(i) * xpwav(i) / xpwev(i)
2475 edtx(i) = min(edtx(i),edtmax)
2481 !c--- downdraft cloudwork functions
2486 if (asqecflg(i) .and. k < jmin(i)) then
2487 gamma = el2orc * qeso(i,k) / to(i,k)**2
2492 dz=-1.*(zo(i,k+1)-zo(i,k))
2493 ! xaa0(i)=xaa0(i)+edtx(i)*dz*etad(i,k)
2494 xaa0(i)=xaa0(i)+edtx(i)*dz &
2495 & *(g/(cp*dt))*((dhh-dh)/(1.+dg)) &
2496 & *(1.+delta*cp*dg*dt/hvap)
2498 ! xaa0(i)=xaa0(i)+edtx(i)*dz*etad(i,k)
2499 xaa0(i)=xaa0(i)+edtx(i)*dz &
2500 & *g*delta*max(val,(qeso(i,k)-qo(i,k)))
2505 !c calculate critical cloud work function
2508 ! if(cnvflg(i)) then
2509 ! if(pfld(i,ktcon(i)) < pcrit(15))then
2510 ! acrt(i)=acrit(15)*(975.-pfld(i,ktcon(i)))
2511 ! & /(975.-pcrit(15))
2512 ! else if(pfld(i,ktcon(i)) > pcrit(1))then
2515 ! k = int((850. - pfld(i,ktcon(i)))/50.) + 2
2518 ! acrt(i)=acrit(k)+(acrit(k-1)-acrit(k))*
2519 ! & (pfld(i,ktcon(i))-pcrit(k))/(pcrit(k-1)-pcrit(k))
2524 ! if(cnvflg(i)) then
2525 ! if(islimsk(i) == 1) then
2537 !c modify critical cloud workfunction by cloud base vertical velocity
2539 ! if(pdot(i) <= w4) then
2540 ! acrtfct(i) = (pdot(i) - w4) / (w3 - w4)
2541 ! elseif(pdot(i) >= -w4) then
2542 ! acrtfct(i) = - (pdot(i) + w4) / (w4 - w3)
2547 ! acrtfct(i) = max(acrtfct(i),val1)
2549 ! acrtfct(i) = min(acrtfct(i),val2)
2550 ! acrtfct(i) = 1. - acrtfct(i)
2552 !c modify acrtfct(i) by colume mean rh if rhbar(i) is greater than 80 percent
2554 !c if(rhbar(i) >= .8) then
2555 !c acrtfct(i) = acrtfct(i) * (.9 - min(rhbar(i),.9)) * 10.
2558 !c modify adjustment time scale by cloud base vertical velocity
2560 ! dtconv(i) = dt2 + max((1800. - dt2),0.) *
2561 ! & (pdot(i) - w2) / (w1 - w2)
2562 !c dtconv(i) = max(dtconv(i), dt2)
2563 !c dtconv(i) = 1800. * (pdot(i) - w2) / (w1 - w2)
2565 ! dtconv(i) = max(dtconv(i),dtmin)
2566 ! dtconv(i) = min(dtconv(i),dtmax)
2571 ! compute convective turn-over time
2575 tem = zi(i,ktcon1(i)) - zi(i,kbcon1(i))
2576 dtconv(i) = tem / wc(i)
2577 dtconv(i) = max(dtconv(i),dtmin)
2578 dtconv(i) = min(dtconv(i),dtmax)
2582 ! compute advective time scale using a mean cloud layer wind speed
2593 if(k >= kbcon1(i) .and. k < ktcon1(i)) then
2594 dz = zi(i,k) - zi(i,k-1)
2595 tem = sqrt(u1(i,k)*u1(i,k)+v1(i,k)*v1(i,k))
2596 umean(i) = umean(i) + tem * dz
2597 sumx(i) = sumx(i) + dz
2604 umean(i) = umean(i) / sumx(i)
2605 umean(i) = max(umean(i), 1._kind_phys)
2606 tauadv(i) = gdx(i) / umean(i)
2610 !c compute cloud base mass flux as a function of the mean
2611 !c updraft velcoity for the grid sizes where
2612 !c the quasi-equilibrium assumption of Arakawa-Schubert is not
2613 !c valid any longer.
2616 if(cnvflg(i) .and. .not.asqecflg(i)) then
2618 rho = po(i,k)*100. / (rd*to(i,k))
2619 tfac = tauadv(i) / dtconv(i)
2620 tfac = min(tfac, 1._kind_phys)
2621 xmb(i) = tfac*betaw*rho*wc(i)
2625 !c compute cloud base mass flux using
2626 !c the quasi-equilibrium assumption of Arakawa-Schubert
2629 if(asqecflg(i)) then
2630 ! fld(i)=(aa1(i)-acrt(i)*acrtfct(i))/dtconv(i)
2631 fld(i)=aa1(i)/dtconv(i)
2632 if(fld(i) <= 0.) then
2633 asqecflg(i) = .false.
2637 if(asqecflg(i)) then
2638 !c xaa0(i) = max(xaa0(i),0.)
2639 xk(i) = (xaa0(i) - aa1(i)) / mbdt(i)
2640 if(xk(i) >= 0.) then
2641 asqecflg(i) = .false.
2646 !c--- kernel, cloud base mass flux
2648 if(asqecflg(i)) then
2649 tfac = tauadv(i) / dtconv(i)
2650 tfac = min(tfac, 1._kind_phys)
2651 xmb(i) = -tfac * fld(i) / xk(i)
2652 ! xmb(i) = min(xmb(i),xmbmax(i))
2658 totflg = totflg .and. (.not. cnvflg(i))
2663 !--- modified Grell & Freitas' (2014) updraft fraction which uses
2664 ! actual entrainment rate at cloud base
2668 tem = min(max(xlamx(i), 7.e-5_kind_phys), 3.e-4_kind_phys)
2670 tem1 = 3.14 * tem * tem
2671 sigmagfm(i) = tem1 / garea(i)
2672 sigmagfm(i) = max(sigmagfm(i), 0.001_kind_phys)
2673 sigmagfm(i) = min(sigmagfm(i), 0.999_kind_phys)
2677 !--- compute scale-aware function based on Arakawa & Wu (2013)
2681 if (gdx(i) < dxcrtuf) then
2682 scaldfunc(i) = (1.-sigmagfm(i)) * (1.-sigmagfm(i))
2683 scaldfunc(i) = max(min(scaldfunc(i), 1.0_kind_phys), 0._kind_phys)
2684 sigmuout(i)=sigmagfm(i)
2688 xmb(i) = xmb(i) * scaldfunc(i)
2689 xmb(i) = min(xmb(i),xmbmax(i))
2693 !c restore to,qo,uo,vo to t1,q1,u1,v1 in case convection stops
2697 if (cnvflg(i) .and. k <= kmax(i)) then
2702 qeso(i,k) = 0.01 * fpvs(t1(i,k)) ! fpvs is in pa
2703 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
2705 qeso(i,k) = max(qeso(i,k), val )
2709 !c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2711 !c--- feedback: simply the changes from the cloud with unit mass flux
2712 !c--- multiplied by the mass flux necessary to keep the
2713 !c--- equilibrium with the larger-scale.
2725 if (cnvflg(i) .and. k <= kmax(i)) then
2726 if(k <= ktcon(i)) then
2727 dellat = (dellah(i,k) - hvap * dellaq(i,k)) / cp
2728 t1(i,k) = t1(i,k) + dellat * xmb(i) * dt2
2729 q1(i,k) = q1(i,k) + dellaq(i,k) * xmb(i) * dt2
2731 ! u1(i,k) = u1(i,k) + dellau(i,k) * xmb(i) * dt2 * tem
2732 ! v1(i,k) = v1(i,k) + dellav(i,k) * xmb(i) * dt2 * tem
2733 u1(i,k) = u1(i,k) + dellau(i,k) * xmb(i) * dt2
2734 v1(i,k) = v1(i,k) + dellav(i,k) * xmb(i) * dt2
2735 dp = 1000. * del(i,k)
2736 delhbar(i) = delhbar(i) + dellah(i,k)*xmb(i)*dp/g
2737 delqbar(i) = delqbar(i) + dellaq(i,k)*xmb(i)*dp/g
2738 deltbar(i) = deltbar(i) + dellat*xmb(i)*dp/g
2739 delubar(i) = delubar(i) + dellau(i,k)*xmb(i)*dp/g
2740 delvbar(i) = delvbar(i) + dellav(i,k)*xmb(i)*dp/g
2747 if (cnvflg(i) .and. k <= kmax(i)) then
2748 if(k <= ktcon(i)) then
2749 qeso(i,k) = 0.01 * fpvs(t1(i,k)) ! fpvs is in pa
2750 qeso(i,k) = eps * qeso(i,k)/(pfld(i,k) + epsm1*qeso(i,k))
2752 qeso(i,k) = max(qeso(i,k), val )
2766 if (cnvflg(i) .and. k <= kmax(i)) then
2767 if(k < ktcon(i)) then
2769 if(k <= kb(i)) aup = 0.
2771 if(k >= jmin(i)) adw = 0.
2772 rain = aup * pwo(i,k) + adw * edto(i) * pwdo(i,k)
2773 rntot(i) = rntot(i) + rain * xmb(i) * .001 * dt2
2780 if (k <= kmax(i)) then
2784 if(cnvflg(i) .and. k < ktcon(i)) then
2786 if(k <= kb(i)) aup = 0.
2788 if(k >= jmin(i)) adw = 0.
2789 rain = aup * pwo(i,k) + adw * edto(i) * pwdo(i,k)
2790 rn(i) = rn(i) + rain * xmb(i) * .001 * dt2
2792 if(flg(i) .and. k < ktcon(i)) then
2793 evef = edt(i) * evfact
2794 if(islimsk(i) == 1) evef=edt(i) * evfactl
2795 ! if(islimsk(i) == 1) evef=.07
2796 !c if(islimsk(i) == 1) evef = 0.
2797 qcond(i) = evef * (q1(i,k) - qeso(i,k)) &
2798 & / (1. + el2orc * qeso(i,k) / t1(i,k)**2)
2799 dp = 1000. * del(i,k)
2800 if(rn(i) > 0. .and. qcond(i) < 0.) then
2801 qevap(i) = -qcond(i) * (1.-exp(-.32*sqrt(dt2*rn(i))))
2802 qevap(i) = min(qevap(i), rn(i)*1000.*g/dp)
2803 delq2(i) = delqev(i) + .001 * qevap(i) * dp / g
2805 if(rn(i) > 0. .and. qcond(i) < 0. .and. &
2806 & delq2(i) > rntot(i)) then
2807 qevap(i) = 1000.* g * (rntot(i) - delqev(i)) / dp
2810 if(rn(i) > 0. .and. qevap(i) > 0.) then
2811 q1(i,k) = q1(i,k) + qevap(i)
2812 t1(i,k) = t1(i,k) - elocp * qevap(i)
2813 rn(i) = rn(i) - .001 * qevap(i) * dp / g
2814 deltv(i) = - elocp*qevap(i)/dt2
2815 delq(i) = + qevap(i)/dt2
2816 delqev(i) = delqev(i) + .001*dp*qevap(i)/g
2818 delqbar(i) = delqbar(i) + delq(i)*dp/g
2819 deltbar(i) = deltbar(i) + deltv(i)*dp/g
2826 ! if(me == 31 .and. cnvflg(i)) then
2827 ! if(cnvflg(i)) then
2828 ! print *, ' deep delhbar, delqbar, deltbar = ',
2829 ! & delhbar(i),hvap*delqbar(i),cp*deltbar(i)
2830 ! print *, ' deep delubar, delvbar = ',delubar(i),delvbar(i)
2831 ! print *, ' precip =', hvap*rn(i)*1000./dt2
2832 ! print*,'pdif= ',pfld(i,kbcon(i))-pfld(i,ktcon(i))
2836 !c precipitation rate converted to actual precip
2837 !c in unit of m instead of kg
2842 !c in the event of upper level rain evaporation and lower level downdraft
2843 !c moistening, rn can become negative, in this case, we back out of the
2844 !c heating and the moistening
2846 if(rn(i) < 0. .and. .not.flg(i)) rn(i) = 0.
2847 if(rn(i) <= 0.) then
2858 !c convective cloud water
2862 if (cnvflg(i) .and. rn(i) > 0.) then
2863 if (k >= kbcon(i) .and. k < ktcon(i)) then
2864 cnvw(i,k) = cnvwt(i,k) * xmb(i) * dt2
2870 !c convective cloud cover
2874 if (cnvflg(i) .and. rn(i) > 0.) then
2875 if (k >= kbcon(i) .and. k < ktcon(i)) then
2876 cnvc(i,k) = 0.04 * log(1. + 675. * eta(i,k) * xmb(i))
2877 cnvc(i,k) = min(cnvc(i,k), 0.6_kind_phys)
2878 cnvc(i,k) = max(cnvc(i,k), 0.0_kind_phys)
2887 if (ncloud > 0) then
2891 if (cnvflg(i) .and. rn(i) > 0.) then
2892 ! if (k > kb(i) .and. k <= ktcon(i)) then
2893 if (k >= kbcon(i) .and. k <= ktcon(i)) then
2894 tem = dellal(i,k) * xmb(i) * dt2
2895 tem1 = max(0.0_kind_phys, min(1.0_kind_phys, (tcr-t1(i,k))*tcrf))
2896 if (ql(i,k,2) > -999.0) then
2897 ql(i,k,1) = ql(i,k,1) + tem * tem1 ! ice
2898 ql(i,k,2) = ql(i,k,2) + tem *(1.0-tem1) ! water
2900 ql(i,k,1) = ql(i,k,1) + tem
2911 if(cnvflg(i) .and. rn(i) <= 0.) then
2912 if (k <= kmax(i)) then
2922 ! hchuang code change
2926 if(cnvflg(i) .and. rn(i) > 0.) then
2927 if(k >= kb(i) .and. k < ktop(i)) then
2928 ud_mf(i,k) = eta(i,k) * xmb(i) * dt2
2934 if(cnvflg(i) .and. rn(i) > 0.) then
2936 dt_mf(i,k) = ud_mf(i,k)
2941 if(cnvflg(i) .and. rn(i) > 0.) then
2942 if(k >= 1 .and. k <= jmin(i)) then
2943 dd_mf(i,k) = edto(i) * etad(i,k) * xmb(i) * dt2
2950 end subroutine mfdeepcnv
2951 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2953 subroutine mfshalcnv(im,ix,km,delt,delp,prslp,psp,phil,ql, &
2954 & q1,t1,u1,v1,rn,kbot,ktop,kcnv,islimsk,garea, &
2955 & dot,ncloud,hpbl,ud_mf,dt_mf,cnvw,cnvc,sigmagfm,scaldfunc, &
2956 & pert_sas, ens_random_seed, ens_sasamp)
2959 ! use machine , only : kind_phys
2960 ! use funcphys , only : fpvs
2961 ! use physcons, grav => con_g, cp => con_cp, hvap => con_hvap
2962 USE MODULE_GFS_MACHINE, ONLY : kind_phys
2963 USE MODULE_GFS_FUNCPHYS, ONLY : fpvs
2964 USE MODULE_GFS_PHYSCONS, grav => con_g, cp => con_cp &
2965 & , hvap => con_hvap &
2966 &, rv => con_rv, fv => con_fvirt, t0c => con_t0c &
2967 &, rd => con_rd, cvap => con_cvap, cliq => con_cliq &
2968 &, eps => con_eps, epsm1 => con_epsm1
2974 integer im, ix, km, ncloud, &
2975 & kbot(im), ktop(im), kcnv(im)
2977 real(kind=kind_phys) delt
2978 real(kind=kind_phys) psp(im), delp(ix,km), prslp(ix,km)
2979 real(kind=kind_phys) ps(im), del(ix,km), prsl(ix,km), &
2980 & ql(ix,km,2),q1(ix,km), t1(ix,km), &
2981 & u1(ix,km), v1(ix,km), &
2982 ! & u1(ix,km), v1(ix,km), rcs(im),
2983 & rn(im), garea(im), &
2984 & dot(ix,km), phil(ix,km), hpbl(im), &
2985 & cnvw(ix,km),cnvc(ix,km) &
2986 ! hchuang code change mass flux output
2987 &, ud_mf(im,km),dt_mf(im,km)
2989 integer i,j,indx, k, kk, km1, n
2991 integer, dimension(im), intent(in) :: islimsk
2993 real(kind=kind_phys) dellat, delta, &
2997 & dq, dqsdp, dqsdt, dt, &
2998 & dt2, dtmax, dtmin, dxcrt, &
2999 & dv1h, dv2h, dv3h, &
3000 & dv1q, dv2q, dv3q, &
3001 & dz, dz1, e1, clam, &
3002 & el2orc, elocp, aafac, cm, &
3004 & evef, evfact, evfactl, fact1, &
3005 & fact2, factor, dthk, &
3006 & g, gamma, pprime, betaw, &
3008 & rfact, shear, tfac, &
3009 & val, val1, val2, &
3010 & w1, w1l, w1s, w2, &
3011 & w2l, w2s, w3, w3l, &
3012 & w3s, w4, w4l, w4s, &
3013 & rho, tem, tem1, tem2, &
3017 logical,optional,intent(in) :: pert_sas
3018 integer,optional,intent(in) :: ens_random_seed
3019 real,optional,intent(in) :: ens_sasamp
3021 integer kb(im), kbcon(im), kbcon1(im), &
3022 & ktcon(im), ktcon1(im), ktconn(im), &
3025 real(kind=kind_phys) aa1(im), cina(im), &
3026 & umean(im), tauadv(im), gdx(im), &
3027 & delhbar(im), delq(im), delq2(im), &
3028 & delqbar(im), delqev(im), deltbar(im), &
3029 & deltv(im), dtconv(im), edt(im), &
3030 & pdot(im), po(im,km), &
3031 & qcond(im), qevap(im), hmax(im), &
3032 & rntot(im), vshear(im), &
3033 & xlamud(im), xmb(im), xmbmax(im), &
3034 & delubar(im), delvbar(im)
3036 real(kind=kind_phys) c0(im)
3038 real(kind=kind_phys) crtlamd
3040 real(kind=kind_phys) cinpcr, cinpcrmx, cinpcrmn, &
3041 & cinacr, cinacrmx, cinacrmn
3043 ! parameters for updraft velocity calculation
3044 real(kind=kind_phys) bet1, cd1, f1, gam1, &
3047 !c physical parameters
3048 parameter(g=grav,asolfac=0.89)
3049 parameter(elocp=hvap/cp, &
3050 & el2orc=hvap*hvap/(rv*cp))
3051 parameter(c0s=0.002,c1=5.e-4,d0=.01)
3052 parameter(c0l=c0s*asolfac)
3054 ! asolfac: aerosol-aware parameter based on Lim & Hong (2012)
3055 ! asolfac= cx / c0s(=.002)
3056 ! cx = min([-0.7 ln(Nccn) + 24]*1.e-4, c0s)
3057 ! Nccn: CCN number concentration in cm^(-3)
3058 ! Until a realistic Nccn is provided, typical Nccns are assumed
3059 ! as Nccn=100 for sea and Nccn=7000 for land
3061 parameter(cm=1.0,delta=fv)
3062 parameter(fact1=(cvap-cliq)/rv,fact2=hvap/rv-fact1*t0c)
3064 parameter(cinpcrmx=180.,cinpcrmn=120.)
3065 parameter(cinacrmx=-120.,cinacrmn=-120.)
3066 parameter(crtlamd=3.e-4)
3067 parameter(dtmax=10800.,dtmin=600.)
3068 parameter(bet1=1.875,cd1=.506,f1=2.0,gam1=.5)
3069 parameter(betaw=.03,dxcrt=15.e3)
3070 parameter(h1=0.33333333)
3071 !c local variables and arrays
3072 real(kind=kind_phys) pfld(im,km), to(im,km), qo(im,km), &
3073 & uo(im,km), vo(im,km), qeso(im,km)
3074 ! for updraft velocity calculation
3075 real(kind=kind_phys) wu2(im,km), buo(im,km), drag(im,km)
3076 real(kind=kind_phys) wc(im), scaldfunc(im), sigmagfm(im)
3079 ! real(kind=kind_phys) qlko_ktcon(im), dellal(im,km), tvo(im,km),
3080 real(kind=kind_phys) qlko_ktcon(im), dellal(im,km), &
3081 & dbyo(im,km), zo(im,km), xlamue(im,km), &
3082 & heo(im,km), heso(im,km), &
3083 & dellah(im,km), dellaq(im,km), &
3084 & dellau(im,km), dellav(im,km), hcko(im,km), &
3085 & ucko(im,km), vcko(im,km), qcko(im,km), &
3086 & qrcko(im,km), eta(im,km), &
3087 & zi(im,km), pwo(im,km), c0t(im,km), &
3088 & sumx(im), tx1(im), cnvwt(im,km)
3090 logical totflg, cnvflg(im), flg(im)
3092 real(kind=kind_phys) tf, tcr, tcrf
3093 parameter (tf=233.16, tcr=263.16, tcrf=1.0/(tcr-tf))
3096 real*8 :: gasdev,ran1 !zhang
3098 logical,save :: pert_sas_local !zhang
3099 integer,save :: ens_random_seed_local,env_pp_local !zhang
3100 integer :: ensda_physics_pert !zhang
3101 real,save :: ens_sasamp_local !zhang
3102 data ens_random_seed_local/0/
3103 data env_pp_local/0/
3104 CHARACTER(len=3) :: env_memb,env_pp
3105 if ( ens_random_seed_local .eq. 0 ) then
3106 CALL nl_get_ensda_physics_pert(1,ensda_physics_pert)
3107 ens_random_seed_local=ens_random_seed
3108 env_pp_local=ensda_physics_pert
3109 pert_sas_local=.false.
3110 ens_sasamp_local=0.0
3111 ! env_pp=1: do physics perturbations for ensda members, ens_random_seed must be 99
3112 if ( env_pp_local .eq. 1 ) then
3113 if ( ens_random_seed .ne. 99 ) then
3114 pert_sas_local=.true.
3115 ens_sasamp_local=ens_sasamp
3117 ! ens_random_seed=99 do physics perturbation for ensemble forecasts, env_pp must be zero
3118 ens_random_seed_local=ens_random_seed
3119 pert_sas_local=pert_sas
3120 ens_sasamp_local=ens_sasamp
3123 ens_random_seed_local=ens_random_seed
3124 pert_sas_local=pert_sas
3125 ens_sasamp_local=ens_sasamp
3128 print*, "SHSAS ==", ens_random_seed_local,pert_sas_local,ens_sasamp_local,ensda_physics_pert
3133 !c-----------------------------------------------------------------------
3135 !************************************************************************
3136 ! convert input Pa terms to Cb terms -- Moorthi
3138 prsl = prslp * 0.001
3140 !************************************************************************
3144 !c initialize arrays
3148 if(kcnv(i) == 1) cnvflg(i) = .false.
3164 gdx(i) = sqrt(garea(i))
3165 scaldfunc(i)=-1.0 ! wang initialized
3171 totflg = totflg .and. (.not. cnvflg(i))
3176 if(islimsk(i) == 1) then
3185 if(t1(i,k) > 273.16) then
3188 tem = d0 * (t1(i,k) - 273.16)
3190 c0t(i,k) = c0(i) * tem1
3201 ! hchuang code change
3211 !c model tunable parameters are all here
3218 ! pgcon = 0.7 ! Gregory et al. (1997, QJRMS)
3219 pgcon = 0.55 ! Zhang & Wu (2003,JAS)
3229 !c define top layer for search of the downdraft originating layer
3230 !c and the maximum thetae for updraft
3235 tx1(i) = 1.0 / ps(i)
3240 if (prsl(i,k)*tx1(i) > 0.70) kbm(i) = k + 1
3241 if (prsl(i,k)*tx1(i) > 0.60) kmax(i) = k + 1
3245 kbm(i) = min(kbm(i),kmax(i))
3248 !c hydrostatic height assume zero terr and compute
3249 !c updraft entrainment rate as an inverse function of height
3253 zo(i,k) = phil(i,k) / g
3258 zi(i,k) = 0.5*(zo(i,k)+zo(i,k+1))
3259 xlamue(i,k) = clam / zi(i,k)
3263 xlamue(i,km) = xlamue(i,km1)
3274 if (flg(i) .and. zo(i,k) <= hpbl(i)) then
3282 kpbl(i)= min(kpbl(i),kbm(i))
3285 !c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3286 !c convert surface pressure to mb from cb
3290 if (cnvflg(i) .and. k <= kmax(i)) then
3291 pfld(i,k) = prsl(i,k) * 10.0
3305 ! uo(i,k) = u1(i,k) * rcs(i)
3306 ! vo(i,k) = v1(i,k) * rcs(i)
3316 !c p is pressure of the layer (mb)
3317 !c t is temperature at t-dt (k)..tn
3318 !c q is mixing ratio at t-dt (kg/kg)..qn
3319 !c to is temperature at t+dt (k)... this is after advection and turbulan
3320 !c qo is mixing ratio at t+dt (kg/kg)..q1
3324 if (cnvflg(i) .and. k <= kmax(i)) then
3325 qeso(i,k) = 0.01 * fpvs(to(i,k)) ! fpvs is in pa
3326 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
3328 qeso(i,k) = max(qeso(i,k), val1)
3330 qo(i,k) = max(qo(i,k), val2 )
3331 ! qo(i,k) = min(qo(i,k),qeso(i,k))
3332 ! tvo(i,k) = to(i,k) + delta * to(i,k) * qo(i,k)
3337 !c compute moist static energy
3341 if (cnvflg(i) .and. k <= kmax(i)) then
3342 ! tem = g * zo(i,k) + cp * to(i,k)
3343 tem = phil(i,k) + cp * to(i,k)
3344 heo(i,k) = tem + hvap * qo(i,k)
3345 heso(i,k) = tem + hvap * qeso(i,k)
3346 !c heo(i,k) = min(heo(i,k),heso(i,k))
3351 !c determine level with largest moist static energy within pbl
3352 !c this is the level where updraft starts
3362 if (cnvflg(i) .and. k <= kpbl(i)) then
3363 if(heo(i,k) > hmax(i)) then
3373 if (cnvflg(i) .and. k <= kmax(i)-1) then
3374 dz = .5 * (zo(i,k+1) - zo(i,k))
3375 dp = .5 * (pfld(i,k+1) - pfld(i,k))
3376 es = 0.01 * fpvs(to(i,k+1)) ! fpvs is in pa
3377 pprime = pfld(i,k+1) + epsm1 * es
3378 qs = eps * es / pprime
3379 dqsdp = - qs / pprime
3380 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
3381 dqsdt = qs * pfld(i,k+1) * desdt / (es * pprime)
3382 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
3383 dt = (g * dz + hvap * dqsdp * dp) / (cp * (1. + gamma))
3384 dq = dqsdt * dt + dqsdp * dp
3385 to(i,k) = to(i,k+1) + dt
3386 qo(i,k) = qo(i,k+1) + dq
3387 po(i,k) = .5 * (pfld(i,k) + pfld(i,k+1))
3394 if (cnvflg(i) .and. k <= kmax(i)-1) then
3395 qeso(i,k) = 0.01 * fpvs(to(i,k)) ! fpvs is in pa
3396 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + epsm1*qeso(i,k))
3398 qeso(i,k) = max(qeso(i,k), val1)
3400 qo(i,k) = max(qo(i,k), val2 )
3401 ! qo(i,k) = min(qo(i,k),qeso(i,k))
3402 heo(i,k) = .5 * g * (zo(i,k) + zo(i,k+1)) + &
3403 & cp * to(i,k) + hvap * qo(i,k)
3404 heso(i,k) = .5 * g * (zo(i,k) + zo(i,k+1)) + &
3405 & cp * to(i,k) + hvap * qeso(i,k)
3406 uo(i,k) = .5 * (uo(i,k) + uo(i,k+1))
3407 vo(i,k) = .5 * (vo(i,k) + vo(i,k+1))
3412 !c look for the level of free convection as cloud base
3416 if(flg(i)) kbcon(i) = kmax(i)
3420 if (flg(i) .and. k < kbm(i)) then
3421 if(k > kb(i) .and. heo(i,kb(i)) > heso(i,k)) then
3431 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
3437 totflg = totflg .and. (.not. cnvflg(i))
3443 ! pdot(i) = 10.* dot(i,kbcon(i))
3444 pdot(i) = 0.01 * dot(i,kbcon(i)) ! Now dot is in Pa/s
3448 !c turn off convection if pressure depth between parcel source level
3449 !c and cloud base is larger than a critical value, cinpcr
3453 if(islimsk(i) == 1) then
3464 if(pdot(i) <= w4) then
3465 tem = (pdot(i) - w4) / (w3 - w4)
3466 elseif(pdot(i) >= -w4) then
3467 tem = - (pdot(i) + w4) / (w4 - w3)
3476 ptem1= .5*(cinpcrmx-cinpcrmn)
3477 cinpcr = cinpcrmx - ptem * ptem1
3478 tem1 = pfld(i,kb(i)) - pfld(i,kbcon(i))
3480 ! randomly perturb the convection trigger
3481 !zzz if( pert_sas_local .and. ens_random_seed_local .gt. 0 ) then
3482 if( pert_sas_local ) then
3483 !zz print*, "zhang inde ens_random_seed=", ens_random_seed,ens_random_seed_local
3484 ens_random_seed_local=ran1(-ens_random_seed_local)*1000
3485 rr=2.0*ens_sasamp_local*ran1(-ens_random_seed_local)-ens_sasamp_local
3486 !zz print*, "zhang inde shsas=a", cinpcr,ens_sasamp_local,ens_random_seed_local,cinpcr
3488 !zz print*, "zhang inde shsas=b", cinpcr,ens_sasamp_local,ens_random_seed_local,cinpcr
3491 if(tem1 > cinpcr) then
3499 totflg = totflg .and. (.not. cnvflg(i))
3504 !c specify the detrainment rate for the updrafts
3508 xlamud(i) = xlamue(i,kbcon(i))
3509 ! xlamud(i) = crtlamd
3513 !c determine updraft mass flux for the subcloud layers
3518 if(k < kbcon(i) .and. k >= kb(i)) then
3519 dz = zi(i,k+1) - zi(i,k)
3520 ptem = 0.5*(xlamue(i,k)+xlamue(i,k+1))-xlamud(i)
3521 eta(i,k) = eta(i,k+1) / (1. + ptem * dz)
3527 !c compute mass flux above cloud base
3535 if(k > kbcon(i) .and. k < kmax(i)) then
3536 dz = zi(i,k) - zi(i,k-1)
3537 ptem = 0.5*(xlamue(i,k)+xlamue(i,k-1))-xlamud(i)
3538 eta(i,k) = eta(i,k-1) * (1 + ptem * dz)
3539 if(eta(i,k) <= 0.) then
3542 kbm(i) = min(kbm(i),kmax(i))
3550 !c compute updraft cloud property
3555 hcko(i,indx) = heo(i,indx)
3556 ucko(i,indx) = uo(i,indx)
3557 vcko(i,indx) = vo(i,indx)
3561 ! cm is an enhancement factor in entrainment rates for momentum
3566 if(k > kb(i) .and. k < kmax(i)) then
3567 dz = zi(i,k) - zi(i,k-1)
3568 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
3569 tem1 = 0.5 * xlamud(i) * dz
3570 factor = 1. + tem - tem1
3571 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5* &
3572 & (heo(i,k)+heo(i,k-1)))/factor
3573 dbyo(i,k) = hcko(i,k) - heso(i,k)
3575 tem = 0.5 * cm * tem
3579 ucko(i,k) = ((1.-tem)*ucko(i,k-1)+ptem*uo(i,k) &
3580 & +ptem1*uo(i,k-1))/factor
3581 vcko(i,k) = ((1.-tem)*vcko(i,k-1)+ptem*vo(i,k) &
3582 & +ptem1*vo(i,k-1))/factor
3588 !c taking account into convection inhibition due to existence of
3589 !c dry layers below cloud base
3597 if (flg(i) .and. k < kbm(i)) then
3598 if(k >= kbcon(i) .and. dbyo(i,k) > 0.) then
3607 if(kbcon1(i) == kmax(i)) cnvflg(i) = .false.
3612 tem = pfld(i,kbcon(i)) - pfld(i,kbcon1(i))
3621 totflg = totflg .and. (.not. cnvflg(i))
3626 !c calculate convective inhibition
3631 if(k > kb(i) .and. k < kbcon1(i)) then
3632 dz1 = zo(i,k+1) - zo(i,k)
3633 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
3634 rfact = 1. + delta * cp * gamma &
3636 cina(i) = cina(i) + &
3637 ! & dz1 * eta(i,k) * (g / (cp * to(i,k)))
3638 & dz1 * (g / (cp * to(i,k))) &
3639 & * dbyo(i,k) / (1. + gamma) &
3642 cina(i) = cina(i) + &
3643 ! & dz1 * eta(i,k) * g * delta *
3644 & dz1 * g * delta * &
3645 & max(val,(qeso(i,k) - qo(i,k)))
3653 ! if(islimsk(i) == 1) then
3664 ! if(pdot(i) <= w4) then
3665 ! tem = (pdot(i) - w4) / (w3 - w4)
3666 ! elseif(pdot(i) >= -w4) then
3667 ! tem = - (pdot(i) + w4) / (w4 - w3)
3673 ! tem = max(tem,val1)
3675 ! tem = min(tem,val2)
3677 ! tem1= .5*(cinacrmx-cinacrmn)
3678 ! cinacr = cinacrmx - tem * tem1
3681 if(cina(i) < cinacr) cnvflg(i) = .false.
3687 totflg = totflg .and. (.not. cnvflg(i))
3692 !c determine first guess cloud top as the level of zero buoyancy
3693 !c limited to the level of P/Ps=0.7
3697 if(flg(i)) ktcon(i) = kbm(i)
3701 if (flg(i) .and. k < kbm(i)) then
3702 if(k > kbcon1(i) .and. dbyo(i,k) < 0.) then
3710 !c specify upper limit of mass flux at cloud base
3717 dp = 1000. * del(i,k)
3718 xmbmax(i) = dp / (g * dt2)
3720 ! tem = dp / (g * dt2)
3721 ! xmbmax(i) = min(tem, xmbmax(i))
3725 !c compute cloud moisture property and precipitation
3730 qcko(i,kb(i)) = qo(i,kb(i))
3731 qrcko(i,kb(i)) = qo(i,kb(i))
3737 if(k > kb(i) .and. k < ktcon(i)) then
3738 dz = zi(i,k) - zi(i,k-1)
3739 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
3741 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
3743 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
3744 tem1 = 0.5 * xlamud(i) * dz
3745 factor = 1. + tem - tem1
3746 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
3747 & (qo(i,k)+qo(i,k-1)))/factor
3748 qrcko(i,k) = qcko(i,k)
3750 dq = eta(i,k) * (qcko(i,k) - qrch)
3752 ! rhbar(i) = rhbar(i) + qo(i,k) / qeso(i,k)
3754 !c below lfc check if there is excess moisture to release latent heat
3756 if(k >= kbcon(i) .and. dq > 0.) then
3757 etah = .5 * (eta(i,k) + eta(i,k-1))
3759 dp = 1000. * del(i,k)
3760 ptem = c0t(i,k) + c1
3761 qlk = dq / (eta(i,k) + etah * ptem * dz)
3762 dellal(i,k) = etah * c1 * dz * qlk * g / dp
3764 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
3766 buo(i,k) = buo(i,k) - g * qlk
3767 qcko(i,k)= qlk + qrch
3768 pwo(i,k) = etah * c0t(i,k) * dz * qlk
3769 cnvwt(i,k) = etah * qlk * g / dp
3772 ! compute buoyancy and drag for updraft velocity
3774 if(k >= kbcon(i)) then
3775 rfact = 1. + delta * cp * gamma &
3777 buo(i,k) = buo(i,k) + (g / (cp * to(i,k))) &
3778 & * dbyo(i,k) / (1. + gamma) &
3781 buo(i,k) = buo(i,k) + g * delta * &
3782 & max(val,(qeso(i,k) - qo(i,k)))
3783 drag(i,k) = max(xlamue(i,k),xlamud(i))
3791 !c calculate cloud work function
3795 ! if (cnvflg(i)) then
3796 ! if(k >= kbcon(i) .and. k < ktcon(i)) then
3797 ! dz1 = zo(i,k+1) - zo(i,k)
3798 ! gamma = el2orc * qeso(i,k) / (to(i,k)**2)
3799 ! rfact = 1. + delta * cp * gamma
3800 ! & * to(i,k) / hvap
3802 !! & dz1 * eta(i,k) * (g / (cp * to(i,k)))
3803 ! & dz1 * (g / (cp * to(i,k)))
3804 ! & * dbyo(i,k) / (1. + gamma)
3808 !! & dz1 * eta(i,k) * g * delta *
3809 ! & dz1 * g * delta *
3810 ! & max(val,(qeso(i,k) - qo(i,k)))
3816 ! if(cnvflg(i) .and. aa1(i) <= 0.) cnvflg(i) = .false.
3819 ! calculate cloud work function
3829 if(k >= kbcon(i) .and. k < ktcon(i)) then
3830 dz1 = zo(i,k+1) - zo(i,k)
3831 aa1(i) = aa1(i) + buo(i,k) * dz1
3837 if(cnvflg(i) .and. aa1(i) <= 0.) cnvflg(i) = .false.
3842 totflg = totflg .and. (.not. cnvflg(i))
3847 !c estimate the onvective overshooting as the level
3848 !c where the [aafac * cloud work function] becomes zero,
3849 !c which is the final cloud top
3850 !c limited to the level of P/Ps=0.7
3854 aa1(i) = aafac * aa1(i)
3865 if(k >= ktcon(i) .and. k < kbm(i)) then
3866 dz1 = zo(i,k+1) - zo(i,k)
3867 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
3868 rfact = 1. + delta * cp * gamma &
3871 ! & dz1 * eta(i,k) * (g / (cp * to(i,k)))
3872 & dz1 * (g / (cp * to(i,k))) &
3873 & * dbyo(i,k) / (1. + gamma) &
3877 !! & dz1 * eta(i,k) * g * delta *
3878 ! & dz1 * g * delta *
3879 ! & max(val,(qeso(i,k) - qo(i,k)))
3880 if(aa1(i) < 0.) then
3889 !c compute cloud moisture property, detraining cloud water
3890 !c and precipitation in overshooting layers
3895 if(k >= ktcon(i) .and. k < ktcon1(i)) then
3896 dz = zi(i,k) - zi(i,k-1)
3897 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
3899 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
3901 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
3902 tem1 = 0.5 * xlamud(i) * dz
3903 factor = 1. + tem - tem1
3904 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
3905 & (qo(i,k)+qo(i,k-1)))/factor
3906 qrcko(i,k) = qcko(i,k)
3908 dq = eta(i,k) * (qcko(i,k) - qrch)
3910 !c check if there is excess moisture to release latent heat
3913 etah = .5 * (eta(i,k) + eta(i,k-1))
3915 dp = 1000. * del(i,k)
3916 ptem = c0t(i,k) + c1
3917 qlk = dq / (eta(i,k) + etah * ptem * dz)
3918 dellal(i,k) = etah * c1 * dz * qlk * g / dp
3920 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
3922 qcko(i,k) = qlk + qrch
3923 pwo(i,k) = etah * c0t(i,k) * dz * qlk
3924 cnvwt(i,k) = etah * qlk * g / dp
3931 ! compute updraft velocity square(wu2)
3933 ! bb1 = 2. * (1.+bet1*cd1)
3934 ! bb2 = 2. / (f1*(1.+gam1))
3948 tem = po(i,k) / (rd * to(i,k))
3949 wucb = -0.01 * dot(i,k) / (tem * g)
3951 wu2(i,k) = wucb * wucb
3960 if(k > kbcon1(i) .and. k < ktcon(i)) then
3961 dz = zi(i,k) - zi(i,k-1)
3962 tem = 0.25 * bb1 * (drag(i,k)+drag(i,k-1)) * dz
3963 tem1 = 0.5 * bb2 * (buo(i,k)+buo(i,k-1)) * dz
3964 ptem = (1. - tem) * wu2(i,k-1)
3966 wu2(i,k) = (ptem + tem1) / ptem1
3967 wu2(i,k) = max(wu2(i,k), 0._kind_phys)
3973 ! compute updraft velocity averaged over the whole cumulus
3982 if(k > kbcon1(i) .and. k < ktcon(i)) then
3983 dz = zi(i,k) - zi(i,k-1)
3984 tem = 0.5 * (sqrt(wu2(i,k)) + sqrt(wu2(i,k-1)))
3985 wc(i) = wc(i) + tem * dz
3986 sumx(i) = sumx(i) + dz
3993 if(sumx(i) == 0.) then
3996 wc(i) = wc(i) / sumx(i)
3999 if (wc(i) < val) cnvflg(i)=.false.
4003 !c exchange ktcon with ktcon1
4008 ktcon(i) = ktcon1(i)
4013 !c this section is ready for cloud water
4017 !c compute liquid and vapor separation at cloud top
4022 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
4024 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
4025 dq = qcko(i,k) - qrch
4027 !c check if there is excess moisture to release latent heat
4037 !c--- compute precipitation efficiency in terms of windshear
4047 if(k > kb(i) .and. k <= ktcon(i)) then
4048 shear= sqrt((uo(i,k)-uo(i,k-1)) ** 2 &
4049 & + (vo(i,k)-vo(i,k-1)) ** 2)
4050 vshear(i) = vshear(i) + shear
4057 vshear(i) = 1.e3 * vshear(i) / (zi(i,ktcon(i))-zi(i,kb(i)))
4058 e1=1.591-.639*vshear(i) &
4059 & +.0953*(vshear(i)**2)-.00496*(vshear(i)**3)
4062 edt(i) = min(edt(i),val)
4064 edt(i) = max(edt(i),val)
4068 !c--- what would the change be, that a cloud with unit mass
4069 !c--- will do to the environment?
4073 if(cnvflg(i) .and. k <= kmax(i)) then
4082 !c--- changed due to subsidence and entrainment
4087 if(k > kb(i) .and. k < ktcon(i)) then
4088 dp = 1000. * del(i,k)
4089 dz = zi(i,k) - zi(i,k-1)
4092 dv2h = .5 * (heo(i,k) + heo(i,k-1))
4095 dv2q = .5 * (qo(i,k) + qo(i,k-1))
4098 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1))
4101 dellah(i,k) = dellah(i,k) + &
4102 & ( eta(i,k)*dv1h - eta(i,k-1)*dv3h &
4103 & - tem*eta(i,k-1)*dv2h*dz &
4104 & + tem1*eta(i,k-1)*.5*(hcko(i,k)+hcko(i,k-1))*dz &
4107 dellaq(i,k) = dellaq(i,k) + &
4108 & ( eta(i,k)*dv1q - eta(i,k-1)*dv3q &
4109 & - tem*eta(i,k-1)*dv2q*dz &
4110 & + tem1*eta(i,k-1)*.5*(qrcko(i,k)+qcko(i,k-1))*dz &
4113 tem1=eta(i,k)*(uo(i,k)-ucko(i,k))
4114 tem2=eta(i,k-1)*(uo(i,k-1)-ucko(i,k-1))
4115 dellau(i,k) = dellau(i,k) + (tem1-tem2) * g/dp
4117 tem1=eta(i,k)*(vo(i,k)-vcko(i,k))
4118 tem2=eta(i,k-1)*(vo(i,k-1)-vcko(i,k-1))
4119 dellav(i,k) = dellav(i,k) + (tem1-tem2) * g/dp
4131 dp = 1000. * del(i,indx)
4132 dv1h = heo(i,indx-1)
4133 dellah(i,indx) = eta(i,indx-1) * &
4134 & (hcko(i,indx-1) - dv1h) * g / dp
4136 dellaq(i,indx) = eta(i,indx-1) * &
4137 & (qcko(i,indx-1) - dv1q) * g / dp
4138 dellau(i,indx) = eta(i,indx-1) * &
4139 & (ucko(i,indx-1) - uo(i,indx-1)) * g / dp
4140 dellav(i,indx) = eta(i,indx-1) * &
4141 & (vcko(i,indx-1) - vo(i,indx-1)) * g / dp
4145 dellal(i,indx) = eta(i,indx-1) * &
4146 & qlko_ktcon(i) * g / dp
4151 ! compute convective turn-over time
4155 tem = zi(i,ktcon1(i)) - zi(i,kbcon1(i))
4156 dtconv(i) = tem / wc(i)
4157 dtconv(i) = max(dtconv(i),dtmin)
4158 dtconv(i) = max(dtconv(i),dt2)
4159 dtconv(i) = min(dtconv(i),dtmax)
4163 ! compute advective time scale using a mean cloud layer wind speed
4174 if(k >= kbcon1(i) .and. k < ktcon1(i)) then
4175 dz = zi(i,k) - zi(i,k-1)
4176 tem = sqrt(u1(i,k)*u1(i,k)+v1(i,k)*v1(i,k))
4177 umean(i) = umean(i) + tem * dz
4178 sumx(i) = sumx(i) + dz
4185 umean(i) = umean(i) / sumx(i)
4186 umean(i) = max(umean(i), 1._kind_phys)
4187 tauadv(i) = gdx(i) / umean(i)
4191 !c compute cloud base mass flux as a function of the mean
4197 rho = po(i,k)*100. / (rd*to(i,k))
4198 tfac = tauadv(i) / dtconv(i)
4199 tfac = min(tfac, 1._kind_phys)
4200 xmb(i) = tfac*betaw*rho*wc(i)
4204 !--- modified Grell & Freitas' (2014) updraft fraction which uses
4205 ! actual entrainment rate at cloud base
4209 tem = min(max(xlamue(i,kbcon(i)), 2.e-4_kind_phys), 6.e-4_kind_phys)
4211 tem1 = 3.14 * tem * tem
4212 sigmagfm(i) = tem1 / garea(i)
4213 sigmagfm(i) = max(sigmagfm(i), 0.001_kind_phys)
4214 sigmagfm(i) = min(sigmagfm(i), 0.999_kind_phys)
4218 !--- compute scale-aware function based on Arakawa & Wu (2013)
4223 if (gdx(i) < dxcrt) then
4224 scaldfunc(i) = (1.-sigmagfm(i)) * (1.-sigmagfm(i))
4225 scaldfunc(i) = max(min(scaldfunc(i), 1._kind_phys), 0._kind_phys)
4229 xmb(i) = xmb(i) * scaldfunc(i)
4230 xmb(i) = min(xmb(i),xmbmax(i))
4234 !c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4238 if (cnvflg(i) .and. k <= kmax(i)) then
4239 qeso(i,k) = 0.01 * fpvs(t1(i,k)) ! fpvs is in pa
4240 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
4242 qeso(i,k) = max(qeso(i,k), val )
4246 !c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4259 if(k > kb(i) .and. k <= ktcon(i)) then
4260 dellat = (dellah(i,k) - hvap * dellaq(i,k)) / cp
4261 t1(i,k) = t1(i,k) + dellat * xmb(i) * dt2
4262 q1(i,k) = q1(i,k) + dellaq(i,k) * xmb(i) * dt2
4264 ! u1(i,k) = u1(i,k) + dellau(i,k) * xmb(i) * dt2 * tem
4265 ! v1(i,k) = v1(i,k) + dellav(i,k) * xmb(i) * dt2 * tem
4266 u1(i,k) = u1(i,k) + dellau(i,k) * xmb(i) * dt2
4267 v1(i,k) = v1(i,k) + dellav(i,k) * xmb(i) * dt2
4268 dp = 1000. * del(i,k)
4269 delhbar(i) = delhbar(i) + dellah(i,k)*xmb(i)*dp/g
4270 delqbar(i) = delqbar(i) + dellaq(i,k)*xmb(i)*dp/g
4271 deltbar(i) = deltbar(i) + dellat*xmb(i)*dp/g
4272 delubar(i) = delubar(i) + dellau(i,k)*xmb(i)*dp/g
4273 delvbar(i) = delvbar(i) + dellav(i,k)*xmb(i)*dp/g
4282 if(k > kb(i) .and. k <= ktcon(i)) then
4283 qeso(i,k) = 0.01 * fpvs(t1(i,k)) ! fpvs is in pa
4284 qeso(i,k) = eps * qeso(i,k)/(pfld(i,k) + epsm1*qeso(i,k))
4286 qeso(i,k) = max(qeso(i,k), val )
4301 if(k < ktcon(i) .and. k > kb(i)) then
4302 rntot(i) = rntot(i) + pwo(i,k) * xmb(i) * .001 * dt2
4312 if (k <= kmax(i)) then
4317 if(k < ktcon(i) .and. k > kb(i)) then
4318 rn(i) = rn(i) + pwo(i,k) * xmb(i) * .001 * dt2
4321 if(flg(i) .and. k < ktcon(i)) then
4322 evef = edt(i) * evfact
4323 if(islimsk(i) == 1) evef=edt(i) * evfactl
4324 ! if(islimsk(i) == 1) evef=.07
4325 !c if(islimsk(i) == 1) evef = 0.
4326 qcond(i) = evef * (q1(i,k) - qeso(i,k)) &
4327 & / (1. + el2orc * qeso(i,k) / t1(i,k)**2)
4328 dp = 1000. * del(i,k)
4329 if(rn(i) > 0. .and. qcond(i) < 0.) then
4330 qevap(i) = -qcond(i) * (1.-exp(-.32*sqrt(dt2*rn(i))))
4331 qevap(i) = min(qevap(i), rn(i)*1000.*g/dp)
4332 delq2(i) = delqev(i) + .001 * qevap(i) * dp / g
4334 if(rn(i) > 0. .and. qcond(i) < 0. .and. &
4335 & delq2(i) > rntot(i)) then
4336 qevap(i) = 1000.* g * (rntot(i) - delqev(i)) / dp
4339 if(rn(i) > 0. .and. qevap(i) > 0.) then
4341 tem1 = qevap(i) * tem
4342 if(tem1 > rn(i)) then
4343 qevap(i) = rn(i) / tem
4346 rn(i) = rn(i) - tem1
4348 q1(i,k) = q1(i,k) + qevap(i)
4349 t1(i,k) = t1(i,k) - elocp * qevap(i)
4350 deltv(i) = - elocp*qevap(i)/dt2
4351 delq(i) = + qevap(i)/dt2
4352 delqev(i) = delqev(i) + .001*dp*qevap(i)/g
4354 delqbar(i) = delqbar(i) + delq(i)*dp/g
4355 deltbar(i) = deltbar(i) + deltv(i)*dp/g
4362 ! if(me == 31 .and. cnvflg(i)) then
4363 ! if(cnvflg(i)) then
4364 ! print *, ' shallow delhbar, delqbar, deltbar = ',
4365 ! & delhbar(i),hvap*delqbar(i),cp*deltbar(i)
4366 ! print *, ' shallow delubar, delvbar = ',delubar(i),delvbar(i)
4367 ! print *, ' precip =', hvap*rn(i)*1000./dt2
4368 ! print*,'pdif= ',pfld(i,kbcon(i))-pfld(i,ktcon(i))
4374 if(rn(i) < 0. .or. .not.flg(i)) rn(i) = 0.
4381 !c convective cloud water
4386 if (k >= kbcon(i) .and. k < ktcon(i)) then
4387 cnvw(i,k) = cnvwt(i,k) * xmb(i) * dt2
4394 !c convective cloud cover
4399 if (k >= kbcon(i) .and. k < ktcon(i)) then
4400 cnvc(i,k) = 0.04 * log(1. + 675. * eta(i,k) * xmb(i))
4401 cnvc(i,k) = min(cnvc(i,k), 0.2_kind_phys)
4402 cnvc(i,k) = max(cnvc(i,k), 0.0_kind_phys)
4411 if (ncloud > 0) then
4416 ! if (k > kb(i) .and. k <= ktcon(i)) then
4417 if (k >= kbcon(i) .and. k <= ktcon(i)) then
4418 tem = dellal(i,k) * xmb(i) * dt2
4419 tem1 = max(0.0_kind_phys, min(1.0_kind_phys, (tcr-t1(i,k))*tcrf))
4420 if (ql(i,k,2) > -999.0) then
4421 ql(i,k,1) = ql(i,k,1) + tem * tem1 ! ice
4422 ql(i,k,2) = ql(i,k,2) + tem *(1.0-tem1) ! water
4424 ql(i,k,1) = ql(i,k,1) + tem
4433 ! hchuang code change
4438 if(k >= kb(i) .and. k < ktop(i)) then
4439 ud_mf(i,k) = eta(i,k) * xmb(i) * dt2
4447 dt_mf(i,k) = ud_mf(i,k)
4452 end subroutine mfshalcnv
4453 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4454 END MODULE module_cu_scalesas