205 subroutine drag_suite_run( &
206 & IM,KM,dvdt,dudt,dtdt,U1,V1,T1,Q1,KPBL, &
207 & PRSI,DEL,PRSL,PRSLK,PHII,PHIL,DELTIM,KDT, &
209 & varss,oc1ss,oa4ss,ol4ss, &
210 & THETA,SIGMA,GAMMA,ELVMAX, &
211 & dtaux2d_ms,dtauy2d_ms,dtaux2d_bl,dtauy2d_bl, &
212 & dtaux2d_ss,dtauy2d_ss,dtaux2d_fd,dtauy2d_fd, &
214 & dusfc_ms,dvsfc_ms,dusfc_bl,dvsfc_bl, &
215 & dusfc_ss,dvsfc_ss,dusfc_fd,dvsfc_fd, &
217 & g, cp, rd, rv, fv, pi, imx, cdmbgwd, alpha_fd, &
218 & me, master, lprnt, ipr, rdxzb, dx, gwd_opt, &
219 & do_gsl_drag_ls_bl, do_gsl_drag_ss, do_gsl_drag_tofd, &
220 & dtend, dtidx, index_of_process_orographic_gwd, &
221 & index_of_temperature, index_of_x_wind, &
222 & index_of_y_wind, ldiag3d, ldiag_ugwp, ugwp_seq_update, &
223 & spp_wts_gwd, spp_gwd, errmsg, errflg)
317 USE machine ,
ONLY : kind_phys
321 integer,
intent(in) :: im, km, imx, kdt, ipr, me, master
322 integer,
intent(in) :: gwd_opt
323 logical,
intent(in) :: lprnt
324 integer,
intent(in) :: KPBL(:)
325 real(kind=kind_phys),
intent(in) :: deltim, g, cp, rd, rv, &
326 & cdmbgwd(:), alpha_fd
327 real(kind=kind_phys),
intent(inout),
optional :: dtend(:,:,:)
328 logical,
intent(in) :: ldiag3d
329 integer,
intent(in) :: dtidx(:,:), index_of_temperature, &
330 & index_of_process_orographic_gwd, index_of_x_wind, index_of_y_wind
333 integer,
parameter :: ims=1, kms=1, its=1, kts=1
334 real(kind=kind_phys),
intent(in) :: fv, pi
335 real(kind=kind_phys) :: rcl, cdmb
336 real(kind=kind_phys) :: g_inv, rd_inv
338 real(kind=kind_phys),
intent(inout) :: &
339 & dudt(:,:),dvdt(:,:), &
341 real(kind=kind_phys),
intent(inout) :: rdxzb(:)
342 real(kind=kind_phys),
intent(in) :: &
345 & phii(:,:),prsl(:,:), &
346 & prslk(:,:),phil(:,:)
347 real(kind=kind_phys),
intent(in) :: prsi(:,:), &
349 real(kind=kind_phys),
intent(in) :: var(:),oc1(:), &
350 & oa4(:,:),ol4(:,:), &
352 real(kind=kind_phys),
intent(in),
optional :: varss(:),oc1ss(:), &
353 & oa4ss(:,:),ol4ss(:,:)
354 real(kind=kind_phys),
intent(in) :: theta(:),sigma(:), &
358 real(kind=kind_phys),
dimension(im,km) :: utendwave,vtendwave,thx,thvx
359 real(kind=kind_phys),
intent(in) :: br1(:), &
362 real(kind=kind_phys),
dimension(im) :: govrth,xland
364 real(kind=kind_phys) :: tauwavex0,tauwavey0, &
365 & xnbv,density,tvcon,hpbl2
366 integer :: kpbl2,kvar
368 real(kind=kind_phys),
dimension(im,km) :: zl
371 real(kind=kind_phys),
dimension(im) :: var_stoch, varss_stoch, &
373 real(kind=kind_phys),
intent(in),
optional :: spp_wts_gwd(:,:)
374 integer,
intent(in) :: spp_gwd
376 real(kind=kind_phys),
dimension(im) :: rstoch
379 real(kind=kind_phys),
intent(inout) :: &
382 real(kind=kind_phys),
intent(inout),
optional :: &
383 & dusfc_ms(:),dvsfc_ms(:), &
384 & dusfc_bl(:),dvsfc_bl(:), &
385 & dusfc_ss(:),dvsfc_ss(:), &
386 & dusfc_fd(:),dvsfc_fd(:)
387 real(kind=kind_phys),
intent(inout),
optional :: &
388 & dtaux2d_ms(:,:),dtauy2d_ms(:,:), &
389 & dtaux2d_bl(:,:),dtauy2d_bl(:,:), &
390 & dtaux2d_ss(:,:),dtauy2d_ss(:,:), &
391 & dtaux2d_fd(:,:),dtauy2d_fd(:,:)
394 real(kind=kind_phys),
dimension(im,km) :: dtaux2d, dtauy2d
400 logical,
intent(in) :: &
406 logical,
intent(in) :: ldiag_ugwp
410 logical,
intent(in) :: ugwp_seq_update
414 real(kind=kind_phys),
dimension(im,km) :: uwnd1, vwnd1
415 real(kind=kind_phys) :: tmp1, tmp2
418 logical,
parameter :: &
419 gwd_opt_ms = .true., &
420 gwd_opt_bl = .true., &
421 gsd_diss_ht_opt = .false.
425 real(kind=kind_phys),
parameter :: dxmin_ss = 1000., &
428 real(kind=kind_phys),
parameter :: dxmin_ms = 3000., &
430 real(kind=kind_phys),
dimension(im) :: ss_taper, ls_taper
433 real(kind=kind_phys),
parameter :: varmax_ss = 50., &
436 real(kind=kind_phys) :: var_temp, var_temp2
439 real(kind=kind_phys),
dimension(im,km) :: utendform,vtendform
440 real(kind=kind_phys) :: a1,a2,wsp
441 real(kind=kind_phys) :: h_efold
442 real(kind=kind_phys),
parameter :: coeff_fd = 6.325e-3
445 real(kind=kind_phys),
parameter :: ric = 0.25
446 real(kind=kind_phys),
parameter :: dw2min = 1.
447 real(kind=kind_phys),
parameter :: rimin = -100.
448 real(kind=kind_phys),
parameter :: bnv2min = 1.0e-5
449 real(kind=kind_phys),
parameter :: efmin = 0.0
450 real(kind=kind_phys),
parameter :: efmax = 10.0
451 real(kind=kind_phys),
parameter :: xl = 4.0e4
452 real(kind=kind_phys),
parameter :: critac = 1.0e-5
453 real(kind=kind_phys),
parameter :: gmax = 1.
454 real(kind=kind_phys),
parameter :: veleps = 1.0
455 real(kind=kind_phys),
parameter :: factop = 0.5
456 real(kind=kind_phys),
parameter :: frc = 1.0
457 real(kind=kind_phys),
parameter :: ce = 0.8
458 real(kind=kind_phys),
parameter :: cg = 0.5
459 real(kind=kind_phys),
parameter :: sgmalolev = 0.5
460 real(kind=kind_phys),
parameter :: plolevmeso = 70.0
461 real(kind=kind_phys),
parameter :: facmeso = 0.5
462 integer,
parameter :: kpblmin = 2
467 integer :: i,j,k,lcap,lcapp1,nwd,idir, &
470 real(kind=kind_phys) :: rcs,csg,fdir,cleff,cleff_ss,cs, &
471 rcsks,wdir,ti,rdz,tem2,dw2,shr2, &
472 bvf2,rdelks,wtkbj,tem,gfobnv,hd,fro, &
473 rim,temc,tem1,efact,temv,dtaux,dtauy, &
474 dtauxb,dtauyb,eng0,eng1,ksmax,dtfac_meso
476 logical :: ldrag(im),icrilv(im), &
480 real(kind=kind_phys) :: onebgrcs
482 real(kind=kind_phys) :: taub(im),taup(im,km+1), &
489 roll(im),dtfac(im), &
490 brvf(im),xlinv(im), &
491 delks(im),delks1(im), &
492 bnv2(im,km),usqj(im,km), &
493 taud_ms(im,km),taud_bl(im,km), &
495 vtk(im,km),vtj(im,km), &
496 zlowtop(im),velco(im,km-1), &
497 coefm(im),coefm_ss(im)
499 integer :: kbl(im),klowtop(im)
500 integer,
parameter :: mdir=8
503 integer,
parameter :: nwdir(8) = (/6,7,5,8,2,3,1,4/)
507 real(kind=kind_phys),
parameter :: frmax = 10.
508 real(kind=kind_phys),
parameter :: olmin = 1.0e-5
509 real(kind=kind_phys),
parameter :: odmin = 0.1
510 real(kind=kind_phys),
parameter :: odmax = 10.
513 real(kind=kind_phys) :: cd
514 real(kind=kind_phys) :: zblk,tautem
515 real(kind=kind_phys) :: pe,ke
516 real(kind=kind_phys) :: delx,dely
517 real(kind=kind_phys) :: dxy4(im,4),dxy4p(im,4)
518 real(kind=kind_phys) :: dxy(im),dxyp(im)
519 real(kind=kind_phys) :: ol4p(4),olp(im),od(im)
520 real(kind=kind_phys) :: taufb(im,km+1)
522 character(len=*),
intent(out) :: errmsg
523 integer,
intent(out) :: errflg
525 integer :: udtend, vdtend, Tdtend
541 udtend = dtidx(index_of_x_wind,index_of_process_orographic_gwd)
542 vdtend = dtidx(index_of_y_wind,index_of_process_orographic_gwd)
543 tdtend = dtidx(index_of_temperature,index_of_process_orographic_gwd)
565 if (cdmbgwd(1) >= 0.0) cdmb = cdmb * cdmbgwd(1)
578 cleff = 0.5e-5 / sqrt(float(imx)/192.0)
584 if (cdmbgwd(2) >= 0.0) cleff = cleff * cdmbgwd(2)
597 fdir = mdir / (2.0*pi)
598 onebgrcs = 1._kind_phys/g*rcs
601 if (slmsk(i)==1. .or. slmsk(i)==2.)
then
610 if ( dx(i) .ge. dxmax_ms )
then
613 if ( dx(i) .le. dxmin_ms)
then
616 ls_taper(i) = 0.5 * ( sin(pi*(dx(i)-0.5*(dxmax_ms+dxmin_ms))/ &
617 (dxmax_ms-dxmin_ms)) + 1. )
626if ( spp_gwd==1 )
then
628 var_stoch(i) = var(i) + var(i)*0.75*spp_wts_gwd(i,1)
629 varss_stoch(i) = varss(i) + varss(i)*0.75*spp_wts_gwd(i,1)
630 varmax_fd_stoch(i) = varmax_fd + varmax_fd*0.75*spp_wts_gwd(i,1)
634 var_stoch(i) = var(i)
635 varss_stoch(i) = varss(i)
636 varmax_fd_stoch(i) = varmax_fd
647 dxy4(i,3) = sqrt(delx*delx + dely*dely)
648 dxy4(i,4) = dxy4(i,3)
649 dxy4p(i,1) = dxy4(i,2)
650 dxy4p(i,2) = dxy4(i,1)
651 dxy4p(i,3) = dxy4(i,4)
652 dxy4p(i,4) = dxy4(i,3)
703 taufb(1:im,1:km+1) = 0.0
709 vtj(i,k) = t1(i,k) * (1.+fv*q1(i,k))
710 vtk(i,k) = vtj(i,k) / prslk(i,k)
711 ro(i,k) = rd_inv * prsl(i,k) / vtj(i,k)
722 zl(i,k) = phil(i,k)*g_inv
729 zlowtop(i) = 2. * var_stoch(i)
738 if(kloop1(i).and.zl(i,k)-zl(i,1).ge.zlowtop(i))
then
746 kbl(i) = max(kpbl(i), klowtop(i))
747 kbl(i) = max(min(kbl(i),kpblmax),kpblmin)
753 komax(:) = klowtop(:) - 1
756 delks(i) = 1.0 / (prsi(i,1) - prsi(i,kbl(i)))
757 delks1(i) = 1.0 / (prsl(i,1) - prsl(i,kbl(i)))
764 if (k.lt.kbl(i))
then
765 rcsks = rcs * del(i,k) * delks(i)
766 rdelks = del(i,k) * delks(i)
767 ubar(i) = ubar(i) + rcsks * u1(i,k)
768 vbar(i) = vbar(i) + rcsks * v1(i,k)
769 roll(i) = roll(i) + rdelks * ro(i,k)
780 wdir = atan2(ubar(i),vbar(i)) + pi
781 idir = mod(nint(fdir*wdir),mdir) + 1
783 oa(i) = (1-2*int( (nwd-1)/4 )) * oa4(i,mod(nwd-1,4)+1)
784 ol(i) = ol4(i,mod(nwd-1,4)+1)
786 oass(i) = (1-2*int( (nwd-1)/4 )) * oa4ss(i,mod(nwd-1,4)+1)
787 olss(i) = ol4ss(i,mod(nwd-1,4)+1)
797 olp(i) = ol4p(mod(nwd-1,4)+1)
801 od(i) = olp(i)/max(ol(i),olmin)
802 od(i) = min(od(i),odmax)
803 od(i) = max(od(i),odmin)
807 dxy(i) = dxy4(i,mod(nwd-1,4)+1)
808 dxyp(i) = dxy4p(i,mod(nwd-1,4)+1)
814IF ( (do_gsl_drag_ls_bl).and. &
815 (gwd_opt_ms.or.gwd_opt_bl) )
then
821 if ( ls_taper(i).GT.1.e-02 )
then
827 ti = 2.0 / (t1(i,k)+t1(i,k+1))
828 rdz = 1./(zl(i,k+1) - zl(i,k))
829 tem1 = u1(i,k) - u1(i,k+1)
830 tem2 = v1(i,k) - v1(i,k+1)
831 dw2 = rcl*(tem1*tem1 + tem2*tem2)
832 shr2 = max(dw2,dw2min) * rdz * rdz
833 bvf2 = g*(g/cp+rdz*(vtj(i,k+1)-vtj(i,k))) * ti
834 usqj(i,k) = max(bvf2/shr2,rimin)
835 bnv2(i,k) = 2.0*g*rdz*(vtk(i,k+1)-vtk(i,k))/(vtk(i,k+1)+vtk(i,k))
836 bnv2(i,k) = max( bnv2(i,k), bnv2min )
841 ulow(i) = max(sqrt(ubar(i)*ubar(i) + vbar(i)*vbar(i)), 1.0)
842 rulow(i) = 1./ulow(i)
845 velco(i,k) = (0.5*rcs) * ((u1(i,k)+u1(i,k+1)) * ubar(i) &
846 + (v1(i,k)+v1(i,k+1)) * vbar(i))
847 velco(i,k) = velco(i,k) * rulow(i)
848 if ((velco(i,k).lt.veleps) .and. (velco(i,k).gt.0.))
then
855 ldrag(i) = velco(i,1).le.0.
859 do k = kpblmin,kpblmax
860 if (k .lt. kbl(i)) ldrag(i) = ldrag(i).or. velco(i,k).le.0.
866 if (k .lt. kbl(i)) ldrag(i) = ldrag(i).or. bnv2(i,k).lt.0.
874 wtkbj = (prsl(i,1)-prsl(i,2)) * delks1(i)
875 bnv2(i,1) = wtkbj * bnv2(i,1)
876 usqj(i,1) = wtkbj * usqj(i,1)
878 do k = kpblmin,kpblmax
879 if (k .lt. kbl(i))
then
880 rdelks = (prsl(i,k)-prsl(i,k+1)) * delks1(i)
881 bnv2(i,1) = bnv2(i,1) + bnv2(i,k) * rdelks
882 usqj(i,1) = usqj(i,1) + usqj(i,k) * rdelks
886 ldrag(i) = ldrag(i) .or. bnv2(i,1).le.0.0
887 ldrag(i) = ldrag(i) .or. ulow(i).eq.1.0
888 ldrag(i) = ldrag(i) .or. var_stoch(i) .le. 0.0
894 if ( bnv2(i,1).gt.0.0 )
then
895 ldrag(i) = ldrag(i) .or. sqrt(bnv2(i,1))*rulow(i).lt.ksmax
900 do k = kpblmin,kpblmax
901 if (k .lt. kbl(i)) usqj(i,k) = usqj(i,1)
904 if (.not.ldrag(i))
then
905 bnv(i) = sqrt( bnv2(i,1) )
906 fr(i) = bnv(i) * rulow(i) * 2. * var_stoch(i) * od(i)
907 fr(i) = min(fr(i),frmax)
908 xn(i) = ubar(i) * rulow(i)
909 yn(i) = vbar(i) * rulow(i)
917 if (.not. ldrag(i))
then
918 efact = (oa(i) + 2.) ** (ce*fr(i)/frc)
919 efact = min( max(efact,efmin), efmax )
924 coefm(i) = (1. + ol(i)) ** (oa(i)+1.)
926 xlinv(i) = coefm(i) * cleff
927 tem = fr(i) * fr(i) * oc1(i)
928 gfobnv = gmax * tem / ((tem + cg)*bnv(i))
929 if ( gwd_opt_ms )
then
930 taub(i) = xlinv(i) * roll(i) * ulow(i) * ulow(i) &
931 * ulow(i) * gfobnv * efact
953IF ( (do_gsl_drag_ls_bl).and.(gwd_opt_ms) )
THEN
957 if ( ls_taper(i).GT.1.e-02 )
then
962 if (k .le. kbl(i)) taup(i,k) = taub(i)
972 if (k .ge. kbl(i))
then
973 icrilv(i) = icrilv(i) .or. ( usqj(i,k) .lt. ric) &
974 .or. (velco(i,k) .le. 0.0)
975 brvf(i) = max(bnv2(i,k),bnv2min)
976 brvf(i) = sqrt(brvf(i))
979 if (k .ge. kbl(i) .and. (.not. ldrag(i)))
then
980 if (.not.icrilv(i) .and. taup(i,k) .gt. 0.0 )
then
981 temv = 1.0 / velco(i,k)
982 tem1 = coefm(i)/dxy(i)*(ro(i,kp1)+ro(i,k))*brvf(i)* &
984 hd = sqrt(taup(i,k) / tem1)
985 fro = brvf(i) * hd * temv
988 tem2 = sqrt(usqj(i,k))
989 tem = 1. + tem2 * fro
990 rim = usqj(i,k) * (1.-fro) / (tem * tem)
995 if (rim .le. ric)
then
996 if ((oa(i) .le. 0.).or.(kp1 .ge. kpblmin ))
then
997 temc = 2.0 + 1.0 / tem2
998 hd = velco(i,k) * (2.*sqrt(temc)-temc) / brvf(i)
999 taup(i,kp1) = tem1 * hd * hd
1002 taup(i,kp1) = taup(i,k)
1009 do klcap = lcapp1,km
1010 taup(i,klcap) = prsi(i,klcap) / prsi(i,lcap) * taup(i,lcap)
1022IF ( do_gsl_drag_ls_bl .and. gwd_opt_bl )
THEN
1026 if ( ls_taper(i).GT.1.e-02 )
then
1028 if (.not.ldrag(i))
then
1034 do k = km, kpblmin, -1
1035 if(kblk.eq.0 .and. k.le.komax(i))
then
1036 pe = pe + bnv2(i,k)*(zl(i,komax(i))-zl(i,k))* &
1038 ke = 0.5*((rcs*u1(i,k))**2.+(rcs*v1(i,k))**2.)
1044 kblk = min(kblk,kbl(i))
1045 zblk = zl(i,kblk)-zl(i,kts)
1046 rdxzb(i) = real(k,kind=kind_phys)
1054 cd = max(2.0-1.0/od(i),0.0)
1056 taufb(i,kts) = cdmb * 0.5 * roll(i) * coefm(i) / &
1057 max(dxmax_ms,dxy(i))**2 * cd * dxyp(i) * &
1058 olp(i) * zblk * ulow(i)**2
1059 tautem = taufb(i,kts)/float(kblk-kts)
1061 taufb(i,k) = taufb(i,k-1) - tautem
1077IF ( (do_gsl_drag_ls_bl) .and. &
1078 (gwd_opt_ms .OR. gwd_opt_bl) )
THEN
1082 if ( ls_taper(i) .GT. 1.e-02 )
then
1092 taup(i,km+1) = taup(i,km)
1094 taud_ms(i,k) = (taup(i,k+1) - taup(i,k)) * csg / del(i,k)
1095 taud_bl(i,k) = (taufb(i,k+1) - taufb(i,k)) * csg / del(i,k)
1105 do k = kts,kpblmax-1
1106 if (prsi(i,k).ge.sgmalolev*prsi(i,1))
then
1107 if ((taud_ms(i,k)+taud_bl(i,k)).ne.0.) &
1108 dtfac(i) = min(dtfac(i),abs(velco(i,k) &
1109 /(deltim*rcs*(taud_ms(i,k)+taud_bl(i,k)))))
1121 if (prsl(i,k).le.plolevmeso)
then
1122 if (taud_ms(i,k).ne.0.) &
1123 dtfac_meso = min(dtfac_meso,facmeso*abs(velco(i,k) &
1124 /(deltim*rcs*taud_ms(i,k))))
1127 taud_ms(i,k) = taud_ms(i,k)*dtfac(i)*dtfac_meso* &
1128 ls_taper(i) *(1.-rstoch(i))
1129 taud_bl(i,k) = taud_bl(i,k)*dtfac(i)* ls_taper(i) *(1.-rstoch(i))
1131 dtaux = taud_ms(i,k) * xn(i)
1132 dtauy = taud_ms(i,k) * yn(i)
1133 dtauxb = taud_bl(i,k) * xn(i)
1134 dtauyb = taud_bl(i,k) * yn(i)
1137 tmp1 = dtaux + dtauxb
1138 tmp2 = dtauy + dtauyb
1139 dudt(i,k) = tmp1 + dudt(i,k)
1140 dvdt(i,k) = tmp2 + dvdt(i,k)
1146 if ( ugwp_seq_update .and. (do_gsl_drag_ss.or.do_gsl_drag_tofd) )
then
1147 uwnd1(i,k) = uwnd1(i,k) + tmp1*deltim
1148 vwnd1(i,k) = vwnd1(i,k) + tmp2*deltim
1151 if ( gsd_diss_ht_opt )
then
1154 eng0 = 0.5*( (rcs*u1(i,k))**2. + (rcs*v1(i,k))**2. )
1156 eng1 = 0.5*( (rcs*(u1(i,k)+(dtaux+dtauxb)*deltim))**2 + &
1157 (rcs*(v1(i,k)+(dtauy+dtauyb)*deltim))**2 )
1159 dtdt(i,k) = dtdt(i,k) + max((eng0-eng1),0.0)/cp/deltim
1160 if ( tdtend>0 )
then
1161 dtend(i,k,tdtend) = dtend(i,k,tdtend) + max((eng0-eng1),0.0)/cp
1165 dusfc(i) = dusfc(i) - onebgrcs * ( taud_ms(i,k)*xn(i)*del(i,k) + &
1166 taud_bl(i,k)*xn(i)*del(i,k) )
1167 dvsfc(i) = dvsfc(i) - onebgrcs * ( taud_ms(i,k)*yn(i)*del(i,k) + &
1168 taud_bl(i,k)*yn(i)*del(i,k) )
1170 dtend(i,k,udtend) = dtend(i,k,udtend) + (taud_ms(i,k) * &
1171 xn(i) + taud_bl(i,k) * xn(i)) * deltim
1174 dtend(i,k,vdtend) = dtend(i,k,vdtend) + (taud_ms(i,k) * &
1175 yn(i) + taud_bl(i,k) * yn(i)) * deltim
1180 if ( ldiag_ugwp )
then
1182 dtaux2d_ms(i,k) = taud_ms(i,k) * xn(i)
1183 dtauy2d_ms(i,k) = taud_ms(i,k) * yn(i)
1184 dtaux2d_bl(i,k) = taud_bl(i,k) * xn(i)
1185 dtauy2d_bl(i,k) = taud_bl(i,k) * yn(i)
1186 dusfc_ms(i) = dusfc_ms(i) - onebgrcs * dtaux2d_ms(i,k) * del(i,k)
1187 dvsfc_ms(i) = dvsfc_ms(i) - onebgrcs * dtauy2d_ms(i,k) * del(i,k)
1188 dusfc_bl(i) = dusfc_bl(i) - onebgrcs * dtaux2d_bl(i,k) * del(i,k)
1189 dvsfc_bl(i) = dvsfc_bl(i) - onebgrcs * dtauy2d_bl(i,k) * del(i,k)
1210IF ( do_gsl_drag_ss )
THEN
1214 if ( ss_taper(i).GT.1.e-02 )
then
1219 thx(i,k) = t1(i,k)/prslk(i,k)
1223 tvcon = (1.+fv*q1(i,k))
1224 thvx(i,k) = thx(i,k)*tvcon
1231 do k=kts+1,max(kpbl(i),kts+1)
1233 IF (zl(i,k)>300.)
then
1235 IF (k == kpbl(i))
then
1243 if((xland(i)-1.5).le.0. .and. 2.*varss_stoch(i).le.hpbl(i))
then
1244 if(br1(i).gt.0. .and. thvx(i,kpbl2)-thvx(i,kts) > 0.)
then
1251 govrth(i)=g/(0.5*(thvx(i,kpbl2)+thvx(i,kts)))
1253 xnbv=sqrt(govrth(i)*(thvx(i,kpbl2)-thvx(i,kts))/hpbl2)
1257 if (uwnd1(i,kpbl2).eq.0.)
then
1259 elseif (abs(xnbv/uwnd1(i,kpbl2)).gt.xlinv(i))
then
1266 var_temp = varss_stoch(i)
1268 var_temp2 = 0.5*xnbv*xlinv(i)*(2.*var_temp)**2*ro(i,kvar)
1269 tauwavex0=var_temp2*uwnd1(i,kvar)/(1.+var_temp2*deltim)
1270 tauwavex0=tauwavex0*ss_taper(i)
1277 if (vwnd1(i,kpbl2).eq.0.)
then
1279 elseif (abs(xnbv/vwnd1(i,kpbl2)).gt.xlinv(i))
then
1286 var_temp = varss_stoch(i)
1288 var_temp2 = 0.5*xnbv*xlinv(i)*(2.*var_temp)**2*ro(i,kvar)
1289 tauwavey0=var_temp2*vwnd1(i,kvar)/(1.+var_temp2*deltim)
1290 tauwavey0=tauwavey0*ss_taper(i)
1300 utendwave(i,k)=-1.*tauwavex0*2.*max((1.-zl(i,k)/hpbl2),0.)/hpbl2
1301 vtendwave(i,k)=-1.*tauwavey0*2.*max((1.-zl(i,k)/hpbl2),0.)/hpbl2
1310 dudt(i,k) = dudt(i,k) + utendwave(i,k)
1311 dvdt(i,k) = dvdt(i,k) + vtendwave(i,k)
1312 dusfc(i) = dusfc(i) - onebgrcs * utendwave(i,k) * del(i,k)
1313 dvsfc(i) = dvsfc(i) - onebgrcs * vtendwave(i,k) * del(i,k)
1316 dtend(i,kts:km,udtend) = dtend(i,kts:km,udtend) + utendwave(i,kts:km)*deltim
1319 dtend(i,kts:km,vdtend) = dtend(i,kts:km,vdtend) + vtendwave(i,kts:km)*deltim
1321 if ( ldiag_ugwp )
then
1323 dusfc_ss(i) = dusfc_ss(i) + utendwave(i,k) * del(i,k)
1324 dvsfc_ss(i) = dvsfc_ss(i) + vtendwave(i,k) * del(i,k)
1325 dtaux2d_ss(i,k) = utendwave(i,k)
1326 dtauy2d_ss(i,k) = vtendwave(i,k)
1340IF ( do_gsl_drag_tofd )
THEN
1344 if ( ss_taper(i).GT.1.e-02 )
then
1349 IF ((xland(i)-1.5) .le. 0.)
then
1351 var_temp = min(varss_stoch(i),varmax_fd_stoch(i)) + &
1352 max(0.,beta_fd*(varss_stoch(i)-varmax_fd_stoch(i)))
1353 a1=0.00026615161*var_temp**2
1361 wsp=sqrt(uwnd1(i,k)**2 + vwnd1(i,k)**2)
1365 var_temp = alpha_fd*coeff_fd*exp(-(zl(i,k)/h_efold)**1.5)*a2* &
1366 zl(i,k)**(-1.2)*ss_taper(i)
1369 utendform(i,k) = - var_temp*wsp*uwnd1(i,k)/(1. + var_temp*deltim*wsp)
1370 vtendform(i,k) = - var_temp*wsp*vwnd1(i,k)/(1. + var_temp*deltim*wsp)
1376 dudt(i,k) = dudt(i,k) + utendform(i,k)
1377 dvdt(i,k) = dvdt(i,k) + vtendform(i,k)
1378 dusfc(i) = dusfc(i) - onebgrcs * utendform(i,k) * del(i,k)
1379 dvsfc(i) = dvsfc(i) - onebgrcs * vtendform(i,k) * del(i,k)
1382 dtend(i,kts:km,udtend) = dtend(i,kts:km,udtend) + utendform(i,kts:km)*deltim
1385 dtend(i,kts:km,vdtend) = dtend(i,kts:km,vdtend) + vtendform(i,kts:km)*deltim
1387 if ( ldiag_ugwp )
then
1389 dtaux2d_fd(i,k) = utendform(i,k)
1390 dtauy2d_fd(i,k) = vtendform(i,k)
1391 dusfc_fd(i) = dusfc_fd(i) + utendform(i,k) * del(i,k)
1392 dvsfc_fd(i) = dvsfc_fd(i) + vtendform(i,k) * del(i,k)
1404if ( ldiag_ugwp )
then
1406 dusfc_ss(:) = -onebgrcs * dusfc_ss(:)
1407 dvsfc_ss(:) = -onebgrcs * dvsfc_ss(:)
1408 dusfc_fd(:) = -onebgrcs * dusfc_fd(:)
1409 dvsfc_fd(:) = -onebgrcs * dvsfc_fd(:)
1416 subroutine drag_suite_psl( &
1417 & IM,KM,dvdt,dudt,dtdt,U1,V1,T1,Q1,KPBL, &
1418 & PRSI,DEL,PRSL,PRSLK,PHII,PHIL,DELTIM,KDT, &
1419 & var,oc1,oa4,ol4, &
1420 & varss,oc1ss,oa4ss,ol4ss, &
1421 & THETA,SIGMA,GAMMA,ELVMAX, &
1422 & dtaux2d_ls,dtauy2d_ls,dtaux2d_bl,dtauy2d_bl, &
1423 & dtaux2d_ss,dtauy2d_ss,dtaux2d_fd,dtauy2d_fd, &
1425 & dusfc_ls,dvsfc_ls,dusfc_bl,dvsfc_bl, &
1426 & dusfc_ss,dvsfc_ss,dusfc_fd,dvsfc_fd, &
1427 & slmsk,br1,hpbl,vtype, &
1428 & g, cp, rd, rv, fv, pi, imx, cdmbgwd, alpha_fd, &
1429 & me, master, lprnt, ipr, rdxzb, dx, gwd_opt, &
1430 & do_gsl_drag_ls_bl, do_gsl_drag_ss, do_gsl_drag_tofd, &
1431 & psl_gwd_dx_factor, &
1432 & dtend, dtidx, index_of_process_orographic_gwd, &
1433 & index_of_temperature, index_of_x_wind, &
1434 & index_of_y_wind, ldiag3d, ldiag_ugwp, ugwp_seq_update, &
1435 & spp_wts_gwd, spp_gwd, errmsg, errflg)
1530 USE machine ,
ONLY : kind_phys
1534 integer,
intent(in) :: im, km, imx, kdt, ipr, me, master
1535 integer,
intent(in) :: gwd_opt
1536 logical,
intent(in) :: lprnt
1537 integer,
intent(in) :: KPBL(:)
1538 real(kind=kind_phys),
intent(in) :: deltim, g, cp, rd, rv, &
1539 & cdmbgwd(:), alpha_fd
1540 real(kind=kind_phys),
intent(inout),
optional :: dtend(:,:,:)
1541 logical,
intent(in) :: ldiag3d
1542 integer,
intent(in) :: dtidx(:,:), index_of_temperature, &
1543 & index_of_process_orographic_gwd, index_of_x_wind, index_of_y_wind
1546 integer,
parameter :: ims=1, kms=1, its=1, kts=1
1547 real(kind=kind_phys),
intent(in) :: fv, pi
1548 real(kind=kind_phys) :: rcl, cdmb
1549 real(kind=kind_phys) :: g_inv, g_cp, rd_inv
1551 real(kind=kind_phys),
intent(inout) :: &
1552 & dudt(:,:),dvdt(:,:), &
1554 real(kind=kind_phys),
intent(out) :: rdxzb(:)
1555 real(kind=kind_phys),
intent(in) :: &
1556 & u1(:,:),v1(:,:), &
1557 & t1(:,:),q1(:,:), &
1558 & phii(:,:),prsl(:,:), &
1559 & prslk(:,:),phil(:,:)
1560 real(kind=kind_phys),
intent(in) :: prsi(:,:), &
1562 real(kind=kind_phys),
intent(in) :: var(:),oc1(:), &
1563 & oa4(:,:),ol4(:,:), &
1565 real(kind=kind_phys),
intent(in),
optional :: varss(:),oc1ss(:), &
1566 & oa4ss(:,:),ol4ss(:,:)
1567 real(kind=kind_phys),
intent(in) :: theta(:),sigma(:), &
1568 & gamma(:),elvmax(:)
1571 real(kind=kind_phys),
dimension(im,km) :: utendwave,vtendwave,thx,thvx
1572 integer,
intent(in) :: vtype(:)
1573 real(kind=kind_phys),
intent(in) :: br1(:), &
1576 real(kind=kind_phys),
dimension(im) :: govrth,xland
1578 real(kind=kind_phys) :: tauwavex0,tauwavey0, &
1579 & xnbv,density,tvcon,hpbl2
1580 integer :: kpbl2,kvar
1582 real(kind=kind_phys),
dimension(im,km) :: zl
1585 real(kind=kind_phys),
dimension(im) :: var_stoch, varss_stoch, &
1586 varmax_ss_stoch, varmax_fd_stoch
1587 real(kind=kind_phys),
intent(in),
optional :: spp_wts_gwd(:,:)
1588 integer,
intent(in) :: spp_gwd
1590 real(kind=kind_phys),
dimension(im) :: rstoch
1593 real(kind=kind_phys),
intent(out) :: &
1594 & dusfc(:), dvsfc(:)
1596 real(kind=kind_phys),
intent(out),
optional :: &
1597 & dusfc_ls(:),dvsfc_ls(:), &
1598 & dusfc_bl(:),dvsfc_bl(:), &
1599 & dusfc_ss(:),dvsfc_ss(:), &
1600 & dusfc_fd(:),dvsfc_fd(:)
1601 real(kind=kind_phys),
intent(out),
optional :: &
1602 & dtaux2d_ls(:,:),dtauy2d_ls(:,:), &
1603 & dtaux2d_bl(:,:),dtauy2d_bl(:,:), &
1604 & dtaux2d_ss(:,:),dtauy2d_ss(:,:), &
1605 & dtaux2d_fd(:,:),dtauy2d_fd(:,:)
1608 real(kind=kind_phys),
dimension(im,km) :: dtaux2d, dtauy2d
1614 logical,
intent(in) :: &
1615 do_gsl_drag_ls_bl, &
1619 logical,
intent(in) :: ldiag_ugwp
1623 logical,
intent(in) :: ugwp_seq_update
1626 integer,
parameter :: &
1633 real(kind=kind_phys),
parameter :: dxmin_ss = 1000., &
1636 real(kind=kind_phys),
parameter :: dxmin_ls = 3000., &
1638 real(kind=kind_phys),
dimension(im) :: ss_taper, ls_taper
1641 real(kind=kind_phys),
parameter :: varmax_ss = 50., &
1645 real(kind=kind_phys) :: var_temp, var_temp2
1648 real(kind=kind_phys),
dimension(im,km) :: utendform,vtendform
1649 real(kind=kind_phys) :: a1,a2,wsp
1650 real(kind=kind_phys) :: h_efold
1651 real(kind=kind_phys),
parameter :: coeff_fd = 6.325e-3
1655 real(kind=kind_phys),
intent(in) :: psl_gwd_dx_factor
1658 real(kind=kind_phys),
parameter :: ric = 0.25
1659 real(kind=kind_phys),
parameter :: dw2min = 1.
1660 real(kind=kind_phys),
parameter :: rimin = -100.
1661 real(kind=kind_phys),
parameter :: bnv2min = 1.0e-5
1662 real(kind=kind_phys),
parameter :: efmin = 0.0
1663 real(kind=kind_phys),
parameter :: efmax = 10.0
1664 real(kind=kind_phys),
parameter :: xl = 4.0e4
1665 real(kind=kind_phys),
parameter :: critac = 1.0e-5
1666 real(kind=kind_phys),
parameter :: gmax = 1.
1667 real(kind=kind_phys),
parameter :: veleps = 1.0
1668 real(kind=kind_phys),
parameter :: factop = 0.5
1669 real(kind=kind_phys),
parameter :: frc = 1.0
1670 real(kind=kind_phys),
parameter :: ce = 0.8
1671 real(kind=kind_phys),
parameter :: cg = 1.0
1673 real(kind=kind_phys),
parameter :: var_min = 10.0
1674 real(kind=kind_phys),
parameter :: hmt_min = 50.
1675 real(kind=kind_phys),
parameter :: oc_min = 1.0
1676 real(kind=kind_phys),
parameter :: oc_max = 10.0
1678 real(kind=kind_phys),
parameter :: pcutoff = 7.5e2
1680 real(kind=kind_phys),
parameter :: pcutoff_den = 0.01
1682 integer,
parameter :: kpblmin = 2
1687 integer :: i,j,k,lcap,lcapp1,nwd,idir, &
1690 real(kind=kind_phys) :: rcs,csg,fdir,cs, &
1691 rcsks,wdir,ti,rdz,tem2,dw2,shr2, &
1692 bvf2,rdelks,wtkbj,tem,gfobnv,hd,fro, &
1693 rim,temc,tem1,efact,temv,dtaux,dtauy, &
1694 dtauxb,dtauyb,eng0,eng1
1695 real(kind=kind_phys) :: denfac
1697 logical :: ldrag(im),icrilv(im), &
1700 real(kind=kind_phys) :: invgrcs
1702 real(kind=kind_phys) :: taub(im),taup(im,km+1), &
1704 ubar(im),vbar(im), &
1706 rulow(im),bnv(im), &
1707 oa(im),ol(im),oc(im), &
1708 oass(im),olss(im), &
1709 roll(im),dtfac(im,km), &
1710 brvf(im),xlinv(im), &
1711 delks(im),delks1(im), &
1712 bnv2(im,km),usqj(im,km), &
1713 taud_ls(im,km),taud_bl(im,km), &
1715 vtk(im,km),vtj(im,km), &
1716 zlowtop(im),velco(im,km-1), &
1717 coefm(im),coefm_ss(im)
1718 real(kind=kind_phys) :: cleff(im),cleff_ss(im)
1720 integer :: kbl(im),klowtop(im)
1721 integer,
parameter :: mdir=8
1724 integer,
parameter :: nwdir(8) = (/6,7,5,8,2,3,1,4/)
1728 real(kind=kind_phys),
parameter :: frmax = 10.
1729 real(kind=kind_phys),
parameter :: olmin = 1.e-5
1730 real(kind=kind_phys),
parameter :: odmin = 0.1
1731 real(kind=kind_phys),
parameter :: odmax = 10.
1732 real(kind=kind_phys),
parameter :: cdmin = 0.0
1733 integer :: komax(im),kbmax(im),kblk(im)
1734 real(kind=kind_phys) :: hmax(im)
1735 real(kind=kind_phys) :: cd
1736 real(kind=kind_phys) :: zblk,tautem
1737 real(kind=kind_phys) :: pe,ke
1738 real(kind=kind_phys) :: delx,dely
1739 real(kind=kind_phys) :: dxy4(im,4),dxy4p(im,4)
1740 real(kind=kind_phys) :: dxy(im),dxyp(im)
1741 real(kind=kind_phys) :: ol4p(4),olp(im),od(im)
1742 real(kind=kind_phys) :: taufb(im,km+1)
1744 character(len=*),
intent(out) :: errmsg
1745 integer,
intent(out) :: errflg
1747 integer :: udtend, vdtend, Tdtend
1763 udtend = dtidx(index_of_x_wind,index_of_process_orographic_gwd)
1764 vdtend = dtidx(index_of_y_wind,index_of_process_orographic_gwd)
1765 tdtend = dtidx(index_of_temperature,index_of_process_orographic_gwd)
1776 fdir = mdir / (2.0*pi)
1777 invgrcs = 1._kind_phys/g*rcs
1782 if (slmsk(i)==1. .or. slmsk(i)==2.)
then
1792 if ( dx(i) .ge. dxmax_ls )
then
1795 if ( dx(i) .le. dxmin_ls)
then
1798 ls_taper(i) = 0.5 * ( sin(pi*(dx(i)-0.5*(dxmax_ls+dxmin_ls))/ &
1799 (dxmax_ls-dxmin_ls)) + 1. )
1808 if ( spp_gwd==1 )
then
1810 var_stoch(i) = var(i) + var(i)*0.75*spp_wts_gwd(i,1)
1811 varss_stoch(i) = varss(i) + varss(i)*0.75*spp_wts_gwd(i,1)
1812 varmax_ss_stoch(i) = varmax_ss + varmax_ss*0.75*spp_wts_gwd(i,1)
1813 varmax_fd_stoch(i) = varmax_fd + varmax_fd*0.75*spp_wts_gwd(i,1)
1817 var_stoch(i) = var(i)
1818 varss_stoch(i) = varss(i)
1819 varmax_ss_stoch(i) = varmax_ss
1820 varmax_fd_stoch(i) = varmax_fd
1831 dxy4(i,3) = sqrt(delx*delx + dely*dely)
1832 dxy4(i,4) = dxy4(i,3)
1833 dxy4p(i,1) = dxy4(i,2)
1834 dxy4p(i,2) = dxy4(i,1)
1835 dxy4p(i,3) = dxy4(i,4)
1836 dxy4p(i,4) = dxy4(i,3)
1837 cleff(i) = psl_gwd_dx_factor*(delx+dely)*0.5
1838 cleff_ss(i) = 0.1 * max(dxmax_ss,dxy4(i,3))
1884 if ( ldiag_ugwp )
then
1897 dtaux2d_ls(i,k)= 0.0
1898 dtauy2d_ls(i,k)= 0.0
1899 dtaux2d_bl(i,k)= 0.0
1900 dtauy2d_bl(i,k)= 0.0
1901 dtaux2d_ss(i,k)= 0.0
1902 dtauy2d_ss(i,k)= 0.0
1903 dtaux2d_fd(i,k)= 0.0
1904 dtauy2d_fd(i,k)= 0.0
1918 taufb(1:im,1:km+1) = 0.0
1927 vtj(i,k) = t1(i,k) * (1.+fv*q1(i,k))
1928 vtk(i,k) = vtj(i,k) / prslk(i,k)
1929 ro(i,k) = rd_inv * prsl(i,k) / vtj(i,k)
1940 zl(i,k) = phil(i,k)*g_inv
1947 if(vtype(i)==15)
then
1948 zlowtop(i) = 1.0 * var_stoch(i)
1950 zlowtop(i) = 2.0 * var_stoch(i)
1960 if(flag(i).and.zl(i,k).ge.zlowtop(i))
then
1977 if(flag(i).and.zl(i,k).ge.elvmax(i))
then
1992 if(flag(i).and.zl(i,k).ge.elvmax(i)+zlowtop(i))
then
2002 hmax(i) = max(elvmax(i),zlowtop(i))
2007 kbl(i) = max(komax(i), klowtop(i))
2008 kbl(i) = max(min(kbl(i),kpblmax),kpblmin)
2014 delks(i) = 1.0 / (prsi(i,1) - prsi(i,kbl(i)))
2015 delks1(i) = 1.0 / (prsl(i,1) - prsl(i,kbl(i)))
2019 if (k.lt.kbl(i))
then
2020 rcsks = rcs * del(i,k) * delks(i)
2021 rdelks = del(i,k) * delks(i)
2022 ubar(i) = ubar(i) + rcsks * u1(i,k)
2023 vbar(i) = vbar(i) + rcsks * v1(i,k)
2024 roll(i) = roll(i) + rdelks * ro(i,k)
2035 wdir = atan2(ubar(i),vbar(i)) + pi
2036 idir = mod(nint(fdir*wdir),mdir) + 1
2038 oa(i) = (1-2*int( (nwd-1)/4 )) * oa4(i,mod(nwd-1,4)+1)
2039 ol(i) = max(ol4(i,mod(nwd-1,4)+1),olmin)
2040 oc(i) = min(max(oc1(i),oc_min),oc_max)
2045 oass(i) = (1-2*int( (nwd-1)/4 )) * oa4ss(i,mod(nwd-1,4)+1)
2046 olss(i) = ol4ss(i,mod(nwd-1,4)+1)
2056 olp(i) = max(ol4p(mod(nwd-1,4)+1),olmin)
2060 od(i) = olp(i)/ol(i)
2061 od(i) = min(od(i),odmax)
2062 od(i) = max(od(i),odmin)
2066 dxy(i) = dxy4(i,mod(nwd-1,4)+1)
2067 dxyp(i) = dxy4p(i,mod(nwd-1,4)+1)
2072IF ( (do_gsl_drag_ls_bl).and. &
2073 ((gwd_opt_ls .EQ. 1).or.(gwd_opt_bl .EQ. 1)) )
then
2078 if ( ls_taper(i).GT.1.e-02 )
then
2084 ti = 2.0 / (t1(i,k)+t1(i,k+1))
2085 rdz = 1./(zl(i,k+1) - zl(i,k))
2086 tem1 = u1(i,k) - u1(i,k+1)
2087 tem2 = v1(i,k) - v1(i,k+1)
2088 dw2 = rcl*(tem1*tem1 + tem2*tem2)
2089 shr2 = max(dw2,dw2min) * rdz * rdz
2090 bvf2 = g*(g_cp+rdz*(vtj(i,k+1)-vtj(i,k))) * ti
2091 usqj(i,k) = max(bvf2/shr2,rimin)
2092 bnv2(i,k) = 2.0*g*rdz*(vtk(i,k+1)-vtk(i,k))/(vtk(i,k+1)+vtk(i,k))
2093 bnv2(i,k) = max( bnv2(i,k), bnv2min )
2098 ulow(i) = max(sqrt(ubar(i)*ubar(i) + vbar(i)*vbar(i)), 1.0)
2099 rulow(i) = 1./ulow(i)
2102 velco(i,k) = (0.5*rcs) * ((u1(i,k)+u1(i,k+1)) * ubar(i) &
2103 + (v1(i,k)+v1(i,k+1)) * vbar(i))
2104 velco(i,k) = velco(i,k) * rulow(i)
2105 if ((velco(i,k).lt.veleps) .and. (velco(i,k).gt.0.))
then
2112 ldrag(i) = hmax(i).le.hmt_min
2116 ldrag(i) = ldrag(i).or. velco(i,1).le.0.
2120 do k = kpblmin,kpblmax
2121 if (k .lt. kbl(i)) ldrag(i) = ldrag(i).or. velco(i,k).le.0.
2127 if (k .lt. kbl(i)) ldrag(i) = ldrag(i).or. bnv2(i,k).lt.0.
2135 wtkbj = (prsl(i,1)-prsl(i,2)) * delks1(i)
2136 bnv2(i,1) = wtkbj * bnv2(i,1)
2137 usqj(i,1) = wtkbj * usqj(i,1)
2139 do k = kpblmin,kpblmax
2140 if (k .lt. kbl(i))
then
2141 rdelks = (prsl(i,k)-prsl(i,k+1)) * delks1(i)
2142 bnv2(i,1) = bnv2(i,1) + bnv2(i,k) * rdelks
2143 usqj(i,1) = usqj(i,1) + usqj(i,k) * rdelks
2147 ldrag(i) = ldrag(i) .or. bnv2(i,1).le.0.0
2148 ldrag(i) = ldrag(i) .or. ulow(i).eq.1.0
2149 ldrag(i) = ldrag(i) .or. var_stoch(i) .le. 0.0
2150 ldrag(i) = ldrag(i) .or. xland(i) .gt. 1.5
2154 do k = kpblmin,kpblmax
2155 if (k .lt. kbl(i)) usqj(i,k) = usqj(i,1)
2158 if (.not.ldrag(i))
then
2159 bnv(i) = sqrt( bnv2(i,1) )
2160 fr(i) = bnv(i) * rulow(i) * 2. * var_stoch(i) * od(i)
2161 fr(i) = min(fr(i),frmax)
2162 xn(i) = ubar(i) * rulow(i)
2163 yn(i) = vbar(i) * rulow(i)
2171 if (.not. ldrag(i))
then
2172 efact = (oa(i) + 2.) ** (ce*fr(i)/frc)
2173 efact = min( max(efact,efmin), efmax )
2174 coefm(i) = (1. + ol(i)) ** (oa(i)+1.)
2175 xlinv(i) = coefm(i) / cleff(i)
2176 tem = fr(i) * fr(i) * oc(i)
2177 gfobnv = gmax * tem / ((tem + cg)*bnv(i))
2178 if ( gwd_opt_ls .NE. 0 )
then
2179 taub(i) = xlinv(i) * roll(i) * ulow(i) * ulow(i) &
2180 * ulow(i) * gfobnv * efact
2206IF ( do_gsl_drag_ss )
THEN
2210 if ( ss_taper(i).GT.1.e-02 )
then
2215 thx(i,k) = t1(i,k)/prslk(i,k)
2219 tvcon = (1.+fv*q1(i,k))
2220 thvx(i,k) = thx(i,k)*tvcon
2227 do k=kts+1,max(kpbl(i),kts+1)
2229 IF (zl(i,k)>300.)
then
2231 IF (k == kpbl(i))
then
2239 if((xland(i)-1.5).le.0. .and. 2.*varss_stoch(i).le.hpbl(i))
then
2240 if(br1(i).gt.0. .and. thvx(i,kpbl2)-thvx(i,kts) > 0.)
then
2241 coefm_ss(i) = (1. + olss(i)) ** (oass(i)+1.)
2242 xlinv(i) = coefm_ss(i) / cleff_ss(i)
2244 govrth(i)=g/(0.5*(thvx(i,kpbl2)+thvx(i,kts)))
2246 xnbv=sqrt(govrth(i)*(thvx(i,kpbl2)-thvx(i,kts))/hpbl2)
2249 if(abs(xnbv/u1(i,kpbl2)).gt.xlinv(i))
then
2254 var_temp = varss_stoch(i)
2256 var_temp2 = 0.5*xnbv*xlinv(i)*(2.*var_temp)**2*ro(i,kvar)
2257 tauwavex0=var_temp2*u1(i,kvar)/(1.+var_temp2*deltim)
2258 tauwavex0=tauwavex0*ss_taper(i)
2264 if(abs(xnbv/v1(i,kpbl2)).gt.xlinv(i))
then
2269 var_temp = varss_stoch(i)
2271 var_temp2 = 0.5*xnbv*xlinv(i)*(2.*var_temp)**2*ro(i,kvar)
2272 tauwavey0=var_temp2*v1(i,kvar)/(1.+var_temp2*deltim)
2273 tauwavey0=tauwavey0*ss_taper(i)
2283 utendwave(i,k)=-1.*tauwavex0*2.*max((1.-zl(i,k)/hpbl2),0.)/hpbl2
2284 vtendwave(i,k)=-1.*tauwavey0*2.*max((1.-zl(i,k)/hpbl2),0.)/hpbl2
2293 dudt(i,k) = dudt(i,k) + utendwave(i,k)
2294 dvdt(i,k) = dvdt(i,k) + vtendwave(i,k)
2295 dusfc(i) = dusfc(i) + utendwave(i,k) * del(i,k)
2296 dvsfc(i) = dvsfc(i) + vtendwave(i,k) * del(i,k)
2299 dtend(i,kts:km,udtend) = dtend(i,kts:km,udtend) + utendwave(i,kts:km)*deltim
2302 dtend(i,kts:km,vdtend) = dtend(i,kts:km,vdtend) + vtendwave(i,kts:km)*deltim
2304 if ( ldiag_ugwp )
then
2306 dusfc_ss(i) = dusfc_ss(i) + utendwave(i,k) * del(i,k)
2307 dvsfc_ss(i) = dvsfc_ss(i) + vtendwave(i,k) * del(i,k)
2308 dtaux2d_ss(i,k) = utendwave(i,k)
2309 dtauy2d_ss(i,k) = vtendwave(i,k)
2322IF ( do_gsl_drag_tofd )
THEN
2326 if ( ss_taper(i).GT.1.e-02 )
then
2331 IF ((xland(i)-1.5) .le. 0.)
then
2334 var_temp = varss_stoch(i)
2336 a1=0.00026615161*var_temp**2
2344 wsp=sqrt(u1(i,k)**2 + v1(i,k)**2)
2348 var_temp = alpha_fd*coeff_fd*exp(-(zl(i,k)/h_efold)**1.5)*a2* &
2349 zl(i,k)**(-1.2)*ss_taper(i)
2352 utendform(i,k) = - var_temp*wsp*u1(i,k)/(1. + var_temp*deltim*wsp)
2353 vtendform(i,k) = - var_temp*wsp*v1(i,k)/(1. + var_temp*deltim*wsp)
2359 dudt(i,k) = dudt(i,k) + utendform(i,k)
2360 dvdt(i,k) = dvdt(i,k) + vtendform(i,k)
2361 dusfc(i) = dusfc(i) + utendform(i,k) * del(i,k)
2362 dvsfc(i) = dvsfc(i) + vtendform(i,k) * del(i,k)
2365 dtend(i,kts:km,udtend) = dtend(i,kts:km,udtend) + utendform(i,kts:km)*deltim
2368 dtend(i,kts:km,vdtend) = dtend(i,kts:km,vdtend) + vtendform(i,kts:km)*deltim
2370 if ( ldiag_ugwp )
then
2372 dtaux2d_fd(i,k) = utendform(i,k)
2373 dtauy2d_fd(i,k) = vtendform(i,k)
2374 dusfc_fd(i) = dusfc_fd(i) + utendform(i,k) * del(i,k)
2375 dvsfc_fd(i) = dvsfc_fd(i) + vtendform(i,k) * del(i,k)
2386IF ( (do_gsl_drag_ls_bl).and.(gwd_opt_ls .EQ. 1) )
THEN
2390 if ( ls_taper(i).GT.1.e-02 )
then
2395 if (k .le. kbl(i)) taup(i,k) = taub(i)
2398 do k = kpblmin, km-1
2405 if (k .ge. kbl(i))
then
2406 icrilv(i) = icrilv(i) .or. ( usqj(i,k) .lt. ric) &
2407 .or. (velco(i,k) .le. 0.0)
2408 brvf(i) = max(bnv2(i,k),bnv2min)
2409 brvf(i) = sqrt(brvf(i))
2412 if (k .ge. kbl(i) .and. (.not. ldrag(i)))
then
2413 if (.not.icrilv(i) .and. taup(i,k) .gt. 0.0 )
then
2414 temv = 1.0 / velco(i,k)
2415 tem1 = coefm(i)/dxy(i)*(ro(i,kp1)+ro(i,k))*brvf(i)* &
2417 hd = sqrt(taup(i,k) / tem1)
2418 fro = brvf(i) * hd * temv
2421 tem2 = sqrt(usqj(i,k))
2422 tem = 1. + tem2 * fro
2423 rim = usqj(i,k) * (1.-fro) / (tem * tem)
2428 if (rim .le. ric)
then
2429 temc = 2.0 + 1.0 / tem2
2430 hd = velco(i,k) * (2.*sqrt(temc)-temc) / brvf(i)
2431 taup(i,kp1) = tem1 * hd * hd
2433 taup(i,kp1) = taup(i,k)
2440 do klcap = lcapp1,km
2441 taup(i,klcap) = prsi(i,klcap) / prsi(i,lcap) * taup(i,lcap)
2453IF ( (do_gsl_drag_ls_bl) .and. (gwd_opt_bl .EQ. 1) )
THEN
2460 if ( ls_taper(i).GT.1.e-02 )
then
2462 if (.not.ldrag(i))
then
2468 do k = km, kpblmin, -1
2469 if(flag(i).and. k.le.kbmax(i))
then
2470 pe = pe + bnv2(i,k)*(zl(i,kbmax(i))-zl(i,k))* &
2471 del(i,k)*g_inv/ro(i,k)
2472 ke = 0.5*((rcs*u1(i,k))**2.+(rcs*v1(i,k))**2.)
2476 if(pe.ge.ke.and.zl(i,k).le.hmax(i))
then
2479 rdxzb(i) = real(k,kind=kind_phys)
2484 if(.not.flag(i))
then
2488 cd = max(2.0-1.0/od(i),cdmin)
2489 taufb(i,kts) = 0.5 * roll(i) * coefm(i) / &
2490 max(dxmax_ls,dxy(i))**2 * cd * dxyp(i) * &
2491 olp(i) * zblk * ulow(i)**2
2492 tautem = taufb(i,kts)/float(kblk(i)-kts)
2493 do k = kts+1, kpblmax
2494 if (k .le. kblk(i)) taufb(i,k) = taufb(i,k-1) - tautem
2500 if (k .le. kblk(i)) taup(i,k) = taup(i,kblk(i))
2514IF ( (do_gsl_drag_ls_bl) .and. &
2515 (gwd_opt_ls .EQ. 1 .OR. gwd_opt_bl .EQ. 1) )
THEN
2519 if ( ls_taper(i) .GT. 1.e-02 )
then
2525 taud_ls(i,k) = 1. * (taup(i,k+1) - taup(i,k)) * csg / del(i,k)
2526 taud_bl(i,k) = 1. * (taufb(i,k+1) - taufb(i,k)) * csg / del(i,k)
2532 taud_ls(i,klcap) = taud_ls(i,klcap) * factop
2533 taud_bl(i,klcap) = taud_bl(i,klcap) * factop
2540 do k = kts,kpblmax-1
2541 if ((taud_ls(i,k)+taud_bl(i,k)).ne.0.)
then
2542 dtfac(i,k) = min(dtfac(i,k),abs(velco(i,k) &
2543 /(deltim*rcs*(taud_ls(i,k)+taud_bl(i,k)))))
2550 if ((taud_ls(i,k)+taud_bl(i,k)).ne.0..and.prsl(i,k).le.pcutoff)
then
2551 denfac = min(ro(i,k)/pcutoff_den,1.)
2552 dtfac(i,k) = min(dtfac(i,k),denfac*abs(velco(i,k) &
2553 /(deltim*rcs*(taud_ls(i,k)+taud_bl(i,k)))))
2558 taud_ls(i,k) = taud_ls(i,k)*dtfac(i,k)* ls_taper(i) *(1.-rstoch(i))
2559 taud_bl(i,k) = taud_bl(i,k)*dtfac(i,k)* ls_taper(i) *(1.-rstoch(i))
2560 dtaux = taud_ls(i,k) * xn(i)
2561 dtauy = taud_ls(i,k) * yn(i)
2562 dtauxb = taud_bl(i,k) * xn(i)
2563 dtauyb = taud_bl(i,k) * yn(i)
2566 dudt(i,k) = dtaux + dtauxb + dudt(i,k)
2567 dvdt(i,k) = dtauy + dtauyb + dvdt(i,k)
2569 if ( gsd_diss_ht_opt .EQ. 1 )
then
2572 eng0 = 0.5*( (rcs*u1(i,k))**2. + (rcs*v1(i,k))**2. )
2574 eng1 = 0.5*( (rcs*(u1(i,k)+(dtaux+dtauxb)*deltim))**2 + &
2575 (rcs*(v1(i,k)+(dtauy+dtauyb)*deltim))**2 )
2577 dtdt(i,k) = dtdt(i,k) + max((eng0-eng1),0.0)/cp/deltim
2578 if ( tdtend>0 )
then
2579 dtend(i,k,tdtend) = dtend(i,k,tdtend) + max((eng0-eng1),0.0)/cp
2583 dusfc(i) = dusfc(i) + taud_ls(i,k)*xn(i)*del(i,k) + &
2584 taud_bl(i,k)*xn(i)*del(i,k)
2585 dvsfc(i) = dvsfc(i) + taud_ls(i,k)*yn(i)*del(i,k) + &
2586 taud_bl(i,k)*yn(i)*del(i,k)
2588 dtend(i,k,udtend) = dtend(i,k,udtend) + (taud_ls(i,k) * &
2589 xn(i) + taud_bl(i,k) * xn(i)) * deltim
2592 dtend(i,k,vdtend) = dtend(i,k,vdtend) + (taud_ls(i,k) * &
2593 yn(i) + taud_bl(i,k) * yn(i)) * deltim
2599 dusfc(i) = -(invgrcs) * dusfc(i)
2600 dvsfc(i) = -(invgrcs) * dvsfc(i)
2602 if ( ldiag_ugwp )
then
2604 dtaux2d_ls(i,k) = taud_ls(i,k) * xn(i)
2605 dtauy2d_ls(i,k) = taud_ls(i,k) * yn(i)
2606 dtaux2d_bl(i,k) = taud_bl(i,k) * xn(i)
2607 dtauy2d_bl(i,k) = taud_bl(i,k) * yn(i)
2608 dusfc_ls(i) = dusfc_ls(i) + dtaux2d_ls(i,k) * del(i,k)
2609 dvsfc_ls(i) = dvsfc_ls(i) + dtauy2d_ls(i,k) * del(i,k)
2610 dusfc_bl(i) = dusfc_bl(i) + dtaux2d_bl(i,k) * del(i,k)
2611 dvsfc_bl(i) = dvsfc_bl(i) + dtauy2d_bl(i,k) * del(i,k)
2621if ( ldiag_ugwp )
then
2624 dusfc_ls(i) = -(invgrcs) * dusfc_ls(i)
2625 dvsfc_ls(i) = -(invgrcs) * dvsfc_ls(i)
2626 dusfc_bl(i) = -(invgrcs) * dusfc_bl(i)
2627 dvsfc_bl(i) = -(invgrcs) * dvsfc_bl(i)
2628 dusfc_ss(i) = -(invgrcs) * dusfc_ss(i)
2629 dvsfc_ss(i) = -(invgrcs) * dvsfc_ss(i)
2630 dusfc_fd(i) = -(invgrcs) * dusfc_fd(i)
2631 dvsfc_fd(i) = -(invgrcs) * dvsfc_fd(i)