49 use fv_mp_mod, only: fill_corners, xdir, ydir
59 real,
parameter::
r3 = 1./3.
71 real,
parameter::
p1 = 7./12.
72 real,
parameter::
p2 = -1./12.
76 real,
parameter::
a1 = 0.5625
77 real,
parameter::
a2 = -0.0625
80 real,
parameter::
c1 = -2./14.
81 real,
parameter::
c2 = 11./14.
82 real,
parameter::
c3 = 5./14.
89 real,
parameter::
b1 = 1./30.
90 real,
parameter::
b2 = -13./60.
91 real,
parameter::
b3 = -13./60.
92 real,
parameter::
b4 = 0.45
93 real,
parameter::
b5 = -0.05
102 subroutine c_sw(delpc, delp, ptc, pt, u,v, w, uc,vc, ua,va, wc, &
103 ut, vt, divg_d, nord, dt2, hydrostatic, dord4, &
104 bd, gridstruct, flagstruct)
107 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u, vc
108 real,
intent(INOUT),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ) :: v, uc
109 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed ) :: delp, pt, ua, va, ut, vt
110 real,
intent(INOUT),
dimension(bd%isd: , bd%jsd: ) :: w
111 real,
intent(OUT ),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed ) :: delpc, ptc, wc
112 real,
intent(OUT ),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1) :: divg_d
113 integer,
intent(IN) :: nord
114 real,
intent(IN) :: dt2
115 logical,
intent(IN) :: hydrostatic
116 logical,
intent(IN) :: dord4
121 logical:: sw_corner, se_corner, ne_corner, nw_corner
122 real,
dimension(bd%is-1:bd%ie+1,bd%js-1:bd%je+1):: vort, ke
123 real,
dimension(bd%is-1:bd%ie+2,bd%js-1:bd%je+1):: fx, fx1, fx2
124 real,
dimension(bd%is-1:bd%ie+1,bd%js-1:bd%je+2):: fy, fy1, fy2
126 integer :: i,j, is2, ie1
129 integer :: is, ie, js, je
130 integer :: isd, ied, jsd, jed
132 logical :: nested,regional
134 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
135 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v
136 real,
pointer,
dimension(:,:) :: sina_u, sina_v
138 real,
pointer,
dimension(:,:) :: dx, dy, dxc, dyc
151 nested = gridstruct%nested
152 regional = gridstruct%regional
154 sin_sg => gridstruct%sin_sg
155 cos_sg => gridstruct%cos_sg
156 cosa_u => gridstruct%cosa_u
157 cosa_v => gridstruct%cosa_v
158 sina_u => gridstruct%sina_u
159 sina_v => gridstruct%sina_v
162 dxc => gridstruct%dxc
163 dyc => gridstruct%dyc
165 sw_corner = gridstruct%sw_corner
166 se_corner = gridstruct%se_corner
167 nw_corner = gridstruct%nw_corner
168 ne_corner = gridstruct%ne_corner
170 iep1 = ie+1; jep1 = je+1
172 call d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, &
173 npx, npy, nested, flagstruct%grid_type, regional )
176 if (nested .or. regional)
then 185 if (ut(i,j) > 0.)
then 186 ut(i,j) = dt2*ut(i,j)*dy(i,j)*sin_sg(i-1,j,3)
188 ut(i,j) = dt2*ut(i,j)*dy(i,j)*sin_sg(i,j,1)
194 if (vt(i,j) > 0.)
then 195 vt(i,j) = dt2*vt(i,j)*dx(i,j)*sin_sg(i,j-1,4)
197 vt(i,j) = dt2*vt(i,j)*dx(i,j)*sin_sg(i,j, 2)
206 if (flagstruct%grid_type < 3 .and. .not. (nested .or. regional)) &
207 call fill2_4corners(delp, pt, 1, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
209 if ( hydrostatic )
then 213 if ( ut(i,j) > 0. )
then 214 fx1(i,j) = delp(i-1,j)
218 fx1(i,j) = ut(i,j)*fx1(i,j)
224 if ( ut(i,j) > 0. )
then 225 fx1(i,j) = delp(i-1,j)
231 fx1(i,j) = ut(i,j)*fx1(i,j)
232 fx(i,j) = fx1(i,j)* fx(i,j)
237 if (flagstruct%grid_type < 3) &
238 call fill_4corners(w, 1, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
241 if ( ut(i,j) > 0. )
then 242 fx1(i,j) = delp(i-1,j)
250 fx1(i,j) = ut(i,j)*fx1(i,j)
251 fx(i,j) = fx1(i,j)* fx(i,j)
252 fx2(i,j) = fx1(i,j)*fx2(i,j)
258 if (flagstruct%grid_type < 3 .and. .not. (nested .or. regional)) &
259 call fill2_4corners(delp, pt, 2, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
261 if ( hydrostatic )
then 264 if ( vt(i,j) > 0. )
then 265 fy1(i,j) = delp(i,j-1)
271 fy1(i,j) = vt(i,j)*fy1(i,j)
272 fy(i,j) = fy1(i,j)* fy(i,j)
277 delpc(i,j) = delp(i,j) + (fx1(i,j)-fx1(i+1,j)+fy1(i,j)-fy1(i,j+1))*gridstruct%rarea(i,j)
281 ptc(i,j) = (pt(i,j)*delp(i,j) + &
282 (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*gridstruct%rarea(i,j))/delpc(i,j)
287 if (flagstruct%grid_type < 3)
call fill_4corners(w, 2, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
290 if ( vt(i,j) > 0. )
then 291 fy1(i,j) = delp(i,j-1)
299 fy1(i,j) = vt(i,j)*fy1(i,j)
300 fy(i,j) = fy1(i,j)* fy(i,j)
301 fy2(i,j) = fy1(i,j)*fy2(i,j)
306 delpc(i,j) = delp(i,j) + (fx1(i,j)-fx1(i+1,j)+fy1(i,j)-fy1(i,j+1))*gridstruct%rarea(i,j)
307 ptc(i,j) = (pt(i,j)*delp(i,j) + &
308 (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*gridstruct%rarea(i,j))/delpc(i,j)
309 wc(i,j) = (w(i,j)*delp(i,j) + (fx2(i,j)-fx2(i+1,j) + &
310 fy2(i,j)-fy2(i,j+1))*gridstruct%rarea(i,j))/delpc(i,j)
324 if (nested .or. regional .or. flagstruct%grid_type >=3 )
then 327 if ( ua(i,j) > 0. )
then 336 if ( va(i,j) > 0. )
then 339 vort(i,j) = vc(i,j+1)
346 if ( ua(i,j) > 0. )
then 348 ke(1,j) = uc(1, j)*sin_sg(1,j,1)+v(1,j)*cos_sg(1,j,1)
349 elseif ( i==npx )
then 350 ke(i,j) = uc(npx,j)*sin_sg(npx,j,1)+v(npx,j)*cos_sg(npx,j,1)
356 ke(0,j) = uc(1, j)*sin_sg(0,j,3)+v(1,j)*cos_sg(0,j,3)
357 elseif ( i==(npx-1) )
then 358 ke(i,j) = uc(npx,j)*sin_sg(npx-1,j,3)+v(npx,j)*cos_sg(npx-1,j,3)
367 if ( va(i,j) > 0. )
then 369 vort(i,1) = vc(i, 1)*sin_sg(i,1,2)+u(i, 1)*cos_sg(i,1,2)
370 elseif ( j==npy )
then 371 vort(i,j) = vc(i,npy)*sin_sg(i,npy,2)+u(i,npy)*cos_sg(i,npy,2)
377 vort(i,0) = vc(i, 1)*sin_sg(i,0,4)+u(i, 1)*cos_sg(i,0,4)
378 elseif ( j==(npy-1) )
then 379 vort(i,j) = vc(i,npy)*sin_sg(i,npy-1,4)+u(i,npy)*cos_sg(i,npy-1,4)
381 vort(i,j) = vc(i,j+1)
391 ke(i,j) = dt4*(ua(i,j)*ke(i,j) + va(i,j)*vort(i,j))
401 fx(i,j) = uc(i,j) * dxc(i,j)
407 fy(i,j) = vc(i,j) * dyc(i,j)
413 vort(i,j) = fx(i,j-1) - fx(i,j) - fy(i-1,j) + fy(i,j)
418 if ( sw_corner ) vort(1, 1) = vort(1, 1) + fy(0, 1)
419 if ( se_corner ) vort(npx ,1) = vort(npx, 1) - fy(npx, 1)
420 if ( ne_corner ) vort(npx,npy) = vort(npx,npy) - fy(npx,npy)
421 if ( nw_corner ) vort(1, npy) = vort(1, npy) + fy(0, npy)
428 vort(i,j) = gridstruct%fC(i,j) + gridstruct%rarea_c(i,j) * vort(i,j)
441 if (nested .or. regional .or. flagstruct%grid_type >= 3)
then 444 fy1(i,j) = dt2*(v(i,j)-uc(i,j)*cosa_u(i,j))/sina_u(i,j)
445 if ( fy1(i,j) > 0. )
then 448 fy(i,j) = vort(i,j+1)
454 fx1(i,j) = dt2*(u(i,j)-vc(i,j)*cosa_v(i,j))/sina_v(i,j)
455 if ( fx1(i,j) > 0. )
then 458 fx(i,j) = vort(i+1,j)
466 if ( ( i==1 .or. i==npx ) )
then 467 fy1(i,j) = dt2*v(i,j)
469 fy1(i,j) = dt2*(v(i,j)-uc(i,j)*cosa_u(i,j))/sina_u(i,j)
471 if ( fy1(i,j) > 0. )
then 474 fy(i,j) = vort(i,j+1)
479 if ( ( j==1 .or. j==npy ) )
then 482 fx1(i,j) = dt2*u(i,j)
483 if ( fx1(i,j) > 0. )
then 486 fx(i,j) = vort(i+1,j)
492 fx1(i,j) = dt2*(u(i,j)-vc(i,j)*cosa_v(i,j))/sina_v(i,j)
493 if ( fx1(i,j) > 0. )
then 496 fx(i,j) = vort(i+1,j)
506 uc(i,j) = uc(i,j) + fy1(i,j)*fy(i,j) + gridstruct%rdxc(i,j)*(ke(i-1,j)-ke(i,j))
511 vc(i,j) = vc(i,j) - fx1(i,j)*fx(i,j) + gridstruct%rdyc(i,j)*(ke(i,j-1)-ke(i,j))
523 subroutine d_sw(delpc, delp, ptc, pt, u, v, w, uc,vc, &
524 ua, va, divg_d, xflux, yflux, cx, cy, &
525 crx_adv, cry_adv, xfx_adv, yfx_adv, q_con, z_rat, kgb, heat_source,diss_est, &
526 zvir, sphum, nq, q, k, km, inline_q, &
527 dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, &
528 nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, &
529 damp_t, d_con, hydrostatic, gridstruct, flagstruct, bd)
531 integer,
intent(IN):: hord_tr, hord_mt, hord_vt, hord_tm, hord_dp
532 integer,
intent(IN):: nord
533 integer,
intent(IN):: nord_v
534 integer,
intent(IN):: nord_w
535 integer,
intent(IN):: nord_t
536 integer,
intent(IN):: sphum, nq, k, km
537 real ,
intent(IN):: dt, dddmp, d2_bg, d4_bg, d_con
538 real ,
intent(IN):: zvir
539 real,
intent(in):: damp_v, damp_w, damp_t, kgb
541 real,
intent(inout):: divg_d(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
542 real,
intent(IN),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed):: z_rat
543 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed):: delp, pt, ua, va
544 real,
intent(INOUT),
dimension(bd%isd: , bd%jsd: ):: w, q_con
545 real,
intent(INOUT),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1):: u, vc
546 real,
intent(INOUT),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v, uc
547 real,
intent(INOUT):: q(bd%isd:bd%ied,bd%jsd:bd%jed,km,nq)
548 real,
intent(OUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc
549 real,
intent(OUT),
dimension(bd%is:bd%ie,bd%js:bd%je):: heat_source
550 real,
intent(OUT),
dimension(bd%is:bd%ie,bd%js:bd%je):: diss_est
552 real,
intent(INOUT):: xflux(bd%is:bd%ie+1,bd%js:bd%je )
553 real,
intent(INOUT):: yflux(bd%is:bd%ie ,bd%js:bd%je+1)
555 real,
intent(INOUT):: cx(bd%is:bd%ie+1,bd%jsd:bd%jed )
556 real,
intent(INOUT):: cy(bd%isd:bd%ied,bd%js:bd%je+1)
557 logical,
intent(IN):: hydrostatic
558 logical,
intent(IN):: inline_q
559 real,
intent(OUT),
dimension(bd%is:bd%ie+1,bd%jsd:bd%jed):: crx_adv, xfx_adv
560 real,
intent(OUT),
dimension(bd%isd:bd%ied,bd%js:bd%je+1):: cry_adv, yfx_adv
564 logical:: sw_corner, se_corner, ne_corner, nw_corner
565 real :: ut(bd%isd:bd%ied+1,bd%jsd:bd%jed)
566 real :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
568 real :: fx2(bd%isd:bd%ied+1,bd%jsd:bd%jed)
569 real :: fy2(bd%isd:bd%ied, bd%jsd:bd%jed+1)
570 real :: dw(bd%is:bd%ie,bd%js:bd%je)
572 real,
dimension(bd%is:bd%ie+1,bd%js:bd%je+1):: ub, vb
573 real :: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
574 real :: ke(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
575 real :: vort(bd%isd:bd%ied,bd%jsd:bd%jed)
576 real :: fx(bd%is:bd%ie+1,bd%js:bd%je )
577 real :: fy(bd%is:bd%ie ,bd%js:bd%je+1)
578 real :: ra_x(bd%is:bd%ie,bd%jsd:bd%jed)
579 real :: ra_y(bd%isd:bd%ied,bd%js:bd%je)
580 real :: gx(bd%is:bd%ie+1,bd%js:bd%je )
581 real :: gy(bd%is:bd%ie ,bd%js:bd%je+1)
584 real :: dt2, dt4, dt5, dt6
585 real :: damp, damp2, damp4, dd8, u2, v2, du2, dv2
587 integer :: i,j, is2, ie1, js2, je1, n, nt, n2, iq
589 real,
pointer,
dimension(:,:) :: area, area_c, rarea
591 real,
pointer,
dimension(:,:,:) :: sin_sg
592 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v, cosa_s
593 real,
pointer,
dimension(:,:) :: sina_u, sina_v
594 real,
pointer,
dimension(:,:) :: rsin_u, rsin_v, rsina
595 real,
pointer,
dimension(:,:) :: f0, rsin2, divg_u, divg_v
597 real,
pointer,
dimension(:,:) :: cosa, dx, dy, dxc, dyc, rdxa, rdya, rdx, rdy
599 integer :: is, ie, js, je
600 integer :: isd, ied, jsd, jed
602 logical :: nested,regional
615 nested = gridstruct%nested
616 regional = gridstruct%regional
618 area => gridstruct%area
619 rarea => gridstruct%rarea
620 sin_sg => gridstruct%sin_sg
621 cosa_u => gridstruct%cosa_u
622 cosa_v => gridstruct%cosa_v
623 cosa_s => gridstruct%cosa_s
624 sina_u => gridstruct%sina_u
625 sina_v => gridstruct%sina_v
626 rsin_u => gridstruct%rsin_u
627 rsin_v => gridstruct%rsin_v
628 rsina => gridstruct%rsina
630 rsin2 => gridstruct%rsin2
631 divg_u => gridstruct%divg_u
632 divg_v => gridstruct%divg_v
633 cosa => gridstruct%cosa
636 dxc => gridstruct%dxc
637 dyc => gridstruct%dyc
638 rdxa => gridstruct%rdxa
639 rdya => gridstruct%rdya
640 rdx => gridstruct%rdx
641 rdy => gridstruct%rdy
643 sw_corner = gridstruct%sw_corner
644 se_corner = gridstruct%se_corner
645 nw_corner = gridstruct%nw_corner
646 ne_corner = gridstruct%ne_corner
652 xfx_adv(i,j) = dt * uc(i,j) / sina_u(i,j)
653 if (xfx_adv(i,j) > 0.)
then 654 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i-1,j)
656 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i,j)
658 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sina_u(i,j)
664 yfx_adv(i,j) = dt * vc(i,j) / sina_v(i,j)
665 if (yfx_adv(i,j) > 0.)
then 666 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j-1)
668 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j)
670 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sina_v(i,j)
675 if ( flagstruct%grid_type < 3 )
then 678 if (nested .or. regional)
then 681 ut(i,j) = ( uc(i,j) - 0.25 * cosa_u(i,j) * &
682 (vc(i-1,j)+vc(i,j)+vc(i-1,j+1)+vc(i,j+1)))*rsin_u(i,j)
687 vt(i,j) = ( vc(i,j) - 0.25 * cosa_v(i,j) * &
688 (uc(i,j-1)+uc(i+1,j-1)+uc(i,j)+uc(i+1,j)))*rsin_v(i,j)
693 if( j/=0 .and. j/=1 .and. j/=(npy-1) .and. j/=npy)
then 695 ut(i,j) = ( uc(i,j) - 0.25 * cosa_u(i,j) * &
696 (vc(i-1,j)+vc(i,j)+vc(i-1,j+1)+vc(i,j+1)))*rsin_u(i,j)
702 if( j/=1 .and. j/=npy )
then 705 vt(i,j) = ( vc(i,j) - 0.25 * cosa_v(i,j) * &
706 (uc(i,j-1)+uc(i+1,j-1)+uc(i,j)+uc(i+1,j)))*rsin_v(i,j)
712 if (.not. (nested .or. regional))
then 716 if ( uc(1,j)*dt > 0. )
then 717 ut(1,j) = uc(1,j) / sin_sg(0,j,3)
719 ut(1,j) = uc(1,j) / sin_sg(1,j,1)
722 do j=max(3,js), min(npy-2,je+1)
723 vt(0,j) = vc(0,j) - 0.25*cosa_v(0,j)* &
724 (ut(0,j-1)+ut(1,j-1)+ut(0,j)+ut(1,j))
725 vt(1,j) = vc(1,j) - 0.25*cosa_v(1,j)* &
726 (ut(1,j-1)+ut(2,j-1)+ut(1,j)+ut(2,j))
731 if ( (ie+1)==npx )
then 733 if ( uc(npx,j)*dt > 0. )
then 734 ut(npx,j) = uc(npx,j) / sin_sg(npx-1,j,3)
736 ut(npx,j) = uc(npx,j) / sin_sg(npx,j,1)
740 do j=max(3,js), min(npy-2,je+1)
741 vt(npx-1,j) = vc(npx-1,j) - 0.25*cosa_v(npx-1,j)* &
742 (ut(npx-1,j-1)+ut(npx,j-1)+ut(npx-1,j)+ut(npx,j))
743 vt(npx,j) = vc(npx,j) - 0.25*cosa_v(npx,j)* &
744 (ut(npx,j-1)+ut(npx+1,j-1)+ut(npx,j)+ut(npx+1,j))
752 if ( vc(i,1)*dt > 0. )
then 753 vt(i,1) = vc(i,1) / sin_sg(i,0,4)
755 vt(i,1) = vc(i,1) / sin_sg(i,1,2)
759 do i=max(3,is),min(npx-2,ie+1)
760 ut(i,0) = uc(i,0) - 0.25*cosa_u(i,0)* &
761 (vt(i-1,0)+vt(i,0)+vt(i-1,1)+vt(i,1))
762 ut(i,1) = uc(i,1) - 0.25*cosa_u(i,1)* &
763 (vt(i-1,1)+vt(i,1)+vt(i-1,2)+vt(i,2))
768 if ( (je+1)==npy )
then 770 if ( vc(i,npy)*dt > 0. )
then 771 vt(i,npy) = vc(i,npy) / sin_sg(i,npy-1,4)
773 vt(i,npy) = vc(i,npy) / sin_sg(i,npy,2)
776 do i=max(3,is),min(npx-2,ie+1)
777 ut(i,npy-1) = uc(i,npy-1) - 0.25*cosa_u(i,npy-1)* &
778 (vt(i-1,npy-1)+vt(i,npy-1)+vt(i-1,npy)+vt(i,npy))
779 ut(i,npy) = uc(i,npy) - 0.25*cosa_u(i,npy)* &
780 (vt(i-1,npy)+vt(i,npy)+vt(i-1,npy+1)+vt(i,npy+1))
795 damp = 1. / (1.-0.0625*cosa_u(2,0)*cosa_v(1,0))
796 ut(2,0) = (uc(2,0)-0.25*cosa_u(2,0)*(vt(1,1)+vt(2,1)+vt(2,0) +vc(1,0) - &
797 0.25*cosa_v(1,0)*(ut(1,0)+ut(1,-1)+ut(2,-1))) ) * damp
798 damp = 1. / (1.-0.0625*cosa_u(0,1)*cosa_v(0,2))
799 vt(0,2) = (vc(0,2)-0.25*cosa_v(0,2)*(ut(1,1)+ut(1,2)+ut(0,2)+uc(0,1) - &
800 0.25*cosa_u(0,1)*(vt(0,1)+vt(-1,1)+vt(-1,2))) ) * damp
802 damp = 1. / (1.-0.0625*cosa_u(2,1)*cosa_v(1,2))
803 ut(2,1) = (uc(2,1)-0.25*cosa_u(2,1)*(vt(1,1)+vt(2,1)+vt(2,2)+vc(1,2) - &
804 0.25*cosa_v(1,2)*(ut(1,1)+ut(1,2)+ut(2,2))) ) * damp
806 vt(1,2) = (vc(1,2)-0.25*cosa_v(1,2)*(ut(1,1)+ut(1,2)+ut(2,2)+uc(2,1) - &
807 0.25*cosa_u(2,1)*(vt(1,1)+vt(2,1)+vt(2,2))) ) * damp
811 damp = 1. / (1. - 0.0625*cosa_u(npx-1,0)*cosa_v(npx-1,0))
812 ut(npx-1,0) = ( uc(npx-1,0)-0.25*cosa_u(npx-1,0)*( &
813 vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,0)+vc(npx-1,0) - &
814 0.25*cosa_v(npx-1,0)*(ut(npx,0)+ut(npx,-1)+ut(npx-1,-1))) ) * damp
815 damp = 1. / (1. - 0.0625*cosa_u(npx+1,1)*cosa_v(npx,2))
816 vt(npx, 2) = ( vc(npx,2)-0.25*cosa_v(npx,2)*( &
817 ut(npx,1)+ut(npx,2)+ut(npx+1,2)+uc(npx+1,1) - &
818 0.25*cosa_u(npx+1,1)*(vt(npx,1)+vt(npx+1,1)+vt(npx+1,2))) ) * damp
820 damp = 1. / (1. - 0.0625*cosa_u(npx-1,1)*cosa_v(npx-1,2))
821 ut(npx-1,1) = ( uc(npx-1,1)-0.25*cosa_u(npx-1,1)*( &
822 vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,2)+vc(npx-1,2) - &
823 0.25*cosa_v(npx-1,2)*(ut(npx,1)+ut(npx,2)+ut(npx-1,2))) ) * damp
824 vt(npx-1,2) = ( vc(npx-1,2)-0.25*cosa_v(npx-1,2)*( &
825 ut(npx,1)+ut(npx,2)+ut(npx-1,2)+uc(npx-1,1) - &
826 0.25*cosa_u(npx-1,1)*(vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,2))) ) * damp
830 damp = 1. / (1. - 0.0625*cosa_u(npx-1,npy)*cosa_v(npx-1,npy+1))
831 ut(npx-1,npy) = ( uc(npx-1,npy)-0.25*cosa_u(npx-1,npy)*( &
832 vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy+1)+vc(npx-1,npy+1) - &
833 0.25*cosa_v(npx-1,npy+1)*(ut(npx,npy)+ut(npx,npy+1)+ut(npx-1,npy+1))) ) * damp
834 damp = 1. / (1. - 0.0625*cosa_u(npx+1,npy-1)*cosa_v(npx,npy-1))
835 vt(npx, npy-1) = ( vc(npx,npy-1)-0.25*cosa_v(npx,npy-1)*( &
836 ut(npx,npy-1)+ut(npx,npy-2)+ut(npx+1,npy-2)+uc(npx+1,npy-1) - &
837 0.25*cosa_u(npx+1,npy-1)*(vt(npx,npy)+vt(npx+1,npy)+vt(npx+1,npy-1))) ) * damp
839 damp = 1. / (1. - 0.0625*cosa_u(npx-1,npy-1)*cosa_v(npx-1,npy-1))
840 ut(npx-1,npy-1) = ( uc(npx-1,npy-1)-0.25*cosa_u(npx-1,npy-1)*( &
841 vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy-1)+vc(npx-1,npy-1) - &
842 0.25*cosa_v(npx-1,npy-1)*(ut(npx,npy-1)+ut(npx,npy-2)+ut(npx-1,npy-2))) ) * damp
843 vt(npx-1,npy-1) = ( vc(npx-1,npy-1)-0.25*cosa_v(npx-1,npy-1)*( &
844 ut(npx,npy-1)+ut(npx,npy-2)+ut(npx-1,npy-2)+uc(npx-1,npy-1) - &
845 0.25*cosa_u(npx-1,npy-1)*(vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy-1))) ) * damp
849 damp = 1. / (1. - 0.0625*cosa_u(2,npy)*cosa_v(1,npy+1))
850 ut(2,npy) = ( uc(2,npy)-0.25*cosa_u(2,npy)*( &
851 vt(1,npy)+vt(2,npy)+vt(2,npy+1)+vc(1,npy+1) - &
852 0.25*cosa_v(1,npy+1)*(ut(1,npy)+ut(1,npy+1)+ut(2,npy+1))) ) * damp
853 damp = 1. / (1. - 0.0625*cosa_u(0,npy-1)*cosa_v(0,npy-1))
854 vt(0,npy-1) = ( vc(0,npy-1)-0.25*cosa_v(0,npy-1)*( &
855 ut(1,npy-1)+ut(1,npy-2)+ut(0,npy-2)+uc(0,npy-1) - &
856 0.25*cosa_u(0,npy-1)*(vt(0,npy)+vt(-1,npy)+vt(-1,npy-1))) ) * damp
858 damp = 1. / (1. - 0.0625*cosa_u(2,npy-1)*cosa_v(1,npy-1))
859 ut(2,npy-1) = ( uc(2,npy-1)-0.25*cosa_u(2,npy-1)*( &
860 vt(1,npy)+vt(2,npy)+vt(2,npy-1)+vc(1,npy-1) - &
861 0.25*cosa_v(1,npy-1)*(ut(1,npy-1)+ut(1,npy-2)+ut(2,npy-2))) ) * damp
863 vt(1,npy-1) = ( vc(1,npy-1)-0.25*cosa_v(1,npy-1)*( &
864 ut(1,npy-1)+ut(1,npy-2)+ut(2,npy-2)+uc(2,npy-1) - &
865 0.25*cosa_u(2,npy-1)*(vt(1,npy)+vt(2,npy)+vt(2,npy-1))) ) * damp
887 xfx_adv(i,j) = dt*ut(i,j)
893 yfx_adv(i,j) = dt*vt(i,j)
904 if ( xfx_adv(i,j) > 0. )
then 905 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i-1,j)
906 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sin_sg(i-1,j,3)
908 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i,j)
909 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sin_sg(i,j,1)
916 if ( yfx_adv(i,j) > 0. )
then 917 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j-1)
918 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sin_sg(i,j-1,4)
920 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j)
921 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sin_sg(i,j,2)
932 ra_x(i,j) = area(i,j) + xfx_adv(i,j) - xfx_adv(i+1,j)
937 ra_y(i,j) = area(i,j) + yfx_adv(i,j) - yfx_adv(i,j+1)
942 call fv_tp_2d(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx, fy, &
943 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
944 regional,nord=nord_v, damp_c=damp_v)
949 cx(i,j) = cx(i,j) + crx_adv(i,j)
954 xflux(i,j) = xflux(i,j) + fx(i,j)
959 cy(i,j) = cy(i,j) + cry_adv(i,j)
962 yflux(i,j) = yflux(i,j) + fy(i,j)
969 heat_source(i,j) = 0.
974 if ( .not. hydrostatic )
then 975 if ( damp_w>1.e-5 )
then 977 damp4 = (damp_w*gridstruct%da_min_c)**(nord_w+1)
978 call del6_vt_flux(nord_w, npx, npy, damp4, w, wk, fx2, fy2, gridstruct, bd)
981 dw(i,j) = (fx2(i,j)-fx2(i+1,j)+fy2(i,j)-fy2(i,j+1))*rarea(i,j)
984 heat_source(i,j) = dd8 - dw(i,j)*(w(i,j)+0.5*dw(i,j))
985 diss_est(i,j) = heat_source(i,j)
989 call fv_tp_2d(w, crx_adv,cry_adv, npx, npy, hord_vt, gx, gy, xfx_adv, yfx_adv, &
990 gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
991 regional,mfx=fx, mfy=fy)
994 w(i,j) = delp(i,j)*w(i,j) + (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j)
1000 call fv_tp_2d(q_con, crx_adv,cry_adv, npx, npy, hord_dp, gx, gy, &
1001 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac,&
1002 regional, mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
1005 q_con(i,j) = delp(i,j)*q_con(i,j) + (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j)
1017 call fv_tp_2d(pt, crx_adv,cry_adv, npx, npy, hord_tm, gx, gy, &
1018 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
1019 regional,mfx=fx, mfy=fy, mass=delp, nord=nord_v, damp_c=damp_v)
1023 if ( inline_q )
then 1027 delp(i,j) = wk(i,j) + (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*rarea(i,j)
1031 pt(i,j) = (pt(i,j)*wk(i,j) + &
1032 (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j))/delp(i,j)
1037 call fv_tp_2d(q(isd,jsd,k,iq), crx_adv,cry_adv, npx, npy, hord_tr, gx, gy, &
1038 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
1039 regional,mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
1042 q(i,j,k,iq) = (q(i,j,k,iq)*wk(i,j) + &
1043 (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j))/delp(i,j)
1059 pt(i,j) = pt(i,j)*delp(i,j) + &
1060 (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j)
1062 delp(i,j) = delp(i,j) + &
1063 (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*rarea(i,j)
1065 pt(i,j) = pt(i,j) / delp(i,j)
1084 if (nested .or. regional)
then 1085 is2 = is; ie1 = ie+1
1086 js2 = js; je1 = je+1
1088 is2 = max(2,is); ie1 = min(npx-1,ie+1)
1089 js2 = max(2,js); je1 = min(npy-1,je+1)
1093 if (flagstruct%grid_type < 3)
then 1095 if (nested .or. regional)
then 1098 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j)-(uc(i,j-1)+uc(i,j))*cosa(i,j))*rsina(i,j)
1104 vb(i,1) = dt5*(vt(i-1,1)+vt(i,1))
1110 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j)-(uc(i,j-1)+uc(i,j))*cosa(i,j))*rsina(i,j)
1115 vb(1,j) = dt4*(-vt(-1,j) + 3.*(vt(0,j)+vt(1,j)) - vt(2,j))
1117 if ( (ie+1)==npx )
then 1119 vb(npx,j) = dt4*(-vt(npx-2,j) + 3.*(vt(npx-1,j)+vt(npx,j)) - vt(npx+1,j))
1123 if ( (je+1)==npy )
then 1125 vb(i,npy) = dt5*(vt(i-1,npy)+vt(i,npy))
1133 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j))
1138 call ytp_v(is,ie,js,je,isd,ied,jsd,jed, vb, u, v, ub, hord_mt, gridstruct%dy, gridstruct%rdy, &
1139 npx, npy, flagstruct%grid_type, nested, flagstruct%lim_fac, regional)
1143 ke(i,j) = vb(i,j)*ub(i,j)
1147 if (flagstruct%grid_type < 3)
then 1149 if (nested .or. regional)
then 1154 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j)-(vc(i-1,j)+vc(i,j))*cosa(i,j))*rsina(i,j)
1163 ub(1,j) = dt5*(ut(1,j-1)+ut(1,j))
1168 if ( (j==1 .or. j==npy) )
then 1171 ub(i,j) = dt4*(-ut(i,j-2) + 3.*(ut(i,j-1)+ut(i,j)) - ut(i,j+1))
1175 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j)-(vc(i-1,j)+vc(i,j))*cosa(i,j))*rsina(i,j)
1180 if ( (ie+1)==npx )
then 1182 ub(npx,j) = dt5*(ut(npx,j-1)+ut(npx,j))
1190 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j))
1195 call xtp_u(is,ie,js,je, isd,ied,jsd,jed, ub, u, v, vb, hord_mt, gridstruct%dx, gridstruct%rdx, &
1196 npx, npy, flagstruct%grid_type, nested, flagstruct%lim_fac, regional)
1200 ke(i,j) = 0.5*(ke(i,j) + ub(i,j)*vb(i,j))
1207 if (.not. (nested .or. regional))
then 1209 if ( sw_corner )
then 1210 ke(1,1) = dt6*( (ut(1,1) + ut(1,0)) * u(1,1) + &
1211 (vt(1,1) + vt(0,1)) * v(1,1) + &
1212 (ut(1,1) + vt(1,1)) * u(0,1) )
1214 if ( se_corner )
then 1216 ke(i,1) = dt6*( (ut(i,1) + ut(i, 0)) * u(i-1,1) + &
1217 (vt(i,1) + vt(i-1,1)) * v(i, 1) + &
1218 (ut(i,1) - vt(i-1,1)) * u(i, 1) )
1220 if ( ne_corner )
then 1222 ke(i,j) = dt6*( (ut(i,j ) + ut(i,j-1)) * u(i-1,j) + &
1223 (vt(i,j ) + vt(i-1,j)) * v(i,j-1) + &
1224 (ut(i,j-1) + vt(i-1,j)) * u(i,j ) )
1226 if ( nw_corner )
then 1228 ke(1,j) = dt6*( (ut(1, j) + ut(1,j-1)) * u(1,j ) + &
1229 (vt(1, j) + vt(0, j)) * v(1,j-1) + &
1230 (ut(1,j-1) - vt(1, j)) * u(0,j ) )
1237 vt(i,j) = u(i,j)*dx(i,j)
1242 ut(i,j) = v(i,j)*dy(i,j)
1249 wk(i,j) = rarea(i,j)*(vt(i,j)-vt(i,j+1)-ut(i,j)+ut(i+1,j))
1253 if ( .not. hydrostatic )
then 1254 if( flagstruct%do_f3d )
then 1259 w(i,j) = w(i,j)/delp(i,j) + dt2*gridstruct%w00(i,j) * &
1260 ( gridstruct%a11(i,j)*(u(i,j)+u(i,j+1)) + &
1261 gridstruct%a12(i,j)*(v(i,j)+v(i+1,j)) )
1268 w(i,j) = w(i,j)/delp(i,j)
1272 if ( damp_w>1.e-5 )
then 1275 w(i,j) = w(i,j) + dw(i,j)
1284 q_con(i,j) = q_con(i,j)/delp(i,j)
1297 if (nested .or. regional)
then 1301 ptc(i,j) = (u(i,j)-0.5*(va(i,j-1)+va(i,j))*cosa_v(i,j)) &
1302 *dyc(i,j)*sina_v(i,j)
1308 vort(i,j) = (v(i,j) - 0.5*(ua(i-1,j)+ua(i,j))*cosa_u(i,j)) &
1309 *dxc(i,j)*sina_u(i,j)
1316 if ( (j==1 .or. j==npy) )
then 1318 if (vc(i,j) > 0)
then 1319 ptc(i,j) = u(i,j)*dyc(i,j)*sin_sg(i,j-1,4)
1321 ptc(i,j) = u(i,j)*dyc(i,j)*sin_sg(i,j,2)
1326 ptc(i,j) = (u(i,j)-0.5*(va(i,j-1)+va(i,j))*cosa_v(i,j)) &
1327 *dyc(i,j)*sina_v(i,j)
1334 vort(i,j) = (v(i,j) - 0.5*(ua(i-1,j)+ua(i,j))*cosa_u(i,j)) &
1335 *dxc(i,j)*sina_u(i,j)
1338 if (uc(1,j) > 0)
then 1339 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(0,j,3)
1341 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(1,j,1)
1344 if ( (ie+1)==npx )
then 1345 if (uc(npx,j) > 0)
then 1346 vort(npx,j) = v(npx,j)*dxc(npx,j)* &
1349 vort(npx,j) = v(npx,j)*dxc(npx,j)* &
1358 delpc(i,j) = vort(i,j-1) - vort(i,j) + ptc(i-1,j) - ptc(i,j)
1363 if (sw_corner) delpc(1, 1) = delpc(1, 1) - vort(1, 0)
1364 if (se_corner) delpc(npx, 1) = delpc(npx, 1) - vort(npx, 0)
1365 if (ne_corner) delpc(npx,npy) = delpc(npx,npy) + vort(npx,npy)
1366 if (nw_corner) delpc(1, npy) = delpc(1, npy) + vort(1, npy)
1370 delpc(i,j) = gridstruct%rarea_c(i,j)*delpc(i,j)
1371 damp = gridstruct%da_min_c*max(d2_bg, min(0.20, dddmp*abs(delpc(i,j)*dt)))
1372 vort(i,j) = damp*delpc(i,j)
1373 ke(i,j) = ke(i,j) + vort(i,j)
1383 delpc(i,j) = divg_d(i,j)
1391 fill_c = (nt/=0) .and. (flagstruct%grid_type<3) .and. &
1392 ( sw_corner .or. se_corner .or. ne_corner .or. nw_corner ) &
1393 .and. .not. (nested .or. regional)
1395 if ( fill_c )
call fill_corners(divg_d, npx, npy, fill=xdir, bgrid=.true.)
1397 do i=is-1-nt,ie+1+nt
1398 vc(i,j) = (divg_d(i+1,j)-divg_d(i,j))*divg_u(i,j)
1402 if ( fill_c )
call fill_corners(divg_d, npx, npy, fill=ydir, bgrid=.true.)
1403 do j=js-1-nt,je+1+nt
1405 uc(i,j) = (divg_d(i,j+1)-divg_d(i,j))*divg_v(i,j)
1409 if ( fill_c )
call fill_corners(vc, uc, npx, npy, vector=.true., dgrid=.true.)
1412 divg_d(i,j) = uc(i,j-1) - uc(i,j) + vc(i-1,j) - vc(i,j)
1417 if (sw_corner) divg_d(1, 1) = divg_d(1, 1) - uc(1, 0)
1418 if (se_corner) divg_d(npx, 1) = divg_d(npx, 1) - uc(npx, 0)
1419 if (ne_corner) divg_d(npx,npy) = divg_d(npx,npy) + uc(npx,npy)
1420 if (nw_corner) divg_d(1, npy) = divg_d(1, npy) + uc(1, npy)
1422 if ( .not. gridstruct%stretched_grid )
then 1425 divg_d(i,j) = divg_d(i,j)*gridstruct%rarea_c(i,j)
1432 if ( dddmp<1.e-5)
then 1435 if ( flagstruct%grid_type < 3 )
then 1437 call a2b_ord4(wk, vort, gridstruct, npx, npy, is, ie, js, je, ng, .false.)
1441 vort(i,j) = abs(dt)*sqrt(delpc(i,j)**2 + vort(i,j)**2)
1445 call smag_corner(abs(dt), u, v, ua, va, vort, bd, npx, npy, gridstruct, ng)
1449 if (gridstruct%stretched_grid )
then 1451 dd8 = gridstruct%da_min * d4_bg**n2
1453 dd8 = ( gridstruct%da_min_c*d4_bg )**n2
1458 damp2 = gridstruct%da_min_c*max(d2_bg, min(0.20, dddmp*vort(i,j)))
1459 vort(i,j) = damp2*delpc(i,j) + dd8*divg_d(i,j)
1460 ke(i,j) = ke(i,j) + vort(i,j)
1466 if ( d_con > 1.e-5 )
then 1469 ub(i,j) = vort(i,j) - vort(i+1,j)
1474 vb(i,j) = vort(i,j) - vort(i,j+1)
1480 if ( hydrostatic )
then 1483 vort(i,j) = wk(i,j) + f0(i,j)
1487 if ( flagstruct%do_f3d )
then 1490 vort(i,j) = wk(i,j) + f0(i,j)*z_rat(i,j)
1496 vort(i,j) = wk(i,j) + f0(i,j)
1502 call fv_tp_2d(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx, fy, &
1503 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac,regional)
1506 u(i,j) = vt(i,j) + ke(i,j) - ke(i+1,j) + fy(i,j)
1511 v(i,j) = ut(i,j) + ke(i,j) - ke(i,j+1) - fx(i,j)
1517 if ( damp_v>1.e-5 )
then 1518 damp4 = (damp_v*gridstruct%da_min_c)**(nord_v+1)
1519 call del6_vt_flux(nord_v, npx, npy, damp4, wk, vort, ut, vt, gridstruct, bd)
1522 if ( d_con > 1.e-5 .or. flagstruct%do_skeb )
then 1525 ub(i,j) = (ub(i,j) + vt(i,j))*rdx(i,j)
1526 fy(i,j) = u(i,j)*rdx(i,j)
1527 gy(i,j) = fy(i,j)*ub(i,j)
1532 vb(i,j) = (vb(i,j) - ut(i,j))*rdy(i,j)
1533 fx(i,j) = v(i,j)*rdy(i,j)
1534 gx(i,j) = fx(i,j)*vb(i,j)
1543 u2 = fy(i,j) + fy(i,j+1)
1544 du2 = ub(i,j) + ub(i,j+1)
1545 v2 = fx(i,j) + fx(i+1,j)
1546 dv2 = vb(i,j) + vb(i+1,j)
1549 heat_source(i,j) = delp(i,j)*(heat_source(i,j) - damp*rsin2(i,j)*( &
1550 (ub(i,j)**2 + ub(i,j+1)**2 + vb(i,j)**2 + vb(i+1,j)**2) &
1551 + 2.*(gy(i,j)+gy(i,j+1)+gx(i,j)+gx(i+1,j)) &
1552 - cosa_s(i,j)*(u2*dv2 + v2*du2 + du2*dv2)) )
1553 if (flagstruct%do_skeb)
then 1554 diss_est(i,j) = diss_est(i,j)-rsin2(i,j)*( &
1555 (ub(i,j)**2 + ub(i,j+1)**2 + vb(i,j)**2 + vb(i+1,j)**2) &
1556 + 2.*(gy(i,j)+gy(i,j+1)+gx(i,j)+gx(i+1,j)) &
1557 - cosa_s(i,j)*(u2*dv2 + v2*du2 + du2*dv2))
1564 if ( damp_v>1.e-5 )
then 1567 u(i,j) = u(i,j) + vt(i,j)
1572 v(i,j) = v(i,j) - ut(i,j)
1585 subroutine del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
1593 integer,
intent(in):: nord, npx, npy
1594 real,
intent(in):: damp
1596 real,
intent(inout):: q(bd%isd:bd%ied, bd%jsd:bd%jed)
1599 real,
intent(out):: d2(bd%isd:bd%ied, bd%jsd:bd%jed)
1600 real,
intent(out):: fx2(bd%isd:bd%ied+1,bd%jsd:bd%jed), fy2(bd%isd:bd%ied,bd%jsd:bd%jed+1)
1601 integer i,j, nt, n, i1, i2, j1, j2
1603 logical :: nested, regional
1606 real,
pointer,
dimension(:,:,:) :: sin_sg
1607 real,
pointer,
dimension(:,:) :: rdxc, rdyc, dx,dy
1610 integer :: is, ie, js, je
1613 sin_sg => gridstruct%sin_sg
1614 rdxc => gridstruct%rdxc
1615 rdyc => gridstruct%rdyc
1619 nested = gridstruct%nested
1620 regional = gridstruct%regional
1626 i1 = is-1-nord; i2 = ie+1+nord
1627 j1 = js-1-nord; j2 = je+1+nord
1631 d2(i,j) = damp*q(i,j)
1635 if( nord>0 .and. (.not. (regional)))
call copy_corners(d2, npx, npy, 1, nested, bd, gridstruct%sw_corner, &
1636 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1637 do j=js-nord,je+nord
1638 do i=is-nord,ie+nord+1
1640 fx2(i,j) = 0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))*dy(i,j)*(d2(i-1,j)-d2(i,j))*rdxc(i,j)
1642 fx2(i,j) = gridstruct%del6_v(i,j)*(d2(i-1,j)-d2(i,j))
1647 if( nord>0 .and. (.not. (regional)))
call copy_corners(d2, npx, npy, 2, nested, bd, gridstruct%sw_corner, &
1648 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1649 do j=js-nord,je+nord+1
1650 do i=is-nord,ie+nord
1652 fy2(i,j) = 0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))*dx(i,j)*(d2(i,j-1)-d2(i,j))*rdyc(i,j)
1654 fy2(i,j) = gridstruct%del6_u(i,j)*(d2(i,j-1)-d2(i,j))
1662 do j=js-nt-1,je+nt+1
1663 do i=is-nt-1,ie+nt+1
1664 d2(i,j) = (fx2(i,j)-fx2(i+1,j)+fy2(i,j)-fy2(i,j+1))*gridstruct%rarea(i,j)
1668 if (.not. (regional))
call copy_corners(d2, npx, npy, 1, nested, bd, gridstruct%sw_corner, &
1669 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1674 fx2(i,j) = 0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))*dy(i,j)*(d2(i,j)-d2(i-1,j))*rdxc(i,j)
1676 fx2(i,j) = gridstruct%del6_v(i,j)*(d2(i,j)-d2(i-1,j))
1681 if (.not. (regional))
call copy_corners(d2, npx, npy, 2, nested, bd, &
1682 gridstruct%sw_corner, gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1687 fy2(i,j) = 0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))*dx(i,j)*(d2(i,j)-d2(i,j-1))*rdyc(i,j)
1689 fy2(i,j) = gridstruct%del6_u(i,j)*(d2(i,j)-d2(i,j-1))
1702 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1703 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v
1704 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1705 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1):: divg_d
1709 real uf(bd%is-2:bd%ie+2,bd%js-1:bd%je+2)
1710 real vf(bd%is-1:bd%ie+2,bd%js-2:bd%je+2)
1714 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
1715 real,
pointer,
dimension(:,:) :: dxc,dyc
1717 integer :: is, ie, js, je
1719 logical :: nested, regional
1726 npx = flagstruct%npx
1727 npy = flagstruct%npy
1728 nested = gridstruct%nested
1729 regional = gridstruct%regional
1731 sin_sg => gridstruct%sin_sg
1732 cos_sg => gridstruct%cos_sg
1733 dxc => gridstruct%dxc
1734 dyc => gridstruct%dyc
1736 if (nested .or. regional)
then 1737 is2 = is; ie1 = ie+1
1739 is2 = max(2,is); ie1 = min(npx-1,ie+1)
1742 if (flagstruct%grid_type==4)
then 1745 uf(i,j) = u(i,j)*dyc(i,j)
1750 vf(i,j) = v(i,j)*dxc(i,j)
1755 divg_d(i,j) = gridstruct%rarea_c(i,j)*(vf(i,j-1)-vf(i,j)+uf(i-1,j)-uf(i,j))
1765 if ( j==1 .or. j==npy )
then 1767 uf(i,j) = u(i,j)*dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1771 uf(i,j) = (u(i,j)-0.25*(va(i,j-1)+va(i,j))*(cos_sg(i,j-1,4)+cos_sg(i,j,2))) &
1772 * dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1779 vf(i,j) = (v(i,j) - 0.25*(ua(i-1,j)+ua(i,j))*(cos_sg(i-1,j,3)+cos_sg(i,j,1))) &
1780 *dxc(i,j)*0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))
1782 if ( is == 1 ) vf(1, j) = v(1, j)*dxc(1, j)*0.5*(sin_sg(0,j,3)+sin_sg(1,j,1))
1783 if ( (ie+1)==npx ) vf(npx,j) = v(npx,j)*dxc(npx,j)*0.5*(sin_sg(npx-1,j,3)+sin_sg(npx,j,1))
1788 divg_d(i,j) = vf(i,j-1) - vf(i,j) + uf(i-1,j) - uf(i,j)
1793 if (gridstruct%sw_corner) divg_d(1, 1) = divg_d(1, 1) - vf(1, 0)
1794 if (gridstruct%se_corner) divg_d(npx, 1) = divg_d(npx, 1) - vf(npx, 0)
1795 if (gridstruct%ne_corner) divg_d(npx,npy) = divg_d(npx,npy) + vf(npx,npy)
1796 if (gridstruct%nw_corner) divg_d(1, npy) = divg_d(1, npy) + vf(1, npy)
1800 divg_d(i,j) = gridstruct%rarea_c(i,j)*divg_d(i,j)
1810 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1811 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed):: v
1812 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1813 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1):: divg_d
1818 real uf(bd%isd:bd%ied,bd%jsd:bd%jed+1)
1819 real vf(bd%isd:bd%ied+1,bd%jsd:bd%jed)
1823 real,
pointer,
dimension(:,:) :: rarea_c
1825 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
1826 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v
1827 real,
pointer,
dimension(:,:) :: sina_u, sina_v
1828 real,
pointer,
dimension(:,:) :: dxc,dyc
1830 integer :: isd, ied, jsd, jed
1832 logical :: nested, regional
1839 npx = flagstruct%npx
1840 npy = flagstruct%npy
1841 nested = gridstruct%nested
1842 regional = gridstruct%regional
1844 rarea_c => gridstruct%rarea_c
1845 sin_sg => gridstruct%sin_sg
1846 cos_sg => gridstruct%cos_sg
1847 cosa_u => gridstruct%cosa_u
1848 cosa_v => gridstruct%cosa_v
1849 sina_u => gridstruct%sina_u
1850 sina_v => gridstruct%sina_v
1851 dxc => gridstruct%dxc
1852 dyc => gridstruct%dyc
1856 if (flagstruct%grid_type==4)
then 1859 uf(i,j) = u(i,j)*dyc(i,j)
1864 vf(i,j) = v(i,j)*dxc(i,j)
1869 divg_d(i,j) = rarea_c(i,j)*(vf(i,j-1)-vf(i,j)+uf(i-1,j)-uf(i,j))
1876 uf(i,j) = (u(i,j)-0.25*(va(i,j-1)+va(i,j))*(cos_sg(i,j-1,4)+cos_sg(i,j,2))) &
1877 * dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1883 vf(i,j) = (v(i,j) - 0.25*(ua(i-1,j)+ua(i,j))*(cos_sg(i-1,j,3)+cos_sg(i,j,1))) &
1884 *dxc(i,j)*0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))
1890 divg_d(i,j) = (vf(i,j-1) - vf(i,j) + uf(i-1,j) - uf(i,j))*rarea_c(i,j)
1920 subroutine smag_corner(dt, u, v, ua, va, smag_c, bd, npx, npy, gridstruct, ng)
1924 real,
intent(in):: dt
1925 integer,
intent(IN) :: npx, npy, ng
1926 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1927 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v
1928 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1929 real,
intent(out),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: smag_c
1932 real:: ut(bd%isd:bd%ied+1,bd%jsd:bd%jed)
1933 real:: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1934 real:: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
1935 real:: sh(bd%isd:bd%ied,bd%jsd:bd%jed)
1939 real,
pointer,
dimension(:,:) :: dxc, dyc, dx, dy, rarea, rarea_c
1941 integer :: is, ie, js, je
1942 integer :: isd, ied, jsd, jed
1954 dxc => gridstruct%dxc
1955 dyc => gridstruct%dyc
1958 rarea => gridstruct%rarea
1959 rarea_c => gridstruct%rarea_c
1961 is2 = max(2,is); ie1 = min(npx-1,ie+1)
1968 ut(i,j) = u(i,j)*dyc(i,j)
1973 vt(i,j) = v(i,j)*dxc(i,j)
1978 smag_c(i,j) = rarea_c(i,j)*(vt(i,j-1)-vt(i,j)-ut(i-1,j)+ut(i,j))
1986 vt(i,j) = u(i,j)*dx(i,j)
1991 ut(i,j) = v(i,j)*dy(i,j)
1997 wk(i,j) = rarea(i,j)*(vt(i,j)-vt(i,j+1)+ut(i,j)-ut(i+1,j))
2000 call a2b_ord4(wk, sh, gridstruct, npx, npy, is, ie, js, je, ng, .false.)
2003 smag_c(i,j) = dt*sqrt( sh(i,j)**2 + smag_c(i,j)**2 )
2010 subroutine xtp_u(is,ie,js,je,isd,ied,jsd,jed,c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, nested, lim_fac, regional)
2012 integer,
intent(in):: is,ie,js,je, isd,ied,jsd,jed
2013 real,
INTENT(IN):: u(isd:ied,jsd:jed+1)
2014 real,
INTENT(IN):: v(isd:ied+1,jsd:jed)
2015 real,
INTENT(IN):: c(is:ie+1,js:je+1)
2016 real,
INTENT(out):: flux(is:ie+1,js:je+1)
2017 real,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
2018 real,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
2019 integer,
INTENT(IN) :: iord, npx, npy, grid_type
2020 logical,
INTENT(IN) :: nested,regional
2021 real,
INTENT(IN) :: lim_fac
2023 real,
dimension(is-1:ie+1):: bl, br, b0
2024 logical,
dimension(is-1:ie+1):: smt5, smt6
2025 logical,
dimension(is:ie+1):: hi5, hi6
2027 real al(is-1:ie+2), dm(is-2:ie+2)
2029 real dl, dr, xt, pmp, lac, cfl
2030 real pmp_1, lac_1, pmp_2, lac_2
2031 real x0, x1, x0L, x0R
2036 if ( nested .or. regional .or. grid_type>3 )
then 2037 is3 = is-1 ; ie3 = ie+1
2039 is3 = max(3,is-1) ; ie3 = min(npx-3,ie+1)
2043 if ( iord < 8 )
then 2049 al(i) =
p1*(u(i-1,j)+u(i,j)) +
p2*(u(i-2,j)+u(i+1,j))
2052 bl(i) = al(i ) - u(i,j)
2053 br(i) = al(i+1) - u(i,j)
2056 if ( (.not. (nested .or. regional)) .and. grid_type < 3)
then 2058 xt =
c3*u(1,j) +
c2*u(2,j) +
c1*u(3,j)
2061 br(2) = al(3) - u(2,j)
2062 if( j==1 .or. j==npy )
then 2068 bl(0) =
c1*u(-2,j) +
c2*u(-1,j) +
c3*u(0,j) - u(0,j)
2069 xt = 0.5*( ((2.*dx(0,j)+dx(-1,j))*(u(0,j))-dx(0,j)*u(-1,j))/(dx(0,j)+dx(-1,j)) &
2070 + ((2.*dx(1,j)+dx( 2,j))*(u(1,j))-dx(1,j)*u( 2,j))/(dx(1,j)+dx( 2,j)) )
2076 if ( (ie+1)==npx )
then 2077 bl(npx-2) = al(npx-2) - u(npx-2,j)
2078 xt =
c1*u(npx-3,j) +
c2*u(npx-2,j) +
c3*u(npx-1,j)
2079 br(npx-2) = xt - u(npx-2,j)
2080 bl(npx-1) = xt - u(npx-1,j)
2081 if( j==1 .or. j==npy )
then 2087 xt = 0.5*( ( (2.*dx(npx-1,j)+dx(npx-2,j))*u(npx-1,j)-dx(npx-1,j)*u(npx-2,j))/(dx(npx-1,j)+dx(npx-2,j)) &
2088 + ( (2.*dx(npx ,j)+dx(npx+1,j))*u(npx ,j)-dx(npx ,j)*u(npx+1,j))/(dx(npx ,j)+dx(npx+1,j)) )
2089 br(npx-1) = xt - u(npx-1,j)
2090 bl(npx ) = xt - u(npx ,j)
2091 br(npx) =
c3*u(npx,j) +
c2*u(npx+1,j) +
c1*u(npx+2,j) - u(npx,j)
2098 b0(i) = bl(i) + br(i)
2104 smt5(i) = abs(lim_fac*b0(i)) < abs(bl(i)-br(i))
2108 if( c(i,j)>0. )
then 2109 cfl = c(i,j)*rdx(i-1,j)
2110 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2111 flux(i,j) = u(i-1,j)
2113 cfl = c(i,j)*rdx(i,j)
2114 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2117 if (smt5(i-1).or.smt5(i)) flux(i,j) = flux(i,j) + fx0(i)
2120 elseif ( iord==2 )
then 2124 if( c(i,j)>0. )
then 2125 cfl = c(i,j)*rdx(i-1,j)
2126 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2128 cfl = c(i,j)*rdx(i,j)
2129 flux(i,j) = u(i,j) + (1.+cfl)*(bl(i)+cfl*b0(i))
2133 elseif ( iord==3 )
then 2137 x1 = abs(bl(i)-br(i))
2139 smt6(i) = 3.*x0 < x1
2143 hi5(i) = smt5(i-1) .and. smt5(i)
2144 hi6(i) = smt6(i-1) .or. smt6(i)
2147 if( c(i,j)>0. )
then 2148 cfl = c(i,j)*rdx(i-1,j)
2150 fx0(i) = br(i-1) - cfl*b0(i-1)
2151 elseif( hi5(i) )
then 2152 fx0(i) = sign(min(abs(bl(i-1)),abs(br(i-1))), br(i-1))
2154 flux(i,j) = u(i-1,j) + (1.-cfl)*fx0(i)
2156 cfl = c(i,j)*rdx(i,j)
2158 fx0(i) = bl(i) + cfl*b0(i)
2159 elseif( hi5(i) )
then 2160 fx0(i) = sign(min(abs(bl(i)),abs(br(i))), bl(i))
2162 flux(i,j) = u(i,j) + (1.+cfl)*fx0(i)
2166 elseif ( iord==4 )
then 2170 x1 = abs(bl(i)-br(i))
2172 smt6(i) = 3.*x0 < x1
2175 hi5(i) = smt5(i-1) .and. smt5(i)
2176 hi6(i) = smt6(i-1) .or. smt6(i)
2177 hi5(i) = hi5(i) .or. hi6(i)
2181 if( c(i,j)>0. )
then 2182 cfl = c(i,j)*rdx(i-1,j)
2183 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2184 flux(i,j) = u(i-1,j)
2186 cfl = c(i,j)*rdx(i,j)
2187 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2190 if ( hi5(i) ) flux(i,j) = flux(i,j) + fx0(i)
2197 smt5(i) = bl(i)*br(i) < 0.
2201 smt5(i) = 3.*abs(b0(i)) < abs(bl(i)-br(i))
2207 if( c(i,j)>0. )
then 2208 cfl = c(i,j)*rdx(i-1,j)
2209 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2210 flux(i,j) = u(i-1,j)
2212 cfl = c(i,j)*rdx(i,j)
2213 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2216 if (smt5(i-1).or.smt5(i)) flux(i,j) = flux(i,j) + fx0(i)
2227 xt = 0.25*(u(i+1,j) - u(i-1,j))
2228 dm(i) = sign(min(abs(xt), max(u(i-1,j), u(i,j), u(i+1,j)) - u(i,j), &
2229 u(i,j) - min(u(i-1,j), u(i,j), u(i+1,j))), xt)
2232 dq(i) = u(i+1,j) - u(i,j)
2235 if (grid_type < 3)
then 2238 al(i) = 0.5*(u(i-1,j)+u(i,j)) +
r3*(dm(i-1) - dm(i))
2245 bl(i) = -sign(min(abs(xt), abs(al(i )-u(i,j))), xt)
2246 br(i) = sign(min(abs(xt), abs(al(i+1)-u(i,j))), xt)
2248 elseif( iord==9 )
then 2251 lac_1 = pmp_1 + 1.5*dq(i+1)
2252 bl(i) = min(max(0., pmp_1, lac_1), max(al(i )-u(i,j), min(0., pmp_1, lac_1)))
2254 lac_2 = pmp_2 - 1.5*dq(i-2)
2255 br(i) = min(max(0., pmp_2, lac_2), max(al(i+1)-u(i,j), min(0., pmp_2, lac_2)))
2257 elseif( iord==10 )
then 2259 bl(i) = al(i ) - u(i,j)
2260 br(i) = al(i+1) - u(i,j)
2263 if ( abs(dm(i-1))+abs(dm(i+1)) <
near_zero )
then 2268 elseif( abs(3.*(bl(i)+br(i))) > abs(bl(i)-br(i)) )
then 2270 lac_1 = pmp_1 + 1.5*dq(i+1)
2271 bl(i) = min(max(0., pmp_1, lac_1), max(bl(i), min(0., pmp_1, lac_1)))
2273 lac_2 = pmp_2 - 1.5*dq(i-2)
2274 br(i) = min(max(0., pmp_2, lac_2), max(br(i), min(0., pmp_2, lac_2)))
2280 bl(i) = al(i ) - u(i,j)
2281 br(i) = al(i+1) - u(i,j)
2289 if ( is==1 .and. .not. (nested .or. regional))
then 2290 br(2) = al(3) - u(2,j)
2291 xt =
s15*u(1,j) +
s11*u(2,j) -
s14*dm(2)
2294 if( j==1 .or. j==npy )
then 2300 bl(0) =
s14*dm(-1) -
s11*dq(-1)
2301 x0l = 0.5*((2.*dx(0,j)+dx(-1,j))*(u(0,j)) &
2302 - dx(0,j)*(u(-1,j)))/(dx(0,j)+dx(-1,j))
2303 x0r = 0.5*((2.*dx(1,j)+dx(2,j))*(u(1,j)) &
2304 - dx(1,j)*(u(2,j)))/(dx(1,j)+dx(2,j))
2309 call pert_ppm(1, u(2,j), bl(2), br(2), -1)
2312 if ( (ie+1)==npx .and. .not. (nested .or. regional))
then 2313 bl(npx-2) = al(npx-2) - u(npx-2,j)
2314 xt =
s15*u(npx-1,j) +
s11*u(npx-2,j) +
s14*dm(npx-2)
2315 br(npx-2) = xt - u(npx-2,j)
2316 bl(npx-1) = xt - u(npx-1,j)
2317 if( j==1 .or. j==npy )
then 2323 br(npx) =
s11*dq(npx) -
s14*dm(npx+1)
2324 x0l = 0.5*( (2.*dx(npx-1,j)+dx(npx-2,j))*(u(npx-1,j)) &
2325 - dx(npx-1,j)*(u(npx-2,j)))/(dx(npx-1,j)+dx(npx-2,j))
2326 x0r = 0.5*( (2.*dx(npx,j)+dx(npx+1,j))*(u(npx,j)) &
2327 - dx(npx,j)*(u(npx+1,j)))/(dx(npx,j)+dx(npx+1,j))
2329 br(npx-1) = xt - u(npx-1,j)
2330 bl(npx ) = xt - u(npx ,j)
2332 call pert_ppm(1, u(npx-2,j), bl(npx-2), br(npx-2), -1)
2338 al(i) = 0.5*(u(i-1,j)+u(i,j)) +
r3*(dm(i-1) - dm(i))
2343 lac = pmp + 1.5*dq(i+1)
2344 bl(i) = min(max(0., pmp, lac), max(al(i )-u(i,j), min(0.,pmp, lac)))
2346 lac = pmp - 1.5*dq(i-2)
2347 br(i) = min(max(0., pmp, lac), max(al(i+1)-u(i,j), min(0.,pmp, lac)))
2352 if( c(i,j)>0. )
then 2353 cfl = c(i,j)*rdx(i-1,j)
2354 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1)-cfl*(bl(i-1)+br(i-1)))
2356 cfl = c(i,j)*rdx(i,j)
2357 flux(i,j) = u(i, j) + (1.+cfl)*(bl(i )+cfl*(bl(i )+br(i )))
2364 end subroutine xtp_u 2367 subroutine ytp_v(is,ie,js,je,isd,ied,jsd,jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, nested, lim_fac, regional)
2368 integer,
intent(in):: is,ie,js,je, isd,ied,jsd,jed
2369 integer,
intent(IN):: jord
2370 real,
INTENT(IN) :: u(isd:ied,jsd:jed+1)
2371 real,
INTENT(IN) :: v(isd:ied+1,jsd:jed)
2372 real,
INTENT(IN) :: c(is:ie+1,js:je+1)
2373 real,
INTENT(OUT):: flux(is:ie+1,js:je+1)
2374 real,
INTENT(IN) :: dy(isd:ied+1,jsd:jed)
2375 real,
INTENT(IN) :: rdy(isd:ied+1,jsd:jed)
2376 integer,
INTENT(IN) :: npx, npy, grid_type
2377 logical,
INTENT(IN) :: nested,regional
2378 real,
INTENT(IN) :: lim_fac
2380 logical,
dimension(is:ie+1,js-1:je+1):: smt5, smt6
2381 logical,
dimension(is:ie+1):: hi5, hi6
2383 real dm(is:ie+1,js-2:je+2)
2384 real al(is:ie+1,js-1:je+2)
2385 real,
dimension(is:ie+1,js-1:je+1):: bl, br, b0
2386 real dq(is:ie+1,js-3:je+2)
2387 real xt, dl, dr, pmp, lac, cfl
2388 real pmp_1, lac_1, pmp_2, lac_2
2389 real x0, x1, x0R, x0L
2390 integer i, j, is1, ie1, js3, je3
2392 if ( nested .or. regional .or. grid_type>3 )
then 2393 js3 = js-1; je3 = je+1
2395 js3 = max(3,js-1); je3 = min(npy-3,je+1)
2403 al(i,j) =
p1*(v(i,j-1)+v(i,j)) +
p2*(v(i,j-2)+v(i,j+1))
2408 bl(i,j) = al(i,j ) - v(i,j)
2409 br(i,j) = al(i,j+1) - v(i,j)
2413 if ( (.not. (nested .or. regional)) .and. grid_type < 3)
then 2416 bl(i,0) =
c1*v(i,-2) +
c2*v(i,-1) +
c3*v(i,0) - v(i,0)
2417 xt = 0.5*( ((2.*dy(i,0)+dy(i,-1))*v(i,0)-dy(i,0)*v(i,-1))/(dy(i,0)+dy(i,-1)) &
2418 + ((2.*dy(i,1)+dy(i, 2))*v(i,1)-dy(i,1)*v(i, 2))/(dy(i,1)+dy(i, 2)) )
2419 br(i,0) = xt - v(i,0)
2420 bl(i,1) = xt - v(i,1)
2421 xt =
c3*v(i,1) +
c2*v(i,2) +
c1*v(i,3)
2422 br(i,1) = xt - v(i,1)
2423 bl(i,2) = xt - v(i,2)
2424 br(i,2) = al(i,3) - v(i,2)
2432 if ( (ie+1)==npx )
then 2441 if( (je+1)==npy )
then 2443 bl(i,npy-2) = al(i,npy-2) - v(i,npy-2)
2444 xt =
c1*v(i,npy-3) +
c2*v(i,npy-2) +
c3*v(i,npy-1)
2445 br(i,npy-2) = xt - v(i,npy-2)
2446 bl(i,npy-1) = xt - v(i,npy-1)
2447 xt = 0.5*( ((2.*dy(i,npy-1)+dy(i,npy-2))*v(i,npy-1)-dy(i,npy-1)*v(i,npy-2))/(dy(i,npy-1)+dy(i,npy-2)) &
2448 + ((2.*dy(i,npy )+dy(i,npy+1))*v(i,npy )-dy(i,npy )*v(i,npy+1))/(dy(i,npy )+dy(i,npy+1)) )
2449 br(i,npy-1) = xt - v(i,npy-1)
2450 bl(i,npy ) = xt - v(i,npy)
2451 br(i,npy) =
c3*v(i,npy)+
c2*v(i,npy+1) +
c1*v(i,npy+2) - v(i,npy)
2459 if ( (ie+1)==npx )
then 2472 b0(i,j) = bl(i,j) + br(i,j)
2480 smt5(i,j) = abs(lim_fac*b0(i,j)) < abs(bl(i,j)-br(i,j))
2486 if( c(i,j)>0. )
then 2487 cfl = c(i,j)*rdy(i,j-1)
2488 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2489 flux(i,j) = v(i,j-1)
2491 cfl = c(i,j)*rdy(i,j)
2492 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2495 if (smt5(i,j-1).or.smt5(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2499 elseif ( jord==2 )
then 2503 if( c(i,j)>0. )
then 2504 cfl = c(i,j)*rdy(i,j-1)
2505 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2507 cfl = c(i,j)*rdy(i,j)
2508 flux(i,j) = v(i,j) + (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2513 elseif ( jord==3 )
then 2518 x1 = abs(bl(i,j)-br(i,j))
2520 smt6(i,j) = 3.*x0 < x1
2526 hi5(i) = smt5(i,j-1) .and. smt5(i,j)
2527 hi6(i) = smt6(i,j-1) .or. smt6(i,j)
2530 if( c(i,j)>0. )
then 2531 cfl = c(i,j)*rdy(i,j-1)
2533 fx0(i) = br(i,j-1) - cfl*b0(i,j-1)
2534 elseif ( hi5(i) )
then 2535 fx0(i) = sign(min(abs(bl(i,j-1)),abs(br(i,j-1))), br(i,j-1))
2537 flux(i,j) = v(i,j-1) + (1.-cfl)*fx0(i)
2539 cfl = c(i,j)*rdy(i,j)
2541 fx0(i) = bl(i,j) + cfl*b0(i,j)
2542 elseif ( hi5(i) )
then 2543 fx0(i) = sign(min(abs(bl(i,j)),abs(br(i,j))), bl(i,j))
2545 flux(i,j) = v(i,j) + (1.+cfl)*fx0(i)
2550 elseif ( jord==4 )
then 2555 x1 = abs(bl(i,j)-br(i,j))
2557 smt6(i,j) = 3.*x0 < x1
2563 hi5(i) = smt5(i,j-1) .and. smt5(i,j)
2564 hi6(i) = smt6(i,j-1) .or. smt6(i,j)
2565 hi5(i) = hi5(i) .or. hi6(i)
2569 if( c(i,j)>0. )
then 2570 cfl = c(i,j)*rdy(i,j-1)
2571 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2572 flux(i,j) = v(i,j-1)
2574 cfl = c(i,j)*rdy(i,j)
2575 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2578 if ( hi5(i) ) flux(i,j) = flux(i,j) + fx0(i)
2587 smt5(i,j) = bl(i,j)*br(i,j) < 0.
2593 if( c(i,j)>0. )
then 2594 cfl = c(i,j)*rdy(i,j-1)
2595 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2596 flux(i,j) = v(i,j-1)
2598 cfl = c(i,j)*rdy(i,j)
2599 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2602 if (smt5(i,j-1).or.smt5(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2609 smt6(i,j) = 3.*abs(b0(i,j)) < abs(bl(i,j)-br(i,j))
2615 if( c(i,j)>0. )
then 2616 cfl = c(i,j)*rdy(i,j-1)
2617 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2618 flux(i,j) = v(i,j-1)
2620 cfl = c(i,j)*rdy(i,j)
2621 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2624 if (smt6(i,j-1).or.smt6(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2636 xt = 0.25*(v(i,j+1) - v(i,j-1))
2637 dm(i,j) = sign(min(abs(xt), max(v(i,j-1), v(i,j), v(i,j+1)) - v(i,j), &
2638 v(i,j) - min(v(i,j-1), v(i,j), v(i,j+1))), xt)
2644 dq(i,j) = v(i,j+1) - v(i,j)
2648 if (grid_type < 3)
then 2651 al(i,j) = 0.5*(v(i,j-1)+v(i,j)) +
r3*(dm(i,j-1)-dm(i,j))
2659 bl(i,j) = -sign(min(abs(xt), abs(al(i,j)-v(i,j))), xt)
2660 br(i,j) = sign(min(abs(xt), abs(al(i,j+1)-v(i,j))), xt)
2663 elseif ( jord==9 )
then 2667 lac_1 = pmp_1 + 1.5*dq(i,j+1)
2668 bl(i,j) = min(max(0., pmp_1, lac_1), max(al(i,j)-v(i,j), min(0., pmp_1, lac_1)))
2669 pmp_2 = 2.*dq(i,j-1)
2670 lac_2 = pmp_2 - 1.5*dq(i,j-2)
2671 br(i,j) = min(max(0., pmp_2, lac_2), max(al(i,j+1)-v(i,j), min(0., pmp_2, lac_2)))
2674 elseif ( jord==10 )
then 2677 bl(i,j) = al(i,j ) - v(i,j)
2678 br(i,j) = al(i,j+1) - v(i,j)
2681 if ( abs(dm(i,j-1))+abs(dm(i,j+1)) <
near_zero )
then 2685 elseif( abs(3.*(bl(i,j)+br(i,j))) > abs(bl(i,j)-br(i,j)) )
then 2687 lac_1 = pmp_1 + 1.5*dq(i,j+1)
2688 bl(i,j) = min(max(0., pmp_1, lac_1), max(bl(i,j), min(0., pmp_1, lac_1)))
2689 pmp_2 = 2.*dq(i,j-1)
2690 lac_2 = pmp_2 - 1.5*dq(i,j-2)
2691 br(i,j) = min(max(0., pmp_2, lac_2), max(br(i,j), min(0., pmp_2, lac_2)))
2699 bl(i,j) = al(i,j ) - v(i,j)
2700 br(i,j) = al(i,j+1) - v(i,j)
2708 if( js==1 .and. .not. (nested .or. regional))
then 2710 br(i,2) = al(i,3) - v(i,2)
2711 xt =
s15*v(i,1) +
s11*v(i,2) -
s14*dm(i,2)
2712 br(i,1) = xt - v(i,1)
2713 bl(i,2) = xt - v(i,2)
2715 bl(i,0) =
s14*dm(i,-1) -
s11*dq(i,-1)
2718 xt =
t14*v(i,1) +
t12*v(i,2) +
t15*v(i,3)
2719 bl(i,1) = 2.*xt - v(i,1)
2720 xt =
t14*v(i,0) +
t12*v(i,-1) +
t15*v(i,-2)
2721 br(i,0) = 2.*xt - v(i,0)
2723 x0l = 0.5*( (2.*dy(i,0)+dy(i,-1))*(v(i,0)) &
2724 - dy(i,0)*(v(i,-1)))/(dy(i,0)+dy(i,-1))
2725 x0r = 0.5*( (2.*dy(i,1)+dy(i,2))*(v(i,1)) &
2726 - dy(i,1)*(v(i,2)))/(dy(i,1)+dy(i,2))
2729 bl(i,1) = xt - v(i,1)
2730 br(i,0) = xt - v(i,0)
2739 if ( (ie+1)==npx )
then 2746 call pert_ppm(ie-is+2, v(is,j), bl(is,j), br(is,j), -1)
2748 if( (je+1)==npy .and. .not. (nested .or. regional))
then 2750 bl(i,npy-2) = al(i,npy-2) - v(i,npy-2)
2751 xt =
s15*v(i,npy-1) +
s11*v(i,npy-2) +
s14*dm(i,npy-2)
2752 br(i,npy-2) = xt - v(i,npy-2)
2753 bl(i,npy-1) = xt - v(i,npy-1)
2754 br(i,npy) =
s11*dq(i,npy) -
s14*dm(i,npy+1)
2756 xt =
t14*v(i,npy-1) +
t12*v(i,npy-2) +
t15*v(i,npy-3)
2757 br(i,npy-1) = 2.*xt - v(i,npy-1)
2758 xt =
t14*v(i,npy) +
t12*v(i,npy+1) +
t15*v(i,npy+2)
2759 bl(i,npy ) = 2.*xt - v(i,npy)
2761 x0l= 0.5*((2.*dy(i,npy-1)+dy(i,npy-2))*(v(i,npy-1)) - &
2762 dy(i,npy-1)*(v(i,npy-2)))/(dy(i,npy-1)+dy(i,npy-2))
2763 x0r= 0.5*((2.*dy(i,npy)+dy(i,npy+1))*(v(i,npy)) - &
2764 dy(i,npy)*(v(i,npy+1)))/(dy(i,npy)+dy(i,npy+1))
2767 br(i,npy-1) = xt - v(i,npy-1)
2768 bl(i,npy ) = xt - v(i,npy)
2777 if ( (ie+1)==npx )
then 2784 call pert_ppm(ie-is+2, v(is,j), bl(is,j), br(is,j), -1)
2791 al(i,j) = 0.5*(v(i,j-1)+v(i,j)) +
r3*(dm(i,j-1)-dm(i,j))
2798 lac = pmp - 1.5*dq(i,j-2)
2799 br(i,j) = min(max(0.,pmp,lac), max(al(i,j+1)-v(i,j), min(0.,pmp,lac)))
2801 lac = pmp + 1.5*dq(i,j+1)
2802 bl(i,j) = min(max(0.,pmp,lac), max(al(i,j)-v(i,j), min(0.,pmp,lac)))
2811 cfl = c(i,j)*rdy(i,j-1)
2812 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1)-cfl*(bl(i,j-1)+br(i,j-1)))
2814 cfl = c(i,j)*rdy(i,j)
2815 flux(i,j) = v(i,j ) + (1.+cfl)*(bl(i,j )+cfl*(bl(i,j )+br(i,j )))
2822 end subroutine ytp_v 2830 subroutine d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, &
2831 bd, npx, npy, nested, grid_type, regional )
2833 logical,
intent(in):: dord4
2834 real,
intent(in) :: u(bd%isd:bd%ied,bd%jsd:bd%jed+1)
2835 real,
intent(in) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed)
2836 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: uc
2837 real,
intent(out),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1):: vc
2838 real,
intent(out),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed ):: ua, va, ut, vt
2839 integer,
intent(IN) :: npx, npy, grid_type
2840 logical,
intent(IN) :: nested,regional
2843 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: utmp, vtmp
2844 integer npt, i, j, ifirst, ilast, id
2845 integer :: is, ie, js, je
2846 integer :: isd, ied, jsd, jed
2848 real,
pointer,
dimension(:,:,:) :: sin_sg
2849 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v, cosa_s
2850 real,
pointer,
dimension(:,:) :: rsin_u, rsin_v, rsin2
2851 real,
pointer,
dimension(:,:) :: dxa,dya
2862 sin_sg => gridstruct%sin_sg
2863 cosa_u => gridstruct%cosa_u
2864 cosa_v => gridstruct%cosa_v
2865 cosa_s => gridstruct%cosa_s
2866 rsin_u => gridstruct%rsin_u
2867 rsin_v => gridstruct%rsin_v
2868 rsin2 => gridstruct%rsin2
2869 dxa => gridstruct%dxa
2870 dya => gridstruct%dya
2878 if (grid_type < 3 .and. .not. (nested .or. regional))
then 2888 if ( nested .or. regional)
then 2892 utmp(i,j) =
a2*(u(i,j-1)+u(i,j+2)) +
a1*(u(i,j)+u(i,j+1))
2897 utmp(i,j) = 0.5*(u(i,j)+u(i,j+1))
2899 utmp(i,j) = 0.5*(u(i,j)+u(i,j+1))
2904 vtmp(i,j) =
a2*(v(i-1,j)+v(i+2,j)) +
a1*(v(i,j)+v(i+1,j))
2907 vtmp(i,j) = 0.5*(v(i,j)+v(i+1,j))
2909 vtmp(i,j) = 0.5*(v(i,j)+v(i+1,j))
2914 ua(i,j) = (utmp(i,j)-vtmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2915 va(i,j) = (vtmp(i,j)-utmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2923 do j=max(npt,js-1),min(npy-npt,je+1)
2924 do i=max(npt,isd),min(npx-npt,ied)
2925 utmp(i,j) =
a2*(u(i,j-1)+u(i,j+2)) +
a1*(u(i,j)+u(i,j+1))
2928 do j=max(npt,jsd),min(npy-npt,jed)
2929 do i=max(npt,is-1),min(npx-npt,ie+1)
2930 vtmp(i,j) =
a2*(v(i-1,j)+v(i+2,j)) +
a1*(v(i,j)+v(i+1,j))
2937 if (grid_type < 3)
then 2939 if ( js==1 .or. jsd<npt)
then 2942 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2943 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2947 if ( (je+1)==npy .or. jed>=(npy-npt))
then 2950 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2951 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2956 if ( is==1 .or. isd<npt )
then 2957 do j=max(npt,jsd),min(npy-npt,jed)
2959 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2960 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2964 if ( (ie+1)==npx .or. ied>=(npx-npt))
then 2965 do j=max(npt,jsd),min(npy-npt,jed)
2967 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2968 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2976 do j=js-1-id,je+1+id
2977 do i=is-1-id,ie+1+id
2978 ua(i,j) = (utmp(i,j)-vtmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2979 va(i,j) = (vtmp(i,j)-utmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2990 if( gridstruct%sw_corner )
then 2992 utmp(i,0) = -vtmp(0,1-i)
2995 if( gridstruct%se_corner )
then 2997 utmp(npx+i,0) = vtmp(npx,i+1)
3000 if( gridstruct%ne_corner )
then 3002 utmp(npx+i,npy) = -vtmp(npx,je-i)
3005 if( gridstruct%nw_corner )
then 3007 utmp(i,npy) = vtmp(0,je+i)
3011 if (grid_type < 3 .and. .not. (nested .or. regional))
then 3012 ifirst = max(3, is-1)
3013 ilast = min(npx-2,ie+2)
3023 uc(i,j) =
a2*(utmp(i-2,j)+utmp(i+1,j)) +
a1*(utmp(i-1,j)+utmp(i,j))
3024 ut(i,j) = (uc(i,j) - v(i,j)*cosa_u(i,j))*rsin_u(i,j)
3028 if (grid_type < 3)
then 3030 if( gridstruct%sw_corner )
then 3034 if( gridstruct%se_corner )
then 3035 ua(npx, 0) = va(npx,1)
3036 ua(npx+1,0) = va(npx,2)
3038 if( gridstruct%ne_corner )
then 3039 ua(npx, npy) = -va(npx,npy-1)
3040 ua(npx+1,npy) = -va(npx,npy-2)
3042 if( gridstruct%nw_corner )
then 3043 ua(-1,npy) = va(0,npy-2)
3044 ua( 0,npy) = va(0,npy-1)
3047 if( is==1 .and. .not. (nested .or. regional) )
then 3049 uc(0,j) =
c1*utmp(-2,j) +
c2*utmp(-1,j) +
c3*utmp(0,j)
3052 if (ut(1,j) > 0.)
then 3053 uc(1,j) = ut(1,j)*sin_sg(0,j,3)
3055 uc(1,j) = ut(1,j)*sin_sg(1,j,1)
3057 uc(2,j) =
c1*utmp(3,j) +
c2*utmp(2,j) +
c3*utmp(1,j)
3058 ut(0,j) = (uc(0,j) - v(0,j)*cosa_u(0,j))*rsin_u(0,j)
3059 ut(2,j) = (uc(2,j) - v(2,j)*cosa_u(2,j))*rsin_u(2,j)
3063 if( (ie+1)==npx .and. .not. (nested .or. regional) )
then 3065 uc(npx-1,j) =
c1*utmp(npx-3,j)+
c2*utmp(npx-2,j)+
c3*utmp(npx-1,j)
3067 if (ut(npx,j) > 0.)
then 3068 uc(npx,j) = ut(npx,j)*sin_sg(npx-1,j,3)
3070 uc(npx,j) = ut(npx,j)*sin_sg(npx,j,1)
3072 uc(npx+1,j) =
c3*utmp(npx,j) +
c2*utmp(npx+1,j) +
c1*utmp(npx+2,j)
3073 ut(npx-1,j) = (uc(npx-1,j)-v(npx-1,j)*cosa_u(npx-1,j))*rsin_u(npx-1,j)
3074 ut(npx+1,j) = (uc(npx+1,j)-v(npx+1,j)*cosa_u(npx+1,j))*rsin_u(npx+1,j)
3083 if( gridstruct%sw_corner )
then 3085 vtmp(0,j) = -utmp(1-j,0)
3088 if( gridstruct%nw_corner )
then 3090 vtmp(0,npy+j) = utmp(j+1,npy)
3093 if( gridstruct%se_corner )
then 3095 vtmp(npx,j) = utmp(ie+j,0)
3098 if( gridstruct%ne_corner )
then 3100 vtmp(npx,npy+j) = -utmp(ie-j,npy)
3103 if( gridstruct%sw_corner )
then 3107 if( gridstruct%se_corner )
then 3108 va(npx, 0) = ua(npx-1,0)
3109 va(npx,-1) = ua(npx-2,0)
3111 if( gridstruct%ne_corner )
then 3112 va(npx,npy ) = -ua(npx-1,npy)
3113 va(npx,npy+1) = -ua(npx-2,npy)
3115 if( gridstruct%nw_corner )
then 3116 va(0,npy) = ua(1,npy)
3117 va(0,npy+1) = ua(2,npy)
3120 if (grid_type < 3)
then 3123 if ( j==1 .and. .not. (nested .or. regional) )
then 3126 if (vt(i,j) > 0.)
then 3127 vc(i,j) = vt(i,j)*sin_sg(i,j-1,4)
3129 vc(i,j) = vt(i,j)*sin_sg(i,j,2)
3132 elseif ( j==0 .or. j==(npy-1) .and. .not. (nested .or. regional) )
then 3134 vc(i,j) =
c1*vtmp(i,j-2) +
c2*vtmp(i,j-1) +
c3*vtmp(i,j)
3135 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3137 elseif ( j==2 .or. j==(npy+1) .and. .not. (nested.or. regional) )
then 3139 vc(i,j) =
c1*vtmp(i,j+1) +
c2*vtmp(i,j) +
c3*vtmp(i,j-1)
3140 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3142 elseif ( j==npy .and. .not. (nested .or. regional) )
then 3145 if (vt(i,j) > 0.)
then 3146 vc(i,j) = vt(i,j)*sin_sg(i,j-1,4)
3148 vc(i,j) = vt(i,j)*sin_sg(i,j,2)
3154 vc(i,j) =
a2*(vtmp(i,j-2)+vtmp(i,j+1)) +
a1*(vtmp(i,j-1)+vtmp(i,j))
3155 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3163 vc(i,j) =
a2*(vtmp(i,j-2)+vtmp(i,j+1)) +
a1*(vtmp(i,j-1)+vtmp(i,j))
3174 real,
intent(in) :: ua(4)
3175 real,
intent(in) :: dxa(4)
3178 t1 = dxa(1) + dxa(2)
3179 t2 = dxa(3) + dxa(4)
3181 ((t2+dxa(3))*ua(3)-dxa(3)*ua(4)) / t2 )
3186 subroutine fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3188 integer,
intent(in):: dir
3189 real,
intent(inout):: q1(bd%isd:bd%ied,bd%jsd:bd%jed)
3190 real,
intent(inout):: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
3191 real,
intent(inout):: q3(bd%isd:bd%ied,bd%jsd:bd%jed)
3192 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3193 integer,
intent(IN) :: npx, npy
3196 integer :: is, ie, js, je
3197 integer :: isd, ied, jsd, jed
3210 if ( sw_corner )
then 3211 q1(-1,0) = q1(0,2); q1(0,0) = q1(0,1); q1(0,-1) = q1(-1,1)
3212 q2(-1,0) = q2(0,2); q2(0,0) = q2(0,1); q2(0,-1) = q2(-1,1)
3213 q3(-1,0) = q3(0,2); q3(0,0) = q3(0,1); q3(0,-1) = q3(-1,1)
3215 if ( se_corner )
then 3216 q1(npx+1,0) = q1(npx,2); q1(npx,0) = q1(npx,1); q1(npx,-1) = q1(npx+1,1)
3217 q2(npx+1,0) = q2(npx,2); q2(npx,0) = q2(npx,1); q2(npx,-1) = q2(npx+1,1)
3218 q3(npx+1,0) = q3(npx,2); q3(npx,0) = q3(npx,1); q3(npx,-1) = q3(npx+1,1)
3220 if ( ne_corner )
then 3221 q1(npx,npy) = q1(npx,npy-1); q1(npx+1,npy) = q1(npx,npy-2); q1(npx,npy+1) = q1(npx+1,npy-1)
3222 q2(npx,npy) = q2(npx,npy-1); q2(npx+1,npy) = q2(npx,npy-2); q2(npx,npy+1) = q2(npx+1,npy-1)
3223 q3(npx,npy) = q3(npx,npy-1); q3(npx+1,npy) = q3(npx,npy-2); q3(npx,npy+1) = q3(npx+1,npy-1)
3225 if ( nw_corner )
then 3226 q1(0,npy) = q1(0,npy-1); q1(-1,npy) = q1(0,npy-2); q1(0,npy+1) = q1(-1,npy-1)
3227 q2(0,npy) = q2(0,npy-1); q2(-1,npy) = q2(0,npy-2); q2(0,npy+1) = q2(-1,npy-1)
3228 q3(0,npy) = q3(0,npy-1); q3(-1,npy) = q3(0,npy-2); q3(0,npy+1) = q3(-1,npy-1)
3232 if ( sw_corner )
then 3233 q1(0,0) = q1(1,0); q1(0,-1) = q1(2,0); q1(-1,0) = q1(1,-1)
3234 q2(0,0) = q2(1,0); q2(0,-1) = q2(2,0); q2(-1,0) = q2(1,-1)
3235 q3(0,0) = q3(1,0); q3(0,-1) = q3(2,0); q3(-1,0) = q3(1,-1)
3237 if ( se_corner )
then 3238 q1(npx,0) = q1(npx-1,0); q1(npx,-1) = q1(npx-2,0); q1(npx+1,0) = q1(npx-1,-1)
3239 q2(npx,0) = q2(npx-1,0); q2(npx,-1) = q2(npx-2,0); q2(npx+1,0) = q2(npx-1,-1)
3240 q3(npx,0) = q3(npx-1,0); q3(npx,-1) = q3(npx-2,0); q3(npx+1,0) = q3(npx-1,-1)
3242 if ( ne_corner )
then 3243 q1(npx,npy) = q1(npx-1,npy); q1(npx,npy+1) = q1(npx-2,npy); q1(npx+1,npy) = q1(npx-1,npy+1)
3244 q2(npx,npy) = q2(npx-1,npy); q2(npx,npy+1) = q2(npx-2,npy); q2(npx+1,npy) = q2(npx-1,npy+1)
3245 q3(npx,npy) = q3(npx-1,npy); q3(npx,npy+1) = q3(npx-2,npy); q3(npx+1,npy) = q3(npx-1,npy+1)
3247 if ( nw_corner )
then 3248 q1(0,npy) = q1(1,npy); q1(0,npy+1) = q1(2,npy); q1(-1,npy) = q1(1,npy+1)
3249 q2(0,npy) = q2(1,npy); q2(0,npy+1) = q2(2,npy); q2(-1,npy) = q2(1,npy+1)
3250 q3(0,npy) = q3(1,npy); q3(0,npy+1) = q3(2,npy); q3(-1,npy) = q3(1,npy+1)
3257 subroutine fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3259 integer,
intent(in):: dir
3260 real,
intent(inout):: q1(bd%isd:bd%ied,bd%jsd:bd%jed)
3261 real,
intent(inout):: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
3262 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3263 integer,
intent(IN) :: npx, npy
3265 integer :: is, ie, js, je
3266 integer :: isd, ied, jsd, jed
3279 if ( sw_corner )
then 3280 q1(-1,0) = q1(0,2); q1(0,0) = q1(0,1)
3281 q2(-1,0) = q2(0,2); q2(0,0) = q2(0,1)
3283 if ( se_corner )
then 3284 q1(npx+1,0) = q1(npx,2); q1(npx,0) = q1(npx,1)
3285 q2(npx+1,0) = q2(npx,2); q2(npx,0) = q2(npx,1)
3287 if ( nw_corner )
then 3288 q1(0,npy) = q1(0,npy-1); q1(-1,npy) = q1(0,npy-2)
3289 q2(0,npy) = q2(0,npy-1); q2(-1,npy) = q2(0,npy-2)
3291 if ( ne_corner )
then 3292 q1(npx,npy) = q1(npx,npy-1); q1(npx+1,npy) = q1(npx,npy-2)
3293 q2(npx,npy) = q2(npx,npy-1); q2(npx+1,npy) = q2(npx,npy-2)
3297 if ( sw_corner )
then 3298 q1(0,0) = q1(1,0); q1(0,-1) = q1(2,0)
3299 q2(0,0) = q2(1,0); q2(0,-1) = q2(2,0)
3301 if ( se_corner )
then 3302 q1(npx,0) = q1(npx-1,0); q1(npx,-1) = q1(npx-2,0)
3303 q2(npx,0) = q2(npx-1,0); q2(npx,-1) = q2(npx-2,0)
3305 if ( nw_corner )
then 3306 q1(0,npy) = q1(1,npy); q1(0,npy+1) = q1(2,npy)
3307 q2(0,npy) = q2(1,npy); q2(0,npy+1) = q2(2,npy)
3309 if ( ne_corner )
then 3310 q1(npx,npy) = q1(npx-1,npy); q1(npx,npy+1) = q1(npx-2,npy)
3311 q2(npx,npy) = q2(npx-1,npy); q2(npx,npy+1) = q2(npx-2,npy)
3319 subroutine fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3321 integer,
intent(in):: dir
3322 real,
intent(inout):: q(bd%isd:bd%ied,bd%jsd:bd%jed)
3323 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3324 integer,
intent(IN) :: npx, npy
3326 integer :: is, ie, js, je
3327 integer :: isd, ied, jsd, jed
3340 if ( sw_corner )
then 3344 if ( se_corner )
then 3345 q(npx+1,0) = q(npx,2)
3346 q(npx, 0) = q(npx,1)
3348 if ( nw_corner )
then 3349 q( 0,npy) = q(0,npy-1)
3350 q(-1,npy) = q(0,npy-2)
3352 if ( ne_corner )
then 3353 q(npx, npy) = q(npx,npy-1)
3354 q(npx+1,npy) = q(npx,npy-2)
3358 if ( sw_corner )
then 3362 if ( se_corner )
then 3363 q(npx, 0) = q(npx-1,0)
3364 q(npx,-1) = q(npx-2,0)
3366 if ( nw_corner )
then 3367 q(0,npy ) = q(1,npy)
3368 q(0,npy+1) = q(2,npy)
3370 if ( ne_corner )
then 3371 q(npx,npy ) = q(npx-1,npy)
3372 q(npx,npy+1) = q(npx-2,npy)
real, parameter p1
0.58333333
subroutine, public divergence_corner_nest(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
subroutine fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
The subroutine ' fill2_4corners' fills the 4 corners of the scalar fileds only as needed by 'c_core'...
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
The type 'fv_grid_type' is made up of grid-dependent information from fv_grid_tools and fv_grid_utils...
subroutine, public c_sw(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, wc, ut, vt, divg_d, nord, dt2, hydrostatic, dord4, bd, gridstruct, flagstruct)
The subroutine 'c_sw' performs a half-timestep advance of the C-grid winds.
The module 'sw_core' advances the forward step of the Lagrangian dynamics as described by ...
integer, public test_case
subroutine, public divergence_corner(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
The subroutine 'divergence_corner' computes the cell-mean divergence on the "dual grid"...
subroutine, public del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
The subroutine 'del6_vt_flux' applies 2nd, 4th, or 6th-order damping to fluxes ("vorticity damping") ...
real function edge_interpolate4(ua, dxa)
The module 'tp_core' is a collection of routines to support FV transport.
The module 'a2b_edge' performs FV-consistent interpolation of pressure to corners.
subroutine, public copy_corners(q, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
subroutine d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, npx, npy, nested, grid_type, regional)
subroutine, public fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
The subroutine 'fill_4corners' fills the 4 corners of the scalar fields only as needed by c_core...
The module 'fv_arrays' contains the 'fv_atmos_type' and associated datatypes.
real, parameter big_number
subroutine, public pert_ppm(im, a0, al, ar, iv)
subroutine xtp_u(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, nested, lim_fac, regional)
subroutine smag_corner(dt, u, v, ua, va, smag_c, bd, npx, npy, gridstruct, ng)
The subroutine 'smag_corner' computes Smagorinsky damping.
integer, parameter, public ng
real, parameter near_zero
for KE limiter
subroutine, public fv_tp_2d(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, lim_fac, regional, mfx, mfy, mass, nord, damp_c)
The subroutine 'fv_tp_2d' contains the FV advection scheme .
subroutine, public d_sw(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, divg_d, xflux, yflux, cx, cy, crx_adv, cry_adv, xfx_adv, yfx_adv, q_con, z_rat, kgb, heat_source, diss_est, zvir, sphum, nq, q, k, km, inline_q, dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, damp_t, d_con, hydrostatic, gridstruct, flagstruct, bd)
The subroutine 'd_sw' peforms a full-timestep advance of the D-grid winds and other prognostic varaia...
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine ytp_v(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, nested, lim_fac, regional)
subroutine fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
The subroutine 'fill3_4corners' fills the 4 corners of the scalar fileds only as needed by 'c_core'...