1 !WRF:model_layer:physics
\r
3 !####################e-epsilon scheme##################################
\r
4 ! taken from the IPRC IRAM - Yuqing Wang, university of hawaii
\r
5 ! added and improved by Chunxi Zhang and Yuqing Wang to wrf4.2, 2020
\r
6 ! refenrences: Langland and Liou (1996, mwr, 124, 905-918)
\r
7 ! Zhang et al. (2020, mwr, 148, 1121-1145)
\r
8 !######################################################################
\r
9 module module_bl_eeps
\r
11 use module_model_constants, only:rgas=>r_d, &
\r
12 & t13=>Prandtl,ep1=>EP_1,ep2=>EP_2,grv=>g, &
\r
13 & akv=>KARMAN,cp,rcp,xlv,xls,xlf,p1000mb
\r
15 real, private, parameter :: cs2=17.67,cs3=273.15,cs4=29.65
\r
16 real, private, parameter :: ci2=22.514,ci3=273.16,ci4=0.0
\r
17 real, private, parameter :: hgfr=233.15,t0=273.15
\r
18 real, private, parameter :: epsl=1.e-20
\r
19 real, private, parameter :: us2min=0.1
\r
20 real, private, parameter :: akvmx = 1600.
\r
21 real, private, parameter :: ricr=0.25,bt=5.0
\r
22 real, private, parameter :: minpek = 1.0e-4
\r
23 real, private, parameter :: minpep = 1.0e-6
\r
24 real, private, parameter :: maxpek = 80.
\r
25 real, private, parameter :: maxpep = 2.0
\r
26 integer,private,parameter:: bl_eeps_tkeadv = 1
\r
27 !---------------------------------------------------------------
\r
28 ! ci--- five constants used in TKE tubrbulence closure scheme
\r
29 !---------------------------------------------------------------
\r
30 ! Detering and Etling (1986); Langland and Liou (1996)
\r
31 ! real,parameter :: c1=1.35,c2=0.026,c3=1.13,c4=1.90,c5=0.77
\r
32 ! Duynkerke and Driedonks (1987); Stubley and Rooney (1986)
\r
33 real,parameter :: c1=1.35,c2=0.09,c3=1.44,c4=1.92,c5=0.77
\r
34 ! Beljaars et al. (1987)
\r
35 ! real,parameter :: c1=1.35,c2=0.032,c3=1.44,c4=1.92,c5=0.54
\r
38 !-------------------------------------------------------------------------------
\r
40 subroutine eeps(u3d,v3d,t3d,qv3d,qc3d,qi3d,qr3d,qs3d,qg3d,p3d,pi3d, &
\r
41 rublten,rvblten,rthblten, &
\r
42 rqvblten,rqcblten,rqiblten, &
\r
44 dz8w,psfc,qsfc,tsk,ust,rmol,wspd, &
\r
46 dt,dx,itimestep,exch_h,exch_m,pblh,kpbl, &
\r
48 ids,ide, jds,jde, kds,kde, &
\r
49 ims,ime, jms,jme, kms,kme, &
\r
50 its,ite, jts,jte, kts,kte &
\r
52 !-------------------------------------------------------------------------------
\r
54 !-------------------------------------------------------------------------------
\r
55 !-- u3d 3d u-velocity interpolated to theta points (m/s)
\r
56 !-- v3d 3d v-velocity interpolated to theta points (m/s)
\r
57 !-- t3d temperature (k)
\r
58 !-- qv3d 3d water vapor mixing ratio (kg/kg)
\r
59 !-- qc3d 3d cloud mixing ratio (kg/kg)
\r
60 !-- qi3d 3d ice mixing ratio (kg/kg)
\r
61 !-- qr3d 3d rain mixing ratio (kg/kg)
\r
62 !-- qs3d 3d snow mixing ratio (kg/kg)
\r
63 !-- qg3d 3d graupel mixing ratio (kg/kg)
\r
64 ! (note: if P_QI<PARAM_FIRST_SCALAR this should be zero filled)
\r
65 !-- p3d 3d pressure (pa)
\r
66 !-- pi3d 3d exner function (dimensionless)
\r
67 !-- rublten u tendency due to
\r
68 ! pbl parameterization (m/s/s)
\r
69 !-- rvblten v tendency due to
\r
70 ! pbl parameterization (m/s/s)
\r
71 !-- rthblten theta tendency due to
\r
72 ! pbl parameterization (K/s)
\r
73 !-- rqvblten qv tendency due to
\r
74 ! pbl parameterization (kg/kg/s)
\r
75 !-- rqcblten qc tendency due to
\r
76 ! pbl parameterization (kg/kg/s)
\r
77 !-- rqiblten qi tendency due to
\r
78 ! pbl parameterization (kg/kg/s)
\r
79 !-- dz8w dz between full levels (m)
\r
80 !-- pek 3d turbulent kinetic energy (TKE, m2/s2)
\r
81 !-- pep 3d dissipation rate of TKE
\r
82 !-- psfc pressure at the surface (pa)
\r
83 !-- qsfc ground saturated mixing ratio
\r
84 !-- ust u* in similarity theory (m/s)
\r
85 !-- rmol inverse (1/L) of Monin-Obukhov length (m)
\r
86 !-- xland land mask (1 for land, 2 for water)
\r
87 !-- tsk surface skin temperature
\r
88 !-- hfx upward heat flux at the surface (w/m^2)
\r
89 !-- qfx upward moisture flux at the surface (kg/m^2/s)
\r
90 !-- dt time step (s)
\r
91 !-- ids start index for i in domain
\r
92 !-- ide end index for i in domain
\r
93 !-- jds start index for j in domain
\r
94 !-- jde end index for j in domain
\r
95 !-- kds start index for k in domain
\r
96 !-- kde end index for k in domain
\r
97 !-- ims start index for i in memory
\r
98 !-- ime end index for i in memory
\r
99 !-- jms start index for j in memory
\r
100 !-- jme end index for j in memory
\r
101 !-- kms start index for k in memory
\r
102 !-- kme end index for k in memory
\r
103 !-- its start index for i in tile
\r
104 !-- ite end index for i in tile
\r
105 !-- jts start index for j in tile
\r
106 !-- jte end index for j in tile
\r
107 !-- kts start index for k in tile
\r
108 !-- kte end index for k in tile
\r
109 !-------------------------------------------------------------------------------
\r
111 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
\r
112 ims,ime, jms,jme, kms,kme, &
\r
113 its,ite, jts,jte, kts,kte
\r
115 integer, intent(in ) :: itimestep
\r
117 real, intent(in ) :: dt, dx
\r
120 real, dimension( ims:ime, kms:kme, jms:jme ) , &
\r
121 intent(in ) :: qv3d, &
\r
131 real, dimension( ims:ime, kms:kme, jms:jme ) , &
\r
133 intent(in ) :: qr3d, &
\r
137 real, dimension( ims:ime, kms:kme, jms:jme ) , &
\r
138 intent(inout) :: rublten, &
\r
145 real, dimension( ims:ime, jms:jme ) , &
\r
146 intent(in ) :: xland, &
\r
156 real, dimension( ims:ime, kms:kme, jms:jme ) , &
\r
157 intent(inout) :: pek, pep
\r
159 real, dimension( ims:ime, kms:kme, jms:jme ) , &
\r
160 intent(inout) :: pek_adv,pep_adv
\r
162 real, dimension( ims:ime, kms:kme, jms:jme ) , &
\r
163 intent(out) :: exch_h,exch_m
\r
165 real, dimension( ims:ime, jms:jme ) , &
\r
166 intent(out ) :: pblh
\r
168 integer, dimension( ims:ime, jms:jme ) , &
\r
169 intent(out ) :: kpbl
\r
172 real, dimension( its:ite, kts:kte+1):: zi,ghti
\r
173 real, dimension( its:ite, kts:kte ) :: zl
\r
175 real, dimension( its:ite, kts:kte ) :: u1, &
\r
186 real, dimension( its:ite, kts:kte ) :: pek2d,pep2d
\r
187 real, dimension( its:ite, kts:kte+1 ) :: exh2d,exm2d
\r
188 real, dimension( its:ite) :: psfc1,ust1,rmol1, &
\r
189 xland1,qsfc1,hfx1, &
\r
190 qfx1,tsk1,pblh1,wspd1
\r
191 integer, dimension( its:ite) :: kpbl1
\r
194 integer :: i,j,k,zz,im,kx,pp
\r
200 if(itimestep .eq. 1) then
\r
206 ! --------------- compute zi and zl -----------------------------------------
\r
213 zi(i,k+1)=zi(i,k)+dz8w(i,k,j)
\r
219 zl(i,k)=0.5*(zi(i,k)+zi(i,k+1))
\r
223 ! reverse the vertical levels
\r
228 u1(i,zz)=u3d(i,k,j)
\r
229 v1(i,zz)=v3d(i,k,j)
\r
230 t1(i,zz)=t3d(i,k,j)
\r
231 q1(i,zz)=qv3d(i,k,j)/(1.+qv3d(i,k,j))
\r
232 q2(i,zz)=qc3d(i,k,j)/(1.+qc3d(i,k,j))
\r
233 q3(i,zz)=qi3d(i,k,j)/(1.+qi3d(i,k,j))
\r
234 if(present(qr3d)) then
\r
235 q4(i,zz)=qr3d(i,k,j)/(1.+qr3d(i,k,j))
\r
239 if(present(qs3d)) then
\r
240 q5(i,zz)=qs3d(i,k,j)/(1.+qs3d(i,k,j))
\r
244 if(present(qg3d)) then
\r
245 q6(i,zz)=qg3d(i,k,j)/(1.+qg3d(i,k,j))
\r
250 prsl(i,zz) = p3d(i,k,j)
\r
251 if(bl_eeps_tkeadv==1)then
\r
253 pek(i,k,j) = 0.5*(pek_adv(i,k,j)+pek_adv(i,k-1,j))
\r
254 pep(i,k,j) = 0.5*(pep_adv(i,k,j)+pep_adv(i,k-1,j))
\r
256 pek(i,k,j) = minpek
\r
257 pep(i,k,j) = minpep
\r
260 pek2d(i,zz)= min(maxpek,max(minpek,pek(i,k,j)))
\r
261 pep2d(i,zz)= min(maxpep,max(minpep,pep(i,k,j)))
\r
270 ghti(i,zz) = zi(i,k)
\r
276 psfc1(i) = psfc(i,j)
\r
278 rmol1(i) = rmol(i,j)
\r
279 wspd1(i) = wspd(i,j)
\r
280 xland1(i)= xland(i,j)
\r
281 qsfc1(i) = qsfc(i,j)
\r
287 call eeps2d(u1,v1,t1,q1,q2,q3,q4,q5,q6,prsl,ghtl,ghti,pek2d,pep2d &
\r
288 ,psfc1,ust1,rmol1,wspd1,xland1,qsfc1,hfx1,qfx1,tsk1 &
\r
289 ,dt,dx,itimestep,exh2d,exm2d,pblh1,kpbl1,im,kx)
\r
295 rthblten(i,k,j)=(t1(i,zz)-t3d(i,k,j))/pi3d(i,k,j)*rdelt
\r
296 rqvblten(i,k,j)=(q1(i,zz)/(1.-q1(i,zz))-qv3d(i,k,j))*rdelt
\r
297 rqcblten(i,k,j)=(q2(i,zz)/(1.-q2(i,zz))-qc3d(i,k,j))*rdelt
\r
298 rqiblten(i,k,j)=(q3(i,zz)/(1.-q3(i,zz))-qi3d(i,k,j))*rdelt
\r
299 rublten(i,k,j) =(u1(i,zz)-u3d(i,k,j))*rdelt
\r
300 rvblten(i,k,j) =(v1(i,zz)-v3d(i,k,j))*rdelt
\r
302 pek(i,k,j) = pek2d(i,zz)
\r
303 pep(i,k,j) = pep2d(i,zz)
\r
312 exch_h(i,k,j) = exh2d(i,zz)
\r
313 exch_m(i,k,j) = exm2d(i,zz)
\r
319 pblh(i,j) = pblh1(i)
\r
320 kpbl(i,j) = kpbl1(i)
\r
323 if(bl_eeps_tkeadv==1)then
\r
327 pek_adv(i,k,j) = 0.5*(pek(i,k,j)+pek(i,k+1,j))
\r
328 pep_adv(i,k,j) = 0.5*(pep(i,k,j)+pep(i,k+1,j))
\r
330 pek_adv(i,k,j) = 0.5*pek(i,k,j)
\r
331 pep_adv(i,k,j) = 0.5*pep(i,k,j)
\r
340 end subroutine eeps
\r
342 !-------------------------------------------------------------------------------
\r
344 subroutine eeps2d(pu,pv,tz,pqv,pqc,pqi,pqr,pqs,pqg,prs,poz,zz,pek,pep, &
\r
345 psfcpa,ust,rmol,wspd,xland,qsfc,hfx,qfx,tsk, &
\r
346 dt,dx,itimestep,k_h,k_m,pblh,kpbl,lq,km)
\r
347 !-------------------------------------------------------------------------------
\r
349 !-------------------------------------------------------------------------------
\r
351 integer, intent(in ) :: itimestep,lq,km
\r
352 real, intent(in ) :: dt, dx
\r
354 real, dimension( lq ) , &
\r
355 intent(in) :: ust, &
\r
364 real, dimension( lq,km ),intent(inout) :: pu, &
\r
373 real, dimension( lq,km ),intent(in) :: prs, &
\r
378 real, dimension( lq,km+1 ),intent(in) :: zz
\r
380 real, dimension( lq,km+1 ),intent(out) :: k_h,k_m
\r
381 real, dimension( lq ),intent(out) :: pblh
\r
382 integer, dimension( lq ),intent(out) :: kpbl
\r
385 real, dimension( lq,km ) :: fac,psp,pt,ztv,szv,disht,up2
\r
386 real, dimension( lq,km ) :: qvs,st,sh,rich,richb,dum2,dzz,doz
\r
387 real, dimension( lq,km ) :: am,src,src1,ax,bx,cx,ac,ab,ba,alt
\r
388 real, dimension( lq,km-1 ) :: ax1,bx1,cx1,yy1,amt
\r
389 real, dimension( lq,km+1 ) :: akm,akh,pnt
\r
391 real, dimension( lq) :: tkm,zkm,qkm,us2,us,dens,wstar2,sflux
\r
392 real, dimension( lq) :: rm2,sfa,hs,hq
\r
393 real, dimension( lq) :: gamat,gamaq
\r
394 real, dimension( lq,km) :: sgk1,sgk2
\r
395 integer :: j,k,mdt,lvl
\r
396 real :: dtt,dum,dum0,alh,eqp,qvsw,qvsi,faf,rdz,du,dv,dss
\r
397 real :: tk,qvk,alk,af,ag,aks,aco
\r
398 real :: duj,alv0,richf,rch,alv,ak,cpm
\r
399 real :: govrth,bfx0,wstar3,coef
\r
401 mdt = min(6,max(3,int(dt/10.0+0.1)))
\r
404 ! dzz for dz between full levels, doz for dz between half levels
\r
407 dzz(j,k) = zz(j,k)-zz(j,k+1)
\r
408 alt(j,k) = dt/dzz(j,k)
\r
409 up2(j,k)=grv/max(us2min,pu(j,k)*pu(j,k)+pv(j,k)*pv(j,k))
\r
415 doz(j,k) = poz(j,k)-poz(j,k+1)
\r
420 doz(j,km)= 2.0*poz(j,km) ! not used
\r
421 ! wstar2(j)= 0.0 ! it will be assigned values later
\r
426 amt(j,k) = dtt/doz(j,k)
\r
439 psp(j,k)=(prs(j,k)/p1000mb)**rcp
\r
440 pt(j,k)=tz(j,k)/psp(j,k)
\r
441 dum=1.0+ep1*pqv(j,k)
\r
442 ztv(j,k)=tz(j,k)*dum
\r
443 szv(j,k)=pt(j,k)*dum
\r
444 fac(j,k) = pqc(j,k) + pqi(j,k) + pqr(j,k) + pqs(j,k) + pqg(j,k)
\r
445 cx(j,k)=1.0+pqv(j,k)+fac(j,k)
\r
447 alh=3.1484e6-2.37e3*tz(j,k)
\r
448 eqp=611.2*exp(cs2*(tz(j,k)-cs3)/(tz(j,k)-cs4))
\r
449 eqp=min(0.5*prs(j,k),eqp)
\r
450 qvsw=0.622*eqp/(prs(j,k)-eqp)
\r
451 eqp=611.0*exp(ci2*(tz(j,k)-ci3)/(tz(j,k)-ci4))
\r
452 eqp=min(0.5*prs(j,k),eqp)
\r
453 qvsi=0.622*eqp/(prs(j,k)-eqp)
\r
454 if(tz(j,k).ge.t0) then
\r
456 else if(tz(j,k).le.hgfr) then
\r
459 if(pqi(j,k).le.epsl) then
\r
461 else if(pqc(j,k).le.epsl) then
\r
464 faf=pqi(j,k)/(pqc(j,k)+pqi(j,k))
\r
467 qvs(j,k)=(1.0-faf)*qvsw+faf*qvsi
\r
468 ax(j,k)=(1.0-faf)*alh+faf*xls
\r
473 ! to calculate the Richardson number and vertical shear of
\r
474 ! the horizontal wind above the surface layer
\r
478 rdz=1.0/(poz(j,k)-poz(j,k+1))
\r
479 du=pu(j,k)-pu(j,k+1)
\r
480 dv=pv(j,k)-pv(j,k+1)
\r
481 sh(j,k)=(du*du+dv*dv)*(rdz*rdz)
\r
482 if((pqv(j,k).lt.qvs(j,k)).or.(pqv(j,k+1).lt.qvs(j,k+1))) then
\r
483 dss=log(szv(j,k)/szv(j,k+1))
\r
484 st(j,k)=grv*dss*rdz
\r
486 dss=log(pt(j,k)/pt(j,k+1))
\r
487 tk=0.5*(tz(j,k+1)+tz(j,k))
\r
488 qvk=0.5*(pqv(j,k+1)+pqv(j,k))
\r
489 alk=0.5*(ax(j,k+1)+ax(j,k))
\r
490 af=alk*qvk/(rgas*tk)
\r
493 aco=(1.0+af)/(1.0+aks)
\r
494 st(j,k)=(aco*(dss+ag*(pqv(j,k)-pqv(j,k+1))) &
\r
495 -(cx(j,k)-cx(j,k+1)))*grv*rdz
\r
497 rich(j,k)=st(j,k)/max(1.0e-7,sh(j,k))
\r
501 ! calculate first guess pblh
\r
504 richb(j,k)=poz(j,k)*(szv(j,k)/szv(j,km)-1.0)*up2(j,k)
\r
513 if(richb(j,k).ge.ricr) then
\r
520 dum=(poz(j,lvl)-poz(j,lvl+1))/(richb(j,lvl)-richb(j,lvl+1))
\r
521 pblh(j)=max(poz(j,lvl+1),poz(j,lvl)-(richb(j,lvl)-ricr)*dum)
\r
522 pblh(j)=min(pblh(j),poz(j,lvl))
\r
526 ! preparing for tke/ep calculations
\r
532 sfa(j) = tsk(j)*(p1000mb/psfcpa(j))**rcp
\r
533 dens(j) = psfcpa(j)/(rgas*tkm(j)*(1.+ep1*qkm(j)))
\r
534 cpm = cp * (1.+0.81*qkm(j))
\r
536 rm2(j)=ust(j)*ust(j)/wspd(j)
\r
537 hs(j)=hfx(j)/(dens(j)*cpm)
\r
538 hq(j)=qfx(j)/dens(j)
\r
543 pep(j,km)=duj*ust(j)/(akv*zkm(j))
\r
544 pep(j,km) = min(maxpep,max(minpep,pep(j,km)))
\r
545 govrth = grv/pt(j,km)
\r
546 sflux(j) = hfx(j)/dens(j)/cpm + &
\r
547 qfx(j)/dens(j)*ep1*pt(j,km)
\r
548 bfx0 = max(sflux(j),0.)
\r
549 wstar3 = govrth*bfx0*pblh(j)
\r
550 wstar2(j) = (wstar3**2)**t13
\r
552 rich(j,km) = grv*zkm(j)* &
\r
553 log(szv(j,km)/(sfa(j)*(1.+ep1*qsfc(j))))/(wspd(j)**2.)
\r
555 if(rmol(j).lt.0. .and. sflux(j).gt.0) then
\r
556 pek(j,km)=3.75*duj+0.2*wstar2(j)+duj*((-zkm(j)*rmol(j))**2.)**t13
\r
560 pek(j,km) = min(maxpek,max(minpek,pek(j,km)))
\r
564 ! to recalculate pblh here
\r
566 if(rmol(j).lt.0. .and. sflux(j).gt.0) then
\r
567 dss=szv(j,km)+min(5.0,bt*sflux(j)/(max(0.1,sqrt(wstar2(j)))))
\r
569 richb(j,k)=poz(j,k)*(szv(j,k)/dss-1.0)*up2(j,k)
\r
575 if(richb(j,k).ge.ricr) then
\r
582 dum=(poz(j,lvl)-poz(j,lvl+1))/(richb(j,lvl)-richb(j,lvl+1))
\r
583 pblh(j)=max(poz(j,lvl+1),poz(j,lvl)-(richb(j,lvl)-ricr)*dum)
\r
584 pblh(j)=min(pblh(j),poz(j,lvl))
\r
590 ! to add the countergradient term
\r
592 if(rmol(j).lt.0.0 .and. sflux(j).gt.0) then
\r
593 du=max(0.1,sqrt(wstar2(j)))
\r
594 gamat(j)=max(bt*hs(j)/(pblh(j)*du),0.)
\r
595 gamaq(j)=max(bt*hq(j)/(pblh(j)*du),0.)
\r
602 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
603 ! time integration of tke and ep equations
\r
604 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
608 if(rich(j,k).lt.0.195) then
\r
609 richf=0.6588*(rich(j,k)+0.1776-sqrt(rich(j,k)*rich(j,k)- &
\r
610 0.3221*rich(j,k)+0.03156))
\r
611 richf=max(-1000.0,min(0.1912408,richf))
\r
614 if(richf.lt.0.16) dum2(j,k)=1.318*(0.2231-richf) &
\r
620 do while(lvl .le. mdt)
\r
624 akm(j,k)=c2*pek(j,k)*pek(j,k)/pep(j,k)
\r
625 akh(j,k)=dum2(j,k)*akm(j,k)
\r
626 akm(j,k)=sgk1(j,k)+akm(j,k)
\r
627 akh(j,k)=sgk2(j,k)+akh(j,k)
\r
628 akm(j,k)=min(akvmx,akm(j,k))
\r
629 akh(j,k)=min(akvmx,akh(j,k))
\r
630 if(zz(j,k).gt.pblh(j))then
\r
631 src(j,k)=akm(j,k)*sh(j,k)-akh(j,k)*st(j,k)
\r
632 src1(j,k)=max(akm(j,k)*sh(j,k),akm(j,k)*sh(j,k)-akh(j,k)*st(j,k))
\r
634 src(j,k)=akm(j,k)*sh(j,k)-akh(j,k)*(st(j,k) &
\r
635 -2.0*grv*gamat(j)/(szv(j,k+1)+szv(j,k)))
\r
636 src1(j,k)=max(akm(j,k)*sh(j,k),akm(j,k)*sh(j,k)-akh(j,k)*(st(j,k) &
\r
637 -2.0*grv*gamat(j)/(szv(j,k+1)+szv(j,k))))
\r
643 akm(j,km)=c2*pek(j,km)*pek(j,km)/pep(j,km)
\r
644 akh(j,km)=dum2(j,km)*akm(j,km)
\r
647 ! to calculate the vertical diffusion coefficients at u,v,levels
\r
651 am(j,k)=0.5*(akm(j,k-1)+akm(j,k))/dzz(j,k)
\r
656 am(j,1)=0.5*akm(j,1)/dzz(j,1)
\r
659 ! to calculate the cofficients for the triangle matrix
\r
660 ! for tke dissipation and solve the matrix
\r
664 dum=(c3*src1(j,k)-c4*pep(j,k))*dtt/pek(j,k)
\r
665 ax1(j,k)=-c5*amt(j,k)*am(j,k+1)
\r
666 cx1(j,k)=-c5*amt(j,k)*am(j,k)
\r
667 if(dum.le.0.5) then
\r
668 bx1(j,k)=1.0+c5*amt(j,k)*(am(j,k)+am(j,k+1))-dum
\r
671 bx1(j,k)=1.0+c5*amt(j,k)*(am(j,k)+am(j,k+1))
\r
672 yy1(j,k)=pep(j,k)+dum*pep(j,k)
\r
680 yy1(j,km-1)=yy1(j,km-1)+c5*amt(j,km-1)*am(j,km)*pep(j,km)
\r
683 call tridiag(ax1,bx1,cx1,yy1,lq,km-1)
\r
685 ! to calculate the cofficients for the triangle matrix
\r
686 ! for tke and solve the matrix
\r
690 pep(j,k)=min(maxpep,max(minpep, yy1(j,k)))
\r
691 dum=(src(j,k)-pep(j,k))*dtt
\r
692 ax1(j,k)=-c1*amt(j,k)*am(j,k+1)
\r
693 bx1(j,k)=1.0+c1*amt(j,k)*(am(j,k)+am(j,k+1))
\r
694 cx1(j,k)=-c1*amt(j,k)*am(j,k)
\r
695 yy1(j,k)=pek(j,k)+dum
\r
702 yy1(j,km-1)=yy1(j,km-1)+c1*amt(j,km-1)*am(j,km)*pek(j,km)
\r
705 call tridiag(ax1,bx1,cx1,yy1,lq,km-1)
\r
709 pek(j,k)=min(maxpek,max(minpek, yy1(j,k)))
\r
716 !-------------------------------------------------------------
\r
717 ! to calculate the vertical diffusion coeficient for momentum
\r
719 !-------------------------------------------------------------
\r
720 ! note: akm and akh at the first level (km) will not be used
\r
723 akm(j,k)=c2*pek(j,k-1)*pek(j,k-1)/pep(j,k-1)
\r
724 akh(j,k)=dum2(j,k)*akm(j,k)
\r
725 akm(j,k)=sgk1(j,k)+akm(j,k)
\r
726 akh(j,k)=sgk2(j,k)+akh(j,k)
\r
727 akm(j,k)=min(akvmx,akm(j,k))
\r
728 akh(j,k)=min(akvmx,akh(j,k))
\r
730 if(zz(j,k).gt.pblh(j))pnt(j,k)=0.
\r
731 akm(j,k)=akm(j,k)/doz(j,k-1)
\r
732 akh(j,k)=akh(j,k)/doz(j,k-1)
\r
745 ! Momentum fluxes calculation
\r
749 ax(j,k)=-alt(j,k)*akm(j,k+1)
\r
750 bx(j,k)=1.0+alt(j,k)*(akm(j,k)+akm(j,k+1))
\r
751 cx(j,k)=-alt(j,k)*akm(j,k)
\r
759 bx(j,km) = bx(j,km)+alt(j,km)*rm2(j)
\r
764 call tridiag(ba,ab,ac,pu,lq,km)
\r
766 call tridiag(ax,bx,cx,pv,lq,km)
\r
768 ! Heat and moisture fluxes calculation
\r
772 ax(j,k)=-alt(j,k)*akh(j,k+1)
\r
773 bx(j,k)=1.0+alt(j,k)*(akh(j,k)+akh(j,k+1))
\r
774 cx(j,k)=-alt(j,k)*akh(j,k)
\r
779 if(k.gt.1) dum0=pep(j,k-1)
\r
781 if(dum0.le.1.e-6) dum0=0.0
\r
782 if(dum.le.1.e-6) dum=0.0
\r
783 disht(j,k)=0.5*(dum0+dum)/(cp*(1.+.81*pqv(j,k)))
\r
784 pt(j,k)=pt(j,k)+disht(j,k)*dt/psp(j,k)+alt(j,k)* &
\r
785 gamat(j)*(pnt(j,k+1)-pnt(j,k))
\r
790 pt(j,km)=pt(j,km)+alt(j,km)*hs(j)
\r
793 call tridiag(ba,ab,ac,pt,lq,km)
\r
805 pqv(j,k)=pqv(j,k)+alt(j,k)*gamaq(j)* &
\r
806 (pnt(j,k+1)-pnt(j,k))
\r
811 pqv(j,km)=pqv(j,km)+alt(j,km)*hq(j)
\r
814 call tridiag(ba,ab,ac,pqv,lq,km)
\r
824 call tridiag(ba,ab,ac,pqc,lq,km)
\r
826 call tridiag(ax,bx,cx,pqi,lq,km)
\r
830 tz(j,k)=pt(j,k)*psp(j,k)
\r
831 pqv(j,k)=max(epsl,pqv(j,k))
\r
832 pqc(j,k)=max(epsl,pqc(j,k))
\r
833 pqi(j,k)=max(epsl,pqi(j,k))
\r
834 !-----------------------------------------------------
\r
835 ! immediate melting of cloud ice below freezing level
\r
836 !-----------------------------------------------------
\r
837 if(tz(j,k).ge.t0.and.pqi(j,k).gt.epsl) then
\r
838 if(pqc(j,k).le.epsl) then
\r
841 pqc(j,k)=pqc(j,k)+pqi(j,k)
\r
843 cpm=cp*(1.0+0.81*pqv(j,k))
\r
844 alh=3.1484e6-2.37e3*tz(j,k)
\r
845 tz(j,k)=tz(j,k)-(xls-alh)*pqi(j,k)/cpm
\r
853 k_h(j,k)=akh(j,k)*doz(j,k-1)
\r
854 k_m(j,k)=akm(j,k)*doz(j,k-1)
\r
861 k_m(j,km+1)= 0. !c2*pek(j,km)*pek(j,km)/pep(j,km) ! we don't need it
\r
862 k_h(j,km+1)= 0. !dum2(j,km)*k_m(j,km+1) ! we don't need it
\r
865 end subroutine eeps2d
\r
867 !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
869 ! ==================================================================
\r
870 subroutine tridiag(a,b,c,d,lq,km)
\r
871 !! to solve system of linear eqs on tridiagonal matrix n times n
\r
872 !! after Peaceman and Rachford, 1955
\r
873 !! a,b,c,d - are vectors of order n
\r
874 !! a,b,c - are coefficients on the LHS
\r
875 !! d - is initially RHS on the output becomes a solution vector
\r
877 !-------------------------------------------------------------------
\r
879 INTEGER, INTENT(in):: lq,km
\r
880 REAL, DIMENSION(lq,km), INTENT(in) :: a,b
\r
881 REAL, DIMENSION(lq,km), INTENT(inout) :: c,d
\r
885 REAL, DIMENSION(lq,km) :: q
\r
889 q(j,km)=-c(j,km)/b(j,km)
\r
890 d(j,km)=d(j,km)/b(j,km)
\r
895 p=1./(b(j,k)+a(j,k)*q(j,k+1))
\r
897 d(j,k)=(d(j,k)-a(j,k)*d(j,k+1))*p
\r
903 d(j,k)=d(j,k)+q(j,k)*d(j,k-1)
\r
907 end subroutine tridiag
\r
909 !-------------------------------------------------------------------------------
\r
910 subroutine eepsinit(rublten,rvblten,rthblten,rqvblten, &
\r
911 rqcblten,rqiblten,p_qi,p_first_scalar,pek,pep, &
\r
912 restart, allowed_to_read, &
\r
913 ids, ide, jds, jde, kds, kde, &
\r
914 ims, ime, jms, jme, kms, kme, &
\r
915 its, ite, jts, jte, kts, kte )
\r
916 !-------------------------------------------------------------------------------
\r
918 !-------------------------------------------------------------------------------
\r
920 logical , intent(in) :: restart, allowed_to_read
\r
921 integer , intent(in) :: ids, ide, jds, jde, kds, kde, &
\r
922 ims, ime, jms, jme, kms, kme, &
\r
923 its, ite, jts, jte, kts, kte
\r
924 integer , intent(in) :: p_qi,p_first_scalar
\r
925 real , dimension( ims:ime , kms:kme , jms:jme ), intent(out) :: &
\r
932 real, dimension( ims:ime, kms:kme, jms:jme ),intent(out) :: pek, pep
\r
933 integer :: i, j, k, itf, jtf, ktf
\r
935 jtf = min0(jte,jde-1)
\r
936 ktf = min0(kte,kde-1)
\r
937 itf = min0(ite,ide-1)
\r
939 if(.not.restart)then
\r
943 rublten(i,k,j) = 0.
\r
944 rvblten(i,k,j) = 0.
\r
945 rthblten(i,k,j) = 0.
\r
946 rqvblten(i,k,j) = 0.
\r
947 rqcblten(i,k,j) = 0.
\r
948 pek(i,k,j) = minpek
\r
949 pep(i,k,j) = minpep
\r
955 if (p_qi .ge. p_first_scalar .and. .not.restart) then
\r
959 rqiblten(i,k,j) = 0.
\r
965 end subroutine eepsinit
\r
966 !-------------------------------------------------------------------------------
\r
967 end module module_bl_eeps
\r