183 SUBROUTINE gwdps(IM,IX,IY,KM,A,B,C,U1,V1,T1,Q1,KPBL, &
184 & prsi,del,prsl,prslk,phii, phil,deltim,kdt, &
185 & hprime,oc,oa4,clx4,theta,sigma,gamma,elvmax, &
186 & dusfc,dvsfc,g, cp, rd, rv, imx, &
187 & nmtvr, cdmbgwd, me, lprnt, ipr)
280 USE machine
, ONLY : kind_phys
282 integer im, iy, ix, km, imx, kdt, ipr, me
284 real(kind=kind_phys) deltim, G, CP, RD, RV, cdmbgwd(2)
285 real(kind=kind_phys) A(iy,km), B(iy,km), C(iy,km), &
286 & U1(IX,KM), V1(IX,KM), T1(IX,KM), &
287 & Q1(IX,KM), PRSI(IX,KM+1), DEL(IX,KM), &
288 & PRSL(IX,KM), PRSLK(IX,KM), PHIL(IX,KM), &
290 real(kind=kind_phys) OC(im), OA4(iy,4), CLX4(iy,4) &
293 real(kind=kind_phys) ELVMAX(im),THETA(im),SIGMA(im),GAMMA(im)
294 real(kind=kind_phys) wk(im)
295 real(kind=kind_phys) bnv2lm(im,km),PE(im),EK(im),ZBK(im),UP(im)
296 real(kind=kind_phys) DB(im,km),ANG(im,km),UDS(im,km)
297 real(kind=kind_phys) ZLEN, DBTMP, R, PHIANG, CDmb, DBIM
298 real(kind=kind_phys) ENG0, ENG1
302 real(kind=kind_phys) pi, dw2min, rimin, ric, bnv2min, efmin
303 &, efmax,hpmax,hpmin, rad_to_deg, deg_to_rad
304 parameter(pi=3.1415926535897931)
305 parameter(rad_to_deg=180.0/pi, deg_to_rad=pi/180.0)
306 parameter(dw2min=1., rimin=-100., ric=0.25, bnv2min=1.0e-5)
308 parameter(efmin=0.0, efmax=10.0, hpmax=2400.0, hpmin=1.0)
310 real(kind=kind_phys) FRC, CE, CEOFRC, frmax, CG, GMAX
311 &, veleps, factop, rlolev, rdi
313 parameter(frc=1.0, ce=0.8, ceofrc=ce/frc, frmax=100., cg=0.5)
314 parameter(gmax=1.0, veleps=1.0, factop=0.5)
316 parameter(rlolev=50000.0)
320 real(kind=kind_phys) dpmin,hminmt,hncrit,minwnd,sigfac
323 parameter(hncrit=8000.)
325 parameter(sigfac=4.0)
326 parameter(hminmt=50.)
327 parameter(minwnd=0.1)
333 parameter(dpmin=5000.0)
336 real(kind=kind_phys) FDIR
338 parameter(mdir=8, fdir=mdir/(pi+pi))
340 data nwdir/6,7,5,8,2,3,1,4/
347 real(kind=kind_phys) TAUB(im), XN(im), YN(im), UBAR(im) &
348 &, VBAR(IM), ULOW(IM), OA(IM), CLX(IM) &
349 &, ROLL(IM), ULOI(IM), DUSFC(IM), DVSFC(IM) &
350 &, DTFAC(IM), XLINV(IM), DELKS(IM), DELKS1(IM)
352 real(kind=kind_phys) BNV2(im,km), TAUP(im,km+1), ri_n(im,km) &
353 &, TAUD(IM,KM), RO(IM,KM), VTK(IM,KM) &
354 &, VTJ(IM,KM), SCOR(IM), VELCO(IM,KM-1) &
358 Integer kref(im), kint(im), iwk(im), ipt(im)
360 Integer kreflm(im), iwklm(im)
361 Integer idxzb(im), ktrial, klevm1, nmtvr
363 real(kind=kind_phys) gor, gocp, fv, gr2, bnv, fr &
364 &, brvf, cleff, tem, tem1, tem2, temc, temv &
365 &, wdir, ti, rdz, dw2, shr2, bvf2 &
366 &, rdelks, efact, coefm, gfobnv &
367 &, scork, rscor, hd, fro, rim, sira &
368 &, dtaux, dtauy, pkp1log, pklog
369 integer kmm1, kmm2, lcap, lcapp1, kbps, kbpsp1,kbpsm1 &
370 &, kmps, idir, nwd, i, j, k, klcap, kp1, kmpbl, npt, npr &
379 cdmb = 4.0 * 192.0/float(imx)
380 if (cdmbgwd(1) >= 0.0) cdmb = cdmb * cdmbgwd(1)
409 IF ( nmtvr .eq. 14)
then
414 IF ( (elvmax(i) .GT. hminmt)
415 & .and. (hprime(i) .GT. hpmin) )
then
418 if (ipr .eq. i) npr = npt
421 IF (npt .eq. 0)
RETURN
453 elvmax(j) = min(elvmax(j) + sigfac * hprime(j), hncrit)
461 pkp1log = phil(j,k+1) / g
462 pklog = phil(j,k) / g
464 if ( ( elvmax(j) .le. pkp1log ) .and.
465 & ( elvmax(j) .ge. pklog ) )
THEN
468 wk(i) = g * elvmax(j) / ( phil(j,k+1) - phil(j,k) )
469 iwklm(i) = max(iwklm(i), k+1 )
475 vtj(i,k) = t1(j,k) * (1.+fv*q1(j,k))
476 vtk(i,k) = vtj(i,k) / prslk(j,k)
477 ro(i,k) = rdi * prsl(j,k) / vtj(i,k)
499 rdz = g / ( phil(j,k+1) - phil(j,k) )
502 bnv2lm(i,k) = (g+g) * rdz * ( vtk(i,k+1)-vtk(i,k) )
503 & / ( vtk(i,k+1)+vtk(i,k) )
504 bnv2lm(i,k) = max( bnv2lm(i,k), bnv2min )
511 delks(i) = 1.0 / (prsi(j,1) - prsi(j,iwklm(i)))
512 delks1(i) = 1.0 / (prsl(j,1) - prsl(j,iwklm(i)))
518 bnv2bar(i) = (prsl(j,1)-prsl(j,2)) * delks1(i) * bnv2lm(i,1)
526 DO ktrial = kmll, 1, -1
528 IF ( ktrial .LT. iwklm(i) .and. kreflm(i) .eq. 0 )
then
543 rdelks = del(j,k) * delks(i)
544 ubar(i) = ubar(i) + rdelks * u1(j,k)
545 vbar(i) = vbar(i) + rdelks * v1(j,k)
546 roll(i) = roll(i) + rdelks * ro(i,k)
547 rdelks = (prsl(j,k)-prsl(j,k+1)) * delks1(i)
548 bnv2bar(i) = bnv2bar(i) + bnv2lm(i,k) * rdelks
560 DO k = iwklm(i), 1, -1
561 phiang = atan2(v1(j,k),u1(j,k))*rad_to_deg
562 ang(i,k) = ( theta(j) - phiang )
563 if ( ang(i,k) .gt. 90. ) ang(i,k) = ang(i,k) - 180.
564 if ( ang(i,k) .lt. -90. ) ang(i,k) = ang(i,k) + 180.
565 ang(i,k) = ang(i,k) * deg_to_rad
574 & max(sqrt(u1(j,k)*u1(j,k) + v1(j,k)*v1(j,k)), minwnd)
576 IF (idxzb(i) .eq. 0 )
then
577 pe(i) = pe(i) + bnv2lm(i,k) *
578 & ( g * elvmax(j) - phil(j,k) ) *
579 & ( phii(j,k+1) - phii(j,k) ) / (g*g)
584 up(i) = uds(i,k) * cos(ang(i,k))
585 ek(i) = 0.5 * up(i) * up(i)
588 IF ( pe(i) .ge. ek(i) ) idxzb(i) = k
621 & - sqrt(ubar(i)*ubar(i) + vbar(i)*vbar(i))/bnv2bar(i)
636 IF ( idxzb(i) .gt. 0 )
then
637 DO k = idxzb(i), 1, -1
638 IF ( phil(j,idxzb(i)) .gt. phil(j,k) )
then
647 zlen = sqrt( ( phil(j,idxzb(i)) - phil(j,k) ) /
648 & ( phil(j,k ) + g * hprime(j) ) )
659 r = (cos(ang(i,k))**2 + gamma(j) * sin(ang(i,k))**2) /
660 & (gamma(j) * cos(ang(i,k))**2 + sin(ang(i,k))**2)
672 dbtmp = 0.25 * cdmb *
673 & max( 2. - 1. / r, 0. ) * sigma(j) *
674 & max(cos(ang(i,k)), gamma(j)*sin(ang(i,k))) *
676 db(i,k) = dbtmp * uds(i,k)
694 ELSEIF ( nmtvr .ne. 14)
then
699 IF ( hprime(i) .GT. hpmin )
then
702 if (ipr .eq. i) npr = npt
705 IF (npt .eq. 0)
RETURN
729 cleff = 0.5e-5 / sqrt(float(imx)/192.0)
735 if (cdmbgwd(2) >= 0.0) cleff = cleff * cdmbgwd(2)
740 vtj(i,k) = t1(j,k) * (1.+fv*q1(j,k))
741 vtk(i,k) = vtj(i,k) / prslk(j,k)
742 ro(i,k) = rdi * prsl(j,k) / vtj(i,k)
749 ti = 2.0 / (t1(j,k)+t1(j,k+1))
750 tem = ti / (prsl(j,k)-prsl(j,k+1))
751 rdz = g / (phil(j,k+1) - phil(j,k))
752 tem1 = u1(j,k) - u1(j,k+1)
753 tem2 = v1(j,k) - v1(j,k+1)
754 dw2 = tem1*tem1 + tem2*tem2
755 shr2 = max(dw2,dw2min) * rdz * rdz
756 bvf2 = g*(gocp+rdz*(vtj(i,k+1)-vtj(i,k))) * ti
757 ri_n(i,k) = max(bvf2/shr2,rimin)
761 bnv2(i,k) = (g+g) * rdz * (vtk(i,k+1)-vtk(i,k))
762 & / (vtk(i,k+1)+vtk(i,k))
763 bnv2(i,k) = max( bnv2(i,k), bnv2min )
789 tem = (prsi(j,1) - prsi(j,k))
790 if (tem .lt. dpmin) iwk(i) = k
800 kref(i) = max(iwk(i), kpbl(j)+1 )
801 delks(i) = 1.0 / (prsi(j,1) - prsi(j,kref(i)))
802 delks1(i) = 1.0 / (prsl(j,1) - prsl(j,kref(i)))
806 kbps = max(kbps, kref(i))
807 kmps = min(kmps, kref(i))
809 bnv2bar(i) = (prsl(j,1)-prsl(j,2)) * delks1(i) * bnv2(i,1)
816 IF (k .LT. kref(i))
THEN
818 rdelks = del(j,k) * delks(i)
819 ubar(i) = ubar(i) + rdelks * u1(j,k)
820 vbar(i) = vbar(i) + rdelks * v1(j,k)
822 roll(i) = roll(i) + rdelks * ro(i,k)
823 rdelks = (prsl(j,k)-prsl(j,k+1)) * delks1(i)
824 bnv2bar(i) = bnv2bar(i) + bnv2(i,k) * rdelks
839 wdir = atan2(ubar(i),vbar(i)) + pi
840 idir = mod(nint(fdir*wdir),mdir) + 1
842 oa(i) = (1-2*int( (nwd-1)/4 )) * oa4(j,mod(nwd-1,4)+1)
843 clx(i) = clx4(j,mod(nwd-1,4)+1)
869 ulow(i) = max(sqrt(ubar(i)*ubar(i) + vbar(i)*vbar(i)), 1.0)
870 uloi(i) = 1.0 / ulow(i)
876 velco(i,k) = 0.5 * ((u1(j,k)+u1(j,k+1))*ubar(i)
877 & + (v1(j,k)+v1(j,k+1))*vbar(i))
878 velco(i,k) = velco(i,k) * uloi(i)
911 bnv = sqrt( bnv2bar(i) )
912 fr = bnv * uloi(i) * min(hprime(j),hpmax)
914 xn(i) = ubar(i) * uloi(i)
915 yn(i) = vbar(i) * uloi(i)
960 efact = (oa(i) + 2.) ** (ceofrc*fr)
961 efact = min( max(efact,efmin), efmax )
963 coefm = (1. + clx(i)) ** (oa(i)+1.)
965 xlinv(i) = coefm * cleff
967 tem = fr * fr * oc(j)
968 gfobnv = gmax * tem / ((tem + cg)*bnv)
970 taub(i) = xlinv(i) * roll(i) * ulow(i) * ulow(i)
971 & * ulow(i) * gfobnv * efact
976 k = max(1, kref(i)-1)
977 tem = max(velco(i,k)*velco(i,k), 0.1)
978 scor(i) = bnv2(i,k) / tem
986 IF (k .LE. kref(i)) taup(i,k) = taub(i)
1000 IF (k .GE. kref(i))
THEN
1001 icrilv(i) = icrilv(i) .OR. ( ri_n(i,k) .LT. ric)
1002 & .OR. (velco(i,k) .LE. 0.0)
1019 IF (k .GE. kref(i))
THEN
1020 IF (.NOT.icrilv(i) .AND. taup(i,k) .GT. 0.0 )
THEN
1021 temv = 1.0 / max(velco(i,k), 0.01)
1023 IF (oa(i).GT.0. .AND. kp1 .lt. kint(i))
THEN
1024 scork = bnv2(i,k) * temv * temv
1025 rscor = min(1.0, scork / scor(i))
1043 brvf = sqrt(bnv2(i,k))
1045 tem1 = xlinv(i)*(ro(i,kp1)+ro(i,k))*brvf*0.5
1046 & * max(velco(i,k),0.01)
1047 hd = sqrt(taup(i,k) / tem1)
1048 fro = brvf * hd * temv
1061 tem2 = sqrt(ri_n(i,k))
1062 tem = 1. + tem2 * fro
1063 rim = ri_n(i,k) * (1.-fro) / (tem * tem)
1084 IF (rim .LE. ric .AND.
1086 & (oa(i) .LE. 0. .OR. kp1 .ge. kint(i) ))
THEN
1087 temc = 2.0 + 1.0 / tem2
1088 hd = velco(i,k) * (2.*sqrt(temc)-temc) / brvf
1089 taup(i,kp1) = tem1 * hd * hd
1091 taup(i,kp1) = taup(i,k) * rscor
1093 taup(i,kp1) = min(taup(i,kp1), taup(i,k))
1103 IF(lcap .LE. km)
THEN
1104 DO klcap = lcapp1, km+1
1106 sira = prsi(ipt(i),klcap) / prsi(ipt(i),lcap)
1107 taup(i,klcap) = sira * taup(i,lcap)
1116 taud(i,k) = g * (taup(i,k+1) - taup(i,k)) / del(ipt(i),k)
1125 taud(i,klcap) = taud(i,klcap) * factop
1135 IF (k .GT. kref(i) .and. prsi(ipt(i),k) .GE. rlolev)
THEN
1136 IF(taud(i,k).NE.0.)
THEN
1137 tem = deltim * taud(i,k)
1138 dtfac(i) = min(dtfac(i),abs(velco(i,k)/tem))
1156 taud(i,k) = taud(i,k) * dtfac(i)
1157 dtaux = taud(i,k) * xn(i)
1158 dtauy = taud(i,k) * yn(i)
1159 eng0 = 0.5*(u1(j,k)*u1(j,k)+v1(j,k)*v1(j,k))
1161 if ( k .lt. idxzb(i) .AND. idxzb(i) .ne. 0 )
then
1162 dbim = db(i,k) / (1.+db(i,k)*deltim)
1163 a(j,k) = - dbim * v1(j,k) + a(j,k)
1164 b(j,k) = - dbim * u1(j,k) + b(j,k)
1165 eng1 = eng0*(1.0-dbim*deltim)*(1.0-dbim*deltim)
1169 dusfc(j) = dusfc(j) - dbim * v1(j,k) * del(j,k)
1170 dvsfc(j) = dvsfc(j) - dbim * u1(j,k) * del(j,k)
1173 a(j,k) = dtauy + a(j,k)
1174 b(j,k) = dtaux + b(j,k)
1176 & (u1(j,k)+dtaux*deltim)*(u1(j,k)+dtaux*deltim)
1177 & + (v1(j,k)+dtauy*deltim)*(v1(j,k)+dtauy*deltim))
1178 dusfc(j) = dusfc(j) + dtaux * del(j,k)
1179 dvsfc(j) = dvsfc(j) + dtauy * del(j,k)
1181 c(j,k) = c(j,k) + max(eng0-eng1,0.)/cp/deltim
1193 dusfc(j) = tem * dusfc(j)
1194 dvsfc(j) = tem * dvsfc(j)
subroutine gwdps(IM, IX, IY, KM, A, B, C, U1, V1, T1, Q1, KPBL, PRSI, DEL, PRSL, PRSLK, PHII, PHIL, DELTIM, KDT, HPRIME, OC, OA4, CLX4, THETA, SIGMA, GAMMA, ELVMAX, DUSFC, DVSFC, G, CP, RD, RV, IMX, nmtvr, cdmbgwd, me, lprnt, ipr)