55 SUBROUTINE bndlyr(PBND,TBND,QBND,RHBND,UBND,VBND, &
56 WBND,OMGBND,PWTBND,QCNVBND,LVLBND)
60 use vrbls3d,
only: pint, q, uh, vh, pmid, t, omga, wh, cwm
62 use params_mod,
only: d00, gi, pq0, a2, a3, a4
63 use ctlblk_mod,
only: jsta_2l, jend_2u, lm, jsta, jend, modelname, &
64 jsta_m, jend_m, im, nbnd, spval, ista_2l, iend_2u, ista_m, iend_m, ista, iend
65 use physcons_post,
only: con_rd, con_rv, con_eps, con_epsm1
66 use gridspec_mod,
only: gridtype
67 use upp_physics,
only: fpvsnew
73 real,
PARAMETER :: DPBND=30.e2
74 integer,
dimension(ista:iend,jsta:jend,NBND),
intent(inout) :: LVLBND
75 real,
dimension(ista:iend,jsta:jend,NBND),
intent(inout) :: PBND,TBND, &
76 qbnd,rhbnd,ubnd,vbnd,wbnd,omgbnd,pwtbnd,qcnvbnd
78 REAL Q1D(ISTA_2L:IEND_2U,JSTA_2L:JEND_2U),V1D(ISTA_2L:IEND_2U,JSTA_2L:JEND_2U), &
79 u1d(ista_2l:iend_2u,jsta_2l:jend_2u),qcnv1d(ista_2l:iend_2u,jsta_2l:jend_2u)
81 REAL,
ALLOCATABLE :: PBINT(:,:,:),QSBND(:,:,:)
82 REAL,
ALLOCATABLE :: PSUM(:,:,:), QCNVG(:,:,:)
83 REAL,
ALLOCATABLE :: PVSUM(:,:,:),NSUM(:,:,:)
85 integer I,J,L,IE,IW,LL,LV,LBND
86 real DP,QSAT,PV1,PV2,PMV,RPSUM,RPVSUM,PMIN,PM,DELP,PMINV,DELPV
92 ALLOCATE (pbint(ista_2l:iend_2u,jsta_2l:jend_2u,nbnd+1))
93 ALLOCATE (qsbnd(ista_2l:iend_2u,jsta_2l:jend_2u,nbnd))
94 ALLOCATE (psum(ista_2l:iend_2u,jsta_2l:jend_2u,nbnd))
95 ALLOCATE (qcnvg(ista_2l:iend_2u,jsta_2l:jend_2u,lm))
96 ALLOCATE (pvsum(ista_2l:iend_2u,jsta_2l:jend_2u,nbnd))
97 ALLOCATE (nsum(ista_2l:iend_2u,jsta_2l:jend_2u,nbnd))
105 pbint(i,j,1) = pint(i,j,nint(lmh(i,j))+1)
113 pbint(i,j,lbnd) = pbint(i,j,lbnd-1) - dpbnd
128 CALL calmcvg(q1d,u1d,v1d,qcnv1d)
132 qcnvg(i,j,l)=qcnv1d(i,j)
151 qsbnd(i,j,lbnd) = d00
152 rhbnd(i,j,lbnd) = d00
156 omgbnd(i,j,lbnd) = d00
160 pvsum(i,j,lbnd) = d00
161 pwtbnd(i,j,lbnd) = d00
162 qcnvbnd(i,j,lbnd)= d00
174 IF((pbint(i,j,lbnd) >= pm).AND. &
175 (pbint(i,j,lbnd+1) <= pm))
THEN
176 dp = pint(i,j,l+1) - pint(i,j,l)
177 psum(i,j,lbnd) = psum(i,j,lbnd) + dp
178 nsum(i,j,lbnd) = nsum(i,j,lbnd) + 1
179 lvlbnd(i,j,lbnd) = lvlbnd(i,j,lbnd) + l
180 tbnd(i,j,lbnd) = tbnd(i,j,lbnd) + t(i,j,l)*dp
181 qbnd(i,j,lbnd) = qbnd(i,j,lbnd) + q(i,j,l)*dp
182 omgbnd(i,j,lbnd) = omgbnd(i,j,lbnd) + omga(i,j,l)*dp
183 IF(gridtype ==
'A')
THEN
184 ubnd(i,j,lbnd) = ubnd(i,j,lbnd) + uh(i,j,l)*dp
185 vbnd(i,j,lbnd) = vbnd(i,j,lbnd) + vh(i,j,l)*dp
187 wbnd(i,j,lbnd) = wbnd(i,j,lbnd) + wh(i,j,l)*dp
188 qcnvbnd(i,j,lbnd) = qcnvbnd(i,j,lbnd) + qcnvg(i,j,l)*dp
189 pwtbnd(i,j,lbnd) = pwtbnd(i,j,lbnd) &
190 + ( q(i,j,l)+cwm(i,j,l))*dp*gi
191 IF(modelname ==
'GFS')
THEN
192 es = min(fpvsnew(t(i,j,l)),pm)
193 qsat = con_eps*es/(pm+con_epsm1*es)
195 qsat = pq0/pm*exp(a2*(t(i,j,l)-a3)/(t(i,j,l)-a4))
197 qsbnd(i,j,lbnd) = qsbnd(i,j,lbnd) + qsat*dp
205 omgbnd(i,j,lbnd)=spval
206 qcnvbnd(i,j,lbnd)=spval
207 pwtbnd(i,j,lbnd)=spval
209 qsbnd(i,j,lbnd)=spval
210 rhbnd(i,j,lbnd)=spval
217 IF(gridtype==
'E')
THEN
218 CALL exch(pint(ista_2l:iend_2u,jsta_2l:jend_2u,1))
220 CALL exch(pint(ista_2l:iend_2u,jsta_2l:jend_2u,l+1))
226 pv1 = 0.25*(pint(iw,j,l) + pint(ie,j,l) &
227 +pint(i,j+1,l) + pint(i,j-1,l))
228 pv2 = 0.25*(pint(iw,j,l+1) + pint(ie,j,l+1) &
229 +pint(i,j+1,l+1) + pint(i,j-1,l+1))
232 IF((pbint(iw,j,lbnd)>=pmv).AND. &
233 (pbint(iw,j,lbnd+1)<=pmv))
THEN
234 pvsum(i,j,lbnd) = pvsum(i,j,lbnd) + dp
235 ubnd(i,j,lbnd) = ubnd(i,j,lbnd) + dp* uh(i,j,l)
236 vbnd(i,j,lbnd) = vbnd(i,j,lbnd) + dp*vh(i,j,l)
242 ELSE IF (gridtype==
'B')
THEN
243 CALL exch(pint(ista_2l:iend_2u,jsta_2l:jend_2u,1))
245 CALL exch(pint(ista_2l:iend_2u,jsta_2l:jend_2u,l+1))
251 pv1 = 0.25*(pint(iw,j,l) + pint(ie,j,l) &
252 +pint(iw,j+1,l) + pint(ie,j+1,l))
253 pv2 = 0.25*(pint(iw,j,l+1) + pint(ie,j,l+1) &
254 +pint(iw,j+1,l+1) + pint(ie,j+1,l+1))
257 IF((pbint(iw,j,lbnd)>=pmv).AND. &
258 (pbint(iw,j,lbnd+1)<=pmv))
THEN
259 pvsum(i,j,lbnd) = pvsum(i,j,lbnd)+dp
260 ubnd(i,j,lbnd) = ubnd(i,j,lbnd)+uh(i,j,l)*dp
261 vbnd(i,j,lbnd) = vbnd(i,j,lbnd)+vh(i,j,l)*dp
276 IF(psum(i,j,lbnd)/=0..AND.tbnd(i,j,lbnd)<spval)
THEN
277 rpsum = 1./psum(i,j,lbnd)
278 lvlbnd(i,j,lbnd)= lvlbnd(i,j,lbnd)/nsum(i,j,lbnd)
279 pbnd(i,j,lbnd) = (pbint(i,j,lbnd)+pbint(i,j,lbnd+1))*0.5
280 tbnd(i,j,lbnd) = tbnd(i,j,lbnd)*rpsum
281 qbnd(i,j,lbnd) = qbnd(i,j,lbnd)*rpsum
282 qsbnd(i,j,lbnd) = qsbnd(i,j,lbnd)*rpsum
283 omgbnd(i,j,lbnd)= omgbnd(i,j,lbnd)*rpsum
284 IF(gridtype==
'A')
THEN
285 ubnd(i,j,lbnd) = ubnd(i,j,lbnd)*rpsum
286 vbnd(i,j,lbnd) = vbnd(i,j,lbnd)*rpsum
288 wbnd(i,j,lbnd) = wbnd(i,j,lbnd)*rpsum
289 IF(qcnvbnd(i,j,lbnd)<spval) &
290 qcnvbnd(i,j,lbnd) = qcnvbnd(i,j,lbnd)*rpsum
295 IF(gridtype==
'E' .or. gridtype==
'B')
THEN
298 IF(pvsum(i,j,lbnd)/=0.)
THEN
299 rpvsum = 1./pvsum(i,j,lbnd)
300 ubnd(i,j,lbnd) = ubnd(i,j,lbnd)*rpvsum
301 vbnd(i,j,lbnd) = vbnd(i,j,lbnd)*rpvsum
317 IF(psum(i,j,lbnd)==0..AND.pbnd(i,j,lbnd)<spval)
THEN
320 pbnd(i,j,lbnd) = (pbint(i,j,lbnd)+pbint(i,j,lbnd+1))*0.5
324 delp = abs(pm-pbnd(i,j,lbnd))
331 dp = pint(i,j,l+1)-pint(i,j,l)
334 tbnd(i,j,lbnd) = t(i,j,l)
335 qbnd(i,j,lbnd) = q(i,j,l)
336 IF(gridtype ==
'A')
THEN
337 ubnd(i,j,lbnd) = uh(i,j,l)
338 vbnd(i,j,lbnd) = vh(i,j,l)
340 wbnd(i,j,lbnd) = wh(i,j,l)
341 qcnvbnd(i,j,lbnd) = qcnvg(i,j,l)
342 IF(modelname ==
'GFS' .OR. modelname ==
'FV3R')
THEN
343 es = fpvsnew(t(i,j,l))
345 qsat = con_eps*es/(pm+con_epsm1*es)
347 qsat=pq0/pm*exp(a2*(t(i,j,l)-a3)/(t(i,j,l)-a4))
349 qsbnd(i,j,lbnd) = qsat
350 omgbnd(i,j,lbnd) = omga(i,j,l)
351 pwtbnd(i,j,lbnd) = (q(i,j,l)+cwm(i,j,l))*dp*gi
356 IF(qsbnd(i,j,lbnd)/=0..AND.qbnd(i,j,lbnd)<spval)
THEN
357 rhbnd(i,j,lbnd) = qbnd(i,j,lbnd)/qsbnd(i,j,lbnd)
358 IF (rhbnd(i,j,lbnd)>1.0)
THEN
359 rhbnd(i,j,lbnd) = 1.0
360 qbnd(i,j,lbnd) = rhbnd(i,j,lbnd)*qsbnd(i,j,lbnd)
362 IF (rhbnd(i,j,lbnd)<0.01)
THEN
363 rhbnd(i,j,lbnd) = 0.01
364 qbnd(i,j,lbnd) = rhbnd(i,j,lbnd)*qsbnd(i,j,lbnd)
370 IF(gridtype ==
'E')
THEN
373 IF(pvsum(i,j,lbnd)==0.)
THEN
382 pmv = 0.125*(pint(iw,j,ll) + pint(ie,j,ll) + &
383 pint(i,j+1,ll) + pint(i,j-1,ll) + &
384 pint(iw,j,ll+1) + pint(ie,j,ll+1) + &
385 pint(i,j+1,ll+1) + pint(i,j-1,ll+1))
386 delpv = abs(pmv-pbnd(i,j,lbnd))
393 ubnd(i,j,lbnd) = uh(i,j,lv)
394 vbnd(i,j,lbnd) = vh(i,j,lv)
400 ELSE IF(gridtype==
'B')
THEN
403 IF(pvsum(i,j,lbnd)==0.)
THEN
412 pmv=0.125*(pint(iw,j,ll)+pint(ie,j,ll)+ &
413 pint(iw,j+1,ll)+pint(ie,j+1,ll)+ &
414 pint(iw,j,ll+1)+pint(ie,j,ll+1)+ &
415 pint(iw,j+1,ll+1)+pint(ie,j+1,ll+1))
416 delpv=abs(pmv-pbnd(i,j,lbnd))
423 ubnd(i,j,lbnd) = uh(i,j,lv)
424 vbnd(i,j,lbnd) = vh(i,j,lv)
431 DEALLOCATE (pbint, qsbnd, psum, pvsum, qcnvg, nsum)