31 real,
parameter::
r3 = 1./3.
35 real,
parameter::
a1 = 0.5625
36 real,
parameter::
a2 = -0.0625
40 real,
parameter::
b1 = 7./12.
41 real,
parameter::
b2 = -1./12.
48 SUBROUTINE a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, &
51 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
53 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
55 REAL,
INTENT(INOUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
57 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
59 REAL,
PARAMETER :: c1=2./3.
60 REAL,
PARAMETER :: c2=-(1./6.)
64 REAL :: qx(is:ie+1, js-ng:je+ng)
65 REAL :: qy(is-ng:ie+ng, js:je+1)
66 REAL :: qxx(is-ng:ie+ng, js-ng:je+ng)
67 REAL :: qyy(is-ng:ie+ng, js-ng:je+ng)
70 REAL :: q1(is-1:ie+1), q2(js-1:je+1)
71 INTEGER :: i, j, is1, js1, is2, js2, ie1, je1
72 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
73 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
74 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
112 edge_w => gridstruct%edge_w
113 edge_e => gridstruct%edge_e
114 edge_s => gridstruct%edge_s
115 edge_n => gridstruct%edge_n
116 grid => gridstruct%grid
117 agrid => gridstruct%agrid
118 dxa => gridstruct%dxa
119 dya => gridstruct%dya
120 IF (gridstruct%grid_type .LT. 3)
THEN 121 IF (1 .LT. is - 1)
THEN 126 IF (1 .LT. js - 1)
THEN 141 IF (npx - 1 .GT. ie + 1)
THEN 146 IF (npy - 1 .GT. je + 1)
THEN 153 IF (gridstruct%nested)
THEN 156 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
161 IF (gridstruct%sw_corner)
THEN 162 p0(1:2) = grid(1, 1, 1:2)
163 result1 =
extrap_corner(p0, agrid(1, 1, 1:2), agrid(2, 2, 1:2)&
164 & , qin(1, 1), qin(2, 2))
165 result2 =
extrap_corner(p0, agrid(0, 1, 1:2), agrid(-1, 2, 1:2&
166 & ), qin(0, 1), qin(-1, 2))
167 result3 =
extrap_corner(p0, agrid(1, 0, 1:2), agrid(2, -1, 1:2&
168 & ), qin(1, 0), qin(2, -1))
169 qout(1, 1) = (result1+result2+result3)*
r3 171 IF (gridstruct%se_corner)
THEN 172 p0(1:2) = grid(npx, 1, 1:2)
173 result1 =
extrap_corner(p0, agrid(npx-1, 1, 1:2), agrid(npx-2&
174 & , 2, 1:2), qin(npx-1, 1), qin(npx-2, 2))
175 result2 =
extrap_corner(p0, agrid(npx-1, 0, 1:2), agrid(npx-2&
176 & , -1, 1:2), qin(npx-1, 0), qin(npx-2, -1))
177 result3 =
extrap_corner(p0, agrid(npx, 1, 1:2), agrid(npx+1, 2&
178 & , 1:2), qin(npx, 1), qin(npx+1, 2))
179 qout(npx, 1) = (result1+result2+result3)*
r3 181 IF (gridstruct%ne_corner)
THEN 182 p0(1:2) = grid(npx, npy, 1:2)
183 result1 =
extrap_corner(p0, agrid(npx-1, npy-1, 1:2), agrid(&
184 & npx-2, npy-2, 1:2), qin(npx-1, npy-1), qin(npx-2, npy-2))
185 result2 =
extrap_corner(p0, agrid(npx, npy-1, 1:2), agrid(npx+&
186 & 1, npy-2, 1:2), qin(npx, npy-1), qin(npx+1, npy-2))
187 result3 =
extrap_corner(p0, agrid(npx-1, npy, 1:2), agrid(npx-&
188 & 2, npy+1, 1:2), qin(npx-1, npy), qin(npx-2, npy+1))
189 qout(npx, npy) = (result1+result2+result3)*
r3 191 IF (gridstruct%nw_corner)
THEN 192 p0(1:2) = grid(1, npy, 1:2)
193 result1 =
extrap_corner(p0, agrid(1, npy-1, 1:2), agrid(2, npy&
194 & -2, 1:2), qin(1, npy-1), qin(2, npy-2))
195 result2 =
extrap_corner(p0, agrid(0, npy-1, 1:2), agrid(-1, &
196 & npy-2, 1:2), qin(0, npy-1), qin(-1, npy-2))
197 result3 =
extrap_corner(p0, agrid(1, npy, 1:2), agrid(2, npy+1&
198 & , 1:2), qin(1, npy), qin(2, npy+1))
199 qout(1, npy) = (result1+result2+result3)*
r3 201 IF (1 .LT. js - 2)
THEN 206 IF (npy - 1 .GT. je + 2)
THEN 220 IF (npx - 2 .GT. ie + 1)
THEN 226 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
233 q2(j) = (qin(0, j)*dxa(1, j)+qin(1, j)*dxa(0, j))/(dxa(0, j)&
237 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
239 IF (1 .LT. js - 2)
THEN 244 IF (npy - 1 .GT. je + 2)
THEN 251 g_in = dxa(2, j)/dxa(1, j)
252 g_ou = dxa(-1, j)/dxa(0, j)
253 qx(1, j) = 0.5*(((2.+g_in)*qin(1, j)-qin(2, j))/(1.+g_in)+((&
254 & 2.+g_ou)*qin(0, j)-qin(-1, j))/(1.+g_ou))
255 qx(2, j) = (3.*(g_in*qin(1, j)+qin(2, j))-(g_in*qx(1, j)+qx(&
256 & 3, j)))/(2.+2.*g_in)
260 IF (ie + 1 .EQ. npx)
THEN 262 q2(j) = (qin(npx-1, j)*dxa(npx, j)+qin(npx, j)*dxa(npx-1, j)&
263 & )/(dxa(npx-1, j)+dxa(npx, j))
266 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
268 IF (1 .LT. js - 2)
THEN 273 IF (npy - 1 .GT. je + 2)
THEN 280 g_in = dxa(npx-2, j)/dxa(npx-1, j)
281 g_ou = dxa(npx+1, j)/dxa(npx, j)
282 qx(npx, j) = 0.5*(((2.+g_in)*qin(npx-1, j)-qin(npx-2, j))/(&
283 & 1.+g_in)+((2.+g_ou)*qin(npx, j)-qin(npx+1, j))/(1.+g_ou))
284 qx(npx-1, j) = (3.*(qin(npx-2, j)+g_in*qin(npx-1, j))-(g_in*&
285 & qx(npx, j)+qx(npx-2, j)))/(2.+2.*g_in)
292 IF (gridstruct%nested)
THEN 295 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
305 IF (npy - 2 .GT. je + 1)
THEN 311 IF (1 .LT. is - 2)
THEN 316 IF (npx - 1 .GT. ie + 2)
THEN 322 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
329 q1(i) = (qin(i, 0)*dya(i, 1)+qin(i, 1)*dya(i, 0))/(dya(i, 0)&
333 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
335 IF (1 .LT. is - 2)
THEN 340 IF (npx - 1 .GT. ie + 2)
THEN 347 g_in = dya(i, 2)/dya(i, 1)
348 g_ou = dya(i, -1)/dya(i, 0)
349 qy(i, 1) = 0.5*(((2.+g_in)*qin(i, 1)-qin(i, 2))/(1.+g_in)+((&
350 & 2.+g_ou)*qin(i, 0)-qin(i, -1))/(1.+g_ou))
351 qy(i, 2) = (3.*(g_in*qin(i, 1)+qin(i, 2))-(g_in*qy(i, 1)+qy(&
352 & i, 3)))/(2.+2.*g_in)
356 IF (je + 1 .EQ. npy)
THEN 358 q1(i) = (qin(i, npy-1)*dya(i, npy)+qin(i, npy)*dya(i, npy-1)&
359 & )/(dya(i, npy-1)+dya(i, npy))
362 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
364 IF (1 .LT. is - 2)
THEN 369 IF (npx - 1 .GT. ie + 2)
THEN 376 g_in = dya(i, npy-2)/dya(i, npy-1)
377 g_ou = dya(i, npy+1)/dya(i, npy)
378 qy(i, npy) = 0.5*(((2.+g_in)*qin(i, npy-1)-qin(i, npy-2))/(&
379 & 1.+g_in)+((2.+g_ou)*qin(i, npy)-qin(i, npy+1))/(1.+g_ou))
380 qy(i, npy-1) = (3.*(qin(i, npy-2)+g_in*qin(i, npy-1))-(g_in*&
381 & qy(i, npy)+qy(i, npy-2)))/(2.+2.*g_in)
386 IF (gridstruct%nested)
THEN 389 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
395 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
400 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
409 IF (npy - 2 .GT. je + 1)
THEN 420 IF (npx - 1 .GT. ie + 1)
THEN 426 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
436 IF (npx - 1 .GT. ie + 1)
THEN 442 qxx(i, 2) = c1*(qx(i, 1)+qx(i, 2)) + c2*(qout(i, 1)+qxx(i, 3&
446 IF (je + 1 .EQ. npy)
THEN 452 IF (npx - 1 .GT. ie + 1)
THEN 458 qxx(i, npy-1) = c1*(qx(i, npy-2)+qx(i, npy-1)) + c2*(qout(i&
459 & , npy)+qxx(i, npy-2))
467 IF (npy - 1 .GT. je + 1)
THEN 478 IF (npx - 2 .GT. ie + 1)
THEN 484 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
487 IF (is .EQ. 1) qyy(2, j) = c1*(qy(1, j)+qy(2, j)) + c2*(qout(1&
489 IF (ie + 1 .EQ. npx) qyy(npx-1, j) = c1*(qy(npx-2, j)+qy(npx-1&
490 & , j)) + c2*(qout(npx, j)+qyy(npx-2, j))
496 IF (npx - 1 .GT. ie + 1)
THEN 503 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
515 qx(i, j) =
b1*(qin(i-1, j)+qin(i, j)) +
b2*(qin(i-2, j)+qin(i+&
522 qy(i, j) =
b1*(qin(i, j-1)+qin(i, j)) +
b2*(qin(i, j-2)+qin(i&
528 qout(i, j) = 0.5*(
a1*(qx(i, j-1)+qx(i, j)+qy(i-1, j)+qy(i, j))&
529 & +
a2*(qx(i, j-2)+qx(i, j+1)+qy(i-2, j)+qy(i+1, j)))
533 IF (
PRESENT(replace))
THEN 537 qin(i, j) = qout(i, j)
546 SUBROUTINE a2b_ord4_tlm(qin, qin_tl, qout, qout_tl, gridstruct, npx&
547 & , npy, is, ie, js, je, ng, replace)
549 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
551 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
552 REAL,
INTENT(INOUT) :: qin_tl(is-ng:ie+ng, js-ng:je+ng)
554 REAL,
INTENT(INOUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
555 REAL,
INTENT(INOUT) :: qout_tl(is-ng:ie+ng, js-ng:je+ng)
557 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
559 REAL,
PARAMETER :: c1=2./3.
560 REAL,
PARAMETER :: c2=-(1./6.)
564 REAL :: qx(is:ie+1, js-ng:je+ng)
565 REAL :: qx_tl(is:ie+1, js-ng:je+ng)
566 REAL :: qy(is-ng:ie+ng, js:je+1)
567 REAL :: qy_tl(is-ng:ie+ng, js:je+1)
568 REAL :: qxx(is-ng:ie+ng, js-ng:je+ng)
569 REAL :: qxx_tl(is-ng:ie+ng, js-ng:je+ng)
570 REAL :: qyy(is-ng:ie+ng, js-ng:je+ng)
571 REAL :: qyy_tl(is-ng:ie+ng, js-ng:je+ng)
574 REAL :: q1(is-1:ie+1), q2(js-1:je+1)
575 REAL :: q1_tl(is-1:ie+1), q2_tl(js-1:je+1)
576 INTEGER :: i, j, is1, js1, is2, js2, ie1, je1
577 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
578 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
579 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
620 edge_w => gridstruct%edge_w
621 edge_e => gridstruct%edge_e
622 edge_s => gridstruct%edge_s
623 edge_n => gridstruct%edge_n
624 grid => gridstruct%grid
625 agrid => gridstruct%agrid
626 dxa => gridstruct%dxa
627 dya => gridstruct%dya
628 IF (gridstruct%grid_type .LT. 3)
THEN 629 IF (1 .LT. is - 1)
THEN 634 IF (1 .LT. js - 1)
THEN 649 IF (npx - 1 .GT. ie + 1)
THEN 654 IF (npy - 1 .GT. je + 1)
THEN 661 IF (gridstruct%nested)
THEN 665 qx_tl(i, j) =
b2*(qin_tl(i-2, j)+qin_tl(i+1, j)) +
b1*(&
666 & qin_tl(i-1, j)+qin_tl(i, j))
667 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
672 IF (gridstruct%sw_corner)
THEN 673 p0(1:2) = grid(1, 1, 1:2)
675 & 2, 2, 1:2), qin(1, 1), qin_tl(1, 1), qin(2, 2), qin_tl(2, 2)&
678 & -1, 2, 1:2), qin(0, 1), qin_tl(0, 1), qin(-1, 2), qin_tl(-1&
681 & 2, -1, 1:2), qin(1, 0), qin_tl(1, 0), qin(2, -1), qin_tl(2, &
683 qout_tl(1, 1) =
r3*(result1_tl+result2_tl+result3_tl)
684 qout(1, 1) = (result1+result2+result3)*
r3 686 IF (gridstruct%se_corner)
THEN 687 p0(1:2) = grid(npx, 1, 1:2)
689 & agrid(npx-2, 2, 1:2), qin(npx-1, 1), qin_tl(npx-1, 1), qin(&
690 & npx-2, 2), qin_tl(npx-2, 2), result1)
692 & agrid(npx-2, -1, 1:2), qin(npx-1, 0), qin_tl(npx-1, 0), qin(&
693 & npx-2, -1), qin_tl(npx-2, -1), result2)
695 & agrid(npx+1, 2, 1:2), qin(npx, 1), qin_tl(npx, 1), qin(npx+1&
696 & , 2), qin_tl(npx+1, 2), result3)
697 qout_tl(npx, 1) =
r3*(result1_tl+result2_tl+result3_tl)
698 qout(npx, 1) = (result1+result2+result3)*
r3 700 IF (gridstruct%ne_corner)
THEN 701 p0(1:2) = grid(npx, npy, 1:2)
703 & , agrid(npx-2, npy-2, 1:2), qin(npx-1, npy-1), qin_tl(npx-1&
704 & , npy-1), qin(npx-2, npy-2), qin_tl(npx-2, npy-2), result1)
706 & agrid(npx+1, npy-2, 1:2), qin(npx, npy-1), qin_tl(npx, npy-1&
707 & ), qin(npx+1, npy-2), qin_tl(npx+1, npy-2), result2)
709 & agrid(npx-2, npy+1, 1:2), qin(npx-1, npy), qin_tl(npx-1, npy&
710 & ), qin(npx-2, npy+1), qin_tl(npx-2, npy+1), result3)
711 qout_tl(npx, npy) =
r3*(result1_tl+result2_tl+result3_tl)
712 qout(npx, npy) = (result1+result2+result3)*
r3 714 IF (gridstruct%nw_corner)
THEN 715 p0(1:2) = grid(1, npy, 1:2)
717 & agrid(2, npy-2, 1:2), qin(1, npy-1), qin_tl(1, npy-1), qin(2&
718 & , npy-2), qin_tl(2, npy-2), result1)
720 & agrid(-1, npy-2, 1:2), qin(0, npy-1), qin_tl(0, npy-1), qin(&
721 & -1, npy-2), qin_tl(-1, npy-2), result2)
723 & agrid(2, npy+1, 1:2), qin(1, npy), qin_tl(1, npy), qin(2, &
724 & npy+1), qin_tl(2, npy+1), result3)
725 qout_tl(1, npy) =
r3*(result1_tl+result2_tl+result3_tl)
726 qout(1, npy) = (result1+result2+result3)*
r3 728 IF (1 .LT. js - 2)
THEN 733 IF (npy - 1 .GT. je + 2)
THEN 749 IF (npx - 2 .GT. ie + 1)
THEN 755 qx_tl(i, j) =
b2*(qin_tl(i-2, j)+qin_tl(i+1, j)) +
b1*(&
756 & qin_tl(i-1, j)+qin_tl(i, j))
757 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
765 q2_tl(j) = (dxa(1, j)*qin_tl(0, j)+dxa(0, j)*qin_tl(1, j))/(&
766 & dxa(0, j)+dxa(1, j))
767 q2(j) = (qin(0, j)*dxa(1, j)+qin(1, j)*dxa(0, j))/(dxa(0, j)&
771 qout_tl(1, j) = edge_w(j)*q2_tl(j-1) + (1.-edge_w(j))*q2_tl(&
773 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
775 IF (1 .LT. js - 2)
THEN 780 IF (npy - 1 .GT. je + 2)
THEN 787 g_in = dxa(2, j)/dxa(1, j)
788 g_ou = dxa(-1, j)/dxa(0, j)
789 qx_tl(1, j) = 0.5*(((2.+g_in)*qin_tl(1, j)-qin_tl(2, j))/(1.&
790 & +g_in)+((2.+g_ou)*qin_tl(0, j)-qin_tl(-1, j))/(1.+g_ou))
791 qx(1, j) = 0.5*(((2.+g_in)*qin(1, j)-qin(2, j))/(1.+g_in)+((&
792 & 2.+g_ou)*qin(0, j)-qin(-1, j))/(1.+g_ou))
793 qx_tl(2, j) = (3.*(g_in*qin_tl(1, j)+qin_tl(2, j))-g_in*&
794 & qx_tl(1, j)-qx_tl(3, j))/(2.+2.*g_in)
795 qx(2, j) = (3.*(g_in*qin(1, j)+qin(2, j))-(g_in*qx(1, j)+qx(&
796 & 3, j)))/(2.+2.*g_in)
802 IF (ie + 1 .EQ. npx)
THEN 804 q2_tl(j) = (dxa(npx, j)*qin_tl(npx-1, j)+dxa(npx-1, j)*&
805 & qin_tl(npx, j))/(dxa(npx-1, j)+dxa(npx, j))
806 q2(j) = (qin(npx-1, j)*dxa(npx, j)+qin(npx, j)*dxa(npx-1, j)&
807 & )/(dxa(npx-1, j)+dxa(npx, j))
810 qout_tl(npx, j) = edge_e(j)*q2_tl(j-1) + (1.-edge_e(j))*&
812 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
814 IF (1 .LT. js - 2)
THEN 819 IF (npy - 1 .GT. je + 2)
THEN 826 g_in = dxa(npx-2, j)/dxa(npx-1, j)
827 g_ou = dxa(npx+1, j)/dxa(npx, j)
828 qx_tl(npx, j) = 0.5*(((2.+g_in)*qin_tl(npx-1, j)-qin_tl(npx-&
829 & 2, j))/(1.+g_in)+((2.+g_ou)*qin_tl(npx, j)-qin_tl(npx+1, j&
831 qx(npx, j) = 0.5*(((2.+g_in)*qin(npx-1, j)-qin(npx-2, j))/(&
832 & 1.+g_in)+((2.+g_ou)*qin(npx, j)-qin(npx+1, j))/(1.+g_ou))
833 qx_tl(npx-1, j) = (3.*(qin_tl(npx-2, j)+g_in*qin_tl(npx-1, j&
834 & ))-g_in*qx_tl(npx, j)-qx_tl(npx-2, j))/(2.+2.*g_in)
835 qx(npx-1, j) = (3.*(qin(npx-2, j)+g_in*qin(npx-1, j))-(g_in*&
836 & qx(npx, j)+qx(npx-2, j)))/(2.+2.*g_in)
843 IF (gridstruct%nested)
THEN 847 qy_tl(i, j) =
b2*(qin_tl(i, j-2)+qin_tl(i, j+1)) +
b1*(&
848 & qin_tl(i, j-1)+qin_tl(i, j))
849 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
859 IF (npy - 2 .GT. je + 1)
THEN 867 IF (1 .LT. is - 2)
THEN 872 IF (npx - 1 .GT. ie + 2)
THEN 878 qy_tl(i, j) =
b2*(qin_tl(i, j-2)+qin_tl(i, j+1)) +
b1*(&
879 & qin_tl(i, j-1)+qin_tl(i, j))
880 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
888 q1_tl(i) = (dya(i, 1)*qin_tl(i, 0)+dya(i, 0)*qin_tl(i, 1))/(&
889 & dya(i, 0)+dya(i, 1))
890 q1(i) = (qin(i, 0)*dya(i, 1)+qin(i, 1)*dya(i, 0))/(dya(i, 0)&
894 qout_tl(i, 1) = edge_s(i)*q1_tl(i-1) + (1.-edge_s(i))*q1_tl(&
896 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
898 IF (1 .LT. is - 2)
THEN 903 IF (npx - 1 .GT. ie + 2)
THEN 910 g_in = dya(i, 2)/dya(i, 1)
911 g_ou = dya(i, -1)/dya(i, 0)
912 qy_tl(i, 1) = 0.5*(((2.+g_in)*qin_tl(i, 1)-qin_tl(i, 2))/(1.&
913 & +g_in)+((2.+g_ou)*qin_tl(i, 0)-qin_tl(i, -1))/(1.+g_ou))
914 qy(i, 1) = 0.5*(((2.+g_in)*qin(i, 1)-qin(i, 2))/(1.+g_in)+((&
915 & 2.+g_ou)*qin(i, 0)-qin(i, -1))/(1.+g_ou))
916 qy_tl(i, 2) = (3.*(g_in*qin_tl(i, 1)+qin_tl(i, 2))-g_in*&
917 & qy_tl(i, 1)-qy_tl(i, 3))/(2.+2.*g_in)
918 qy(i, 2) = (3.*(g_in*qin(i, 1)+qin(i, 2))-(g_in*qy(i, 1)+qy(&
919 & i, 3)))/(2.+2.*g_in)
925 IF (je + 1 .EQ. npy)
THEN 927 q1_tl(i) = (dya(i, npy)*qin_tl(i, npy-1)+dya(i, npy-1)*&
928 & qin_tl(i, npy))/(dya(i, npy-1)+dya(i, npy))
929 q1(i) = (qin(i, npy-1)*dya(i, npy)+qin(i, npy)*dya(i, npy-1)&
930 & )/(dya(i, npy-1)+dya(i, npy))
933 qout_tl(i, npy) = edge_n(i)*q1_tl(i-1) + (1.-edge_n(i))*&
935 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
937 IF (1 .LT. is - 2)
THEN 942 IF (npx - 1 .GT. ie + 2)
THEN 949 g_in = dya(i, npy-2)/dya(i, npy-1)
950 g_ou = dya(i, npy+1)/dya(i, npy)
951 qy_tl(i, npy) = 0.5*(((2.+g_in)*qin_tl(i, npy-1)-qin_tl(i, &
952 & npy-2))/(1.+g_in)+((2.+g_ou)*qin_tl(i, npy)-qin_tl(i, npy+&
954 qy(i, npy) = 0.5*(((2.+g_in)*qin(i, npy-1)-qin(i, npy-2))/(&
955 & 1.+g_in)+((2.+g_ou)*qin(i, npy)-qin(i, npy+1))/(1.+g_ou))
956 qy_tl(i, npy-1) = (3.*(qin_tl(i, npy-2)+g_in*qin_tl(i, npy-1&
957 & ))-g_in*qy_tl(i, npy)-qy_tl(i, npy-2))/(2.+2.*g_in)
958 qy(i, npy-1) = (3.*(qin(i, npy-2)+g_in*qin(i, npy-1))-(g_in*&
959 & qy(i, npy)+qy(i, npy-2)))/(2.+2.*g_in)
964 IF (gridstruct%nested)
THEN 968 qxx_tl(i, j) =
a2*(qx_tl(i, j-2)+qx_tl(i, j+1)) +
a1*(qx_tl(&
969 & i, j-1)+qx_tl(i, j))
970 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
977 qyy_tl(i, j) =
a2*(qy_tl(i-2, j)+qy_tl(i+1, j)) +
a1*(qy_tl(&
978 & i-1, j)+qy_tl(i, j))
979 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
984 qout_tl(i, j) = 0.5*(qxx_tl(i, j)+qyy_tl(i, j))
985 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
994 IF (npy - 2 .GT. je + 1)
THEN 1007 IF (npx - 1 .GT. ie + 1)
THEN 1013 qxx_tl(i, j) =
a2*(qx_tl(i, j-2)+qx_tl(i, j+1)) +
a1*(qx_tl(&
1014 & i, j-1)+qx_tl(i, j))
1015 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
1025 IF (npx - 1 .GT. ie + 1)
THEN 1031 qxx_tl(i, 2) = c1*(qx_tl(i, 1)+qx_tl(i, 2)) + c2*(qout_tl(i&
1032 & , 1)+qxx_tl(i, 3))
1033 qxx(i, 2) = c1*(qx(i, 1)+qx(i, 2)) + c2*(qout(i, 1)+qxx(i, 3&
1037 IF (je + 1 .EQ. npy)
THEN 1043 IF (npx - 1 .GT. ie + 1)
THEN 1049 qxx_tl(i, npy-1) = c1*(qx_tl(i, npy-2)+qx_tl(i, npy-1)) + c2&
1050 & *(qout_tl(i, npy)+qxx_tl(i, npy-2))
1051 qxx(i, npy-1) = c1*(qx(i, npy-2)+qx(i, npy-1)) + c2*(qout(i&
1052 & , npy)+qxx(i, npy-2))
1060 IF (npy - 1 .GT. je + 1)
THEN 1073 IF (npx - 2 .GT. ie + 1)
THEN 1079 qyy_tl(i, j) =
a2*(qy_tl(i-2, j)+qy_tl(i+1, j)) +
a1*(qy_tl(&
1080 & i-1, j)+qy_tl(i, j))
1081 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
1085 qyy_tl(2, j) = c1*(qy_tl(1, j)+qy_tl(2, j)) + c2*(qout_tl(1&
1086 & , j)+qyy_tl(3, j))
1087 qyy(2, j) = c1*(qy(1, j)+qy(2, j)) + c2*(qout(1, j)+qyy(3, j&
1090 IF (ie + 1 .EQ. npx)
THEN 1091 qyy_tl(npx-1, j) = c1*(qy_tl(npx-2, j)+qy_tl(npx-1, j)) + c2&
1092 & *(qout_tl(npx, j)+qyy_tl(npx-2, j))
1093 qyy(npx-1, j) = c1*(qy(npx-2, j)+qy(npx-1, j)) + c2*(qout(&
1094 & npx, j)+qyy(npx-2, j))
1101 IF (npx - 1 .GT. ie + 1)
THEN 1108 qout_tl(i, j) = 0.5*(qxx_tl(i, j)+qyy_tl(i, j))
1109 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
1122 qx_tl(i, j) =
b1*(qin_tl(i-1, j)+qin_tl(i, j)) +
b2*(qin_tl(i-&
1123 & 2, j)+qin_tl(i+1, j))
1124 qx(i, j) =
b1*(qin(i-1, j)+qin(i, j)) +
b2*(qin(i-2, j)+qin(i+&
1132 qy_tl(i, j) =
b1*(qin_tl(i, j-1)+qin_tl(i, j)) +
b2*(qin_tl(i&
1133 & , j-2)+qin_tl(i, j+1))
1134 qy(i, j) =
b1*(qin(i, j-1)+qin(i, j)) +
b2*(qin(i, j-2)+qin(i&
1140 qout_tl(i, j) = 0.5*(
a1*(qx_tl(i, j-1)+qx_tl(i, j)+qy_tl(i-1, &
1141 & j)+qy_tl(i, j))+
a2*(qx_tl(i, j-2)+qx_tl(i, j+1)+qy_tl(i-2, j&
1143 qout(i, j) = 0.5*(
a1*(qx(i, j-1)+qx(i, j)+qy(i-1, j)+qy(i, j))&
1144 & +
a2*(qx(i, j-2)+qx(i, j+1)+qy(i-2, j)+qy(i+1, j)))
1148 IF (
PRESENT(replace))
THEN 1152 qin_tl(i, j) = qout_tl(i, j)
1153 qin(i, j) = qout(i, j)
1162 SUBROUTINE a2b_ord2_tlm(qin, qin_tl, qout, qout_tl, gridstruct, npx, &
1163 & npy, is, ie, js, je, ng, replace)
1165 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
1167 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
1168 REAL,
INTENT(INOUT) :: qin_tl(is-ng:ie+ng, js-ng:je+ng)
1170 REAL,
INTENT(OUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
1171 REAL,
INTENT(OUT) :: qout_tl(is-ng:ie+ng, js-ng:je+ng)
1173 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
1175 REAL :: q1(npx), q2(npy)
1176 REAL :: q1_tl(npx), q2_tl(npy)
1178 INTEGER :: is1, js1, is2, js2, ie1, je1
1179 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
1180 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
1181 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
1186 edge_w => gridstruct%edge_w
1187 edge_e => gridstruct%edge_e
1188 edge_s => gridstruct%edge_s
1189 edge_n => gridstruct%edge_n
1190 grid => gridstruct%grid
1191 agrid => gridstruct%agrid
1192 dxa => gridstruct%dxa
1193 dya => gridstruct%dya
1194 IF (gridstruct%grid_type .LT. 3)
THEN 1195 IF (gridstruct%nested)
THEN 1198 qout_tl(i, j) = 0.25*(qin_tl(i-1, j-1)+qin_tl(i, j-1)+qin_tl&
1199 & (i-1, j)+qin_tl(i, j))
1200 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
1205 IF (1 .LT. is - 1)
THEN 1210 IF (1 .LT. js - 1)
THEN 1225 IF (npx - 1 .GT. ie + 1)
THEN 1230 IF (npy - 1 .GT. je + 1)
THEN 1237 qout_tl(i, j) = 0.25*(qin_tl(i-1, j-1)+qin_tl(i, j-1)+qin_tl&
1238 & (i-1, j)+qin_tl(i, j))
1239 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
1244 IF (gridstruct%sw_corner)
THEN 1245 qout_tl(1, 1) =
r3*(qin_tl(1, 1)+qin_tl(1, 0)+qin_tl(0, 1))
1246 qout(1, 1) =
r3*(qin(1, 1)+qin(1, 0)+qin(0, 1))
1248 IF (gridstruct%se_corner)
THEN 1249 qout_tl(npx, 1) =
r3*(qin_tl(npx-1, 1)+qin_tl(npx-1, 0)+qin_tl&
1251 qout(npx, 1) =
r3*(qin(npx-1, 1)+qin(npx-1, 0)+qin(npx, 1))
1253 IF (gridstruct%ne_corner)
THEN 1254 qout_tl(npx, npy) =
r3*(qin_tl(npx-1, npy-1)+qin_tl(npx, npy-1&
1255 & )+qin_tl(npx-1, npy))
1256 qout(npx, npy) =
r3*(qin(npx-1, npy-1)+qin(npx, npy-1)+qin(npx&
1259 IF (gridstruct%nw_corner)
THEN 1260 qout_tl(1, npy) =
r3*(qin_tl(1, npy-1)+qin_tl(0, npy-1)+qin_tl&
1262 qout(1, npy) =
r3*(qin(1, npy-1)+qin(0, npy-1)+qin(1, npy))
1268 q2_tl(j) = 0.5*(qin_tl(0, j)+qin_tl(1, j))
1269 q2(j) = 0.5*(qin(0, j)+qin(1, j))
1272 qout_tl(1, j) = edge_w(j)*q2_tl(j-1) + (1.-edge_w(j))*q2_tl(&
1274 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
1280 IF (ie + 1 .EQ. npx)
THEN 1282 q2_tl(j) = 0.5*(qin_tl(npx-1, j)+qin_tl(npx, j))
1283 q2(j) = 0.5*(qin(npx-1, j)+qin(npx, j))
1286 qout_tl(npx, j) = edge_e(j)*q2_tl(j-1) + (1.-edge_e(j))*&
1288 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
1295 q1_tl(i) = 0.5*(qin_tl(i, 0)+qin_tl(i, 1))
1296 q1(i) = 0.5*(qin(i, 0)+qin(i, 1))
1299 qout_tl(i, 1) = edge_s(i)*q1_tl(i-1) + (1.-edge_s(i))*q1_tl(&
1301 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
1307 IF (je + 1 .EQ. npy)
THEN 1309 q1_tl(i) = 0.5*(qin_tl(i, npy-1)+qin_tl(i, npy))
1310 q1(i) = 0.5*(qin(i, npy-1)+qin(i, npy))
1313 qout_tl(i, npy) = edge_n(i)*q1_tl(i-1) + (1.-edge_n(i))*&
1315 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
1322 qout_tl(i, j) = 0.25*(qin_tl(i-1, j-1)+qin_tl(i, j-1)+qin_tl(i&
1323 & -1, j)+qin_tl(i, j))
1324 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin(i&
1329 IF (
PRESENT(replace))
THEN 1333 qin_tl(i, j) = qout_tl(i, j)
1334 qin(i, j) = qout(i, j)
1340 SUBROUTINE a2b_ord2(qin, qout, gridstruct, npx, npy, is, ie, js, je, &
1343 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
1345 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
1347 REAL,
INTENT(OUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
1349 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
1351 REAL :: q1(npx), q2(npy)
1353 INTEGER :: is1, js1, is2, js2, ie1, je1
1354 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
1355 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
1356 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
1361 edge_w => gridstruct%edge_w
1362 edge_e => gridstruct%edge_e
1363 edge_s => gridstruct%edge_s
1364 edge_n => gridstruct%edge_n
1365 grid => gridstruct%grid
1366 agrid => gridstruct%agrid
1367 dxa => gridstruct%dxa
1368 dya => gridstruct%dya
1369 IF (gridstruct%grid_type .LT. 3)
THEN 1370 IF (gridstruct%nested)
THEN 1373 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
1378 IF (1 .LT. is - 1)
THEN 1383 IF (1 .LT. js - 1)
THEN 1398 IF (npx - 1 .GT. ie + 1)
THEN 1403 IF (npy - 1 .GT. je + 1)
THEN 1410 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
1415 IF (gridstruct%sw_corner) qout(1, 1) =
r3*(qin(1, 1)+qin(1, 0)+&
1417 IF (gridstruct%se_corner) qout(npx, 1) =
r3*(qin(npx-1, 1)+qin(&
1418 & npx-1, 0)+qin(npx, 1))
1419 IF (gridstruct%ne_corner) qout(npx, npy) =
r3*(qin(npx-1, npy-1)&
1420 & +qin(npx, npy-1)+qin(npx-1, npy))
1421 IF (gridstruct%nw_corner) qout(1, npy) =
r3*(qin(1, npy-1)+qin(0&
1422 & , npy-1)+qin(1, npy))
1426 q2(j) = 0.5*(qin(0, j)+qin(1, j))
1429 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
1433 IF (ie + 1 .EQ. npx)
THEN 1435 q2(j) = 0.5*(qin(npx-1, j)+qin(npx, j))
1438 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
1444 q1(i) = 0.5*(qin(i, 0)+qin(i, 1))
1447 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
1451 IF (je + 1 .EQ. npy)
THEN 1453 q1(i) = 0.5*(qin(i, npy-1)+qin(i, npy))
1456 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
1463 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin(i&
1468 IF (
PRESENT(replace))
THEN 1472 qin(i, j) = qout(i, j)
1480 REAL,
DIMENSION(2),
INTENT(IN) :: p0, p1, p2
1481 REAL,
INTENT(IN) :: q1, q2
1484 x1 = great_circle_dist(
REAL(p1, kind=r_grid),
REAL(p0, kind=
r_grid))
1485 x2 = great_circle_dist(
REAL(p2, kind=r_grid),
REAL(p0, kind=
r_grid))
1494 REAL,
DIMENSION(2),
INTENT(IN) :: p0, p1, p2
1495 REAL,
INTENT(IN) :: q1, q2
1496 REAL,
INTENT(IN) :: q1_tl, q2_tl
1500 x1 = great_circle_dist(
REAL(p1, kind=r_grid),
REAL(p0, kind=
r_grid))
1501 x2 = great_circle_dist(
REAL(p2, kind=r_grid),
REAL(p0, kind=
r_grid))
real function extrap_corner(p0, p1, p2, q1, q2)
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
real function extrap_corner_tlm(p0, p1, p2, q1, q1_tl, q2, q2_tl, extrap_corner)
void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, double *qout, int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
integer, parameter, public r_grid
real function, public great_circle_dist(q1, q2, radius)
subroutine, public a2b_ord4_tlm(qin, qin_tl, qout, qout_tl, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine, public a2b_ord2_tlm(qin, qin_tl, qout, qout_tl, gridstruct, npx, npy, is, ie, js, je, ng, replace)