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
129 integer :: is, ie, js, je
130 integer :: isd, ied, jsd, jed
132 logical :: bounded_domain
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 bounded_domain = gridstruct%bounded_domain
153 sin_sg => gridstruct%sin_sg
154 cos_sg => gridstruct%cos_sg
155 cosa_u => gridstruct%cosa_u
156 cosa_v => gridstruct%cosa_v
157 sina_u => gridstruct%sina_u
158 sina_v => gridstruct%sina_v
161 dxc => gridstruct%dxc
162 dyc => gridstruct%dyc
164 sw_corner = gridstruct%sw_corner
165 se_corner = gridstruct%se_corner
166 nw_corner = gridstruct%nw_corner
167 ne_corner = gridstruct%ne_corner
169 iep1 = ie+1; jep1 = je+1
171 call d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, &
172 npx, npy, bounded_domain, flagstruct%grid_type)
175 if (bounded_domain)
then 184 if (ut(i,j) > 0.)
then 185 ut(i,j) = dt2*ut(i,j)*dy(i,j)*sin_sg(i-1,j,3)
187 ut(i,j) = dt2*ut(i,j)*dy(i,j)*sin_sg(i,j,1)
193 if (vt(i,j) > 0.)
then 194 vt(i,j) = dt2*vt(i,j)*dx(i,j)*sin_sg(i,j-1,4)
196 vt(i,j) = dt2*vt(i,j)*dx(i,j)*sin_sg(i,j, 2)
205 if (flagstruct%grid_type < 3 .and. .not. bounded_domain)
call fill2_4corners(delp, pt, 1, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
207 if ( hydrostatic )
then 211 if ( ut(i,j) > 0. )
then 212 fx1(i,j) = delp(i-1,j)
216 fx1(i,j) = ut(i,j)*fx1(i,j)
222 if ( ut(i,j) > 0. )
then 223 fx1(i,j) = delp(i-1,j)
229 fx1(i,j) = ut(i,j)*fx1(i,j)
230 fx(i,j) = fx1(i,j)* fx(i,j)
235 if (flagstruct%grid_type < 3) &
236 call fill_4corners(w, 1, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
239 if ( ut(i,j) > 0. )
then 240 fx1(i,j) = delp(i-1,j)
248 fx1(i,j) = ut(i,j)*fx1(i,j)
249 fx(i,j) = fx1(i,j)* fx(i,j)
250 fx2(i,j) = fx1(i,j)*fx2(i,j)
256 if (flagstruct%grid_type < 3 .and. .not. bounded_domain)
call fill2_4corners(delp, pt, 2, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
257 if ( hydrostatic )
then 260 if ( vt(i,j) > 0. )
then 261 fy1(i,j) = delp(i,j-1)
267 fy1(i,j) = vt(i,j)*fy1(i,j)
268 fy(i,j) = fy1(i,j)* fy(i,j)
273 delpc(i,j) = delp(i,j) + (fx1(i,j)-fx1(i+1,j)+fy1(i,j)-fy1(i,j+1))*gridstruct%rarea(i,j)
277 ptc(i,j) = (pt(i,j)*delp(i,j) + &
278 (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*gridstruct%rarea(i,j))/delpc(i,j)
283 if (flagstruct%grid_type < 3)
call fill_4corners(w, 2, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
286 if ( vt(i,j) > 0. )
then 287 fy1(i,j) = delp(i,j-1)
295 fy1(i,j) = vt(i,j)*fy1(i,j)
296 fy(i,j) = fy1(i,j)* fy(i,j)
297 fy2(i,j) = fy1(i,j)*fy2(i,j)
302 delpc(i,j) = delp(i,j) + (fx1(i,j)-fx1(i+1,j)+fy1(i,j)-fy1(i,j+1))*gridstruct%rarea(i,j)
303 ptc(i,j) = (pt(i,j)*delp(i,j) + &
304 (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*gridstruct%rarea(i,j))/delpc(i,j)
305 wc(i,j) = (w(i,j)*delp(i,j) + (fx2(i,j)-fx2(i+1,j) + &
306 fy2(i,j)-fy2(i,j+1))*gridstruct%rarea(i,j))/delpc(i,j)
320 if (bounded_domain .or. flagstruct%grid_type >=3 )
then 323 if ( ua(i,j) > 0. )
then 332 if ( va(i,j) > 0. )
then 335 vort(i,j) = vc(i,j+1)
342 if ( ua(i,j) > 0. )
then 344 ke(1,j) = uc(1, j)*sin_sg(1,j,1)+v(1,j)*cos_sg(1,j,1)
345 elseif ( i==npx )
then 346 ke(i,j) = uc(npx,j)*sin_sg(npx,j,1)+v(npx,j)*cos_sg(npx,j,1)
352 ke(0,j) = uc(1, j)*sin_sg(0,j,3)+v(1,j)*cos_sg(0,j,3)
353 elseif ( i==(npx-1) )
then 354 ke(i,j) = uc(npx,j)*sin_sg(npx-1,j,3)+v(npx,j)*cos_sg(npx-1,j,3)
363 if ( va(i,j) > 0. )
then 365 vort(i,1) = vc(i, 1)*sin_sg(i,1,2)+u(i, 1)*cos_sg(i,1,2)
366 elseif ( j==npy )
then 367 vort(i,j) = vc(i,npy)*sin_sg(i,npy,2)+u(i,npy)*cos_sg(i,npy,2)
373 vort(i,0) = vc(i, 1)*sin_sg(i,0,4)+u(i, 1)*cos_sg(i,0,4)
374 elseif ( j==(npy-1) )
then 375 vort(i,j) = vc(i,npy)*sin_sg(i,npy-1,4)+u(i,npy)*cos_sg(i,npy-1,4)
377 vort(i,j) = vc(i,j+1)
387 ke(i,j) = dt4*(ua(i,j)*ke(i,j) + va(i,j)*vort(i,j))
397 fx(i,j) = uc(i,j) * dxc(i,j)
403 fy(i,j) = vc(i,j) * dyc(i,j)
409 vort(i,j) = fx(i,j-1) - fx(i,j) - fy(i-1,j) + fy(i,j)
414 if ( sw_corner ) vort(1, 1) = vort(1, 1) + fy(0, 1)
415 if ( se_corner ) vort(npx ,1) = vort(npx, 1) - fy(npx, 1)
416 if ( ne_corner ) vort(npx,npy) = vort(npx,npy) - fy(npx,npy)
417 if ( nw_corner ) vort(1, npy) = vort(1, npy) + fy(0, npy)
424 vort(i,j) = gridstruct%fC(i,j) + gridstruct%rarea_c(i,j) * vort(i,j)
437 if (bounded_domain .or. flagstruct%grid_type >= 3)
then 440 fy1(i,j) = dt2*(v(i,j)-uc(i,j)*cosa_u(i,j))/sina_u(i,j)
441 if ( fy1(i,j) > 0. )
then 444 fy(i,j) = vort(i,j+1)
450 fx1(i,j) = dt2*(u(i,j)-vc(i,j)*cosa_v(i,j))/sina_v(i,j)
451 if ( fx1(i,j) > 0. )
then 454 fx(i,j) = vort(i+1,j)
462 if ( ( i==1 .or. i==npx ) )
then 463 fy1(i,j) = dt2*v(i,j)
465 fy1(i,j) = dt2*(v(i,j)-uc(i,j)*cosa_u(i,j))/sina_u(i,j)
467 if ( fy1(i,j) > 0. )
then 470 fy(i,j) = vort(i,j+1)
475 if ( ( j==1 .or. j==npy ) )
then 478 fx1(i,j) = dt2*u(i,j)
479 if ( fx1(i,j) > 0. )
then 482 fx(i,j) = vort(i+1,j)
488 fx1(i,j) = dt2*(u(i,j)-vc(i,j)*cosa_v(i,j))/sina_v(i,j)
489 if ( fx1(i,j) > 0. )
then 492 fx(i,j) = vort(i+1,j)
502 uc(i,j) = uc(i,j) + fy1(i,j)*fy(i,j) + gridstruct%rdxc(i,j)*(ke(i-1,j)-ke(i,j))
507 vc(i,j) = vc(i,j) - fx1(i,j)*fx(i,j) + gridstruct%rdyc(i,j)*(ke(i,j-1)-ke(i,j))
519 subroutine d_sw(delpc, delp, ptc, pt, u, v, w, uc,vc, &
520 ua, va, divg_d, xflux, yflux, cx, cy, &
521 crx_adv, cry_adv, xfx_adv, yfx_adv, q_con, z_rat, kgb, heat_source,diss_est, &
522 zvir, sphum, nq, q, k, km, inline_q, &
523 dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, &
524 nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, &
525 damp_t, d_con, hydrostatic, gridstruct, flagstruct, bd)
527 integer,
intent(IN):: hord_tr, hord_mt, hord_vt, hord_tm, hord_dp
528 integer,
intent(IN):: nord
529 integer,
intent(IN):: nord_v
530 integer,
intent(IN):: nord_w
531 integer,
intent(IN):: nord_t
532 integer,
intent(IN):: sphum, nq, k, km
533 real ,
intent(IN):: dt, dddmp, d2_bg, d4_bg, d_con
534 real ,
intent(IN):: zvir
535 real,
intent(in):: damp_v, damp_w, damp_t, kgb
537 real,
intent(inout):: divg_d(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
538 real,
intent(IN),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed):: z_rat
539 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed):: delp, pt, ua, va
540 real,
intent(INOUT),
dimension(bd%isd: , bd%jsd: ):: w, q_con
541 real,
intent(INOUT),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1):: u, vc
542 real,
intent(INOUT),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v, uc
543 real,
intent(INOUT):: q(bd%isd:bd%ied,bd%jsd:bd%jed,km,nq)
544 real,
intent(OUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc
545 real,
intent(OUT),
dimension(bd%is:bd%ie,bd%js:bd%je):: heat_source
546 real,
intent(OUT),
dimension(bd%is:bd%ie,bd%js:bd%je):: diss_est
548 real,
intent(INOUT):: xflux(bd%is:bd%ie+1,bd%js:bd%je )
549 real,
intent(INOUT):: yflux(bd%is:bd%ie ,bd%js:bd%je+1)
551 real,
intent(INOUT):: cx(bd%is:bd%ie+1,bd%jsd:bd%jed )
552 real,
intent(INOUT):: cy(bd%isd:bd%ied,bd%js:bd%je+1)
553 logical,
intent(IN):: hydrostatic
554 logical,
intent(IN):: inline_q
555 real,
intent(OUT),
dimension(bd%is:bd%ie+1,bd%jsd:bd%jed):: crx_adv, xfx_adv
556 real,
intent(OUT),
dimension(bd%isd:bd%ied,bd%js:bd%je+1):: cry_adv, yfx_adv
560 logical:: sw_corner, se_corner, ne_corner, nw_corner
561 real :: ut(bd%isd:bd%ied+1,bd%jsd:bd%jed)
562 real :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
564 real :: fx2(bd%isd:bd%ied+1,bd%jsd:bd%jed)
565 real :: fy2(bd%isd:bd%ied, bd%jsd:bd%jed+1)
566 real :: dw(bd%is:bd%ie,bd%js:bd%je)
568 real,
dimension(bd%is:bd%ie+1,bd%js:bd%je+1):: ub, vb
569 real :: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
570 real :: ke(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
571 real :: vort(bd%isd:bd%ied,bd%jsd:bd%jed)
572 real :: fx(bd%is:bd%ie+1,bd%js:bd%je )
573 real :: fy(bd%is:bd%ie ,bd%js:bd%je+1)
574 real :: ra_x(bd%is:bd%ie,bd%jsd:bd%jed)
575 real :: ra_y(bd%isd:bd%ied,bd%js:bd%je)
576 real :: gx(bd%is:bd%ie+1,bd%js:bd%je )
577 real :: gy(bd%is:bd%ie ,bd%js:bd%je+1)
580 real :: dt2, dt4, dt5, dt6
581 real :: damp, damp2, damp4, dd8, u2, v2, du2, dv2
583 integer :: i,j, is2, ie1, js2, je1, n, nt, n2, iq
585 real,
pointer,
dimension(:,:) :: area, area_c, rarea
587 real,
pointer,
dimension(:,:,:) :: sin_sg
588 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v, cosa_s
589 real,
pointer,
dimension(:,:) :: sina_u, sina_v
590 real,
pointer,
dimension(:,:) :: rsin_u, rsin_v, rsina
591 real,
pointer,
dimension(:,:) :: f0, rsin2, divg_u, divg_v
593 real,
pointer,
dimension(:,:) :: cosa, dx, dy, dxc, dyc, rdxa, rdya, rdx, rdy
595 integer :: is, ie, js, je
596 integer :: isd, ied, jsd, jed
597 integer :: npx, npy, ng
598 logical :: bounded_domain
612 bounded_domain = gridstruct%bounded_domain
614 area => gridstruct%area
615 rarea => gridstruct%rarea
616 sin_sg => gridstruct%sin_sg
617 cosa_u => gridstruct%cosa_u
618 cosa_v => gridstruct%cosa_v
619 cosa_s => gridstruct%cosa_s
620 sina_u => gridstruct%sina_u
621 sina_v => gridstruct%sina_v
622 rsin_u => gridstruct%rsin_u
623 rsin_v => gridstruct%rsin_v
624 rsina => gridstruct%rsina
626 rsin2 => gridstruct%rsin2
627 divg_u => gridstruct%divg_u
628 divg_v => gridstruct%divg_v
629 cosa => gridstruct%cosa
632 dxc => gridstruct%dxc
633 dyc => gridstruct%dyc
634 rdxa => gridstruct%rdxa
635 rdya => gridstruct%rdya
636 rdx => gridstruct%rdx
637 rdy => gridstruct%rdy
639 sw_corner = gridstruct%sw_corner
640 se_corner = gridstruct%se_corner
641 nw_corner = gridstruct%nw_corner
642 ne_corner = gridstruct%ne_corner
648 xfx_adv(i,j) = dt * uc(i,j) / sina_u(i,j)
649 if (xfx_adv(i,j) > 0.)
then 650 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i-1,j)
652 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i,j)
654 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sina_u(i,j)
660 yfx_adv(i,j) = dt * vc(i,j) / sina_v(i,j)
661 if (yfx_adv(i,j) > 0.)
then 662 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j-1)
664 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j)
666 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sina_v(i,j)
671 if ( flagstruct%grid_type < 3 )
then 674 if (bounded_domain)
then 677 ut(i,j) = ( uc(i,j) - 0.25 * cosa_u(i,j) * &
678 (vc(i-1,j)+vc(i,j)+vc(i-1,j+1)+vc(i,j+1)))*rsin_u(i,j)
683 vt(i,j) = ( vc(i,j) - 0.25 * cosa_v(i,j) * &
684 (uc(i,j-1)+uc(i+1,j-1)+uc(i,j)+uc(i+1,j)))*rsin_v(i,j)
689 if( j/=0 .and. j/=1 .and. j/=(npy-1) .and. j/=npy)
then 691 ut(i,j) = ( uc(i,j) - 0.25 * cosa_u(i,j) * &
692 (vc(i-1,j)+vc(i,j)+vc(i-1,j+1)+vc(i,j+1)))*rsin_u(i,j)
698 if( j/=1 .and. j/=npy )
then 701 vt(i,j) = ( vc(i,j) - 0.25 * cosa_v(i,j) * &
702 (uc(i,j-1)+uc(i+1,j-1)+uc(i,j)+uc(i+1,j)))*rsin_v(i,j)
708 if (.not. bounded_domain)
then 712 if ( uc(1,j)*dt > 0. )
then 713 ut(1,j) = uc(1,j) / sin_sg(0,j,3)
715 ut(1,j) = uc(1,j) / sin_sg(1,j,1)
718 do j=max(3,js), min(npy-2,je+1)
719 vt(0,j) = vc(0,j) - 0.25*cosa_v(0,j)* &
720 (ut(0,j-1)+ut(1,j-1)+ut(0,j)+ut(1,j))
721 vt(1,j) = vc(1,j) - 0.25*cosa_v(1,j)* &
722 (ut(1,j-1)+ut(2,j-1)+ut(1,j)+ut(2,j))
727 if ( (ie+1)==npx )
then 729 if ( uc(npx,j)*dt > 0. )
then 730 ut(npx,j) = uc(npx,j) / sin_sg(npx-1,j,3)
732 ut(npx,j) = uc(npx,j) / sin_sg(npx,j,1)
736 do j=max(3,js), min(npy-2,je+1)
737 vt(npx-1,j) = vc(npx-1,j) - 0.25*cosa_v(npx-1,j)* &
738 (ut(npx-1,j-1)+ut(npx,j-1)+ut(npx-1,j)+ut(npx,j))
739 vt(npx,j) = vc(npx,j) - 0.25*cosa_v(npx,j)* &
740 (ut(npx,j-1)+ut(npx+1,j-1)+ut(npx,j)+ut(npx+1,j))
748 if ( vc(i,1)*dt > 0. )
then 749 vt(i,1) = vc(i,1) / sin_sg(i,0,4)
751 vt(i,1) = vc(i,1) / sin_sg(i,1,2)
755 do i=max(3,is),min(npx-2,ie+1)
756 ut(i,0) = uc(i,0) - 0.25*cosa_u(i,0)* &
757 (vt(i-1,0)+vt(i,0)+vt(i-1,1)+vt(i,1))
758 ut(i,1) = uc(i,1) - 0.25*cosa_u(i,1)* &
759 (vt(i-1,1)+vt(i,1)+vt(i-1,2)+vt(i,2))
764 if ( (je+1)==npy )
then 766 if ( vc(i,npy)*dt > 0. )
then 767 vt(i,npy) = vc(i,npy) / sin_sg(i,npy-1,4)
769 vt(i,npy) = vc(i,npy) / sin_sg(i,npy,2)
772 do i=max(3,is),min(npx-2,ie+1)
773 ut(i,npy-1) = uc(i,npy-1) - 0.25*cosa_u(i,npy-1)* &
774 (vt(i-1,npy-1)+vt(i,npy-1)+vt(i-1,npy)+vt(i,npy))
775 ut(i,npy) = uc(i,npy) - 0.25*cosa_u(i,npy)* &
776 (vt(i-1,npy)+vt(i,npy)+vt(i-1,npy+1)+vt(i,npy+1))
791 damp = 1. / (1.-0.0625*cosa_u(2,0)*cosa_v(1,0))
792 ut(2,0) = (uc(2,0)-0.25*cosa_u(2,0)*(vt(1,1)+vt(2,1)+vt(2,0) +vc(1,0) - &
793 0.25*cosa_v(1,0)*(ut(1,0)+ut(1,-1)+ut(2,-1))) ) * damp
794 damp = 1. / (1.-0.0625*cosa_u(0,1)*cosa_v(0,2))
795 vt(0,2) = (vc(0,2)-0.25*cosa_v(0,2)*(ut(1,1)+ut(1,2)+ut(0,2)+uc(0,1) - &
796 0.25*cosa_u(0,1)*(vt(0,1)+vt(-1,1)+vt(-1,2))) ) * damp
798 damp = 1. / (1.-0.0625*cosa_u(2,1)*cosa_v(1,2))
799 ut(2,1) = (uc(2,1)-0.25*cosa_u(2,1)*(vt(1,1)+vt(2,1)+vt(2,2)+vc(1,2) - &
800 0.25*cosa_v(1,2)*(ut(1,1)+ut(1,2)+ut(2,2))) ) * damp
802 vt(1,2) = (vc(1,2)-0.25*cosa_v(1,2)*(ut(1,1)+ut(1,2)+ut(2,2)+uc(2,1) - &
803 0.25*cosa_u(2,1)*(vt(1,1)+vt(2,1)+vt(2,2))) ) * damp
807 damp = 1. / (1. - 0.0625*cosa_u(npx-1,0)*cosa_v(npx-1,0))
808 ut(npx-1,0) = ( uc(npx-1,0)-0.25*cosa_u(npx-1,0)*( &
809 vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,0)+vc(npx-1,0) - &
810 0.25*cosa_v(npx-1,0)*(ut(npx,0)+ut(npx,-1)+ut(npx-1,-1))) ) * damp
811 damp = 1. / (1. - 0.0625*cosa_u(npx+1,1)*cosa_v(npx,2))
812 vt(npx, 2) = ( vc(npx,2)-0.25*cosa_v(npx,2)*( &
813 ut(npx,1)+ut(npx,2)+ut(npx+1,2)+uc(npx+1,1) - &
814 0.25*cosa_u(npx+1,1)*(vt(npx,1)+vt(npx+1,1)+vt(npx+1,2))) ) * damp
816 damp = 1. / (1. - 0.0625*cosa_u(npx-1,1)*cosa_v(npx-1,2))
817 ut(npx-1,1) = ( uc(npx-1,1)-0.25*cosa_u(npx-1,1)*( &
818 vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,2)+vc(npx-1,2) - &
819 0.25*cosa_v(npx-1,2)*(ut(npx,1)+ut(npx,2)+ut(npx-1,2))) ) * damp
820 vt(npx-1,2) = ( vc(npx-1,2)-0.25*cosa_v(npx-1,2)*( &
821 ut(npx,1)+ut(npx,2)+ut(npx-1,2)+uc(npx-1,1) - &
822 0.25*cosa_u(npx-1,1)*(vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,2))) ) * damp
826 damp = 1. / (1. - 0.0625*cosa_u(npx-1,npy)*cosa_v(npx-1,npy+1))
827 ut(npx-1,npy) = ( uc(npx-1,npy)-0.25*cosa_u(npx-1,npy)*( &
828 vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy+1)+vc(npx-1,npy+1) - &
829 0.25*cosa_v(npx-1,npy+1)*(ut(npx,npy)+ut(npx,npy+1)+ut(npx-1,npy+1))) ) * damp
830 damp = 1. / (1. - 0.0625*cosa_u(npx+1,npy-1)*cosa_v(npx,npy-1))
831 vt(npx, npy-1) = ( vc(npx,npy-1)-0.25*cosa_v(npx,npy-1)*( &
832 ut(npx,npy-1)+ut(npx,npy-2)+ut(npx+1,npy-2)+uc(npx+1,npy-1) - &
833 0.25*cosa_u(npx+1,npy-1)*(vt(npx,npy)+vt(npx+1,npy)+vt(npx+1,npy-1))) ) * damp
835 damp = 1. / (1. - 0.0625*cosa_u(npx-1,npy-1)*cosa_v(npx-1,npy-1))
836 ut(npx-1,npy-1) = ( uc(npx-1,npy-1)-0.25*cosa_u(npx-1,npy-1)*( &
837 vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy-1)+vc(npx-1,npy-1) - &
838 0.25*cosa_v(npx-1,npy-1)*(ut(npx,npy-1)+ut(npx,npy-2)+ut(npx-1,npy-2))) ) * damp
839 vt(npx-1,npy-1) = ( vc(npx-1,npy-1)-0.25*cosa_v(npx-1,npy-1)*( &
840 ut(npx,npy-1)+ut(npx,npy-2)+ut(npx-1,npy-2)+uc(npx-1,npy-1) - &
841 0.25*cosa_u(npx-1,npy-1)*(vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy-1))) ) * damp
845 damp = 1. / (1. - 0.0625*cosa_u(2,npy)*cosa_v(1,npy+1))
846 ut(2,npy) = ( uc(2,npy)-0.25*cosa_u(2,npy)*( &
847 vt(1,npy)+vt(2,npy)+vt(2,npy+1)+vc(1,npy+1) - &
848 0.25*cosa_v(1,npy+1)*(ut(1,npy)+ut(1,npy+1)+ut(2,npy+1))) ) * damp
849 damp = 1. / (1. - 0.0625*cosa_u(0,npy-1)*cosa_v(0,npy-1))
850 vt(0,npy-1) = ( vc(0,npy-1)-0.25*cosa_v(0,npy-1)*( &
851 ut(1,npy-1)+ut(1,npy-2)+ut(0,npy-2)+uc(0,npy-1) - &
852 0.25*cosa_u(0,npy-1)*(vt(0,npy)+vt(-1,npy)+vt(-1,npy-1))) ) * damp
854 damp = 1. / (1. - 0.0625*cosa_u(2,npy-1)*cosa_v(1,npy-1))
855 ut(2,npy-1) = ( uc(2,npy-1)-0.25*cosa_u(2,npy-1)*( &
856 vt(1,npy)+vt(2,npy)+vt(2,npy-1)+vc(1,npy-1) - &
857 0.25*cosa_v(1,npy-1)*(ut(1,npy-1)+ut(1,npy-2)+ut(2,npy-2))) ) * damp
859 vt(1,npy-1) = ( vc(1,npy-1)-0.25*cosa_v(1,npy-1)*( &
860 ut(1,npy-1)+ut(1,npy-2)+ut(2,npy-2)+uc(2,npy-1) - &
861 0.25*cosa_u(2,npy-1)*(vt(1,npy)+vt(2,npy)+vt(2,npy-1))) ) * damp
883 xfx_adv(i,j) = dt*ut(i,j)
889 yfx_adv(i,j) = dt*vt(i,j)
900 if ( xfx_adv(i,j) > 0. )
then 901 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i-1,j)
902 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sin_sg(i-1,j,3)
904 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i,j)
905 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sin_sg(i,j,1)
912 if ( yfx_adv(i,j) > 0. )
then 913 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j-1)
914 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sin_sg(i,j-1,4)
916 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j)
917 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sin_sg(i,j,2)
928 ra_x(i,j) = area(i,j) + xfx_adv(i,j) - xfx_adv(i+1,j)
933 ra_y(i,j) = area(i,j) + yfx_adv(i,j) - yfx_adv(i,j+1)
938 call fv_tp_2d(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx, fy, &
939 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
940 nord=nord_v, damp_c=damp_v)
945 cx(i,j) = cx(i,j) + crx_adv(i,j)
950 xflux(i,j) = xflux(i,j) + fx(i,j)
955 cy(i,j) = cy(i,j) + cry_adv(i,j)
958 yflux(i,j) = yflux(i,j) + fy(i,j)
965 heat_source(i,j) = 0.
970 if ( .not. hydrostatic )
then 971 if ( damp_w>1.e-5 )
then 973 damp4 = (damp_w*gridstruct%da_min_c)**(nord_w+1)
974 call del6_vt_flux(nord_w, npx, npy, damp4, w, wk, fx2, fy2, gridstruct, bd)
977 dw(i,j) = (fx2(i,j)-fx2(i+1,j)+fy2(i,j)-fy2(i,j+1))*rarea(i,j)
980 heat_source(i,j) = dd8 - dw(i,j)*(w(i,j)+0.5*dw(i,j))
981 diss_est(i,j) = heat_source(i,j)
985 call fv_tp_2d(w, crx_adv,cry_adv, npx, npy, hord_vt, gx, gy, xfx_adv, yfx_adv, &
986 gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
990 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)
996 call fv_tp_2d(q_con, crx_adv,cry_adv, npx, npy, hord_dp, gx, gy, &
997 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac,&
998 mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
1001 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)
1013 call fv_tp_2d(pt, crx_adv,cry_adv, npx, npy, hord_tm, gx, gy, &
1014 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
1015 mfx=fx, mfy=fy, mass=delp, nord=nord_v, damp_c=damp_v)
1019 if ( inline_q )
then 1023 delp(i,j) = wk(i,j) + (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*rarea(i,j)
1027 pt(i,j) = (pt(i,j)*wk(i,j) + &
1028 (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j))/delp(i,j)
1033 call fv_tp_2d(q(isd,jsd,k,iq), crx_adv,cry_adv, npx, npy, hord_tr, gx, gy, &
1034 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac, &
1035 mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
1038 q(i,j,k,iq) = (q(i,j,k,iq)*wk(i,j) + &
1039 (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j))/delp(i,j)
1055 pt(i,j) = pt(i,j)*delp(i,j) + &
1056 (gx(i,j)-gx(i+1,j)+gy(i,j)-gy(i,j+1))*rarea(i,j)
1058 delp(i,j) = delp(i,j) + &
1059 (fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))*rarea(i,j)
1061 pt(i,j) = pt(i,j) / delp(i,j)
1080 if (bounded_domain)
then 1081 is2 = is; ie1 = ie+1
1082 js2 = js; je1 = je+1
1084 is2 = max(2,is); ie1 = min(npx-1,ie+1)
1085 js2 = max(2,js); je1 = min(npy-1,je+1)
1088 if (flagstruct%grid_type < 3)
then 1090 if (bounded_domain)
then 1093 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j)-(uc(i,j-1)+uc(i,j))*cosa(i,j))*rsina(i,j)
1099 vb(i,1) = dt5*(vt(i-1,1)+vt(i,1))
1105 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j)-(uc(i,j-1)+uc(i,j))*cosa(i,j))*rsina(i,j)
1110 vb(1,j) = dt4*(-vt(-1,j) + 3.*(vt(0,j)+vt(1,j)) - vt(2,j))
1112 if ( (ie+1)==npx )
then 1114 vb(npx,j) = dt4*(-vt(npx-2,j) + 3.*(vt(npx-1,j)+vt(npx,j)) - vt(npx+1,j))
1118 if ( (je+1)==npy )
then 1120 vb(i,npy) = dt5*(vt(i-1,npy)+vt(i,npy))
1128 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j))
1133 call ytp_v(is,ie,js,je,isd,ied,jsd,jed, vb, u, v, ub, hord_mt, gridstruct%dy, gridstruct%rdy, &
1134 npx, npy, flagstruct%grid_type, flagstruct%lim_fac, bounded_domain)
1138 ke(i,j) = vb(i,j)*ub(i,j)
1142 if (flagstruct%grid_type < 3)
then 1144 if (bounded_domain)
then 1149 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j)-(vc(i-1,j)+vc(i,j))*cosa(i,j))*rsina(i,j)
1158 ub(1,j) = dt5*(ut(1,j-1)+ut(1,j))
1163 if ( (j==1 .or. j==npy) )
then 1166 ub(i,j) = dt4*(-ut(i,j-2) + 3.*(ut(i,j-1)+ut(i,j)) - ut(i,j+1))
1170 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j)-(vc(i-1,j)+vc(i,j))*cosa(i,j))*rsina(i,j)
1175 if ( (ie+1)==npx )
then 1177 ub(npx,j) = dt5*(ut(npx,j-1)+ut(npx,j))
1185 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j))
1190 call xtp_u(is,ie,js,je, isd,ied,jsd,jed, ub, u, v, vb, hord_mt, gridstruct%dx, gridstruct%rdx, &
1191 npx, npy, flagstruct%grid_type, flagstruct%lim_fac, bounded_domain)
1195 ke(i,j) = 0.5*(ke(i,j) + ub(i,j)*vb(i,j))
1202 if (.not. bounded_domain)
then 1204 if ( sw_corner )
then 1205 ke(1,1) = dt6*( (ut(1,1) + ut(1,0)) * u(1,1) + &
1206 (vt(1,1) + vt(0,1)) * v(1,1) + &
1207 (ut(1,1) + vt(1,1)) * u(0,1) )
1209 if ( se_corner )
then 1211 ke(i,1) = dt6*( (ut(i,1) + ut(i, 0)) * u(i-1,1) + &
1212 (vt(i,1) + vt(i-1,1)) * v(i, 1) + &
1213 (ut(i,1) - vt(i-1,1)) * u(i, 1) )
1215 if ( ne_corner )
then 1217 ke(i,j) = dt6*( (ut(i,j ) + ut(i,j-1)) * u(i-1,j) + &
1218 (vt(i,j ) + vt(i-1,j)) * v(i,j-1) + &
1219 (ut(i,j-1) + vt(i-1,j)) * u(i,j ) )
1221 if ( nw_corner )
then 1223 ke(1,j) = dt6*( (ut(1, j) + ut(1,j-1)) * u(1,j ) + &
1224 (vt(1, j) + vt(0, j)) * v(1,j-1) + &
1225 (ut(1,j-1) - vt(1, j)) * u(0,j ) )
1232 vt(i,j) = u(i,j)*dx(i,j)
1237 ut(i,j) = v(i,j)*dy(i,j)
1244 wk(i,j) = rarea(i,j)*(vt(i,j)-vt(i,j+1)-ut(i,j)+ut(i+1,j))
1248 if ( .not. hydrostatic )
then 1249 if( flagstruct%do_f3d )
then 1254 w(i,j) = w(i,j)/delp(i,j) + dt2*gridstruct%w00(i,j) * &
1255 ( gridstruct%a11(i,j)*(u(i,j)+u(i,j+1)) + &
1256 gridstruct%a12(i,j)*(v(i,j)+v(i+1,j)) )
1263 w(i,j) = w(i,j)/delp(i,j)
1267 if ( damp_w>1.e-5 )
then 1270 w(i,j) = w(i,j) + dw(i,j)
1279 q_con(i,j) = q_con(i,j)/delp(i,j)
1292 if (bounded_domain)
then 1296 ptc(i,j) = (u(i,j)-0.5*(va(i,j-1)+va(i,j))*cosa_v(i,j)) &
1297 *dyc(i,j)*sina_v(i,j)
1303 vort(i,j) = (v(i,j) - 0.5*(ua(i-1,j)+ua(i,j))*cosa_u(i,j)) &
1304 *dxc(i,j)*sina_u(i,j)
1311 if ( (j==1 .or. j==npy) )
then 1313 if (vc(i,j) > 0)
then 1314 ptc(i,j) = u(i,j)*dyc(i,j)*sin_sg(i,j-1,4)
1316 ptc(i,j) = u(i,j)*dyc(i,j)*sin_sg(i,j,2)
1321 ptc(i,j) = (u(i,j)-0.5*(va(i,j-1)+va(i,j))*cosa_v(i,j)) &
1322 *dyc(i,j)*sina_v(i,j)
1329 vort(i,j) = (v(i,j) - 0.5*(ua(i-1,j)+ua(i,j))*cosa_u(i,j)) &
1330 *dxc(i,j)*sina_u(i,j)
1333 if (uc(1,j) > 0)
then 1334 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(0,j,3)
1336 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(1,j,1)
1339 if ( (ie+1)==npx )
then 1340 if (uc(npx,j) > 0)
then 1341 vort(npx,j) = v(npx,j)*dxc(npx,j)* &
1344 vort(npx,j) = v(npx,j)*dxc(npx,j)* &
1353 delpc(i,j) = vort(i,j-1) - vort(i,j) + ptc(i-1,j) - ptc(i,j)
1358 if (sw_corner) delpc(1, 1) = delpc(1, 1) - vort(1, 0)
1359 if (se_corner) delpc(npx, 1) = delpc(npx, 1) - vort(npx, 0)
1360 if (ne_corner) delpc(npx,npy) = delpc(npx,npy) + vort(npx,npy)
1361 if (nw_corner) delpc(1, npy) = delpc(1, npy) + vort(1, npy)
1365 delpc(i,j) = gridstruct%rarea_c(i,j)*delpc(i,j)
1366 damp = gridstruct%da_min_c*max(d2_bg, min(0.20, dddmp*abs(delpc(i,j)*dt)))
1367 vort(i,j) = damp*delpc(i,j)
1368 ke(i,j) = ke(i,j) + vort(i,j)
1378 delpc(i,j) = divg_d(i,j)
1386 fill_c = (nt/=0) .and. (flagstruct%grid_type<3) .and. &
1387 ( sw_corner .or. se_corner .or. ne_corner .or. nw_corner ) &
1388 .and. .not. bounded_domain
1390 if ( fill_c )
call fill_corners(divg_d, npx, npy, fill=xdir, bgrid=.true.)
1392 do i=is-1-nt,ie+1+nt
1393 vc(i,j) = (divg_d(i+1,j)-divg_d(i,j))*divg_u(i,j)
1397 if ( fill_c )
call fill_corners(divg_d, npx, npy, fill=ydir, bgrid=.true.)
1398 do j=js-1-nt,je+1+nt
1400 uc(i,j) = (divg_d(i,j+1)-divg_d(i,j))*divg_v(i,j)
1404 if ( fill_c )
call fill_corners(vc, uc, npx, npy, vector=.true., dgrid=.true.)
1407 divg_d(i,j) = uc(i,j-1) - uc(i,j) + vc(i-1,j) - vc(i,j)
1412 if (sw_corner) divg_d(1, 1) = divg_d(1, 1) - uc(1, 0)
1413 if (se_corner) divg_d(npx, 1) = divg_d(npx, 1) - uc(npx, 0)
1414 if (ne_corner) divg_d(npx,npy) = divg_d(npx,npy) + uc(npx,npy)
1415 if (nw_corner) divg_d(1, npy) = divg_d(1, npy) + uc(1, npy)
1417 if ( .not. gridstruct%stretched_grid )
then 1420 divg_d(i,j) = divg_d(i,j)*gridstruct%rarea_c(i,j)
1427 if ( dddmp<1.e-5)
then 1430 if ( flagstruct%grid_type < 3 )
then 1432 call a2b_ord4(wk, vort, gridstruct, npx, npy, is, ie, js, je, ng, .false.)
1436 vort(i,j) = abs(dt)*sqrt(delpc(i,j)**2 + vort(i,j)**2)
1440 call smag_corner(abs(dt), u, v, ua, va, vort, bd, npx, npy, gridstruct, ng)
1444 if (gridstruct%stretched_grid )
then 1446 dd8 = gridstruct%da_min * d4_bg**n2
1448 dd8 = ( gridstruct%da_min_c*d4_bg )**n2
1453 damp2 = gridstruct%da_min_c*max(d2_bg, min(0.20, dddmp*vort(i,j)))
1454 vort(i,j) = damp2*delpc(i,j) + dd8*divg_d(i,j)
1455 ke(i,j) = ke(i,j) + vort(i,j)
1461 if ( d_con > 1.e-5 )
then 1464 ub(i,j) = vort(i,j) - vort(i+1,j)
1469 vb(i,j) = vort(i,j) - vort(i,j+1)
1475 if ( hydrostatic )
then 1478 vort(i,j) = wk(i,j) + f0(i,j)
1482 if ( flagstruct%do_f3d )
then 1485 vort(i,j) = wk(i,j) + f0(i,j)*z_rat(i,j)
1491 vort(i,j) = wk(i,j) + f0(i,j)
1497 call fv_tp_2d(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx, fy, &
1498 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, flagstruct%lim_fac)
1501 u(i,j) = vt(i,j) + ke(i,j) - ke(i+1,j) + fy(i,j)
1506 v(i,j) = ut(i,j) + ke(i,j) - ke(i,j+1) - fx(i,j)
1512 if ( damp_v>1.e-5 )
then 1513 damp4 = (damp_v*gridstruct%da_min_c)**(nord_v+1)
1514 call del6_vt_flux(nord_v, npx, npy, damp4, wk, vort, ut, vt, gridstruct, bd)
1517 if ( d_con > 1.e-5 .or. flagstruct%do_skeb )
then 1520 ub(i,j) = (ub(i,j) + vt(i,j))*rdx(i,j)
1521 fy(i,j) = u(i,j)*rdx(i,j)
1522 gy(i,j) = fy(i,j)*ub(i,j)
1527 vb(i,j) = (vb(i,j) - ut(i,j))*rdy(i,j)
1528 fx(i,j) = v(i,j)*rdy(i,j)
1529 gx(i,j) = fx(i,j)*vb(i,j)
1538 u2 = fy(i,j) + fy(i,j+1)
1539 du2 = ub(i,j) + ub(i,j+1)
1540 v2 = fx(i,j) + fx(i+1,j)
1541 dv2 = vb(i,j) + vb(i+1,j)
1544 heat_source(i,j) = delp(i,j)*(heat_source(i,j) - damp*rsin2(i,j)*( &
1545 (ub(i,j)**2 + ub(i,j+1)**2 + vb(i,j)**2 + vb(i+1,j)**2) &
1546 + 2.*(gy(i,j)+gy(i,j+1)+gx(i,j)+gx(i+1,j)) &
1547 - cosa_s(i,j)*(u2*dv2 + v2*du2 + du2*dv2)) )
1548 if (flagstruct%do_skeb)
then 1549 diss_est(i,j) = diss_est(i,j)-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))
1559 if ( damp_v>1.e-5 )
then 1562 u(i,j) = u(i,j) + vt(i,j)
1567 v(i,j) = v(i,j) - ut(i,j)
1580 subroutine del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
1588 integer,
intent(in):: nord, npx, npy
1589 real,
intent(in):: damp
1591 real,
intent(inout):: q(bd%isd:bd%ied, bd%jsd:bd%jed)
1594 real,
intent(out):: d2(bd%isd:bd%ied, bd%jsd:bd%jed)
1595 real,
intent(out):: fx2(bd%isd:bd%ied+1,bd%jsd:bd%jed), fy2(bd%isd:bd%ied,bd%jsd:bd%jed+1)
1596 integer i,j, nt, n, i1, i2, j1, j2
1598 logical :: bounded_domain
1601 real,
pointer,
dimension(:,:,:) :: sin_sg
1602 real,
pointer,
dimension(:,:) :: rdxc, rdyc, dx,dy
1605 integer :: is, ie, js, je
1608 sin_sg => gridstruct%sin_sg
1609 rdxc => gridstruct%rdxc
1610 rdyc => gridstruct%rdyc
1614 bounded_domain = gridstruct%bounded_domain
1621 i1 = is-1-nord; i2 = ie+1+nord
1622 j1 = js-1-nord; j2 = je+1+nord
1626 d2(i,j) = damp*q(i,j)
1630 if( nord>0 .and. .not. bounded_domain)
call copy_corners(d2, npx, npy, 1, bounded_domain, bd, gridstruct%sw_corner, &
1631 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1632 do j=js-nord,je+nord
1633 do i=is-nord,ie+nord+1
1635 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)
1637 fx2(i,j) = gridstruct%del6_v(i,j)*(d2(i-1,j)-d2(i,j))
1642 if( nord>0 .and. .not. bounded_domain)
call copy_corners(d2, npx, npy, 2, bounded_domain, bd, gridstruct%sw_corner, &
1643 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1644 do j=js-nord,je+nord+1
1645 do i=is-nord,ie+nord
1647 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)
1649 fy2(i,j) = gridstruct%del6_u(i,j)*(d2(i,j-1)-d2(i,j))
1657 do j=js-nt-1,je+nt+1
1658 do i=is-nt-1,ie+nt+1
1659 d2(i,j) = (fx2(i,j)-fx2(i+1,j)+fy2(i,j)-fy2(i,j+1))*gridstruct%rarea(i,j)
1663 if (.not. bounded_domain)
call copy_corners(d2, npx, npy, 1, bounded_domain, bd, gridstruct%sw_corner, &
1664 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1669 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)
1671 fx2(i,j) = gridstruct%del6_v(i,j)*(d2(i,j)-d2(i-1,j))
1676 if (.not. bounded_domain)
call copy_corners(d2, npx, npy, 2, bounded_domain, bd, &
1677 gridstruct%sw_corner, gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1682 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)
1684 fy2(i,j) = gridstruct%del6_u(i,j)*(d2(i,j)-d2(i,j-1))
1697 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1698 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v
1699 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1700 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1):: divg_d
1704 real uf(bd%is-2:bd%ie+2,bd%js-1:bd%je+2)
1705 real vf(bd%is-1:bd%ie+2,bd%js-2:bd%je+2)
1709 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
1710 real,
pointer,
dimension(:,:) :: dxc,dyc
1712 integer :: is, ie, js, je
1714 logical :: bounded_domain
1721 npx = flagstruct%npx
1722 npy = flagstruct%npy
1723 bounded_domain = gridstruct%bounded_domain
1725 sin_sg => gridstruct%sin_sg
1726 cos_sg => gridstruct%cos_sg
1727 dxc => gridstruct%dxc
1728 dyc => gridstruct%dyc
1730 if (bounded_domain)
then 1731 is2 = is; ie1 = ie+1
1733 is2 = max(2,is); ie1 = min(npx-1,ie+1)
1736 if (flagstruct%grid_type==4)
then 1739 uf(i,j) = u(i,j)*dyc(i,j)
1744 vf(i,j) = v(i,j)*dxc(i,j)
1749 divg_d(i,j) = gridstruct%rarea_c(i,j)*(vf(i,j-1)-vf(i,j)+uf(i-1,j)-uf(i,j))
1759 if ( j==1 .or. j==npy )
then 1761 uf(i,j) = u(i,j)*dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1765 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))) &
1766 * dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1773 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))) &
1774 *dxc(i,j)*0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))
1776 if ( is == 1 ) vf(1, j) = v(1, j)*dxc(1, j)*0.5*(sin_sg(0,j,3)+sin_sg(1,j,1))
1777 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))
1782 divg_d(i,j) = vf(i,j-1) - vf(i,j) + uf(i-1,j) - uf(i,j)
1787 if (gridstruct%sw_corner) divg_d(1, 1) = divg_d(1, 1) - vf(1, 0)
1788 if (gridstruct%se_corner) divg_d(npx, 1) = divg_d(npx, 1) - vf(npx, 0)
1789 if (gridstruct%ne_corner) divg_d(npx,npy) = divg_d(npx,npy) + vf(npx,npy)
1790 if (gridstruct%nw_corner) divg_d(1, npy) = divg_d(1, npy) + vf(1, npy)
1794 divg_d(i,j) = gridstruct%rarea_c(i,j)*divg_d(i,j)
1804 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1805 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed):: v
1806 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1807 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1):: divg_d
1812 real uf(bd%isd:bd%ied,bd%jsd:bd%jed+1)
1813 real vf(bd%isd:bd%ied+1,bd%jsd:bd%jed)
1817 real,
pointer,
dimension(:,:) :: rarea_c
1819 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
1820 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v
1821 real,
pointer,
dimension(:,:) :: sina_u, sina_v
1822 real,
pointer,
dimension(:,:) :: dxc,dyc
1824 integer :: isd, ied, jsd, jed
1832 npx = flagstruct%npx
1833 npy = flagstruct%npy
1835 rarea_c => gridstruct%rarea_c
1836 sin_sg => gridstruct%sin_sg
1837 cos_sg => gridstruct%cos_sg
1838 cosa_u => gridstruct%cosa_u
1839 cosa_v => gridstruct%cosa_v
1840 sina_u => gridstruct%sina_u
1841 sina_v => gridstruct%sina_v
1842 dxc => gridstruct%dxc
1843 dyc => gridstruct%dyc
1847 if (flagstruct%grid_type==4)
then 1850 uf(i,j) = u(i,j)*dyc(i,j)
1855 vf(i,j) = v(i,j)*dxc(i,j)
1860 divg_d(i,j) = rarea_c(i,j)*(vf(i,j-1)-vf(i,j)+uf(i-1,j)-uf(i,j))
1867 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))) &
1868 * dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1874 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))) &
1875 *dxc(i,j)*0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))
1881 divg_d(i,j) = (vf(i,j-1) - vf(i,j) + uf(i-1,j) - uf(i,j))*rarea_c(i,j)
1911 subroutine smag_corner(dt, u, v, ua, va, smag_c, bd, npx, npy, gridstruct, ng)
1915 real,
intent(in):: dt
1916 integer,
intent(IN) :: npx, npy, ng
1917 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1918 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v
1919 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1920 real,
intent(out),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: smag_c
1923 real:: ut(bd%isd:bd%ied+1,bd%jsd:bd%jed)
1924 real:: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1925 real:: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
1926 real:: sh(bd%isd:bd%ied,bd%jsd:bd%jed)
1930 real,
pointer,
dimension(:,:) :: dxc, dyc, dx, dy, rarea, rarea_c
1932 integer :: is, ie, js, je
1933 integer :: isd, ied, jsd, jed
1945 dxc => gridstruct%dxc
1946 dyc => gridstruct%dyc
1949 rarea => gridstruct%rarea
1950 rarea_c => gridstruct%rarea_c
1952 is2 = max(2,is); ie1 = min(npx-1,ie+1)
1959 ut(i,j) = u(i,j)*dyc(i,j)
1964 vt(i,j) = v(i,j)*dxc(i,j)
1969 smag_c(i,j) = rarea_c(i,j)*(vt(i,j-1)-vt(i,j)-ut(i-1,j)+ut(i,j))
1977 vt(i,j) = u(i,j)*dx(i,j)
1982 ut(i,j) = v(i,j)*dy(i,j)
1988 wk(i,j) = rarea(i,j)*(vt(i,j)-vt(i,j+1)+ut(i,j)-ut(i+1,j))
1991 call a2b_ord4(wk, sh, gridstruct, npx, npy, is, ie, js, je, ng, .false.)
1994 smag_c(i,j) = dt*sqrt( sh(i,j)**2 + smag_c(i,j)**2 )
2001 subroutine xtp_u(is,ie,js,je,isd,ied,jsd,jed,c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, lim_fac,bounded_domain)
2003 integer,
intent(in):: is,ie,js,je, isd,ied,jsd,jed
2004 real,
INTENT(IN):: u(isd:ied,jsd:jed+1)
2005 real,
INTENT(IN):: v(isd:ied+1,jsd:jed)
2006 real,
INTENT(IN):: c(is:ie+1,js:je+1)
2007 real,
INTENT(out):: flux(is:ie+1,js:je+1)
2008 real,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
2009 real,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
2010 integer,
INTENT(IN) :: iord, npx, npy, grid_type
2011 logical,
INTENT(IN) :: bounded_domain
2012 real,
INTENT(IN) :: lim_fac
2014 real,
dimension(is-1:ie+1):: bl, br, b0
2015 logical,
dimension(is-1:ie+1):: smt5, smt6
2016 logical,
dimension(is:ie+1):: hi5, hi6
2018 real al(is-1:ie+2), dm(is-2:ie+2)
2020 real dl, dr, xt, pmp, lac, cfl
2021 real pmp_1, lac_1, pmp_2, lac_2
2022 real x0, x1, x0L, x0R
2027 if ( bounded_domain .or. grid_type>3 )
then 2028 is3 = is-1 ; ie3 = ie+1
2030 is3 = max(3,is-1) ; ie3 = min(npx-3,ie+1)
2034 if ( iord < 8 )
then 2040 al(i) =
p1*(u(i-1,j)+u(i,j)) +
p2*(u(i-2,j)+u(i+1,j))
2043 bl(i) = al(i ) - u(i,j)
2044 br(i) = al(i+1) - u(i,j)
2047 if ( (.not.bounded_domain) .and. grid_type < 3)
then 2049 xt =
c3*u(1,j) +
c2*u(2,j) +
c1*u(3,j)
2052 br(2) = al(3) - u(2,j)
2053 if( j==1 .or. j==npy )
then 2059 bl(0) =
c1*u(-2,j) +
c2*u(-1,j) +
c3*u(0,j) - u(0,j)
2060 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)) &
2061 + ((2.*dx(1,j)+dx( 2,j))*(u(1,j))-dx(1,j)*u( 2,j))/(dx(1,j)+dx( 2,j)) )
2067 if ( (ie+1)==npx )
then 2068 bl(npx-2) = al(npx-2) - u(npx-2,j)
2069 xt =
c1*u(npx-3,j) +
c2*u(npx-2,j) +
c3*u(npx-1,j)
2070 br(npx-2) = xt - u(npx-2,j)
2071 bl(npx-1) = xt - u(npx-1,j)
2072 if( j==1 .or. j==npy )
then 2078 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)) &
2079 + ( (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)) )
2080 br(npx-1) = xt - u(npx-1,j)
2081 bl(npx ) = xt - u(npx ,j)
2082 br(npx) =
c3*u(npx,j) +
c2*u(npx+1,j) +
c1*u(npx+2,j) - u(npx,j)
2089 b0(i) = bl(i) + br(i)
2095 smt5(i) = abs(lim_fac*b0(i)) < abs(bl(i)-br(i))
2099 if( c(i,j)>0. )
then 2100 cfl = c(i,j)*rdx(i-1,j)
2101 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2102 flux(i,j) = u(i-1,j)
2104 cfl = c(i,j)*rdx(i,j)
2105 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2108 if (smt5(i-1).or.smt5(i)) flux(i,j) = flux(i,j) + fx0(i)
2111 elseif ( iord==2 )
then 2115 if( c(i,j)>0. )
then 2116 cfl = c(i,j)*rdx(i-1,j)
2117 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2119 cfl = c(i,j)*rdx(i,j)
2120 flux(i,j) = u(i,j) + (1.+cfl)*(bl(i)+cfl*b0(i))
2124 elseif ( iord==3 )
then 2128 x1 = abs(bl(i)-br(i))
2130 smt6(i) = 3.*x0 < x1
2134 hi5(i) = smt5(i-1) .and. smt5(i)
2135 hi6(i) = smt6(i-1) .or. smt6(i)
2138 if( c(i,j)>0. )
then 2139 cfl = c(i,j)*rdx(i-1,j)
2141 fx0(i) = br(i-1) - cfl*b0(i-1)
2142 elseif( hi5(i) )
then 2143 fx0(i) = sign(min(abs(bl(i-1)),abs(br(i-1))), br(i-1))
2145 flux(i,j) = u(i-1,j) + (1.-cfl)*fx0(i)
2147 cfl = c(i,j)*rdx(i,j)
2149 fx0(i) = bl(i) + cfl*b0(i)
2150 elseif( hi5(i) )
then 2151 fx0(i) = sign(min(abs(bl(i)),abs(br(i))), bl(i))
2153 flux(i,j) = u(i,j) + (1.+cfl)*fx0(i)
2157 elseif ( iord==4 )
then 2161 x1 = abs(bl(i)-br(i))
2163 smt6(i) = 3.*x0 < x1
2166 hi5(i) = smt5(i-1) .and. smt5(i)
2167 hi6(i) = smt6(i-1) .or. smt6(i)
2168 hi5(i) = hi5(i) .or. hi6(i)
2172 if( c(i,j)>0. )
then 2173 cfl = c(i,j)*rdx(i-1,j)
2174 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2175 flux(i,j) = u(i-1,j)
2177 cfl = c(i,j)*rdx(i,j)
2178 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2181 if ( hi5(i) ) flux(i,j) = flux(i,j) + fx0(i)
2189 smt5(i) = bl(i)*br(i) < 0.
2193 smt5(i) = 3.*abs(b0(i)) < abs(bl(i)-br(i))
2199 if( c(i,j)>0. )
then 2200 cfl = c(i,j)*rdx(i-1,j)
2201 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2202 flux(i,j) = u(i-1,j)
2204 cfl = c(i,j)*rdx(i,j)
2205 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2208 if (smt5(i-1).or.smt5(i)) flux(i,j) = flux(i,j) + fx0(i)
2219 xt = 0.25*(u(i+1,j) - u(i-1,j))
2220 dm(i) = sign(min(abs(xt), max(u(i-1,j), u(i,j), u(i+1,j)) - u(i,j), &
2221 u(i,j) - min(u(i-1,j), u(i,j), u(i+1,j))), xt)
2224 dq(i) = u(i+1,j) - u(i,j)
2227 if (grid_type < 3)
then 2230 al(i) = 0.5*(u(i-1,j)+u(i,j)) +
r3*(dm(i-1) - dm(i))
2237 bl(i) = -sign(min(abs(xt), abs(al(i )-u(i,j))), xt)
2238 br(i) = sign(min(abs(xt), abs(al(i+1)-u(i,j))), xt)
2240 elseif( iord==9 )
then 2243 lac_1 = pmp_1 + 1.5*dq(i+1)
2244 bl(i) = min(max(0., pmp_1, lac_1), max(al(i )-u(i,j), min(0., pmp_1, lac_1)))
2246 lac_2 = pmp_2 - 1.5*dq(i-2)
2247 br(i) = min(max(0., pmp_2, lac_2), max(al(i+1)-u(i,j), min(0., pmp_2, lac_2)))
2249 elseif( iord==10 )
then 2251 bl(i) = al(i ) - u(i,j)
2252 br(i) = al(i+1) - u(i,j)
2255 if ( abs(dm(i-1))+abs(dm(i+1)) <
near_zero )
then 2260 elseif( abs(3.*(bl(i)+br(i))) > abs(bl(i)-br(i)) )
then 2262 lac_1 = pmp_1 + 1.5*dq(i+1)
2263 bl(i) = min(max(0., pmp_1, lac_1), max(bl(i), min(0., pmp_1, lac_1)))
2265 lac_2 = pmp_2 - 1.5*dq(i-2)
2266 br(i) = min(max(0., pmp_2, lac_2), max(br(i), min(0., pmp_2, lac_2)))
2272 bl(i) = al(i ) - u(i,j)
2273 br(i) = al(i+1) - u(i,j)
2281 if ( is==1 .and. .not. bounded_domain)
then 2282 br(2) = al(3) - u(2,j)
2283 xt =
s15*u(1,j) +
s11*u(2,j) -
s14*dm(2)
2286 if( j==1 .or. j==npy )
then 2292 bl(0) =
s14*dm(-1) -
s11*dq(-1)
2293 x0l = 0.5*((2.*dx(0,j)+dx(-1,j))*(u(0,j)) &
2294 - dx(0,j)*(u(-1,j)))/(dx(0,j)+dx(-1,j))
2295 x0r = 0.5*((2.*dx(1,j)+dx(2,j))*(u(1,j)) &
2296 - dx(1,j)*(u(2,j)))/(dx(1,j)+dx(2,j))
2301 call pert_ppm(1, u(2,j), bl(2), br(2), -1)
2304 if ( (ie+1)==npx .and. .not. bounded_domain)
then 2305 bl(npx-2) = al(npx-2) - u(npx-2,j)
2306 xt =
s15*u(npx-1,j) +
s11*u(npx-2,j) +
s14*dm(npx-2)
2307 br(npx-2) = xt - u(npx-2,j)
2308 bl(npx-1) = xt - u(npx-1,j)
2309 if( j==1 .or. j==npy )
then 2315 br(npx) =
s11*dq(npx) -
s14*dm(npx+1)
2316 x0l = 0.5*( (2.*dx(npx-1,j)+dx(npx-2,j))*(u(npx-1,j)) &
2317 - dx(npx-1,j)*(u(npx-2,j)))/(dx(npx-1,j)+dx(npx-2,j))
2318 x0r = 0.5*( (2.*dx(npx,j)+dx(npx+1,j))*(u(npx,j)) &
2319 - dx(npx,j)*(u(npx+1,j)))/(dx(npx,j)+dx(npx+1,j))
2321 br(npx-1) = xt - u(npx-1,j)
2322 bl(npx ) = xt - u(npx ,j)
2324 call pert_ppm(1, u(npx-2,j), bl(npx-2), br(npx-2), -1)
2330 al(i) = 0.5*(u(i-1,j)+u(i,j)) +
r3*(dm(i-1) - dm(i))
2335 lac = pmp + 1.5*dq(i+1)
2336 bl(i) = min(max(0., pmp, lac), max(al(i )-u(i,j), min(0.,pmp, lac)))
2338 lac = pmp - 1.5*dq(i-2)
2339 br(i) = min(max(0., pmp, lac), max(al(i+1)-u(i,j), min(0.,pmp, lac)))
2344 if( c(i,j)>0. )
then 2345 cfl = c(i,j)*rdx(i-1,j)
2346 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1)-cfl*(bl(i-1)+br(i-1)))
2348 cfl = c(i,j)*rdx(i,j)
2349 flux(i,j) = u(i, j) + (1.+cfl)*(bl(i )+cfl*(bl(i )+br(i )))
2356 end subroutine xtp_u 2359 subroutine ytp_v(is,ie,js,je,isd,ied,jsd,jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, lim_fac, bounded_domain)
2360 integer,
intent(in):: is,ie,js,je, isd,ied,jsd,jed
2361 integer,
intent(IN):: jord
2362 real,
INTENT(IN) :: u(isd:ied,jsd:jed+1)
2363 real,
INTENT(IN) :: v(isd:ied+1,jsd:jed)
2364 real,
INTENT(IN) :: c(is:ie+1,js:je+1)
2365 real,
INTENT(OUT):: flux(is:ie+1,js:je+1)
2366 real,
INTENT(IN) :: dy(isd:ied+1,jsd:jed)
2367 real,
INTENT(IN) :: rdy(isd:ied+1,jsd:jed)
2368 integer,
INTENT(IN) :: npx, npy, grid_type
2369 logical,
INTENT(IN) :: bounded_domain
2370 real,
INTENT(IN) :: lim_fac
2372 logical,
dimension(is:ie+1,js-1:je+1):: smt5, smt6
2373 logical,
dimension(is:ie+1):: hi5, hi6
2375 real dm(is:ie+1,js-2:je+2)
2376 real al(is:ie+1,js-1:je+2)
2377 real,
dimension(is:ie+1,js-1:je+1):: bl, br, b0
2378 real dq(is:ie+1,js-3:je+2)
2379 real xt, dl, dr, pmp, lac, cfl
2380 real pmp_1, lac_1, pmp_2, lac_2
2381 real x0, x1, x0R, x0L
2382 integer i, j, is1, ie1, js3, je3
2384 if ( bounded_domain .or. grid_type>3 )
then 2385 js3 = js-1; je3 = je+1
2387 js3 = max(3,js-1); je3 = min(npy-3,je+1)
2395 al(i,j) =
p1*(v(i,j-1)+v(i,j)) +
p2*(v(i,j-2)+v(i,j+1))
2400 bl(i,j) = al(i,j ) - v(i,j)
2401 br(i,j) = al(i,j+1) - v(i,j)
2405 if ( (.not.bounded_domain) .and. grid_type < 3)
then 2408 bl(i,0) =
c1*v(i,-2) +
c2*v(i,-1) +
c3*v(i,0) - v(i,0)
2409 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)) &
2410 + ((2.*dy(i,1)+dy(i, 2))*v(i,1)-dy(i,1)*v(i, 2))/(dy(i,1)+dy(i, 2)) )
2411 br(i,0) = xt - v(i,0)
2412 bl(i,1) = xt - v(i,1)
2413 xt =
c3*v(i,1) +
c2*v(i,2) +
c1*v(i,3)
2414 br(i,1) = xt - v(i,1)
2415 bl(i,2) = xt - v(i,2)
2416 br(i,2) = al(i,3) - v(i,2)
2424 if ( (ie+1)==npx )
then 2433 if( (je+1)==npy )
then 2435 bl(i,npy-2) = al(i,npy-2) - v(i,npy-2)
2436 xt =
c1*v(i,npy-3) +
c2*v(i,npy-2) +
c3*v(i,npy-1)
2437 br(i,npy-2) = xt - v(i,npy-2)
2438 bl(i,npy-1) = xt - v(i,npy-1)
2439 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)) &
2440 + ((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)) )
2441 br(i,npy-1) = xt - v(i,npy-1)
2442 bl(i,npy ) = xt - v(i,npy)
2443 br(i,npy) =
c3*v(i,npy)+
c2*v(i,npy+1) +
c1*v(i,npy+2) - v(i,npy)
2451 if ( (ie+1)==npx )
then 2464 b0(i,j) = bl(i,j) + br(i,j)
2473 smt5(i,j) = abs(lim_fac*b0(i,j)) < abs(bl(i,j)-br(i,j))
2479 if( c(i,j)>0. )
then 2480 cfl = c(i,j)*rdy(i,j-1)
2481 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2482 flux(i,j) = v(i,j-1)
2484 cfl = c(i,j)*rdy(i,j)
2485 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2488 if (smt5(i,j-1).or.smt5(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2492 elseif ( jord==2 )
then 2496 if( c(i,j)>0. )
then 2497 cfl = c(i,j)*rdy(i,j-1)
2498 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2500 cfl = c(i,j)*rdy(i,j)
2501 flux(i,j) = v(i,j) + (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2506 elseif ( jord==3 )
then 2511 x1 = abs(bl(i,j)-br(i,j))
2513 smt6(i,j) = 3.*x0 < x1
2519 hi5(i) = smt5(i,j-1) .and. smt5(i,j)
2520 hi6(i) = smt6(i,j-1) .or. smt6(i,j)
2523 if( c(i,j)>0. )
then 2524 cfl = c(i,j)*rdy(i,j-1)
2526 fx0(i) = br(i,j-1) - cfl*b0(i,j-1)
2527 elseif ( hi5(i) )
then 2528 fx0(i) = sign(min(abs(bl(i,j-1)),abs(br(i,j-1))), br(i,j-1))
2530 flux(i,j) = v(i,j-1) + (1.-cfl)*fx0(i)
2532 cfl = c(i,j)*rdy(i,j)
2534 fx0(i) = bl(i,j) + cfl*b0(i,j)
2535 elseif ( hi5(i) )
then 2536 fx0(i) = sign(min(abs(bl(i,j)),abs(br(i,j))), bl(i,j))
2538 flux(i,j) = v(i,j) + (1.+cfl)*fx0(i)
2543 elseif ( jord==4 )
then 2548 x1 = abs(bl(i,j)-br(i,j))
2550 smt6(i,j) = 3.*x0 < x1
2556 hi5(i) = smt5(i,j-1) .and. smt5(i,j)
2557 hi6(i) = smt6(i,j-1) .or. smt6(i,j)
2558 hi5(i) = hi5(i) .or. hi6(i)
2562 if( c(i,j)>0. )
then 2563 cfl = c(i,j)*rdy(i,j-1)
2564 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2565 flux(i,j) = v(i,j-1)
2567 cfl = c(i,j)*rdy(i,j)
2568 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2571 if ( hi5(i) ) flux(i,j) = flux(i,j) + fx0(i)
2579 smt5(i,j) = bl(i,j)*br(i,j) < 0.
2585 if( c(i,j)>0. )
then 2586 cfl = c(i,j)*rdy(i,j-1)
2587 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2588 flux(i,j) = v(i,j-1)
2590 cfl = c(i,j)*rdy(i,j)
2591 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2594 if (smt5(i,j-1).or.smt5(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2601 smt6(i,j) = 3.*abs(b0(i,j)) < abs(bl(i,j)-br(i,j))
2607 if( c(i,j)>0. )
then 2608 cfl = c(i,j)*rdy(i,j-1)
2609 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2610 flux(i,j) = v(i,j-1)
2612 cfl = c(i,j)*rdy(i,j)
2613 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2616 if (smt6(i,j-1).or.smt6(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2628 xt = 0.25*(v(i,j+1) - v(i,j-1))
2629 dm(i,j) = sign(min(abs(xt), max(v(i,j-1), v(i,j), v(i,j+1)) - v(i,j), &
2630 v(i,j) - min(v(i,j-1), v(i,j), v(i,j+1))), xt)
2636 dq(i,j) = v(i,j+1) - v(i,j)
2640 if (grid_type < 3)
then 2643 al(i,j) = 0.5*(v(i,j-1)+v(i,j)) +
r3*(dm(i,j-1)-dm(i,j))
2651 bl(i,j) = -sign(min(abs(xt), abs(al(i,j)-v(i,j))), xt)
2652 br(i,j) = sign(min(abs(xt), abs(al(i,j+1)-v(i,j))), xt)
2655 elseif ( jord==9 )
then 2659 lac_1 = pmp_1 + 1.5*dq(i,j+1)
2660 bl(i,j) = min(max(0., pmp_1, lac_1), max(al(i,j)-v(i,j), min(0., pmp_1, lac_1)))
2661 pmp_2 = 2.*dq(i,j-1)
2662 lac_2 = pmp_2 - 1.5*dq(i,j-2)
2663 br(i,j) = min(max(0., pmp_2, lac_2), max(al(i,j+1)-v(i,j), min(0., pmp_2, lac_2)))
2666 elseif ( jord==10 )
then 2669 bl(i,j) = al(i,j ) - v(i,j)
2670 br(i,j) = al(i,j+1) - v(i,j)
2673 if ( abs(dm(i,j-1))+abs(dm(i,j+1)) <
near_zero )
then 2677 elseif( abs(3.*(bl(i,j)+br(i,j))) > abs(bl(i,j)-br(i,j)) )
then 2679 lac_1 = pmp_1 + 1.5*dq(i,j+1)
2680 bl(i,j) = min(max(0., pmp_1, lac_1), max(bl(i,j), min(0., pmp_1, lac_1)))
2681 pmp_2 = 2.*dq(i,j-1)
2682 lac_2 = pmp_2 - 1.5*dq(i,j-2)
2683 br(i,j) = min(max(0., pmp_2, lac_2), max(br(i,j), min(0., pmp_2, lac_2)))
2691 bl(i,j) = al(i,j ) - v(i,j)
2692 br(i,j) = al(i,j+1) - v(i,j)
2700 if( js==1 .and. .not. bounded_domain)
then 2702 br(i,2) = al(i,3) - v(i,2)
2703 xt =
s15*v(i,1) +
s11*v(i,2) -
s14*dm(i,2)
2704 br(i,1) = xt - v(i,1)
2705 bl(i,2) = xt - v(i,2)
2707 bl(i,0) =
s14*dm(i,-1) -
s11*dq(i,-1)
2710 xt =
t14*v(i,1) +
t12*v(i,2) +
t15*v(i,3)
2711 bl(i,1) = 2.*xt - v(i,1)
2712 xt =
t14*v(i,0) +
t12*v(i,-1) +
t15*v(i,-2)
2713 br(i,0) = 2.*xt - v(i,0)
2715 x0l = 0.5*( (2.*dy(i,0)+dy(i,-1))*(v(i,0)) &
2716 - dy(i,0)*(v(i,-1)))/(dy(i,0)+dy(i,-1))
2717 x0r = 0.5*( (2.*dy(i,1)+dy(i,2))*(v(i,1)) &
2718 - dy(i,1)*(v(i,2)))/(dy(i,1)+dy(i,2))
2721 bl(i,1) = xt - v(i,1)
2722 br(i,0) = xt - v(i,0)
2731 if ( (ie+1)==npx )
then 2738 call pert_ppm(ie-is+2, v(is,j), bl(is,j), br(is,j), -1)
2740 if( (je+1)==npy .and. .not. bounded_domain)
then 2742 bl(i,npy-2) = al(i,npy-2) - v(i,npy-2)
2743 xt =
s15*v(i,npy-1) +
s11*v(i,npy-2) +
s14*dm(i,npy-2)
2744 br(i,npy-2) = xt - v(i,npy-2)
2745 bl(i,npy-1) = xt - v(i,npy-1)
2746 br(i,npy) =
s11*dq(i,npy) -
s14*dm(i,npy+1)
2748 xt =
t14*v(i,npy-1) +
t12*v(i,npy-2) +
t15*v(i,npy-3)
2749 br(i,npy-1) = 2.*xt - v(i,npy-1)
2750 xt =
t14*v(i,npy) +
t12*v(i,npy+1) +
t15*v(i,npy+2)
2751 bl(i,npy ) = 2.*xt - v(i,npy)
2753 x0l= 0.5*((2.*dy(i,npy-1)+dy(i,npy-2))*(v(i,npy-1)) - &
2754 dy(i,npy-1)*(v(i,npy-2)))/(dy(i,npy-1)+dy(i,npy-2))
2755 x0r= 0.5*((2.*dy(i,npy)+dy(i,npy+1))*(v(i,npy)) - &
2756 dy(i,npy)*(v(i,npy+1)))/(dy(i,npy)+dy(i,npy+1))
2759 br(i,npy-1) = xt - v(i,npy-1)
2760 bl(i,npy ) = xt - v(i,npy)
2769 if ( (ie+1)==npx )
then 2776 call pert_ppm(ie-is+2, v(is,j), bl(is,j), br(is,j), -1)
2783 al(i,j) = 0.5*(v(i,j-1)+v(i,j)) +
r3*(dm(i,j-1)-dm(i,j))
2790 lac = pmp - 1.5*dq(i,j-2)
2791 br(i,j) = min(max(0.,pmp,lac), max(al(i,j+1)-v(i,j), min(0.,pmp,lac)))
2793 lac = pmp + 1.5*dq(i,j+1)
2794 bl(i,j) = min(max(0.,pmp,lac), max(al(i,j)-v(i,j), min(0.,pmp,lac)))
2803 cfl = c(i,j)*rdy(i,j-1)
2804 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1)-cfl*(bl(i,j-1)+br(i,j-1)))
2806 cfl = c(i,j)*rdy(i,j)
2807 flux(i,j) = v(i,j ) + (1.+cfl)*(bl(i,j )+cfl*(bl(i,j )+br(i,j )))
2814 end subroutine ytp_v 2823 subroutine d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, &
2824 bd, npx, npy, bounded_domain, grid_type)
2826 logical,
intent(in):: dord4
2827 real,
intent(in) :: u(bd%isd:bd%ied,bd%jsd:bd%jed+1)
2828 real,
intent(in) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed)
2829 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: uc
2830 real,
intent(out),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1):: vc
2831 real,
intent(out),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed ):: ua, va, ut, vt
2832 integer,
intent(IN) :: npx, npy, grid_type
2833 logical,
intent(IN) :: bounded_domain
2836 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: utmp, vtmp
2837 integer npt, i, j, ifirst, ilast, id
2838 integer :: is, ie, js, je
2839 integer :: isd, ied, jsd, jed
2841 real,
pointer,
dimension(:,:,:) :: sin_sg
2842 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v, cosa_s
2843 real,
pointer,
dimension(:,:) :: rsin_u, rsin_v, rsin2
2844 real,
pointer,
dimension(:,:) :: dxa,dya
2855 sin_sg => gridstruct%sin_sg
2856 cosa_u => gridstruct%cosa_u
2857 cosa_v => gridstruct%cosa_v
2858 cosa_s => gridstruct%cosa_s
2859 rsin_u => gridstruct%rsin_u
2860 rsin_v => gridstruct%rsin_v
2861 rsin2 => gridstruct%rsin2
2862 dxa => gridstruct%dxa
2863 dya => gridstruct%dya
2871 if (grid_type < 3 .and. .not. bounded_domain)
then 2881 if ( bounded_domain )
then 2885 utmp(i,j) =
a2*(u(i,j-1)+u(i,j+2)) +
a1*(u(i,j)+u(i,j+1))
2890 utmp(i,j) = 0.5*(u(i,j)+u(i,j+1))
2892 utmp(i,j) = 0.5*(u(i,j)+u(i,j+1))
2897 vtmp(i,j) =
a2*(v(i-1,j)+v(i+2,j)) +
a1*(v(i,j)+v(i+1,j))
2900 vtmp(i,j) = 0.5*(v(i,j)+v(i+1,j))
2902 vtmp(i,j) = 0.5*(v(i,j)+v(i+1,j))
2907 ua(i,j) = (utmp(i,j)-vtmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2908 va(i,j) = (vtmp(i,j)-utmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2916 do j=max(npt,js-1),min(npy-npt,je+1)
2917 do i=max(npt,isd),min(npx-npt,ied)
2918 utmp(i,j) =
a2*(u(i,j-1)+u(i,j+2)) +
a1*(u(i,j)+u(i,j+1))
2921 do j=max(npt,jsd),min(npy-npt,jed)
2922 do i=max(npt,is-1),min(npx-npt,ie+1)
2923 vtmp(i,j) =
a2*(v(i-1,j)+v(i+2,j)) +
a1*(v(i,j)+v(i+1,j))
2930 if (grid_type < 3)
then 2932 if ( js==1 .or. jsd<npt)
then 2935 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2936 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2940 if ( (je+1)==npy .or. jed>=(npy-npt))
then 2943 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2944 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2949 if ( is==1 .or. isd<npt )
then 2950 do j=max(npt,jsd),min(npy-npt,jed)
2952 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2953 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2957 if ( (ie+1)==npx .or. ied>=(npx-npt))
then 2958 do j=max(npt,jsd),min(npy-npt,jed)
2960 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2961 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2969 do j=js-1-id,je+1+id
2970 do i=is-1-id,ie+1+id
2971 ua(i,j) = (utmp(i,j)-vtmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2972 va(i,j) = (vtmp(i,j)-utmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2983 if( gridstruct%sw_corner )
then 2985 utmp(i,0) = -vtmp(0,1-i)
2988 if( gridstruct%se_corner )
then 2990 utmp(npx+i,0) = vtmp(npx,i+1)
2993 if( gridstruct%ne_corner )
then 2995 utmp(npx+i,npy) = -vtmp(npx,je-i)
2998 if( gridstruct%nw_corner )
then 3000 utmp(i,npy) = vtmp(0,je+i)
3004 if (grid_type < 3 .and. .not. bounded_domain)
then 3005 ifirst = max(3, is-1)
3006 ilast = min(npx-2,ie+2)
3016 uc(i,j) =
a2*(utmp(i-2,j)+utmp(i+1,j)) +
a1*(utmp(i-1,j)+utmp(i,j))
3017 ut(i,j) = (uc(i,j) - v(i,j)*cosa_u(i,j))*rsin_u(i,j)
3021 if (grid_type < 3)
then 3023 if( gridstruct%sw_corner )
then 3027 if( gridstruct%se_corner )
then 3028 ua(npx, 0) = va(npx,1)
3029 ua(npx+1,0) = va(npx,2)
3031 if( gridstruct%ne_corner )
then 3032 ua(npx, npy) = -va(npx,npy-1)
3033 ua(npx+1,npy) = -va(npx,npy-2)
3035 if( gridstruct%nw_corner )
then 3036 ua(-1,npy) = va(0,npy-2)
3037 ua( 0,npy) = va(0,npy-1)
3040 if( is==1 .and. .not. bounded_domain )
then 3042 uc(0,j) =
c1*utmp(-2,j) +
c2*utmp(-1,j) +
c3*utmp(0,j)
3045 if (ut(1,j) > 0.)
then 3046 uc(1,j) = ut(1,j)*sin_sg(0,j,3)
3048 uc(1,j) = ut(1,j)*sin_sg(1,j,1)
3050 uc(2,j) =
c1*utmp(3,j) +
c2*utmp(2,j) +
c3*utmp(1,j)
3051 ut(0,j) = (uc(0,j) - v(0,j)*cosa_u(0,j))*rsin_u(0,j)
3052 ut(2,j) = (uc(2,j) - v(2,j)*cosa_u(2,j))*rsin_u(2,j)
3056 if( (ie+1)==npx .and. .not. bounded_domain )
then 3058 uc(npx-1,j) =
c1*utmp(npx-3,j)+
c2*utmp(npx-2,j)+
c3*utmp(npx-1,j)
3060 if (ut(npx,j) > 0.)
then 3061 uc(npx,j) = ut(npx,j)*sin_sg(npx-1,j,3)
3063 uc(npx,j) = ut(npx,j)*sin_sg(npx,j,1)
3065 uc(npx+1,j) =
c3*utmp(npx,j) +
c2*utmp(npx+1,j) +
c1*utmp(npx+2,j)
3066 ut(npx-1,j) = (uc(npx-1,j)-v(npx-1,j)*cosa_u(npx-1,j))*rsin_u(npx-1,j)
3067 ut(npx+1,j) = (uc(npx+1,j)-v(npx+1,j)*cosa_u(npx+1,j))*rsin_u(npx+1,j)
3076 if( gridstruct%sw_corner )
then 3078 vtmp(0,j) = -utmp(1-j,0)
3081 if( gridstruct%nw_corner )
then 3083 vtmp(0,npy+j) = utmp(j+1,npy)
3086 if( gridstruct%se_corner )
then 3088 vtmp(npx,j) = utmp(ie+j,0)
3091 if( gridstruct%ne_corner )
then 3093 vtmp(npx,npy+j) = -utmp(ie-j,npy)
3096 if( gridstruct%sw_corner )
then 3100 if( gridstruct%se_corner )
then 3101 va(npx, 0) = ua(npx-1,0)
3102 va(npx,-1) = ua(npx-2,0)
3104 if( gridstruct%ne_corner )
then 3105 va(npx,npy ) = -ua(npx-1,npy)
3106 va(npx,npy+1) = -ua(npx-2,npy)
3108 if( gridstruct%nw_corner )
then 3109 va(0,npy) = ua(1,npy)
3110 va(0,npy+1) = ua(2,npy)
3113 if (grid_type < 3)
then 3116 if ( j==1 .and. .not. bounded_domain )
then 3119 if (vt(i,j) > 0.)
then 3120 vc(i,j) = vt(i,j)*sin_sg(i,j-1,4)
3122 vc(i,j) = vt(i,j)*sin_sg(i,j,2)
3125 elseif ( j==0 .or. j==(npy-1) .and. .not. bounded_domain )
then 3127 vc(i,j) =
c1*vtmp(i,j-2) +
c2*vtmp(i,j-1) +
c3*vtmp(i,j)
3128 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3130 elseif ( j==2 .or. j==(npy+1) .and. .not. bounded_domain )
then 3132 vc(i,j) =
c1*vtmp(i,j+1) +
c2*vtmp(i,j) +
c3*vtmp(i,j-1)
3133 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3135 elseif ( j==npy .and. .not. bounded_domain )
then 3138 if (vt(i,j) > 0.)
then 3139 vc(i,j) = vt(i,j)*sin_sg(i,j-1,4)
3141 vc(i,j) = vt(i,j)*sin_sg(i,j,2)
3147 vc(i,j) =
a2*(vtmp(i,j-2)+vtmp(i,j+1)) +
a1*(vtmp(i,j-1)+vtmp(i,j))
3148 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3156 vc(i,j) =
a2*(vtmp(i,j-2)+vtmp(i,j+1)) +
a1*(vtmp(i,j-1)+vtmp(i,j))
3167 real,
intent(in) :: ua(4)
3168 real,
intent(in) :: dxa(4)
3171 t1 = dxa(1) + dxa(2)
3172 t2 = dxa(3) + dxa(4)
3174 ((t2+dxa(3))*ua(3)-dxa(3)*ua(4)) / t2 )
3179 subroutine fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3181 integer,
intent(in):: dir
3182 real,
intent(inout):: q1(bd%isd:bd%ied,bd%jsd:bd%jed)
3183 real,
intent(inout):: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
3184 real,
intent(inout):: q3(bd%isd:bd%ied,bd%jsd:bd%jed)
3185 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3186 integer,
intent(IN) :: npx, npy
3189 integer :: is, ie, js, je
3190 integer :: isd, ied, jsd, jed
3203 if ( sw_corner )
then 3204 q1(-1,0) = q1(0,2); q1(0,0) = q1(0,1); q1(0,-1) = q1(-1,1)
3205 q2(-1,0) = q2(0,2); q2(0,0) = q2(0,1); q2(0,-1) = q2(-1,1)
3206 q3(-1,0) = q3(0,2); q3(0,0) = q3(0,1); q3(0,-1) = q3(-1,1)
3208 if ( se_corner )
then 3209 q1(npx+1,0) = q1(npx,2); q1(npx,0) = q1(npx,1); q1(npx,-1) = q1(npx+1,1)
3210 q2(npx+1,0) = q2(npx,2); q2(npx,0) = q2(npx,1); q2(npx,-1) = q2(npx+1,1)
3211 q3(npx+1,0) = q3(npx,2); q3(npx,0) = q3(npx,1); q3(npx,-1) = q3(npx+1,1)
3213 if ( ne_corner )
then 3214 q1(npx,npy) = q1(npx,npy-1); q1(npx+1,npy) = q1(npx,npy-2); q1(npx,npy+1) = q1(npx+1,npy-1)
3215 q2(npx,npy) = q2(npx,npy-1); q2(npx+1,npy) = q2(npx,npy-2); q2(npx,npy+1) = q2(npx+1,npy-1)
3216 q3(npx,npy) = q3(npx,npy-1); q3(npx+1,npy) = q3(npx,npy-2); q3(npx,npy+1) = q3(npx+1,npy-1)
3218 if ( nw_corner )
then 3219 q1(0,npy) = q1(0,npy-1); q1(-1,npy) = q1(0,npy-2); q1(0,npy+1) = q1(-1,npy-1)
3220 q2(0,npy) = q2(0,npy-1); q2(-1,npy) = q2(0,npy-2); q2(0,npy+1) = q2(-1,npy-1)
3221 q3(0,npy) = q3(0,npy-1); q3(-1,npy) = q3(0,npy-2); q3(0,npy+1) = q3(-1,npy-1)
3225 if ( sw_corner )
then 3226 q1(0,0) = q1(1,0); q1(0,-1) = q1(2,0); q1(-1,0) = q1(1,-1)
3227 q2(0,0) = q2(1,0); q2(0,-1) = q2(2,0); q2(-1,0) = q2(1,-1)
3228 q3(0,0) = q3(1,0); q3(0,-1) = q3(2,0); q3(-1,0) = q3(1,-1)
3230 if ( se_corner )
then 3231 q1(npx,0) = q1(npx-1,0); q1(npx,-1) = q1(npx-2,0); q1(npx+1,0) = q1(npx-1,-1)
3232 q2(npx,0) = q2(npx-1,0); q2(npx,-1) = q2(npx-2,0); q2(npx+1,0) = q2(npx-1,-1)
3233 q3(npx,0) = q3(npx-1,0); q3(npx,-1) = q3(npx-2,0); q3(npx+1,0) = q3(npx-1,-1)
3235 if ( ne_corner )
then 3236 q1(npx,npy) = q1(npx-1,npy); q1(npx,npy+1) = q1(npx-2,npy); q1(npx+1,npy) = q1(npx-1,npy+1)
3237 q2(npx,npy) = q2(npx-1,npy); q2(npx,npy+1) = q2(npx-2,npy); q2(npx+1,npy) = q2(npx-1,npy+1)
3238 q3(npx,npy) = q3(npx-1,npy); q3(npx,npy+1) = q3(npx-2,npy); q3(npx+1,npy) = q3(npx-1,npy+1)
3240 if ( nw_corner )
then 3241 q1(0,npy) = q1(1,npy); q1(0,npy+1) = q1(2,npy); q1(-1,npy) = q1(1,npy+1)
3242 q2(0,npy) = q2(1,npy); q2(0,npy+1) = q2(2,npy); q2(-1,npy) = q2(1,npy+1)
3243 q3(0,npy) = q3(1,npy); q3(0,npy+1) = q3(2,npy); q3(-1,npy) = q3(1,npy+1)
3250 subroutine fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3252 integer,
intent(in):: dir
3253 real,
intent(inout):: q1(bd%isd:bd%ied,bd%jsd:bd%jed)
3254 real,
intent(inout):: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
3255 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3256 integer,
intent(IN) :: npx, npy
3258 integer :: is, ie, js, je
3259 integer :: isd, ied, jsd, jed
3272 if ( sw_corner )
then 3273 q1(-1,0) = q1(0,2); q1(0,0) = q1(0,1)
3274 q2(-1,0) = q2(0,2); q2(0,0) = q2(0,1)
3276 if ( se_corner )
then 3277 q1(npx+1,0) = q1(npx,2); q1(npx,0) = q1(npx,1)
3278 q2(npx+1,0) = q2(npx,2); q2(npx,0) = q2(npx,1)
3280 if ( nw_corner )
then 3281 q1(0,npy) = q1(0,npy-1); q1(-1,npy) = q1(0,npy-2)
3282 q2(0,npy) = q2(0,npy-1); q2(-1,npy) = q2(0,npy-2)
3284 if ( ne_corner )
then 3285 q1(npx,npy) = q1(npx,npy-1); q1(npx+1,npy) = q1(npx,npy-2)
3286 q2(npx,npy) = q2(npx,npy-1); q2(npx+1,npy) = q2(npx,npy-2)
3290 if ( sw_corner )
then 3291 q1(0,0) = q1(1,0); q1(0,-1) = q1(2,0)
3292 q2(0,0) = q2(1,0); q2(0,-1) = q2(2,0)
3294 if ( se_corner )
then 3295 q1(npx,0) = q1(npx-1,0); q1(npx,-1) = q1(npx-2,0)
3296 q2(npx,0) = q2(npx-1,0); q2(npx,-1) = q2(npx-2,0)
3298 if ( nw_corner )
then 3299 q1(0,npy) = q1(1,npy); q1(0,npy+1) = q1(2,npy)
3300 q2(0,npy) = q2(1,npy); q2(0,npy+1) = q2(2,npy)
3302 if ( ne_corner )
then 3303 q1(npx,npy) = q1(npx-1,npy); q1(npx,npy+1) = q1(npx-2,npy)
3304 q2(npx,npy) = q2(npx-1,npy); q2(npx,npy+1) = q2(npx-2,npy)
3312 subroutine fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3314 integer,
intent(in):: dir
3315 real,
intent(inout):: q(bd%isd:bd%ied,bd%jsd:bd%jed)
3316 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3317 integer,
intent(IN) :: npx, npy
3319 integer :: is, ie, js, je
3320 integer :: isd, ied, jsd, jed
3333 if ( sw_corner )
then 3337 if ( se_corner )
then 3338 q(npx+1,0) = q(npx,2)
3339 q(npx, 0) = q(npx,1)
3341 if ( nw_corner )
then 3342 q( 0,npy) = q(0,npy-1)
3343 q(-1,npy) = q(0,npy-2)
3345 if ( ne_corner )
then 3346 q(npx, npy) = q(npx,npy-1)
3347 q(npx+1,npy) = q(npx,npy-2)
3351 if ( sw_corner )
then 3355 if ( se_corner )
then 3356 q(npx, 0) = q(npx-1,0)
3357 q(npx,-1) = q(npx-2,0)
3359 if ( nw_corner )
then 3360 q(0,npy ) = q(1,npy)
3361 q(0,npy+1) = q(2,npy)
3363 if ( ne_corner )
then 3364 q(npx,npy ) = q(npx-1,npy)
3365 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, public fv_tp_2d(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, lim_fac, mfx, mfy, mass, nord, damp_c)
The subroutine 'fv_tp_2d' contains the FV advection scheme .
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 ...
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)
subroutine d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, npx, npy, bounded_domain, grid_type)
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 xtp_u(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, lim_fac, bounded_domain)
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 ytp_v(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, lim_fac, bounded_domain)
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 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 copy_corners(q, npx, npy, dir, bounded_domain, bd, sw_corner, se_corner, nw_corner, ne_corner)
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
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'...