34 real,
parameter::
r3 = 1./3.
46 real,
parameter::
p1 = 7./12.
47 real,
parameter::
p2 = -1./12.
51 real,
parameter::
a1 = 0.5625
52 real,
parameter::
a2 = -0.0625
55 real,
parameter::
c1 = -2./14.
56 real,
parameter::
c2 = 11./14.
57 real,
parameter::
c3 = 5./14.
64 real,
parameter::
b1 = 1./30.
65 real,
parameter::
b2 = -13./60.
66 real,
parameter::
b3 = -13./60.
67 real,
parameter::
b4 = 0.45
68 real,
parameter::
b5 = -0.05
77 subroutine c_sw(delpc, delp, ptc, pt, u,v, w, uc,vc, ua,va, wc, &
78 ut, vt, divg_d, nord, dt2, hydrostatic, dord4, &
79 bd, gridstruct, flagstruct)
82 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u, vc
83 real,
intent(INOUT),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ) :: v, uc
84 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed ) :: delp, pt, ua, va, ut, vt
85 real,
intent(INOUT),
dimension(bd%isd: , bd%jsd: ) :: w
86 real,
intent(OUT ),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed ) :: delpc, ptc, wc
87 real,
intent(OUT ),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1) :: divg_d
88 integer,
intent(IN) :: nord
89 real,
intent(IN) :: dt2
90 logical,
intent(IN) :: hydrostatic
91 logical,
intent(IN) :: dord4
96 logical:: sw_corner, se_corner, ne_corner, nw_corner
97 real,
dimension(bd%is-1:bd%ie+1,bd%js-1:bd%je+1):: vort, ke
98 real,
dimension(bd%is-1:bd%ie+2,bd%js-1:bd%je+1):: fx, fx1, fx2
99 real,
dimension(bd%is-1:bd%ie+1,bd%js-1:bd%je+2):: fy, fy1, fy2
101 integer :: i,j, is2, ie1
104 integer :: is, ie, js, je
105 integer :: isd, ied, jsd, jed
109 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
110 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v
111 real,
pointer,
dimension(:,:) :: sina_u, sina_v
113 real,
pointer,
dimension(:,:) :: dx, dy, dxc, dyc
126 nested = gridstruct%nested
128 sin_sg => gridstruct%sin_sg
129 cos_sg => gridstruct%cos_sg
130 cosa_u => gridstruct%cosa_u
131 cosa_v => gridstruct%cosa_v
132 sina_u => gridstruct%sina_u
133 sina_v => gridstruct%sina_v
136 dxc => gridstruct%dxc
137 dyc => gridstruct%dyc
139 sw_corner = gridstruct%sw_corner
140 se_corner = gridstruct%se_corner
141 nw_corner = gridstruct%nw_corner
142 ne_corner = gridstruct%ne_corner
144 iep1 = ie+1; jep1 = je+1
146 call d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, &
147 npx, npy, nested, flagstruct%grid_type)
159 if (ut(i,j) > 0.)
then 160 ut(i,j) = dt2*ut(i,j)*dy(i,j)*sin_sg(i-1,j,3)
162 ut(i,j) = dt2*ut(i,j)*dy(i,j)*sin_sg(i,j,1)
168 if (vt(i,j) > 0.)
then 169 vt(i,j) = dt2*vt(i,j)*dx(i,j)*sin_sg(i,j-1,4)
171 vt(i,j) = dt2*vt(i,j)*dx(i,j)*sin_sg(i,j, 2)
180 if (flagstruct%grid_type < 3 .and. .not. nested)
call fill2_4corners(delp, pt, 1, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
182 if ( hydrostatic )
then 186 if ( ut(i,j) > 0. )
then 187 fx1(i,j) = delp(i-1,j)
191 fx1(i,j) = ut(i,j)*fx1(i,j)
197 if ( ut(i,j) > 0. )
then 198 fx1(i,j) = delp(i-1,j)
204 fx1(i,j) = ut(i,j)*fx1(i,j)
205 fx(i,j) = fx1(i,j)* fx(i,j)
210 if (flagstruct%grid_type < 3) &
211 call fill_4corners(w, 1, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
214 if ( ut(i,j) > 0. )
then 215 fx1(i,j) = delp(i-1,j)
223 fx1(i,j) = ut(i,j)*fx1(i,j)
224 fx(i,j) = fx1(i,j)* fx(i,j)
225 fx2(i,j) = fx1(i,j)*fx2(i,j)
231 if (flagstruct%grid_type < 3 .and. .not. nested)
call fill2_4corners(delp, pt, 2, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
232 if ( hydrostatic )
then 235 if ( vt(i,j) > 0. )
then 236 fy1(i,j) = delp(i,j-1)
242 fy1(i,j) = vt(i,j)*fy1(i,j)
243 fy(i,j) = fy1(i,j)* fy(i,j)
248 delpc(i,j) = delp(i,j) + ((fx1(i,j)-fx1(i+1,j))+(fy1(i,j)-fy1(i,j+1)))*gridstruct%rarea(i,j)
252 ptc(i,j) = (pt(i,j)*delp(i,j) + &
253 ((fx(i,j)-fx(i+1,j))+(fy(i,j)-fy(i,j+1)))*gridstruct%rarea(i,j))/delpc(i,j)
258 if (flagstruct%grid_type < 3)
call fill_4corners(w, 2, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
261 if ( vt(i,j) > 0. )
then 262 fy1(i,j) = delp(i,j-1)
270 fy1(i,j) = vt(i,j)*fy1(i,j)
271 fy(i,j) = fy1(i,j)* fy(i,j)
272 fy2(i,j) = fy1(i,j)*fy2(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)
278 ptc(i,j) = (pt(i,j)*delp(i,j) + &
279 ((fx(i,j)-fx(i+1,j))+(fy(i,j)-fy(i,j+1)))*gridstruct%rarea(i,j))/delpc(i,j)
280 wc(i,j) = (w(i,j)*delp(i,j) + ((fx2(i,j)-fx2(i+1,j)) + &
281 (fy2(i,j)-fy2(i,j+1)))*gridstruct%rarea(i,j))/delpc(i,j)
295 if (nested .or. flagstruct%grid_type >=3 )
then 298 if ( ua(i,j) > 0. )
then 307 if ( va(i,j) > 0. )
then 310 vort(i,j) = vc(i,j+1)
317 if ( ua(i,j) > 0. )
then 319 ke(1,j) = uc(1, j)*sin_sg(1,j,1)+v(1,j)*cos_sg(1,j,1)
320 elseif ( i==npx )
then 321 ke(i,j) = uc(npx,j)*sin_sg(npx,j,1)+v(npx,j)*cos_sg(npx,j,1)
327 ke(0,j) = uc(1, j)*sin_sg(0,j,3)+v(1,j)*cos_sg(0,j,3)
328 elseif ( i==(npx-1) )
then 329 ke(i,j) = uc(npx,j)*sin_sg(npx-1,j,3)+v(npx,j)*cos_sg(npx-1,j,3)
338 if ( va(i,j) > 0. )
then 340 vort(i,1) = vc(i, 1)*sin_sg(i,1,2)+u(i, 1)*cos_sg(i,1,2)
341 elseif ( j==npy )
then 342 vort(i,j) = vc(i,npy)*sin_sg(i,npy,2)+u(i,npy)*cos_sg(i,npy,2)
348 vort(i,0) = vc(i, 1)*sin_sg(i,0,4)+u(i, 1)*cos_sg(i,0,4)
349 elseif ( j==(npy-1) )
then 350 vort(i,j) = vc(i,npy)*sin_sg(i,npy-1,4)+u(i,npy)*cos_sg(i,npy-1,4)
352 vort(i,j) = vc(i,j+1)
362 ke(i,j) = dt4*(ua(i,j)*ke(i,j) + va(i,j)*vort(i,j))
372 fx(i,j) = uc(i,j) * dxc(i,j)
378 fy(i,j) = vc(i,j) * dyc(i,j)
384 vort(i,j) = (fx(i,j-1) - fx(i,j)) + (fy(i,j) - fy(i-1,j))
389 if ( sw_corner ) vort(1, 1) = vort(1, 1) + fy(0, 1)
390 if ( se_corner ) vort(npx ,1) = vort(npx, 1) - fy(npx, 1)
391 if ( ne_corner ) vort(npx,npy) = vort(npx,npy) - fy(npx,npy)
392 if ( nw_corner ) vort(1, npy) = vort(1, npy) + fy(0, npy)
399 vort(i,j) = gridstruct%fC(i,j) + gridstruct%rarea_c(i,j) * vort(i,j)
412 if (nested .or. flagstruct%grid_type >= 3)
then 415 fy1(i,j) = dt2*(v(i,j)-uc(i,j)*cosa_u(i,j))/sina_u(i,j)
416 if ( fy1(i,j) > 0. )
then 419 fy(i,j) = vort(i,j+1)
425 fx1(i,j) = dt2*(u(i,j)-vc(i,j)*cosa_v(i,j))/sina_v(i,j)
426 if ( fx1(i,j) > 0. )
then 429 fx(i,j) = vort(i+1,j)
437 if ( ( i==1 .or. i==npx ) )
then 438 fy1(i,j) = dt2*v(i,j)
440 fy1(i,j) = dt2*(v(i,j)-uc(i,j)*cosa_u(i,j))/sina_u(i,j)
442 if ( fy1(i,j) > 0. )
then 445 fy(i,j) = vort(i,j+1)
450 if ( ( j==1 .or. j==npy ) )
then 453 fx1(i,j) = dt2*u(i,j)
454 if ( fx1(i,j) > 0. )
then 457 fx(i,j) = vort(i+1,j)
463 fx1(i,j) = dt2*(u(i,j)-vc(i,j)*cosa_v(i,j))/sina_v(i,j)
464 if ( fx1(i,j) > 0. )
then 467 fx(i,j) = vort(i+1,j)
477 uc(i,j) = uc(i,j) + fy1(i,j)*fy(i,j) + gridstruct%rdxc(i,j)*(ke(i-1,j)-ke(i,j))
482 vc(i,j) = vc(i,j) - fx1(i,j)*fx(i,j) + gridstruct%rdyc(i,j)*(ke(i,j-1)-ke(i,j))
492 subroutine d_sw(delpc, delp, ptc, pt, u, v, w, uc,vc, &
493 ua, va, divg_d, xflux, yflux, cx, cy, &
494 crx_adv, cry_adv, xfx_adv, yfx_adv, q_con, z_rat, kgb, heat_source, dpx, &
495 zvir, sphum, nq, q, k, km, inline_q, &
496 dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, &
497 nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, &
498 damp_t, d_con, hydrostatic, gridstruct, flagstruct, bd)
500 integer,
intent(IN):: hord_tr, hord_mt, hord_vt, hord_tm, hord_dp
501 integer,
intent(IN):: nord
502 integer,
intent(IN):: nord_v
503 integer,
intent(IN):: nord_w
504 integer,
intent(IN):: nord_t
505 integer,
intent(IN):: sphum, nq, k, km
506 real ,
intent(IN):: dt, dddmp, d2_bg, d4_bg, d_con
507 real ,
intent(IN):: zvir
508 real,
intent(in):: damp_v, damp_w, damp_t, kgb
510 real,
intent(inout):: divg_d(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
511 real,
intent(IN),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed):: z_rat
512 real,
intent(INOUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed):: delp, pt, ua, va
513 real,
intent(INOUT),
dimension(bd%isd: , bd%jsd: ):: w, q_con
514 real,
intent(INOUT),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1):: u, vc
515 real,
intent(INOUT),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v, uc
516 real,
intent(INOUT):: q(bd%isd:bd%ied,bd%jsd:bd%jed,km,nq)
517 real,
intent(OUT),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc
518 real,
intent(OUT),
dimension(bd%is:bd%ie,bd%js:bd%je):: heat_source
519 real(kind=8),
intent(INOUT),
dimension(bd%is:bd%ie,bd%js:bd%je):: dpx
521 real,
intent(INOUT):: xflux(bd%is:bd%ie+1,bd%js:bd%je )
522 real,
intent(INOUT):: yflux(bd%is:bd%ie ,bd%js:bd%je+1)
524 real,
intent(INOUT):: cx(bd%is:bd%ie+1,bd%jsd:bd%jed )
525 real,
intent(INOUT):: cy(bd%isd:bd%ied,bd%js:bd%je+1)
526 logical,
intent(IN):: hydrostatic
527 logical,
intent(IN):: inline_q
528 real,
intent(OUT),
dimension(bd%is:bd%ie+1,bd%jsd:bd%jed):: crx_adv, xfx_adv
529 real,
intent(OUT),
dimension(bd%isd:bd%ied,bd%js:bd%je+1):: cry_adv, yfx_adv
533 logical:: sw_corner, se_corner, ne_corner, nw_corner
534 real :: ut(bd%isd:bd%ied+1,bd%jsd:bd%jed)
535 real :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
537 real :: fx2(bd%isd:bd%ied+1,bd%jsd:bd%jed)
538 real :: fy2(bd%isd:bd%ied, bd%jsd:bd%jed+1)
539 real :: dw(bd%is:bd%ie,bd%js:bd%je)
541 real,
dimension(bd%is:bd%ie+1,bd%js:bd%je+1):: ub, vb
542 real :: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
543 real :: ke(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
544 real :: vort(bd%isd:bd%ied,bd%jsd:bd%jed)
545 real :: fx(bd%is:bd%ie+1,bd%js:bd%je )
546 real :: fy(bd%is:bd%ie ,bd%js:bd%je+1)
547 real :: ra_x(bd%is:bd%ie,bd%jsd:bd%jed)
548 real :: ra_y(bd%isd:bd%ied,bd%js:bd%je)
549 real :: gx(bd%is:bd%ie+1,bd%js:bd%je )
550 real :: gy(bd%is:bd%ie ,bd%js:bd%je+1)
553 real :: dt2, dt4, dt5, dt6
554 real :: damp, damp2, damp4, dd8,
u2, v2, du2, dv2
556 integer :: i,j, is2, ie1, js2, je1, n, nt, n2, iq
558 real,
pointer,
dimension(:,:) :: area, area_c, rarea
560 real,
pointer,
dimension(:,:,:) :: sin_sg
561 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v, cosa_s
562 real,
pointer,
dimension(:,:) :: sina_u, sina_v
563 real,
pointer,
dimension(:,:) :: rsin_u, rsin_v, rsina
564 real,
pointer,
dimension(:,:) ::
f0, rsin2, divg_u, divg_v
566 real,
pointer,
dimension(:,:) :: cosa, dx, dy, dxc, dyc, rdxa, rdya, rdx, rdy
568 integer :: is, ie, js, je
569 integer :: isd, ied, jsd, jed
584 nested = gridstruct%nested
586 area => gridstruct%area
587 rarea => gridstruct%rarea
588 sin_sg => gridstruct%sin_sg
589 cosa_u => gridstruct%cosa_u
590 cosa_v => gridstruct%cosa_v
591 cosa_s => gridstruct%cosa_s
592 sina_u => gridstruct%sina_u
593 sina_v => gridstruct%sina_v
594 rsin_u => gridstruct%rsin_u
595 rsin_v => gridstruct%rsin_v
596 rsina => gridstruct%rsina
598 rsin2 => gridstruct%rsin2
599 divg_u => gridstruct%divg_u
600 divg_v => gridstruct%divg_v
601 cosa => gridstruct%cosa
604 dxc => gridstruct%dxc
605 dyc => gridstruct%dyc
606 rdxa => gridstruct%rdxa
607 rdya => gridstruct%rdya
608 rdx => gridstruct%rdx
609 rdy => gridstruct%rdy
611 sw_corner = gridstruct%sw_corner
612 se_corner = gridstruct%se_corner
613 nw_corner = gridstruct%nw_corner
614 ne_corner = gridstruct%ne_corner
620 xfx_adv(i,j) = dt * uc(i,j) / sina_u(i,j)
621 if (xfx_adv(i,j) > 0.)
then 622 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i-1,j)
624 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i,j)
626 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sina_u(i,j)
632 yfx_adv(i,j) = dt * vc(i,j) / sina_v(i,j)
633 if (yfx_adv(i,j) > 0.)
then 634 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j-1)
636 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j)
638 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sina_v(i,j)
643 if ( flagstruct%grid_type < 3 )
then 649 ut(i,j) = ( uc(i,j) - 0.25 * cosa_u(i,j) * &
650 (vc(i-1,j)+vc(i,j)+vc(i-1,j+1)+vc(i,j+1)))*rsin_u(i,j)
655 vt(i,j) = ( vc(i,j) - 0.25 * cosa_v(i,j) * &
656 (uc(i,j-1)+uc(i+1,j-1)+uc(i,j)+uc(i+1,j)))*rsin_v(i,j)
661 if( j/=0 .and. j/=1 .and. j/=(npy-1) .and. j/=npy)
then 663 ut(i,j) = ( uc(i,j) - 0.25 * cosa_u(i,j) * &
664 (vc(i-1,j)+vc(i,j)+vc(i-1,j+1)+vc(i,j+1)))*rsin_u(i,j)
670 if( j/=1 .and. j/=npy )
then 673 vt(i,j) = ( vc(i,j) - 0.25 * cosa_v(i,j) * &
674 (uc(i,j-1)+uc(i+1,j-1)+uc(i,j)+uc(i+1,j)))*rsin_v(i,j)
680 if (.not. nested)
then 684 if ( uc(1,j)*dt > 0. )
then 685 ut(1,j) = uc(1,j) / sin_sg(0,j,3)
687 ut(1,j) = uc(1,j) / sin_sg(1,j,1)
690 do j=
max(3,js),
min(npy-2,je+1)
691 vt(0,j) = vc(0,j) - 0.25*cosa_v(0,j)* &
692 (ut(0,j-1)+ut(1,j-1)+ut(0,j)+ut(1,j))
693 vt(1,j) = vc(1,j) - 0.25*cosa_v(1,j)* &
694 (ut(1,j-1)+ut(2,j-1)+ut(1,j)+ut(2,j))
699 if ( (ie+1)==npx )
then 701 if ( uc(npx,j)*dt > 0. )
then 702 ut(npx,j) = uc(npx,j) / sin_sg(npx-1,j,3)
704 ut(npx,j) = uc(npx,j) / sin_sg(npx,j,1)
708 do j=
max(3,js),
min(npy-2,je+1)
709 vt(npx-1,j) = vc(npx-1,j) - 0.25*cosa_v(npx-1,j)* &
710 (ut(npx-1,j-1)+ut(npx,j-1)+ut(npx-1,j)+ut(npx,j))
711 vt(npx,j) = vc(npx,j) - 0.25*cosa_v(npx,j)* &
712 (ut(npx,j-1)+ut(npx+1,j-1)+ut(npx,j)+ut(npx+1,j))
720 if ( vc(i,1)*dt > 0. )
then 721 vt(i,1) = vc(i,1) / sin_sg(i,0,4)
723 vt(i,1) = vc(i,1) / sin_sg(i,1,2)
727 do i=
max(3,is),
min(npx-2,ie+1)
728 ut(i,0) = uc(i,0) - 0.25*cosa_u(i,0)* &
729 (vt(i-1,0)+vt(i,0)+vt(i-1,1)+vt(i,1))
730 ut(i,1) = uc(i,1) - 0.25*cosa_u(i,1)* &
731 (vt(i-1,1)+vt(i,1)+vt(i-1,2)+vt(i,2))
736 if ( (je+1)==npy )
then 738 if ( vc(i,npy)*dt > 0. )
then 739 vt(i,npy) = vc(i,npy) / sin_sg(i,npy-1,4)
741 vt(i,npy) = vc(i,npy) / sin_sg(i,npy,2)
744 do i=
max(3,is),
min(npx-2,ie+1)
745 ut(i,npy-1) = uc(i,npy-1) - 0.25*cosa_u(i,npy-1)* &
746 (vt(i-1,npy-1)+vt(i,npy-1)+vt(i-1,npy)+vt(i,npy))
747 ut(i,npy) = uc(i,npy) - 0.25*cosa_u(i,npy)* &
748 (vt(i-1,npy)+vt(i,npy)+vt(i-1,npy+1)+vt(i,npy+1))
763 damp = 1. / (1.-0.0625*cosa_u(2,0)*cosa_v(1,0))
764 ut(2,0) = (uc(2,0)-0.25*cosa_u(2,0)*(vt(1,1)+vt(2,1)+vt(2,0) +vc(1,0) - &
765 0.25*cosa_v(1,0)*(ut(1,0)+ut(1,-1)+ut(2,-1))) ) * damp
766 damp = 1. / (1.-0.0625*cosa_u(0,1)*cosa_v(0,2))
767 vt(0,2) = (vc(0,2)-0.25*cosa_v(0,2)*(ut(1,1)+ut(1,2)+ut(0,2)+uc(0,1) - &
768 0.25*cosa_u(0,1)*(vt(0,1)+vt(-1,1)+vt(-1,2))) ) * damp
770 damp = 1. / (1.-0.0625*cosa_u(2,1)*cosa_v(1,2))
771 ut(2,1) = (uc(2,1)-0.25*cosa_u(2,1)*(vt(1,1)+vt(2,1)+vt(2,2)+vc(1,2) - &
772 0.25*cosa_v(1,2)*(ut(1,1)+ut(1,2)+ut(2,2))) ) * damp
774 vt(1,2) = (vc(1,2)-0.25*cosa_v(1,2)*(ut(1,1)+ut(1,2)+ut(2,2)+uc(2,1) - &
775 0.25*cosa_u(2,1)*(vt(1,1)+vt(2,1)+vt(2,2))) ) * damp
779 damp = 1. / (1. - 0.0625*cosa_u(npx-1,0)*cosa_v(npx-1,0))
780 ut(npx-1,0) = ( uc(npx-1,0)-0.25*cosa_u(npx-1,0)*( &
781 vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,0)+vc(npx-1,0) - &
782 0.25*cosa_v(npx-1,0)*(ut(npx,0)+ut(npx,-1)+ut(npx-1,-1))) ) * damp
783 damp = 1. / (1. - 0.0625*cosa_u(npx+1,1)*cosa_v(npx,2))
784 vt(npx, 2) = ( vc(npx,2)-0.25*cosa_v(npx,2)*( &
785 ut(npx,1)+ut(npx,2)+ut(npx+1,2)+uc(npx+1,1) - &
786 0.25*cosa_u(npx+1,1)*(vt(npx,1)+vt(npx+1,1)+vt(npx+1,2))) ) * damp
788 damp = 1. / (1. - 0.0625*cosa_u(npx-1,1)*cosa_v(npx-1,2))
789 ut(npx-1,1) = ( uc(npx-1,1)-0.25*cosa_u(npx-1,1)*( &
790 vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,2)+vc(npx-1,2) - &
791 0.25*cosa_v(npx-1,2)*(ut(npx,1)+ut(npx,2)+ut(npx-1,2))) ) * damp
792 vt(npx-1,2) = ( vc(npx-1,2)-0.25*cosa_v(npx-1,2)*( &
793 ut(npx,1)+ut(npx,2)+ut(npx-1,2)+uc(npx-1,1) - &
794 0.25*cosa_u(npx-1,1)*(vt(npx-1,1)+vt(npx-2,1)+vt(npx-2,2))) ) * damp
798 damp = 1. / (1. - 0.0625*cosa_u(npx-1,npy)*cosa_v(npx-1,npy+1))
799 ut(npx-1,npy) = ( uc(npx-1,npy)-0.25*cosa_u(npx-1,npy)*( &
800 vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy+1)+vc(npx-1,npy+1) - &
801 0.25*cosa_v(npx-1,npy+1)*(ut(npx,npy)+ut(npx,npy+1)+ut(npx-1,npy+1))) ) * damp
802 damp = 1. / (1. - 0.0625*cosa_u(npx+1,npy-1)*cosa_v(npx,npy-1))
803 vt(npx, npy-1) = ( vc(npx,npy-1)-0.25*cosa_v(npx,npy-1)*( &
804 ut(npx,npy-1)+ut(npx,npy-2)+ut(npx+1,npy-2)+uc(npx+1,npy-1) - &
805 0.25*cosa_u(npx+1,npy-1)*(vt(npx,npy)+vt(npx+1,npy)+vt(npx+1,npy-1))) ) * damp
807 damp = 1. / (1. - 0.0625*cosa_u(npx-1,npy-1)*cosa_v(npx-1,npy-1))
808 ut(npx-1,npy-1) = ( uc(npx-1,npy-1)-0.25*cosa_u(npx-1,npy-1)*( &
809 vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy-1)+vc(npx-1,npy-1) - &
810 0.25*cosa_v(npx-1,npy-1)*(ut(npx,npy-1)+ut(npx,npy-2)+ut(npx-1,npy-2))) ) * damp
811 vt(npx-1,npy-1) = ( vc(npx-1,npy-1)-0.25*cosa_v(npx-1,npy-1)*( &
812 ut(npx,npy-1)+ut(npx,npy-2)+ut(npx-1,npy-2)+uc(npx-1,npy-1) - &
813 0.25*cosa_u(npx-1,npy-1)*(vt(npx-1,npy)+vt(npx-2,npy)+vt(npx-2,npy-1))) ) * damp
817 damp = 1. / (1. - 0.0625*cosa_u(2,npy)*cosa_v(1,npy+1))
818 ut(2,npy) = ( uc(2,npy)-0.25*cosa_u(2,npy)*( &
819 vt(1,npy)+vt(2,npy)+vt(2,npy+1)+vc(1,npy+1) - &
820 0.25*cosa_v(1,npy+1)*(ut(1,npy)+ut(1,npy+1)+ut(2,npy+1))) ) * damp
821 damp = 1. / (1. - 0.0625*cosa_u(0,npy-1)*cosa_v(0,npy-1))
822 vt(0,npy-1) = ( vc(0,npy-1)-0.25*cosa_v(0,npy-1)*( &
823 ut(1,npy-1)+ut(1,npy-2)+ut(0,npy-2)+uc(0,npy-1) - &
824 0.25*cosa_u(0,npy-1)*(vt(0,npy)+vt(-1,npy)+vt(-1,npy-1))) ) * damp
826 damp = 1. / (1. - 0.0625*cosa_u(2,npy-1)*cosa_v(1,npy-1))
827 ut(2,npy-1) = ( uc(2,npy-1)-0.25*cosa_u(2,npy-1)*( &
828 vt(1,npy)+vt(2,npy)+vt(2,npy-1)+vc(1,npy-1) - &
829 0.25*cosa_v(1,npy-1)*(ut(1,npy-1)+ut(1,npy-2)+ut(2,npy-2))) ) * damp
831 vt(1,npy-1) = ( vc(1,npy-1)-0.25*cosa_v(1,npy-1)*( &
832 ut(1,npy-1)+ut(1,npy-2)+ut(2,npy-2)+uc(2,npy-1) - &
833 0.25*cosa_u(2,npy-1)*(vt(1,npy)+vt(2,npy)+vt(2,npy-1))) ) * damp
855 xfx_adv(i,j) = dt*ut(i,j)
861 yfx_adv(i,j) = dt*vt(i,j)
872 if ( xfx_adv(i,j) > 0. )
then 873 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i-1,j)
874 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sin_sg(i-1,j,3)
876 crx_adv(i,j) = xfx_adv(i,j) * rdxa(i,j)
877 xfx_adv(i,j) = dy(i,j)*xfx_adv(i,j)*sin_sg(i,j,1)
884 if ( yfx_adv(i,j) > 0. )
then 885 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j-1)
886 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sin_sg(i,j-1,4)
888 cry_adv(i,j) = yfx_adv(i,j) * rdya(i,j)
889 yfx_adv(i,j) = dx(i,j)*yfx_adv(i,j)*sin_sg(i,j,2)
900 ra_x(i,j) = area(i,j) + (xfx_adv(i,j) - xfx_adv(i+1,j))
905 ra_y(i,j) = area(i,j) + (yfx_adv(i,j) - yfx_adv(i,j+1))
910 call fv_tp_2d(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx, fy, &
911 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, nord=nord_v, damp_c=damp_v)
916 cx(i,j) = cx(i,j) + crx_adv(i,j)
921 xflux(i,j) = xflux(i,j) + fx(i,j)
926 cy(i,j) = cy(i,j) + cry_adv(i,j)
929 yflux(i,j) = yflux(i,j) + fy(i,j)
936 heat_source(i,j) = 0.
940 if ( .not. hydrostatic )
then 941 if ( damp_w>1.e-5 )
then 943 damp4 = (damp_w*gridstruct%da_min_c)**(nord_w+1)
944 call del6_vt_flux(nord_w, npx, npy, damp4, w, wk, fx2, fy2, gridstruct, bd)
947 dw(i,j) = ((fx2(i,j)-fx2(i+1,j))+(fy2(i,j)-fy2(i,j+1)))*rarea(i,j)
950 heat_source(i,j) = dd8 - dw(i,j)*(w(i,j)+0.5*dw(i,j))
954 call fv_tp_2d(w, crx_adv,cry_adv, npx, npy, hord_vt, gx, gy, xfx_adv, yfx_adv, &
955 gridstruct, bd, ra_x, ra_y, mfx=fx, mfy=fy)
958 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)
964 call fv_tp_2d(q_con, crx_adv,cry_adv, npx, npy, hord_dp, gx, gy, &
965 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
968 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)
980 call fv_tp_2d(pt, crx_adv,cry_adv, npx, npy, hord_tm, gx, gy, &
981 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, &
982 mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
989 delp(i,j) = wk(i,j) + ((fx(i,j)-fx(i+1,j))+(fy(i,j)-fy(i,j+1)))*rarea(i,j)
993 pt(i,j) = (pt(i,j)*wk(i,j) + &
994 ((gx(i,j)-gx(i+1,j))+(gy(i,j)-gy(i,j+1)))*rarea(i,j))/delp(i,j)
999 call fv_tp_2d(q(isd,jsd,k,iq), crx_adv,cry_adv, npx, npy, hord_tr, gx, gy, &
1000 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y, &
1001 mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
1004 q(i,j,k,iq) = (q(i,j,k,iq)*wk(i,j) + &
1005 ((gx(i,j)-gx(i+1,j))+(gy(i,j)-gy(i,j+1)))*rarea(i,j))/delp(i,j)
1021 pt(i,j) = pt(i,j)*delp(i,j) + &
1022 ((gx(i,j)-gx(i+1,j))+(gy(i,j)-gy(i,j+1)))*rarea(i,j)
1024 delp(i,j) = delp(i,j) + &
1025 ((fx(i,j)-fx(i+1,j))+(fy(i,j)-fy(i,j+1)))*rarea(i,j)
1027 pt(i,j) = pt(i,j) / delp(i,j)
1037 dpx(i,j) = dpx(i,j) + ( (fx(i,j)-fx(i+1,j)) + (fy(i,j)-fy(i,j+1)) )*rarea(i,j)
1055 is2 = is; ie1 = ie+1
1056 js2 = js; je1 = je+1
1058 is2 =
max(2,is); ie1 =
min(npx-1,ie+1)
1059 js2 =
max(2,js); je1 =
min(npy-1,je+1)
1063 if (flagstruct%grid_type < 3)
then 1068 vb(i,j) = dt5*((vc(i-1,j)+vc(i,j))-(uc(i,j-1)+uc(i,j))*cosa(i,j))*rsina(i,j)
1074 vb(i,1) = dt5*(vt(i-1,1)+vt(i,1))
1080 vb(i,j) = dt5*((vc(i-1,j)+vc(i,j))-(uc(i,j-1)+uc(i,j))*cosa(i,j))*rsina(i,j)
1085 vb(1,j) = dt4*(-vt(-1,j) + 3.*(vt(0,j)+vt(1,j)) - vt(2,j))
1087 if ( (ie+1)==npx )
then 1089 vb(npx,j) = dt4*(-vt(npx-2,j) + 3.*(vt(npx-1,j)+vt(npx,j)) - vt(npx+1,j))
1093 if ( (je+1)==npy )
then 1095 vb(i,npy) = dt5*(vt(i-1,npy)+vt(i,npy))
1103 vb(i,j) = dt5*(vc(i-1,j)+vc(i,j))
1108 call ytp_v(is,ie,js,je,isd,ied,jsd,jed, vb, u, v, ub, hord_mt, gridstruct%dy, gridstruct%rdy, &
1109 npx, npy, flagstruct%grid_type, nested)
1113 ke(i,j) = vb(i,j)*ub(i,j)
1117 if (flagstruct%grid_type < 3)
then 1124 ub(i,j) = dt5*((uc(i,j-1)+uc(i,j))-(vc(i-1,j)+vc(i,j))*cosa(i,j))*rsina(i,j)
1133 ub(1,j) = dt5*(ut(1,j-1)+ut(1,j))
1138 if ( (j==1 .or. j==npy) )
then 1141 ub(i,j) = dt4*(-ut(i,j-2) + 3.*(ut(i,j-1)+ut(i,j)) - ut(i,j+1))
1145 ub(i,j) = dt5*((uc(i,j-1)+uc(i,j))-(vc(i-1,j)+vc(i,j))*cosa(i,j))*rsina(i,j)
1150 if ( (ie+1)==npx )
then 1152 ub(npx,j) = dt5*(ut(npx,j-1)+ut(npx,j))
1160 ub(i,j) = dt5*(uc(i,j-1)+uc(i,j))
1165 call xtp_u(is,ie,js,je, isd,ied,jsd,jed, ub, u, v, vb, hord_mt, gridstruct%dx, gridstruct%rdx, &
1166 npx, npy, flagstruct%grid_type, nested)
1170 ke(i,j) = 0.5*(ke(i,j) + ub(i,j)*vb(i,j))
1177 if (.not. nested)
then 1179 if ( sw_corner )
then 1180 ke(1,1) = dt6*( (ut(1,1) + ut(1,0)) * u(1,1) + &
1181 (vt(1,1) + vt(0,1)) * v(1,1) + &
1182 (ut(1,1) + vt(1,1)) * u(0,1) )
1184 if ( se_corner )
then 1186 ke(i,1) = dt6*( (ut(i,1) + ut(i, 0)) * u(i-1,1) + &
1187 (vt(i,1) + vt(i-1,1)) * v(i, 1) + &
1188 (ut(i,1) - vt(i-1,1)) * u(i, 1) )
1190 if ( ne_corner )
then 1192 ke(i,j) = dt6*( (ut(i,j ) + ut(i,j-1)) * u(i-1,j) + &
1193 (vt(i,j ) + vt(i-1,j)) * v(i,j-1) + &
1194 (ut(i,j-1) + vt(i-1,j)) * u(i,j ) )
1196 if ( nw_corner )
then 1198 ke(1,j) = dt6*( (ut(1, j) + ut(1,j-1)) * u(1,j ) + &
1199 (vt(1, j) + vt(0, j)) * v(1,j-1) + &
1200 (ut(1,j-1) - vt(1, j)) * u(0,j ) )
1207 vt(i,j) = u(i,j)*dx(i,j)
1212 ut(i,j) = v(i,j)*dy(i,j)
1219 wk(i,j) = rarea(i,j)*( (vt(i,j)-vt(i,j+1)) + (ut(i+1,j)-ut(i,j)) )
1223 if ( .not. hydrostatic )
then 1224 if( flagstruct%do_f3d )
then 1229 w(i,j) = w(i,j)/delp(i,j) + dt2*gridstruct%w00(i,j) * &
1230 ( gridstruct%a11(i,j)*(u(i,j)+u(i,j+1)) + &
1231 gridstruct%a12(i,j)*(v(i,j)+v(i+1,j)) )
1238 w(i,j) = w(i,j)/delp(i,j)
1242 if ( damp_w>1.e-5 )
then 1245 w(i,j) = w(i,j) + dw(i,j)
1254 q_con(i,j) = q_con(i,j)/delp(i,j)
1271 ptc(i,j) = (u(i,j)-0.5*(va(i,j-1)+va(i,j))*cosa_v(i,j)) &
1272 *dyc(i,j)*sina_v(i,j)
1278 vort(i,j) = (v(i,j) - 0.5*(ua(i-1,j)+ua(i,j))*cosa_u(i,j)) &
1279 *dxc(i,j)*sina_u(i,j)
1286 if ( (j==1 .or. j==npy) )
then 1288 if (vc(i,j) > 0)
then 1289 ptc(i,j) = u(i,j)*dyc(i,j)*sin_sg(i,j-1,4)
1291 ptc(i,j) = u(i,j)*dyc(i,j)*sin_sg(i,j,2)
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)
1304 vort(i,j) = (v(i,j) - 0.5*(ua(i-1,j)+ua(i,j))*cosa_u(i,j)) &
1305 *dxc(i,j)*sina_u(i,j)
1308 if (uc(1,j) > 0)
then 1309 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(0,j,3)
1311 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(1,j,1)
1314 if ( (ie+1)==npx )
then 1315 if (uc(npx,j) > 0)
then 1316 vort(npx,j) = v(npx,j)*dxc(npx,j)* &
1319 vort(npx,j) = v(npx,j)*dxc(npx,j)* &
1328 delpc(i,j) = (vort(i,j-1) - vort(i,j)) + (ptc(i-1,j) - ptc(i,j))
1333 if (sw_corner) delpc(1, 1) = delpc(1, 1) - vort(1, 0)
1334 if (se_corner) delpc(npx, 1) = delpc(npx, 1) - vort(npx, 0)
1335 if (ne_corner) delpc(npx,npy) = delpc(npx,npy) + vort(npx,npy)
1336 if (nw_corner) delpc(1, npy) = delpc(1, npy) + vort(1, npy)
1340 delpc(i,j) = gridstruct%rarea_c(i,j)*delpc(i,j)
1341 damp = gridstruct%da_min_c*
max(d2_bg,
min(0.20, dddmp*abs(delpc(i,j)*dt)))
1342 vort(i,j) = damp*delpc(i,j)
1343 ke(i,j) = ke(i,j) + vort(i,j)
1353 delpc(i,j) = divg_d(i,j)
1361 fill_c = (nt/=0) .and. (flagstruct%grid_type<3) .and. &
1362 ( sw_corner .or. se_corner .or. ne_corner .or. nw_corner ) &
1365 if ( fill_c )
call fill_corners(divg_d, npx, npy, fill=xdir, bgrid=.true.)
1367 do i=is-1-nt,ie+1+nt
1368 vc(i,j) = (divg_d(i+1,j)-divg_d(i,j))*divg_u(i,j)
1372 if ( fill_c )
call fill_corners(divg_d, npx, npy, fill=ydir, bgrid=.true.)
1373 do j=js-1-nt,je+1+nt
1375 uc(i,j) = (divg_d(i,j+1)-divg_d(i,j))*divg_v(i,j)
1379 if ( fill_c )
call fill_corners(vc, uc, npx, npy, vector=.true., dgrid=.true.)
1382 divg_d(i,j) = (uc(i,j-1) - uc(i,j)) + (vc(i-1,j) - vc(i,j))
1387 if (sw_corner) divg_d(1, 1) = divg_d(1, 1) - uc(1, 0)
1388 if (se_corner) divg_d(npx, 1) = divg_d(npx, 1) - uc(npx, 0)
1389 if (ne_corner) divg_d(npx,npy) = divg_d(npx,npy) + uc(npx,npy)
1390 if (nw_corner) divg_d(1, npy) = divg_d(1, npy) + uc(1, npy)
1392 if ( .not. gridstruct%stretched_grid )
then 1395 divg_d(i,j) = divg_d(i,j)*gridstruct%rarea_c(i,j)
1402 if ( dddmp<1.e-5)
then 1405 if ( flagstruct%grid_type < 3 )
then 1407 call a2b_ord4(wk, vort, gridstruct, npx, npy, is, ie, js, je, ng, .false.)
1411 vort(i,j) = abs(dt)*sqrt(delpc(i,j)**2 + vort(i,j)**2)
1415 call smag_corner(abs(dt), u, v, ua, va, vort, bd, npx, npy, gridstruct, ng)
1419 if (gridstruct%stretched_grid )
then 1421 dd8 = gridstruct%da_min * d4_bg**n2
1423 dd8 = ( gridstruct%da_min_c*d4_bg )**n2
1428 damp2 = gridstruct%da_min_c*
max(d2_bg,
min(0.20, dddmp*vort(i,j)))
1429 vort(i,j) = damp2*delpc(i,j) + dd8*divg_d(i,j)
1430 ke(i,j) = ke(i,j) + vort(i,j)
1436 if ( d_con > 1.e-5 )
then 1439 ub(i,j) = vort(i,j) - vort(i+1,j)
1444 vb(i,j) = vort(i,j) - vort(i,j+1)
1450 if ( hydrostatic )
then 1453 vort(i,j) = wk(i,j) +
f0(i,j)
1457 if ( flagstruct%do_f3d )
then 1460 vort(i,j) = wk(i,j) +
f0(i,j)*z_rat(i,j)
1466 vort(i,j) = wk(i,j) +
f0(i,j)
1472 call fv_tp_2d(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx, fy, &
1473 xfx_adv,yfx_adv, gridstruct, bd, ra_x, ra_y)
1476 u(i,j) = vt(i,j) + (ke(i,j) - ke(i+1,j)) + fy(i,j)
1481 v(i,j) = ut(i,j) + (ke(i,j) - ke(i,j+1)) - fx(i,j)
1487 if ( damp_v>1.e-5 )
then 1488 damp4 = (damp_v*gridstruct%da_min_c)**(nord_v+1)
1489 call del6_vt_flux(nord_v, npx, npy, damp4, wk, vort, ut, vt, gridstruct, bd)
1492 if ( d_con > 1.e-5 )
then 1495 ub(i,j) = (ub(i,j) + vt(i,j))*rdx(i,j)
1496 fy(i,j) = u(i,j)*rdx(i,j)
1497 gy(i,j) = fy(i,j)*ub(i,j)
1502 vb(i,j) = (vb(i,j) - ut(i,j))*rdy(i,j)
1503 fx(i,j) = v(i,j)*rdy(i,j)
1504 gx(i,j) = fx(i,j)*vb(i,j)
1513 u2 = fy(i,j) + fy(i,j+1)
1514 du2 = ub(i,j) + ub(i,j+1)
1515 v2 = fx(i,j) + fx(i+1,j)
1516 dv2 = vb(i,j) + vb(i+1,j)
1519 heat_source(i,j) = delp(i,j)*(heat_source(i,j) - damp*rsin2(i,j)*( &
1520 (ub(i,j)**2 + ub(i,j+1)**2 + vb(i,j)**2 + vb(i+1,j)**2) &
1521 + 2.*(gy(i,j)+gy(i,j+1)+gx(i,j)+gx(i+1,j)) &
1522 - cosa_s(i,j)*(
u2*dv2 + v2*du2 + du2*dv2)) )
1528 if ( damp_v>1.e-5 )
then 1531 u(i,j) = u(i,j) + vt(i,j)
1536 v(i,j) = v(i,j) - ut(i,j)
1547 subroutine del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
1555 integer,
intent(in):: nord, npx, npy
1556 real,
intent(in):: damp
1558 real,
intent(inout):: q(bd%isd:bd%ied, bd%jsd:bd%jed)
1561 real,
intent(out):: d2(bd%isd:bd%ied, bd%jsd:bd%jed)
1562 real,
intent(out):: fx2(bd%isd:bd%ied+1,bd%jsd:bd%jed), fy2(bd%isd:bd%ied,bd%jsd:bd%jed+1)
1563 integer i,j, nt, n, i1, i2, j1, j2
1568 real,
pointer,
dimension(:,:,:) :: sin_sg
1569 real,
pointer,
dimension(:,:) :: rdxc, rdyc, dx,dy
1572 integer :: is, ie, js, je
1575 sin_sg => gridstruct%sin_sg
1576 rdxc => gridstruct%rdxc
1577 rdyc => gridstruct%rdyc
1581 nested = gridstruct%nested
1588 i1 = is-1-nord; i2 = ie+1+nord
1589 j1 = js-1-nord; j2 = je+1+nord
1593 d2(i,j) = damp*q(i,j)
1597 if( nord>0 )
call copy_corners(d2, npx, npy, 1, nested, bd, gridstruct%sw_corner, &
1598 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1599 do j=js-nord,je+nord
1600 do i=is-nord,ie+nord+1
1602 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)
1604 fx2(i,j) = gridstruct%del6_v(i,j)*(d2(i-1,j)-d2(i,j))
1609 if( nord>0 )
call copy_corners(d2, npx, npy, 2, nested, bd, gridstruct%sw_corner, &
1610 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1611 do j=js-nord,je+nord+1
1612 do i=is-nord,ie+nord
1614 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)
1616 fy2(i,j) = gridstruct%del6_u(i,j)*(d2(i,j-1)-d2(i,j))
1624 do j=js-nt-1,je+nt+1
1625 do i=is-nt-1,ie+nt+1
1626 d2(i,j) = ((fx2(i,j)-fx2(i+1,j))+(fy2(i,j)-fy2(i,j+1)))*gridstruct%rarea(i,j)
1630 call copy_corners(d2, npx, npy, 1, nested, bd, gridstruct%sw_corner, &
1631 gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1636 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)
1638 fx2(i,j) = gridstruct%del6_v(i,j)*(d2(i,j)-d2(i-1,j))
1644 gridstruct%sw_corner, gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
1649 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)
1651 fy2(i,j) = gridstruct%del6_u(i,j)*(d2(i,j)-d2(i,j-1))
1663 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1664 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v
1665 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1666 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1):: divg_d
1670 real uf(bd%is-2:bd%ie+2,bd%js-1:bd%je+2)
1671 real vf(bd%is-1:bd%ie+2,bd%js-2:bd%je+2)
1675 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
1676 real,
pointer,
dimension(:,:) :: dxc,dyc
1678 integer :: is, ie, js, je
1687 npx = flagstruct%npx
1688 npy = flagstruct%npy
1689 nested = gridstruct%nested
1691 sin_sg => gridstruct%sin_sg
1692 cos_sg => gridstruct%cos_sg
1693 dxc => gridstruct%dxc
1694 dyc => gridstruct%dyc
1697 is2 = is; ie1 = ie+1
1699 is2 =
max(2,is); ie1 =
min(npx-1,ie+1)
1702 if (flagstruct%grid_type==4)
then 1705 uf(i,j) = u(i,j)*dyc(i,j)
1710 vf(i,j) = v(i,j)*dxc(i,j)
1715 divg_d(i,j) = gridstruct%rarea_c(i,j)*((vf(i,j-1)-vf(i,j))+(uf(i-1,j)-uf(i,j)))
1725 if ( j==1 .or. j==npy )
then 1727 uf(i,j) = u(i,j)*dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1731 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))) &
1732 * dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1739 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))) &
1740 *dxc(i,j)*0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))
1742 if ( is == 1 ) vf(1, j) = v(1, j)*dxc(1, j)*0.5*(sin_sg(0,j,3)+sin_sg(1,j,1))
1743 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))
1748 divg_d(i,j) = (vf(i,j-1) - vf(i,j)) + (uf(i-1,j) - uf(i,j))
1753 if (gridstruct%sw_corner) divg_d(1, 1) = divg_d(1, 1) - vf(1, 0)
1754 if (gridstruct%se_corner) divg_d(npx, 1) = divg_d(npx, 1) - vf(npx, 0)
1755 if (gridstruct%ne_corner) divg_d(npx,npy) = divg_d(npx,npy) + vf(npx,npy)
1756 if (gridstruct%nw_corner) divg_d(1, npy) = divg_d(1, npy) + vf(1, npy)
1760 divg_d(i,j) = gridstruct%rarea_c(i,j)*divg_d(i,j)
1770 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1771 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed):: v
1772 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1773 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed+1):: divg_d
1778 real uf(bd%isd:bd%ied,bd%jsd:bd%jed+1)
1779 real vf(bd%isd:bd%ied+1,bd%jsd:bd%jed)
1783 real,
pointer,
dimension(:,:) :: rarea_c
1785 real,
pointer,
dimension(:,:,:) :: sin_sg, cos_sg
1786 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v
1787 real,
pointer,
dimension(:,:) :: sina_u, sina_v
1788 real,
pointer,
dimension(:,:) :: dxc,dyc
1790 integer :: isd, ied, jsd, jed
1799 npx = flagstruct%npx
1800 npy = flagstruct%npy
1801 nested = gridstruct%nested
1803 rarea_c => gridstruct%rarea_c
1804 sin_sg => gridstruct%sin_sg
1805 cos_sg => gridstruct%cos_sg
1806 cosa_u => gridstruct%cosa_u
1807 cosa_v => gridstruct%cosa_v
1808 sina_u => gridstruct%sina_u
1809 sina_v => gridstruct%sina_v
1810 dxc => gridstruct%dxc
1811 dyc => gridstruct%dyc
1815 if (flagstruct%grid_type==4)
then 1818 uf(i,j) = u(i,j)*dyc(i,j)
1823 vf(i,j) = v(i,j)*dxc(i,j)
1828 divg_d(i,j) = rarea_c(i,j)*((vf(i,j-1)-vf(i,j))+(uf(i-1,j)-uf(i,j)))
1835 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))) &
1836 * dyc(i,j)*0.5*(sin_sg(i,j-1,4)+sin_sg(i,j,2))
1842 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))) &
1843 *dxc(i,j)*0.5*(sin_sg(i-1,j,3)+sin_sg(i,j,1))
1849 divg_d(i,j) = ((vf(i,j-1) - vf(i,j)) + (uf(i-1,j) - uf(i,j)))*rarea_c(i,j)
1880 subroutine smag_corner(dt, u, v, ua, va, smag_c, bd, npx, npy, gridstruct, ng)
1883 type(fv_grid_bounds_type),
intent(IN) :: bd
1884 real,
intent(in):: dt
1885 integer,
intent(IN) :: npx, npy, ng
1886 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed+1):: u
1887 real,
intent(in),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: v
1888 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ua, va
1889 real,
intent(out),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: smag_c
1890 type(fv_grid_type),
intent(IN),
target :: gridstruct
1892 real:: ut(bd%isd:bd%ied+1,bd%jsd:bd%jed)
1893 real:: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1894 real:: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
1895 real:: sh(bd%isd:bd%ied,bd%jsd:bd%jed)
1899 real,
pointer,
dimension(:,:) :: dxc, dyc, dx, dy, rarea, rarea_c
1901 integer :: is, ie, js, je
1902 integer :: isd, ied, jsd, jed
1914 dxc => gridstruct%dxc
1915 dyc => gridstruct%dyc
1918 rarea => gridstruct%rarea
1919 rarea_c => gridstruct%rarea_c
1921 is2 =
max(2,is); ie1 =
min(npx-1,ie+1)
1928 ut(i,j) = u(i,j)*dyc(i,j)
1933 vt(i,j) = v(i,j)*dxc(i,j)
1938 smag_c(i,j) = rarea_c(i,j)*((vt(i,j-1)-vt(i,j)) + (ut(i,j)-ut(i-1,j)))
1946 vt(i,j) = u(i,j)*dx(i,j)
1951 ut(i,j) = v(i,j)*dy(i,j)
1957 wk(i,j) = rarea(i,j)*((vt(i,j)-vt(i,j+1))+(ut(i,j)-ut(i+1,j)))
1960 call a2b_ord4(wk, sh, gridstruct, npx, npy, is, ie, js, je, ng, .false.)
1963 smag_c(i,j) = dt*sqrt( sh(i,j)**2 + smag_c(i,j)**2 )
1970 subroutine xtp_u(is,ie,js,je,isd,ied,jsd,jed,c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, nested)
1972 integer,
intent(in):: is,ie,js,je, isd,ied,jsd,jed
1973 real,
INTENT(IN):: u(isd:ied,jsd:jed+1)
1974 real,
INTENT(IN):: v(isd:ied+1,jsd:jed)
1975 real,
INTENT(IN):: c(is:ie+1,js:je+1)
1976 real,
INTENT(out):: flux(is:ie+1,js:je+1)
1977 real,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
1978 real,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
1979 integer,
INTENT(IN) :: iord, npx, npy, grid_type
1980 logical,
INTENT(IN) :: nested
1982 real,
dimension(is-1:ie+1):: bl, br, b0
1983 logical,
dimension(is-1:ie+1):: smt5, smt6
1985 real al(is-1:ie+2), dm(is-2:ie+2)
1987 real dl, dr, xt, pmp, lac, cfl
1988 real pmp_1, lac_1, pmp_2, lac_2
1989 real x0, x1, x0L, x0R
1995 is3 = is-1 ; ie3 = ie+1
1997 is3 =
max(3,is-1) ; ie3 =
min(npx-3,ie+1)
2004 if( c(i,j)>0. )
then 2005 flux(i,j) = u(i-1,j)
2012 elseif ( iord < 8 )
then 2018 al(i) =
p1*(u(i-1,j)+u(i,j)) +
p2*(u(i-2,j)+u(i+1,j))
2021 bl(i) = al(i ) - u(i,j)
2022 br(i) = al(i+1) - u(i,j)
2025 if ( (.not.nested) .and.
grid_type < 3)
then 2027 xt =
c3*u(1,j) +
c2*u(2,j) +
c1*u(3,j)
2030 br(2) = al(3) - u(2,j)
2031 if( j==1 .or. j==npy )
then 2037 bl(0) =
c1*u(-2,j) +
c2*u(-1,j) +
c3*u(0,j) - u(0,j)
2038 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)) &
2039 + ((2.*dx(1,j)+dx( 2,j))*(u(1,j))-dx(1,j)*u( 2,j))/(dx(1,j)+dx( 2,j)) )
2045 if ( (ie+1)==npx )
then 2046 bl(npx-2) = al(npx-2) - u(npx-2,j)
2047 xt =
c1*u(npx-3,j) +
c2*u(npx-2,j) +
c3*u(npx-1,j)
2048 br(npx-2) = xt - u(npx-2,j)
2049 bl(npx-1) = xt - u(npx-1,j)
2050 if( j==1 .or. j==npy )
then 2056 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)) &
2057 + ( (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)) )
2058 br(npx-1) = xt - u(npx-1,j)
2059 bl(npx ) = xt - u(npx ,j)
2060 br(npx) =
c3*u(npx,j) +
c2*u(npx+1,j) +
c1*u(npx+2,j) - u(npx,j)
2067 b0(i) = bl(i) + br(i)
2074 if( c(i,j)>0. )
then 2075 cfl = c(i,j)*rdx(i-1,j)
2076 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2078 cfl = c(i,j)*rdx(i,j)
2079 flux(i,j) = u(i,j) + (1.+cfl)*(bl(i)+cfl*b0(i))
2083 elseif ( iord==3 )
then 2086 x1 = abs(bl(i)-br(i))
2088 smt6(i) = 3.*x0 < x1
2094 if( c(i,j)>0. )
then 2095 cfl = c(i,j)*rdx(i-1,j)
2096 if ( smt6(i-1).or.smt5(i) )
then 2097 fx0(i) = br(i-1) - cfl*b0(i-1)
2098 elseif( smt5(i-1) )
then 2099 fx0(i) = sign(
min(abs(bl(i-1)),abs(br(i-1))), br(i-1))
2101 flux(i,j) = u(i-1,j) + (1.-cfl)*fx0(i)
2103 cfl = c(i,j)*rdx(i,j)
2104 if ( smt6(i).or.smt5(i-1) )
then 2105 fx0(i) = bl(i) + cfl*b0(i)
2106 elseif( smt5(i) )
then 2107 fx0(i) = sign(
min(abs(bl(i)),abs(br(i))), bl(i))
2109 flux(i,j) = u(i,j) + (1.+cfl)*fx0(i)
2113 elseif ( iord==4 )
then 2116 x1 = abs(bl(i)-br(i))
2118 smt6(i) = 3.*x0 < x1
2121 if( c(i,j)>0. )
then 2122 if ( smt6(i-1).or.smt5(i) )
then 2123 cfl = c(i,j)*rdx(i-1,j)
2124 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1) - cfl*b0(i-1))
2126 flux(i,j) = u(i-1,j)
2129 if ( smt6(i).or.smt5(i-1) )
then 2130 cfl = c(i,j)*rdx(i,j)
2131 flux(i,j) = u(i,j) + (1.+cfl)*(bl(i) + cfl*b0(i))
2143 smt5(i) = bl(i)*br(i) < 0.
2147 smt5(i) = abs(3.*b0(i)) < abs(bl(i)-br(i))
2152 if( c(i,j)>0. )
then 2153 cfl = c(i,j)*rdx(i-1,j)
2154 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
2155 flux(i,j) = u(i-1,j)
2157 cfl = c(i,j)*rdx(i,j)
2158 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
2161 if (smt5(i-1).or.smt5(i)) flux(i,j) = flux(i,j) + fx0(i)
2172 xt = 0.25*(u(i+1,j) - u(i-1,j))
2173 dm(i) = sign(
min(abs(xt),
max(u(i-1,j), u(i,j), u(i+1,j)) - u(i,j), &
2174 u(i,j) -
min(u(i-1,j), u(i,j), u(i+1,j))), xt)
2177 dq(i) = u(i+1,j) - u(i,j)
2183 al(i) = 0.5*(u(i-1,j)+u(i,j)) +
r3*(dm(i-1) - dm(i))
2190 bl(i) = -sign(
min(abs(xt), abs(al(i )-u(i,j))), xt)
2191 br(i) = sign(
min(abs(xt), abs(al(i+1)-u(i,j))), xt)
2193 elseif( iord==9 )
then 2196 lac_1 = pmp_1 + 1.5*dq(i+1)
2197 bl(i) =
min(
max(0., pmp_1, lac_1),
max(al(i )-u(i,j),
min(0., pmp_1, lac_1)))
2199 lac_2 = pmp_2 - 1.5*dq(i-2)
2200 br(i) =
min(
max(0., pmp_2, lac_2),
max(al(i+1)-u(i,j),
min(0., pmp_2, lac_2)))
2202 elseif( iord==10 )
then 2204 bl(i) = al(i ) - u(i,j)
2205 br(i) = al(i+1) - u(i,j)
2208 if ( abs(dm(i-1))+abs(dm(i+1)) <
near_zero )
then 2213 elseif( abs(3.*(bl(i)+br(i))) > abs(bl(i)-br(i)) )
then 2215 lac_1 = pmp_1 + 1.5*dq(i+1)
2216 bl(i) =
min(
max(0., pmp_1, lac_1),
max(bl(i),
min(0., pmp_1, lac_1)))
2218 lac_2 = pmp_2 - 1.5*dq(i-2)
2219 br(i) =
min(
max(0., pmp_2, lac_2),
max(br(i),
min(0., pmp_2, lac_2)))
2225 bl(i) = al(i ) - u(i,j)
2226 br(i) = al(i+1) - u(i,j)
2234 if ( is==1 .and. .not. nested)
then 2235 br(2) = al(3) - u(2,j)
2236 xt =
s15*u(1,j) +
s11*u(2,j) -
s14*dm(2)
2239 if( j==1 .or. j==npy )
then 2245 bl(0) =
s14*dm(-1) -
s11*dq(-1)
2246 x0l = 0.5*((2.*dx(0,j)+dx(-1,j))*(u(0,j)) &
2247 - dx(0,j)*(u(-1,j)))/(dx(0,j)+dx(-1,j))
2248 x0r = 0.5*((2.*dx(1,j)+dx(2,j))*(u(1,j)) &
2249 - dx(1,j)*(u(2,j)))/(dx(1,j)+dx(2,j))
2254 call pert_ppm(1, u(2,j), bl(2), br(2), -1)
2257 if ( (ie+1)==npx .and. .not. nested)
then 2258 bl(npx-2) = al(npx-2) - u(npx-2,j)
2259 xt =
s15*u(npx-1,j) +
s11*u(npx-2,j) +
s14*dm(npx-2)
2260 br(npx-2) = xt - u(npx-2,j)
2261 bl(npx-1) = xt - u(npx-1,j)
2262 if( j==1 .or. j==npy )
then 2268 br(npx) =
s11*dq(npx) -
s14*dm(npx+1)
2269 x0l = 0.5*( (2.*dx(npx-1,j)+dx(npx-2,j))*(u(npx-1,j)) &
2270 - dx(npx-1,j)*(u(npx-2,j)))/(dx(npx-1,j)+dx(npx-2,j))
2271 x0r = 0.5*( (2.*dx(npx,j)+dx(npx+1,j))*(u(npx,j)) &
2272 - dx(npx,j)*(u(npx+1,j)))/(dx(npx,j)+dx(npx+1,j))
2274 br(npx-1) = xt - u(npx-1,j)
2275 bl(npx ) = xt - u(npx ,j)
2277 call pert_ppm(1, u(npx-2,j), bl(npx-2), br(npx-2), -1)
2283 al(i) = 0.5*(u(i-1,j)+u(i,j)) +
r3*(dm(i-1) - dm(i))
2288 lac = pmp + 1.5*dq(i+1)
2289 bl(i) =
min(
max(0., pmp, lac),
max(al(i )-u(i,j),
min(0.,pmp, lac)))
2291 lac = pmp - 1.5*dq(i-2)
2292 br(i) =
min(
max(0., pmp, lac),
max(al(i+1)-u(i,j),
min(0.,pmp, lac)))
2297 if( c(i,j)>0. )
then 2298 cfl = c(i,j)*rdx(i-1,j)
2299 flux(i,j) = u(i-1,j) + (1.-cfl)*(br(i-1)-cfl*(bl(i-1)+br(i-1)))
2301 cfl = c(i,j)*rdx(i,j)
2302 flux(i,j) = u(i, j) + (1.+cfl)*(bl(i )+cfl*(bl(i )+br(i )))
2309 end subroutine xtp_u 2312 subroutine ytp_v(is,ie,js,je,isd,ied,jsd,jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, nested)
2313 integer,
intent(in):: is,ie,js,je, isd,ied,jsd,jed
2314 integer,
intent(IN):: jord
2315 real,
INTENT(IN) :: u(isd:ied,jsd:jed+1)
2316 real,
INTENT(IN) :: v(isd:ied+1,jsd:jed)
2317 real,
INTENT(IN) :: c(is:ie+1,js:je+1)
2318 real,
INTENT(OUT):: flux(is:ie+1,js:je+1)
2319 real,
INTENT(IN) :: dy(isd:ied+1,jsd:jed)
2320 real,
INTENT(IN) :: rdy(isd:ied+1,jsd:jed)
2321 integer,
INTENT(IN) :: npx, npy, grid_type
2322 logical,
INTENT(IN) :: nested
2324 logical,
dimension(is:ie+1,js-1:je+1):: smt5, smt6
2326 real dm(is:ie+1,js-2:je+2)
2327 real al(is:ie+1,js-1:je+2)
2328 real,
dimension(is:ie+1,js-1:je+1):: bl, br, b0
2329 real dq(is:ie+1,js-3:je+2)
2330 real xt, dl, dr, pmp, lac, cfl
2331 real pmp_1, lac_1, pmp_2, lac_2
2332 real x0, x1, x0R, x0L
2333 integer i, j, is1, ie1, js3, je3
2336 js3 = js-1; je3 = je+1
2338 js3 =
max(3,js-1); je3 =
min(npy-3,je+1)
2345 if( c(i,j)>0. )
then 2346 flux(i,j) = v(i,j-1)
2353 elseif ( jord<8 )
then 2358 al(i,j) =
p1*(v(i,j-1)+v(i,j)) +
p2*(v(i,j-2)+v(i,j+1))
2363 bl(i,j) = al(i,j ) - v(i,j)
2364 br(i,j) = al(i,j+1) - v(i,j)
2368 if ( (.not.nested) .and.
grid_type < 3)
then 2371 bl(i,0) =
c1*v(i,-2) +
c2*v(i,-1) +
c3*v(i,0) - v(i,0)
2372 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)) &
2373 + ((2.*dy(i,1)+dy(i, 2))*v(i,1)-dy(i,1)*v(i, 2))/(dy(i,1)+dy(i, 2)) )
2374 br(i,0) = xt - v(i,0)
2375 bl(i,1) = xt - v(i,1)
2376 xt =
c3*v(i,1) +
c2*v(i,2) +
c1*v(i,3)
2377 br(i,1) = xt - v(i,1)
2378 bl(i,2) = xt - v(i,2)
2379 br(i,2) = al(i,3) - v(i,2)
2387 if ( (ie+1)==npx )
then 2396 if( (je+1)==npy )
then 2398 bl(i,npy-2) = al(i,npy-2) - v(i,npy-2)
2399 xt =
c1*v(i,npy-3) +
c2*v(i,npy-2) +
c3*v(i,npy-1)
2400 br(i,npy-2) = xt - v(i,npy-2)
2401 bl(i,npy-1) = xt - v(i,npy-1)
2402 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)) &
2403 + ((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)) )
2404 br(i,npy-1) = xt - v(i,npy-1)
2405 bl(i,npy ) = xt - v(i,npy)
2406 br(i,npy) =
c3*v(i,npy)+
c2*v(i,npy+1) +
c1*v(i,npy+2) - v(i,npy)
2414 if ( (ie+1)==npx )
then 2427 b0(i,j) = bl(i,j) + br(i,j)
2435 if( c(i,j)>0. )
then 2436 cfl = c(i,j)*rdy(i,j-1)
2437 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2439 cfl = c(i,j)*rdy(i,j)
2440 flux(i,j) = v(i,j) + (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2445 elseif ( jord==3 )
then 2450 x1 = abs(bl(i,j)-br(i,j))
2452 smt6(i,j) = 3.*x0 < x1
2461 if( c(i,j)>0. )
then 2462 cfl = c(i,j)*rdy(i,j-1)
2463 if ( smt6(i,j-1).or.smt5(i,j) )
then 2464 fx0(i) = br(i,j-1) - cfl*b0(i,j-1)
2465 elseif ( smt5(i,j-1) )
then 2466 fx0(i) = sign(
min(abs(bl(i,j-1)),abs(br(i,j-1))), br(i,j-1))
2468 flux(i,j) = v(i,j-1) + (1.-cfl)*fx0(i)
2470 cfl = c(i,j)*rdy(i,j)
2471 if ( smt6(i,j).or.smt5(i,j-1) )
then 2472 fx0(i) = bl(i,j) + cfl*b0(i,j)
2473 elseif ( smt5(i,j) )
then 2474 fx0(i) = sign(
min(abs(bl(i,j)),abs(br(i,j))), bl(i,j))
2476 flux(i,j) = v(i,j) + (1.+cfl)*fx0(i)
2481 elseif ( jord==4 )
then 2486 x1 = abs(bl(i,j)-br(i,j))
2488 smt6(i,j) = 3.*x0 < x1
2493 if( c(i,j)>0. )
then 2494 if ( smt6(i,j-1).or.smt5(i,j) )
then 2495 cfl = c(i,j)*rdy(i,j-1)
2496 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1) - cfl*b0(i,j-1))
2498 flux(i,j) = v(i,j-1)
2501 if ( smt6(i,j).or.smt5(i,j-1) )
then 2502 cfl = c(i,j)*rdy(i,j)
2503 flux(i,j) = v(i,j) + (1.+cfl)*(bl(i,j) + cfl*b0(i,j))
2518 smt5(i,j) = bl(i,j)*br(i,j) < 0.
2524 smt5(i,j) = abs(3.*b0(i,j)) < abs(bl(i,j)-br(i,j))
2532 if( c(i,j)>0. )
then 2533 cfl = c(i,j)*rdy(i,j-1)
2534 fx0(i) = (1.-cfl)*(br(i,j-1)-cfl*b0(i,j-1))
2535 flux(i,j) = v(i,j-1)
2537 cfl = c(i,j)*rdy(i,j)
2538 fx0(i) = (1.+cfl)*(bl(i,j)+cfl*b0(i,j))
2541 if (smt5(i,j-1).or.smt5(i,j)) flux(i,j) = flux(i,j) + fx0(i)
2552 xt = 0.25*(v(i,j+1) - v(i,j-1))
2553 dm(i,j) = sign(
min(abs(xt),
max(v(i,j-1), v(i,j), v(i,j+1)) - v(i,j), &
2554 v(i,j) -
min(v(i,j-1), v(i,j), v(i,j+1))), xt)
2560 dq(i,j) = v(i,j+1) - v(i,j)
2567 al(i,j) = 0.5*(v(i,j-1)+v(i,j)) +
r3*(dm(i,j-1)-dm(i,j))
2575 bl(i,j) = -sign(
min(abs(xt), abs(al(i,j)-v(i,j))), xt)
2576 br(i,j) = sign(
min(abs(xt), abs(al(i,j+1)-v(i,j))), xt)
2579 elseif ( jord==9 )
then 2583 lac_1 = pmp_1 + 1.5*dq(i,j+1)
2584 bl(i,j) =
min(
max(0., pmp_1, lac_1),
max(al(i,j)-v(i,j),
min(0., pmp_1, lac_1)))
2585 pmp_2 = 2.*dq(i,j-1)
2586 lac_2 = pmp_2 - 1.5*dq(i,j-2)
2587 br(i,j) =
min(
max(0., pmp_2, lac_2),
max(al(i,j+1)-v(i,j),
min(0., pmp_2, lac_2)))
2590 elseif ( jord==10 )
then 2593 bl(i,j) = al(i,j ) - v(i,j)
2594 br(i,j) = al(i,j+1) - v(i,j)
2597 if ( abs(dm(i,j-1))+abs(dm(i,j+1)) <
near_zero )
then 2601 elseif( abs(3.*(bl(i,j)+br(i,j))) > abs(bl(i,j)-br(i,j)) )
then 2603 lac_1 = pmp_1 + 1.5*dq(i,j+1)
2604 bl(i,j) =
min(
max(0., pmp_1, lac_1),
max(bl(i,j),
min(0., pmp_1, lac_1)))
2605 pmp_2 = 2.*dq(i,j-1)
2606 lac_2 = pmp_2 - 1.5*dq(i,j-2)
2607 br(i,j) =
min(
max(0., pmp_2, lac_2),
max(br(i,j),
min(0., pmp_2, lac_2)))
2615 bl(i,j) = al(i,j ) - v(i,j)
2616 br(i,j) = al(i,j+1) - v(i,j)
2624 if( js==1 .and. .not. nested)
then 2626 br(i,2) = al(i,3) - v(i,2)
2627 xt =
s15*v(i,1) +
s11*v(i,2) -
s14*dm(i,2)
2628 br(i,1) = xt - v(i,1)
2629 bl(i,2) = xt - v(i,2)
2631 bl(i,0) =
s14*dm(i,-1) -
s11*dq(i,-1)
2634 xt =
t14*v(i,1) +
t12*v(i,2) +
t15*v(i,3)
2635 bl(i,1) = 2.*xt - v(i,1)
2636 xt =
t14*v(i,0) +
t12*v(i,-1) +
t15*v(i,-2)
2637 br(i,0) = 2.*xt - v(i,0)
2639 x0l = 0.5*( (2.*dy(i,0)+dy(i,-1))*(v(i,0)) &
2640 - dy(i,0)*(v(i,-1)))/(dy(i,0)+dy(i,-1))
2641 x0r = 0.5*( (2.*dy(i,1)+dy(i,2))*(v(i,1)) &
2642 - dy(i,1)*(v(i,2)))/(dy(i,1)+dy(i,2))
2645 bl(i,1) = xt - v(i,1)
2646 br(i,0) = xt - v(i,0)
2655 if ( (ie+1)==npx )
then 2662 call pert_ppm(ie-is+2, v(is,j), bl(is,j), br(is,j), -1)
2664 if( (je+1)==npy .and. .not. nested)
then 2666 bl(i,npy-2) = al(i,npy-2) - v(i,npy-2)
2667 xt =
s15*v(i,npy-1) +
s11*v(i,npy-2) +
s14*dm(i,npy-2)
2668 br(i,npy-2) = xt - v(i,npy-2)
2669 bl(i,npy-1) = xt - v(i,npy-1)
2670 br(i,npy) =
s11*dq(i,npy) -
s14*dm(i,npy+1)
2672 xt =
t14*v(i,npy-1) +
t12*v(i,npy-2) +
t15*v(i,npy-3)
2673 br(i,npy-1) = 2.*xt - v(i,npy-1)
2674 xt =
t14*v(i,npy) +
t12*v(i,npy+1) +
t15*v(i,npy+2)
2675 bl(i,npy ) = 2.*xt - v(i,npy)
2677 x0l= 0.5*((2.*dy(i,npy-1)+dy(i,npy-2))*(v(i,npy-1)) - &
2678 dy(i,npy-1)*(v(i,npy-2)))/(dy(i,npy-1)+dy(i,npy-2))
2679 x0r= 0.5*((2.*dy(i,npy)+dy(i,npy+1))*(v(i,npy)) - &
2680 dy(i,npy)*(v(i,npy+1)))/(dy(i,npy)+dy(i,npy+1))
2683 br(i,npy-1) = xt - v(i,npy-1)
2684 bl(i,npy ) = xt - v(i,npy)
2693 if ( (ie+1)==npx )
then 2700 call pert_ppm(ie-is+2, v(is,j), bl(is,j), br(is,j), -1)
2707 al(i,j) = 0.5*(v(i,j-1)+v(i,j)) +
r3*(dm(i,j-1)-dm(i,j))
2714 lac = pmp - 1.5*dq(i,j-2)
2715 br(i,j) =
min(
max(0.,pmp,lac),
max(al(i,j+1)-v(i,j),
min(0.,pmp,lac)))
2717 lac = pmp + 1.5*dq(i,j+1)
2718 bl(i,j) =
min(
max(0.,pmp,lac),
max(al(i,j)-v(i,j),
min(0.,pmp,lac)))
2727 cfl = c(i,j)*rdy(i,j-1)
2728 flux(i,j) = v(i,j-1) + (1.-cfl)*(br(i,j-1)-cfl*(bl(i,j-1)+br(i,j-1)))
2730 cfl = c(i,j)*rdy(i,j)
2731 flux(i,j) = v(i,j ) + (1.+cfl)*(bl(i,j )+cfl*(bl(i,j )+br(i,j )))
2738 end subroutine ytp_v 2746 subroutine d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, &
2747 bd, npx, npy, nested, grid_type)
2749 logical,
intent(in):: dord4
2750 real,
intent(in) :: u(bd%isd:bd%ied,bd%jsd:bd%jed+1)
2751 real,
intent(in) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed)
2752 real,
intent(out),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ):: uc
2753 real,
intent(out),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1):: vc
2754 real,
intent(out),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed ):: ua, va, ut, vt
2755 integer,
intent(IN) :: npx, npy,
grid_type 2756 logical,
intent(IN) :: nested
2759 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: utmp, vtmp
2760 integer npt, i, j, ifirst, ilast, id
2761 integer :: is, ie, js, je
2762 integer :: isd, ied, jsd, jed
2764 real,
pointer,
dimension(:,:,:) :: sin_sg
2765 real,
pointer,
dimension(:,:) :: cosa_u, cosa_v, cosa_s
2766 real,
pointer,
dimension(:,:) :: rsin_u, rsin_v, rsin2
2767 real,
pointer,
dimension(:,:) :: dxa,dya
2778 sin_sg => gridstruct%sin_sg
2779 cosa_u => gridstruct%cosa_u
2780 cosa_v => gridstruct%cosa_v
2781 cosa_s => gridstruct%cosa_s
2782 rsin_u => gridstruct%rsin_u
2783 rsin_v => gridstruct%rsin_v
2784 rsin2 => gridstruct%rsin2
2785 dxa => gridstruct%dxa
2786 dya => gridstruct%dya
2794 if (
grid_type < 3 .and. .not. nested)
then 2808 utmp(i,j) =
a2*(u(i,j-1)+u(i,j+2)) +
a1*(u(i,j)+u(i,j+1))
2813 utmp(i,j) = 0.5*(u(i,j)+u(i,j+1))
2815 utmp(i,j) = 0.5*(u(i,j)+u(i,j+1))
2820 vtmp(i,j) =
a2*(v(i-1,j)+v(i+2,j)) +
a1*(v(i,j)+v(i+1,j))
2823 vtmp(i,j) = 0.5*(v(i,j)+v(i+1,j))
2825 vtmp(i,j) = 0.5*(v(i,j)+v(i+1,j))
2830 ua(i,j) = (utmp(i,j)-vtmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2831 va(i,j) = (vtmp(i,j)-utmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2839 do j=
max(npt,js-1),
min(npy-npt,je+1)
2840 do i=
max(npt,isd),
min(npx-npt,ied)
2841 utmp(i,j) =
a2*(u(i,j-1)+u(i,j+2)) +
a1*(u(i,j)+u(i,j+1))
2844 do j=
max(npt,jsd),
min(npy-npt,jed)
2845 do i=
max(npt,is-1),
min(npx-npt,ie+1)
2846 vtmp(i,j) =
a2*(v(i-1,j)+v(i+2,j)) +
a1*(v(i,j)+v(i+1,j))
2855 if ( js==1 .or. jsd<npt)
then 2858 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2859 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2863 if ( (je+1)==npy .or. jed>=(npy-npt))
then 2866 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2867 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2872 if ( is==1 .or. isd<npt )
then 2873 do j=
max(npt,jsd),
min(npy-npt,jed)
2875 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2876 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2880 if ( (ie+1)==npx .or. ied>=(npx-npt))
then 2881 do j=
max(npt,jsd),
min(npy-npt,jed)
2883 utmp(i,j) = 0.5*(u(i,j) + u(i,j+1))
2884 vtmp(i,j) = 0.5*(v(i,j) + v(i+1,j))
2892 do j=js-1-id,je+1+id
2893 do i=is-1-id,ie+1+id
2894 ua(i,j) = (utmp(i,j)-vtmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2895 va(i,j) = (vtmp(i,j)-utmp(i,j)*cosa_s(i,j)) * rsin2(i,j)
2906 if( gridstruct%sw_corner )
then 2908 utmp(i,0) = -vtmp(0,1-i)
2911 if( gridstruct%se_corner )
then 2913 utmp(npx+i,0) = vtmp(npx,i+1)
2916 if( gridstruct%ne_corner )
then 2918 utmp(npx+i,npy) = -vtmp(npx,je-i)
2921 if( gridstruct%nw_corner )
then 2923 utmp(i,npy) = vtmp(0,je+i)
2927 if (
grid_type < 3 .and. .not. nested)
then 2928 ifirst =
max(3, is-1)
2929 ilast =
min(npx-2,ie+2)
2939 uc(i,j) =
a2*(utmp(i-2,j)+utmp(i+1,j)) +
a1*(utmp(i-1,j)+utmp(i,j))
2940 ut(i,j) = (uc(i,j) - v(i,j)*cosa_u(i,j))*rsin_u(i,j)
2946 if( gridstruct%sw_corner )
then 2950 if( gridstruct%se_corner )
then 2951 ua(npx, 0) = va(npx,1)
2952 ua(npx+1,0) = va(npx,2)
2954 if( gridstruct%ne_corner )
then 2955 ua(npx, npy) = -va(npx,npy-1)
2956 ua(npx+1,npy) = -va(npx,npy-2)
2958 if( gridstruct%nw_corner )
then 2959 ua(-1,npy) = va(0,npy-2)
2960 ua( 0,npy) = va(0,npy-1)
2963 if( is==1 .and. .not. nested )
then 2965 uc(0,j) =
c1*utmp(-2,j) +
c2*utmp(-1,j) +
c3*utmp(0,j)
2968 if (ut(1,j) > 0.)
then 2969 uc(1,j) = ut(1,j)*sin_sg(0,j,3)
2971 uc(1,j) = ut(1,j)*sin_sg(1,j,1)
2973 uc(2,j) =
c1*utmp(3,j) +
c2*utmp(2,j) +
c3*utmp(1,j)
2974 ut(0,j) = (uc(0,j) - v(0,j)*cosa_u(0,j))*rsin_u(0,j)
2975 ut(2,j) = (uc(2,j) - v(2,j)*cosa_u(2,j))*rsin_u(2,j)
2979 if( (ie+1)==npx .and. .not. nested )
then 2981 uc(npx-1,j) =
c1*utmp(npx-3,j)+
c2*utmp(npx-2,j)+
c3*utmp(npx-1,j)
2983 if (ut(npx,j) > 0.)
then 2984 uc(npx,j) = ut(npx,j)*sin_sg(npx-1,j,3)
2986 uc(npx,j) = ut(npx,j)*sin_sg(npx,j,1)
2988 uc(npx+1,j) =
c3*utmp(npx,j) +
c2*utmp(npx+1,j) +
c1*utmp(npx+2,j)
2989 ut(npx-1,j) = (uc(npx-1,j)-v(npx-1,j)*cosa_u(npx-1,j))*rsin_u(npx-1,j)
2990 ut(npx+1,j) = (uc(npx+1,j)-v(npx+1,j)*cosa_u(npx+1,j))*rsin_u(npx+1,j)
2999 if( gridstruct%sw_corner )
then 3001 vtmp(0,j) = -utmp(1-j,0)
3004 if( gridstruct%nw_corner )
then 3006 vtmp(0,npy+j) = utmp(j+1,npy)
3009 if( gridstruct%se_corner )
then 3011 vtmp(npx,j) = utmp(ie+j,0)
3014 if( gridstruct%ne_corner )
then 3016 vtmp(npx,npy+j) = -utmp(ie-j,npy)
3019 if( gridstruct%sw_corner )
then 3023 if( gridstruct%se_corner )
then 3024 va(npx, 0) = ua(npx-1,0)
3025 va(npx,-1) = ua(npx-2,0)
3027 if( gridstruct%ne_corner )
then 3028 va(npx,npy ) = -ua(npx-1,npy)
3029 va(npx,npy+1) = -ua(npx-2,npy)
3031 if( gridstruct%nw_corner )
then 3032 va(0,npy) = ua(1,npy)
3033 va(0,npy+1) = ua(2,npy)
3039 if ( j==1 .and. .not. nested )
then 3042 if (vt(i,j) > 0.)
then 3043 vc(i,j) = vt(i,j)*sin_sg(i,j-1,4)
3045 vc(i,j) = vt(i,j)*sin_sg(i,j,2)
3048 elseif ( j==0 .or. j==(npy-1) .and. .not. nested )
then 3050 vc(i,j) =
c1*vtmp(i,j-2) +
c2*vtmp(i,j-1) +
c3*vtmp(i,j)
3051 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3053 elseif ( j==2 .or. j==(npy+1) .and. .not. nested )
then 3055 vc(i,j) =
c1*vtmp(i,j+1) +
c2*vtmp(i,j) +
c3*vtmp(i,j-1)
3056 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3058 elseif ( j==npy .and. .not. nested )
then 3061 if (vt(i,j) > 0.)
then 3062 vc(i,j) = vt(i,j)*sin_sg(i,j-1,4)
3064 vc(i,j) = vt(i,j)*sin_sg(i,j,2)
3070 vc(i,j) =
a2*(vtmp(i,j-2)+vtmp(i,j+1)) +
a1*(vtmp(i,j-1)+vtmp(i,j))
3071 vt(i,j) = (vc(i,j) - u(i,j)*cosa_v(i,j))*rsin_v(i,j)
3079 vc(i,j) =
a2*(vtmp(i,j-2)+vtmp(i,j+1)) +
a1*(vtmp(i,j-1)+vtmp(i,j))
3090 real,
intent(in) :: ua(4)
3091 real,
intent(in) :: dxa(4)
3094 t1 = dxa(1) + dxa(2)
3095 t2 = dxa(3) + dxa(4)
3097 ((t2+dxa(3))*ua(3)-dxa(3)*ua(4)) / t2 )
3102 subroutine fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3103 type(fv_grid_bounds_type),
intent(IN) :: bd
3105 integer,
intent(in):: dir
3106 real,
intent(inout):: q1(bd%isd:bd%ied,bd%jsd:bd%jed)
3107 real,
intent(inout):: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
3108 real,
intent(inout):: q3(bd%isd:bd%ied,bd%jsd:bd%jed)
3109 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3110 integer,
intent(IN) :: npx, npy
3113 integer :: is, ie, js, je
3114 integer :: isd, ied, jsd, jed
3127 if ( sw_corner )
then 3128 q1(-1,0) = q1(0,2); q1(0,0) = q1(0,1); q1(0,-1) = q1(-1,1)
3129 q2(-1,0) = q2(0,2); q2(0,0) = q2(0,1); q2(0,-1) = q2(-1,1)
3130 q3(-1,0) = q3(0,2); q3(0,0) = q3(0,1); q3(0,-1) = q3(-1,1)
3132 if ( se_corner )
then 3133 q1(npx+1,0) = q1(npx,2); q1(npx,0) = q1(npx,1); q1(npx,-1) = q1(npx+1,1)
3134 q2(npx+1,0) = q2(npx,2); q2(npx,0) = q2(npx,1); q2(npx,-1) = q2(npx+1,1)
3135 q3(npx+1,0) = q3(npx,2); q3(npx,0) = q3(npx,1); q3(npx,-1) = q3(npx+1,1)
3137 if ( ne_corner )
then 3138 q1(npx,npy) = q1(npx,npy-1); q1(npx+1,npy) = q1(npx,npy-2); q1(npx,npy+1) = q1(npx+1,npy-1)
3139 q2(npx,npy) = q2(npx,npy-1); q2(npx+1,npy) = q2(npx,npy-2); q2(npx,npy+1) = q2(npx+1,npy-1)
3140 q3(npx,npy) = q3(npx,npy-1); q3(npx+1,npy) = q3(npx,npy-2); q3(npx,npy+1) = q3(npx+1,npy-1)
3142 if ( nw_corner )
then 3143 q1(0,npy) = q1(0,npy-1); q1(-1,npy) = q1(0,npy-2); q1(0,npy+1) = q1(-1,npy-1)
3144 q2(0,npy) = q2(0,npy-1); q2(-1,npy) = q2(0,npy-2); q2(0,npy+1) = q2(-1,npy-1)
3145 q3(0,npy) = q3(0,npy-1); q3(-1,npy) = q3(0,npy-2); q3(0,npy+1) = q3(-1,npy-1)
3149 if ( sw_corner )
then 3150 q1(0,0) = q1(1,0); q1(0,-1) = q1(2,0); q1(-1,0) = q1(1,-1)
3151 q2(0,0) = q2(1,0); q2(0,-1) = q2(2,0); q2(-1,0) = q2(1,-1)
3152 q3(0,0) = q3(1,0); q3(0,-1) = q3(2,0); q3(-1,0) = q3(1,-1)
3154 if ( se_corner )
then 3155 q1(npx,0) = q1(npx-1,0); q1(npx,-1) = q1(npx-2,0); q1(npx+1,0) = q1(npx-1,-1)
3156 q2(npx,0) = q2(npx-1,0); q2(npx,-1) = q2(npx-2,0); q2(npx+1,0) = q2(npx-1,-1)
3157 q3(npx,0) = q3(npx-1,0); q3(npx,-1) = q3(npx-2,0); q3(npx+1,0) = q3(npx-1,-1)
3159 if ( ne_corner )
then 3160 q1(npx,npy) = q1(npx-1,npy); q1(npx,npy+1) = q1(npx-2,npy); q1(npx+1,npy) = q1(npx-1,npy+1)
3161 q2(npx,npy) = q2(npx-1,npy); q2(npx,npy+1) = q2(npx-2,npy); q2(npx+1,npy) = q2(npx-1,npy+1)
3162 q3(npx,npy) = q3(npx-1,npy); q3(npx,npy+1) = q3(npx-2,npy); q3(npx+1,npy) = q3(npx-1,npy+1)
3164 if ( nw_corner )
then 3165 q1(0,npy) = q1(1,npy); q1(0,npy+1) = q1(2,npy); q1(-1,npy) = q1(1,npy+1)
3166 q2(0,npy) = q2(1,npy); q2(0,npy+1) = q2(2,npy); q2(-1,npy) = q2(1,npy+1)
3167 q3(0,npy) = q3(1,npy); q3(0,npy+1) = q3(2,npy); q3(-1,npy) = q3(1,npy+1)
3174 subroutine fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3175 type(fv_grid_bounds_type),
intent(IN) :: bd
3177 integer,
intent(in):: dir
3178 real,
intent(inout):: q1(bd%isd:bd%ied,bd%jsd:bd%jed)
3179 real,
intent(inout):: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
3180 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3181 integer,
intent(IN) :: npx, npy
3183 integer :: is, ie, js, je
3184 integer :: isd, ied, jsd, jed
3197 if ( sw_corner )
then 3198 q1(-1,0) = q1(0,2); q1(0,0) = q1(0,1)
3199 q2(-1,0) = q2(0,2); q2(0,0) = q2(0,1)
3201 if ( se_corner )
then 3202 q1(npx+1,0) = q1(npx,2); q1(npx,0) = q1(npx,1)
3203 q2(npx+1,0) = q2(npx,2); q2(npx,0) = q2(npx,1)
3205 if ( nw_corner )
then 3206 q1(0,npy) = q1(0,npy-1); q1(-1,npy) = q1(0,npy-2)
3207 q2(0,npy) = q2(0,npy-1); q2(-1,npy) = q2(0,npy-2)
3209 if ( ne_corner )
then 3210 q1(npx,npy) = q1(npx,npy-1); q1(npx+1,npy) = q1(npx,npy-2)
3211 q2(npx,npy) = q2(npx,npy-1); q2(npx+1,npy) = q2(npx,npy-2)
3215 if ( sw_corner )
then 3216 q1(0,0) = q1(1,0); q1(0,-1) = q1(2,0)
3217 q2(0,0) = q2(1,0); q2(0,-1) = q2(2,0)
3219 if ( se_corner )
then 3220 q1(npx,0) = q1(npx-1,0); q1(npx,-1) = q1(npx-2,0)
3221 q2(npx,0) = q2(npx-1,0); q2(npx,-1) = q2(npx-2,0)
3223 if ( nw_corner )
then 3224 q1(0,npy) = q1(1,npy); q1(0,npy+1) = q1(2,npy)
3225 q2(0,npy) = q2(1,npy); q2(0,npy+1) = q2(2,npy)
3227 if ( ne_corner )
then 3228 q1(npx,npy) = q1(npx-1,npy); q1(npx,npy+1) = q1(npx-2,npy)
3229 q2(npx,npy) = q2(npx-1,npy); q2(npx,npy+1) = q2(npx-2,npy)
3236 subroutine fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
3239 integer,
intent(in):: dir
3240 real,
intent(inout):: q(bd%isd:bd%ied,bd%jsd:bd%jed)
3241 logical,
intent(IN) :: sw_corner, se_corner, ne_corner, nw_corner
3242 integer,
intent(IN) :: npx, npy
3244 integer :: is, ie, js, je
3245 integer :: isd, ied, jsd, jed
3258 if ( sw_corner )
then 3262 if ( se_corner )
then 3263 q(npx+1,0) = q(npx,2)
3264 q(npx, 0) = q(npx,1)
3266 if ( nw_corner )
then 3267 q( 0,npy) = q(0,npy-1)
3268 q(-1,npy) = q(0,npy-2)
3270 if ( ne_corner )
then 3271 q(npx, npy) = q(npx,npy-1)
3272 q(npx+1,npy) = q(npx,npy-2)
3276 if ( sw_corner )
then 3280 if ( se_corner )
then 3281 q(npx, 0) = q(npx-1,0)
3282 q(npx,-1) = q(npx-2,0)
3284 if ( nw_corner )
then 3285 q(0,npy ) = q(1,npy)
3286 q(0,npy+1) = q(2,npy)
3288 if ( ne_corner )
then 3289 q(npx,npy ) = q(npx-1,npy)
3290 q(npx,npy+1) = q(npx-2,npy)
subroutine fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
real(kind=kind_real), parameter f0
Coriolis parameter at southern boundary.
subroutine, public pert_ppm(im, a0, al, ar, iv)
subroutine, public del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
subroutine xtp_u(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, nested)
subroutine smag_corner(dt, u, v, ua, va, smag_c, bd, npx, npy, gridstruct, ng)
subroutine fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
real, parameter near_zero
integer, parameter, public ng
subroutine, public divergence_corner(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
subroutine, public fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, npx, npy, nested, grid_type)
real, parameter big_number
subroutine, public divergence_corner_nest(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
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)
subroutine, public copy_corners(q, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
integer, public test_case
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, dpx, 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)
subroutine ytp_v(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, nested)
real function edge_interpolate4(ua, dxa)
subroutine, public fv_tp_2d(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, mfx, mfy, mass, nord, damp_c)
Derived type containing the data.
real(kind=kind_real), parameter u2