1 !WRF:model_layer:physics
3 module module_bl_shinhong
7 !-------------------------------------------------------------------------------
9 subroutine shinhong(u3d,v3d,th3d,t3d,qv3d,qc3d,qi3d,p3d,p3di,pi3d, &
10 rublten,rvblten,rthblten, &
11 rqvblten,rqcblten,rqiblten,flag_qi, &
12 cp,g,rovcp,rd,rovg,ep1,ep2,karman,xlv,rv, &
15 znt,ust,hpbl,psim,psih, &
16 xland,hfx,qfx,wspd,br, &
20 shinhong_tke_diag,tke_pbl,el_pbl,corf, &
22 ids,ide, jds,jde, kds,kde, &
23 ims,ime, jms,jme, kms,kme, &
24 its,ite, jts,jte, kts,kte, &
29 !-------------------------------------------------------------------------------
31 !-------------------------------------------------------------------------------
32 !-- u3d 3d u-velocity interpolated to theta points (m/s)
33 !-- v3d 3d v-velocity interpolated to theta points (m/s)
34 !-- th3d 3d potential temperature (k)
35 !-- t3d temperature (k)
36 !-- qv3d 3d water vapor mixing ratio (kg/kg)
37 !-- qc3d 3d cloud mixing ratio (kg/kg)
38 !-- qi3d 3d ice mixing ratio (kg/kg)
39 ! (note: if P_QI<PARAM_FIRST_SCALAR this should be zero filled)
40 !-- p3d 3d pressure (pa)
41 !-- p3di 3d pressure (pa) at interface level
42 !-- pi3d 3d exner function (dimensionless)
43 !-- rublten u tendency due to
44 ! pbl parameterization (m/s/s)
45 !-- rvblten v tendency due to
46 ! pbl parameterization (m/s/s)
47 !-- rthblten theta tendency due to
48 ! pbl parameterization (K/s)
49 !-- rqvblten qv tendency due to
50 ! pbl parameterization (kg/kg/s)
51 !-- rqcblten qc tendency due to
52 ! pbl parameterization (kg/kg/s)
53 !-- rqiblten qi tendency due to
54 ! pbl parameterization (kg/kg/s)
55 !-- cp heat capacity at constant pressure for dry air (j/kg/k)
56 !-- g acceleration due to gravity (m/s^2)
58 !-- rd gas constant for dry air (j/kg/k)
60 !-- ep1 constant for virtual temperature (r_v/r_d - 1)
61 !-- ep2 constant for specific humidity calculation
62 !-- karman von karman constant
63 !-- xlv latent heat of vaporization (j/kg)
64 !-- rv gas constant for water vapor (j/kg/k)
65 !-- dz8w dz between full levels (m)
66 !-- psfc pressure at the surface (pa)
67 !-- znu eta values on half (mass) levels
68 !-- znw eta values on full (w) levels
69 !-- p_top pressure top of the model (pa)
70 !-- znt roughness length (m)
71 !-- ust u* in similarity theory (m/s)
72 !-- hpbl pbl height (m)
73 !-- psim similarity stability function for momentum
74 !-- psih similarity stability function for heat
75 !-- xland land mask (1 for land, 2 for water)
76 !-- hfx upward heat flux at the surface (w/m^2)
77 !-- qfx upward moisture flux at the surface (kg/m^2/s)
78 !-- wspd wind speed at lowest model level (m/s)
79 !-- br bulk richardson number in surface layer
80 !-- u10 u-wind speed at 10 m (m/s)
81 !-- v10 v-wind speed at 10 m (m/s)
83 !-- ids start index for i in domain
84 !-- ide end index for i in domain
85 !-- jds start index for j in domain
86 !-- jde end index for j in domain
87 !-- kds start index for k in domain
88 !-- kde end index for k in domain
89 !-- ims start index for i in memory
90 !-- ime end index for i in memory
91 !-- jms start index for j in memory
92 !-- jme end index for j in memory
93 !-- kms start index for k in memory
94 !-- kme end index for k in memory
95 !-- its start index for i in tile
96 !-- ite end index for i in tile
97 !-- jts start index for j in tile
98 !-- jte end index for j in tile
99 !-- kts start index for k in tile
100 !-- kte end index for k in tile
101 !-------------------------------------------------------------------------------
103 integer,parameter :: ndiff = 3
104 real,parameter :: rcl = 1.0
106 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
107 ims,ime, jms,jme, kms,kme, &
108 its,ite, jts,jte, kts,kte
109 integer, intent(in ) :: shinhong_tke_diag
111 real, intent(in ) :: dt,cp,g,rovcp,rovg,rd,xlv,rv
112 real, intent(in ) :: ep1,ep2,karman
113 real, intent(in ) :: dx,dy
115 integer, dimension( ims:ime, jms:jme ) , &
116 intent(out ) :: kpbl2d
118 real, dimension( ims:ime, kms:kme, jms:jme ) , &
119 intent(in ) :: u3d, &
121 real, dimension( ims:ime, kms:kme, jms:jme ) , &
122 intent(in ) :: qv3d, &
130 real, dimension( ims:ime, kms:kme, jms:jme ) , &
133 real, dimension( ims:ime, kms:kme, jms:jme ) , &
134 intent(inout) :: rublten, &
139 real, dimension( ims:ime, kms:kme, jms:jme ) , &
140 intent(inout) :: exch_h
141 real, dimension( ims:ime, kms:kme, jms:jme ) , &
142 intent(inout) :: tke_pbl, &
145 real, dimension( ims:ime, jms:jme ) , &
146 intent(in ) :: xland, &
152 real, dimension( ims:ime, jms:jme ) , &
157 real, dimension( ims:ime, jms:jme ) , &
158 intent(inout) :: u10, &
160 real, dimension( ims:ime, jms:jme ) , &
161 intent(inout) :: znt, &
166 logical, intent(in) :: flag_qi
170 real, dimension( ims:ime, kms:kme, jms:jme ) , &
171 intent(inout), optional :: rqiblten
173 real, dimension( ims:ime, jms:jme ) , &
174 intent(inout), optional :: wstar, &
176 real, dimension( ims:ime, jms:jme ) , &
177 intent(inout), optional :: regime
179 real, dimension( ims:ime, jms:jme ) , &
180 intent(in ), optional :: ctopo, &
183 real, dimension( kms:kme ) , &
184 intent(in ), optional :: znu, &
187 real, optional, intent(in ) :: p_top
192 real, dimension( its:ite, kts:kte*ndiff ) :: rqvbl2dt, &
194 real, dimension( its:ite, kts:kte ) :: pdh
195 real, dimension( its:ite, kts:kte+1 ) :: pdhi
196 real, dimension( its:ite ) :: &
202 qv2d(its:ite,:) = 0.0
207 if(k.le.kte)pdh(i,k) = p3d(i,k,j)
208 pdhi(i,k) = p3di(i,k,j)
213 qv2d(i,k) = qv3d(i,k,j)
214 qv2d(i,k+kte) = qc3d(i,k,j)
215 if(present(rqiblten)) qv2d(i,k+kte+kte) = qi3d(i,k,j)
219 call shinhong2d(J=j,ux=u3d(ims,kms,j),vx=v3d(ims,kms,j) &
222 ,p2d=pdh(its,kts),p2di=pdhi(its,kts) &
223 ,pi2d=pi3d(ims,kms,j) &
224 ,utnp=rublten(ims,kms,j),vtnp=rvblten(ims,kms,j) &
225 ,ttnp=rthblten(ims,kms,j),qtnp=rqvbl2dt(its,kts),ndiff=ndiff &
226 ,cp=cp,g=g,rovcp=rovcp,rd=rd,rovg=rovg &
228 ,ep1=ep1,ep2=ep2,karman=karman &
229 ,dz8w2d=dz8w(ims,kms,j) &
230 ,psfcpa=psfc(ims,j),znt=znt(ims,j),ust=ust(ims,j) &
232 ,regime=regime(ims,j),psim=psim(ims,j) &
233 ,psih=psih(ims,j),xland=xland(ims,j) &
234 ,hfx=hfx(ims,j),qfx=qfx(ims,j) &
235 ,wspd=wspd(ims,j),br=br(ims,j) &
236 ,dusfc=dusfc,dvsfc=dvsfc,dtsfc=dtsfc,dqsfc=dqsfc &
237 ,dt=dt,rcl=1.0,kpbl1d=kpbl2d(ims,j) &
238 ,exch_hx=exch_h(ims,kms,j) &
239 ,wstar=wstar(ims,j) &
240 ,delta=delta(ims,j) &
241 ,u10=u10(ims,j),v10=v10(ims,j) &
242 ,ctopo=ctopo(ims,j),ctopo2=ctopo2(ims,j) &
243 ,shinhong_tke_diag=shinhong_tke_diag &
244 ,tke=tke_pbl(ims,kms,j),el_pbl=el_pbl(ims,kms,j) &
247 ,ids=ids,ide=ide, jds=jds,jde=jde, kds=kds,kde=kde &
248 ,ims=ims,ime=ime, jms=jms,jme=jme, kms=kms,kme=kme &
249 ,its=its,ite=ite, jts=jts,jte=jte, kts=kts,kte=kte )
253 rthblten(i,k,j) = rthblten(i,k,j)/pi3d(i,k,j)
254 rqvblten(i,k,j) = rqvbl2dt(i,k)
255 rqcblten(i,k,j) = rqvbl2dt(i,k+kte)
256 if(present(rqiblten)) rqiblten(i,k,j) = rqvbl2dt(i,k+kte+kte)
262 end subroutine shinhong
263 !-------------------------------------------------------------------------------
265 !-------------------------------------------------------------------------------
266 subroutine shinhong2d(j,ux,vx,tx,qx,p2d,p2di,pi2d, &
267 utnp,vtnp,ttnp,qtnp,ndiff, &
268 cp,g,rovcp,rd,rovg,ep1,ep2,karman,xlv,rv, &
270 znt,ust,hpbl,psim,psih, &
271 xland,hfx,qfx,wspd,br, &
272 dusfc,dvsfc,dtsfc,dqsfc, &
281 ids,ide, jds,jde, kds,kde, &
282 ims,ime, jms,jme, kms,kme, &
283 its,ite, jts,jte, kts,kte, &
286 !-------------------------------------------------------------------------------
288 !-------------------------------------------------------------------------------
290 ! the shinhongpbl (shin and hong 2015) is based on the les study of shin
291 ! and hong (2013). the major ingredients of the shinhongpbl are
292 ! 1) the prescribed nonlocal heat transport profile fit to the les and
293 ! 2) inclusion of explicit scale dependency functions for vertical
294 ! transport in convective pbl.
295 ! so, the shinhongpbl works at the gray zone resolution of convective pbl.
296 ! note that honnert et al. (2011) first suggested explicit scale dependency
297 ! function, and shin and hong (2013) further classified the function by
298 ! stability (u*/w*) in convective pbl and calculated the function for
299 ! nonlocal and local transport separately.
300 ! vertical mixing in the stable boundary layer and free atmosphere follows
301 ! hong (2010) and hong et al. (2006), same as the ysupbl scheme.
304 ! coded and implemented by hyeyum hailey shin (ncar)
308 ! coded by song-you hong (yonsei university) and implemented by
309 ! song-you hong (yonsei university) and jimy dudhia (ncar)
313 ! shin and hong (2015) mon. wea. rev.
314 ! shin and hong (2013) j. atmos. sci.
315 ! honnert, masson, and couvreux (2011) j. atmos. sci.
316 ! hong (2010) quart. j. roy. met. soc
317 ! hong, noh, and dudhia (2006), mon. wea. rev.
319 !-------------------------------------------------------------------------------
321 real,parameter :: xkzminm = 0.1,xkzminh = 0.01
322 real,parameter :: xkzmax = 1000.,rimin = -100.
323 real,parameter :: rlam = 30.,prmin = 0.25,prmax = 4.
324 real,parameter :: brcr_ub = 0.0,brcr_sb = 0.25,cori = 1.e-4
325 real,parameter :: afac = 6.8,bfac = 6.8,pfac = 2.0,pfac_q = 2.0
326 real,parameter :: phifac = 8.,sfcfrac = 0.1
327 real,parameter :: d1 = 0.02, d2 = 0.05, d3 = 0.001
328 real,parameter :: h1 = 0.33333333, h2 = 0.6666667
329 real,parameter :: ckz = 0.001,zfmin = 1.e-8,aphi5 = 5.,aphi16 = 16.
330 real,parameter :: tmin=1.e-2
331 real,parameter :: gamcrt = 3.,gamcrq = 2.e-3
332 real,parameter :: xka = 2.4e-5
333 integer,parameter :: imvdif = 1
335 ! tunable parameters for tke
337 real,parameter :: epsq2l = 0.01,c_1 = 1.0,gamcre = 0.224
339 ! tunable parameters for prescribed nonlocal transport profile
341 real,parameter :: mltop = 1.0,sfcfracn1 = 0.075
342 real,parameter :: nlfrac = 0.7,enlfrac = -0.4
343 real,parameter :: a11 = 1.0,a12 = -1.15
344 real,parameter :: ezfac = 1.5
345 real,parameter :: cpent = -0.4,rigsmax = 100.
346 real,parameter :: entfmin = 1.0, entfmax = 5.0
348 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
349 ims,ime, jms,jme, kms,kme, &
350 its,ite, jts,jte, kts,kte, &
352 integer, intent(in ) :: shinhong_tke_diag
354 real, intent(in ) :: dt,rcl,cp,g,rovcp,rovg,rd,xlv,rv
355 real, intent(in ) :: ep1,ep2,karman
356 real, intent(in ) :: dx,dy
358 integer, dimension( ims:ime ) , &
359 intent(out ) :: kpbl1d
361 real, dimension( ims:ime, kms:kme ) , &
362 intent(in ) :: dz8w2d, &
364 real, dimension( ims:ime, kms:kme ) , &
367 real, dimension( ims:ime, kms:kme ) , &
370 real, dimension( its:ite, kts:kte*ndiff ) , &
372 real, dimension( its:ite, kts:kte+1 ) , &
374 real, dimension( its:ite, kts:kte ) , &
377 real, dimension( ims:ime, kms:kme ) , &
378 intent(inout) :: utnp, &
381 real, dimension( ims:ime, kms:kme ) , &
382 intent(inout) :: exch_hx
383 real, dimension( ims:ime, kms:kme ) , &
384 intent(inout) :: tke, &
386 real, dimension( its:ite, kts:kte*ndiff ) , &
387 intent(inout) :: qtnp
389 real, dimension( ims:ime ) , &
390 intent(in ) :: xland, &
393 real, dimension( ims:ime ) , &
398 real, dimension( ims:ime ) , &
401 real, dimension( ims:ime ) , &
402 intent(inout) :: ust, &
405 real, dimension( ims:ime ) , &
406 intent(inout) :: wspd
407 real, dimension( ims:ime ) , &
408 intent(inout) :: u10, &
411 real, dimension( ims:ime ) , &
413 intent(in ) :: ctopo, &
415 real, dimension( ims:ime ) , &
417 intent(inout) :: regime
418 real, dimension( its:ite ) , &
419 intent(out ) :: wstar, &
424 integer :: n,i,k,l,ic,is,nwmass
425 integer :: klpbl, kqc, kqi
428 real :: dt2,rdt,spdk2,fm,fh,hol1,gamfac,vpert,prnum,prnum0
429 real :: ss,ri,qmean,tmean,alpha,chi,zk,rl2,dk,sri
430 real :: brint,dtodsd,dtodsu,rdz,dsdzt,dsdzq,dsdz2,rlamdz
431 real :: utend,vtend,ttend,qtend
432 real :: dtstep,govrthv
433 real :: cont, conq, conw, conwrc
434 real :: delxy,pu1,pth1,pq1
437 real :: amf1,amf2,bmf2,amf3,bmf3,amf4,bmf4,sflux0,snlflux0
438 real :: mlfrac,ezfrac,sfcfracn
439 real :: uwst,uwstx,csfac
440 real :: prnumfac,bfx0,hfx0,qfx0,delb,dux,dvx, &
441 dsdzu,dsdzv,wm3,dthx,dqx,wspd10,ross,tem1,dsig,tvcon,conpr, &
445 integer, dimension( its:ite ) :: kpbl
446 real, dimension( its:ite ) :: hol
447 real, dimension( its:ite ) :: deltaoh
448 real, dimension( its:ite ) :: rigs, &
451 real, dimension( its:ite ) :: &
463 real, dimension( its:ite ) :: &
472 real, dimension( its:ite ) :: &
477 real, dimension( its:ite ) :: &
483 real, dimension( its:ite, kts:kte ) :: xkzm,xkzh, &
491 real, dimension( its:ite, kts:kte ) :: &
499 real, dimension( its:ite, kts:kte ) :: &
501 real, dimension( its:ite, kts:kte ) :: &
504 real, dimension( its:ite, kts:kte ) :: &
508 real, dimension( its:ite, kts:kte ) :: &
514 real, dimension( its:ite, kts:kte+1 ) :: zq
515 real, dimension( its:ite, kts:kte, ndiff ) :: r3,f3
517 real, dimension( kts:kte ) :: &
522 real, dimension( kts:kte ) :: &
523 ps1d,pb1d,eps1d,pt1d, &
524 xkze1d,eflx_l1d,eflx_nl1d, &
526 real, dimension( kts+1:kte ) :: &
529 mfk,ufxpblk,vfxpblk,qfxpblk
530 real, dimension( kts:kte+1 ) :: zqk
531 real, dimension( kts:kte*ndiff ) :: qxk
533 logical, dimension( its:ite ) :: pblflg, &
536 logical, dimension( ndiff ) :: ifvmix
538 !-------------------------------------------------------------------------------
547 conwrc = conw*sqrt(rcl)
548 conpr = bfac*karman*sfcfrac
550 ! k-start index for cloud and rain
559 thx(i,k) = tx(i,k)/pi2d(i,k)
565 tvcon = (1.+ep1*qx(i,k))
566 thvx(i,k) = thx(i,k)*tvcon
571 tvcon = (1.+ep1*qx(i,1))
572 rhox(i) = psfcpa(i)/(rd*tx(i,1)*tvcon)
573 govrth(i) = g/thx(i,1)
576 !-----compute the height of full- and half-sigma levels above ground
577 ! level, and the layer thicknesses.
585 zq(i,k+1) = dz8w2d(i,k)+zq(i,k)
591 za(i,k) = 0.5*(zq(i,k)+zq(i,k+1))
592 dzq(i,k) = zq(i,k+1)-zq(i,k)
593 del(i,k) = p2di(i,k)-p2di(i,k+1)
603 dza(i,k) = za(i,k)-za(i,k-1)
608 !-----initialize vertical tendencies and
616 wspd1(i) = sqrt(ux(i,1)*ux(i,1)+vx(i,1)*vx(i,1))+1.e-9
619 !---- compute vertical diffusion
621 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
622 ! compute preliminary variables
667 q2x(i,k) = 2.*tke(i,k)
708 hpbl_cbl(i) = zq(i,1)
710 thermal(i)= thvx(i,1)
713 sflux(i) = hfx(i)/rhox(i)/cp + qfx(i)/rhox(i)*ep1*thx(i,1)
714 if(br(i).gt.0.0) sfcflg(i) = .false.
717 ! compute the first guess of pbl height
727 if(.not.stable(i))then
729 spdk2 = max(ux(i,k)**2+vx(i,k)**2,1.)
730 brup(i) = (thvx(i,k)-thermal(i))*(g*za(i,k)/thvx(i,1))/spdk2
732 stable(i) = brup(i).gt.brcr(i)
739 if(brdn(i).ge.brcr(i))then
741 elseif(brup(i).le.brcr(i))then
744 brint = (brcr(i)-brdn(i))/(brup(i)-brdn(i))
746 hpbl(i) = za(i,k-1)+brint*(za(i,k)-za(i,k-1))
747 if(hpbl(i).lt.zq(i,2)) kpbl(i) = 1
748 if(kpbl(i).le.1) pblflg(i) = .false.
754 zol1(i) = max(br(i)*fm*fm/fh,rimin)
756 zol1(i) = min(zol1(i),-zfmin)
758 zol1(i) = max(zol1(i),zfmin)
760 hol1 = zol1(i)*hpbl(i)/zl1(i)*sfcfrac
763 phim(i) = (1.-aphi16*hol1)**(-1./4.)
764 phih(i) = (1.-aphi16*hol1)**(-1./2.)
765 bfx0 = max(sflux(i),0.)
766 hfx0 = max(hfx(i)/rhox(i)/cp,0.)
767 qfx0 = max(ep1*thx(i,1)*qfx(i)/rhox(i),0.)
768 wstar3(i) = (govrth(i)*bfx0*hpbl(i))
769 wstar(i) = (wstar3(i))**h1
771 phim(i) = (1.+aphi5*hol1)
777 wscale(i) = (ust3(i)+phifac*karman*wstar3(i)*0.5)**h1
778 wscale(i) = min(wscale(i),ust(i)*aphi16)
779 wscale(i) = max(wscale(i),ust(i)/aphi5)
782 ! compute the surface variables for pbl height estimation
783 ! under unstable conditions
786 if(sfcflg(i).and.sflux(i).gt.0.0)then
787 gamfac = bfac/rhox(i)/wscale(i)
788 hgamt(i) = min(gamfac*hfx(i)/cp,gamcrt)
789 hgamq(i) = min(gamfac*qfx(i),gamcrq)
790 vpert = (hgamt(i)+ep1*thx(i,1)*hgamq(i))/bfac*afac
791 thermal(i) = thermal(i)+max(vpert,0.)*min(za(i,1)/(sfcfrac*hpbl(i)),1.0)
792 hgamt(i) = max(hgamt(i),0.0)
793 hgamq(i) = max(hgamq(i),0.0)
794 brint = -15.9*ust(i)*ust(i)/wspd(i)*wstar3(i)/(wscale(i)**4.)
795 hgamu(i) = brint*ux(i,1)
796 hgamv(i) = brint*vx(i,1)
802 ! enhance the pbl height by considering the thermal
821 if(.not.stable(i).and.pblflg(i))then
823 spdk2 = max(ux(i,k)**2+vx(i,k)**2,1.)
824 brup(i) = (thvx(i,k)-thermal(i))*(g*za(i,k)/thvx(i,1))/spdk2
826 stable(i) = brup(i).gt.brcr(i)
834 if(brdn(i).ge.brcr(i))then
836 elseif(brup(i).le.brcr(i))then
839 brint = (brcr(i)-brdn(i))/(brup(i)-brdn(i))
841 hpbl(i) = za(i,k-1)+brint*(za(i,k)-za(i,k-1))
842 if(hpbl(i).lt.zq(i,2)) kpbl(i) = 1
843 if(kpbl(i).le.1) pblflg(i) = .false.
844 if (wstar(i) .ne. 0) then
845 uwst = abs(ust(i)/wstar(i)-0.5)
846 uwstx = -80.*uwst+14.
847 csfac = 0.5*(tanh(uwstx)+3.)
851 cslen(i) = csfac*hpbl(i)
855 ! stable boundary layer
858 hpbl_cbl(i) = hpbl(i)
859 if((.not.sfcflg(i)).and.hpbl(i).lt.zq(i,2)) then
868 if((.not.stable(i)).and.((xland(i)-1.5).ge.0))then
869 wspd10 = u10(i)*u10(i) + v10(i)*v10(i)
870 wspd10 = sqrt(wspd10)
871 ross = wspd10 / (cori*znt(i))
872 brcr_sbro(i) = min(0.16*(1.e-7*ross)**(-0.18),.3)
877 if(.not.stable(i))then
878 if((xland(i)-1.5).ge.0)then
879 brcr(i) = brcr_sbro(i)
888 if(.not.stable(i))then
890 spdk2 = max(ux(i,k)**2+vx(i,k)**2,1.)
891 brup(i) = (thvx(i,k)-thermal(i))*(g*za(i,k)/thvx(i,1))/spdk2
893 stable(i) = brup(i).gt.brcr(i)
899 if((.not.sfcflg(i)).and.hpbl(i).lt.zq(i,2)) then
901 if(brdn(i).ge.brcr(i))then
903 elseif(brup(i).le.brcr(i))then
906 brint = (brcr(i)-brdn(i))/(brup(i)-brdn(i))
908 hpbl(i) = za(i,k-1)+brint*(za(i,k)-za(i,k-1))
909 if(hpbl(i).lt.zq(i,2)) kpbl(i) = 1
910 if(kpbl(i).le.1) pblflg(i) = .false.
914 ! scale dependency for nonlocal momentum and moisture transport
919 pu1=pu(delxy,cslen(i))
920 pq1=pq(delxy,cslen(i))
922 hgamu(i) = hgamu(i)*pu1
923 hgamv(i) = hgamv(i)*pu1
924 hgamq(i) = hgamq(i)*pq1
928 ! estimate the entrainment parameters
936 wm3 = wstar3(i) + 5. * ust3(i)
938 bfxpbl(i) = -0.15*thvx(i,1)/g*wm3/hpbl(i)
939 dthvx(i) = max(thvx(i,k+1)-thvx(i,k),tmin)
940 dthx = max(thx(i,k+1)-thx(i,k),tmin)
941 dqx = min(qx(i,k+1)-qx(i,k),0.0)
942 we(i) = max(bfxpbl(i)/dthvx(i),-sqrt(wm2(i)))
943 hfxpbl(i) = we(i)*dthx
944 pq1=pq(delxy,cslen(i))
945 qfxpbl(i) = we(i)*dqx*pq1
947 pu1=pu(delxy,cslen(i))
948 dux = ux(i,k+1)-ux(i,k)
949 dvx = vx(i,k+1)-vx(i,k)
951 ufxpbl(i) = max(prpbl(i)*we(i)*dux*pu1,-ust(i)*ust(i))
952 elseif(dux.lt.-tmin) then
953 ufxpbl(i) = min(prpbl(i)*we(i)*dux*pu1,ust(i)*ust(i))
958 vfxpbl(i) = max(prpbl(i)*we(i)*dvx*pu1,-ust(i)*ust(i))
959 elseif(dvx.lt.-tmin) then
960 vfxpbl(i) = min(prpbl(i)*we(i)*dvx*pu1,ust(i)*ust(i))
964 delb = govrth(i)*d3*hpbl(i)
965 delta(i) = min(d1*hpbl(i) + d2*wm2(i)/delb,100.)
966 delb = govrth(i)*dthvx(i)
967 deltaoh(i) = d1*hpbl(i) + d2*wm2(i)/delb
968 deltaoh(i) = max(ezfac*deltaoh(i),hpbl(i)-za(i,kpbl(i)-1)-1.)
969 deltaoh(i) = min(deltaoh(i) ,hpbl(i))
970 if ((dux .ne. 0) .or. (dvx .ne. 0)) then
971 rigs(i) = govrth(i)*dthvx(i)*deltaoh(i)/(dux**2.+dvx**2.)
975 rigs(i) = max(min(rigs(i), rigsmax),rimin)
976 if((rigs(i).gt.0) .and. (abs(rigs(i)+cpent) .le. 1.e-6))then
979 cenlfrac = rigs(i)/(rigs(i)+cpent)
981 cenlfrac = min(cenlfrac,entfmax)
982 enlfrac2(i) = max(wm3/wstar3(i)*cenlfrac, entfmin)
983 enlfrac2(i) = enlfrac2(i)*enlfrac
990 entfacmf(i,k) = sqrt(((zq(i,k+1)-hpbl(i))/deltaoh(i))**2.)
992 if(pblflg(i).and.k.ge.kpbl(i))then
993 entfac(i,k) = ((zq(i,k+1)-hpbl(i))/deltaoh(i))**2.
1000 ! compute diffusion coefficients below pbl
1004 if(k.lt.kpbl(i)) then
1005 zfac(i,k) = min(max((1.-(zq(i,k+1)-zl1(i))/(hpbl(i)-zl1(i))),zfmin),1.)
1006 zfacent(i,k) = (1.-zfac(i,k))**3.
1007 wscalek(i,k) = (ust3(i)+phifac*karman*wstar3(i)*(1.-zfac(i,k)))**h1
1010 prfac2 = 15.9*wstar3(i)/ust3(i)/(1.+4.*karman*wstar3(i)/ust3(i))
1011 prnumfac = -3.*(max(zq(i,k+1)-sfcfrac*hpbl(i),0.))**2./hpbl(i)**2.
1016 phim8z = 1.+aphi5*zol1(i)*zq(i,k+1)/zl1(i)
1017 wscalek(i,k) = ust(i)/phim8z
1018 wscalek(i,k) = max(wscalek(i,k),0.001)
1020 prnum0 = (phih(i)/phim(i)+prfac)
1021 prnum0 = max(min(prnum0,prmax),prmin)
1022 xkzm(i,k) = wscalek(i,k)*karman*zq(i,k+1)*zfac(i,k)**pfac
1023 prnum = 1. + (prnum0-1.)*exp(prnumfac)
1024 xkzq(i,k) = xkzm(i,k)/prnum*zfac(i,k)**(pfac_q-pfac)
1025 prnum0 = prnum0/(1.+prfac2*karman*sfcfrac)
1026 prnum = 1. + (prnum0-1.)*exp(prnumfac)
1027 xkzh(i,k) = xkzm(i,k)/prnum
1028 xkzm(i,k) = xkzm(i,k)+xkzom(i,k)
1029 xkzh(i,k) = xkzh(i,k)+xkzoh(i,k)
1030 xkzq(i,k) = xkzq(i,k)+xkzoh(i,k)
1031 xkzm(i,k) = min(xkzm(i,k),xkzmax)
1032 xkzh(i,k) = min(xkzh(i,k),xkzmax)
1033 xkzq(i,k) = min(xkzq(i,k),xkzmax)
1038 ! compute diffusion coefficients over pbl (free atmosphere)
1042 if(k.ge.kpbl(i)) then
1043 ss = ((ux(i,k+1)-ux(i,k))*(ux(i,k+1)-ux(i,k)) &
1044 +(vx(i,k+1)-vx(i,k))*(vx(i,k+1)-vx(i,k))) &
1045 /(dza(i,k+1)*dza(i,k+1))+1.e-9
1046 govrthv = g/(0.5*(thvx(i,k+1)+thvx(i,k)))
1047 ri = govrthv*(thvx(i,k+1)-thvx(i,k))/(ss*dza(i,k+1))
1049 if(imvdif.eq.1.and.nwmass.ge.3)then
1050 if((qx(i,kqc+k-1)+qx(i,kqi+k-1)).gt.0.01e-3 &
1051 .and.(qx(i,kqc+k)+qx(i,kqi+k)).gt.0.01e-3) then
1052 qmean = 0.5*(qx(i,k)+qx(i,k+1))
1053 tmean = 0.5*(tx(i,k)+tx(i,k+1))
1054 alpha = xlv*qmean/rd/tmean
1055 chi = xlv*xlv*qmean/cp/rv/tmean/tmean
1056 ri = (1.+alpha)*(ri-g*g/ss/tmean/cp*((chi-alpha)/(1.+chi)))
1059 zk = karman*zq(i,k+1)
1060 rlamdz = min(max(0.1*dza(i,k+1),rlam),300.)
1061 rlamdz = min(dza(i,k+1),rlamdz)
1062 rl2 = (zk*rlamdz/(rlamdz+zk))**2
1068 xkzm(i,k) = dk*(1+8.*(-ri)/(1+1.746*sri))
1069 xkzh(i,k) = dk*(1+8.*(-ri)/(1+1.286*sri))
1072 xkzh(i,k) = dk/(1+5.*ri)**2
1074 prnum = min(prnum,prmax)
1075 xkzm(i,k) = xkzh(i,k)*prnum
1078 xkzm(i,k) = xkzm(i,k)+xkzom(i,k)
1079 xkzh(i,k) = xkzh(i,k)+xkzoh(i,k)
1080 xkzm(i,k) = min(xkzm(i,k),xkzmax)
1081 xkzh(i,k) = min(xkzh(i,k),xkzmax)
1082 xkzml(i,k) = xkzm(i,k)
1083 xkzhl(i,k) = xkzh(i,k)
1088 ! prescribe nonlocal heat transport below pbl
1091 deltaoh(i) = deltaoh(i)/hpbl(i)
1096 mlfrac = mltop-deltaoh(i)
1097 ezfrac = mltop+deltaoh(i)
1098 zfacmf(i,1) = min(max((zq(i,2)/hpbl(i)),zfmin),1.)
1099 sfcfracn = max(sfcfracn1,zfacmf(i,1))
1101 sflux0 = (a11+a12*sfcfracn)*sflux(i)
1102 snlflux0 = nlfrac*sflux0
1103 amf1 = snlflux0/sfcfracn
1105 amf2 = -snlflux0/(mlfrac-sfcfracn)
1108 if ((deltaoh(i) .eq. 0) .and. (enlfrac2(i) .eq. 0)) then
1111 amf3 = snlflux0*enlfrac2(i)/deltaoh(i)
1114 hfxpbl(i) = amf3+bmf3
1115 pth1=pthnl(delxy,cslen(i))
1116 hfxpbl(i) = hfxpbl(i)*pth1
1119 zfacmf(i,k) = max((zq(i,k+1)/hpbl(i)),zfmin)
1120 if(pblflg(i).and.k.lt.kpbl(i)) then
1121 if(zfacmf(i,k).le.sfcfracn) then
1122 mf(i,k) = amf1*zfacmf(i,k)
1123 else if (zfacmf(i,k).le.mlfrac) then
1124 mf(i,k) = amf2*zfacmf(i,k)+bmf2
1126 mf(i,k) = mf(i,k)+hfxpbl(i)*exp(-entfacmf(i,k))
1127 mf(i,k) = mf(i,k)*pth1
1132 ! compute tridiagonal matrix elements for heat
1145 f1(i,1) = thx(i,1)-300.+hfx(i)/cont/del(i,1)*dt2
1151 dtodsd = dt2/del(i,k)
1152 dtodsu = dt2/del(i,k+1)
1153 dsig = p2d(i,k)-p2d(i,k+1)
1155 tem1 = dsig*xkzh(i,k)*rdz
1156 if(pblflg(i).and.k.lt.kpbl(i)) then
1157 dsdzt = tem1*(-mf(i,k)/xkzh(i,k))
1158 f1(i,k) = f1(i,k)+dtodsd*dsdzt
1159 f1(i,k+1) = thx(i,k+1)-300.-dtodsu*dsdzt
1160 elseif(pblflg(i).and.k.ge.kpbl(i).and.entfac(i,k).lt.4.6) then
1161 xkzh(i,k) = -we(i)*dza(i,kpbl(i))*exp(-entfac(i,k))
1162 xkzh(i,k) = sqrt(xkzh(i,k)*xkzhl(i,k))
1163 xkzh(i,k) = max(xkzh(i,k),xkzoh(i,k))
1164 xkzh(i,k) = min(xkzh(i,k),xkzmax)
1165 f1(i,k+1) = thx(i,k+1)-300.
1167 f1(i,k+1) = thx(i,k+1)-300.
1169 tem1 = dsig*xkzh(i,k)*rdz
1171 au(i,k) = -dtodsd*dsdz2
1172 al(i,k) = -dtodsu*dsdz2
1174 ! scale dependency for local heat transport
1176 zfacdx=0.2*hpbl(i)/zq(i,k+1)
1177 delxy=sqrt(dx*dy)*max(zfacdx,1.0)
1178 pth1=pthl(delxy,hpbl(i))
1179 if(pblflg(i).and.k.lt.kpbl(i)) then
1180 au(i,k) = au(i,k)*pth1
1181 al(i,k) = al(i,k)*pth1
1183 ad(i,k) = ad(i,k)-au(i,k)
1184 ad(i,k+1) = 1.-al(i,k)
1185 exch_hx(i,k+1) = xkzh(i,k)
1189 ! copies here to avoid duplicate input args for tridin
1198 call tridin_ysu(al,ad,cu,r1,au,f1,its,ite,kts,kte,1)
1200 ! recover tendencies of heat
1204 ttend = (f1(i,k)-thx(i,k)+300.)*rdt*pi2d(i,k)
1205 ttnp(i,k) = ttnp(i,k)+ttend
1206 dtsfc(i) = dtsfc(i)+ttend*cont*del(i,k)/pi2d(i,k)
1208 tflux_e(i,k) = ttend*dz8w2d(i,k)
1210 tflux_e(i,k) = tflux_e(i,k+1) + ttend*dz8w2d(i,k)
1215 ! compute tridiagonal matrix elements for moisture, clouds, and gases
1235 f3(i,1,1) = qx(i,1)+qfx(i)*g/del(i,1)*dt2
1242 f3(i,1,ic) = qx(i,1+is)
1249 if(k.ge.kpbl(i)) then
1250 xkzq(i,k) = xkzh(i,k)
1257 dtodsd = dt2/del(i,k)
1258 dtodsu = dt2/del(i,k+1)
1259 dsig = p2d(i,k)-p2d(i,k+1)
1261 tem1 = dsig*xkzq(i,k)*rdz
1262 if(pblflg(i).and.k.lt.kpbl(i)) then
1263 dsdzq = tem1*(-qfxpbl(i)*zfacent(i,k)/xkzq(i,k))
1264 f3(i,k,1) = f3(i,k,1)+dtodsd*dsdzq
1265 f3(i,k+1,1) = qx(i,k+1)-dtodsu*dsdzq
1266 elseif(pblflg(i).and.k.ge.kpbl(i).and.entfac(i,k).lt.4.6) then
1267 xkzq(i,k) = -we(i)*dza(i,kpbl(i))*exp(-entfac(i,k))
1268 xkzq(i,k) = sqrt(xkzq(i,k)*xkzhl(i,k))
1269 xkzq(i,k) = max(xkzq(i,k),xkzoh(i,k))
1270 xkzq(i,k) = min(xkzq(i,k),xkzmax)
1271 f3(i,k+1,1) = qx(i,k+1)
1273 f3(i,k+1,1) = qx(i,k+1)
1275 tem1 = dsig*xkzq(i,k)*rdz
1277 au(i,k) = -dtodsd*dsdz2
1278 al(i,k) = -dtodsu*dsdz2
1280 ! scale dependency for local moisture transport
1282 zfacdx=0.2*hpbl(i)/zq(i,k+1)
1283 delxy=sqrt(dx*dy)*max(zfacdx,1.0)
1284 pq1=pq(delxy,hpbl(i))
1285 if(pblflg(i).and.k.lt.kpbl(i)) then
1286 au(i,k) = au(i,k)*pq1
1287 al(i,k) = al(i,k)*pq1
1289 ad(i,k) = ad(i,k)-au(i,k)
1290 ad(i,k+1) = 1.-al(i,k)
1291 ! exch_hx(i,k+1) = xkzh(i,k)
1300 f3(i,k+1,ic) = qx(i,k+1+is)
1306 ! copies here to avoid duplicate input args for tridin
1317 r3(i,k,ic) = f3(i,k,ic)
1322 ! solve tridiagonal problem for moisture, clouds, and gases
1324 call tridin_ysu(al,ad,cu,r3,au,f3,its,ite,kts,kte,ndiff)
1326 ! recover tendencies of heat and moisture
1330 qtend = (f3(i,k,1)-qx(i,k))*rdt
1331 qtnp(i,k) = qtnp(i,k)+qtend
1332 dqsfc(i) = dqsfc(i)+qtend*conq*del(i,k)
1334 qflux_e(i,k) = qtend*dz8w2d(i,k)
1336 qflux_e(i,k) = qflux_e(i,k+1) + qtend*dz8w2d(i,k)
1338 tvflux_e(i,k) = tflux_e(i,k) + qflux_e(i,k)*ep1*thx(i,k)
1344 if(pblflg(i).and.k.lt.kpbl(i)) then
1345 hgame_c=c_1*0.2*2.5*(g/thvx(i,k))*wstar(i)/(0.25*(q2x(i,k+1)+q2x(i,k)))
1346 hgame_c=min(hgame_c,gamcre)
1348 hgame2d(i,k)=hgame_c*0.5*tvflux_e(i,k)*hpbl(i)
1349 hgame2d(i,k)=max(hgame2d(i,k),0.0)
1351 hgame2d(i,k)=hgame_c*0.5*(tvflux_e(i,k)+tvflux_e(i,k+1))*hpbl(i)
1352 hgame2d(i,k)=max(hgame2d(i,k),0.0)
1364 qtend = (f3(i,k,ic)-qx(i,k+is))*rdt
1365 qtnp(i,k+is) = qtnp(i,k+is)+qtend
1372 ! compute tridiagonal matrix elements for momentum
1385 ! paj: ctopo=1 if topo_wind=0 (default)
1386 ! mchen add this line to make sure NMM can still work with YSU PBL
1387 ad(i,1) = 1.+ctopo(i)*ust(i)**2/wspd1(i)*rhox(i)*g/del(i,1)*dt2 &
1388 *(wspd1(i)/wspd(i))**2
1396 dtodsd = dt2/del(i,k)
1397 dtodsu = dt2/del(i,k+1)
1398 dsig = p2d(i,k)-p2d(i,k+1)
1400 tem1 = dsig*xkzm(i,k)*rdz
1401 if(pblflg(i).and.k.lt.kpbl(i))then
1402 dsdzu = tem1*(-hgamu(i)/hpbl(i)-ufxpbl(i)*zfacent(i,k)/xkzm(i,k))
1403 dsdzv = tem1*(-hgamv(i)/hpbl(i)-vfxpbl(i)*zfacent(i,k)/xkzm(i,k))
1404 f1(i,k) = f1(i,k)+dtodsd*dsdzu
1405 f1(i,k+1) = ux(i,k+1)-dtodsu*dsdzu
1406 f2(i,k) = f2(i,k)+dtodsd*dsdzv
1407 f2(i,k+1) = vx(i,k+1)-dtodsu*dsdzv
1408 elseif(pblflg(i).and.k.ge.kpbl(i).and.entfac(i,k).lt.4.6) then
1409 xkzm(i,k) = prpbl(i)*xkzh(i,k)
1410 xkzm(i,k) = sqrt(xkzm(i,k)*xkzml(i,k))
1411 xkzm(i,k) = max(xkzm(i,k),xkzom(i,k))
1412 xkzm(i,k) = min(xkzm(i,k),xkzmax)
1413 f1(i,k+1) = ux(i,k+1)
1414 f2(i,k+1) = vx(i,k+1)
1416 f1(i,k+1) = ux(i,k+1)
1417 f2(i,k+1) = vx(i,k+1)
1419 tem1 = dsig*xkzm(i,k)*rdz
1421 au(i,k) = -dtodsd*dsdz2
1422 al(i,k) = -dtodsu*dsdz2
1424 ! scale dependency for local momentum transport
1426 zfacdx=0.2*hpbl(i)/zq(i,k+1)
1427 delxy=sqrt(dx*dy)*max(zfacdx,1.0)
1428 pu1=pu(delxy,hpbl(i))
1429 if(pblflg(i).and.k.lt.kpbl(i)) then
1430 au(i,k) = au(i,k)*pu1
1431 al(i,k) = al(i,k)*pu1
1433 ad(i,k) = ad(i,k)-au(i,k)
1434 ad(i,k+1) = 1.-al(i,k)
1438 ! copies here to avoid duplicate input args for tridin
1448 ! solve tridiagonal problem for momentum
1450 call tridi1n(al,ad,cu,r1,r2,au,f1,f2,its,ite,kts,kte,1)
1452 ! recover tendencies of momentum
1456 utend = (f1(i,k)-ux(i,k))*rdt
1457 vtend = (f2(i,k)-vx(i,k))*rdt
1458 utnp(i,k) = utnp(i,k)+utend
1459 vtnp(i,k) = vtnp(i,k)+vtend
1460 dusfc(i) = dusfc(i) + utend*conwrc*del(i,k)
1461 dvsfc(i) = dvsfc(i) + vtend*conwrc*del(i,k)
1469 ! paj: ctopo2=1 if topo_wind=0 (default)
1472 u10(i) = ctopo2(i)*u10(i)+(1-ctopo2(i))*ux(i,1)
1473 v10(i) = ctopo2(i)*v10(i)+(1-ctopo2(i))*vx(i,1)
1476 !---- calculate sgs tke which is consistent with shinhongpbl algorithm
1478 if (shinhong_tke_diag.eq.1) then
1480 tke_calculation: do i = its,ite
1516 do k = kts,kte*ndiff
1525 thvxk(k) = thvx(i,k)
1527 hgame(k) = hgame2d(i,k)
1531 if(pblflg(i).and.k.le.kpbl(i)) then
1532 zfacdx = 0.2*hpbl(i)/za(i,k)
1533 delxy = sqrt(dx*dy)*max(zfacdx,1.0)
1534 ptke1(k+1) = ptke(delxy,hpbl(i))
1542 do k = kts,kte*ndiff
1547 akmk(k) = xkzm(i,k-1)
1548 akhk(k) = xkzh(i,k-1)
1549 mfk(k) = mf(i,k-1)/xkzh(i,k-1)
1550 ufxpblk(k) = ufxpbl(i)*zfacent(i,k-1)/xkzm(i,k-1)
1551 vfxpblk(k) = vfxpbl(i)*zfacent(i,k-1)/xkzm(i,k-1)
1552 qfxpblk(k) = qfxpbl(i)*zfacent(i,k-1)/xkzq(i,k-1)
1557 dex = 0.25*(q2xk(k+2)-q2xk(k))
1558 efxpbl(i) = we(i)*dex
1563 !---- find the mixing length
1565 call mixlen(lmh,uxk,vxk,txk,thxk,qxk(kts),qxk(kte+1) &
1566 ,q2xk,zqk,ust(i),corf(i),epshol(i) &
1568 ,hpbl(i),kpbl(i),lmxl,ct(i) &
1569 ,hgamu(i),hgamv(i),hgamq(i),pblflg(i) &
1570 ,mfk,ufxpblk,vfxpblk,qfxpblk &
1572 ,ids,ide,jds,jde,kds,kde &
1573 ,ims,ime,jms,jme,kms,kme &
1574 ,its,ite,jts,jte,kts,kte )
1576 !---- solve for the production/dissipation of the turbulent kinetic energy
1578 call prodq2(lmh,dt,ust(i),s2,rig,q2xk,el,zqk,akmk,akhk &
1579 ,uxk,vxk,thxk,thvxk &
1580 ,hgamu(i),hgamv(i),hgamq(i),delxy &
1581 ,hpbl(i),pblflg(i),kpbl(i) &
1582 ,mfk,ufxpblk,vfxpblk,qfxpblk &
1584 ,ids,ide,jds,jde,kds,kde &
1585 ,ims,ime,jms,jme,kms,kme &
1586 ,its,ite,jts,jte,kts,kte )
1589 !---- carry out the vertical diffusion of turbulent kinetic energy
1591 call vdifq(lmh,dt,q2xk,el,zqk &
1593 ,hgame,hpbl(i),pblflg(i),kpbl(i) &
1595 ,ids,ide,jds,jde,kds,kde &
1596 ,ims,ime,jms,jme,kms,kme &
1597 ,its,ite,jts,jte,kts,kte )
1599 !---- save the new tke and mixing length.
1602 q2x(i,k) = amax1(q2xk(k),epsq2l)
1603 tke(i,k) = 0.5*q2x(i,k)
1604 if(k/=kts) el_pbl(i,k) = el(k) ! el is not defined at kte
1607 enddo tke_calculation
1610 !---- end of tke calculation
1613 !---- end of vertical diffusion
1615 end subroutine shinhong2d
1616 !-------------------------------------------------------------------------------
1618 !-------------------------------------------------------------------------------
1619 subroutine tridi1n(cl,cm,cu,r1,r2,au,f1,f2,its,ite,kts,kte,nt)
1620 !-------------------------------------------------------------------------------
1622 !-------------------------------------------------------------------------------
1624 integer, intent(in ) :: its,ite, kts,kte, nt
1626 real, dimension( its:ite, kts+1:kte+1 ) , &
1629 real, dimension( its:ite, kts:kte ) , &
1630 intent(in ) :: cm, &
1632 real, dimension( its:ite, kts:kte,nt ) , &
1635 real, dimension( its:ite, kts:kte ) , &
1636 intent(inout) :: au, &
1639 real, dimension( its:ite, kts:kte,nt ) , &
1643 integer :: i,k,l,n,it
1645 !-------------------------------------------------------------------------------
1652 au(i,1) = fk*cu(i,1)
1653 f1(i,1) = fk*r1(i,1)
1659 f2(i,1,it) = fk*r2(i,1,it)
1665 fk = 1./(cm(i,k)-cl(i,k)*au(i,k-1))
1666 au(i,k) = fk*cu(i,k)
1667 f1(i,k) = fk*(r1(i,k)-cl(i,k)*f1(i,k-1))
1674 fk = 1./(cm(i,k)-cl(i,k)*au(i,k-1))
1675 f2(i,k,it) = fk*(r2(i,k,it)-cl(i,k)*f2(i,k-1,it))
1681 fk = 1./(cm(i,n)-cl(i,n)*au(i,n-1))
1682 f1(i,n) = fk*(r1(i,n)-cl(i,n)*f1(i,n-1))
1687 fk = 1./(cm(i,n)-cl(i,n)*au(i,n-1))
1688 f2(i,n,it) = fk*(r2(i,n,it)-cl(i,n)*f2(i,n-1,it))
1694 f1(i,k) = f1(i,k)-au(i,k)*f1(i,k+1)
1701 f2(i,k,it) = f2(i,k,it)-au(i,k)*f2(i,k+1,it)
1706 end subroutine tridi1n
1707 !-------------------------------------------------------------------------------
1709 !-------------------------------------------------------------------------------
1710 subroutine tridin_ysu(cl,cm,cu,r2,au,f2,its,ite,kts,kte,nt)
1711 !-------------------------------------------------------------------------------
1713 !-------------------------------------------------------------------------------
1715 integer, intent(in ) :: its,ite, kts,kte, nt
1717 real, dimension( its:ite, kts+1:kte+1 ) , &
1720 real, dimension( its:ite, kts:kte ) , &
1722 real, dimension( its:ite, kts:kte,nt ) , &
1725 real, dimension( its:ite, kts:kte ) , &
1726 intent(inout) :: au, &
1728 real, dimension( its:ite, kts:kte,nt ) , &
1732 integer :: i,k,l,n,it
1734 !-------------------------------------------------------------------------------
1742 au(i,1) = fk*cu(i,1)
1743 f2(i,1,it) = fk*r2(i,1,it)
1750 fk = 1./(cm(i,k)-cl(i,k)*au(i,k-1))
1751 au(i,k) = fk*cu(i,k)
1752 f2(i,k,it) = fk*(r2(i,k,it)-cl(i,k)*f2(i,k-1,it))
1759 fk = 1./(cm(i,n)-cl(i,n)*au(i,n-1))
1760 f2(i,n,it) = fk*(r2(i,n,it)-cl(i,n)*f2(i,n-1,it))
1767 f2(i,k,it) = f2(i,k,it)-au(i,k)*f2(i,k+1,it)
1772 end subroutine tridin_ysu
1773 !-------------------------------------------------------------------------------
1775 !-------------------------------------------------------------------------------
1776 subroutine mixlen(lmh,u,v,t,the,q,cwm,q2,z,ustar,corf,epshol, &
1777 s2,gh,ri,el,hpbl,lpbl,lmxl,ct, &
1778 hgamu,hgamv,hgamq,pblflg, &
1779 mf,ufxpbl,vfxpbl,qfxpbl, &
1781 ids,ide,jds,jde,kds,kde, &
1782 ims,ime,jms,jme,kms,kme, &
1783 its,ite,jts,jte,kts,kte)
1784 !-------------------------------------------------------------------------------
1786 !-------------------------------------------------------------------------------
1787 ! qnse model constants
1788 !-------------------------------------------------------------------------------
1789 real,parameter :: blckdr=0.0063,cn=0.75
1790 real,parameter :: eps1=1.e-12,epsl=0.32,epsru=1.e-7,epsrs=1.e-7
1791 real,parameter :: el0max=1000.,el0min=1.,elfc=0.23*0.5
1792 real,parameter :: alph=0.30,beta=1./273.,g=9.81,btg=beta*g
1793 real,parameter :: a1=0.659888514560862645,a2x=0.6574209922667784586
1794 real,parameter :: b1=11.87799326209552761,b2=7.226971804046074028
1795 real,parameter :: c1=0.000830955950095854396
1796 real,parameter :: adnh= 9.*a1*a2x*a2x*(12.*a1+3.*b2)*btg*btg
1797 real,parameter :: adnm=18.*a1*a1*a2x*(b2-3.*a2x)*btg
1798 real,parameter :: bdnh= 3.*a2x*(7.*a1+b2)*btg,bdnm= 6.*a1*a1
1799 !-------------------------------------------------------------------------------
1800 ! free term in the equilibrium equation for (l/q)**2
1801 !-------------------------------------------------------------------------------
1802 real,parameter :: aeqh=9.*a1*a2x*a2x*b1*btg*btg &
1803 +9.*a1*a2x*a2x*(12.*a1+3.*b2)*btg*btg
1804 real,parameter :: aeqm=3.*a1*a2x*b1*(3.*a2x+3.*b2*c1+18.*a1*c1-b2) &
1805 *btg+18.*a1*a1*a2x*(b2-3.*a2x)*btg
1806 !-------------------------------------------------------------------------------
1807 ! forbidden turbulence area
1808 !-------------------------------------------------------------------------------
1809 real,parameter :: requ=-aeqh/aeqm
1810 real,parameter :: epsgh=1.e-9,epsgm=requ*epsgh
1811 !-------------------------------------------------------------------------------
1812 ! near isotropy for shear turbulence, ww/q2 lower limit
1813 !-------------------------------------------------------------------------------
1814 real,parameter :: ubryl=(18.*requ*a1*a1*a2x*b2*c1*btg &
1815 +9.*a1*a2x*a2x*b2*btg*btg) &
1817 real,parameter :: ubry=(1.+epsrs)*ubryl,ubry3=3.*ubry
1818 real,parameter :: aubh=27.*a1*a2x*a2x*b2*btg*btg-adnh*ubry3
1819 real,parameter :: aubm=54.*a1*a1*a2x*b2*c1*btg -adnm*ubry3
1820 real,parameter :: bubh=(9.*a1*a2x+3.*a2x*b2)*btg-bdnh*ubry3
1821 real,parameter :: bubm=18.*a1*a1*c1 -bdnm*ubry3
1822 real,parameter :: cubr=1.-ubry3,rcubr=1./cubr
1823 !-------------------------------------------------------------------------------
1824 ! k profile constants
1825 !-------------------------------------------------------------------------------
1826 real,parameter :: elcbl=0.77
1827 !-------------------------------------------------------------------------------
1829 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
1830 ims,ime, jms,jme, kms,kme, &
1831 its,ite, jts,jte, kts,kte
1832 integer, intent(in ) :: lmh,lmxl,lpbl
1834 real, intent(in ) :: p608,vkarman,cp
1835 real, intent(in ) :: hpbl,corf,ustar,hgamu,hgamv,hgamq
1836 real, intent(inout) :: ct,epshol
1838 real, dimension( kts:kte ) , &
1839 intent(in ) :: cwm, &
1847 real, dimension( kts+1:kte ) , &
1848 intent(in ) :: mf, &
1853 real, dimension( kts:kte+1 ) , &
1856 real, dimension( kts+1:kte ) , &
1857 intent(out ) :: el, &
1862 logical,intent(in) :: pblflg
1867 real :: suk,svk,elocp
1868 real :: a,aden,b,bden,aubr,bubr,blmx,el0,eloq2x,ghl,s2l, &
1869 qol2st,qol2un,qdzl,rdz,sq,srel,szq,tem,thm,vkrmz,rlambda, &
1872 real, dimension( kts:kte ) :: q1, &
1874 real, dimension( kts+1:kte ) :: dth, &
1878 !-------------------------------------------------------------------------------
1888 dth(k) = the(k)-the(k-1)
1892 if(dth(k)>0..and.dth(k-1)<=0.)then
1898 ! compute local gradient richardson number
1901 rdz=2./(z(k+1)-z(k-1))
1902 s2l=((u(k)-u(k-1))**2+(v(k)-v(k-1))**2)*rdz*rdz ! s**2
1903 if(pblflg.and.k.le.lpbl)then
1904 suk=(u(k)-u(k-1))*rdz
1905 svk=(v(k)-v(k-1))*rdz
1906 s2l=(suk-hgamu/hpbl-ufxpbl(k))*suk+(svk-hgamv/hpbl-vfxpbl(k))*svk
1911 tem=(t(k)+t(k-1))*0.5
1912 thm=(the(k)+the(k-1))*0.5
1914 b=(elocp/tem-1.-p608)*thm
1915 ghl=(dth(k)*((q(k)+q(k-1)+cwm(k)+cwm(k-1))*(0.5*p608)+1.) &
1916 +(q(k)-q(k-1)+cwm(k)-cwm(k-1))*a &
1917 +(cwm(k)-cwm(k-1))*b)*rdz ! dtheta/dz
1918 if(pblflg.and.k.le.lpbl)then
1919 ghl=ghl-mf(k)-(hgamq/hpbl+qfxpbl(k))*a
1921 if(abs(ghl)<=epsgh)ghl=epsgh
1923 en2(k)=ghl*g/thm ! n**2
1928 ! find maximum mixing lengths and the level of the pbl top
1934 if(s2l/ghl<=requ)then
1937 aubr=(aubm*s2l+aubh*ghl)*ghl
1938 bubr= bubm*s2l+bubh*ghl
1939 qol2st=(-0.5*bubr+sqrt(bubr*bubr*0.25-aubr*cubr))*rcubr
1941 elm(k)=max(sqrt(eloq2x*q2(k)),epsl)
1944 aden=(adnm*s2l+adnh*ghl)*ghl
1945 bden= bdnm*s2l+bdnh*ghl
1946 qol2un=-0.5*bden+sqrt(bden*bden*0.25-aden)
1947 eloq2x=1./(qol2un+epsru) ! repsr1/qol2un
1948 elm(k)=max(sqrt(eloq2x*q2(k)),epsl)
1959 qdzl=(q1(k)+q1(k-1))*(z(k)-z(k-1))
1960 szq=(z(k)+z(k-1)-z(lmh)-z(lmh))*qdzl+szq
1964 ! computation of asymptotic l in blackadar formula
1966 el0=min(alph*szq*0.5/sq,el0max)
1967 el0=max(el0 ,el0min)
1971 lpblm=min(lpbl+1,kte)
1973 el(k)=(z(k+1)-z(k-1))*elfc
1979 epshol=min(epshol,0.0)
1980 ckp=elcbl*((1.0-8.0*epshol)**(1./3.))
1982 do k = lpbl,lmh+1,-1
1983 vkrmz=(z(k)-z(lmh))*vkarman
1985 vkrmz=ckp*(z(k)-z(lmh))*vkarman
1986 el(k)=vkrmz/(vkrmz/el0+1.)
1988 el(k)=vkrmz/(vkrmz/el0+1.)
1994 do k = lpbl-1,lmh+2,-1
1995 srel=min(((rel(k-1)+rel(k+1))*0.5+rel(k))*0.5,rel(k))
1996 el(k)=max(srel*elm(k),epsl)
1999 ! mixing length for the qnse model in stable case
2002 rlambda=f/(blckdr*ustar)
2004 if(en2(k)>=0.0)then ! stable case
2005 vkrmz=(z(k)-z(lmh))*vkarman
2006 rlb=rlambda+1./vkrmz
2007 rln=sqrt(2.*en2(k)/q2(k))/cn
2012 end subroutine mixlen
2013 !-------------------------------------------------------------------------------
2015 !-------------------------------------------------------------------------------
2016 subroutine prodq2(lmh,dtturbl,ustar,s2,ri,q2,el,z,akm,akh, &
2017 uxk,vxk,thxk,thvxk, &
2018 hgamu,hgamv,hgamq,delxy, &
2020 mf,ufxpbl,vfxpbl,qfxpbl, &
2022 ids,ide,jds,jde,kds,kde, &
2023 ims,ime,jms,jme,kms,kme, &
2024 its,ite,jts,jte,kts,kte)
2025 !-------------------------------------------------------------------------------
2027 !-------------------------------------------------------------------------------
2029 real,parameter :: epsq2l = 0.01,c0 = 0.55,ceps = 16.6,g = 9.81
2031 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
2032 ims,ime, jms,jme, kms,kme, &
2033 its,ite, jts,jte, kts,kte
2034 integer, intent(in ) :: lmh,kpbl
2036 real, intent(in ) :: p608,dtturbl,ustar
2037 real, intent(in ) :: hgamu,hgamv,hgamq,delxy,hpbl
2039 logical, intent(in ) :: pblflg
2041 real, dimension( kts:kte ) , &
2042 intent(in ) :: uxk, &
2046 real, dimension( kts+1:kte ) , &
2047 intent(in ) :: s2, &
2057 real, dimension( kts:kte+1 ) , &
2060 real, dimension( kts:kte ) , &
2067 real :: s2l,q2l,deltaz,akml,akhl,en2,pr,bpr,dis,rc02
2068 real :: suk,svk,gthvk,govrthvk,pru,prv
2071 !-------------------------------------------------------------------------------
2075 ! start of production/dissipation loop
2077 main_integration: do k = kts+1,kte
2078 deltaz=0.5*(z(k+1)-z(k-1))
2081 suk=(uxk(k)-uxk(k-1))/deltaz
2082 svk=(vxk(k)-vxk(k-1))/deltaz
2083 gthvk=(thvxk(k)-thvxk(k-1))/deltaz
2084 govrthvk=g/(0.5*(thvxk(k)+thvxk(k-1)))
2088 thm=(thxk(k)+thxk(k-1))*0.5
2090 ! turbulence production term
2092 if(pblflg.and.k.le.kpbl)then
2093 pru=(akml*(suk-hgamu/hpbl-ufxpbl(k)))*suk
2094 prv=(akml*(svk-hgamv/hpbl-vfxpbl(k)))*svk
2101 ! buoyancy production
2103 if(pblflg.and.k.le.kpbl)then
2104 bpr=(akhl*(gthvk-mf(k)-(hgamq/hpbl+qfxpbl(k))*p608*thm))*govrthvk
2106 bpr=akhl*gthvk*govrthvk
2111 disel=min(delxy,ceps*el(k))
2112 dis=(q2l)**1.5/disel
2114 q2l=q2l+2.0*(pr-bpr-dis)*dtturbl
2115 q2(k)=amax1(q2l,epsq2l)
2117 ! end of production/dissipation loop
2119 enddo main_integration
2121 ! lower boundary condition for q2
2123 q2(kts)=amax1(rc02*ustar*ustar,epsq2l)
2125 end subroutine prodq2
2126 !-------------------------------------------------------------------------------
2128 !-------------------------------------------------------------------------------
2129 subroutine vdifq(lmh,dtdif,q2,el,z, &
2131 hgame,hpbl,pblflg,kpbl, &
2133 ids,ide,jds,jde,kds,kde, &
2134 ims,ime,jms,jme,kms,kme, &
2135 its,ite,jts,jte,kts,kte)
2136 !-------------------------------------------------------------------------------
2138 !-------------------------------------------------------------------------------
2140 real,parameter :: c_k=1.0,esq=5.0
2142 integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &
2143 ims,ime, jms,jme, kms,kme, &
2144 its,ite, jts,jte, kts,kte
2145 integer, intent(in ) :: lmh,kpbl
2147 real, intent(in ) :: dtdif,hpbl,efxpbl
2149 logical, intent(in ) :: pblflg
2151 real, dimension( kts:kte ) , &
2152 intent(in ) :: hgame, &
2154 real, dimension( kts+1:kte ) , &
2155 intent(in ) :: el, &
2157 real, dimension( kts:kte+1 ) , &
2160 real, dimension( kts:kte ) , &
2167 real :: aden,akqs,bden,besh,besm,cden,cf,dtozs,ell,eloq2,eloq4
2168 real :: elqdz,esh,esm,esqhf,ghl,gml,q1l,rden,rdz
2171 real, dimension( kts+1:kte ) :: zfacentk
2172 real, dimension( kts+2:kte ) :: akq, &
2178 !-------------------------------------------------------------------------------
2180 ! vertical turbulent diffusion
2184 zak=0.5*(z(k)+z(k-1)) !zak of vdifq = za(k-1) of shinhong2d
2185 zfacentk(k)=(zak/hpbl)**3.0
2189 dtoz(k)=(dtdif+dtdif)/(z(k+1)-z(k-1))
2190 akq(k)=c_k*(akhk(k)/(z(k+1)-z(k-1))+akhk(k-1)/(z(k)-z(k-2)))
2191 akq(k)=akq(k)*ptke1(k)
2192 cr(k)=-dtoz(k)*akq(k)
2195 akqs=c_k*akhk(kts+1)/(z(kts+2)-z(kts))
2196 akqs=akqs*ptke1(kts+1)
2197 cm(kte)=dtoz(kte)*akq(kte)+1.
2200 do k = kte-1,kts+2,-1
2201 cf=-dtoz(k)*akq(k+1)/cm(k+1)
2202 cm(k)=-cr(k+1)*cf+(akq(k+1)+akq(k))*dtoz(k)+1.
2203 rsq2(k)=-rsq2(k+1)*cf+q2(k)
2204 if(pblflg.and.k.lt.kpbl) then
2205 rsq2(k)=rsq2(k)-dtoz(k)*(2.0*hgame(k)/hpbl)*akq(k+1)*(z(k+1)-z(k)) &
2206 +dtoz(k)*(2.0*hgame(k-1)/hpbl)*akq(k)*(z(k)-z(k-1))
2207 rsq2(k)=rsq2(k)-dtoz(k)*2.0*efxpbl*zfacentk(k+1) &
2208 +dtoz(k)*2.0*efxpbl*zfacentk(k)
2212 dtozs=(dtdif+dtdif)/(z(kts+2)-z(kts))
2213 cf=-dtozs*akq(lmh+2)/cm(lmh+2)
2215 if(pblflg.and.((lmh+1).lt.kpbl)) then
2216 q2(lmh+1)=(dtozs*akqs*q2(lmh)-rsq2(lmh+2)*cf+q2(lmh+1) &
2217 -dtozs*(2.0*hgame(lmh+1)/hpbl)*akq(lmh+2)*(z(lmh+2)-z(lmh+1)) &
2218 +dtozs*(2.0*hgame(lmh)/hpbl)*akqs*(z(lmh+1)-z(lmh)))
2219 q2(lmh+1)=q2(lmh+1)-dtozs*2.0*efxpbl*zfacentk(lmh+2) &
2220 +dtozs*2.0*efxpbl*zfacentk(lmh+1)
2221 q2(lmh+1)=q2(lmh+1)/((akq(lmh+2)+akqs)*dtozs-cr(lmh+2)*cf+1.)
2223 q2(lmh+1)=(dtozs*akqs*q2(lmh)-rsq2(lmh+2)*cf+q2(lmh+1)) &
2224 /((akq(lmh+2)+akqs)*dtozs-cr(lmh+2)*cf+1.)
2228 q2(k)=(-cr(k)*q2(k-1)+rsq2(k))/cm(k)
2231 end subroutine vdifq
2232 !-------------------------------------------------------------------------------
2234 !-------------------------------------------------------------------------------
2235 subroutine shinhonginit(rublten,rvblten,rthblten,rqvblten, &
2236 rqcblten,rqiblten, &
2238 p_qi,p_first_scalar, &
2239 restart, allowed_to_read, &
2240 ids, ide, jds, jde, kds, kde, &
2241 ims, ime, jms, jme, kms, kme, &
2242 its, ite, jts, jte, kts, kte )
2243 !-------------------------------------------------------------------------------
2245 !-------------------------------------------------------------------------------
2247 real,parameter :: epsq2l = 0.01
2248 logical , intent(in) :: restart, allowed_to_read
2249 integer , intent(in) :: ids, ide, jds, jde, kds, kde, &
2250 ims, ime, jms, jme, kms, kme, &
2251 its, ite, jts, jte, kts, kte
2252 integer , intent(in) :: p_qi,p_first_scalar
2253 real , dimension( ims:ime , kms:kme , jms:jme ), intent(out) :: &
2260 real , dimension( ims:ime , kms:kme , jms:jme ), intent(out) :: &
2262 integer :: i, j, k, itf, jtf, ktf
2264 jtf = min0(jte,jde-1)
2265 ktf = min0(kte,kde-1)
2266 itf = min0(ite,ide-1)
2268 if(.not.restart)then
2274 rthblten(i,k,j) = 0.
2275 rqvblten(i,k,j) = 0.
2276 rqcblten(i,k,j) = 0.
2277 tke_pbl(i,k,j) = epsq2l/2.
2283 if (p_qi .ge. p_first_scalar .and. .not.restart) then
2287 rqiblten(i,k,j) = 0.
2293 end subroutine shinhonginit
2294 !-------------------------------------------------------------------------------
2296 !-------------------------------------------------------------------------------
2298 !-------------------------------------------------------------------------------
2300 !-------------------------------------------------------------------------------
2302 real,parameter :: pmin = 0.0,pmax = 1.0
2303 real,parameter :: a1 = 1.0, a2 = 0.070, a3 = 1.0, a4 = 0.142, a5 = 0.071
2304 real,parameter :: b1 = 2.0, b2 = 0.6666667
2305 real :: d,h,doh,num,den
2309 num=a1*(doh)**b1+a2*(doh)**b2
2310 den=a3*(doh)**b1+a4*(doh)**b2+a5
2320 !-------------------------------------------------------------------------------
2322 !-------------------------------------------------------------------------------
2324 !-------------------------------------------------------------------------------
2326 !-------------------------------------------------------------------------------
2328 real,parameter :: pmin = 0.0,pmax = 1.0
2329 real,parameter :: a1 = 1.0, a2 = -0.098, a3 = 1.0, a4 = 0.106, a5 = 0.5
2330 real,parameter :: b1 = 2.0
2331 real :: d,h,doh,num,den
2337 pq=a5*num/den+(1.-a5)
2346 !-------------------------------------------------------------------------------
2348 !-------------------------------------------------------------------------------
2350 !-------------------------------------------------------------------------------
2352 !-------------------------------------------------------------------------------
2354 real,parameter :: pmin = 0.0,pmax = 1.0
2355 real,parameter :: a1 = 1.000, a2 = 0.936, a3 = -1.110, &
2356 a4 = 1.000, a5 = 0.312, a6 = 0.329, a7 = 0.243
2357 real,parameter :: b1 = 2.0, b2 = 0.875
2358 real :: d,h,doh,num,den
2362 num=a1*(doh)**b1+a2*(doh)**b2+a3
2363 den=a4*(doh)**b1+a5*(doh)**b2+a6
2364 pthnl=a7*num/den+(1.-a7)
2368 pthnl=max(pthnl,pmin)
2369 pthnl=min(pthnl,pmax)
2373 !-------------------------------------------------------------------------------
2375 !-------------------------------------------------------------------------------
2377 !-------------------------------------------------------------------------------
2379 !-------------------------------------------------------------------------------
2381 real,parameter :: pmin = 0.0,pmax = 1.0
2382 real,parameter :: a1 = 1.000, a2 = 0.870, a3 = -0.913, &
2383 a4 = 1.000, a5 = 0.153, a6 = 0.278, a7 = 0.280
2384 real,parameter :: b1 = 2.0, b2 = 0.5
2385 real :: d,h,doh,num,den
2389 num=a1*(doh)**b1+a2*(doh)**b2+a3
2390 den=a4*(doh)**b1+a5*(doh)**b2+a6
2391 pthl=a7*num/den+(1.-a7)
2400 !-------------------------------------------------------------------------------
2402 !-------------------------------------------------------------------------------
2404 !-------------------------------------------------------------------------------
2406 !-------------------------------------------------------------------------------
2408 real,parameter :: pmin = 0.0,pmax = 1.0
2409 real,parameter :: a1 = 1.000, a2 = 0.070, &
2410 a3 = 1.000, a4 = 0.142, a5 = 0.071
2411 real,parameter :: b1 = 2.0, b2 = 0.6666667
2412 real :: d,h,doh,num,den
2416 num=a1*(doh)**b1+a2*(doh)**b2
2417 den=a3*(doh)**b1+a4*(doh)**b2+a5
2427 !-------------------------------------------------------------------------------
2429 !-------------------------------------------------------------------------------
2430 end module module_bl_shinhong
2431 !-------------------------------------------------------------------------------