85 subroutine gwdc(im,ix,iy,km,lat,u1,v1,t1,q1,deltim,
86 & pmid1,pint1,dpmid1,qmax,ktop,kbot,kcnv,cldf,
87 & grav,cp,rd,fv,pi,dlength,lprnt,ipr,fhour,
88 & utgwc,vtgwc,tauctx,taucty)
102 USE machine
, ONLY : kind_phys
128 integer im, ix, iy, km, lat, ipr
129 integer ktop(im),kbot(im),kcnv(im)
132 real(kind=kind_phys) grav,cp,rd,fv,fhour,deltim,pi
133 real(kind=kind_phys),
dimension(im) :: qmax &
135 real(kind=kind_phys),
dimension(im) :: cldf,dlength
136 real(kind=kind_phys),
dimension(ix,km) :: u1,v1,t1,q1, &
139 real(kind=kind_phys),
dimension(iy,km) :: utgwc,vtgwc
140 real(kind=kind_phys),
dimension(ix,km+1) :: pint1
197 integer i,ii,k,k1,kk,kb,ilev,npt,kcb,kcldm,npr
198 integer,
dimension(im) :: ipt
200 real(kind=kind_phys) tem, tem1, tem2, qtem, wtgwc, tauct, &
201 & windcltop, shear, nonlinct, nonlin, nonlins,&
202 & n2, dtdp, crit1, crit2, p1, p2, &
207 integer,
allocatable :: kcldtop(:),kcldbot(:)
208 logical,
allocatable :: do_gwc(:)
209 real(kind=kind_phys),
allocatable :: tauctxl(:), tauctyl(:),
210 & gwdcloc(:), break(:),
213 & cosphi(:), sinphi(:),
214 & xstress(:), ystress(:),
215 & ucltop(:), vcltop(:),
217 & dlen(:), gqmcldlen(:)
222 real(kind=kind_phys),
allocatable :: plnint(:,:), velco(:,:),
223 & taugwci(:,:), bruni(:,:),
224 & rhoi(:,:), basicui(:,:),
225 & ti(:,:), riloc(:,:),
226 & rimin(:,:), pint(:,:)
228 real(kind=kind_phys),
allocatable ::
230 & plnmid(:,:), taugw(:,:),
231 & utgwcl(:,:), vtgwcl(:,:),
232 & basicum(:,:), u(:,:),v(:,:),
234 & pmid(:,:), dpmid(:,:),
236 & brunm(:,:), rhom(:,:)
262 real(kind=kind_phys),
parameter ::
263 & c1=1.41, c2=-0.38, ricrit=0.25
264 &, n2min=1.e-32, zero=0.0, one=1.0
265 &, taumin=1.0e-20, tauctmax=-20.
267 &, qmin=1.0e-10, shmin=1.0e-20
268 &, rimax=1.0e+20, rimaxm=0.99e+20
269 &, rimaxp=1.01e+20, rilarge=0.9e+20
270 &, riminx=-1.0e+20, riminm=-1.01e+20
271 &, riminp=-0.99e+20, rismall=-0.9e+20
277 if (kcnv(i) /= 0 .and. qmax(i) > zero)
then 347 allocate (kcldtop(npt), kcldbot(npt), do_gwc(npt))
348 allocate (tauctxl(npt), tauctyl(npt), dtfac(npt),
349 & gwdcloc(npt), break(npt), cosphi(npt),
351 & sinphi(npt), xstress(npt), ystress(npt), wrk(npt),
352 & ucltop(npt), vcltop(npt),dlen(npt), gqmcldlen(npt))
357 allocate (plnint(npt,2:km+1),
358 & taugwci(npt,km+1), bruni(npt,km+1),
359 & rhoi(npt,km+1), basicui(npt,km+1),
360 & ti(npt,km+1), riloc(npt,km+1),
361 & rimin(npt,km+1), pint(npt,km+1))
366 & (plnmid(npt,km), velco(npt,km),
367 & utgwcl(npt,km), vtgwcl(npt,km),
368 & basicum(npt,km), u(npt,km), v(npt,km),
369 & t(npt,km), spfh(npt,km), pmid(npt,km),
370 & dpmid(npt,km), taugw(npt,km),
372 & brunm(npt,km), rhom(npt,km))
384 if (ipr == ipt(i))
then 398 spfh(i,k) = max(q1(ii,k1),qmin)
399 pmid(i,k) = pmid1(ii,k1)
400 dpmid(i,k) = dpmid1(ii,k1) * onebg
403 rhom(i,k) = pmid(i,k) / (rd*t(i,k)*(1.0+fv*spfh(i,k)))
404 plnmid(i,k) = log(pmid(i,k))
418 pint(i,k) = pint1(ii,k1)
430 plnint(i,k) = log(pint(i,k))
436 kcldtop(i) = km - ktop(ii) + 1
437 kcldbot(i) = km - kbot(ii) + 1
438 dlen(i) = dlength(ii)
440 gqmcldlen(i) = grav*qmax(ii)*cldf(ii)*dlen(i)
513 rhoi(i,1) = pint(i,1)/(rd*ti(i,1))
514 bruni(i,1) = sqrt( gsqr / (cp*ti(i,1)) )
521 rhoi(i,km+1) = pint(i,km+1)/(rd*ti(i,km+1)*(1.0+fv*spfh(i,km)))
522 bruni(i,km+1) = sqrt( gsqr / (cp*ti(i,km+1)) )
535 tem1 = (plnmid(i,k)-plnint(i,k)) / (plnmid(i,k)-plnmid(i,k-1))
537 ti(i,k) = t(i,k-1) * tem1 + t(i,k) * tem2
538 qtem = spfh(i,k-1) * tem1 + spfh(i,k) * tem2
539 rhoi(i,k) = pint(i,k) / ( rd * ti(i,k)*(1.0+fv*qtem) )
540 dtdp = (t(i,k)-t(i,k-1)) / (pmid(i,k)-pmid(i,k-1))
541 n2 = gsqr / ti(i,k) * ( 1./cp - rhoi(i,k)*dtdp )
542 bruni(i,k) = sqrt(max(n2min, n2))
555 dtdp = (ti(i,k+1)-ti(i,k)) / (pint(i,k+1)-pint(i,k))
556 n2 = gsqr / t(i,k) * ( 1./cp - rhom(i,k)*dtdp )
557 brunm(i,k) = sqrt(max(n2min, n2))
614 kcldm = max(kcldm,kk)
627 windcltop = 1.0 / sqrt( ucltop(i)*ucltop(i)
628 & + vcltop(i)*vcltop(i) )
629 cosphi(i) = ucltop(i)*windcltop
630 sinphi(i) = vcltop(i)*windcltop
648 basicum(i,k) = u(i,k)*cosphi(i) + v(i,k)*sinphi(i)
663 basicui(i,1) = basicum(i,1)
664 basicui(i,km+1) = basicum(i,km)
668 tem1 = (plnmid(i,k)-plnint(i,k)) / (plnmid(i,k)-plnmid(i,k-1))
670 basicui(i,k) = basicum(i,k)*tem2 + basicum(i,k-1)*tem1
704 shear = grav*rhoi(i,k) * (basicum(i,k) - basicum(i,k-1))
705 & / (pmid(i,k) - pmid(i,k-1))
706 if ( abs(shear) < shmin )
then 709 tem = bruni(i,k) / shear
710 riloc(i,k) = tem * tem
711 if (riloc(i,k) >= rimax ) riloc(i,k) = rilarge
717 riloc(i,1) = riloc(i,2)
718 riloc(i,km+1) = riloc(i,km)
832 if ( abs(basicui(i,kk)) > zero .and. riloc(i,kk) > ricrit)
then 836 nonlinct = gqmcldlen(i) / (bruni(i,kk)*t(i,kk)*tem1)
839 tauct = - rhom(i,kk) * tem * tem1 * c1 * tem2 * tem2
840 & / (bruni(i,kk)*dlen(i))
842 tauct = max(tauctmax, tauct)
843 tauctxl(i) = tauct * cosphi(i)
844 tauctyl(i) = tauct * sinphi(i)
845 taugwci(i,kk) = tauct
900 tem1 = (u(i,k)+u(i,k-1))*0.5
901 tem2 = (v(i,k)+v(i,k-1))*0.5
902 crit1 = ucltop(i)*tem1
903 crit2 = vcltop(i)*tem2
904 velco(i,k) = tem1 * cosphi(i) + tem2 * sinphi(i)
906 crit1 = ucltop(i)*u(i,1)
907 crit2 = vcltop(i)*v(i,1)
908 velco(i,1) = u(i,1) * cosphi(i) + v(i,1) * sinphi(i)
913 if ( abs(basicui(i,k)) > zero .and. crit1 > zero
914 & .and. crit2 > zero )
then 915 tem = basicui(i,k) * basicui(i,k)
916 nonlin = gqmcldlen(i) / (bruni(i,k)*ti(i,k)*tem)
918 if ( riloc(i,k) < rimaxm )
then 919 tem1 = 1 + tem*sqrt(riloc(i,k))
920 rimin(i,k) = riloc(i,k) * (1-tem) / (tem1*tem1)
921 else if((riloc(i,k) > rimaxm) .and.
922 & (riloc(i,k) < rimaxp))
then 923 rimin(i,k) = ( 1 - tem) / (tem*tem)
925 if ( rimin(i,k) <= riminx )
then 1007 if (k < kk .and. k > 1)
then 1008 if ( abs(taugwci(i,k+1)) > taumin )
then 1009 if ( riloc(i,k) > ricrit )
then 1010 if ( rimin(i,k) > ricrit )
then 1011 taugwci(i,k) = taugwci(i,k+1)
1012 elseif (rimin(i,k) > riminp)
then 1013 tem = 2.0 + 1.0 / sqrt(riloc(i,k))
1014 nonlins = (1.0/abs(c2)) * (2.*sqrt(tem) - tem)
1016 tem2 = c2*nonlins*tem1
1017 taugwci(i,k) = - rhoi(i,k) * c1 * tem1 * tem2 * tem2
1018 & / (bruni(i,k)*dlen(i))
1019 elseif (rimin(i,k) > riminm)
then 1035 if ( (basicum(i,k+1)*basicum(i,k) ) < 0. )
then 1036 taugwci(i,k+1) = zero
1040 if (abs(taugwci(i,k)) > abs(taugwci(i,k+1)))
then 1041 taugwci(i,k) = taugwci(i,k+1)
1044 elseif (k == 1)
then 1049 taugwci(i,1) = taugwci(i,2)
1072 taugw(i,k) = (taugwci(i,k+1) - taugwci(i,k)) / dpmid(i,k)
1073 if (taugw(i,k) /= 0.0)
then 1074 tem = deltim * taugw(i,k)
1075 dtfac(i) = min(dtfac(i), abs(velco(i,k)/tem))
1098 wtgwc = taugw(i,k) * dtfac(i)
1099 utgwcl(i,k) = wtgwc * cosphi(i)
1100 vtgwcl(i,k) = wtgwc * sinphi(i)
1129 xstress(i) = xstress(i) + utgwcl(i,k)*dpmid(i,k)
1130 ystress(i) = ystress(i) + vtgwcl(i,k)*dpmid(i,k)
1150 wrk(i) = 0.5 * pi / (pint(i,kcldbot(i)+1)-pint(i,kcldtop(i)))
1157 if (k >= kk .and. k <= kcldbot(i))
then 1158 p1 = sin(wrk(i) * (pint(i,k) -pint(i,kk)))
1159 p2 = sin(wrk(i) * (pint(i,k+1)-pint(i,kk)))
1160 tem = - (p2-p1) / dpmid(i,k)
1161 utgwcl(i,k) = tem*xstress(i)
1162 vtgwcl(i,k) = tem*ystress(i)
1315 utgwc(ii,k1) = utgwcl(i,k)
1317 vtgwc(ii,k1) = vtgwcl(i,k)
1330 tauctx(ii) = tauctxl(i)
1331 taucty(ii) = tauctyl(i)
1349 deallocate (kcldtop,kcldbot,do_gwc)
1350 deallocate (tauctxl, tauctyl, dtfac,
1352 & gwdcloc, break, cosphi,
1353 & sinphi, xstress, ystress,
1354 & dlen, ucltop, vcltop, gqmcldlen, wrk)
1356 deallocate (plnint, taugwci, velco,
1357 & bruni, rhoi, basicui,
1358 & ti, riloc, rimin, pint)
1360 deallocate (plnmid, utgwcl, vtgwcl, basicum, u, v, t,
1361 & pmid, dpmid, brunm, rhom, taugw)
subroutine gwdc(im, ix, iy, km, lat, u1, v1, t1, q1, deltim,