5 MODULE module_shcu_nscv
7 !-------------------------------------------------------------------------------
8 subroutine shcu_nscv(dt,p3di,p3d,pi3d,qc3d,qi3d,rho3d, &
9 qv3d,t3d,raincv,xland,dz8w,w,u3d,v3d, &
13 cp,cliq,cpv,g,xlv,r_d,r_v,ep_1,ep_2, &
14 cice,xls,psat,f_qi,f_qc, &
15 rthshten,rqvshten,rqcshten,rqishten, &
18 ids,ide, jds,jde, kds,kde, &
19 ims,ime, jms,jme, kms,kme, &
20 its,ite, jts,jte, kts,kte)
21 !-------------------------------------------------------------------------------
23 !-------------------------------------------------------------------------------
25 !-- p3di 3d pressure (pa) at interface level
26 !-- p3d 3d pressure (pa)
27 !-- pi3d 3d exner function (dimensionless)
28 !-- z height above sea level (m)
29 !-- qc3d cloud water mixing ratio (kg/kg)
30 !-- qi3d cloud ice mixing ratio (kg/kg)
31 !-- qv3d 3d water vapor mixing ratio (kg/kg)
32 !-- t3d temperature (k)
33 !-- w vertical velocity (m/s)
34 !-- dz8w dz between full levels (m)
35 !-- u3d 3d u-velocity interpolated to theta points (m/s)
36 !-- v3d 3d v-velocity interpolated to theta points (m/s)
37 !-- ids start index for i in domain
38 !-- ide end index for i in domain
39 !-- jds start index for j in domain
40 !-- jde end index for j in domain
41 !-- kds start index for k in domain
42 !-- kde end index for k in domain
43 !-- ims start index for i in memory
44 !-- ime end index for i in memory
45 !-- jms start index for j in memory
46 !-- jme end index for j in memory
47 !-- kms start index for k in memory
48 !-- kme end index for k in memory
49 !-- its start index for i in tile
50 !-- ite end index for i in tile
51 !-- jts start index for j in tile
52 !-- jte end index for j in tile
53 !-- kts start index for k in tile
54 !-- kte end index for k in tile
55 !-------------------------------------------------------------------------------
56 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
57 ims,ime, jms,jme, kms,kme, &
58 its,ite, jts,jte, kts,kte
59 real, intent(in ) :: cp,cliq,cpv,g,xlv,r_d,r_v,ep_1,ep_2, &
61 real, intent(in ) :: dt
62 real, optional, intent(in ) :: pgcon
63 real, dimension( ims:ime, kms:kme, jms:jme ),optional ,&
64 intent(inout) :: rthshten,&
70 logical, optional :: F_QC,F_QI
71 real, dimension( ims:ime, kms:kme, jms:jme ) ,&
79 real, dimension( ims:ime, kms:kme, jms:jme ) ,&
81 real, dimension( ims:ime, kms:kme, jms:jme ) ,&
84 real, dimension( ims:ime, jms:jme ) , &
86 real, dimension( ims:ime, jms:jme ) ,&
87 intent(inout) :: pratesh
88 real, dimension( ims:ime, jms:jme ) ,&
92 real, dimension( ims:ime, jms:jme ) ,&
95 real, dimension( ims:ime, kms:kme, jms:jme ) ,&
99 real, dimension( ims:ime, jms:jme ) ,&
100 intent(in ) :: hpbl,&
103 integer, intent(in ) :: mp_physics
108 real, dimension( its:ite, kts:kte ) :: del,&
117 real, dimension( its:ite, kts:kte+1 ) :: prsii,&
119 real, dimension( its:ite, kts:kte ) :: zll
120 real, dimension( its:ite) :: rain
122 integer, dimension (its:ite) :: kbot,&
128 ! microphysics scheme --> ncloud
130 if (mp_physics .eq. 0) then
132 elseif ( mp_physics .eq. 1 .or. mp_physics .eq. 3 ) then
138 if(present(pgcon)) then
141 ! pgcon_use = 0.7 ! Gregory et al. (1997, QJRMS)
142 pgcon_use = 0.55 ! Zhang & Wu (2003,JAS)
143 ! 0.55 is a physically-based value used by GFS
144 ! HWRF uses 0.2, for model tuning purposes
156 dot(i,k) = -5.0e-4*g*rho3d(i,k,j)*(w(i,k,j)+w(i,kp,j))
157 prsll(i,k)=p3d(i,k,j)*0.001
158 prsii(i,k)=p3di(i,k,j)*0.001
163 prsii(i,kte+1)=p3di(i,kte+1,j)*0.001
172 zii(i,k+1)=zii(i,k)+dz8w(i,k,j)
178 zll(i,k)=0.5*(zii(i,k)+zii(i,k+1))
184 del(i,k)=prsll(i,k)*g/r_d*dz8w(i,k,j)/t3d(i,k,j)
188 ! q1(i,k)=qv3d(i,k,j)/(1.+qv3d(i,k,j))
190 qi2(i,k) = qi3d(i,k,j)
191 qc2(i,k) = qc3d(i,k,j)
197 if(raincv(i,j) .gt. 1.e-30) icps(i)=1
202 call nscv2d(delt=delt,del=del(its,kts),prsl=prsll(its,kts), &
203 prsi=prsii(its,kts),prslk=pi3d(ims,kms,j),zl=zll(its,kts), &
204 ncloud=ncloud,qc2=qc2(its,kts),qi2=qi2(its,kts), &
205 q1=q1(its,kts),t1=t1(its,kts),rain=rain(its), &
206 kbot=kbot(its),ktop=ktop(its), &
208 slimsk=xland(ims,j),dot=dot(its,kts), &
209 u1=u1(its,kts), v1=v1(its,kts), &
210 cp_=cp,cliq_=cliq,cvap_=cpv,g_=g,hvap_=xlv, &
211 rd_=r_d,rv_=r_v,fv_=ep_1,ep2=ep_2, &
212 cice=cice,xls=xls,psat=psat, &
213 hpbl=hpbl(ims,j),hfx=hfx(ims,j),qfx=qfx(ims,j), &
215 ids=ids,ide=ide, jds=jds,jde=jde, kds=kds,kde=kde, &
216 ims=ims,ime=ime, jms=jms,jme=jme, kms=kms,kme=kme, &
217 its=its,ite=ite, jts=jts,jte=jte, kts=kts,kte=kte )
220 pratesh(i,j) = rain(i)*1000./dt
225 IF(PRESENT(rthshten).AND.PRESENT(rqvshten)) THEN
228 rthshten(i,k,j)=(t1(i,k)-t3d(i,k,j))/pi3d(i,k,j)*rdelt
229 rqvshten(i,k,j)=(q1(i,k)-qv3d(i,k,j))*rdelt
234 IF(PRESENT(rushten).AND.PRESENT(rvshten)) THEN
237 rushten(i,k,j)=(u1(i,k)-u3d(i,k,j))*rdelt
238 rvshten(i,k,j)=(v1(i,k)-v3d(i,k,j))*rdelt
243 IF(PRESENT( rqishten )) THEN
247 rqishten(i,k,j)=(qi2(i,k)-qi3d(i,k,j))*rdelt
253 IF(PRESENT( rqcshten )) THEN
257 rqcshten(i,k,j)=(qc2(i,k)-qc3d(i,k,j))*rdelt
263 enddo ! outer most J_loop
266 end subroutine shcu_nscv
267 !-------------------------------------------------------------------------------
269 !-------------------------------------------------------------------------------
270 ! NCEP SCV (Shallow Convection Scheme)
271 !-------------------------------------------------------------------------------
272 subroutine nscv2d(delt,del,prsl,prsi,prslk,zl, &
273 ncloud,qc2,qi2,q1,t1,rain,kbot,ktop, &
276 cp_,cliq_,cvap_,g_,hvap_,rd_,rv_,fv_,ep2, &
280 ids,ide, jds,jde, kds,kde, &
281 ims,ime, jms,jme, kms,kme, &
282 its,ite, jts,jte, kts,kte)
283 !-------------------------------------------------------------------------------
285 ! subprogram: nscv2d computes shallow-convective heating and moistening
287 ! abstract: computes non-precipitating convective heating and moistening
288 ! using a one cloud type arakawa-schubert convection scheme as in the ncep
289 ! sas scheme. the scheme has been operational at ncep gfs model since july 2010
290 ! the scheme includes updraft and downdraft effects, but the cloud depth is
291 ! limited less than 150 hpa.
293 ! developed by jong-il han and hua-lu pan
294 ! implemented into wrf by jihyeon jang and songyou hong
295 ! module with cpp-based options is available in grims
297 ! program history log:
298 ! 10-07-01 jong-il han initial operational implementation at ncep gfs
299 ! 10-12-01 jihyeon jang implemented into wrf
300 ! 18-05-04 jihyeon jang seperated the shallow convection module from nsas
302 ! subprograms called:
303 ! fpvs - function to compute saturation vapor pressure
306 ! han and pan (2011, wea. forecasting)
308 !-------------------------------------------------------------------------------
310 !-------------------------------------------------------------------------------
314 integer :: ids,ide, jds,jde, kds,kde, &
315 ims,ime, jms,jme, kms,kme, &
316 its,ite, jts,jte, kts,kte
317 real :: cp_,cliq_,cvap_,g_,hvap_,rd_,rv_,fv_,ep2
318 real :: pi_,qmin_,t0c_
319 real :: cice,xlv0,xls,psat
322 real :: del(its:ite,kts:kte), &
323 prsl(its:ite,kts:kte),prslk(ims:ime,kms:kme), &
324 prsi(its:ite,kts:kte+1),zl(its:ite,kts:kte)
326 real :: slimsk(ims:ime)
327 real :: dot(its:ite,kts:kte)
328 real :: hpbl(ims:ime)
330 real :: hfx(ims:ime),qfx(ims:ime)
332 real :: qi2(its:ite,kts:kte),qc2(its:ite,kts:kte)
333 real :: q1(its:ite,kts:kte), &
334 t1(its:ite,kts:kte), &
335 u1(its:ite,kts:kte), &
337 integer :: icps(its:ite)
339 real :: rain(its:ite)
340 integer :: kbot(its:ite),ktop(its:ite)
342 ! local variables and arrays
344 integer :: i,j,indx, jmn, k, kk, km1
345 integer :: kpbl(its:ite)
348 desdt, deta, detad, dg, &
349 dh, dhh, dlnsig, dp, &
350 dq, dqsdp, dqsdt, dt, &
359 evef, evfact, evfactl, &
361 gamma, pprime, betaw, &
363 rfact, shear, tem1, &
365 val2, w1, w1l, w1s, &
368 w4s, tem, ptem, ptem1, &
371 integer :: kb(its:ite), kbcon(its:ite), kbcon1(its:ite), &
372 ktcon(its:ite), ktcon1(its:ite), &
373 kbm(its:ite), kmax(its:ite)
375 real :: aa1(its:ite), &
376 delhbar(its:ite), delq(its:ite), &
377 delq2(its:ite), delqev(its:ite), rntot(its:ite), &
378 delqbar(its:ite), deltbar(its:ite), &
379 deltv(its:ite), edt(its:ite), &
380 wstar(its:ite), sflx(its:ite), &
381 pdot(its:ite), po(its:ite,kts:kte), &
382 qcond(its:ite), qevap(its:ite), hmax(its:ite), &
384 xlamud(its:ite), xmb(its:ite), xmbmax(its:ite)
385 real :: delubar(its:ite), delvbar(its:ite)
389 real :: thx(its:ite, kts:kte)
390 real :: rhox(its:ite)
393 real :: p(its:ite,kts:kte), to(its:ite,kts:kte), &
394 qo(its:ite,kts:kte), qeso(its:ite,kts:kte), &
395 uo(its:ite,kts:kte), vo(its:ite,kts:kte)
399 real :: qlko_ktcon(its:ite), dellal(its:ite,kts:kte), &
400 dbyo(its:ite,kts:kte), &
401 xlamue(its:ite,kts:kte), &
402 heo(its:ite,kts:kte), heso(its:ite,kts:kte), &
403 dellah(its:ite,kts:kte), dellaq(its:ite,kts:kte), &
404 dellau(its:ite,kts:kte), dellav(its:ite,kts:kte), &
405 ucko(its:ite,kts:kte), vcko(its:ite,kts:kte), &
406 hcko(its:ite,kts:kte), qcko(its:ite,kts:kte), &
407 eta(its:ite,kts:kte), zi(its:ite,kts:kte+1), &
410 logical :: totflg, cnvflg(its:ite), flg(its:ite)
412 ! physical parameters
414 real,parameter :: c0=.002,c1=5.e-4
415 real,parameter :: cincrmax=180.,cincrmin=120.,dthk=25.
416 real :: el2orc,fact1,fact2,eps
417 real,parameter :: h1=0.33333333
418 real,parameter :: tf=233.16, tcr=263.16, tcrf=1.0/(tcr-tf)
419 !-------------------------------------------------------------------------------
426 ! compute surface buoyancy flux
430 thx(i,k) = t1(i,k)/prslk(i,k)
435 tvcon = (1.+fv_*q1(i,1))
436 rhox(i) = prsl(i,1)*1.e3/(rd_*t1(i,1)*tvcon)
440 ! sflx(i) = heat(i)+fv_*t1(i,1)*evap(i)
441 sflx(i) = hfx(i)/rhox(i)/cp_ + qfx(i)/rhox(i)*fv_*thx(i,1)
448 if(icps(i).eq.1) cnvflg(i) = .false.
449 if(sflx(i).le.0.) cnvflg(i) = .false.
467 totflg = totflg .and. (.not. cnvflg(i))
473 dtmin = max(dt2, val )
475 dtmax = max(dt2, val )
477 ! model tunable parameters are all here
486 ! define miscellaneous values
488 el2orc = hvap_*hvap_/(rv_*cp_)
490 fact1 = (cvap_-cliq_)/rv_
491 fact2 = hvap_/rv_-fact1*t0c_
502 ! define top layer for search of the downdraft originating layer
503 ! and the maximum thetae for updraft
512 if (prsl(i,k).gt.prsi(i,1)*0.70) kbm(i) = k + 1
513 if (prsl(i,k).gt.prsi(i,1)*0.60) kmax(i) = k + 1
518 kbm(i) = min(kbm(i),kmax(i))
521 ! hydrostatic height assume zero terr and compute
522 ! updraft entrainment rate as an inverse function of height
526 zi(i,k) = 0.5*(zl(i,k-1)+zl(i,k))
532 xlamue(i,k) = clam / zi(i,k+1)
537 xlamue(i,kte) = xlamue(i,km1)
549 if (flg(i).and.zl(i,k).le.hpbl(i)) then
558 kpbl(i)= min(kpbl(i),kbm(i))
561 ! convert surface pressure to mb from cb
566 if (cnvflg(i) .and. k .le. kmax(i)) then
567 p(i,k) = prsl(i,k) * 10.0
578 uo(i,k) = u1(i,k) * rcs
579 vo(i,k) = v1(i,k) * rcs
586 ! p is pressure of the layer (mb)
587 ! t is temperature at t-dt (k)..tn
588 ! q is mixing ratio at t-dt (kg/kg)..qn
589 ! to is temperature at t+dt (k)... this is after advection and turbulan
590 ! qo is mixing ratio at t+dt (kg/kg)..q1
594 if (cnvflg(i) .and. k .le. kmax(i)) then
595 qeso(i,k) = 0.01 * fpvs(to(i,k),1,rd_,rv_,cvap_,cliq_,cice,xlv0,xls,psat,t0c_)
596 qeso(i,k) = eps * qeso(i,k) / (p(i,k) + (eps-1.)*qeso(i,k))
598 qeso(i,k) = max(qeso(i,k), val1)
600 qo(i,k) = max(qo(i,k), val2 )
605 ! compute moist static energy
609 if (cnvflg(i) .and. k .le. kmax(i)) then
610 tem = g_ * zl(i,k) + cp_ * to(i,k)
611 heo(i,k) = tem + hvap_ * qo(i,k)
612 heso(i,k) = tem + hvap_ * qeso(i,k)
617 ! determine level with largest moist static energy within pbl
618 ! this is the level where updraft starts
629 if (cnvflg(i).and.k.le.kpbl(i)) then
630 if(heo(i,k).gt.hmax(i)) then
640 if (cnvflg(i) .and. k .le. kmax(i)-1) then
641 dz = .5 * (zl(i,k+1) - zl(i,k))
642 dp = .5 * (p(i,k+1) - p(i,k))
643 es = 0.01*fpvs(to(i,k+1),1,rd_,rv_,cvap_,cliq_,cice,xlv0,xls,psat,t0c_)
644 pprime = p(i,k+1) + (eps-1.) * es
645 qs = eps * es / pprime
646 dqsdp = - qs / pprime
647 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
648 dqsdt = qs * p(i,k+1) * desdt / (es * pprime)
649 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
650 dt = (g_ * dz + hvap_ * dqsdp * dp) / (cp_ * (1. + gamma))
651 dq = dqsdt * dt + dqsdp * dp
652 to(i,k) = to(i,k+1) + dt
653 qo(i,k) = qo(i,k+1) + dq
654 po(i,k) = .5 * (p(i,k) + p(i,k+1))
661 if (cnvflg(i) .and. k .le. kmax(i)-1) then
662 qeso(i,k)=0.01*fpvs(to(i,k),1,rd_,rv_,cvap_,cliq_,cice,xlv0,xls,psat,t0c_)
663 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + (eps-1.) * qeso(i,k))
665 qeso(i,k) = max(qeso(i,k), val1)
667 qo(i,k) = max(qo(i,k), val2 )
668 heo(i,k) = .5 * g_ * (zl(i,k) + zl(i,k+1)) + &
669 cp_ * to(i,k) + hvap_ * qo(i,k)
670 heso(i,k) = .5 * g_ * (zl(i,k) + zl(i,k+1)) + &
671 cp_ * to(i,k) + hvap_ * qeso(i,k)
672 uo(i,k) = .5 * (uo(i,k) + uo(i,k+1))
673 vo(i,k) = .5 * (vo(i,k) + vo(i,k+1))
678 ! look for the level of free convection as cloud base
682 if(flg(i)) kbcon(i) = kmax(i)
687 if (flg(i).and.k.lt.kbm(i)) then
688 if(k.gt.kb(i).and.heo(i,kb(i)).gt.heso(i,k)) then
698 if(kbcon(i).eq.kmax(i)) cnvflg(i) = .false.
704 totflg = totflg .and. (.not. cnvflg(i))
708 ! determine critical convective inhibition
709 ! as a function of vertical velocity at cloud base.
713 pdot(i) = 10.* dot(i,kbcon(i))
719 if(slimsk(i).eq.1.) then
730 if(pdot(i).le.w4) then
731 ptem = (pdot(i) - w4) / (w3 - w4)
732 elseif(pdot(i).ge.-w4) then
733 ptem = - (pdot(i) + w4) / (w4 - w3)
738 ptem = max(ptem,val1)
740 ptem = min(ptem,val2)
742 ptem1= .5*(cincrmax-cincrmin)
743 cincr = cincrmax - ptem * ptem1
744 tem1 = p(i,kb(i)) - p(i,kbcon(i))
745 if(tem1.gt.cincr) then
753 totflg = totflg .and. (.not. cnvflg(i))
757 ! assume the detrainment rate for the updrafts to be same as
758 ! the entrainment rate at cloud base
762 xlamud(i) = xlamue(i,kbcon(i))
766 ! determine updraft mass flux for the subcloud layers
771 if(k.lt.kbcon(i).and.k.ge.kb(i)) then
772 dz = zi(i,k+2) - zi(i,k+1)
773 ptem = 0.5*(xlamue(i,k)+xlamue(i,k+1))-xlamud(i)
774 eta(i,k) = eta(i,k+1) / (1. + ptem * dz)
780 ! compute mass flux above cloud base
785 if(k.gt.kbcon(i).and.k.lt.kmax(i)) then
786 dz = zi(i,k+1) - zi(i,k)
787 ptem = 0.5*(xlamue(i,k)+xlamue(i,k-1))-xlamud(i)
788 eta(i,k) = eta(i,k-1) * (1 + ptem * dz)
794 ! compute updraft cloud property
799 hcko(i,indx) = heo(i,indx)
800 ucko(i,indx) = uo(i,indx)
801 vcko(i,indx) = vo(i,indx)
808 if(k.gt.kb(i).and.k.lt.kmax(i)) then
809 dz = zi(i,k+1) - zi(i,k)
810 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
811 tem1 = 0.5 * xlamud(i) * dz
812 factor = 1. + tem - tem1
813 ptem = 0.5 * tem + pgcon
814 ptem1= 0.5 * tem - pgcon
815 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5* &
816 (heo(i,k)+heo(i,k-1)))/factor
817 ucko(i,k) = ((1.-tem1)*ucko(i,k-1)+ptem*uo(i,k) &
818 +ptem1*uo(i,k-1))/factor
819 vcko(i,k) = ((1.-tem1)*vcko(i,k-1)+ptem*vo(i,k) &
820 +ptem1*vo(i,k-1))/factor
821 dbyo(i,k) = hcko(i,k) - heso(i,k)
827 ! taking account into convection inhibition due to existence of
828 ! dry layers below cloud base
837 if (flg(i).and.k.lt.kbm(i)) then
838 if(k.ge.kbcon(i).and.dbyo(i,k).gt.0.) then
848 if(kbcon1(i).eq.kmax(i)) cnvflg(i) = .false.
854 tem = p(i,kbcon(i)) - p(i,kbcon1(i))
863 totflg = totflg .and. (.not. cnvflg(i))
867 ! determine first guess cloud top as the level of zero buoyancy
868 ! limited to the level of sigma=0.7
872 if(flg(i)) ktcon(i) = kbm(i)
877 if (flg(i).and.k .lt. kbm(i)) then
878 if(k.gt.kbcon1(i).and.dbyo(i,k).lt.0.) then
886 ! specify upper limit of mass flux at cloud base
891 dp = 1000. * del(i,k)
892 xmbmax(i) = dp / (g_ * dt2)
896 ! compute cloud moisture property and precipitation
901 qcko(i,kb(i)) = qo(i,kb(i))
908 if(k.gt.kb(i).and.k.lt.ktcon(i)) then
909 dz = zi(i,k+1) - zi(i,k)
910 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
911 qrch = qeso(i,k) + gamma * dbyo(i,k) / (hvap_ * (1. + gamma))
912 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
913 tem1 = 0.5 * xlamud(i) * dz
914 factor = 1. + tem - tem1
915 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
916 (qo(i,k)+qo(i,k-1)))/factor
917 dq = eta(i,k) * (qcko(i,k) - qrch)
919 ! rhbar(i) = rhbar(i) + qo(i,k) / qeso(i,k)
921 ! below lfc check if there is excess moisture to release latent heat
923 if(k.ge.kbcon(i).and.dq.gt.0.) then
924 etah = .5 * (eta(i,k) + eta(i,k-1))
926 dp = 1000. * del(i,k)
927 qlk = dq / (eta(i,k) + etah * (c0 + c1) * dz)
928 dellal(i,k) = etah * c1 * dz * qlk * g_ / dp
930 qlk = dq / (eta(i,k) + etah * c0 * dz)
932 aa1(i) = aa1(i) - dz * g_ * qlk
933 qcko(i,k)= qlk + qrch
934 pwo(i,k) = etah * c0 * dz * qlk
941 ! calculate cloud work function
946 if(k.ge.kbcon(i).and.k.lt.ktcon(i)) then
947 dz1 = zl(i,k+1) - zl(i,k)
948 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
949 rfact = 1. + fv_ * cp_ * gamma * to(i,k) / hvap_
950 aa1(i) = aa1(i) + dz1 * (g_ / (cp_ * to(i,k))) &
951 * dbyo(i,k) / (1. + gamma) * rfact
953 aa1(i)=aa1(i)+ dz1 * g_ * fv_ * max(val,(qeso(i,k) - qo(i,k)))
960 if(cnvflg(i).and.aa1(i).le.0.) cnvflg(i) = .false.
965 totflg = totflg .and. (.not. cnvflg(i))
969 ! estimate the convective overshooting as the level
970 ! where the [aafac * cloud work function] becomes zero,
971 ! which is the final cloud top limited to the level of sigma=0.7
975 aa1(i) = aafac * aa1(i)
987 if(k.ge.ktcon(i).and.k.lt.kbm(i)) then
988 dz1 = zl(i,k+1) - zl(i,k)
989 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
990 rfact = 1. + fv_ * cp_ * gamma &
993 dz1 * (g_ / (cp_ * to(i,k))) &
994 * dbyo(i,k) / (1. + gamma) * rfact
995 if(aa1(i).lt.0.) then
1004 ! compute cloud moisture property, detraining cloud water
1005 ! and precipitation in overshooting layers
1010 if(k.ge.ktcon(i).and.k.lt.ktcon1(i)) then
1011 dz = zi(i,k+1) - zi(i,k)
1012 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1014 + gamma * dbyo(i,k) / (hvap_ * (1. + gamma))
1015 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1016 tem1 = 0.5 * xlamud(i) * dz
1017 factor = 1. + tem - tem1
1018 qcko(i,k) = ((1.-tem1)*qcko(i,k-1)+tem*0.5* &
1019 (qo(i,k)+qo(i,k-1)))/factor
1020 dq = eta(i,k) * (qcko(i,k) - qrch)
1022 ! check if there is excess moisture to release latent heat
1025 etah = .5 * (eta(i,k) + eta(i,k-1))
1026 if(ncloud.gt.0) then
1027 dp = 1000. * del(i,k)
1028 qlk = dq / (eta(i,k) + etah * (c0 + c1) * dz)
1029 dellal(i,k) = etah * c1 * dz * qlk * g_ / dp
1031 qlk = dq / (eta(i,k) + etah * c0 * dz)
1033 qcko(i,k) = qlk + qrch
1034 pwo(i,k) = etah * c0 * dz * qlk
1041 ! exchange ktcon with ktcon1
1046 ktcon(i) = ktcon1(i)
1051 ! this section is ready for cloud water
1053 if(ncloud.gt.0) then
1055 ! compute liquid and vapor separation at cloud top
1060 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1062 + gamma * dbyo(i,k) / (hvap_ * (1. + gamma))
1063 dq = qcko(i,k) - qrch
1065 ! check if there is excess moisture to release latent heat
1076 !--- compute precipitation efficiency in terms of windshear
1087 if(k.gt.kb(i).and.k.le.ktcon(i)) then
1088 shear= sqrt((uo(i,k)-uo(i,k-1)) ** 2 + (vo(i,k)-vo(i,k-1)) ** 2)
1089 vshear(i) = vshear(i) + shear
1097 vshear(i) = 1.e3 * vshear(i) / (zi(i,ktcon(i)+1)-zi(i,kb(i)+1))
1098 e1=1.591-.639*vshear(i) &
1099 +.0953*(vshear(i)**2)-.00496*(vshear(i)**3)
1102 edt(i) = min(edt(i),val)
1104 edt(i) = max(edt(i),val)
1108 !--- what would the change be, that a cloud with unit mass
1109 !--- will do to the environment?
1113 if(cnvflg(i) .and. k .le. kmax(i)) then
1122 !--- changed due to subsidence and entrainment
1127 if(k.gt.kb(i).and.k.lt.ktcon(i)) then
1128 dp = 1000. * del(i,k)
1129 dz = zi(i,k+1) - zi(i,k)
1132 dv2h = .5 * (heo(i,k) + heo(i,k-1))
1135 dv2q = .5 * (qo(i,k) + qo(i,k-1))
1138 dv2u = .5 * (uo(i,k) + uo(i,k-1))
1141 dv2v = .5 * (vo(i,k) + vo(i,k-1))
1144 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1))
1147 dellah(i,k) = dellah(i,k) + &
1148 ( eta(i,k)*dv1h - eta(i,k-1)*dv3h &
1149 - tem*eta(i,k-1)*dv2h*dz &
1150 + tem1*eta(i,k-1)*.5*(hcko(i,k)+hcko(i,k-1))*dz ) *g_/dp
1152 dellaq(i,k) = dellaq(i,k) + &
1153 ( eta(i,k)*dv1q - eta(i,k-1)*dv3q &
1154 - tem*eta(i,k-1)*dv2q*dz &
1155 + tem1*eta(i,k-1)*.5*(qcko(i,k)+qcko(i,k-1))*dz ) *g_/dp
1157 dellau(i,k) = dellau(i,k) + &
1158 ( eta(i,k)*dv1u - eta(i,k-1)*dv3u &
1159 - tem*eta(i,k-1)*dv2u*dz &
1160 + tem1*eta(i,k-1)*.5*(ucko(i,k)+ucko(i,k-1))*dz &
1161 - pgcon*eta(i,k-1)*(dv1u-dv3u) ) *g_/dp
1163 dellav(i,k) = dellav(i,k) + &
1164 ( eta(i,k)*dv1v - eta(i,k-1)*dv3v &
1165 - tem*eta(i,k-1)*dv2v*dz &
1166 + tem1*eta(i,k-1)*.5*(vcko(i,k)+vcko(i,k-1))*dz &
1167 - pgcon*eta(i,k-1)*(dv1v-dv3v) ) *g_/dp
1179 dp = 1000. * del(i,indx)
1180 dv1h = heo(i,indx-1)
1181 dellah(i,indx) = eta(i,indx-1) * &
1182 (hcko(i,indx-1) - dv1h) * g_ / dp
1184 dellaq(i,indx) = eta(i,indx-1) * &
1185 (qcko(i,indx-1) - dv1q) * g_ / dp
1187 dellau(i,indx) = eta(i,indx-1) * &
1188 (ucko(i,indx-1) - dv1u) * g_ / dp
1190 dellav(i,indx) = eta(i,indx-1) * &
1191 (vcko(i,indx-1) - dv1v) * g_ / dp
1195 dellal(i,indx) = eta(i,indx-1) * &
1196 qlko_ktcon(i) * g_ / dp
1200 ! mass flux at cloud base for shallow convection
1206 ptem = g_*sflx(i)*hpbl(i)/t1(i,1)
1208 tem = po(i,k)*100. / (rd_*t1(i,k))
1209 xmb(i) = betaw*tem*wstar(i)
1210 xmb(i) = min(xmb(i),xmbmax(i))
1216 if (cnvflg(i) .and. k .le. kmax(i)) then
1217 qeso(i,k)=0.01* fpvs(t1(i,k),1,rd_,rv_,cvap_,cliq_,cice,xlv0,xls,psat,t0c_)
1218 qeso(i,k) = eps * qeso(i,k) / (p(i,k) + (eps-1.)*qeso(i,k))
1220 qeso(i,k) = max(qeso(i,k), val )
1237 if(k.gt.kb(i).and.k.le.ktcon(i)) then
1238 dellat = (dellah(i,k) - hvap_ * dellaq(i,k)) / cp_
1239 t1(i,k) = t1(i,k) + dellat * xmb(i) * dt2
1240 q1(i,k) = q1(i,k) + dellaq(i,k) * xmb(i) * dt2
1242 u1(i,k) = u1(i,k) + dellau(i,k) * xmb(i) * dt2 * tem
1243 v1(i,k) = v1(i,k) + dellav(i,k) * xmb(i) * dt2 * tem
1244 dp = 1000. * del(i,k)
1245 delhbar(i) = delhbar(i) + dellah(i,k)*xmb(i)*dp/g_
1246 delqbar(i) = delqbar(i) + dellaq(i,k)*xmb(i)*dp/g_
1247 deltbar(i) = deltbar(i) + dellat*xmb(i)*dp/g_
1248 delubar(i) = delubar(i) + dellau(i,k)*xmb(i)*dp/g_
1249 delvbar(i) = delvbar(i) + dellav(i,k)*xmb(i)*dp/g_
1258 if(k.gt.kb(i).and.k.le.ktcon(i)) then
1259 qeso(i,k)=0.01* fpvs(t1(i,k),1,rd_,rv_,cvap_,cliq_,cice,xlv0,xls &
1261 qeso(i,k) = eps * qeso(i,k)/(p(i,k) + (eps-1.)*qeso(i,k))
1263 qeso(i,k) = max(qeso(i,k), val )
1279 if(k.lt.ktcon(i).and.k.gt.kb(i)) then
1280 rntot(i) = rntot(i) + pwo(i,k) * xmb(i) * .001 * dt2
1290 if (k .le. kmax(i)) then
1295 if(k.lt.ktcon(i).and.k.gt.kb(i)) then
1296 rain(i) = rain(i) + pwo(i,k) * xmb(i) * .001 * dt2
1299 if(flg(i).and.k.lt.ktcon(i)) then
1300 evef = edt(i) * evfact
1301 if(slimsk(i).eq.1.) evef=edt(i) * evfactl
1302 qcond(i) = evef * (q1(i,k) - qeso(i,k)) &
1303 / (1. + el2orc * qeso(i,k) / t1(i,k)**2)
1304 dp = 1000. * del(i,k)
1305 if(rain(i).gt.0..and.qcond(i).lt.0.) then
1306 qevap(i) = -qcond(i) * (1.-exp(-.32*sqrt(dt2*rain(i))))
1307 qevap(i) = min(qevap(i), rain(i)*1000.*g_/dp)
1308 delq2(i) = delqev(i) + .001 * qevap(i) * dp / g_
1310 if(rain(i).gt.0..and.qcond(i).lt.0..and.delq2(i).gt.rntot(i)) then
1311 qevap(i) = 1000.* g_ * (rntot(i) - delqev(i)) / dp
1314 if(rain(i).gt.0..and.qevap(i).gt.0.) then
1315 tem = .001 * dp / g_
1316 tem1 = qevap(i) * tem
1317 if(tem1.gt.rain(i)) then
1318 qevap(i) = rain(i) / tem
1321 rain(i) = rain(i) - tem1
1323 q1(i,k) = q1(i,k) + qevap(i)
1324 t1(i,k) = t1(i,k) - (hvap_/cp_) * qevap(i)
1325 deltv(i) = - (hvap_/cp_)*qevap(i)/dt2
1326 delq(i) = + qevap(i)/dt2
1327 delqev(i) = delqev(i) + .001*dp*qevap(i)/g_
1329 dellaq(i,k) = dellaq(i,k) + delq(i) / xmb(i)
1330 delqbar(i) = delqbar(i) + delq(i)*dp/g_
1331 deltbar(i) = deltbar(i) + deltv(i)*dp/g_
1339 if(rain(i).lt.0..or..not.flg(i)) rain(i) = 0.
1348 if (ncloud.gt.0) then
1353 if (k.ge.kbcon(i).and.k.le.ktcon(i)) then
1354 tem = dellal(i,k) * xmb(i) * dt2
1355 tem1 = max(0.0, min(1.0, (tcr-t1(i,k))*tcrf))
1356 if (ncloud.ge.2) then
1357 qi2(i,k) = qi2(i,k) + tem * tem1 ! ice
1358 qc2(i,k) = qc2(i,k) + tem *(1.0-tem1) ! water
1360 qc2(i,k) = qc2(i,k) + tem
1369 end subroutine nscv2d
1370 !-------------------------------------------------------------------------------
1372 !-------------------------------------------------------------------------------
1373 REAL FUNCTION fpvs(t,ice,rd,rv,cvap,cliq,cice,hvap,hsub,psat,t0c)
1374 !-------------------------------------------------------------------------------
1376 !-------------------------------------------------------------------------------
1377 REAL :: t,rd,rv,cvap,cliq,cice,hvap,hsub,psat,t0c,dldt,xa,xb,dldti, &
1387 xbi=xai+hsub/(rv*ttp)
1389 if(t.lt.ttp.and.ice.eq.1) then
1390 fpvs=psat*(tr**xai)*exp(xbi*(1.-tr))
1392 fpvs=psat*(tr**xa)*exp(xb*(1.-tr))
1397 if(t.lt.ttp.and.ice.eq.1) then
1398 fpvs=psat*(tr**xai)*exp(xbi*(1.-tr))
1400 fpvs=psat*(tr**xa)*exp(xb*(1.-tr))
1406 if(t.lt.ttp.and.ice.eq.1) then
1407 fpvs=psat*(tr**xai)*exp(xbi*(1.-tr))
1409 fpvs=psat*(tr**xa)*exp(xb*(1.-tr))
1414 !-------------------------------------------------------------------------------
1416 !-------------------------------------------------------------------------------
1417 subroutine nscvinit(rthshten,rqvshten,rqcshten,rqishten, &
1419 restart,p_qc,p_qi,p_first_scalar, &
1421 ids, ide, jds, jde, kds, kde, &
1422 ims, ime, jms, jme, kms, kme, &
1423 its, ite, jts, jte, kts, kte )
1424 !-------------------------------------------------------------------------------
1426 !-------------------------------------------------------------------------------
1427 logical , intent(in) :: allowed_to_read,restart
1428 integer , intent(in) :: ids, ide, jds, jde, kds, kde, &
1429 ims, ime, jms, jme, kms, kme, &
1430 its, ite, jts, jte, kts, kte
1431 integer , intent(in) :: p_first_scalar, p_qi, p_qc
1432 real, dimension( ims:ime , kms:kme , jms:jme ) , intent(out) :: &
1439 integer :: i, j, k, itf, jtf, ktf
1445 if(.not.restart)then
1457 if (p_qc .ge. p_first_scalar) then
1467 if (p_qi .ge. p_first_scalar) then
1478 end subroutine nscvinit
1479 !-------------------------------------------------------------------------------
1481 END MODULE module_shcu_nscv