189 subroutine cires_ugwp_run(do_ugwp, me, master, im, levs, ntrac, dtp, kdt, lonr, &
190 oro, oro_uf, hprime, nmtvr, oc, theta, sigma, gamma, elvmax, clx, oa4, &
191 do_tofd, ldiag_ugwp, cdmbgwd, xlat, xlat_d, sinlat, coslat, &
192 area, ugrs, vgrs, tgrs, qgrs, prsi, prsl, prslk, phii, phil, &
193 del, kpbl, dusfcg, dvsfcg, gw_dudt, gw_dvdt, gw_dtdt, gw_kdis, &
194 tau_tofd, tau_mtb, tau_ogw, tau_ngw, zmtb, zlwb, zogw, &
195 dusfc_ms, dvsfc_ms, dusfc_bl, dvsfc_bl, &
196 dudt_ogw, dtauy2d_ms, dtaux2d_bl, dtauy2d_bl, &
197 dudt_mtb, dudt_tms, du3dt_mtb, du3dt_ogw, du3dt_tms, &
198 dudt, dvdt, dtdt, rdxzb, con_g, con_pi, con_cp, con_rd, con_rv, con_fvirt, &
199 con_omega, rain, ntke, q_tke, dqdt_tke, lprnt, ipr, &
200 dtend, dtidx, index_of_x_wind, index_of_y_wind, index_of_temperature, &
201 index_of_process_orographic_gwd, index_of_process_nonorographic_gwd, &
202 ldiag3d, lssav, flag_for_gwd_generic_tend, errmsg, errflg)
207 integer,
intent(in) :: me, master, im, levs, ntrac, kdt, lonr, nmtvr
208 integer,
intent(in),
dimension(:) :: kpbl
209 real(kind=kind_phys),
intent(in),
dimension(:) :: oro, oro_uf, hprime, oc, theta, sigma, gamma
210 logical,
intent(in) :: flag_for_gwd_generic_tend
212 real(kind=kind_phys),
intent(inout),
dimension(:) :: elvmax
213 real(kind=kind_phys),
intent(in),
dimension(:, :) :: clx, oa4
214 real(kind=kind_phys),
intent(in),
dimension(:) :: xlat, xlat_d, sinlat, coslat, area
215 real(kind=kind_phys),
intent(in),
dimension(:, :) :: del, ugrs, vgrs, tgrs, prsl, prslk, phil
216 real(kind=kind_phys),
intent(in),
dimension(:, :) :: prsi, phii
217 real(kind=kind_phys),
intent(in),
dimension(:,:,:):: qgrs
218 real(kind=kind_phys),
intent(in) :: dtp, cdmbgwd(:)
219 logical,
intent(in) :: do_ugwp, do_tofd, ldiag_ugwp
221 real(kind=kind_phys),
intent(out),
dimension(:) :: dusfcg, dvsfcg
222 real(kind=kind_phys),
intent(out),
dimension(:) :: zmtb, zlwb, zogw, rdxzb
223 real(kind=kind_phys),
intent(out),
dimension(:) :: tau_mtb, tau_ogw, tau_tofd, tau_ngw
224 real(kind=kind_phys),
intent(out),
dimension(:, :):: gw_dudt, gw_dvdt, gw_dtdt, gw_kdis
225 real(kind=kind_phys),
intent(out),
dimension(:, :):: dudt_mtb, dudt_tms
226 real(kind=kind_phys),
intent(out),
dimension(:, :),
optional :: dudt_ogw
227 real(kind=kind_phys),
intent(out),
dimension(:),
optional :: dusfc_ms, dvsfc_ms, dusfc_bl, dvsfc_bl
228 real(kind=kind_phys),
intent(out),
dimension(:, :),
optional :: dtauy2d_ms
229 real(kind=kind_phys),
intent(out),
dimension(:, :),
optional :: dtaux2d_bl, dtauy2d_bl
232 real(kind=kind_phys),
optional,
intent(inout) :: dtend(:,:,:)
233 integer,
intent(in) :: dtidx(:,:), &
234 index_of_x_wind, index_of_y_wind, index_of_temperature, &
235 index_of_process_orographic_gwd, index_of_process_nonorographic_gwd
237 logical,
intent(in) :: ldiag3d, lssav
240 real(kind=kind_phys),
intent(inout),
dimension(:,:),
optional :: du3dt_mtb, du3dt_ogw, du3dt_tms
242 real(kind=kind_phys),
intent(inout),
dimension(:, :):: dudt, dvdt, dtdt
244 real(kind=kind_phys),
intent(in) :: con_g, con_pi, con_cp, con_rd, con_rv, con_fvirt, con_omega
246 real(kind=kind_phys),
intent(in),
dimension(:) :: rain
248 integer,
intent(in) :: ntke
249 real(kind=kind_phys),
intent(in),
dimension(:,:) :: q_tke, dqdt_tke
251 logical,
intent(in) :: lprnt
252 integer,
intent(in) :: ipr
254 character(len=*),
intent(out) :: errmsg
255 integer,
intent(out) :: errflg
258 integer :: i, k, idtend
259 real(kind=kind_phys),
dimension(im) :: sgh30
260 real(kind=kind_phys),
dimension(im, levs) :: pdvdt, pdudt
261 real(kind=kind_phys),
dimension(im, levs) :: pdtdt, pkdis
262 real(kind=kind_phys),
dimension(im, levs) :: ed_dudt, ed_dvdt, ed_dtdt
264 real(kind=kind_phys),
parameter :: tamp_mpa=30.e-3
266 real(kind=kind_phys),
parameter :: pogw=1., pngw=1., pked=1.
268 real(kind=kind_phys),
dimension(:,:),
allocatable :: tke
269 real(kind=kind_phys),
dimension(:),
allocatable :: turb_fac, tem
270 real(kind=kind_phys) :: rfac, tx1
285 sgh30 = abs(oro - oro_uf)
293 call gwdps_v0(im, levs, lonr, do_tofd, pdvdt, pdudt, pdtdt, pkdis, &
294 ugrs, vgrs, tgrs, qgrs(:,:,1), kpbl, prsi,del,prsl, prslk, phii, phil, &
295 dtp, kdt, sgh30, hprime, oc, oa4, clx, theta, sigma, gamma, elvmax, &
296 dusfcg, dvsfcg, xlat_d, sinlat, coslat, area, cdmbgwd(1:2), &
297 me, master, rdxzb, con_g, con_omega, zmtb, zogw, tau_mtb, tau_ogw, &
298 tau_tofd, dudt_mtb, dudt_ogw, dudt_tms)
311 if (cdmbgwd(1) > 0.0 .or. cdmbgwd(2) > 0.0)
then
312 call gwdps_run(im, levs, pdvdt, pdudt, pdtdt, &
313 ugrs, vgrs, tgrs, qgrs(:,:,1), &
314 kpbl, prsi, del, prsl, prslk, phii, phil, dtp, kdt, &
315 hprime, oc, oa4, clx, theta, sigma, gamma, &
316 elvmax, dusfcg, dvsfcg, dudt_ogw, dtauy2d_ms, &
317 dtaux2d_bl, dtauy2d_bl, dusfc_ms, dvsfc_ms, &
318 dusfc_bl, dvsfc_bl, &
319 con_g, con_cp, con_rd, con_rv, lonr, &
320 nmtvr, cdmbgwd, me, lprnt, ipr, rdxzb, ldiag_ugwp, &
322 if (errflg/=0)
return
325 tau_mtb = 0.0 ; tau_ogw = 0.0 ; tau_tofd = 0.0
327 du3dt_mtb = 0.0 ; du3dt_ogw = 0.0 ; du3dt_tms= 0.0
332 if(ldiag3d .and. lssav .and. .not. flag_for_gwd_generic_tend)
then
333 idtend = dtidx(index_of_x_wind,index_of_process_orographic_gwd)
335 dtend(:,:,idtend) = dtend(:,:,idtend) + pdudt*dtp
337 idtend = dtidx(index_of_y_wind,index_of_process_orographic_gwd)
339 dtend(:,:,idtend) = dtend(:,:,idtend) + pdvdt*dtp
341 idtend = dtidx(index_of_temperature,index_of_process_orographic_gwd)
343 dtend(:,:,idtend) = dtend(:,:,idtend) + pdtdt*dtp
347 if (cdmbgwd(3) > 0.0)
then
350 call slat_geos5_tamp_v0(im, tamp_mpa, xlat_d, tau_ngw)
352 if (abs(1.0-cdmbgwd(3)) > 1.0e-6)
then
353 if (cdmbgwd(4) > 0.0)
then
354 allocate(turb_fac(im))
359 allocate(tke(im,levs))
361 tke(:,:) = q_tke(:,:) + dqdt_tke(:,:) * dtp
365 turb_fac(i) = turb_fac(i) + del(i,k) * tke(i,k)
366 tem(i) = tem(i) + del(i,k)
370 turb_fac(i) = turb_fac(i) / tem(i)
375 rfac = 86400000 / dtp
377 tx1 = cdmbgwd(4)*min(10.0, max(turb_fac(i),rain(i)*rfac))
378 tau_ngw(i) = tau_ngw(i) * max(0.1, min(5.0, tx1))
383 tau_ngw(i) = tau_ngw(i) * cdmbgwd(3)
387 call fv3_ugwp_solv2_v0(im, levs, dtp, tgrs, ugrs, vgrs,qgrs(:,:,1), &
388 prsl, prsi, phil, xlat_d, sinlat, coslat, &
389 gw_dudt, gw_dvdt, gw_dtdt, gw_kdis, tau_ngw, &
394 gw_dtdt(i,k) = pngw*gw_dtdt(i,k) + pogw*pdtdt(i,k)
395 gw_dudt(i,k) = pngw*gw_dudt(i,k) + pogw*pdudt(i,k)
396 gw_dvdt(i,k) = pngw*gw_dvdt(i,k) + pogw*pdvdt(i,k)
397 gw_kdis(i,k) = pngw*gw_kdis(i,k) + pogw*pkdis(i,k)
409 gw_dtdt(i,k) = pdtdt(i,k)
410 gw_dudt(i,k) = pdudt(i,k)
411 gw_dvdt(i,k) = pdvdt(i,k)
412 gw_kdis(i,k) = pkdis(i,k)
418 if (pogw == 0.0)
then
419 tau_mtb = 0. ; tau_ogw = 0. ; tau_tofd = 0.
420 dudt_mtb = 0. ; dudt_ogw = 0. ; dudt_tms = 0.
423 if(ldiag3d .and. lssav .and. .not. flag_for_gwd_generic_tend)
then
424 idtend = dtidx(index_of_x_wind,index_of_process_nonorographic_gwd)
426 dtend(:,:,idtend) = dtend(:,:,idtend) + (gw_dudt - pdudt)*dtp
428 idtend = dtidx(index_of_y_wind,index_of_process_nonorographic_gwd)
430 dtend(:,:,idtend) = dtend(:,:,idtend) + (gw_dvdt - pdvdt)*dtp
432 idtend = dtidx(index_of_temperature,index_of_process_nonorographic_gwd)
434 dtend(:,:,idtend) = dtend(:,:,idtend) + (gw_dtdt - pdtdt)*dtp