44 real,
parameter::
r3 = 1./3.
56 real,
parameter::
p1 = 7./12.
57 real,
parameter::
p2 = -1./12.
61 real,
parameter::
a1 = 0.5625
62 real,
parameter::
a2 = -0.0625
65 real,
parameter::
c1 = -2./14.
66 real,
parameter::
c2 = 11./14.
67 real,
parameter::
c3 = 5./14.
74 REAL,
PARAMETER ::
b1=1./30.
75 REAL,
PARAMETER ::
b2=-(13./60.)
76 REAL,
PARAMETER ::
b3=-(13./60.)
77 REAL,
PARAMETER ::
b4=0.45
78 REAL,
PARAMETER ::
b5=-0.05
112 SUBROUTINE c_sw_fwd(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, wc&
113 & , ut, vt, divg_d, nord, dt2, hydrostatic, dord4, bd, gridstruct, &
119 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: u&
121 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: v&
123 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: delp&
124 & , pt, ua, va, ut, vt
125 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w
126 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc, wc
127 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d
128 INTEGER,
INTENT(IN) :: nord
129 REAL,
INTENT(IN) :: dt2
130 LOGICAL,
INTENT(IN) :: hydrostatic
131 LOGICAL,
INTENT(IN) :: dord4
135 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
136 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+1) :: vort, ke
137 REAL,
DIMENSION(bd%is-1:bd%ie+2, bd%js-1:bd%je+1) :: fx, fx1, fx2
138 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+2) :: fy, fy1, fy2
140 INTEGER :: i, j, is2, ie1
141 INTEGER :: iep1, jep1
142 INTEGER :: is, ie, js, je
143 INTEGER :: isd, ied, jsd, jed
146 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
147 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v
148 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
149 REAL,
DIMENSION(:, :),
POINTER :: dx, dy, dxc, dyc
181 nested = gridstruct%nested
182 sin_sg => gridstruct%sin_sg
183 cos_sg => gridstruct%cos_sg
184 cosa_u => gridstruct%cosa_u
185 cosa_v => gridstruct%cosa_v
186 sina_u => gridstruct%sina_u
187 sina_v => gridstruct%sina_v
190 dxc => gridstruct%dxc
191 dyc => gridstruct%dyc
192 sw_corner = gridstruct%sw_corner
193 se_corner = gridstruct%se_corner
194 nw_corner = gridstruct%nw_corner
195 ne_corner = gridstruct%ne_corner
198 CALL d2a2c_vect_fwd(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct&
199 & , bd, npx, npy, nested, flagstruct%grid_type)
200 IF (nord .GT. 0)
THEN 215 IF (ut(i, j) .GT. 0.)
THEN 217 ut(i, j) = dt2*ut(i, j)*dy(i, j)*sin_sg(i-1, j, 3)
221 ut(i, j) = dt2*ut(i, j)*dy(i, j)*sin_sg(i, j, 1)
228 IF (vt(i, j) .GT. 0.)
THEN 230 vt(i, j) = dt2*vt(i, j)*dx(i, j)*sin_sg(i, j-1, 4)
234 vt(i, j) = dt2*vt(i, j)*dx(i, j)*sin_sg(i, j, 2)
243 IF (flagstruct%grid_type .LT. 3 .AND. (.NOT.nested))
THEN 245 & se_corner, ne_corner, nw_corner)
250 IF (hydrostatic)
THEN 253 IF (ut(i, j) .GT. 0.)
THEN 254 fx1(i, j) = delp(i-1, j)
255 fx(i, j) = pt(i-1, j)
258 fx1(i, j) = delp(i, j)
263 fx1(i, j) = ut(i, j)*fx1(i, j)
265 fx(i, j) = fx1(i, j)*fx(i, j)
270 IF (flagstruct%grid_type .LT. 3)
THEN 272 & , ne_corner, nw_corner)
279 IF (ut(i, j) .GT. 0.)
THEN 280 fx1(i, j) = delp(i-1, j)
281 fx(i, j) = pt(i-1, j)
282 fx2(i, j) = w(i-1, j)
285 fx1(i, j) = delp(i, j)
291 fx1(i, j) = ut(i, j)*fx1(i, j)
293 fx(i, j) = fx1(i, j)*fx(i, j)
295 fx2(i, j) = fx1(i, j)*fx2(i, j)
301 IF (flagstruct%grid_type .LT. 3 .AND. (.NOT.nested))
THEN 303 & se_corner, ne_corner, nw_corner)
308 IF (hydrostatic)
THEN 311 IF (vt(i, j) .GT. 0.)
THEN 312 fy1(i, j) = delp(i, j-1)
313 fy(i, j) = pt(i, j-1)
316 fy1(i, j) = delp(i, j)
321 fy1(i, j) = vt(i, j)*fy1(i, j)
323 fy(i, j) = fy1(i, j)*fy(i, j)
329 delpc(i, j) = delp(i, j) + (fx1(i, j)-fx1(i+1, j)+(fy1(i, j)-&
330 & fy1(i, j+1)))*gridstruct%rarea(i, j)
332 ptc(i, j) = (pt(i, j)*delp(i, j)+(fx(i, j)-fx(i+1, j)+(fy(i, j&
333 & )-fy(i, j+1)))*gridstruct%rarea(i, j))/delpc(i, j)
338 IF (flagstruct%grid_type .LT. 3)
THEN 340 & , ne_corner, nw_corner)
347 IF (vt(i, j) .GT. 0.)
THEN 348 fy1(i, j) = delp(i, j-1)
349 fy(i, j) = pt(i, j-1)
350 fy2(i, j) = w(i, j-1)
353 fy1(i, j) = delp(i, j)
359 fy1(i, j) = vt(i, j)*fy1(i, j)
361 fy(i, j) = fy1(i, j)*fy(i, j)
363 fy2(i, j) = fy1(i, j)*fy2(i, j)
369 delpc(i, j) = delp(i, j) + (fx1(i, j)-fx1(i+1, j)+(fy1(i, j)-&
370 & fy1(i, j+1)))*gridstruct%rarea(i, j)
372 ptc(i, j) = (pt(i, j)*delp(i, j)+(fx(i, j)-fx(i+1, j)+(fy(i, j&
373 & )-fy(i, j+1)))*gridstruct%rarea(i, j))/delpc(i, j)
375 wc(i, j) = (w(i, j)*delp(i, j)+(fx2(i, j)-fx2(i+1, j)+(fy2(i, &
376 & j)-fy2(i, j+1)))*gridstruct%rarea(i, j))/delpc(i, j)
390 IF (nested .OR. flagstruct%grid_type .GE. 3)
THEN 393 IF (ua(i, j) .GT. 0.)
THEN 397 ke(i, j) = uc(i+1, j)
404 IF (va(i, j) .GT. 0.)
THEN 405 vort(i, j) = vc(i, j)
408 vort(i, j) = vc(i, j+1)
417 IF (ua(i, j) .GT. 0.)
THEN 419 ke(1, j) = uc(1, j)*sin_sg(1, j, 1) + v(1, j)*cos_sg(1, j&
422 ELSE IF (i .EQ. npx)
THEN 423 ke(i, j) = uc(npx, j)*sin_sg(npx, j, 1) + v(npx, j)*cos_sg&
430 ELSE IF (i .EQ. 0)
THEN 431 ke(0, j) = uc(1, j)*sin_sg(0, j, 3) + v(1, j)*cos_sg(0, j, 3&
434 ELSE IF (i .EQ. npx - 1)
THEN 435 ke(i, j) = uc(npx, j)*sin_sg(npx-1, j, 3) + v(npx, j)*cos_sg&
439 ke(i, j) = uc(i+1, j)
446 IF (va(i, j) .GT. 0.)
THEN 448 vort(i, 1) = vc(i, 1)*sin_sg(i, 1, 2) + u(i, 1)*cos_sg(i, &
451 ELSE IF (j .EQ. npy)
THEN 452 vort(i, j) = vc(i, npy)*sin_sg(i, npy, 2) + u(i, npy)*&
456 vort(i, j) = vc(i, j)
459 ELSE IF (j .EQ. 0)
THEN 460 vort(i, 0) = vc(i, 1)*sin_sg(i, 0, 4) + u(i, 1)*cos_sg(i, 0&
463 ELSE IF (j .EQ. npy - 1)
THEN 464 vort(i, j) = vc(i, npy)*sin_sg(i, npy-1, 4) + u(i, npy)*&
465 & cos_sg(i, npy-1, 4)
468 vort(i, j) = vc(i, j+1)
479 ke(i, j) = dt4*(ua(i, j)*ke(i, j)+va(i, j)*vort(i, j))
489 fx(i, j) = uc(i, j)*dxc(i, j)
495 fy(i, j) = vc(i, j)*dyc(i, j)
501 vort(i, j) = fx(i, j-1) - fx(i, j) + (fy(i, j)-fy(i-1, j))
507 vort(1, 1) = vort(1, 1) + fy(0, 1)
514 vort(npx, 1) = vort(npx, 1) - fy(npx, 1)
521 vort(npx, npy) = vort(npx, npy) - fy(npx, npy)
528 vort(1, npy) = vort(1, npy) + fy(0, npy)
539 vort(i, j) = gridstruct%fc(i, j) + gridstruct%rarea_c(i, j)*vort&
551 IF (nested .OR. flagstruct%grid_type .GE. 3)
THEN 555 fy1(i, j) = dt2*(v(i, j)-uc(i, j)*cosa_u(i, j))/sina_u(i, j)
556 IF (fy1(i, j) .GT. 0.)
THEN 558 fy(i, j) = vort(i, j)
562 fy(i, j) = vort(i, j+1)
570 fx1(i, j) = dt2*(u(i, j)-vc(i, j)*cosa_v(i, j))/sina_v(i, j)
571 IF (fx1(i, j) .GT. 0.)
THEN 573 fx(i, j) = vort(i, j)
577 fx(i, j) = vort(i+1, j)
587 IF (i .EQ. 1 .OR. i .EQ. npx)
THEN 589 fy1(i, j) = dt2*v(i, j)
593 fy1(i, j) = dt2*(v(i, j)-uc(i, j)*cosa_u(i, j))/sina_u(i, j)
596 IF (fy1(i, j) .GT. 0.)
THEN 598 fy(i, j) = vort(i, j)
602 fy(i, j) = vort(i, j+1)
608 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 612 fx1(i, j) = dt2*u(i, j)
613 IF (fx1(i, j) .GT. 0.)
THEN 615 fx(i, j) = vort(i, j)
619 fx(i, j) = vort(i+1, j)
628 fx1(i, j) = dt2*(u(i, j)-vc(i, j)*cosa_v(i, j))/sina_v(i, j)
629 IF (fx1(i, j) .GT. 0.)
THEN 631 fx(i, j) = vort(i, j)
635 fx(i, j) = vort(i+1, j)
647 uc(i, j) = uc(i, j) + fy1(i, j)*fy(i, j) + gridstruct%rdxc(i, j)&
648 & *(ke(i-1, j)-ke(i, j))
653 vc(i, j) = vc(i, j) - fx1(i, j)*fx(i, j) + gridstruct%rdyc(i, j)&
654 & *(ke(i, j-1)-ke(i, j))
704 SUBROUTINE c_sw_bwd(delpc, delpc_ad, delp, delp_ad, ptc, ptc_ad, pt, &
705 & pt_ad, u, u_ad, v, v_ad, w, w_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, &
706 & va, va_ad, wc, wc_ad, ut, ut_ad, vt, vt_ad, divg_d, divg_d_ad, nord&
707 & , dt2, hydrostatic, dord4, bd, gridstruct, flagstruct)
712 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: u&
714 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
716 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: v&
718 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: &
720 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: delp&
721 & , pt, ua, va, ut, vt
722 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
723 & delp_ad, pt_ad, ua_ad, va_ad, ut_ad, vt_ad
724 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w
725 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w_ad
726 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc, wc
727 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc_ad, ptc_ad, &
729 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d
730 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d_ad
731 INTEGER,
INTENT(IN) :: nord
732 REAL,
INTENT(IN) :: dt2
733 LOGICAL,
INTENT(IN) :: hydrostatic
734 LOGICAL,
INTENT(IN) :: dord4
737 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
738 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+1) :: vort, ke
739 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+1) :: vort_ad, ke_ad
740 REAL,
DIMENSION(bd%is-1:bd%ie+2, bd%js-1:bd%je+1) :: fx, fx1, fx2
741 REAL,
DIMENSION(bd%is-1:bd%ie+2, bd%js-1:bd%je+1) :: fx_ad, fx1_ad, &
743 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+2) :: fy, fy1, fy2
744 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+2) :: fy_ad, fy1_ad, &
747 INTEGER :: i, j, is2, ie1
748 INTEGER :: iep1, jep1
749 INTEGER :: is, ie, js, je
750 INTEGER :: isd, ied, jsd, jed
753 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
754 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v
755 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
756 REAL,
DIMENSION(:, :),
POINTER :: dx, dy, dxc, dyc
805 dxc => gridstruct%dxc
811 cosa_u => gridstruct%cosa_u
814 cosa_v => gridstruct%cosa_v
817 sin_sg => gridstruct%sin_sg
820 dyc => gridstruct%dyc
822 CALL poprealarray(vort, (bd%ie-bd%is+3)*(bd%je-bd%js+3))
824 sina_u => gridstruct%sina_u
826 sina_v => gridstruct%sina_v
838 temp_ad13 = gridstruct%rdyc(i, j)*vc_ad(i, j)
839 fx1_ad(i, j) = fx1_ad(i, j) - fx(i, j)*vc_ad(i, j)
840 fx_ad(i, j) = fx_ad(i, j) - fx1(i, j)*vc_ad(i, j)
841 ke_ad(i, j-1) = ke_ad(i, j-1) + temp_ad13
842 ke_ad(i, j) = ke_ad(i, j) - temp_ad13
849 temp_ad12 = gridstruct%rdxc(i, j)*uc_ad(i, j)
850 fy1_ad(i, j) = fy1_ad(i, j) + fy(i, j)*uc_ad(i, j)
851 fy_ad(i, j) = fy_ad(i, j) + fy1(i, j)*uc_ad(i, j)
852 ke_ad(i-1, j) = ke_ad(i-1, j) + temp_ad12
853 ke_ad(i, j) = ke_ad(i, j) - temp_ad12
857 IF (branch .EQ. 0)
THEN 861 IF (branch .EQ. 0)
THEN 864 IF (branch .EQ. 0)
THEN 866 vort_ad(i+1, j) = vort_ad(i+1, j) + fx_ad(i, j)
870 vort_ad(i, j) = vort_ad(i, j) + fx_ad(i, j)
874 temp_ad11 = dt2*fx1_ad(i, j)/sina_v(i, j)
875 u_ad(i, j) = u_ad(i, j) + temp_ad11
876 vc_ad(i, j) = vc_ad(i, j) - cosa_v(i, j)*temp_ad11
882 IF (branch .EQ. 0)
THEN 884 vort_ad(i+1, j) = vort_ad(i+1, j) + fx_ad(i, j)
888 vort_ad(i, j) = vort_ad(i, j) + fx_ad(i, j)
892 u_ad(i, j) = u_ad(i, j) + dt2*fx1_ad(i, j)
900 IF (branch .EQ. 0)
THEN 902 vort_ad(i, j+1) = vort_ad(i, j+1) + fy_ad(i, j)
906 vort_ad(i, j) = vort_ad(i, j) + fy_ad(i, j)
910 IF (branch .EQ. 0)
THEN 912 v_ad(i, j) = v_ad(i, j) + dt2*fy1_ad(i, j)
916 temp_ad10 = dt2*fy1_ad(i, j)/sina_u(i, j)
917 v_ad(i, j) = v_ad(i, j) + temp_ad10
918 uc_ad(i, j) = uc_ad(i, j) - cosa_u(i, j)*temp_ad10
928 IF (branch .EQ. 0)
THEN 930 vort_ad(i+1, j) = vort_ad(i+1, j) + fx_ad(i, j)
934 vort_ad(i, j) = vort_ad(i, j) + fx_ad(i, j)
938 temp_ad9 = dt2*fx1_ad(i, j)/sina_v(i, j)
939 u_ad(i, j) = u_ad(i, j) + temp_ad9
940 vc_ad(i, j) = vc_ad(i, j) - cosa_v(i, j)*temp_ad9
947 IF (branch .EQ. 0)
THEN 949 vort_ad(i, j+1) = vort_ad(i, j+1) + fy_ad(i, j)
953 vort_ad(i, j) = vort_ad(i, j) + fy_ad(i, j)
957 temp_ad8 = dt2*fy1_ad(i, j)/sina_u(i, j)
958 v_ad(i, j) = v_ad(i, j) + temp_ad8
959 uc_ad(i, j) = uc_ad(i, j) - cosa_u(i, j)*temp_ad8
967 vort_ad(i, j) = gridstruct%rarea_c(i, j)*vort_ad(i, j)
971 IF (branch .NE. 0)
THEN 973 fy_ad(0, npy) = fy_ad(0, npy) + vort_ad(1, npy)
976 IF (branch .EQ. 0)
THEN 978 fy_ad(npx, npy) = fy_ad(npx, npy) - vort_ad(npx, npy)
981 IF (branch .EQ. 0)
THEN 983 fy_ad(npx, 1) = fy_ad(npx, 1) - vort_ad(npx, 1)
986 IF (branch .EQ. 0)
THEN 988 fy_ad(0, 1) = fy_ad(0, 1) + vort_ad(1, 1)
993 fx_ad(i, j-1) = fx_ad(i, j-1) + vort_ad(i, j)
994 fx_ad(i, j) = fx_ad(i, j) - vort_ad(i, j)
995 fy_ad(i, j) = fy_ad(i, j) + vort_ad(i, j)
996 fy_ad(i-1, j) = fy_ad(i-1, j) - vort_ad(i, j)
1003 vc_ad(i, j) = vc_ad(i, j) + dyc(i, j)*fy_ad(i, j)
1010 uc_ad(i, j) = uc_ad(i, j) + dxc(i, j)*fx_ad(i, j)
1017 temp_ad7 = dt4*ke_ad(i, j)
1018 ua_ad(i, j) = ua_ad(i, j) + ke(i, j)*temp_ad7
1019 va_ad(i, j) = va_ad(i, j) + vort(i, j)*temp_ad7
1020 vort_ad(i, j) = vort_ad(i, j) + va(i, j)*temp_ad7
1021 ke_ad(i, j) = ua(i, j)*temp_ad7
1024 cos_sg => gridstruct%cos_sg
1026 IF (branch .EQ. 0)
THEN 1030 IF (branch .EQ. 0)
THEN 1031 vc_ad(i, j+1) = vc_ad(i, j+1) + vort_ad(i, j)
1034 vc_ad(i, j) = vc_ad(i, j) + vort_ad(i, j)
1042 IF (branch .EQ. 0)
THEN 1043 uc_ad(i+1, j) = uc_ad(i+1, j) + ke_ad(i, j)
1046 uc_ad(i, j) = uc_ad(i, j) + ke_ad(i, j)
1055 IF (branch .LT. 3)
THEN 1056 IF (branch .EQ. 0)
THEN 1057 vc_ad(i, j+1) = vc_ad(i, j+1) + vort_ad(i, j)
1059 ELSE IF (branch .EQ. 1)
THEN 1060 vc_ad(i, npy) = vc_ad(i, npy) + sin_sg(i, npy-1, 4)*&
1062 u_ad(i, npy) = u_ad(i, npy) + cos_sg(i, npy-1, 4)*vort_ad(&
1066 vc_ad(i, 1) = vc_ad(i, 1) + sin_sg(i, 0, 4)*vort_ad(i, 0)
1067 u_ad(i, 1) = u_ad(i, 1) + cos_sg(i, 0, 4)*vort_ad(i, 0)
1070 ELSE IF (branch .EQ. 3)
THEN 1071 vc_ad(i, j) = vc_ad(i, j) + vort_ad(i, j)
1073 ELSE IF (branch .EQ. 4)
THEN 1074 vc_ad(i, npy) = vc_ad(i, npy) + sin_sg(i, npy, 2)*vort_ad(i&
1076 u_ad(i, npy) = u_ad(i, npy) + cos_sg(i, npy, 2)*vort_ad(i, j&
1080 vc_ad(i, 1) = vc_ad(i, 1) + sin_sg(i, 1, 2)*vort_ad(i, 1)
1081 u_ad(i, 1) = u_ad(i, 1) + cos_sg(i, 1, 2)*vort_ad(i, 1)
1089 IF (branch .LT. 3)
THEN 1090 IF (branch .EQ. 0)
THEN 1091 uc_ad(i+1, j) = uc_ad(i+1, j) + ke_ad(i, j)
1093 ELSE IF (branch .EQ. 1)
THEN 1094 uc_ad(npx, j) = uc_ad(npx, j) + sin_sg(npx-1, j, 3)*ke_ad(&
1096 v_ad(npx, j) = v_ad(npx, j) + cos_sg(npx-1, j, 3)*ke_ad(i&
1100 uc_ad(1, j) = uc_ad(1, j) + sin_sg(0, j, 3)*ke_ad(0, j)
1101 v_ad(1, j) = v_ad(1, j) + cos_sg(0, j, 3)*ke_ad(0, j)
1104 ELSE IF (branch .EQ. 3)
THEN 1105 uc_ad(i, j) = uc_ad(i, j) + ke_ad(i, j)
1107 ELSE IF (branch .EQ. 4)
THEN 1108 uc_ad(npx, j) = uc_ad(npx, j) + sin_sg(npx, j, 1)*ke_ad(i, j&
1110 v_ad(npx, j) = v_ad(npx, j) + cos_sg(npx, j, 1)*ke_ad(i, j)
1113 uc_ad(1, j) = uc_ad(1, j) + sin_sg(1, j, 1)*ke_ad(1, j)
1114 v_ad(1, j) = v_ad(1, j) + cos_sg(1, j, 1)*ke_ad(1, j)
1121 IF (branch .EQ. 0)
THEN 1125 temp_ad = ptc_ad(i, j)/delpc(i, j)
1126 temp_ad0 = gridstruct%rarea(i, j)*temp_ad
1127 pt_ad(i, j) = pt_ad(i, j) + delp(i, j)*temp_ad
1128 fx_ad(i, j) = fx_ad(i, j) + temp_ad0
1129 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad0
1130 fy_ad(i, j) = fy_ad(i, j) + temp_ad0
1131 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad0
1132 delpc_ad(i, j) = delpc_ad(i, j) - (pt(i, j)*delp(i, j)+&
1133 & gridstruct%rarea(i, j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i, j&
1134 & +1)))*temp_ad/delpc(i, j)
1135 delp_ad(i, j) = delp_ad(i, j) + delpc_ad(i, j) + pt(i, j)*&
1139 temp_ad1 = gridstruct%rarea(i, j)*delpc_ad(i, j)
1140 fx1_ad(i, j) = fx1_ad(i, j) + temp_ad1
1141 fx1_ad(i+1, j) = fx1_ad(i+1, j) - temp_ad1
1142 fy1_ad(i, j) = fy1_ad(i, j) + temp_ad1
1143 fy1_ad(i, j+1) = fy1_ad(i, j+1) - temp_ad1
1144 delpc_ad(i, j) = 0.0
1150 fy1_ad(i, j) = fy1_ad(i, j) + fy(i, j)*fy_ad(i, j)
1151 fy_ad(i, j) = fy1(i, j)*fy_ad(i, j)
1153 vt_ad(i, j) = vt_ad(i, j) + fy1(i, j)*fy1_ad(i, j)
1154 fy1_ad(i, j) = vt(i, j)*fy1_ad(i, j)
1156 IF (branch .EQ. 0)
THEN 1157 pt_ad(i, j-1) = pt_ad(i, j-1) + fy_ad(i, j)
1159 delp_ad(i, j-1) = delp_ad(i, j-1) + fy1_ad(i, j)
1162 pt_ad(i, j) = pt_ad(i, j) + fy_ad(i, j)
1164 delp_ad(i, j) = delp_ad(i, j) + fy1_ad(i, j)
1175 temp_ad4 = ptc_ad(i, j)/delpc(i, j)
1177 temp_ad2 = wc_ad(i, j)/delpc(i, j)
1178 temp_ad3 = gridstruct%rarea(i, j)*temp_ad2
1179 w_ad(i, j) = w_ad(i, j) + delp(i, j)*temp_ad2
1180 fx2_ad(i, j) = fx2_ad(i, j) + temp_ad3
1181 fx2_ad(i+1, j) = fx2_ad(i+1, j) - temp_ad3
1182 fy2_ad(i, j) = fy2_ad(i, j) + temp_ad3
1183 fy2_ad(i, j+1) = fy2_ad(i, j+1) - temp_ad3
1184 delpc_ad(i, j) = delpc_ad(i, j) - (pt(i, j)*delp(i, j)+&
1185 & gridstruct%rarea(i, j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i, j&
1186 & +1)))*temp_ad4/delpc(i, j) - (w(i, j)*delp(i, j)+gridstruct%&
1187 & rarea(i, j)*(fx2(i, j)-fx2(i+1, j)+fy2(i, j)-fy2(i, j+1)))*&
1188 & temp_ad2/delpc(i, j)
1189 delp_ad(i, j) = delp_ad(i, j) + pt(i, j)*temp_ad4 + delpc_ad(i&
1190 & , j) + w(i, j)*temp_ad2
1193 temp_ad5 = gridstruct%rarea(i, j)*temp_ad4
1194 pt_ad(i, j) = pt_ad(i, j) + delp(i, j)*temp_ad4
1195 fx_ad(i, j) = fx_ad(i, j) + temp_ad5
1196 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad5
1197 fy_ad(i, j) = fy_ad(i, j) + temp_ad5
1198 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad5
1201 temp_ad6 = gridstruct%rarea(i, j)*delpc_ad(i, j)
1202 fx1_ad(i, j) = fx1_ad(i, j) + temp_ad6
1203 fx1_ad(i+1, j) = fx1_ad(i+1, j) - temp_ad6
1204 fy1_ad(i, j) = fy1_ad(i, j) + temp_ad6
1205 fy1_ad(i, j+1) = fy1_ad(i, j+1) - temp_ad6
1206 delpc_ad(i, j) = 0.0
1213 fy1_ad(i, j) = fy1_ad(i, j) + fy(i, j)*fy_ad(i, j) + fy2(i, j)&
1215 fy2_ad(i, j) = fy1(i, j)*fy2_ad(i, j)
1216 fy_ad(i, j) = fy1(i, j)*fy_ad(i, j)
1218 vt_ad(i, j) = vt_ad(i, j) + fy1(i, j)*fy1_ad(i, j)
1219 fy1_ad(i, j) = vt(i, j)*fy1_ad(i, j)
1221 IF (branch .EQ. 0)
THEN 1222 w_ad(i, j-1) = w_ad(i, j-1) + fy2_ad(i, j)
1224 pt_ad(i, j-1) = pt_ad(i, j-1) + fy_ad(i, j)
1226 delp_ad(i, j-1) = delp_ad(i, j-1) + fy1_ad(i, j)
1229 w_ad(i, j) = w_ad(i, j) + fy2_ad(i, j)
1231 pt_ad(i, j) = pt_ad(i, j) + fy_ad(i, j)
1233 delp_ad(i, j) = delp_ad(i, j) + fy1_ad(i, j)
1240 & , sw_corner, se_corner, &
1241 & ne_corner, nw_corner)
1245 & , 2, bd, npx, npy, sw_corner, &
1246 & se_corner, ne_corner, nw_corner&
1249 IF (branch .EQ. 0)
THEN 1253 fx1_ad(i, j) = fx1_ad(i, j) + fx(i, j)*fx_ad(i, j)
1254 fx_ad(i, j) = fx1(i, j)*fx_ad(i, j)
1256 ut_ad(i, j) = ut_ad(i, j) + fx1(i, j)*fx1_ad(i, j)
1257 fx1_ad(i, j) = ut(i, j)*fx1_ad(i, j)
1259 IF (branch .EQ. 0)
THEN 1260 pt_ad(i-1, j) = pt_ad(i-1, j) + fx_ad(i, j)
1262 delp_ad(i-1, j) = delp_ad(i-1, j) + fx1_ad(i, j)
1265 pt_ad(i, j) = pt_ad(i, j) + fx_ad(i, j)
1267 delp_ad(i, j) = delp_ad(i, j) + fx1_ad(i, j)
1277 fx1_ad(i, j) = fx1_ad(i, j) + fx(i, j)*fx_ad(i, j) + fx2(i, j)&
1279 fx2_ad(i, j) = fx1(i, j)*fx2_ad(i, j)
1280 fx_ad(i, j) = fx1(i, j)*fx_ad(i, j)
1282 ut_ad(i, j) = ut_ad(i, j) + fx1(i, j)*fx1_ad(i, j)
1283 fx1_ad(i, j) = ut(i, j)*fx1_ad(i, j)
1285 IF (branch .EQ. 0)
THEN 1286 w_ad(i-1, j) = w_ad(i-1, j) + fx2_ad(i, j)
1288 pt_ad(i-1, j) = pt_ad(i-1, j) + fx_ad(i, j)
1290 delp_ad(i-1, j) = delp_ad(i-1, j) + fx1_ad(i, j)
1293 w_ad(i, j) = w_ad(i, j) + fx2_ad(i, j)
1295 pt_ad(i, j) = pt_ad(i, j) + fx_ad(i, j)
1297 delp_ad(i, j) = delp_ad(i, j) + fx1_ad(i, j)
1304 & , sw_corner, se_corner, &
1305 & ne_corner, nw_corner)
1309 & , 1, bd, npx, npy, sw_corner, &
1310 & se_corner, ne_corner, nw_corner&
1316 IF (branch .EQ. 0)
THEN 1318 vt_ad(i, j) = dx(i, j)*sin_sg(i, j, 2)*dt2*vt_ad(i, j)
1321 vt_ad(i, j) = dx(i, j)*sin_sg(i, j-1, 4)*dt2*vt_ad(i, j)
1328 IF (branch .EQ. 0)
THEN 1330 ut_ad(i, j) = dy(i, j)*sin_sg(i, j, 1)*dt2*ut_ad(i, j)
1333 ut_ad(i, j) = dy(i, j)*sin_sg(i-1, j, 3)*dt2*ut_ad(i, j)
1338 IF (branch .NE. 0)
THEN 1339 IF (branch .EQ. 1)
THEN 1341 & va_ad, divg_d, divg_d_ad, gridstruct, &
1345 & , va_ad, divg_d, divg_d_ad, gridstruct&
1350 CALL d2a2c_vect_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, uc, &
1351 & uc_ad, vc, vc_ad, ut, ut_ad, vt, vt_ad, dord4, &
1352 & gridstruct, bd, npx, npy, nested, flagstruct%grid_type&
1355 SUBROUTINE c_sw(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, wc, ut&
1356 & , vt, divg_d, nord, dt2, hydrostatic, dord4, bd, gridstruct, &
1360 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: u&
1362 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: v&
1364 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: delp&
1365 & , pt, ua, va, ut, vt
1366 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w
1367 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(OUT) :: delpc&
1369 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(OUT) :: &
1371 INTEGER,
INTENT(IN) :: nord
1372 REAL,
INTENT(IN) :: dt2
1373 LOGICAL,
INTENT(IN) :: hydrostatic
1374 LOGICAL,
INTENT(IN) :: dord4
1378 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
1379 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+1) :: vort, ke
1380 REAL,
DIMENSION(bd%is-1:bd%ie+2, bd%js-1:bd%je+1) :: fx, fx1, fx2
1381 REAL,
DIMENSION(bd%is-1:bd%ie+1, bd%js-1:bd%je+2) :: fy, fy1, fy2
1383 INTEGER :: i, j, is2, ie1
1384 INTEGER :: iep1, jep1
1385 INTEGER :: is, ie, js, je
1386 INTEGER :: isd, ied, jsd, jed
1389 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
1390 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v
1391 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
1392 REAL,
DIMENSION(:, :),
POINTER :: dx, dy, dxc, dyc
1401 npx = flagstruct%npx
1402 npy = flagstruct%npy
1403 nested = gridstruct%nested
1404 sin_sg => gridstruct%sin_sg
1405 cos_sg => gridstruct%cos_sg
1406 cosa_u => gridstruct%cosa_u
1407 cosa_v => gridstruct%cosa_v
1408 sina_u => gridstruct%sina_u
1409 sina_v => gridstruct%sina_v
1412 dxc => gridstruct%dxc
1413 dyc => gridstruct%dyc
1414 sw_corner = gridstruct%sw_corner
1415 se_corner = gridstruct%se_corner
1416 nw_corner = gridstruct%nw_corner
1417 ne_corner = gridstruct%ne_corner
1420 CALL d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd&
1421 & , npx, npy, nested, flagstruct%grid_type)
1422 IF (nord .GT. 0)
THEN 1433 IF (ut(i, j) .GT. 0.)
THEN 1434 ut(i, j) = dt2*ut(i, j)*dy(i, j)*sin_sg(i-1, j, 3)
1436 ut(i, j) = dt2*ut(i, j)*dy(i, j)*sin_sg(i, j, 1)
1442 IF (vt(i, j) .GT. 0.)
THEN 1443 vt(i, j) = dt2*vt(i, j)*dx(i, j)*sin_sg(i, j-1, 4)
1445 vt(i, j) = dt2*vt(i, j)*dx(i, j)*sin_sg(i, j, 2)
1453 IF (flagstruct%grid_type .LT. 3 .AND. (.NOT.nested))
CALL &
1454 &
fill2_4corners(delp, pt, 1, bd, npx, npy, sw_corner, se_corner, &
1455 & ne_corner, nw_corner)
1456 IF (hydrostatic)
THEN 1459 IF (ut(i, j) .GT. 0.)
THEN 1460 fx1(i, j) = delp(i-1, j)
1461 fx(i, j) = pt(i-1, j)
1463 fx1(i, j) = delp(i, j)
1466 fx1(i, j) = ut(i, j)*fx1(i, j)
1467 fx(i, j) = fx1(i, j)*fx(i, j)
1471 IF (flagstruct%grid_type .LT. 3)
CALL fill_4corners(w, 1, bd, npx&
1472 & , npy, sw_corner, &
1473 & se_corner, ne_corner&
1477 IF (ut(i, j) .GT. 0.)
THEN 1478 fx1(i, j) = delp(i-1, j)
1479 fx(i, j) = pt(i-1, j)
1480 fx2(i, j) = w(i-1, j)
1482 fx1(i, j) = delp(i, j)
1486 fx1(i, j) = ut(i, j)*fx1(i, j)
1487 fx(i, j) = fx1(i, j)*fx(i, j)
1488 fx2(i, j) = fx1(i, j)*fx2(i, j)
1493 IF (flagstruct%grid_type .LT. 3 .AND. (.NOT.nested))
CALL &
1494 &
fill2_4corners(delp, pt, 2, bd, npx, npy, sw_corner, se_corner, &
1495 & ne_corner, nw_corner)
1496 IF (hydrostatic)
THEN 1499 IF (vt(i, j) .GT. 0.)
THEN 1500 fy1(i, j) = delp(i, j-1)
1501 fy(i, j) = pt(i, j-1)
1503 fy1(i, j) = delp(i, j)
1506 fy1(i, j) = vt(i, j)*fy1(i, j)
1507 fy(i, j) = fy1(i, j)*fy(i, j)
1512 delpc(i, j) = delp(i, j) + (fx1(i, j)-fx1(i+1, j)+(fy1(i, j)-&
1513 & fy1(i, j+1)))*gridstruct%rarea(i, j)
1514 ptc(i, j) = (pt(i, j)*delp(i, j)+(fx(i, j)-fx(i+1, j)+(fy(i, j&
1515 & )-fy(i, j+1)))*gridstruct%rarea(i, j))/delpc(i, j)
1519 IF (flagstruct%grid_type .LT. 3)
CALL fill_4corners(w, 2, bd, npx&
1520 & , npy, sw_corner, &
1521 & se_corner, ne_corner&
1525 IF (vt(i, j) .GT. 0.)
THEN 1526 fy1(i, j) = delp(i, j-1)
1527 fy(i, j) = pt(i, j-1)
1528 fy2(i, j) = w(i, j-1)
1530 fy1(i, j) = delp(i, j)
1534 fy1(i, j) = vt(i, j)*fy1(i, j)
1535 fy(i, j) = fy1(i, j)*fy(i, j)
1536 fy2(i, j) = fy1(i, j)*fy2(i, j)
1541 delpc(i, j) = delp(i, j) + (fx1(i, j)-fx1(i+1, j)+(fy1(i, j)-&
1542 & fy1(i, j+1)))*gridstruct%rarea(i, j)
1543 ptc(i, j) = (pt(i, j)*delp(i, j)+(fx(i, j)-fx(i+1, j)+(fy(i, j&
1544 & )-fy(i, j+1)))*gridstruct%rarea(i, j))/delpc(i, j)
1545 wc(i, j) = (w(i, j)*delp(i, j)+(fx2(i, j)-fx2(i+1, j)+(fy2(i, &
1546 & j)-fy2(i, j+1)))*gridstruct%rarea(i, j))/delpc(i, j)
1559 IF (nested .OR. flagstruct%grid_type .GE. 3)
THEN 1562 IF (ua(i, j) .GT. 0.)
THEN 1565 ke(i, j) = uc(i+1, j)
1571 IF (va(i, j) .GT. 0.)
THEN 1572 vort(i, j) = vc(i, j)
1574 vort(i, j) = vc(i, j+1)
1581 IF (ua(i, j) .GT. 0.)
THEN 1583 ke(1, j) = uc(1, j)*sin_sg(1, j, 1) + v(1, j)*cos_sg(1, j&
1585 ELSE IF (i .EQ. npx)
THEN 1586 ke(i, j) = uc(npx, j)*sin_sg(npx, j, 1) + v(npx, j)*cos_sg&
1591 ELSE IF (i .EQ. 0)
THEN 1592 ke(0, j) = uc(1, j)*sin_sg(0, j, 3) + v(1, j)*cos_sg(0, j, 3&
1594 ELSE IF (i .EQ. npx - 1)
THEN 1595 ke(i, j) = uc(npx, j)*sin_sg(npx-1, j, 3) + v(npx, j)*cos_sg&
1598 ke(i, j) = uc(i+1, j)
1604 IF (va(i, j) .GT. 0.)
THEN 1606 vort(i, 1) = vc(i, 1)*sin_sg(i, 1, 2) + u(i, 1)*cos_sg(i, &
1608 ELSE IF (j .EQ. npy)
THEN 1609 vort(i, j) = vc(i, npy)*sin_sg(i, npy, 2) + u(i, npy)*&
1612 vort(i, j) = vc(i, j)
1614 ELSE IF (j .EQ. 0)
THEN 1615 vort(i, 0) = vc(i, 1)*sin_sg(i, 0, 4) + u(i, 1)*cos_sg(i, 0&
1617 ELSE IF (j .EQ. npy - 1)
THEN 1618 vort(i, j) = vc(i, npy)*sin_sg(i, npy-1, 4) + u(i, npy)*&
1619 & cos_sg(i, npy-1, 4)
1621 vort(i, j) = vc(i, j+1)
1629 ke(i, j) = dt4*(ua(i, j)*ke(i, j)+va(i, j)*vort(i, j))
1638 fx(i, j) = uc(i, j)*dxc(i, j)
1643 fy(i, j) = vc(i, j)*dyc(i, j)
1648 vort(i, j) = fx(i, j-1) - fx(i, j) + (fy(i, j)-fy(i-1, j))
1652 IF (sw_corner) vort(1, 1) = vort(1, 1) + fy(0, 1)
1653 IF (se_corner) vort(npx, 1) = vort(npx, 1) - fy(npx, 1)
1654 IF (ne_corner) vort(npx, npy) = vort(npx, npy) - fy(npx, npy)
1655 IF (nw_corner) vort(1, npy) = vort(1, npy) + fy(0, npy)
1661 vort(i, j) = gridstruct%fc(i, j) + gridstruct%rarea_c(i, j)*vort&
1673 IF (nested .OR. flagstruct%grid_type .GE. 3)
THEN 1676 fy1(i, j) = dt2*(v(i, j)-uc(i, j)*cosa_u(i, j))/sina_u(i, j)
1677 IF (fy1(i, j) .GT. 0.)
THEN 1678 fy(i, j) = vort(i, j)
1680 fy(i, j) = vort(i, j+1)
1686 fx1(i, j) = dt2*(u(i, j)-vc(i, j)*cosa_v(i, j))/sina_v(i, j)
1687 IF (fx1(i, j) .GT. 0.)
THEN 1688 fx(i, j) = vort(i, j)
1690 fx(i, j) = vort(i+1, j)
1698 IF (i .EQ. 1 .OR. i .EQ. npx)
THEN 1699 fy1(i, j) = dt2*v(i, j)
1701 fy1(i, j) = dt2*(v(i, j)-uc(i, j)*cosa_u(i, j))/sina_u(i, j)
1703 IF (fy1(i, j) .GT. 0.)
THEN 1704 fy(i, j) = vort(i, j)
1706 fy(i, j) = vort(i, j+1)
1711 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 1714 fx1(i, j) = dt2*u(i, j)
1715 IF (fx1(i, j) .GT. 0.)
THEN 1716 fx(i, j) = vort(i, j)
1718 fx(i, j) = vort(i+1, j)
1724 fx1(i, j) = dt2*(u(i, j)-vc(i, j)*cosa_v(i, j))/sina_v(i, j)
1725 IF (fx1(i, j) .GT. 0.)
THEN 1726 fx(i, j) = vort(i, j)
1728 fx(i, j) = vort(i+1, j)
1737 uc(i, j) = uc(i, j) + fy1(i, j)*fy(i, j) + gridstruct%rdxc(i, j)&
1738 & *(ke(i-1, j)-ke(i, j))
1743 vc(i, j) = vc(i, j) - fx1(i, j)*fx(i, j) + gridstruct%rdyc(i, j)&
1744 & *(ke(i, j-1)-ke(i, j))
1773 SUBROUTINE d_sw_fwd(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, &
1774 & divg_d, xflux, yflux, cx, cy, crx_adv, cry_adv, xfx_adv, yfx_adv, &
1775 & q_con, z_rat, kgb, heat_source, dpx, zvir, sphum, nq, q, k, km, &
1776 & inline_q, dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, &
1777 & nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, damp_t&
1778 & , d_con, hydrostatic, gridstruct, flagstruct, bd, hord_tr_pert, &
1779 & hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, &
1780 & nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, &
1781 & d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
1785 INTEGER,
INTENT(IN) :: hord_tr, hord_mt, hord_vt, hord_tm, hord_dp
1787 INTEGER,
INTENT(IN) :: nord
1789 INTEGER,
INTENT(IN) :: nord_v
1791 INTEGER,
INTENT(IN) :: nord_w
1793 INTEGER,
INTENT(IN) :: nord_t
1794 INTEGER,
INTENT(IN) :: sphum, nq, k, km
1795 REAL,
INTENT(IN) :: dt, dddmp, d2_bg, d4_bg, d_con
1796 REAL,
INTENT(IN) :: zvir
1797 REAL,
INTENT(IN) :: damp_v, damp_w, damp_t, kgb
1799 INTEGER,
INTENT(IN) :: hord_tr_pert, hord_mt_pert, hord_vt_pert, &
1800 & hord_tm_pert, hord_dp_pert, nord_pert, nord_v_pert, nord_w_pert, &
1802 LOGICAL,
INTENT(IN) :: split_damp
1803 REAL,
INTENT(IN) :: dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert&
1804 & , damp_w_pert, damp_t_pert
1806 REAL,
INTENT(INOUT) :: divg_d(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
1807 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: z_rat
1808 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: delp&
1810 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w
1811 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
1813 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: u&
1815 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: v&
1817 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, km, nq)
1818 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc
1819 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: heat_source
1820 REAL(kind=8),
DIMENSION(bd%is:bd%ie, bd%js:bd%je),
INTENT(INOUT) :: &
1823 REAL,
INTENT(INOUT) :: xflux(bd%is:bd%ie+1, bd%js:bd%je)
1824 REAL,
INTENT(INOUT) :: yflux(bd%is:bd%ie, bd%js:bd%je+1)
1826 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed)
1827 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1)
1828 LOGICAL,
INTENT(IN) :: hydrostatic
1829 LOGICAL,
INTENT(IN) :: inline_q
1830 REAL,
DIMENSION(bd%is:bd%ie+1, bd%jsd:bd%jed) :: crx_adv, xfx_adv
1831 REAL,
DIMENSION(bd%isd:bd%ied, bd%js:bd%je+1) :: cry_adv, yfx_adv
1835 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
1836 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
1837 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1839 REAL :: fx2(bd%isd:bd%ied+1, bd%jsd:bd%jed)
1840 REAL :: fy2(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1842 REAL :: dw(bd%is:bd%ie, bd%js:bd%je)
1844 REAL,
DIMENSION(bd%is:bd%ie+1, bd%js:bd%je+1) :: ub, vb
1846 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
1848 REAL :: ke(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
1850 REAL :: vort(bd%isd:bd%ied, bd%jsd:bd%jed)
1852 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
1854 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
1855 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
1856 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
1857 REAL :: gx(bd%is:bd%ie+1, bd%js:bd%je)
1859 REAL :: gy(bd%is:bd%ie, bd%js:bd%je+1)
1861 REAL :: dt2, dt4, dt5, dt6
1862 REAL :: damp, damp2, damp4, dd8,
u2, v2, du2, dv2
1864 INTEGER :: i, j, is2, ie1, js2, je1, n, nt, n2, iq
1865 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
1866 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
1867 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
1868 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
1869 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
1870 REAL,
DIMENSION(:, :),
POINTER ::
f0, rsin2, divg_u, divg_v
1871 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
1873 INTEGER :: is, ie, js, je
1874 INTEGER :: isd, ied, jsd, jed
1877 REAL :: delp_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
1878 REAL :: pt_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
1879 REAL :: vort_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
1880 REAL :: wk_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
1881 REAL :: delpc_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
1882 REAL :: ptc_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
1883 REAL :: ke_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
1884 REAL :: vc_tj(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1885 REAL :: uc_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed)
1886 REAL :: divg_d_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
1887 REAL :: ut_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed)
1888 REAL :: vt_tj(bd%isd:bd%ied, bd%jsd:bd%jed+1)
1967 npx = flagstruct%npx
1968 npy = flagstruct%npy
1969 nested = gridstruct%nested
1970 area => gridstruct%area
1971 rarea => gridstruct%rarea
1972 sin_sg => gridstruct%sin_sg
1973 cosa_u => gridstruct%cosa_u
1974 cosa_v => gridstruct%cosa_v
1975 cosa_s => gridstruct%cosa_s
1976 rsin_u => gridstruct%rsin_u
1977 rsin_v => gridstruct%rsin_v
1978 rsina => gridstruct%rsina
1980 rsin2 => gridstruct%rsin2
1981 cosa => gridstruct%cosa
1984 rdxa => gridstruct%rdxa
1985 rdya => gridstruct%rdya
1986 rdx => gridstruct%rdx
1987 rdy => gridstruct%rdy
1988 sw_corner = gridstruct%sw_corner
1989 se_corner = gridstruct%se_corner
1990 nw_corner = gridstruct%nw_corner
1991 ne_corner = gridstruct%ne_corner
1993 IF (flagstruct%grid_type .LT. 3)
THEN 1998 ut(i, j) = (uc(i, j)-0.25*cosa_u(i, j)*(vc(i-1, j)+vc(i, j)+&
1999 & vc(i-1, j+1)+vc(i, j+1)))*rsin_u(i, j)
2004 vt(i, j) = (vc(i, j)-0.25*cosa_v(i, j)*(uc(i, j-1)+uc(i+1, j&
2005 & -1)+uc(i, j)+uc(i+1, j)))*rsin_v(i, j)
2011 IF (j .NE. 0 .AND. j .NE. 1 .AND. j .NE. npy - 1 .AND. j .NE. &
2014 ut(i, j) = (uc(i, j)-0.25*cosa_u(i, j)*(vc(i-1, j)+vc(i, j&
2015 & )+vc(i-1, j+1)+vc(i, j+1)))*rsin_u(i, j)
2023 IF (j .NE. 1 .AND. j .NE. npy)
THEN 2025 vt(i, j) = (vc(i, j)-0.25*cosa_v(i, j)*(uc(i, j-1)+uc(i+1&
2026 & , j-1)+uc(i, j)+uc(i+1, j)))*rsin_v(i, j)
2036 IF (.NOT.nested)
THEN 2041 IF (uc(1, j)*dt .GT. 0.)
THEN 2042 ut(1, j) = uc(1, j)/sin_sg(0, j, 3)
2045 ut(1, j) = uc(1, j)/sin_sg(1, j, 1)
2054 IF (npy - 2 .GT. je + 1)
THEN 2060 vt(0, j) = vc(0, j) - 0.25*cosa_v(0, j)*(ut(0, j-1)+ut(1, j-&
2061 & 1)+ut(0, j)+ut(1, j))
2062 vt(1, j) = vc(1, j) - 0.25*cosa_v(1, j)*(ut(1, j-1)+ut(2, j-&
2063 & 1)+ut(1, j)+ut(2, j))
2070 IF (ie + 1 .EQ. npx)
THEN 2072 IF (uc(npx, j)*dt .GT. 0.)
THEN 2073 ut(npx, j) = uc(npx, j)/sin_sg(npx-1, j, 3)
2076 ut(npx, j) = uc(npx, j)/sin_sg(npx, j, 1)
2085 IF (npy - 2 .GT. je + 1)
THEN 2091 vt(npx-1, j) = vc(npx-1, j) - 0.25*cosa_v(npx-1, j)*(ut(npx-&
2092 & 1, j-1)+ut(npx, j-1)+ut(npx-1, j)+ut(npx, j))
2093 vt(npx, j) = vc(npx, j) - 0.25*cosa_v(npx, j)*(ut(npx, j-1)+&
2094 & ut(npx+1, j-1)+ut(npx, j)+ut(npx+1, j))
2103 IF (vc(i, 1)*dt .GT. 0.)
THEN 2104 vt(i, 1) = vc(i, 1)/sin_sg(i, 0, 4)
2107 vt(i, 1) = vc(i, 1)/sin_sg(i, 1, 2)
2116 IF (npx - 2 .GT. ie + 1)
THEN 2122 ut(i, 0) = uc(i, 0) - 0.25*cosa_u(i, 0)*(vt(i-1, 0)+vt(i, 0)&
2123 & +vt(i-1, 1)+vt(i, 1))
2124 ut(i, 1) = uc(i, 1) - 0.25*cosa_u(i, 1)*(vt(i-1, 1)+vt(i, 1)&
2125 & +vt(i-1, 2)+vt(i, 2))
2132 IF (je + 1 .EQ. npy)
THEN 2134 IF (vc(i, npy)*dt .GT. 0.)
THEN 2135 vt(i, npy) = vc(i, npy)/sin_sg(i, npy-1, 4)
2138 vt(i, npy) = vc(i, npy)/sin_sg(i, npy, 2)
2147 IF (npx - 2 .GT. ie + 1)
THEN 2153 ut(i, npy-1) = uc(i, npy-1) - 0.25*cosa_u(i, npy-1)*(vt(i-1&
2154 & , npy-1)+vt(i, npy-1)+vt(i-1, npy)+vt(i, npy))
2155 ut(i, npy) = uc(i, npy) - 0.25*cosa_u(i, npy)*(vt(i-1, npy)+&
2156 & vt(i, npy)+vt(i-1, npy+1)+vt(i, npy+1))
2171 damp = 1./(1.-0.0625*cosa_u(2, 0)*cosa_v(1, 0))
2172 ut(2, 0) = (uc(2, 0)-0.25*cosa_u(2, 0)*(vt(1, 1)+vt(2, 1)+vt(2&
2173 & , 0)+vc(1, 0)-0.25*cosa_v(1, 0)*(ut(1, 0)+ut(1, -1)+ut(2, -1&
2175 damp = 1./(1.-0.0625*cosa_u(0, 1)*cosa_v(0, 2))
2176 vt(0, 2) = (vc(0, 2)-0.25*cosa_v(0, 2)*(ut(1, 1)+ut(1, 2)+ut(0&
2177 & , 2)+uc(0, 1)-0.25*cosa_u(0, 1)*(vt(0, 1)+vt(-1, 1)+vt(-1, 2&
2179 damp = 1./(1.-0.0625*cosa_u(2, 1)*cosa_v(1, 2))
2180 ut(2, 1) = (uc(2, 1)-0.25*cosa_u(2, 1)*(vt(1, 1)+vt(2, 1)+vt(2&
2181 & , 2)+vc(1, 2)-0.25*cosa_v(1, 2)*(ut(1, 1)+ut(1, 2)+ut(2, 2))&
2183 vt(1, 2) = (vc(1, 2)-0.25*cosa_v(1, 2)*(ut(1, 1)+ut(1, 2)+ut(2&
2184 & , 2)+uc(2, 1)-0.25*cosa_u(2, 1)*(vt(1, 1)+vt(2, 1)+vt(2, 2))&
2191 damp = 1./(1.-0.0625*cosa_u(npx-1, 0)*cosa_v(npx-1, 0))
2192 ut(npx-1, 0) = (uc(npx-1, 0)-0.25*cosa_u(npx-1, 0)*(vt(npx-1, &
2193 & 1)+vt(npx-2, 1)+vt(npx-2, 0)+vc(npx-1, 0)-0.25*cosa_v(npx-1&
2194 & , 0)*(ut(npx, 0)+ut(npx, -1)+ut(npx-1, -1))))*damp
2195 damp = 1./(1.-0.0625*cosa_u(npx+1, 1)*cosa_v(npx, 2))
2196 vt(npx, 2) = (vc(npx, 2)-0.25*cosa_v(npx, 2)*(ut(npx, 1)+ut(&
2197 & npx, 2)+ut(npx+1, 2)+uc(npx+1, 1)-0.25*cosa_u(npx+1, 1)*(vt(&
2198 & npx, 1)+vt(npx+1, 1)+vt(npx+1, 2))))*damp
2199 damp = 1./(1.-0.0625*cosa_u(npx-1, 1)*cosa_v(npx-1, 2))
2200 ut(npx-1, 1) = (uc(npx-1, 1)-0.25*cosa_u(npx-1, 1)*(vt(npx-1, &
2201 & 1)+vt(npx-2, 1)+vt(npx-2, 2)+vc(npx-1, 2)-0.25*cosa_v(npx-1&
2202 & , 2)*(ut(npx, 1)+ut(npx, 2)+ut(npx-1, 2))))*damp
2203 vt(npx-1, 2) = (vc(npx-1, 2)-0.25*cosa_v(npx-1, 2)*(ut(npx, 1)&
2204 & +ut(npx, 2)+ut(npx-1, 2)+uc(npx-1, 1)-0.25*cosa_u(npx-1, 1)*&
2205 & (vt(npx-1, 1)+vt(npx-2, 1)+vt(npx-2, 2))))*damp
2211 damp = 1./(1.-0.0625*cosa_u(npx-1, npy)*cosa_v(npx-1, npy+1))
2212 ut(npx-1, npy) = (uc(npx-1, npy)-0.25*cosa_u(npx-1, npy)*(vt(&
2213 & npx-1, npy)+vt(npx-2, npy)+vt(npx-2, npy+1)+vc(npx-1, npy+1)&
2214 & -0.25*cosa_v(npx-1, npy+1)*(ut(npx, npy)+ut(npx, npy+1)+ut(&
2215 & npx-1, npy+1))))*damp
2216 damp = 1./(1.-0.0625*cosa_u(npx+1, npy-1)*cosa_v(npx, npy-1))
2217 vt(npx, npy-1) = (vc(npx, npy-1)-0.25*cosa_v(npx, npy-1)*(ut(&
2218 & npx, npy-1)+ut(npx, npy-2)+ut(npx+1, npy-2)+uc(npx+1, npy-1)&
2219 & -0.25*cosa_u(npx+1, npy-1)*(vt(npx, npy)+vt(npx+1, npy)+vt(&
2220 & npx+1, npy-1))))*damp
2221 damp = 1./(1.-0.0625*cosa_u(npx-1, npy-1)*cosa_v(npx-1, npy-1)&
2223 ut(npx-1, npy-1) = (uc(npx-1, npy-1)-0.25*cosa_u(npx-1, npy-1)&
2224 & *(vt(npx-1, npy)+vt(npx-2, npy)+vt(npx-2, npy-1)+vc(npx-1, &
2225 & npy-1)-0.25*cosa_v(npx-1, npy-1)*(ut(npx, npy-1)+ut(npx, npy&
2226 & -2)+ut(npx-1, npy-2))))*damp
2227 vt(npx-1, npy-1) = (vc(npx-1, npy-1)-0.25*cosa_v(npx-1, npy-1)&
2228 & *(ut(npx, npy-1)+ut(npx, npy-2)+ut(npx-1, npy-2)+uc(npx-1, &
2229 & npy-1)-0.25*cosa_u(npx-1, npy-1)*(vt(npx-1, npy)+vt(npx-2, &
2230 & npy)+vt(npx-2, npy-1))))*damp
2236 damp = 1./(1.-0.0625*cosa_u(2, npy)*cosa_v(1, npy+1))
2237 ut(2, npy) = (uc(2, npy)-0.25*cosa_u(2, npy)*(vt(1, npy)+vt(2&
2238 & , npy)+vt(2, npy+1)+vc(1, npy+1)-0.25*cosa_v(1, npy+1)*(ut(1&
2239 & , npy)+ut(1, npy+1)+ut(2, npy+1))))*damp
2240 damp = 1./(1.-0.0625*cosa_u(0, npy-1)*cosa_v(0, npy-1))
2241 vt(0, npy-1) = (vc(0, npy-1)-0.25*cosa_v(0, npy-1)*(ut(1, npy-&
2242 & 1)+ut(1, npy-2)+ut(0, npy-2)+uc(0, npy-1)-0.25*cosa_u(0, npy&
2243 & -1)*(vt(0, npy)+vt(-1, npy)+vt(-1, npy-1))))*damp
2244 damp = 1./(1.-0.0625*cosa_u(2, npy-1)*cosa_v(1, npy-1))
2245 ut(2, npy-1) = (uc(2, npy-1)-0.25*cosa_u(2, npy-1)*(vt(1, npy)&
2246 & +vt(2, npy)+vt(2, npy-1)+vc(1, npy-1)-0.25*cosa_v(1, npy-1)*&
2247 & (ut(1, npy-1)+ut(1, npy-2)+ut(2, npy-2))))*damp
2248 vt(1, npy-1) = (vc(1, npy-1)-0.25*cosa_v(1, npy-1)*(ut(1, npy-&
2249 & 1)+ut(1, npy-2)+ut(2, npy-2)+uc(2, npy-1)-0.25*cosa_u(2, npy&
2250 & -1)*(vt(1, npy)+vt(2, npy)+vt(2, npy-1))))*damp
2275 xfx_adv(i, j) = dt*ut(i, j)
2281 yfx_adv(i, j) = dt*vt(i, j)
2290 IF (xfx_adv(i, j) .GT. 0.)
THEN 2292 crx_adv(i, j) = xfx_adv(i, j)*rdxa(i-1, j)
2294 xfx_adv(i, j) = dy(i, j)*xfx_adv(i, j)*sin_sg(i-1, j, 3)
2298 crx_adv(i, j) = xfx_adv(i, j)*rdxa(i, j)
2300 xfx_adv(i, j) = dy(i, j)*xfx_adv(i, j)*sin_sg(i, j, 1)
2308 IF (yfx_adv(i, j) .GT. 0.)
THEN 2310 cry_adv(i, j) = yfx_adv(i, j)*rdya(i, j-1)
2312 yfx_adv(i, j) = dx(i, j)*yfx_adv(i, j)*sin_sg(i, j-1, 4)
2316 cry_adv(i, j) = yfx_adv(i, j)*rdya(i, j)
2318 yfx_adv(i, j) = dx(i, j)*yfx_adv(i, j)*sin_sg(i, j, 2)
2325 ra_x(i, j) = area(i, j) + (xfx_adv(i, j)-xfx_adv(i+1, j))
2330 ra_y(i, j) = area(i, j) + (yfx_adv(i, j)-yfx_adv(i, j+1))
2333 IF (hord_dp .EQ. hord_dp_pert .AND. (.NOT.split_damp))
THEN 2334 CALL fv_tp_2d_fwd(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx&
2335 & , fy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y&
2336 & , nord=nord_v, damp_c=damp_v)
2341 CALL pushrealarray(delp, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2342 CALL fv_tp_2d(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx, &
2343 & fy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, nord=&
2344 & nord_v, damp_c=damp_v)
2350 cx(i, j) = cx(i, j) + crx_adv(i, j)
2355 xflux(i, j) = xflux(i, j) + fx(i, j)
2360 cy(i, j) = cy(i, j) + cry_adv(i, j)
2363 yflux(i, j) = yflux(i, j) + fy(i, j)
2368 heat_source(i, j) = 0.
2371 IF (.NOT.hydrostatic)
THEN 2372 IF (damp_w .GT. 1.e-5)
THEN 2373 IF (dt .GE. 0.)
THEN 2379 damp4 = (damp_w*gridstruct%da_min_c)**(nord_w+1)
2380 CALL del6_vt_flux(nord_w, npx, npy, damp4, w, wk, fx2, fy2, &
2384 dw(i, j) = (fx2(i, j)-fx2(i+1, j)+(fy2(i, j)-fy2(i, j+1)))*&
2388 heat_source(i, j) = dd8 - dw(i, j)*(w(i, j)+0.5*dw(i, j))
2395 IF (hord_vt .EQ. hord_vt_pert)
THEN 2396 CALL fv_tp_2d_fwd(w, crx_adv, cry_adv, npx, npy, hord_vt, gx&
2397 & , gy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, &
2398 & ra_y, mfx=fx, mfy=fy)
2404 CALL fv_tp_2d(w, crx_adv, cry_adv, npx, npy, hord_vt, gx, &
2405 & gy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, mfx=fx&
2412 w(i, j) = delp(i, j)*w(i, j) + (gx(i, j)-gx(i+1, j)+(gy(i, j)-&
2413 & gy(i, j+1)))*rarea(i, j)
2427 IF (hord_tm .EQ. hord_tm_pert .AND. (.NOT.split_damp))
THEN 2428 CALL fv_tp_2d_fwd(pt, crx_adv, cry_adv, npx, npy, hord_tm, gx, &
2429 & gy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, &
2430 & mfx=fx, mfy=fy, mass=delp, nord=nord_t, damp_c=&
2437 CALL fv_tp_2d(pt, crx_adv, cry_adv, npx, npy, hord_tm, gx, gy&
2438 & , xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, mfx=fx, &
2439 & mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
2445 wk(i, j) = delp(i, j)
2447 delp(i, j) = wk(i, j) + (fx(i, j)-fx(i+1, j)+(fy(i, j)-fy(i, j&
2450 pt(i, j) = (pt(i, j)*wk(i, j)+(gx(i, j)-gx(i+1, j)+(gy(i, j)-&
2451 & gy(i, j+1)))*rarea(i, j))/delp(i, j)
2455 IF (hord_tr .EQ. hord_tr_pert)
THEN 2456 CALL fv_tp_2d_fwd(q(isd:ied, jsd:jed, k, iq), crx_adv, &
2457 & cry_adv, npx, npy, hord_tr, gx, gy, xfx_adv, &
2458 & yfx_adv, gridstruct, bd, ra_x, ra_y, mfx=fx, &
2459 & mfy=fy, mass=delp, nord=nord_t, damp_c=damp_t)
2464 CALL pushrealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)*(&
2466 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), crx_adv, cry_adv, &
2467 & npx, npy, hord_tr, gx, gy, xfx_adv, yfx_adv, &
2468 & gridstruct, bd, ra_x, ra_y, mfx=fx, mfy=fy, mass=delp&
2469 & , nord=nord_t, damp_c=damp_t)
2475 q(i, j, k, iq) = (q(i, j, k, iq)*wk(i, j)+(gx(i, j)-gx(i+1, &
2476 & j)+(gy(i, j)-gy(i, j+1)))*rarea(i, j))/delp(i, j)
2492 pt(i, j) = pt(i, j)*delp(i, j) + (gx(i, j)-gx(i+1, j)+(gy(i, j&
2493 & )-gy(i, j+1)))*rarea(i, j)
2495 delp(i, j) = delp(i, j) + (fx(i, j)-fx(i+1, j)+(fy(i, j)-fy(i&
2496 & , j+1)))*rarea(i, j)
2498 pt(i, j) = pt(i, j)/delp(i, j)
2503 IF (
fpp%fpp_overload_r4)
THEN 2506 dpx(i, j) = dpx(i, j) + (fx(i, j)-fx(i+1, j)+(fy(i, j)-fy(i, j&
2532 IF (npx - 1 .GT. ie + 1)
THEN 2542 IF (npy - 1 .GT. je + 1)
THEN 2551 IF (flagstruct%grid_type .LT. 3)
THEN 2555 vb(i, j) = dt5*(vc(i-1, j)+vc(i, j)-(uc(i, j-1)+uc(i, j))*&
2556 & cosa(i, j))*rsina(i, j)
2564 vb(i, 1) = dt5*(vt(i-1, 1)+vt(i, 1))
2572 vb(i, j) = dt5*(vc(i-1, j)+vc(i, j)-(uc(i, j-1)+uc(i, j))*&
2573 & cosa(i, j))*rsina(i, j)
2577 vb(1, j) = dt4*(-vt(-1, j)+3.*(vt(0, j)+vt(1, j))-vt(2, j))
2582 IF (ie + 1 .EQ. npx)
THEN 2584 vb(npx, j) = dt4*(-vt(npx-2, j)+3.*(vt(npx-1, j)+vt(npx, j))&
2591 IF (je + 1 .EQ. npy)
THEN 2594 vb(i, npy) = dt5*(vt(i-1, npy)+vt(i, npy))
2604 vb(i, j) = dt5*(vc(i-1, j)+vc(i, j))
2609 IF (hord_mt .EQ. hord_mt_pert)
THEN 2610 CALL ytp_v_fwd(is, ie, js, je, isd, ied, jsd, jed, vb, u, v, ub&
2611 & , hord_mt, gridstruct%dy, gridstruct%rdy, npx, npy, &
2612 & flagstruct%grid_type, nested)
2615 CALL ytp_v(is, ie, js, je, isd, ied, jsd, jed, vb, u, v, ub, &
2616 & hord_mt, gridstruct%dy, gridstruct%rdy, npx, npy, &
2617 & flagstruct%grid_type, nested)
2622 ke(i, j) = vb(i, j)*ub(i, j)
2625 IF (flagstruct%grid_type .LT. 3)
THEN 2630 ub(i, j) = dt5*(uc(i, j-1)+uc(i, j)-(vc(i-1, j)+vc(i, j))*&
2631 & cosa(i, j))*rsina(i, j)
2640 ub(1, j) = dt5*(ut(1, j-1)+ut(1, j))
2647 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 2651 ub(i, j) = dt4*(-ut(i, j-2)+3.*(ut(i, j-1)+ut(i, j))-ut(i&
2658 ub(i, j) = dt5*(uc(i, j-1)+uc(i, j)-(vc(i-1, j)+vc(i, j))*&
2659 & cosa(i, j))*rsina(i, j)
2664 IF (ie + 1 .EQ. npx)
THEN 2668 ub(npx, j) = dt5*(ut(npx, j-1)+ut(npx, j))
2679 ub(i, j) = dt5*(uc(i, j-1)+uc(i, j))
2684 IF (hord_mt .EQ. hord_mt_pert)
THEN 2685 CALL xtp_u_fwd(is, ie, js, je, isd, ied, jsd, jed, ub, u, v, vb&
2686 & , hord_mt, gridstruct%dx, gridstruct%rdx, npx, npy, &
2687 & flagstruct%grid_type, nested)
2691 CALL xtp_u(is, ie, js, je, isd, ied, jsd, jed, ub, u, v, vb, &
2692 & hord_mt, gridstruct%dx, gridstruct%rdx, npx, npy, &
2693 & flagstruct%grid_type, nested)
2698 ke(i, j) = 0.5*(ke(i, j)+ub(i, j)*vb(i, j))
2704 IF (.NOT.nested)
THEN 2707 ke(1, 1) = dt6*((ut(1, 1)+ut(1, 0))*u(1, 1)+(vt(1, 1)+vt(0, 1))*&
2708 & v(1, 1)+(ut(1, 1)+vt(1, 1))*u(0, 1))
2715 ke(npx, 1) = dt6*((ut(npx, 1)+ut(npx, 0))*u(npx-1, 1)+(vt(npx, 1&
2716 & )+vt(npx-1, 1))*v(npx, 1)+(ut(npx, 1)-vt(npx-1, 1))*u(npx, 1))
2723 ke(npx, npy) = dt6*((ut(npx, npy)+ut(npx, npy-1))*u(npx-1, npy)+&
2724 & (vt(npx, npy)+vt(npx-1, npy))*v(npx, npy-1)+(ut(npx, npy-1)+vt&
2725 & (npx-1, npy))*u(npx, npy))
2732 ke(1, npy) = dt6*((ut(1, npy)+ut(1, npy-1))*u(1, npy)+(vt(1, npy&
2733 & )+vt(0, npy))*v(1, npy-1)+(ut(1, npy-1)-vt(1, npy))*u(0, npy))
2745 vt(i, j) = u(i, j)*dx(i, j)
2751 ut(i, j) = v(i, j)*dy(i, j)
2758 wk(i, j) = rarea(i, j)*(vt(i, j)-vt(i, j+1)+(ut(i+1, j)-ut(i, j)&
2762 IF (.NOT.hydrostatic)
THEN 2763 IF (flagstruct%do_f3d)
THEN 2769 w(i, j) = w(i, j)/delp(i, j)
2774 IF (damp_w .GT. 1.e-5)
THEN 2778 w(i, j) = w(i, j) + dw(i, j)
2964 IF (.NOT.split_damp)
THEN 2966 & dt, vort, ptc, delpc, ke, u, v, &
2967 & uc, vc, ua, va, divg_d, wk, &
2968 & gridstruct, flagstruct, bd)
2972 CALL pushrealarray(divg_d, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+2))
2975 CALL pushrealarray(delpc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2976 CALL pushrealarray(ptc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2977 CALL pushrealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2979 & , dddmp, dt, vort, ptc, delpc, ke, &
2980 & u, v, uc, vc, ua, va, divg_d, wk, &
2981 & gridstruct, flagstruct, bd)
2984 IF (d_con .GT. 1.e-5)
THEN 2988 ub(i, j) = vort(i, j) - vort(i+1, j)
2994 vb(i, j) = vort(i, j) - vort(i, j+1)
3002 IF (hydrostatic)
THEN 3005 vort(i, j) = wk(i, j) +
f0(i, j)
3009 ELSE IF (flagstruct%do_f3d)
THEN 3012 vort(i, j) = wk(i, j) +
f0(i, j)*z_rat(i, j)
3019 vort(i, j) = wk(i, j) +
f0(i, j)
3024 IF (hord_vt .EQ. hord_vt_pert)
THEN 3025 CALL fv_tp_2d_fwd(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx&
3026 & , fy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y)
3031 CALL pushrealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3032 CALL fv_tp_2d(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx, &
3033 & fy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y)
3039 u(i, j) = vt(i, j) + (ke(i, j)-ke(i+1, j)) + fy(i, j)
3045 v(i, j) = ut(i, j) + (ke(i, j)-ke(i, j+1)) - fx(i, j)
3050 IF (damp_v .GT. 1.e-5)
THEN 3051 damp4 = (damp_v*gridstruct%da_min_c)**(nord_v+1)
3054 CALL pushrealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3055 CALL del6_vt_flux(nord_v, npx, npy, damp4, wk, vort, ut, vt, &
3061 IF (damp_v_pert .GT. 1.e-5)
THEN 3062 damp4 = (damp_v_pert*gridstruct%da_min_c)**(nord_v_pert+1)
3065 CALL pushrealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3072 IF (d_con .GT. 1.e-5)
THEN 3076 ub(i, j) = (ub(i, j)+vt(i, j))*rdx(i, j)
3078 fy(i, j) = u(i, j)*rdx(i, j)
3080 gy(i, j) = fy(i, j)*ub(i, j)
3086 vb(i, j) = (vb(i, j)-ut(i, j))*rdy(i, j)
3088 fx(i, j) = v(i, j)*rdy(i, j)
3090 gx(i, j) = fx(i, j)*vb(i, j)
3099 u2 = fy(i, j) + fy(i, j+1)
3100 du2 = ub(i, j) + ub(i, j+1)
3101 v2 = fx(i, j) + fx(i+1, j)
3102 dv2 = vb(i, j) + vb(i+1, j)
3106 heat_source(i, j) = delp(i, j)*(heat_source(i, j)-damp*rsin2(i&
3107 & , j)*(ub(i, j)**2+ub(i, j+1)**2+vb(i, j)**2+vb(i+1, j)**2+2.&
3108 & *(gy(i, j)+gy(i, j+1)+gx(i, j)+gx(i+1, j))-cosa_s(i, j)*(
u2*&
3109 & dv2+v2*du2+du2*dv2)))
3117 IF (damp_v .GT. 1.e-5)
THEN 3121 u(i, j) = u(i, j) + vt(i, j)
3127 v(i, j) = v(i, j) - ut(i, j)
3134 IF (damp_v_pert .GT. 1.e-5)
THEN 3163 CALL pushrealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3211 CALL pushrealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3269 SUBROUTINE d_sw_bwd(delpc, delpc_ad, delp, delp_ad, ptc, ptc_ad, pt, &
3270 & pt_ad, u, u_ad, v, v_ad, w, w_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, &
3271 & va, va_ad, divg_d, divg_d_ad, xflux, xflux_ad, yflux, yflux_ad, cx, &
3272 & cx_ad, cy, cy_ad, crx_adv, crx_adv_ad, cry_adv, cry_adv_ad, xfx_adv&
3273 & , xfx_adv_ad, yfx_adv, yfx_adv_ad, q_con, z_rat, z_rat_ad, kgb, &
3274 & heat_source, heat_source_ad, dpx, dpx_ad, zvir, sphum, nq, q, q_ad, &
3275 & k, km, inline_q, dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, &
3276 & nord, nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, &
3277 & damp_t, d_con, hydrostatic, gridstruct, flagstruct, bd, hord_tr_pert&
3278 & , hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp&
3279 & , nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, &
3280 & d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
3284 INTEGER,
INTENT(IN) :: hord_tr, hord_mt, hord_vt, hord_tm, hord_dp
3285 INTEGER,
INTENT(IN) :: nord
3286 INTEGER,
INTENT(IN) :: nord_v
3287 INTEGER,
INTENT(IN) :: nord_w
3288 INTEGER,
INTENT(IN) :: nord_t
3289 INTEGER,
INTENT(IN) :: sphum, nq, k, km
3290 REAL,
INTENT(IN) :: dt, dddmp, d2_bg, d4_bg, d_con
3291 REAL,
INTENT(IN) :: zvir
3292 REAL,
INTENT(IN) :: damp_v, damp_w, damp_t, kgb
3294 INTEGER,
INTENT(IN) :: hord_tr_pert, hord_mt_pert, hord_vt_pert, &
3295 & hord_tm_pert, hord_dp_pert, nord_pert, nord_v_pert, nord_w_pert, &
3297 LOGICAL,
INTENT(IN) :: split_damp
3298 REAL,
INTENT(IN) :: dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert&
3299 & , damp_w_pert, damp_t_pert
3300 REAL,
INTENT(INOUT) :: divg_d(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
3301 REAL,
INTENT(INOUT) :: divg_d_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
3302 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: z_rat
3303 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: z_rat_ad
3304 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: delp&
3306 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
3307 & delp_ad, pt_ad, ua_ad, va_ad
3308 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w
3309 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w_ad
3310 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
3312 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: u&
3314 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
3316 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: v&
3318 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: &
3320 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, km, nq)
3321 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed, km, nq)
3322 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc, ptc
3323 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: delpc_ad, ptc_ad
3324 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: heat_source
3325 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: heat_source_ad
3326 REAL(kind=8),
DIMENSION(bd%is:bd%ie, bd%js:bd%je),
INTENT(INOUT) :: &
3328 REAL(kind=8),
DIMENSION(bd%is:bd%ie, bd%js:bd%je),
INTENT(INOUT) :: &
3330 REAL,
INTENT(INOUT) :: xflux(bd%is:bd%ie+1, bd%js:bd%je)
3331 REAL,
INTENT(INOUT) :: xflux_ad(bd%is:bd%ie+1, bd%js:bd%je)
3332 REAL,
INTENT(INOUT) :: yflux(bd%is:bd%ie, bd%js:bd%je+1)
3333 REAL,
INTENT(INOUT) :: yflux_ad(bd%is:bd%ie, bd%js:bd%je+1)
3334 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed)
3335 REAL,
INTENT(INOUT) :: cx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed)
3336 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1)
3337 REAL,
INTENT(INOUT) :: cy_ad(bd%isd:bd%ied, bd%js:bd%je+1)
3338 LOGICAL,
INTENT(IN) :: hydrostatic
3339 LOGICAL,
INTENT(IN) :: inline_q
3340 REAL,
DIMENSION(bd%is:bd%ie+1, bd%jsd:bd%jed) :: crx_adv, xfx_adv
3341 REAL,
DIMENSION(bd%is:bd%ie+1, bd%jsd:bd%jed) :: crx_adv_ad, &
3343 REAL,
DIMENSION(bd%isd:bd%ied, bd%js:bd%je+1) :: cry_adv, yfx_adv
3344 REAL,
DIMENSION(bd%isd:bd%ied, bd%js:bd%je+1) :: cry_adv_ad, &
3348 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
3349 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
3350 REAL :: ut_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed)
3351 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
3352 REAL :: vt_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1)
3353 REAL :: fx2(bd%isd:bd%ied+1, bd%jsd:bd%jed)
3354 REAL :: fx2_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed)
3355 REAL :: fy2(bd%isd:bd%ied, bd%jsd:bd%jed+1)
3356 REAL :: fy2_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1)
3357 REAL :: dw(bd%is:bd%ie, bd%js:bd%je)
3358 REAL :: dw_ad(bd%is:bd%ie, bd%js:bd%je)
3359 REAL,
DIMENSION(bd%is:bd%ie+1, bd%js:bd%je+1) :: ub, vb
3360 REAL,
DIMENSION(bd%is:bd%ie+1, bd%js:bd%je+1) :: ub_ad, vb_ad
3361 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
3362 REAL :: wk_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
3363 REAL :: ke(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
3364 REAL :: ke_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
3365 REAL :: vort(bd%isd:bd%ied, bd%jsd:bd%jed)
3366 REAL :: vort_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
3367 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
3368 REAL :: fx_ad(bd%is:bd%ie+1, bd%js:bd%je)
3369 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
3370 REAL :: fy_ad(bd%is:bd%ie, bd%js:bd%je+1)
3371 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
3372 REAL :: ra_x_ad(bd%is:bd%ie, bd%jsd:bd%jed)
3373 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
3374 REAL :: ra_y_ad(bd%isd:bd%ied, bd%js:bd%je)
3375 REAL :: gx(bd%is:bd%ie+1, bd%js:bd%je)
3376 REAL :: gx_ad(bd%is:bd%ie+1, bd%js:bd%je)
3377 REAL :: gy(bd%is:bd%ie, bd%js:bd%je+1)
3378 REAL :: gy_ad(bd%is:bd%ie, bd%js:bd%je+1)
3380 REAL :: dt2, dt4, dt5, dt6
3381 REAL :: damp, damp2, damp4, dd8,
u2, v2, du2, dv2
3382 REAL :: u2_ad, v2_ad, du2_ad, dv2_ad
3384 INTEGER :: i, j, is2, ie1, js2, je1, n, nt, n2, iq
3385 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
3386 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
3387 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
3388 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
3389 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
3390 REAL,
DIMENSION(:, :),
POINTER ::
f0, rsin2, divg_u, divg_v
3391 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
3393 INTEGER :: is, ie, js, je
3394 INTEGER :: isd, ied, jsd, jed
3397 REAL :: delp_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
3398 REAL :: pt_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
3399 REAL :: vort_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
3400 REAL :: wk_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
3401 REAL :: delpc_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
3402 REAL :: ptc_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
3403 REAL :: ke_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
3404 REAL :: vc_tj(bd%isd:bd%ied, bd%jsd:bd%jed+1)
3405 REAL :: uc_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed)
3406 REAL :: divg_d_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
3407 REAL :: ut_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed)
3408 REAL :: vt_tj(bd%isd:bd%ied, bd%jsd:bd%jed+1)
3586 npx = flagstruct%npx
3587 npy = flagstruct%npy
3588 nested = gridstruct%nested
3589 area => gridstruct%area
3590 rarea => gridstruct%rarea
3591 sin_sg => gridstruct%sin_sg
3592 cosa_u => gridstruct%cosa_u
3593 cosa_v => gridstruct%cosa_v
3594 cosa_s => gridstruct%cosa_s
3595 rsin_u => gridstruct%rsin_u
3596 rsin_v => gridstruct%rsin_v
3597 rsina => gridstruct%rsina
3599 rsin2 => gridstruct%rsin2
3600 cosa => gridstruct%cosa
3603 rdxa => gridstruct%rdxa
3604 rdya => gridstruct%rdya
3605 rdx => gridstruct%rdx
3606 rdy => gridstruct%rdy
3607 sw_corner = gridstruct%sw_corner
3608 se_corner = gridstruct%se_corner
3609 nw_corner = gridstruct%nw_corner
3610 ne_corner = gridstruct%ne_corner
3612 IF (branch .EQ. 0)
THEN 3631 rdya => gridstruct%rdya
3634 cosa_u => gridstruct%cosa_u
3636 cosa_v => gridstruct%cosa_v
3638 cosa => gridstruct%cosa
3639 CALL poprealarray(ut, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1))
3642 sin_sg => gridstruct%sin_sg
3646 CALL poprealarray(ra_x, (bd%ie-bd%is+1)*(bd%jed-bd%jsd+1))
3648 CALL poprealarray(ra_y, (bd%ied-bd%isd+1)*(bd%je-bd%js+1))
3649 CALL poprealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3651 rsin_u => gridstruct%rsin_u
3654 rsina => gridstruct%rsina
3656 rdx => gridstruct%rdx
3657 CALL poprealarray(vt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2))
3668 rdxa => gridstruct%rdxa
3669 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3691 rdya => gridstruct%rdya
3694 cosa_u => gridstruct%cosa_u
3696 cosa_v => gridstruct%cosa_v
3698 cosa => gridstruct%cosa
3699 CALL poprealarray(ut, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1))
3702 sin_sg => gridstruct%sin_sg
3706 CALL poprealarray(ra_x, (bd%ie-bd%is+1)*(bd%jed-bd%jsd+1))
3708 CALL poprealarray(ra_y, (bd%ied-bd%isd+1)*(bd%je-bd%js+1))
3709 CALL poprealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3711 rsin_u => gridstruct%rsin_u
3714 rsina => gridstruct%rsina
3716 rdx => gridstruct%rdx
3717 CALL poprealarray(vt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2))
3728 rdxa => gridstruct%rdxa
3729 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3734 ut_ad(i, j) = ut_ad(i, j) - v_ad(i, j)
3741 vt_ad(i, j) = vt_ad(i, j) + u_ad(i, j)
3746 IF (branch .EQ. 0)
THEN 3760 rsin2 => gridstruct%rsin2
3761 cosa_s => gridstruct%cosa_s
3763 IF (branch .EQ. 0)
THEN 3772 dv2 = vb(i, j) + vb(i+1, j)
3773 v2 = fx(i, j) + fx(i+1, j)
3774 du2 = ub(i, j) + ub(i, j+1)
3775 u2 = fy(i, j) + fy(i, j+1)
3777 temp0 = damp*rsin2(i, j)
3778 temp_ad88 = delp(i, j)*heat_source_ad(i, j)
3779 temp_ad89 = -(temp0*temp_ad88)
3780 temp_ad90 = 2.*temp_ad89
3781 temp_ad91 = -(cosa_s(i, j)*temp_ad89)
3782 delp_ad(i, j) = delp_ad(i, j) + (heat_source(i, j)-temp0*(ub(i&
3783 & , j)**2+ub(i, j+1)**2+vb(i, j)**2+vb(i+1, j)**2+2.*(gy(i, j)&
3784 & +gy(i, j+1)+gx(i, j)+gx(i+1, j))-cosa_s(i, j)*(
u2*dv2+v2*du2&
3785 & +du2*dv2)))*heat_source_ad(i, j)
3786 ub_ad(i, j) = ub_ad(i, j) + 2*ub(i, j)*temp_ad89
3787 ub_ad(i, j+1) = ub_ad(i, j+1) + 2*ub(i, j+1)*temp_ad89
3788 vb_ad(i, j) = vb_ad(i, j) + 2*vb(i, j)*temp_ad89
3789 vb_ad(i+1, j) = vb_ad(i+1, j) + 2*vb(i+1, j)*temp_ad89
3790 gy_ad(i, j) = gy_ad(i, j) + temp_ad90
3791 gy_ad(i, j+1) = gy_ad(i, j+1) + temp_ad90
3792 gx_ad(i, j) = gx_ad(i, j) + temp_ad90
3793 gx_ad(i+1, j) = gx_ad(i+1, j) + temp_ad90
3794 u2_ad = dv2*temp_ad91
3795 dv2_ad = (du2+
u2)*temp_ad91
3796 v2_ad = du2*temp_ad91
3797 du2_ad = (dv2+v2)*temp_ad91
3798 heat_source_ad(i, j) = temp_ad88
3799 vb_ad(i, j) = vb_ad(i, j) + dv2_ad
3800 vb_ad(i+1, j) = vb_ad(i+1, j) + dv2_ad
3801 fx_ad(i, j) = fx_ad(i, j) + v2_ad
3802 fx_ad(i+1, j) = fx_ad(i+1, j) + v2_ad
3803 ub_ad(i, j) = ub_ad(i, j) + du2_ad
3804 ub_ad(i, j+1) = ub_ad(i, j+1) + du2_ad
3805 fy_ad(i, j) = fy_ad(i, j) + u2_ad
3806 fy_ad(i, j+1) = fy_ad(i, j+1) + u2_ad
3809 rdy => gridstruct%rdy
3813 fx_ad(i, j) = fx_ad(i, j) + vb(i, j)*gx_ad(i, j)
3814 vb_ad(i, j) = vb_ad(i, j) + fx(i, j)*gx_ad(i, j)
3817 v_ad(i, j) = v_ad(i, j) + rdy(i, j)*fx_ad(i, j)
3820 temp_ad87 = rdy(i, j)*vb_ad(i, j)
3821 ut_ad(i, j) = ut_ad(i, j) - temp_ad87
3822 vb_ad(i, j) = temp_ad87
3828 fy_ad(i, j) = fy_ad(i, j) + ub(i, j)*gy_ad(i, j)
3829 ub_ad(i, j) = ub_ad(i, j) + fy(i, j)*gy_ad(i, j)
3832 u_ad(i, j) = u_ad(i, j) + rdx(i, j)*fy_ad(i, j)
3835 temp_ad86 = rdx(i, j)*ub_ad(i, j)
3836 vt_ad(i, j) = vt_ad(i, j) + temp_ad86
3837 ub_ad(i, j) = temp_ad86
3849 IF (branch .EQ. 0)
THEN 3850 damp4 = (damp_v_pert*gridstruct%da_min_c)**(nord_v_pert+1)
3851 npx = flagstruct%npx
3852 npy = flagstruct%npy
3853 CALL poprealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3854 CALL poprealarray(ut, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1))
3855 CALL poprealarray(vt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2))
3859 & vort, vort_ad, ut, ut_ad, vt, vt_ad, gridstruct, &
3866 IF (branch .EQ. 0)
THEN 3867 damp4 = (damp_v*gridstruct%da_min_c)**(nord_v+1)
3868 CALL poprealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3869 CALL poprealarray(ut, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1))
3870 CALL poprealarray(vt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2))
3878 ut_ad(i, j) = ut_ad(i, j) + v_ad(i, j)
3879 ke_ad(i, j) = ke_ad(i, j) + v_ad(i, j)
3880 ke_ad(i, j+1) = ke_ad(i, j+1) - v_ad(i, j)
3881 fx_ad(i, j) = fx_ad(i, j) - v_ad(i, j)
3888 vt_ad(i, j) = vt_ad(i, j) + u_ad(i, j)
3889 ke_ad(i, j) = ke_ad(i, j) + u_ad(i, j)
3890 fy_ad(i, j) = fy_ad(i, j) + u_ad(i, j)
3891 ke_ad(i+1, j) = ke_ad(i+1, j) - u_ad(i, j)
3896 IF (branch .EQ. 0)
THEN 3897 CALL poprealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3902 CALL fv_tp_2d_adm(vort, vort_ad, crx_adv, crx_adv_ad, cry_adv, &
3903 & cry_adv_ad, npx, npy, hord_vt_pert, fx, fx_ad, fy, &
3904 & fy_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
3905 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad)
3909 CALL fv_tp_2d_bwd(vort, vort_ad, crx_adv, crx_adv_ad, cry_adv, &
3910 & cry_adv_ad, npx, npy, hord_vt, fx, fx_ad, fy, fy_ad&
3911 & , xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
3912 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad)
3920 IF (branch .EQ. 0)
THEN 3923 wk_ad(i, j) = wk_ad(i, j) + vort_ad(i, j)
3927 ELSE IF (branch .EQ. 1)
THEN 3930 wk_ad(i, j) = wk_ad(i, j) + vort_ad(i, j)
3931 z_rat_ad(i, j) = z_rat_ad(i, j) +
f0(i, j)*vort_ad(i, j)
3938 wk_ad(i, j) = wk_ad(i, j) + vort_ad(i, j)
3944 IF (branch .EQ. 0)
THEN 3948 vort_ad(i, j) = vort_ad(i, j) + vb_ad(i, j)
3949 vort_ad(i, j+1) = vort_ad(i, j+1) - vb_ad(i, j)
3956 vort_ad(i, j) = vort_ad(i, j) + ub_ad(i, j)
3957 vort_ad(i+1, j) = vort_ad(i+1, j) - ub_ad(i, j)
3963 IF (branch .EQ. 0)
THEN 3965 & dt, vort, vort_ad, ptc, ptc_ad, &
3966 & delpc, delpc_ad, ke, ke_ad, u, &
3967 & u_ad, v, v_ad, uc, uc_ad, vc, &
3968 & vc_ad, ua, ua_ad, va, va_ad, &
3969 & divg_d, divg_d_ad, wk, wk_ad, &
3970 & gridstruct, flagstruct, bd)
3972 CALL poprealarray(vort, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3973 CALL poprealarray(ptc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3974 CALL poprealarray(delpc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3975 CALL poprealarray(uc, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1))
3976 CALL poprealarray(vc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2))
3977 CALL poprealarray(divg_d, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+2))
3978 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
3980 & d4_bg_pert, dddmp_pert, dt, vort, &
3981 & vort_ad, ptc, ptc_ad, delpc, &
3982 & delpc_ad, ke, ke_ad, u, u_ad, v, &
3983 & v_ad, uc, uc_ad, vc, vc_ad, ua, &
3984 & ua_ad, va, va_ad, divg_d, divg_d_ad&
3985 & , wk, wk_ad, gridstruct, flagstruct&
3989 IF (branch .EQ. 0)
THEN 3994 dw_ad(i, j) = dw_ad(i, j) + w_ad(i, j)
3997 ELSE IF (branch .EQ. 1)
THEN 4004 IF (branch .NE. 0)
THEN 4008 temp_ad85 = w_ad(i, j)/delp(i, j)
4009 delp_ad(i, j) = delp_ad(i, j) - w(i, j)*temp_ad85/delp(i, j)
4010 w_ad(i, j) = temp_ad85
4014 100 rarea => gridstruct%rarea
4018 temp_ad84 = rarea(i, j)*wk_ad(i, j)
4019 vt_ad(i, j) = vt_ad(i, j) + temp_ad84
4020 vt_ad(i, j+1) = vt_ad(i, j+1) - temp_ad84
4021 ut_ad(i+1, j) = ut_ad(i+1, j) + temp_ad84
4022 ut_ad(i, j) = ut_ad(i, j) - temp_ad84
4029 v_ad(i, j) = v_ad(i, j) + dy(i, j)*ut_ad(i, j)
4036 u_ad(i, j) = u_ad(i, j) + dx(i, j)*vt_ad(i, j)
4041 IF (branch .NE. 0)
THEN 4042 IF (branch .NE. 1)
THEN 4044 temp_ad80 = dt6*ke_ad(1, npy)
4045 temp_ad81 = u(1, npy)*temp_ad80
4046 temp_ad82 = v(1, npy-1)*temp_ad80
4047 temp_ad83 = u(0, npy)*temp_ad80
4048 ut_ad(1, npy) = ut_ad(1, npy) + temp_ad81
4049 ut_ad(1, npy-1) = ut_ad(1, npy-1) + temp_ad83 + temp_ad81
4050 u_ad(1, npy) = u_ad(1, npy) + (ut(1, npy)+ut(1, npy-1))*&
4052 vt_ad(1, npy) = vt_ad(1, npy) + temp_ad82 - temp_ad83
4053 vt_ad(0, npy) = vt_ad(0, npy) + temp_ad82
4054 v_ad(1, npy-1) = v_ad(1, npy-1) + (vt(1, npy)+vt(0, npy))*&
4056 u_ad(0, npy) = u_ad(0, npy) + (ut(1, npy-1)-vt(1, npy))*&
4061 IF (branch .EQ. 0)
THEN 4062 temp_ad76 = dt6*ke_ad(npx, npy)
4063 temp_ad77 = u(npx-1, npy)*temp_ad76
4064 temp_ad78 = v(npx, npy-1)*temp_ad76
4065 temp_ad79 = u(npx, npy)*temp_ad76
4066 ut_ad(npx, npy) = ut_ad(npx, npy) + temp_ad77
4067 ut_ad(npx, npy-1) = ut_ad(npx, npy-1) + temp_ad79 + temp_ad77
4068 u_ad(npx-1, npy) = u_ad(npx-1, npy) + (ut(npx, npy)+ut(npx, npy-&
4070 vt_ad(npx, npy) = vt_ad(npx, npy) + temp_ad78
4071 vt_ad(npx-1, npy) = vt_ad(npx-1, npy) + temp_ad79 + temp_ad78
4072 v_ad(npx, npy-1) = v_ad(npx, npy-1) + (vt(npx, npy)+vt(npx-1, &
4074 u_ad(npx, npy) = u_ad(npx, npy) + (ut(npx, npy-1)+vt(npx-1, npy)&
4076 ke_ad(npx, npy) = 0.0
4079 IF (branch .EQ. 0)
THEN 4080 temp_ad72 = dt6*ke_ad(npx, 1)
4081 temp_ad73 = u(npx-1, 1)*temp_ad72
4082 temp_ad74 = v(npx, 1)*temp_ad72
4083 temp_ad75 = u(npx, 1)*temp_ad72
4084 ut_ad(npx, 1) = ut_ad(npx, 1) + temp_ad75 + temp_ad73
4085 ut_ad(npx, 0) = ut_ad(npx, 0) + temp_ad73
4086 u_ad(npx-1, 1) = u_ad(npx-1, 1) + (ut(npx, 1)+ut(npx, 0))*&
4088 vt_ad(npx, 1) = vt_ad(npx, 1) + temp_ad74
4089 vt_ad(npx-1, 1) = vt_ad(npx-1, 1) + temp_ad74 - temp_ad75
4090 v_ad(npx, 1) = v_ad(npx, 1) + (vt(npx, 1)+vt(npx-1, 1))*&
4092 u_ad(npx, 1) = u_ad(npx, 1) + (ut(npx, 1)-vt(npx-1, 1))*&
4097 IF (branch .EQ. 0)
THEN 4098 temp_ad71 = dt6*ke_ad(1, 1)
4099 ut_ad(1, 1) = ut_ad(1, 1) + (u(0, 1)+u(1, 1))*temp_ad71
4100 ut_ad(1, 0) = ut_ad(1, 0) + u(1, 1)*temp_ad71
4101 u_ad(1, 1) = u_ad(1, 1) + (ut(1, 1)+ut(1, 0))*temp_ad71
4102 vt_ad(1, 1) = vt_ad(1, 1) + (u(0, 1)+v(1, 1))*temp_ad71
4103 vt_ad(0, 1) = vt_ad(0, 1) + v(1, 1)*temp_ad71
4104 v_ad(1, 1) = v_ad(1, 1) + (vt(1, 1)+vt(0, 1))*temp_ad71
4105 u_ad(0, 1) = u_ad(0, 1) + (ut(1, 1)+vt(1, 1))*temp_ad71
4109 nested = gridstruct%nested
4112 temp_ad70 = 0.5*ke_ad(i, j)
4113 ub_ad(i, j) = ub_ad(i, j) + vb(i, j)*temp_ad70
4114 vb_ad(i, j) = vb_ad(i, j) + ub(i, j)*temp_ad70
4115 ke_ad(i, j) = temp_ad70
4119 IF (branch .EQ. 0)
THEN 4121 CALL xtp_u_adm(is, ie, js, je, isd, ied, jsd, jed, ub, ub_ad, u, &
4122 & u_ad, v, vb, vb_ad, hord_mt_pert, gridstruct%dx, &
4123 & gridstruct%rdx, npx, npy, flagstruct%grid_type, nested)
4125 CALL xtp_u_bwd(is, ie, js, je, isd, ied, jsd, jed, ub, ub_ad, u&
4126 & , u_ad, v, vb, vb_ad, hord_mt, gridstruct%dx, &
4127 & gridstruct%rdx, npx, npy, flagstruct%grid_type, nested&
4132 IF (branch .LT. 2)
THEN 4133 IF (branch .EQ. 0)
THEN 4137 temp_ad65 = dt5*rsina(i, j)*ub_ad(i, j)
4138 temp_ad66 = -(cosa(i, j)*temp_ad65)
4139 uc_ad(i, j-1) = uc_ad(i, j-1) + temp_ad65
4140 uc_ad(i, j) = uc_ad(i, j) + temp_ad65
4141 vc_ad(i-1, j) = vc_ad(i-1, j) + temp_ad66
4142 vc_ad(i, j) = vc_ad(i, j) + temp_ad66
4150 ut_ad(npx, j-1) = ut_ad(npx, j-1) + dt5*ub_ad(npx, j)
4151 ut_ad(npx, j) = ut_ad(npx, j) + dt5*ub_ad(npx, j)
4155 ELSE IF (branch .NE. 2)
THEN 4159 uc_ad(i, j-1) = uc_ad(i, j-1) + dt5*ub_ad(i, j)
4160 uc_ad(i, j) = uc_ad(i, j) + dt5*ub_ad(i, j)
4166 cosa => gridstruct%cosa
4168 rsina => gridstruct%rsina
4171 IF (branch .EQ. 0)
THEN 4174 temp_ad68 = dt5*rsina(i, j)*ub_ad(i, j)
4175 temp_ad69 = -(cosa(i, j)*temp_ad68)
4176 uc_ad(i, j-1) = uc_ad(i, j-1) + temp_ad68
4177 uc_ad(i, j) = uc_ad(i, j) + temp_ad68
4178 vc_ad(i-1, j) = vc_ad(i-1, j) + temp_ad69
4179 vc_ad(i, j) = vc_ad(i, j) + temp_ad69
4185 temp_ad67 = dt4*ub_ad(i, j)
4186 ut_ad(i, j-1) = ut_ad(i, j-1) + 3.*temp_ad67
4187 ut_ad(i, j) = ut_ad(i, j) + 3.*temp_ad67
4188 ut_ad(i, j-2) = ut_ad(i, j-2) - temp_ad67
4189 ut_ad(i, j+1) = ut_ad(i, j+1) - temp_ad67
4195 IF (branch .NE. 0)
THEN 4198 ut_ad(1, j-1) = ut_ad(1, j-1) + dt5*ub_ad(1, j)
4199 ut_ad(1, j) = ut_ad(1, j) + dt5*ub_ad(1, j)
4205 vb_ad(i, j) = vb_ad(i, j) + ub(i, j)*ke_ad(i, j)
4206 ub_ad(i, j) = ub_ad(i, j) + vb(i, j)*ke_ad(i, j)
4211 IF (branch .EQ. 0)
THEN 4212 CALL ytp_v_adm(is, ie, js, je, isd, ied, jsd, jed, vb, vb_ad, u, v&
4213 & , v_ad, ub, ub_ad, hord_mt_pert, gridstruct%dy, &
4214 & gridstruct%rdy, npx, npy, flagstruct%grid_type, nested)
4216 CALL ytp_v_bwd(is, ie, js, je, isd, ied, jsd, jed, vb, vb_ad, u&
4217 & , v, v_ad, ub, ub_ad, hord_mt, gridstruct%dy, &
4218 & gridstruct%rdy, npx, npy, flagstruct%grid_type, nested&
4222 IF (branch .LT. 2)
THEN 4223 IF (branch .EQ. 0)
THEN 4226 temp_ad59 = dt5*rsina(i, j)*vb_ad(i, j)
4227 temp_ad60 = -(cosa(i, j)*temp_ad59)
4228 vc_ad(i-1, j) = vc_ad(i-1, j) + temp_ad59
4229 vc_ad(i, j) = vc_ad(i, j) + temp_ad59
4230 uc_ad(i, j-1) = uc_ad(i, j-1) + temp_ad60
4231 uc_ad(i, j) = uc_ad(i, j) + temp_ad60
4238 vt_ad(i-1, npy) = vt_ad(i-1, npy) + dt5*vb_ad(i, npy)
4239 vt_ad(i, npy) = vt_ad(i, npy) + dt5*vb_ad(i, npy)
4243 ELSE IF (branch .NE. 2)
THEN 4246 vc_ad(i-1, j) = vc_ad(i-1, j) + dt5*vb_ad(i, j)
4247 vc_ad(i, j) = vc_ad(i, j) + dt5*vb_ad(i, j)
4255 IF (branch .NE. 0)
THEN 4256 temp_ad64 = dt4*vb_ad(npx, j)
4257 vt_ad(npx-1, j) = vt_ad(npx-1, j) + 3.*temp_ad64
4258 vt_ad(npx, j) = vt_ad(npx, j) + 3.*temp_ad64
4259 vt_ad(npx-2, j) = vt_ad(npx-2, j) - temp_ad64
4260 vt_ad(npx+1, j) = vt_ad(npx+1, j) - temp_ad64
4264 IF (branch .EQ. 0)
THEN 4265 temp_ad63 = dt4*vb_ad(1, j)
4266 vt_ad(0, j) = vt_ad(0, j) + 3.*temp_ad63
4267 vt_ad(1, j) = vt_ad(1, j) + 3.*temp_ad63
4268 vt_ad(-1, j) = vt_ad(-1, j) - temp_ad63
4269 vt_ad(2, j) = vt_ad(2, j) - temp_ad63
4273 temp_ad61 = dt5*rsina(i, j)*vb_ad(i, j)
4274 temp_ad62 = -(cosa(i, j)*temp_ad61)
4275 vc_ad(i-1, j) = vc_ad(i-1, j) + temp_ad61
4276 vc_ad(i, j) = vc_ad(i, j) + temp_ad61
4277 uc_ad(i, j-1) = uc_ad(i, j-1) + temp_ad62
4278 uc_ad(i, j) = uc_ad(i, j) + temp_ad62
4283 IF (branch .NE. 0)
THEN 4285 vt_ad(i-1, 1) = vt_ad(i-1, 1) + dt5*vb_ad(i, 1)
4286 vt_ad(i, 1) = vt_ad(i, 1) + dt5*vb_ad(i, 1)
4292 IF (branch .EQ. 0)
THEN 4295 temp_ad58 = rarea(i, j)*dpx_ad(i, j)
4296 fx_ad(i, j) = fx_ad(i, j) + temp_ad58
4297 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad58
4298 fy_ad(i, j) = fy_ad(i, j) + temp_ad58
4299 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad58
4304 IF (branch .EQ. 0)
THEN 4309 temp_ad53 = q_ad(i, j, k, iq)/delp(i, j)
4310 temp = q(i, j, k, iq)
4311 temp_ad54 = rarea(i, j)*temp_ad53
4312 wk_ad(i, j) = wk_ad(i, j) + temp*temp_ad53
4313 gx_ad(i, j) = gx_ad(i, j) + temp_ad54
4314 gx_ad(i+1, j) = gx_ad(i+1, j) - temp_ad54
4315 gy_ad(i, j) = gy_ad(i, j) + temp_ad54
4316 gy_ad(i, j+1) = gy_ad(i, j+1) - temp_ad54
4317 delp_ad(i, j) = delp_ad(i, j) - (temp*wk(i, j)+rarea(i, j)*(&
4318 & gx(i, j)-gx(i+1, j)+gy(i, j)-gy(i, j+1)))*temp_ad53/delp(i&
4320 q_ad(i, j, k, iq) = wk(i, j)*temp_ad53
4324 IF (branch .EQ. 0)
THEN 4325 CALL poprealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)*(&
4329 CALL fv_tp_2d_adm(q(isd:ied, jsd:jed, k, iq), q_ad(isd:ied, &
4330 & jsd:jed, k, iq), crx_adv, crx_adv_ad, cry_adv, &
4331 & cry_adv_ad, npx, npy, hord_tr_pert, gx, gx_ad, gy&
4332 & , gy_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad&
4333 & , gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, &
4334 & mfx=fx, mfx_ad=fx_ad, mfy=fy, mfy_ad=fy_ad, mass=&
4335 & delp, mass_ad=delp_ad, nord=nord_t_pert, damp_c=&
4338 CALL fv_tp_2d_bwd(q(isd:ied, jsd:jed, k, iq), q_ad(isd:ied&
4339 & , jsd:jed, k, iq), crx_adv, crx_adv_ad, cry_adv&
4340 & , cry_adv_ad, npx, npy, hord_tr, gx, gx_ad, gy&
4341 & , gy_ad, xfx_adv, xfx_adv_ad, yfx_adv, &
4342 & yfx_adv_ad, gridstruct, bd, ra_x, ra_x_ad, ra_y&
4343 & , ra_y_ad, mfx=fx, mfx_ad=fx_ad, mfy=fy, mfy_ad=fy_ad&
4344 & , mass=delp, mass_ad=delp_ad, nord=nord_t, damp_c=&
4351 temp_ad50 = pt_ad(i, j)/delp(i, j)
4352 temp_ad51 = rarea(i, j)*temp_ad50
4353 gx_ad(i, j) = gx_ad(i, j) + temp_ad51
4354 gx_ad(i+1, j) = gx_ad(i+1, j) - temp_ad51
4355 gy_ad(i, j) = gy_ad(i, j) + temp_ad51
4356 gy_ad(i, j+1) = gy_ad(i, j+1) - temp_ad51
4357 delp_ad(i, j) = delp_ad(i, j) - (pt(i, j)*wk(i, j)+rarea(i, j)&
4358 & *(gx(i, j)-gx(i+1, j)+gy(i, j)-gy(i, j+1)))*temp_ad50/delp(i&
4360 wk_ad(i, j) = wk_ad(i, j) + delp_ad(i, j) + pt(i, j)*temp_ad50
4361 pt_ad(i, j) = wk(i, j)*temp_ad50
4363 temp_ad52 = rarea(i, j)*delp_ad(i, j)
4364 fx_ad(i, j) = fx_ad(i, j) + temp_ad52
4365 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad52
4366 fy_ad(i, j) = fy_ad(i, j) + temp_ad52
4367 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad52
4368 delp_ad(i, j) = wk_ad(i, j)
4376 temp_ad55 = pt_ad(i, j)/delp(i, j)
4377 delp_ad(i, j) = delp_ad(i, j) - pt(i, j)*temp_ad55/delp(i, j)
4378 pt_ad(i, j) = temp_ad55
4380 temp_ad56 = rarea(i, j)*delp_ad(i, j)
4381 fx_ad(i, j) = fx_ad(i, j) + temp_ad56
4382 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad56
4383 fy_ad(i, j) = fy_ad(i, j) + temp_ad56
4384 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad56
4386 temp_ad57 = rarea(i, j)*pt_ad(i, j)
4387 delp_ad(i, j) = delp_ad(i, j) + pt(i, j)*pt_ad(i, j)
4388 gx_ad(i, j) = gx_ad(i, j) + temp_ad57
4389 gx_ad(i+1, j) = gx_ad(i+1, j) - temp_ad57
4390 gy_ad(i, j) = gy_ad(i, j) + temp_ad57
4391 gy_ad(i, j+1) = gy_ad(i, j+1) - temp_ad57
4392 pt_ad(i, j) = delp(i, j)*pt_ad(i, j)
4397 IF (branch .EQ. 0)
THEN 4398 CALL fv_tp_2d_bwd(pt, pt_ad, crx_adv, crx_adv_ad, cry_adv, &
4399 & cry_adv_ad, npx, npy, hord_tm, gx, gx_ad, gy, gy_ad&
4400 & , xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
4401 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx=&
4402 & fx, mfx_ad=fx_ad, mfy=fy, mfy_ad=fy_ad, mass=delp, mass_ad=&
4403 & delp_ad, nord=nord_t, damp_c=damp_t)
4405 CALL poprealarray(pt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
4408 CALL fv_tp_2d_adm(pt, pt_ad, crx_adv, crx_adv_ad, cry_adv, &
4409 & cry_adv_ad, npx, npy, hord_tm_pert, gx, gx_ad, gy, &
4410 & gy_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
4411 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx=fx, &
4412 & mfx_ad=fx_ad, mfy=fy, mfy_ad=fy_ad, mass=delp, mass_ad&
4413 & =delp_ad, nord=nord_t_pert, damp_c=damp_t_pert)
4416 IF (branch .EQ. 0)
THEN 4420 temp_ad49 = rarea(i, j)*w_ad(i, j)
4421 delp_ad(i, j) = delp_ad(i, j) + w(i, j)*w_ad(i, j)
4422 gx_ad(i, j) = gx_ad(i, j) + temp_ad49
4423 gx_ad(i+1, j) = gx_ad(i+1, j) - temp_ad49
4424 gy_ad(i, j) = gy_ad(i, j) + temp_ad49
4425 gy_ad(i, j+1) = gy_ad(i, j+1) - temp_ad49
4426 w_ad(i, j) = delp(i, j)*w_ad(i, j)
4430 IF (branch .EQ. 0)
THEN 4431 CALL poprealarray(w, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
4434 CALL fv_tp_2d_adm(w, w_ad, crx_adv, crx_adv_ad, cry_adv, &
4435 & cry_adv_ad, npx, npy, hord_vt_pert, gx, gx_ad, gy, &
4436 & gy_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
4437 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx=fx&
4438 & , mfx_ad=fx_ad, mfy=fy, mfy_ad=fy_ad)
4440 CALL fv_tp_2d_bwd(w, w_ad, crx_adv, crx_adv_ad, cry_adv, &
4441 & cry_adv_ad, npx, npy, hord_vt, gx, gx_ad, gy, &
4442 & gy_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
4443 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx&
4444 & =fx, mfx_ad=fx_ad, mfy=fy, mfy_ad=fy_ad)
4447 IF (branch .EQ. 0)
THEN 4452 temp_ad47 = -(dw(i, j)*heat_source_ad(i, j))
4453 dw_ad(i, j) = dw_ad(i, j) + 0.5*temp_ad47 - (w(i, j)+0.5*dw(&
4454 & i, j))*heat_source_ad(i, j)
4455 w_ad(i, j) = w_ad(i, j) + temp_ad47
4456 heat_source_ad(i, j) = 0.0
4457 temp_ad48 = rarea(i, j)*dw_ad(i, j)
4458 fx2_ad(i, j) = fx2_ad(i, j) + temp_ad48
4459 fx2_ad(i+1, j) = fx2_ad(i+1, j) - temp_ad48
4460 fy2_ad(i, j) = fy2_ad(i, j) + temp_ad48
4461 fy2_ad(i, j+1) = fy2_ad(i, j+1) - temp_ad48
4465 damp4 = (damp_w*gridstruct%da_min_c)**(nord_w+1)
4467 & wk_ad, fx2, fx2_ad, fy2, fy2_ad, gridstruct, bd)
4472 heat_source_ad(i, j) = 0.0
4477 fy_ad(i, j) = fy_ad(i, j) + yflux_ad(i, j)
4480 cry_adv_ad(i, j) = cry_adv_ad(i, j) + cy_ad(i, j)
4485 fx_ad(i, j) = fx_ad(i, j) + xflux_ad(i, j)
4490 crx_adv_ad(i, j) = crx_adv_ad(i, j) + cx_ad(i, j)
4494 IF (branch .EQ. 0)
THEN 4495 CALL poprealarray(delp, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
4498 CALL fv_tp_2d_adm(delp, delp_ad, crx_adv, crx_adv_ad, cry_adv, &
4499 & cry_adv_ad, npx, npy, hord_dp_pert, fx, fx_ad, fy, &
4500 & fy_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
4501 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, nord=&
4502 & nord_v_pert, damp_c=damp_v_pert)
4504 CALL fv_tp_2d_bwd(delp, delp_ad, crx_adv, crx_adv_ad, cry_adv, &
4505 & cry_adv_ad, npx, npy, hord_dp, fx, fx_ad, fy, fy_ad&
4506 & , xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, &
4507 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, nord=&
4508 & nord_v, damp_c=damp_v)
4512 yfx_adv_ad(i, j) = yfx_adv_ad(i, j) + ra_y_ad(i, j)
4513 yfx_adv_ad(i, j+1) = yfx_adv_ad(i, j+1) - ra_y_ad(i, j)
4519 xfx_adv_ad(i, j) = xfx_adv_ad(i, j) + ra_x_ad(i, j)
4520 xfx_adv_ad(i+1, j) = xfx_adv_ad(i+1, j) - ra_x_ad(i, j)
4527 IF (branch .EQ. 0)
THEN 4529 yfx_adv_ad(i, j) = rdya(i, j)*cry_adv_ad(i, j) + sin_sg(i, j, &
4530 & 2)*dx(i, j)*yfx_adv_ad(i, j)
4532 cry_adv_ad(i, j) = 0.0
4535 yfx_adv_ad(i, j) = rdya(i, j-1)*cry_adv_ad(i, j) + sin_sg(i, j&
4536 & -1, 4)*dx(i, j)*yfx_adv_ad(i, j)
4538 cry_adv_ad(i, j) = 0.0
4545 IF (branch .EQ. 0)
THEN 4547 xfx_adv_ad(i, j) = rdxa(i, j)*crx_adv_ad(i, j) + sin_sg(i, j, &
4548 & 1)*dy(i, j)*xfx_adv_ad(i, j)
4550 crx_adv_ad(i, j) = 0.0
4553 xfx_adv_ad(i, j) = rdxa(i-1, j)*crx_adv_ad(i, j) + sin_sg(i-1&
4554 & , j, 3)*dy(i, j)*xfx_adv_ad(i, j)
4556 crx_adv_ad(i, j) = 0.0
4563 vt_ad(i, j) = vt_ad(i, j) + dt*yfx_adv_ad(i, j)
4564 yfx_adv_ad(i, j) = 0.0
4570 ut_ad(i, j) = ut_ad(i, j) + dt*xfx_adv_ad(i, j)
4571 xfx_adv_ad(i, j) = 0.0
4575 IF (branch .LT. 2)
THEN 4576 IF (branch .EQ. 0)
THEN 4579 vc_ad(i, j) = vc_ad(i, j) + vt_ad(i, j)
4585 uc_ad(i, j) = uc_ad(i, j) + ut_ad(i, j)
4592 IF (branch .NE. 2)
THEN 4593 cosa_u => gridstruct%cosa_u
4594 cosa_v => gridstruct%cosa_v
4595 damp = 1./(1.-0.0625*cosa_u(2, npy-1)*cosa_v(1, npy-1))
4596 temp_ad39 = -(damp*cosa_v(1, npy-1)*0.25*vt_ad(1, npy-1))
4597 temp_ad40 = -(cosa_u(2, npy-1)*0.25*temp_ad39)
4598 ut_ad(1, npy-1) = ut_ad(1, npy-1) + temp_ad39
4599 ut_ad(1, npy-2) = ut_ad(1, npy-2) + temp_ad39
4600 ut_ad(2, npy-2) = ut_ad(2, npy-2) + temp_ad39
4601 uc_ad(2, npy-1) = uc_ad(2, npy-1) + damp*ut_ad(2, npy-1) + &
4603 temp_ad41 = -(damp*cosa_u(2, npy-1)*0.25*ut_ad(2, npy-1))
4604 vc_ad(1, npy-1) = vc_ad(1, npy-1) + temp_ad41 + damp*vt_ad(1, &
4606 vt_ad(1, npy) = vt_ad(1, npy) + temp_ad40
4607 vt_ad(2, npy) = vt_ad(2, npy) + temp_ad40
4608 vt_ad(2, npy-1) = vt_ad(2, npy-1) + temp_ad40
4609 vt_ad(1, npy-1) = 0.0
4610 temp_ad42 = -(cosa_v(1, npy-1)*0.25*temp_ad41)
4611 vt_ad(1, npy) = vt_ad(1, npy) + temp_ad41
4612 vt_ad(2, npy) = vt_ad(2, npy) + temp_ad41
4613 vt_ad(2, npy-1) = vt_ad(2, npy-1) + temp_ad41
4614 ut_ad(1, npy-1) = ut_ad(1, npy-1) + temp_ad42
4615 ut_ad(1, npy-2) = ut_ad(1, npy-2) + temp_ad42
4616 ut_ad(2, npy-2) = ut_ad(2, npy-2) + temp_ad42
4617 ut_ad(2, npy-1) = 0.0
4618 damp = 1./(1.-0.0625*cosa_u(0, npy-1)*cosa_v(0, npy-1))
4619 temp_ad43 = -(damp*cosa_v(0, npy-1)*0.25*vt_ad(0, npy-1))
4620 temp_ad44 = -(cosa_u(0, npy-1)*0.25*temp_ad43)
4621 vc_ad(0, npy-1) = vc_ad(0, npy-1) + damp*vt_ad(0, npy-1)
4622 ut_ad(1, npy-1) = ut_ad(1, npy-1) + temp_ad43
4623 ut_ad(1, npy-2) = ut_ad(1, npy-2) + temp_ad43
4624 ut_ad(0, npy-2) = ut_ad(0, npy-2) + temp_ad43
4625 uc_ad(0, npy-1) = uc_ad(0, npy-1) + temp_ad43
4626 vt_ad(0, npy) = vt_ad(0, npy) + temp_ad44
4627 vt_ad(-1, npy) = vt_ad(-1, npy) + temp_ad44
4628 vt_ad(-1, npy-1) = vt_ad(-1, npy-1) + temp_ad44
4629 vt_ad(0, npy-1) = 0.0
4630 damp = 1./(1.-0.0625*cosa_u(2, npy)*cosa_v(1, npy+1))
4631 temp_ad45 = -(damp*cosa_u(2, npy)*0.25*ut_ad(2, npy))
4632 temp_ad46 = -(cosa_v(1, npy+1)*0.25*temp_ad45)
4633 uc_ad(2, npy) = uc_ad(2, npy) + damp*ut_ad(2, npy)
4634 vt_ad(1, npy) = vt_ad(1, npy) + temp_ad45
4635 vt_ad(2, npy) = vt_ad(2, npy) + temp_ad45
4636 vt_ad(2, npy+1) = vt_ad(2, npy+1) + temp_ad45
4637 vc_ad(1, npy+1) = vc_ad(1, npy+1) + temp_ad45
4638 ut_ad(1, npy) = ut_ad(1, npy) + temp_ad46
4639 ut_ad(1, npy+1) = ut_ad(1, npy+1) + temp_ad46
4640 ut_ad(2, npy+1) = ut_ad(2, npy+1) + temp_ad46
4644 IF (branch .EQ. 0)
THEN 4645 damp = 1./(1.-0.0625*cosa_u(npx-1, npy-1)*cosa_v(npx-1, npy-1))
4646 temp_ad31 = -(damp*cosa_v(npx-1, npy-1)*0.25*vt_ad(npx-1, npy-1)&
4648 temp_ad32 = -(cosa_u(npx-1, npy-1)*0.25*temp_ad31)
4649 ut_ad(npx, npy-1) = ut_ad(npx, npy-1) + temp_ad31
4650 ut_ad(npx, npy-2) = ut_ad(npx, npy-2) + temp_ad31
4651 ut_ad(npx-1, npy-2) = ut_ad(npx-1, npy-2) + temp_ad31
4652 uc_ad(npx-1, npy-1) = uc_ad(npx-1, npy-1) + damp*ut_ad(npx-1, &
4653 & npy-1) + temp_ad31
4654 temp_ad33 = -(damp*cosa_u(npx-1, npy-1)*0.25*ut_ad(npx-1, npy-1)&
4656 vc_ad(npx-1, npy-1) = vc_ad(npx-1, npy-1) + temp_ad33 + damp*&
4657 & vt_ad(npx-1, npy-1)
4658 vt_ad(npx-1, npy) = vt_ad(npx-1, npy) + temp_ad32
4659 vt_ad(npx-2, npy) = vt_ad(npx-2, npy) + temp_ad32
4660 vt_ad(npx-2, npy-1) = vt_ad(npx-2, npy-1) + temp_ad32
4661 vt_ad(npx-1, npy-1) = 0.0
4662 temp_ad34 = -(cosa_v(npx-1, npy-1)*0.25*temp_ad33)
4663 vt_ad(npx-1, npy) = vt_ad(npx-1, npy) + temp_ad33
4664 vt_ad(npx-2, npy) = vt_ad(npx-2, npy) + temp_ad33
4665 vt_ad(npx-2, npy-1) = vt_ad(npx-2, npy-1) + temp_ad33
4666 ut_ad(npx, npy-1) = ut_ad(npx, npy-1) + temp_ad34
4667 ut_ad(npx, npy-2) = ut_ad(npx, npy-2) + temp_ad34
4668 ut_ad(npx-1, npy-2) = ut_ad(npx-1, npy-2) + temp_ad34
4669 ut_ad(npx-1, npy-1) = 0.0
4670 damp = 1./(1.-0.0625*cosa_u(npx+1, npy-1)*cosa_v(npx, npy-1))
4671 temp_ad35 = -(damp*cosa_v(npx, npy-1)*0.25*vt_ad(npx, npy-1))
4672 temp_ad36 = -(cosa_u(npx+1, npy-1)*0.25*temp_ad35)
4673 vc_ad(npx, npy-1) = vc_ad(npx, npy-1) + damp*vt_ad(npx, npy-1)
4674 ut_ad(npx, npy-1) = ut_ad(npx, npy-1) + temp_ad35
4675 ut_ad(npx, npy-2) = ut_ad(npx, npy-2) + temp_ad35
4676 ut_ad(npx+1, npy-2) = ut_ad(npx+1, npy-2) + temp_ad35
4677 uc_ad(npx+1, npy-1) = uc_ad(npx+1, npy-1) + temp_ad35
4678 vt_ad(npx, npy) = vt_ad(npx, npy) + temp_ad36
4679 vt_ad(npx+1, npy) = vt_ad(npx+1, npy) + temp_ad36
4680 vt_ad(npx+1, npy-1) = vt_ad(npx+1, npy-1) + temp_ad36
4681 vt_ad(npx, npy-1) = 0.0
4682 damp = 1./(1.-0.0625*cosa_u(npx-1, npy)*cosa_v(npx-1, npy+1))
4683 temp_ad37 = -(damp*cosa_u(npx-1, npy)*0.25*ut_ad(npx-1, npy))
4684 temp_ad38 = -(cosa_v(npx-1, npy+1)*0.25*temp_ad37)
4685 uc_ad(npx-1, npy) = uc_ad(npx-1, npy) + damp*ut_ad(npx-1, npy)
4686 vt_ad(npx-1, npy) = vt_ad(npx-1, npy) + temp_ad37
4687 vt_ad(npx-2, npy) = vt_ad(npx-2, npy) + temp_ad37
4688 vt_ad(npx-2, npy+1) = vt_ad(npx-2, npy+1) + temp_ad37
4689 vc_ad(npx-1, npy+1) = vc_ad(npx-1, npy+1) + temp_ad37
4690 ut_ad(npx, npy) = ut_ad(npx, npy) + temp_ad38
4691 ut_ad(npx, npy+1) = ut_ad(npx, npy+1) + temp_ad38
4692 ut_ad(npx-1, npy+1) = ut_ad(npx-1, npy+1) + temp_ad38
4693 ut_ad(npx-1, npy) = 0.0
4696 IF (branch .EQ. 0)
THEN 4697 damp = 1./(1.-0.0625*cosa_u(npx-1, 1)*cosa_v(npx-1, 2))
4698 temp_ad23 = -(damp*cosa_v(npx-1, 2)*0.25*vt_ad(npx-1, 2))
4699 temp_ad24 = -(cosa_u(npx-1, 1)*0.25*temp_ad23)
4700 ut_ad(npx, 1) = ut_ad(npx, 1) + temp_ad23
4701 ut_ad(npx, 2) = ut_ad(npx, 2) + temp_ad23
4702 ut_ad(npx-1, 2) = ut_ad(npx-1, 2) + temp_ad23
4703 uc_ad(npx-1, 1) = uc_ad(npx-1, 1) + damp*ut_ad(npx-1, 1) + &
4705 temp_ad25 = -(damp*cosa_u(npx-1, 1)*0.25*ut_ad(npx-1, 1))
4706 vc_ad(npx-1, 2) = vc_ad(npx-1, 2) + temp_ad25 + damp*vt_ad(npx-1&
4708 vt_ad(npx-1, 1) = vt_ad(npx-1, 1) + temp_ad24
4709 vt_ad(npx-2, 1) = vt_ad(npx-2, 1) + temp_ad24
4710 vt_ad(npx-2, 2) = vt_ad(npx-2, 2) + temp_ad24
4711 vt_ad(npx-1, 2) = 0.0
4712 temp_ad26 = -(cosa_v(npx-1, 2)*0.25*temp_ad25)
4713 vt_ad(npx-1, 1) = vt_ad(npx-1, 1) + temp_ad25
4714 vt_ad(npx-2, 1) = vt_ad(npx-2, 1) + temp_ad25
4715 vt_ad(npx-2, 2) = vt_ad(npx-2, 2) + temp_ad25
4716 ut_ad(npx, 1) = ut_ad(npx, 1) + temp_ad26
4717 ut_ad(npx, 2) = ut_ad(npx, 2) + temp_ad26
4718 ut_ad(npx-1, 2) = ut_ad(npx-1, 2) + temp_ad26
4719 ut_ad(npx-1, 1) = 0.0
4720 damp = 1./(1.-0.0625*cosa_u(npx+1, 1)*cosa_v(npx, 2))
4721 temp_ad27 = -(damp*cosa_v(npx, 2)*0.25*vt_ad(npx, 2))
4722 temp_ad28 = -(cosa_u(npx+1, 1)*0.25*temp_ad27)
4723 vc_ad(npx, 2) = vc_ad(npx, 2) + damp*vt_ad(npx, 2)
4724 ut_ad(npx, 1) = ut_ad(npx, 1) + temp_ad27
4725 ut_ad(npx, 2) = ut_ad(npx, 2) + temp_ad27
4726 ut_ad(npx+1, 2) = ut_ad(npx+1, 2) + temp_ad27
4727 uc_ad(npx+1, 1) = uc_ad(npx+1, 1) + temp_ad27
4728 vt_ad(npx, 1) = vt_ad(npx, 1) + temp_ad28
4729 vt_ad(npx+1, 1) = vt_ad(npx+1, 1) + temp_ad28
4730 vt_ad(npx+1, 2) = vt_ad(npx+1, 2) + temp_ad28
4732 damp = 1./(1.-0.0625*cosa_u(npx-1, 0)*cosa_v(npx-1, 0))
4733 temp_ad29 = -(damp*cosa_u(npx-1, 0)*0.25*ut_ad(npx-1, 0))
4734 temp_ad30 = -(cosa_v(npx-1, 0)*0.25*temp_ad29)
4735 uc_ad(npx-1, 0) = uc_ad(npx-1, 0) + damp*ut_ad(npx-1, 0)
4736 vt_ad(npx-1, 1) = vt_ad(npx-1, 1) + temp_ad29
4737 vt_ad(npx-2, 1) = vt_ad(npx-2, 1) + temp_ad29
4738 vt_ad(npx-2, 0) = vt_ad(npx-2, 0) + temp_ad29
4739 vc_ad(npx-1, 0) = vc_ad(npx-1, 0) + temp_ad29
4740 ut_ad(npx, 0) = ut_ad(npx, 0) + temp_ad30
4741 ut_ad(npx, -1) = ut_ad(npx, -1) + temp_ad30
4742 ut_ad(npx-1, -1) = ut_ad(npx-1, -1) + temp_ad30
4743 ut_ad(npx-1, 0) = 0.0
4746 IF (branch .EQ. 0)
THEN 4747 damp = 1./(1.-0.0625*cosa_u(2, 1)*cosa_v(1, 2))
4748 temp_ad15 = -(damp*cosa_v(1, 2)*0.25*vt_ad(1, 2))
4749 temp_ad16 = -(cosa_u(2, 1)*0.25*temp_ad15)
4750 ut_ad(1, 1) = ut_ad(1, 1) + temp_ad15
4751 ut_ad(1, 2) = ut_ad(1, 2) + temp_ad15
4752 ut_ad(2, 2) = ut_ad(2, 2) + temp_ad15
4753 uc_ad(2, 1) = uc_ad(2, 1) + damp*ut_ad(2, 1) + temp_ad15
4754 temp_ad17 = -(damp*cosa_u(2, 1)*0.25*ut_ad(2, 1))
4755 vc_ad(1, 2) = vc_ad(1, 2) + temp_ad17 + damp*vt_ad(1, 2)
4756 vt_ad(1, 1) = vt_ad(1, 1) + temp_ad16
4757 vt_ad(2, 1) = vt_ad(2, 1) + temp_ad16
4758 vt_ad(2, 2) = vt_ad(2, 2) + temp_ad16
4760 temp_ad18 = -(cosa_v(1, 2)*0.25*temp_ad17)
4761 vt_ad(1, 1) = vt_ad(1, 1) + temp_ad17
4762 vt_ad(2, 1) = vt_ad(2, 1) + temp_ad17
4763 vt_ad(2, 2) = vt_ad(2, 2) + temp_ad17
4764 ut_ad(1, 1) = ut_ad(1, 1) + temp_ad18
4765 ut_ad(1, 2) = ut_ad(1, 2) + temp_ad18
4766 ut_ad(2, 2) = ut_ad(2, 2) + temp_ad18
4768 damp = 1./(1.-0.0625*cosa_u(0, 1)*cosa_v(0, 2))
4769 temp_ad19 = -(damp*cosa_v(0, 2)*0.25*vt_ad(0, 2))
4770 temp_ad20 = -(cosa_u(0, 1)*0.25*temp_ad19)
4771 vc_ad(0, 2) = vc_ad(0, 2) + damp*vt_ad(0, 2)
4772 ut_ad(1, 1) = ut_ad(1, 1) + temp_ad19
4773 ut_ad(1, 2) = ut_ad(1, 2) + temp_ad19
4774 ut_ad(0, 2) = ut_ad(0, 2) + temp_ad19
4775 uc_ad(0, 1) = uc_ad(0, 1) + temp_ad19
4776 vt_ad(0, 1) = vt_ad(0, 1) + temp_ad20
4777 vt_ad(-1, 1) = vt_ad(-1, 1) + temp_ad20
4778 vt_ad(-1, 2) = vt_ad(-1, 2) + temp_ad20
4780 damp = 1./(1.-0.0625*cosa_u(2, 0)*cosa_v(1, 0))
4781 temp_ad21 = -(damp*cosa_u(2, 0)*0.25*ut_ad(2, 0))
4782 temp_ad22 = -(cosa_v(1, 0)*0.25*temp_ad21)
4783 uc_ad(2, 0) = uc_ad(2, 0) + damp*ut_ad(2, 0)
4784 vt_ad(1, 1) = vt_ad(1, 1) + temp_ad21
4785 vt_ad(2, 1) = vt_ad(2, 1) + temp_ad21
4786 vt_ad(2, 0) = vt_ad(2, 0) + temp_ad21
4787 vc_ad(1, 0) = vc_ad(1, 0) + temp_ad21
4788 ut_ad(1, 0) = ut_ad(1, 0) + temp_ad22
4789 ut_ad(1, -1) = ut_ad(1, -1) + temp_ad22
4790 ut_ad(2, -1) = ut_ad(2, -1) + temp_ad22
4794 IF (branch .EQ. 0)
THEN 4796 temp_ad13 = -(cosa_u(i, npy)*0.25*ut_ad(i, npy))
4797 uc_ad(i, npy) = uc_ad(i, npy) + ut_ad(i, npy)
4798 vt_ad(i-1, npy) = vt_ad(i-1, npy) + temp_ad13
4799 vt_ad(i, npy) = vt_ad(i, npy) + temp_ad13
4800 vt_ad(i-1, npy+1) = vt_ad(i-1, npy+1) + temp_ad13
4801 vt_ad(i, npy+1) = vt_ad(i, npy+1) + temp_ad13
4803 temp_ad14 = -(cosa_u(i, npy-1)*0.25*ut_ad(i, npy-1))
4804 uc_ad(i, npy-1) = uc_ad(i, npy-1) + ut_ad(i, npy-1)
4805 vt_ad(i-1, npy-1) = vt_ad(i-1, npy-1) + temp_ad14
4806 vt_ad(i, npy-1) = vt_ad(i, npy-1) + temp_ad14
4807 vt_ad(i-1, npy) = vt_ad(i-1, npy) + temp_ad14
4808 vt_ad(i, npy) = vt_ad(i, npy) + temp_ad14
4809 ut_ad(i, npy-1) = 0.0
4813 IF (branch .EQ. 0)
THEN 4814 vc_ad(i, npy) = vc_ad(i, npy) + vt_ad(i, npy)/sin_sg(i, npy&
4818 vc_ad(i, npy) = vc_ad(i, npy) + vt_ad(i, npy)/sin_sg(i, npy-&
4825 IF (branch .EQ. 0)
THEN 4827 temp_ad11 = -(cosa_u(i, 1)*0.25*ut_ad(i, 1))
4828 uc_ad(i, 1) = uc_ad(i, 1) + ut_ad(i, 1)
4829 vt_ad(i-1, 1) = vt_ad(i-1, 1) + temp_ad11
4830 vt_ad(i, 1) = vt_ad(i, 1) + temp_ad11
4831 vt_ad(i-1, 2) = vt_ad(i-1, 2) + temp_ad11
4832 vt_ad(i, 2) = vt_ad(i, 2) + temp_ad11
4834 temp_ad12 = -(cosa_u(i, 0)*0.25*ut_ad(i, 0))
4835 uc_ad(i, 0) = uc_ad(i, 0) + ut_ad(i, 0)
4836 vt_ad(i-1, 0) = vt_ad(i-1, 0) + temp_ad12
4837 vt_ad(i, 0) = vt_ad(i, 0) + temp_ad12
4838 vt_ad(i-1, 1) = vt_ad(i-1, 1) + temp_ad12
4839 vt_ad(i, 1) = vt_ad(i, 1) + temp_ad12
4844 IF (branch .EQ. 0)
THEN 4845 vc_ad(i, 1) = vc_ad(i, 1) + vt_ad(i, 1)/sin_sg(i, 1, 2)
4848 vc_ad(i, 1) = vc_ad(i, 1) + vt_ad(i, 1)/sin_sg(i, 0, 4)
4854 IF (branch .EQ. 0)
THEN 4856 temp_ad9 = -(cosa_v(npx, j)*0.25*vt_ad(npx, j))
4857 vc_ad(npx, j) = vc_ad(npx, j) + vt_ad(npx, j)
4858 ut_ad(npx, j-1) = ut_ad(npx, j-1) + temp_ad9
4859 ut_ad(npx+1, j-1) = ut_ad(npx+1, j-1) + temp_ad9
4860 ut_ad(npx, j) = ut_ad(npx, j) + temp_ad9
4861 ut_ad(npx+1, j) = ut_ad(npx+1, j) + temp_ad9
4863 temp_ad10 = -(cosa_v(npx-1, j)*0.25*vt_ad(npx-1, j))
4864 vc_ad(npx-1, j) = vc_ad(npx-1, j) + vt_ad(npx-1, j)
4865 ut_ad(npx-1, j-1) = ut_ad(npx-1, j-1) + temp_ad10
4866 ut_ad(npx, j-1) = ut_ad(npx, j-1) + temp_ad10
4867 ut_ad(npx-1, j) = ut_ad(npx-1, j) + temp_ad10
4868 ut_ad(npx, j) = ut_ad(npx, j) + temp_ad10
4869 vt_ad(npx-1, j) = 0.0
4873 IF (branch .EQ. 0)
THEN 4874 uc_ad(npx, j) = uc_ad(npx, j) + ut_ad(npx, j)/sin_sg(npx, j&
4878 uc_ad(npx, j) = uc_ad(npx, j) + ut_ad(npx, j)/sin_sg(npx-1, &
4885 IF (branch .EQ. 0)
THEN 4887 temp_ad7 = -(cosa_v(1, j)*0.25*vt_ad(1, j))
4888 vc_ad(1, j) = vc_ad(1, j) + vt_ad(1, j)
4889 ut_ad(1, j-1) = ut_ad(1, j-1) + temp_ad7
4890 ut_ad(2, j-1) = ut_ad(2, j-1) + temp_ad7
4891 ut_ad(1, j) = ut_ad(1, j) + temp_ad7
4892 ut_ad(2, j) = ut_ad(2, j) + temp_ad7
4894 temp_ad8 = -(cosa_v(0, j)*0.25*vt_ad(0, j))
4895 vc_ad(0, j) = vc_ad(0, j) + vt_ad(0, j)
4896 ut_ad(0, j-1) = ut_ad(0, j-1) + temp_ad8
4897 ut_ad(1, j-1) = ut_ad(1, j-1) + temp_ad8
4898 ut_ad(0, j) = ut_ad(0, j) + temp_ad8
4899 ut_ad(1, j) = ut_ad(1, j) + temp_ad8
4904 IF (branch .EQ. 0)
THEN 4905 uc_ad(1, j) = uc_ad(1, j) + ut_ad(1, j)/sin_sg(1, j, 1)
4908 uc_ad(1, j) = uc_ad(1, j) + ut_ad(1, j)/sin_sg(0, j, 3)
4914 rsin_v => gridstruct%rsin_v
4916 IF (branch .EQ. 0)
THEN 4919 temp_ad1 = rsin_v(i, j)*vt_ad(i, j)
4920 temp_ad2 = -(cosa_v(i, j)*0.25*temp_ad1)
4921 vc_ad(i, j) = vc_ad(i, j) + temp_ad1
4922 uc_ad(i, j-1) = uc_ad(i, j-1) + temp_ad2
4923 uc_ad(i+1, j-1) = uc_ad(i+1, j-1) + temp_ad2
4924 uc_ad(i, j) = uc_ad(i, j) + temp_ad2
4925 uc_ad(i+1, j) = uc_ad(i+1, j) + temp_ad2
4931 temp_ad = rsin_u(i, j)*ut_ad(i, j)
4932 temp_ad0 = -(cosa_u(i, j)*0.25*temp_ad)
4933 uc_ad(i, j) = uc_ad(i, j) + temp_ad
4934 vc_ad(i-1, j) = vc_ad(i-1, j) + temp_ad0
4935 vc_ad(i, j) = vc_ad(i, j) + temp_ad0
4936 vc_ad(i-1, j+1) = vc_ad(i-1, j+1) + temp_ad0
4937 vc_ad(i, j+1) = vc_ad(i, j+1) + temp_ad0
4944 IF (branch .NE. 0)
THEN 4946 temp_ad5 = rsin_v(i, j)*vt_ad(i, j)
4947 temp_ad6 = -(cosa_v(i, j)*0.25*temp_ad5)
4948 vc_ad(i, j) = vc_ad(i, j) + temp_ad5
4949 uc_ad(i, j-1) = uc_ad(i, j-1) + temp_ad6
4950 uc_ad(i+1, j-1) = uc_ad(i+1, j-1) + temp_ad6
4951 uc_ad(i, j) = uc_ad(i, j) + temp_ad6
4952 uc_ad(i+1, j) = uc_ad(i+1, j) + temp_ad6
4959 IF (branch .NE. 0)
THEN 4961 temp_ad3 = rsin_u(i, j)*ut_ad(i, j)
4962 temp_ad4 = -(cosa_u(i, j)*0.25*temp_ad3)
4963 uc_ad(i, j) = uc_ad(i, j) + temp_ad3
4964 vc_ad(i-1, j) = vc_ad(i-1, j) + temp_ad4
4965 vc_ad(i, j) = vc_ad(i, j) + temp_ad4
4966 vc_ad(i-1, j+1) = vc_ad(i-1, j+1) + temp_ad4
4967 vc_ad(i, j+1) = vc_ad(i, j+1) + temp_ad4
4976 SUBROUTINE d_sw(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, divg_d&
4977 & , xflux, yflux, cx, cy, crx_adv, cry_adv, xfx_adv, yfx_adv, q_con, &
4978 & z_rat, kgb, heat_source, dpx, zvir, sphum, nq, q, k, km, inline_q, &
4979 & dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, nord_v, &
4980 & nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, damp_t, d_con, &
4981 & hydrostatic, gridstruct, flagstruct, bd, hord_tr_pert, hord_mt_pert&
4982 & , hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, &
4983 & nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, &
4984 & d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
4986 INTEGER,
INTENT(IN) :: hord_tr, hord_mt, hord_vt, hord_tm, hord_dp
4988 INTEGER,
INTENT(IN) :: nord
4990 INTEGER,
INTENT(IN) :: nord_v
4992 INTEGER,
INTENT(IN) :: nord_w
4994 INTEGER,
INTENT(IN) :: nord_t
4995 INTEGER,
INTENT(IN) :: sphum, nq, k, km
4996 REAL,
INTENT(IN) :: dt, dddmp, d2_bg, d4_bg, d_con
4997 REAL,
INTENT(IN) :: zvir
4998 REAL,
INTENT(IN) :: damp_v, damp_w, damp_t, kgb
5000 INTEGER,
INTENT(IN) :: hord_tr_pert, hord_mt_pert, hord_vt_pert, &
5001 & hord_tm_pert, hord_dp_pert, nord_pert, nord_v_pert, nord_w_pert, &
5003 LOGICAL,
INTENT(IN) :: split_damp
5004 REAL,
INTENT(IN) :: dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert&
5005 & , damp_w_pert, damp_t_pert
5007 REAL,
INTENT(INOUT) :: divg_d(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5008 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: z_rat
5009 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: delp&
5011 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: w
5012 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
5014 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: u&
5016 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: v&
5018 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, km, nq)
5019 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(OUT) :: delpc&
5021 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je),
INTENT(OUT) :: &
5023 REAL(kind=8),
DIMENSION(bd%is:bd%ie, bd%js:bd%je),
INTENT(INOUT) :: &
5026 REAL,
INTENT(INOUT) :: xflux(bd%is:bd%ie+1, bd%js:bd%je)
5027 REAL,
INTENT(INOUT) :: yflux(bd%is:bd%ie, bd%js:bd%je+1)
5029 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed)
5030 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1)
5031 LOGICAL,
INTENT(IN) :: hydrostatic
5032 LOGICAL,
INTENT(IN) :: inline_q
5033 REAL,
DIMENSION(bd%is:bd%ie+1, bd%jsd:bd%jed),
INTENT(OUT) :: &
5035 REAL,
DIMENSION(bd%isd:bd%ied, bd%js:bd%je+1),
INTENT(OUT) :: &
5040 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
5041 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
5042 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
5044 REAL :: fx2(bd%isd:bd%ied+1, bd%jsd:bd%jed)
5045 REAL :: fy2(bd%isd:bd%ied, bd%jsd:bd%jed+1)
5047 REAL :: dw(bd%is:bd%ie, bd%js:bd%je)
5049 REAL,
DIMENSION(bd%is:bd%ie+1, bd%js:bd%je+1) :: ub, vb
5051 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
5053 REAL :: ke(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5055 REAL :: vort(bd%isd:bd%ied, bd%jsd:bd%jed)
5057 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
5059 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
5060 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
5061 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
5062 REAL :: gx(bd%is:bd%ie+1, bd%js:bd%je)
5064 REAL :: gy(bd%is:bd%ie, bd%js:bd%je+1)
5066 REAL :: dt2, dt4, dt5, dt6
5067 REAL :: damp, damp2, damp4, dd8,
u2, v2, du2, dv2
5069 INTEGER :: i, j, is2, ie1, js2, je1, n, nt, n2, iq
5070 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
5071 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
5072 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
5073 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
5074 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
5075 REAL,
DIMENSION(:, :),
POINTER ::
f0, rsin2, divg_u, divg_v
5076 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
5078 INTEGER :: is, ie, js, je
5079 INTEGER :: isd, ied, jsd, jed
5082 REAL :: delp_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
5083 REAL :: pt_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
5084 REAL :: vort_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
5085 REAL :: wk_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
5086 REAL :: delpc_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
5087 REAL :: ptc_tj(bd%isd:bd%ied, bd%jsd:bd%jed)
5088 REAL :: ke_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5089 REAL :: vc_tj(bd%isd:bd%ied, bd%jsd:bd%jed+1)
5090 REAL :: uc_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed)
5091 REAL :: divg_d_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5092 REAL :: ut_tj(bd%isd:bd%ied+1, bd%jsd:bd%jed)
5093 REAL :: vt_tj(bd%isd:bd%ied, bd%jsd:bd%jed+1)
5114 npx = flagstruct%npx
5115 npy = flagstruct%npy
5116 nested = gridstruct%nested
5117 area => gridstruct%area
5118 rarea => gridstruct%rarea
5119 sin_sg => gridstruct%sin_sg
5120 cosa_u => gridstruct%cosa_u
5121 cosa_v => gridstruct%cosa_v
5122 cosa_s => gridstruct%cosa_s
5123 sina_u => gridstruct%sina_u
5124 sina_v => gridstruct%sina_v
5125 rsin_u => gridstruct%rsin_u
5126 rsin_v => gridstruct%rsin_v
5127 rsina => gridstruct%rsina
5129 rsin2 => gridstruct%rsin2
5130 divg_u => gridstruct%divg_u
5131 divg_v => gridstruct%divg_v
5132 cosa => gridstruct%cosa
5135 dxc => gridstruct%dxc
5136 dyc => gridstruct%dyc
5137 rdxa => gridstruct%rdxa
5138 rdya => gridstruct%rdya
5139 rdx => gridstruct%rdx
5140 rdy => gridstruct%rdy
5141 sw_corner = gridstruct%sw_corner
5142 se_corner = gridstruct%se_corner
5143 nw_corner = gridstruct%nw_corner
5144 ne_corner = gridstruct%ne_corner
5146 IF (flagstruct%grid_type .LT. 3)
THEN 5151 ut(i, j) = (uc(i, j)-0.25*cosa_u(i, j)*(vc(i-1, j)+vc(i, j)+&
5152 & vc(i-1, j+1)+vc(i, j+1)))*rsin_u(i, j)
5157 vt(i, j) = (vc(i, j)-0.25*cosa_v(i, j)*(uc(i, j-1)+uc(i+1, j&
5158 & -1)+uc(i, j)+uc(i+1, j)))*rsin_v(i, j)
5163 IF (j .NE. 0 .AND. j .NE. 1 .AND. j .NE. npy - 1 .AND. j .NE. &
5166 ut(i, j) = (uc(i, j)-0.25*cosa_u(i, j)*(vc(i-1, j)+vc(i, j&
5167 & )+vc(i-1, j+1)+vc(i, j+1)))*rsin_u(i, j)
5172 IF (j .NE. 1 .AND. j .NE. npy)
THEN 5174 vt(i, j) = (vc(i, j)-0.25*cosa_v(i, j)*(uc(i, j-1)+uc(i+1&
5175 & , j-1)+uc(i, j)+uc(i+1, j)))*rsin_v(i, j)
5181 IF (.NOT.nested)
THEN 5186 IF (uc(1, j)*dt .GT. 0.)
THEN 5187 ut(1, j) = uc(1, j)/sin_sg(0, j, 3)
5189 ut(1, j) = uc(1, j)/sin_sg(1, j, 1)
5197 IF (npy - 2 .GT. je + 1)
THEN 5203 vt(0, j) = vc(0, j) - 0.25*cosa_v(0, j)*(ut(0, j-1)+ut(1, j-&
5204 & 1)+ut(0, j)+ut(1, j))
5205 vt(1, j) = vc(1, j) - 0.25*cosa_v(1, j)*(ut(1, j-1)+ut(2, j-&
5206 & 1)+ut(1, j)+ut(2, j))
5210 IF (ie + 1 .EQ. npx)
THEN 5212 IF (uc(npx, j)*dt .GT. 0.)
THEN 5213 ut(npx, j) = uc(npx, j)/sin_sg(npx-1, j, 3)
5215 ut(npx, j) = uc(npx, j)/sin_sg(npx, j, 1)
5223 IF (npy - 2 .GT. je + 1)
THEN 5229 vt(npx-1, j) = vc(npx-1, j) - 0.25*cosa_v(npx-1, j)*(ut(npx-&
5230 & 1, j-1)+ut(npx, j-1)+ut(npx-1, j)+ut(npx, j))
5231 vt(npx, j) = vc(npx, j) - 0.25*cosa_v(npx, j)*(ut(npx, j-1)+&
5232 & ut(npx+1, j-1)+ut(npx, j)+ut(npx+1, j))
5238 IF (vc(i, 1)*dt .GT. 0.)
THEN 5239 vt(i, 1) = vc(i, 1)/sin_sg(i, 0, 4)
5241 vt(i, 1) = vc(i, 1)/sin_sg(i, 1, 2)
5249 IF (npx - 2 .GT. ie + 1)
THEN 5255 ut(i, 0) = uc(i, 0) - 0.25*cosa_u(i, 0)*(vt(i-1, 0)+vt(i, 0)&
5256 & +vt(i-1, 1)+vt(i, 1))
5257 ut(i, 1) = uc(i, 1) - 0.25*cosa_u(i, 1)*(vt(i-1, 1)+vt(i, 1)&
5258 & +vt(i-1, 2)+vt(i, 2))
5262 IF (je + 1 .EQ. npy)
THEN 5264 IF (vc(i, npy)*dt .GT. 0.)
THEN 5265 vt(i, npy) = vc(i, npy)/sin_sg(i, npy-1, 4)
5267 vt(i, npy) = vc(i, npy)/sin_sg(i, npy, 2)
5275 IF (npx - 2 .GT. ie + 1)
THEN 5281 ut(i, npy-1) = uc(i, npy-1) - 0.25*cosa_u(i, npy-1)*(vt(i-1&
5282 & , npy-1)+vt(i, npy-1)+vt(i-1, npy)+vt(i, npy))
5283 ut(i, npy) = uc(i, npy) - 0.25*cosa_u(i, npy)*(vt(i-1, npy)+&
5284 & vt(i, npy)+vt(i-1, npy+1)+vt(i, npy+1))
5296 damp = 1./(1.-0.0625*cosa_u(2, 0)*cosa_v(1, 0))
5297 ut(2, 0) = (uc(2, 0)-0.25*cosa_u(2, 0)*(vt(1, 1)+vt(2, 1)+vt(2&
5298 & , 0)+vc(1, 0)-0.25*cosa_v(1, 0)*(ut(1, 0)+ut(1, -1)+ut(2, -1&
5300 damp = 1./(1.-0.0625*cosa_u(0, 1)*cosa_v(0, 2))
5301 vt(0, 2) = (vc(0, 2)-0.25*cosa_v(0, 2)*(ut(1, 1)+ut(1, 2)+ut(0&
5302 & , 2)+uc(0, 1)-0.25*cosa_u(0, 1)*(vt(0, 1)+vt(-1, 1)+vt(-1, 2&
5304 damp = 1./(1.-0.0625*cosa_u(2, 1)*cosa_v(1, 2))
5305 ut(2, 1) = (uc(2, 1)-0.25*cosa_u(2, 1)*(vt(1, 1)+vt(2, 1)+vt(2&
5306 & , 2)+vc(1, 2)-0.25*cosa_v(1, 2)*(ut(1, 1)+ut(1, 2)+ut(2, 2))&
5308 vt(1, 2) = (vc(1, 2)-0.25*cosa_v(1, 2)*(ut(1, 1)+ut(1, 2)+ut(2&
5309 & , 2)+uc(2, 1)-0.25*cosa_u(2, 1)*(vt(1, 1)+vt(2, 1)+vt(2, 2))&
5313 damp = 1./(1.-0.0625*cosa_u(npx-1, 0)*cosa_v(npx-1, 0))
5314 ut(npx-1, 0) = (uc(npx-1, 0)-0.25*cosa_u(npx-1, 0)*(vt(npx-1, &
5315 & 1)+vt(npx-2, 1)+vt(npx-2, 0)+vc(npx-1, 0)-0.25*cosa_v(npx-1&
5316 & , 0)*(ut(npx, 0)+ut(npx, -1)+ut(npx-1, -1))))*damp
5317 damp = 1./(1.-0.0625*cosa_u(npx+1, 1)*cosa_v(npx, 2))
5318 vt(npx, 2) = (vc(npx, 2)-0.25*cosa_v(npx, 2)*(ut(npx, 1)+ut(&
5319 & npx, 2)+ut(npx+1, 2)+uc(npx+1, 1)-0.25*cosa_u(npx+1, 1)*(vt(&
5320 & npx, 1)+vt(npx+1, 1)+vt(npx+1, 2))))*damp
5321 damp = 1./(1.-0.0625*cosa_u(npx-1, 1)*cosa_v(npx-1, 2))
5322 ut(npx-1, 1) = (uc(npx-1, 1)-0.25*cosa_u(npx-1, 1)*(vt(npx-1, &
5323 & 1)+vt(npx-2, 1)+vt(npx-2, 2)+vc(npx-1, 2)-0.25*cosa_v(npx-1&
5324 & , 2)*(ut(npx, 1)+ut(npx, 2)+ut(npx-1, 2))))*damp
5325 vt(npx-1, 2) = (vc(npx-1, 2)-0.25*cosa_v(npx-1, 2)*(ut(npx, 1)&
5326 & +ut(npx, 2)+ut(npx-1, 2)+uc(npx-1, 1)-0.25*cosa_u(npx-1, 1)*&
5327 & (vt(npx-1, 1)+vt(npx-2, 1)+vt(npx-2, 2))))*damp
5330 damp = 1./(1.-0.0625*cosa_u(npx-1, npy)*cosa_v(npx-1, npy+1))
5331 ut(npx-1, npy) = (uc(npx-1, npy)-0.25*cosa_u(npx-1, npy)*(vt(&
5332 & npx-1, npy)+vt(npx-2, npy)+vt(npx-2, npy+1)+vc(npx-1, npy+1)&
5333 & -0.25*cosa_v(npx-1, npy+1)*(ut(npx, npy)+ut(npx, npy+1)+ut(&
5334 & npx-1, npy+1))))*damp
5335 damp = 1./(1.-0.0625*cosa_u(npx+1, npy-1)*cosa_v(npx, npy-1))
5336 vt(npx, npy-1) = (vc(npx, npy-1)-0.25*cosa_v(npx, npy-1)*(ut(&
5337 & npx, npy-1)+ut(npx, npy-2)+ut(npx+1, npy-2)+uc(npx+1, npy-1)&
5338 & -0.25*cosa_u(npx+1, npy-1)*(vt(npx, npy)+vt(npx+1, npy)+vt(&
5339 & npx+1, npy-1))))*damp
5340 damp = 1./(1.-0.0625*cosa_u(npx-1, npy-1)*cosa_v(npx-1, npy-1)&
5342 ut(npx-1, npy-1) = (uc(npx-1, npy-1)-0.25*cosa_u(npx-1, npy-1)&
5343 & *(vt(npx-1, npy)+vt(npx-2, npy)+vt(npx-2, npy-1)+vc(npx-1, &
5344 & npy-1)-0.25*cosa_v(npx-1, npy-1)*(ut(npx, npy-1)+ut(npx, npy&
5345 & -2)+ut(npx-1, npy-2))))*damp
5346 vt(npx-1, npy-1) = (vc(npx-1, npy-1)-0.25*cosa_v(npx-1, npy-1)&
5347 & *(ut(npx, npy-1)+ut(npx, npy-2)+ut(npx-1, npy-2)+uc(npx-1, &
5348 & npy-1)-0.25*cosa_u(npx-1, npy-1)*(vt(npx-1, npy)+vt(npx-2, &
5349 & npy)+vt(npx-2, npy-1))))*damp
5352 damp = 1./(1.-0.0625*cosa_u(2, npy)*cosa_v(1, npy+1))
5353 ut(2, npy) = (uc(2, npy)-0.25*cosa_u(2, npy)*(vt(1, npy)+vt(2&
5354 & , npy)+vt(2, npy+1)+vc(1, npy+1)-0.25*cosa_v(1, npy+1)*(ut(1&
5355 & , npy)+ut(1, npy+1)+ut(2, npy+1))))*damp
5356 damp = 1./(1.-0.0625*cosa_u(0, npy-1)*cosa_v(0, npy-1))
5357 vt(0, npy-1) = (vc(0, npy-1)-0.25*cosa_v(0, npy-1)*(ut(1, npy-&
5358 & 1)+ut(1, npy-2)+ut(0, npy-2)+uc(0, npy-1)-0.25*cosa_u(0, npy&
5359 & -1)*(vt(0, npy)+vt(-1, npy)+vt(-1, npy-1))))*damp
5360 damp = 1./(1.-0.0625*cosa_u(2, npy-1)*cosa_v(1, npy-1))
5361 ut(2, npy-1) = (uc(2, npy-1)-0.25*cosa_u(2, npy-1)*(vt(1, npy)&
5362 & +vt(2, npy)+vt(2, npy-1)+vc(1, npy-1)-0.25*cosa_v(1, npy-1)*&
5363 & (ut(1, npy-1)+ut(1, npy-2)+ut(2, npy-2))))*damp
5364 vt(1, npy-1) = (vc(1, npy-1)-0.25*cosa_v(1, npy-1)*(ut(1, npy-&
5365 & 1)+ut(1, npy-2)+ut(2, npy-2)+uc(2, npy-1)-0.25*cosa_u(2, npy&
5366 & -1)*(vt(1, npy)+vt(2, npy)+vt(2, npy-1))))*damp
5384 xfx_adv(i, j) = dt*ut(i, j)
5389 yfx_adv(i, j) = dt*vt(i, j)
5398 IF (xfx_adv(i, j) .GT. 0.)
THEN 5399 crx_adv(i, j) = xfx_adv(i, j)*rdxa(i-1, j)
5400 xfx_adv(i, j) = dy(i, j)*xfx_adv(i, j)*sin_sg(i-1, j, 3)
5402 crx_adv(i, j) = xfx_adv(i, j)*rdxa(i, j)
5403 xfx_adv(i, j) = dy(i, j)*xfx_adv(i, j)*sin_sg(i, j, 1)
5410 IF (yfx_adv(i, j) .GT. 0.)
THEN 5411 cry_adv(i, j) = yfx_adv(i, j)*rdya(i, j-1)
5412 yfx_adv(i, j) = dx(i, j)*yfx_adv(i, j)*sin_sg(i, j-1, 4)
5414 cry_adv(i, j) = yfx_adv(i, j)*rdya(i, j)
5415 yfx_adv(i, j) = dx(i, j)*yfx_adv(i, j)*sin_sg(i, j, 2)
5421 ra_x(i, j) = area(i, j) + (xfx_adv(i, j)-xfx_adv(i+1, j))
5426 ra_y(i, j) = area(i, j) + (yfx_adv(i, j)-yfx_adv(i, j+1))
5429 IF (hord_dp .EQ. hord_dp_pert .AND. (.NOT.split_damp))
THEN 5430 CALL fv_tp_2d(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx, fy&
5431 & , xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, nord=&
5432 & nord_v, damp_c=damp_v)
5434 CALL fv_tp_2d(delp, crx_adv, cry_adv, npx, npy, hord_dp, fx, &
5435 & fy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, nord=&
5436 & nord_v, damp_c=damp_v)
5441 cx(i, j) = cx(i, j) + crx_adv(i, j)
5446 xflux(i, j) = xflux(i, j) + fx(i, j)
5451 cy(i, j) = cy(i, j) + cry_adv(i, j)
5454 yflux(i, j) = yflux(i, j) + fy(i, j)
5459 heat_source(i, j) = 0.
5462 IF (.NOT.hydrostatic)
THEN 5463 IF (damp_w .GT. 1.e-5)
THEN 5464 IF (dt .GE. 0.)
THEN 5470 damp4 = (damp_w*gridstruct%da_min_c)**(nord_w+1)
5471 CALL del6_vt_flux(nord_w, npx, npy, damp4, w, wk, fx2, fy2, &
5475 dw(i, j) = (fx2(i, j)-fx2(i+1, j)+(fy2(i, j)-fy2(i, j+1)))*&
5479 heat_source(i, j) = dd8 - dw(i, j)*(w(i, j)+0.5*dw(i, j))
5483 IF (hord_vt .EQ. hord_vt_pert)
THEN 5484 CALL fv_tp_2d(w, crx_adv, cry_adv, npx, npy, hord_vt, gx, gy&
5485 & , xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, mfx=&
5488 CALL fv_tp_2d(w, crx_adv, cry_adv, npx, npy, hord_vt, gx, &
5489 & gy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, mfx=fx&
5494 w(i, j) = delp(i, j)*w(i, j) + (gx(i, j)-gx(i+1, j)+(gy(i, j)-&
5495 & gy(i, j+1)))*rarea(i, j)
5506 IF (hord_tm .EQ. hord_tm_pert .AND. (.NOT.split_damp))
THEN 5507 CALL fv_tp_2d(pt, crx_adv, cry_adv, npx, npy, hord_tm, gx, gy, &
5508 & xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, fx, fy, &
5509 & delp, nord_t, damp_t)
5511 CALL fv_tp_2d(pt, crx_adv, cry_adv, npx, npy, hord_tm, gx, gy&
5512 & , xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y, fx, fy, &
5513 & delp, nord_t, damp_t)
5518 wk(i, j) = delp(i, j)
5519 delp(i, j) = wk(i, j) + (fx(i, j)-fx(i+1, j)+(fy(i, j)-fy(i, j&
5521 pt(i, j) = (pt(i, j)*wk(i, j)+(gx(i, j)-gx(i+1, j)+(gy(i, j)-&
5522 & gy(i, j+1)))*rarea(i, j))/delp(i, j)
5526 IF (hord_tr .EQ. hord_tr_pert)
THEN 5527 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), crx_adv, cry_adv&
5528 & , npx, npy, hord_tr, gx, gy, xfx_adv, yfx_adv, &
5529 & gridstruct, bd, ra_x, ra_y, fx, fy, delp, nord_t, &
5532 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), crx_adv, cry_adv, &
5533 & npx, npy, hord_tr, gx, gy, xfx_adv, yfx_adv, &
5534 & gridstruct, bd, ra_x, ra_y, fx, fy, delp, nord_t&
5539 q(i, j, k, iq) = (q(i, j, k, iq)*wk(i, j)+(gx(i, j)-gx(i+1, &
5540 & j)+(gy(i, j)-gy(i, j+1)))*rarea(i, j))/delp(i, j)
5554 pt(i, j) = pt(i, j)*delp(i, j) + (gx(i, j)-gx(i+1, j)+(gy(i, j&
5555 & )-gy(i, j+1)))*rarea(i, j)
5556 delp(i, j) = delp(i, j) + (fx(i, j)-fx(i+1, j)+(fy(i, j)-fy(i&
5557 & , j+1)))*rarea(i, j)
5558 pt(i, j) = pt(i, j)/delp(i, j)
5562 IF (
fpp%fpp_overload_r4)
THEN 5565 dpx(i, j) = dpx(i, j) + (fx(i, j)-fx(i+1, j)+(fy(i, j)-fy(i, j&
5587 IF (npx - 1 .GT. ie + 1)
THEN 5597 IF (npy - 1 .GT. je + 1)
THEN 5604 IF (flagstruct%grid_type .LT. 3)
THEN 5608 vb(i, j) = dt5*(vc(i-1, j)+vc(i, j)-(uc(i, j-1)+uc(i, j))*&
5609 & cosa(i, j))*rsina(i, j)
5616 vb(i, 1) = dt5*(vt(i-1, 1)+vt(i, 1))
5621 vb(i, j) = dt5*(vc(i-1, j)+vc(i, j)-(uc(i, j-1)+uc(i, j))*&
5622 & cosa(i, j))*rsina(i, j)
5624 IF (is .EQ. 1) vb(1, j) = dt4*(-vt(-1, j)+3.*(vt(0, j)+vt(1, j&
5627 IF (ie + 1 .EQ. npx) vb(npx, j) = dt4*(-vt(npx-2, j)+3.*(vt(&
5628 & npx-1, j)+vt(npx, j))-vt(npx+1, j))
5631 IF (je + 1 .EQ. npy)
THEN 5634 vb(i, npy) = dt5*(vt(i-1, npy)+vt(i, npy))
5641 vb(i, j) = dt5*(vc(i-1, j)+vc(i, j))
5645 IF (hord_mt .EQ. hord_mt_pert)
THEN 5646 CALL ytp_v(is, ie, js, je, isd, ied, jsd, jed, vb, u, v, ub, &
5647 & hord_mt, gridstruct%dy, gridstruct%rdy, npx, npy, &
5648 & flagstruct%grid_type, nested)
5650 CALL ytp_v(is, ie, js, je, isd, ied, jsd, jed, vb, u, v, ub, &
5651 & hord_mt, gridstruct%dy, gridstruct%rdy, npx, npy, &
5652 & flagstruct%grid_type, nested)
5656 ke(i, j) = vb(i, j)*ub(i, j)
5659 IF (flagstruct%grid_type .LT. 3)
THEN 5663 ub(i, j) = dt5*(uc(i, j-1)+uc(i, j)-(vc(i-1, j)+vc(i, j))*&
5664 & cosa(i, j))*rsina(i, j)
5671 ub(1, j) = dt5*(ut(1, j-1)+ut(1, j))
5675 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 5678 ub(i, j) = dt4*(-ut(i, j-2)+3.*(ut(i, j-1)+ut(i, j))-ut(i&
5683 ub(i, j) = dt5*(uc(i, j-1)+uc(i, j)-(vc(i-1, j)+vc(i, j))*&
5684 & cosa(i, j))*rsina(i, j)
5688 IF (ie + 1 .EQ. npx)
THEN 5691 ub(npx, j) = dt5*(ut(npx, j-1)+ut(npx, j))
5698 ub(i, j) = dt5*(uc(i, j-1)+uc(i, j))
5702 IF (hord_mt .EQ. hord_mt_pert)
THEN 5703 CALL xtp_u(is, ie, js, je, isd, ied, jsd, jed, ub, u, v, vb, &
5704 & hord_mt, gridstruct%dx, gridstruct%rdx, npx, npy, &
5705 & flagstruct%grid_type, nested)
5707 CALL xtp_u(is, ie, js, je, isd, ied, jsd, jed, ub, u, v, vb, &
5708 & hord_mt, gridstruct%dx, gridstruct%rdx, npx, npy, &
5709 & flagstruct%grid_type, nested)
5713 ke(i, j) = 0.5*(ke(i, j)+ub(i, j)*vb(i, j))
5719 IF (.NOT.nested)
THEN 5721 IF (sw_corner) ke(1, 1) = dt6*((ut(1, 1)+ut(1, 0))*u(1, 1)+(vt(1, &
5722 & 1)+vt(0, 1))*v(1, 1)+(ut(1, 1)+vt(1, 1))*u(0, 1))
5723 IF (se_corner) ke(npx, 1) = dt6*((ut(npx, 1)+ut(npx, 0))*u(npx-1, &
5724 & 1)+(vt(npx, 1)+vt(npx-1, 1))*v(npx, 1)+(ut(npx, 1)-vt(npx-1, 1&
5727 IF (ne_corner) ke(npx, npy) = dt6*((ut(npx, npy)+ut(npx, npy-1))*u&
5728 & (npx-1, npy)+(vt(npx, npy)+vt(npx-1, npy))*v(npx, npy-1)+(ut(&
5729 & npx, npy-1)+vt(npx-1, npy))*u(npx, npy))
5731 IF (nw_corner) ke(1, npy) = dt6*((ut(1, npy)+ut(1, npy-1))*u(1, &
5732 & npy)+(vt(1, npy)+vt(0, npy))*v(1, npy-1)+(ut(1, npy-1)-vt(1, &
5739 vt(i, j) = u(i, j)*dx(i, j)
5744 ut(i, j) = v(i, j)*dy(i, j)
5750 wk(i, j) = rarea(i, j)*(vt(i, j)-vt(i, j+1)+(ut(i+1, j)-ut(i, j)&
5754 IF (.NOT.hydrostatic)
THEN 5755 IF (.NOT.flagstruct%do_f3d)
THEN 5758 w(i, j) = w(i, j)/delp(i, j)
5762 IF (damp_w .GT. 1.e-5)
THEN 5765 w(i, j) = w(i, j) + dw(i, j)
5946 IF (.NOT.split_damp)
THEN 5948 & vort, ptc, delpc, ke, u, v, uc, vc, &
5949 & ua, va, divg_d, wk, gridstruct, &
5953 & , dddmp, dt, vort, ptc, delpc, ke, &
5954 & u, v, uc, vc, ua, va, divg_d, wk, &
5955 & gridstruct, flagstruct, bd)
5957 IF (d_con .GT. 1.e-5)
THEN 5960 ub(i, j) = vort(i, j) - vort(i+1, j)
5965 vb(i, j) = vort(i, j) - vort(i, j+1)
5970 IF (hydrostatic)
THEN 5973 vort(i, j) = wk(i, j) +
f0(i, j)
5976 ELSE IF (flagstruct%do_f3d)
THEN 5979 vort(i, j) = wk(i, j) +
f0(i, j)*z_rat(i, j)
5985 vort(i, j) = wk(i, j) +
f0(i, j)
5989 IF (hord_vt .EQ. hord_vt_pert)
THEN 5990 CALL fv_tp_2d(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx, fy&
5991 & , xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y)
5993 CALL fv_tp_2d(vort, crx_adv, cry_adv, npx, npy, hord_vt, fx, &
5994 & fy, xfx_adv, yfx_adv, gridstruct, bd, ra_x, ra_y)
5998 u(i, j) = vt(i, j) + (ke(i, j)-ke(i+1, j)) + fy(i, j)
6003 v(i, j) = ut(i, j) + (ke(i, j)-ke(i, j+1)) - fx(i, j)
6008 IF (damp_v .GT. 1.e-5)
THEN 6009 damp4 = (damp_v*gridstruct%da_min_c)**(nord_v+1)
6010 CALL del6_vt_flux(nord_v, npx, npy, damp4, wk, vort, ut, vt, &
6013 IF (d_con .GT. 1.e-5)
THEN 6016 ub(i, j) = (ub(i, j)+vt(i, j))*rdx(i, j)
6017 fy(i, j) = u(i, j)*rdx(i, j)
6018 gy(i, j) = fy(i, j)*ub(i, j)
6023 vb(i, j) = (vb(i, j)-ut(i, j))*rdy(i, j)
6024 fx(i, j) = v(i, j)*rdy(i, j)
6025 gx(i, j) = fx(i, j)*vb(i, j)
6034 u2 = fy(i, j) + fy(i, j+1)
6035 du2 = ub(i, j) + ub(i, j+1)
6036 v2 = fx(i, j) + fx(i+1, j)
6037 dv2 = vb(i, j) + vb(i+1, j)
6040 heat_source(i, j) = delp(i, j)*(heat_source(i, j)-damp*rsin2(i&
6041 & , j)*(ub(i, j)**2+ub(i, j+1)**2+vb(i, j)**2+vb(i+1, j)**2+2.&
6042 & *(gy(i, j)+gy(i, j+1)+gx(i, j)+gx(i+1, j))-cosa_s(i, j)*(
u2*&
6043 & dv2+v2*du2+du2*dv2)))
6048 IF (damp_v .GT. 1.e-5)
THEN 6051 u(i, j) = u(i, j) + vt(i, j)
6056 v(i, j) = v(i, j) - ut(i, j)
6082 & fx2, fx2_ad, fy2, fy2_ad, gridstruct, bd)
6091 INTEGER,
INTENT(IN) :: nord, npx, npy
6092 REAL,
INTENT(IN) :: damp
6095 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed)
6096 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
6099 REAL :: d2(bd%isd:bd%ied, bd%jsd:bd%jed)
6100 REAL :: d2_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
6101 REAL :: fx2(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy2(bd%isd:bd%ied, bd%&
6103 REAL :: fx2_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy2_ad(bd%isd:bd%ied&
6104 & , bd%jsd:bd%jed+1)
6105 INTEGER :: i, j, nt, n, i1, i2, j1, j2
6107 INTEGER :: is, ie, js, je
6126 nested = gridstruct%nested
6135 IF (nord .GT. 0)
THEN 6140 IF (nord .GT. 0)
THEN 6145 IF (nord .GT. 0)
THEN 6148 ad_from0 = js - nt - 1
6149 DO j=ad_from0,je+nt+1
6150 ad_from = is - nt - 1
6167 DO j=ad_from4,je+nt+1
6179 DO j=ad_to4,ad_from4,-1
6182 DO i=ad_to3,ad_from3,-1
6183 temp_ad3 = gridstruct%del6_u(i, j)*fy2_ad(i, j)
6184 d2_ad(i, j) = d2_ad(i, j) + temp_ad3
6185 d2_ad(i, j-1) = d2_ad(i, j-1) - temp_ad3
6190 & gridstruct%sw_corner, gridstruct%se_corner, &
6191 & gridstruct%nw_corner, gridstruct%ne_corner)
6194 DO j=ad_to2,ad_from2,-1
6197 DO i=ad_to1,ad_from1,-1
6198 temp_ad2 = gridstruct%del6_v(i, j)*fx2_ad(i, j)
6199 d2_ad(i, j) = d2_ad(i, j) + temp_ad2
6200 d2_ad(i-1, j) = d2_ad(i-1, j) - temp_ad2
6205 & gridstruct%sw_corner, gridstruct%se_corner, &
6206 & gridstruct%nw_corner, gridstruct%ne_corner)
6209 DO j=ad_to0,ad_from0,-1
6212 DO i=ad_to,ad_from,-1
6213 temp_ad1 = gridstruct%rarea(i, j)*d2_ad(i, j)
6214 fx2_ad(i, j) = fx2_ad(i, j) + temp_ad1
6215 fx2_ad(i+1, j) = fx2_ad(i+1, j) - temp_ad1
6216 fy2_ad(i, j) = fy2_ad(i, j) + temp_ad1
6217 fy2_ad(i, j+1) = fy2_ad(i, j+1) - temp_ad1
6223 DO j=je+nord+1,js-nord,-1
6224 DO i=ie+nord,is-nord,-1
6225 temp_ad0 = gridstruct%del6_u(i, j)*fy2_ad(i, j)
6226 d2_ad(i, j-1) = d2_ad(i, j-1) + temp_ad0
6227 d2_ad(i, j) = d2_ad(i, j) - temp_ad0
6233 & nested, bd, gridstruct%sw_corner&
6234 & , gridstruct%se_corner, &
6235 & gridstruct%nw_corner, gridstruct%&
6237 DO j=je+nord,js-nord,-1
6238 DO i=ie+nord+1,is-nord,-1
6239 temp_ad = gridstruct%del6_v(i, j)*fx2_ad(i, j)
6240 d2_ad(i-1, j) = d2_ad(i-1, j) + temp_ad
6241 d2_ad(i, j) = d2_ad(i, j) - temp_ad
6247 & nested, bd, gridstruct%sw_corner&
6248 & , gridstruct%se_corner, &
6249 & gridstruct%nw_corner, gridstruct%&
6253 q_ad(i, j) = q_ad(i, j) + damp*d2_ad(i, j)
6258 SUBROUTINE del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, &
6268 INTEGER,
INTENT(IN) :: nord, npx, npy
6269 REAL,
INTENT(IN) :: damp
6272 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed)
6275 REAL,
INTENT(OUT) :: d2(bd%isd:bd%ied, bd%jsd:bd%jed)
6276 REAL,
INTENT(OUT) :: fx2(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy2(bd%isd&
6277 & :bd%ied, bd%jsd:bd%jed+1)
6278 INTEGER :: i, j, nt, n, i1, i2, j1, j2
6280 INTEGER :: is, ie, js, je
6281 nested = gridstruct%nested
6292 d2(i, j) = damp*q(i, j)
6295 IF (nord .GT. 0)
CALL copy_corners(d2, npx, npy, 1, nested, bd, &
6296 & gridstruct%sw_corner, gridstruct%&
6297 & se_corner, gridstruct%nw_corner, &
6298 & gridstruct%ne_corner)
6299 DO j=js-nord,je+nord
6300 DO i=is-nord,ie+nord+1
6301 fx2(i, j) = gridstruct%del6_v(i, j)*(d2(i-1, j)-d2(i, j))
6304 IF (nord .GT. 0)
CALL copy_corners(d2, npx, npy, 2, nested, bd, &
6305 & gridstruct%sw_corner, gridstruct%&
6306 & se_corner, gridstruct%nw_corner, &
6307 & gridstruct%ne_corner)
6308 DO j=js-nord,je+nord+1
6309 DO i=is-nord,ie+nord
6310 fy2(i, j) = gridstruct%del6_u(i, j)*(d2(i, j-1)-d2(i, j))
6313 IF (nord .GT. 0)
THEN 6316 DO j=js-nt-1,je+nt+1
6317 DO i=is-nt-1,ie+nt+1
6318 d2(i, j) = (fx2(i, j)-fx2(i+1, j)+(fy2(i, j)-fy2(i, j+1)))*&
6319 & gridstruct%rarea(i, j)
6322 CALL copy_corners(d2, npx, npy, 1, nested, bd, gridstruct%&
6323 & sw_corner, gridstruct%se_corner, gridstruct%&
6324 & nw_corner, gridstruct%ne_corner)
6327 fx2(i, j) = gridstruct%del6_v(i, j)*(d2(i, j)-d2(i-1, j))
6330 CALL copy_corners(d2, npx, npy, 2, nested, bd, gridstruct%&
6331 & sw_corner, gridstruct%se_corner, gridstruct%&
6332 & nw_corner, gridstruct%ne_corner)
6335 fy2(i, j) = gridstruct%del6_u(i, j)*(d2(i, j)-d2(i, j-1))
6367 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
6368 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
6369 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
6370 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d
6374 REAL :: uf(bd%is-2:bd%ie+2, bd%js-1:bd%je+2)
6375 REAL :: vf(bd%is-1:bd%ie+2, bd%js-2:bd%je+2)
6378 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
6379 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc
6380 INTEGER :: is, ie, js, je
6401 npx = flagstruct%npx
6402 npy = flagstruct%npy
6403 nested = gridstruct%nested
6404 sin_sg => gridstruct%sin_sg
6405 cos_sg => gridstruct%cos_sg
6406 dxc => gridstruct%dxc
6407 dyc => gridstruct%dyc
6418 IF (npx - 1 .GT. ie + 1)
THEN 6426 IF (flagstruct%grid_type .EQ. 4)
THEN 6429 uf(i, j) = u(i, j)*dyc(i, j)
6434 vf(i, j) = v(i, j)*dxc(i, j)
6439 divg_d(i, j) = gridstruct%rarea_c(i, j)*(vf(i, j-1)-vf(i, j)+(&
6440 & uf(i-1, j)-uf(i, j)))
6457 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 6459 uf(i, j) = u(i, j)*dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+sin_sg(i&
6465 uf(i, j) = (u(i, j)-0.25*(va(i, j-1)+va(i, j))*(cos_sg(i, j-&
6466 & 1, 4)+cos_sg(i, j, 2)))*dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+&
6474 vf(i, j) = (v(i, j)-0.25*(ua(i-1, j)+ua(i, j))*(cos_sg(i-1, j&
6475 & , 3)+cos_sg(i, j, 1)))*dxc(i, j)*0.5*(sin_sg(i-1, j, 3)+&
6479 vf(1, j) = v(1, j)*dxc(1, j)*0.5*(sin_sg(0, j, 3)+sin_sg(1, j&
6485 IF (ie + 1 .EQ. npx)
THEN 6486 vf(npx, j) = v(npx, j)*dxc(npx, j)*0.5*(sin_sg(npx-1, j, 3)+&
6487 & sin_sg(npx, j, 1))
6495 divg_d(i, j) = vf(i, j-1) - vf(i, j) + (uf(i-1, j)-uf(i, j))
6499 IF (gridstruct%sw_corner)
THEN 6500 divg_d(1, 1) = divg_d(1, 1) - vf(1, 0)
6505 IF (gridstruct%se_corner)
THEN 6506 divg_d(npx, 1) = divg_d(npx, 1) - vf(npx, 0)
6511 IF (gridstruct%ne_corner)
THEN 6512 divg_d(npx, npy) = divg_d(npx, npy) + vf(npx, npy)
6517 IF (gridstruct%nw_corner)
THEN 6518 divg_d(1, npy) = divg_d(1, npy) + vf(1, npy)
6525 divg_d(i, j) = gridstruct%rarea_c(i, j)*divg_d(i, j)
6564 & va_ad, divg_d, divg_d_ad, gridstruct, flagstruct, bd)
6569 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
6570 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u_ad
6571 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
6572 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: v_ad
6573 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
6574 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua_ad, va_ad
6575 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d
6576 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d_ad
6579 REAL :: uf(bd%is-2:bd%ie+2, bd%js-1:bd%je+2)
6580 REAL :: uf_ad(bd%is-2:bd%ie+2, bd%js-1:bd%je+2)
6581 REAL :: vf(bd%is-1:bd%ie+2, bd%js-2:bd%je+2)
6582 REAL :: vf_ad(bd%is-1:bd%ie+2, bd%js-2:bd%je+2)
6585 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
6586 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc
6587 INTEGER :: is, ie, js, je
6617 npx = flagstruct%npx
6618 npy = flagstruct%npy
6619 nested = gridstruct%nested
6620 sin_sg => gridstruct%sin_sg
6621 cos_sg => gridstruct%cos_sg
6622 dxc => gridstruct%dxc
6623 dyc => gridstruct%dyc
6625 IF (branch .EQ. 0)
THEN 6628 dxc => gridstruct%dxc
6631 dyc => gridstruct%dyc
6640 temp_ad = gridstruct%rarea_c(i, j)*divg_d_ad(i, j)
6641 vf_ad(i, j-1) = vf_ad(i, j-1) + temp_ad
6642 vf_ad(i, j) = vf_ad(i, j) - temp_ad
6643 uf_ad(i-1, j) = uf_ad(i-1, j) + temp_ad
6644 uf_ad(i, j) = uf_ad(i, j) - temp_ad
6645 divg_d_ad(i, j) = 0.0
6650 v_ad(i, j) = v_ad(i, j) + dxc(i, j)*vf_ad(i, j)
6656 u_ad(i, j) = u_ad(i, j) + dyc(i, j)*uf_ad(i, j)
6665 cos_sg => gridstruct%cos_sg
6668 dxc => gridstruct%dxc
6672 sin_sg => gridstruct%sin_sg
6675 dyc => gridstruct%dyc
6683 divg_d_ad(i, j) = gridstruct%rarea_c(i, j)*divg_d_ad(i, j)
6687 IF (branch .EQ. 0)
THEN 6690 npy = flagstruct%npy
6692 vf_ad(1, npy) = vf_ad(1, npy) + divg_d_ad(1, npy)
6695 IF (branch .EQ. 0)
THEN 6696 npx = flagstruct%npx
6697 vf_ad(npx, npy) = vf_ad(npx, npy) + divg_d_ad(npx, npy)
6700 IF (branch .EQ. 0) vf_ad(npx, 0) = vf_ad(npx, 0) - divg_d_ad(npx, &
6703 IF (branch .EQ. 0) vf_ad(1, 0) = vf_ad(1, 0) - divg_d_ad(1, 1)
6707 vf_ad(i, j-1) = vf_ad(i, j-1) + divg_d_ad(i, j)
6708 vf_ad(i, j) = vf_ad(i, j) - divg_d_ad(i, j)
6709 uf_ad(i-1, j) = uf_ad(i-1, j) + divg_d_ad(i, j)
6710 uf_ad(i, j) = uf_ad(i, j) - divg_d_ad(i, j)
6711 divg_d_ad(i, j) = 0.0
6716 IF (branch .NE. 0)
THEN 6717 v_ad(npx, j) = v_ad(npx, j) + dxc(npx, j)*(sin_sg(npx-1, j, 3)&
6718 & +sin_sg(npx, j, 1))*0.5*vf_ad(npx, j)
6722 IF (branch .EQ. 0)
THEN 6723 v_ad(1, j) = v_ad(1, j) + dxc(1, j)*(sin_sg(0, j, 3)+sin_sg(1&
6724 & , j, 1))*0.5*vf_ad(1, j)
6728 temp_ad2 = dxc(i, j)*0.5*(sin_sg(i-1, j, 3)+sin_sg(i, j, 1))*&
6730 temp_ad3 = -((cos_sg(i-1, j, 3)+cos_sg(i, j, 1))*0.25*temp_ad2&
6732 v_ad(i, j) = v_ad(i, j) + temp_ad2
6733 ua_ad(i-1, j) = ua_ad(i-1, j) + temp_ad3
6734 ua_ad(i, j) = ua_ad(i, j) + temp_ad3
6740 IF (branch .EQ. 0)
THEN 6742 temp_ad0 = dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+sin_sg(i, j, 2))&
6744 temp_ad1 = -((cos_sg(i, j-1, 4)+cos_sg(i, j, 2))*0.25*&
6746 u_ad(i, j) = u_ad(i, j) + temp_ad0
6747 va_ad(i, j-1) = va_ad(i, j-1) + temp_ad1
6748 va_ad(i, j) = va_ad(i, j) + temp_ad1
6753 u_ad(i, j) = u_ad(i, j) + dyc(i, j)*(sin_sg(i, j-1, 4)+&
6754 & sin_sg(i, j, 2))*0.5*uf_ad(i, j)
6766 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
6767 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
6768 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
6769 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(OUT) :: &
6774 REAL :: uf(bd%is-2:bd%ie+2, bd%js-1:bd%je+2)
6775 REAL :: vf(bd%is-1:bd%ie+2, bd%js-2:bd%je+2)
6778 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
6779 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc
6780 INTEGER :: is, ie, js, je
6789 npx = flagstruct%npx
6790 npy = flagstruct%npy
6791 nested = gridstruct%nested
6792 sin_sg => gridstruct%sin_sg
6793 cos_sg => gridstruct%cos_sg
6794 dxc => gridstruct%dxc
6795 dyc => gridstruct%dyc
6805 IF (npx - 1 .GT. ie + 1)
THEN 6811 IF (flagstruct%grid_type .EQ. 4)
THEN 6814 uf(i, j) = u(i, j)*dyc(i, j)
6819 vf(i, j) = v(i, j)*dxc(i, j)
6824 divg_d(i, j) = gridstruct%rarea_c(i, j)*(vf(i, j-1)-vf(i, j)+(&
6825 & uf(i-1, j)-uf(i, j)))
6835 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 6837 uf(i, j) = u(i, j)*dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+sin_sg(i&
6842 uf(i, j) = (u(i, j)-0.25*(va(i, j-1)+va(i, j))*(cos_sg(i, j-&
6843 & 1, 4)+cos_sg(i, j, 2)))*dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+&
6850 vf(i, j) = (v(i, j)-0.25*(ua(i-1, j)+ua(i, j))*(cos_sg(i-1, j&
6851 & , 3)+cos_sg(i, j, 1)))*dxc(i, j)*0.5*(sin_sg(i-1, j, 3)+&
6854 IF (is .EQ. 1) vf(1, j) = v(1, j)*dxc(1, j)*0.5*(sin_sg(0, j, 3)&
6856 IF (ie + 1 .EQ. npx) vf(npx, j) = v(npx, j)*dxc(npx, j)*0.5*(&
6857 & sin_sg(npx-1, j, 3)+sin_sg(npx, j, 1))
6861 divg_d(i, j) = vf(i, j-1) - vf(i, j) + (uf(i-1, j)-uf(i, j))
6865 IF (gridstruct%sw_corner) divg_d(1, 1) = divg_d(1, 1) - vf(1, 0)
6866 IF (gridstruct%se_corner) divg_d(npx, 1) = divg_d(npx, 1) - vf(npx&
6868 IF (gridstruct%ne_corner) divg_d(npx, npy) = divg_d(npx, npy) + vf&
6870 IF (gridstruct%nw_corner) divg_d(1, npy) = divg_d(1, npy) + vf(1, &
6874 divg_d(i, j) = gridstruct%rarea_c(i, j)*divg_d(i, j)
6924 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
6925 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
6926 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
6927 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d
6931 REAL :: uf(bd%isd:bd%ied, bd%jsd:bd%jed+1)
6932 REAL :: vf(bd%isd:bd%ied+1, bd%jsd:bd%jed)
6934 REAL,
DIMENSION(:, :),
POINTER :: rarea_c
6935 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
6936 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v
6937 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
6938 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc
6939 INTEGER :: isd, ied, jsd, jed
6956 rarea_c => gridstruct%rarea_c
6957 sin_sg => gridstruct%sin_sg
6958 cos_sg => gridstruct%cos_sg
6959 dxc => gridstruct%dxc
6960 dyc => gridstruct%dyc
6962 IF (flagstruct%grid_type .EQ. 4)
THEN 6965 uf(i, j) = u(i, j)*dyc(i, j)
6970 vf(i, j) = v(i, j)*dxc(i, j)
6975 divg_d(i, j) = rarea_c(i, j)*(vf(i, j-1)-vf(i, j)+(uf(i-1, j)-&
6990 uf(i, j) = (u(i, j)-0.25*(va(i, j-1)+va(i, j))*(cos_sg(i, j-1&
6991 & , 4)+cos_sg(i, j, 2)))*dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+&
6997 vf(i, j) = (v(i, j)-0.25*(ua(i-1, j)+ua(i, j))*(cos_sg(i-1, j&
6998 & , 3)+cos_sg(i, j, 1)))*dxc(i, j)*0.5*(sin_sg(i-1, j, 3)+&
7004 divg_d(i, j) = (vf(i, j-1)-vf(i, j)+(uf(i-1, j)-uf(i, j)))*&
7041 & , va_ad, divg_d, divg_d_ad, gridstruct, flagstruct, bd)
7065 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
7066 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u_ad
7067 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
7068 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: v_ad
7069 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
7070 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua_ad, va_ad
7071 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d
7072 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1) :: divg_d_ad
7075 REAL :: uf(bd%isd:bd%ied, bd%jsd:bd%jed+1)
7076 REAL :: uf_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1)
7077 REAL :: vf(bd%isd:bd%ied+1, bd%jsd:bd%jed)
7078 REAL :: vf_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed)
7080 REAL,
DIMENSION(:, :),
POINTER :: rarea_c
7081 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
7082 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v
7083 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
7084 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc
7085 INTEGER :: isd, ied, jsd, jed
7112 rarea_c => gridstruct%rarea_c
7113 sin_sg => gridstruct%sin_sg
7114 cos_sg => gridstruct%cos_sg
7115 dxc => gridstruct%dxc
7116 dyc => gridstruct%dyc
7118 IF (branch .EQ. 0)
THEN 7120 dxc => gridstruct%dxc
7123 rarea_c => gridstruct%rarea_c
7128 dyc => gridstruct%dyc
7136 temp_ad = rarea_c(i, j)*divg_d_ad(i, j)
7137 vf_ad(i, j-1) = vf_ad(i, j-1) + temp_ad
7138 vf_ad(i, j) = vf_ad(i, j) - temp_ad
7139 uf_ad(i-1, j) = uf_ad(i-1, j) + temp_ad
7140 uf_ad(i, j) = uf_ad(i, j) - temp_ad
7141 divg_d_ad(i, j) = 0.0
7146 v_ad(i, j) = v_ad(i, j) + dxc(i, j)*vf_ad(i, j)
7152 u_ad(i, j) = u_ad(i, j) + dyc(i, j)*uf_ad(i, j)
7158 cos_sg => gridstruct%cos_sg
7161 dxc => gridstruct%dxc
7164 rarea_c => gridstruct%rarea_c
7169 sin_sg => gridstruct%sin_sg
7172 dyc => gridstruct%dyc
7180 temp_ad4 = rarea_c(i, j)*divg_d_ad(i, j)
7181 vf_ad(i, j-1) = vf_ad(i, j-1) + temp_ad4
7182 vf_ad(i, j) = vf_ad(i, j) - temp_ad4
7183 uf_ad(i-1, j) = uf_ad(i-1, j) + temp_ad4
7184 uf_ad(i, j) = uf_ad(i, j) - temp_ad4
7185 divg_d_ad(i, j) = 0.0
7190 temp_ad2 = dxc(i, j)*0.5*(sin_sg(i-1, j, 3)+sin_sg(i, j, 1))*&
7192 temp_ad3 = -((cos_sg(i-1, j, 3)+cos_sg(i, j, 1))*0.25*temp_ad2&
7194 v_ad(i, j) = v_ad(i, j) + temp_ad2
7195 ua_ad(i-1, j) = ua_ad(i-1, j) + temp_ad3
7196 ua_ad(i, j) = ua_ad(i, j) + temp_ad3
7202 temp_ad0 = dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+sin_sg(i, j, 2))*&
7204 temp_ad1 = -((cos_sg(i, j-1, 4)+cos_sg(i, j, 2))*0.25*temp_ad0&
7206 u_ad(i, j) = u_ad(i, j) + temp_ad0
7207 va_ad(i, j-1) = va_ad(i, j-1) + temp_ad1
7208 va_ad(i, j) = va_ad(i, j) + temp_ad1
7237 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
7238 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
7239 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
7240 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(OUT) :: &
7245 REAL :: uf(bd%isd:bd%ied, bd%jsd:bd%jed+1)
7246 REAL :: vf(bd%isd:bd%ied+1, bd%jsd:bd%jed)
7248 REAL,
DIMENSION(:, :),
POINTER :: rarea_c
7249 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg, cos_sg
7250 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v
7251 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
7252 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc
7253 INTEGER :: isd, ied, jsd, jed
7260 npx = flagstruct%npx
7261 npy = flagstruct%npy
7262 nested = gridstruct%nested
7263 rarea_c => gridstruct%rarea_c
7264 sin_sg => gridstruct%sin_sg
7265 cos_sg => gridstruct%cos_sg
7266 cosa_u => gridstruct%cosa_u
7267 cosa_v => gridstruct%cosa_v
7268 sina_u => gridstruct%sina_u
7269 sina_v => gridstruct%sina_v
7270 dxc => gridstruct%dxc
7271 dyc => gridstruct%dyc
7273 IF (flagstruct%grid_type .EQ. 4)
THEN 7276 uf(i, j) = u(i, j)*dyc(i, j)
7281 vf(i, j) = v(i, j)*dxc(i, j)
7286 divg_d(i, j) = rarea_c(i, j)*(vf(i, j-1)-vf(i, j)+(uf(i-1, j)-&
7293 uf(i, j) = (u(i, j)-0.25*(va(i, j-1)+va(i, j))*(cos_sg(i, j-1&
7294 & , 4)+cos_sg(i, j, 2)))*dyc(i, j)*0.5*(sin_sg(i, j-1, 4)+&
7300 vf(i, j) = (v(i, j)-0.25*(ua(i-1, j)+ua(i, j))*(cos_sg(i-1, j&
7301 & , 3)+cos_sg(i, j, 1)))*dxc(i, j)*0.5*(sin_sg(i-1, j, 3)+&
7307 divg_d(i, j) = (vf(i, j-1)-vf(i, j)+(uf(i-1, j)-uf(i, j)))*&
7313 SUBROUTINE smag_corner(dt, u, v, ua, va, smag_c, bd, npx, npy, &
7318 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7319 REAL,
INTENT(IN) :: dt
7320 INTEGER,
INTENT(IN) :: npx, npy, ng
7321 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
7322 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
7323 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
7324 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(OUT) :: smag_c
7325 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
7327 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
7328 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
7330 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
7331 REAL :: sh(bd%isd:bd%ied, bd%jsd:bd%jed)
7334 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc, dx, dy, rarea, rarea_c
7335 INTEGER :: is, ie, js, je
7336 INTEGER :: isd, ied, jsd, jed
7348 dxc => gridstruct%dxc
7349 dyc => gridstruct%dyc
7352 rarea => gridstruct%rarea
7353 rarea_c => gridstruct%rarea_c
7359 IF (npx - 1 .GT. ie + 1)
THEN 7369 ut(i, j) = u(i, j)*dyc(i, j)
7374 vt(i, j) = v(i, j)*dxc(i, j)
7379 smag_c(i, j) = rarea_c(i, j)*(vt(i, j-1)-vt(i, j)+(ut(i, j)-ut(i&
7387 vt(i, j) = u(i, j)*dx(i, j)
7392 ut(i, j) = v(i, j)*dy(i, j)
7397 wk(i, j) = rarea(i, j)*(vt(i, j)-vt(i, j+1)+(ut(i, j)-ut(i+1, j)&
7401 CALL a2b_ord4(wk, sh, gridstruct, npx, npy, is, ie, js, je, ng, &
7405 smag_c(i, j) = dt*sqrt(sh(i, j)**2+smag_c(i, j)**2)
7429 SUBROUTINE xtp_u_adm(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u, &
7430 & u_ad, v, flux, flux_ad, iord, dx, rdx, npx, npy, grid_type, nested)
7432 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
7433 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
7434 REAL :: u_ad(isd:ied, jsd:jed+1)
7435 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
7436 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
7437 REAL :: c_ad(is:ie+1, js:je+1)
7438 REAL :: flux(is:ie+1, js:je+1)
7439 REAL :: flux_ad(is:ie+1, js:je+1)
7440 REAL,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
7441 REAL,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
7442 INTEGER,
INTENT(IN) :: iord, npx, npy, grid_type
7443 LOGICAL,
INTENT(IN) :: nested
7445 REAL,
DIMENSION(is-1:ie+1) :: bl, br, b0
7446 REAL,
DIMENSION(is-1:ie+1) :: bl_ad, br_ad, b0_ad
7447 LOGICAL,
DIMENSION(is-1:ie+1) :: smt5, smt6
7448 REAL :: fx0(is:ie+1)
7449 REAL :: fx0_ad(is:ie+1)
7450 REAL :: al(is-1:ie+2), dm(is-2:ie+2)
7451 REAL :: al_ad(is-1:ie+2), dm_ad(is-2:ie+2)
7452 REAL :: dq(is-3:ie+2)
7453 REAL :: dq_ad(is-3:ie+2)
7454 REAL :: dl, dr, xt, pmp, lac, cfl
7455 REAL :: xt_ad, pmp_ad, lac_ad, cfl_ad
7456 REAL :: pmp_1, lac_1, pmp_2, lac_2
7457 REAL :: pmp_1_ad, lac_1_ad, pmp_2_ad, lac_2_ad
7458 REAL :: x0, x1, x0l, x0r
7459 REAL :: x0l_ad, x0r_ad
7569 IF (3 .LT. is - 1)
THEN 7574 IF (npx - 3 .GT. ie + 1)
THEN 7582 IF (iord .EQ. 1)
THEN 7585 IF (c(i, j) .GT. 0.)
THEN 7595 IF (branch .EQ. 0)
THEN 7596 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
7599 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
7604 ELSE IF (iord .LT. 8)
THEN 7608 al(i) =
p1*(u(i-1, j)+u(i, j)) +
p2*(u(i-2, j)+u(i+1, j))
7612 bl(i) = al(i) - u(i, j)
7614 br(i) = al(i+1) - u(i, j)
7616 IF (.NOT.nested .AND.
grid_type .LT. 3)
THEN 7618 xt =
c3*u(1, j) +
c2*u(2, j) +
c1*u(3, j)
7620 br(1) = xt - u(1, j)
7622 bl(2) = xt - u(2, j)
7624 br(2) = al(3) - u(2, j)
7625 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 7641 bl(0) =
c1*u(-2, j) +
c2*u(-1, j) +
c3*u(0, j) - u(0, j)
7642 xt = 0.5*(((2.*dx(0, j)+dx(-1, j))*u(0, j)-dx(0, j)*u(-1, &
7643 & j))/(dx(0, j)+dx(-1, j))+((2.*dx(1, j)+dx(2, j))*u(1, j)&
7644 & -dx(1, j)*u(2, j))/(dx(1, j)+dx(2, j)))
7646 br(0) = xt - u(0, j)
7648 bl(1) = xt - u(1, j)
7655 IF (ie + 1 .EQ. npx)
THEN 7657 bl(npx-2) = al(npx-2) - u(npx-2, j)
7658 xt =
c1*u(npx-3, j) +
c2*u(npx-2, j) +
c3*u(npx-1, j)
7660 br(npx-2) = xt - u(npx-2, j)
7662 bl(npx-1) = xt - u(npx-1, j)
7663 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 7678 xt = 0.5*(((2.*dx(npx-1, j)+dx(npx-2, j))*u(npx-1, j)-dx(&
7679 & npx-1, j)*u(npx-2, j))/(dx(npx-1, j)+dx(npx-2, j))+((2.*&
7680 & dx(npx, j)+dx(npx+1, j))*u(npx, j)-dx(npx, j)*u(npx+1, j&
7681 & ))/(dx(npx, j)+dx(npx+1, j)))
7683 br(npx-1) = xt - u(npx-1, j)
7685 bl(npx) = xt - u(npx, j)
7687 br(npx) =
c3*u(npx, j) +
c2*u(npx+1, j) +
c1*u(npx+2, j) -&
7700 b0(i) = bl(i) + br(i)
7702 IF (iord .EQ. 2)
THEN 7706 IF (c(i, j) .GT. 0.)
THEN 7713 ELSE IF (iord .EQ. 3)
THEN 7715 IF (b0(i) .GE. 0.)
THEN 7720 IF (bl(i) - br(i) .GE. 0.)
THEN 7725 smt5(i) = x0 .LT. x1
7726 smt6(i) = 3.*x0 .LT. x1
7733 IF (c(i, j) .GT. 0.)
THEN 7734 cfl = c(i, j)*rdx(i-1, j)
7735 IF (smt6(i-1) .OR. smt5(i))
THEN 7737 fx0(i) = br(i-1) - cfl*b0(i-1)
7739 ELSE IF (smt5(i-1))
THEN 7740 IF (bl(i-1) .GE. 0.)
THEN 7747 IF (br(i-1) .GE. 0.)
THEN 7754 IF (x2 .GT. y1)
THEN 7764 fx0(i) = sign(min1, br(i-1))
7771 cfl = c(i, j)*rdx(i, j)
7772 IF (smt6(i) .OR. smt5(i-1))
THEN 7774 fx0(i) = bl(i) + cfl*b0(i)
7776 ELSE IF (smt5(i))
THEN 7777 IF (bl(i) .GE. 0.)
THEN 7784 IF (br(i) .GE. 0.)
THEN 7791 IF (x3 .GT. y2)
THEN 7801 fx0(i) = sign(min2, bl(i))
7810 ELSE IF (iord .EQ. 4)
THEN 7813 IF (b0(i) .GE. 0.)
THEN 7818 IF (bl(i) - br(i) .GE. 0.)
THEN 7823 smt5(i) = x0 .LT. x1
7825 smt6(i) = 3.*x0 .LT. x1
7828 IF (c(i, j) .GT. 0.)
THEN 7829 IF (smt6(i-1) .OR. smt5(i))
THEN 7834 ELSE IF (smt6(i) .OR. smt5(i-1))
THEN 7843 IF (iord .EQ. 5)
THEN 7846 smt5(i) = bl(i)*br(i) .LT. 0.
7850 IF (3.*b0(i) .GE. 0.)
THEN 7855 IF (bl(i) - br(i) .GE. 0.)
THEN 7856 abs4 = bl(i) - br(i)
7858 abs4 = -(bl(i)-br(i))
7860 smt5(i) = abs0 .LT. abs4
7866 IF (c(i, j) .GT. 0.)
THEN 7867 cfl = c(i, j)*rdx(i-1, j)
7869 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
7872 cfl = c(i, j)*rdx(i, j)
7874 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
7877 IF (smt5(i-1) .OR. smt5(i))
THEN 7893 IF (branch .LT. 2)
THEN 7894 IF (branch .EQ. 0)
THEN 7897 IF (branch .NE. 0) fx0_ad(i) = fx0_ad(i) + flux_ad(i, j)
7899 IF (branch .EQ. 0)
THEN 7900 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
7902 cfl = c(i, j)*rdx(i-1, j)
7904 temp_ad7 = (1.-cfl)*fx0_ad(i)
7905 cfl_ad = -(b0(i-1)*temp_ad7) - (br(i-1)-cfl*b0(i-1))*&
7907 br_ad(i-1) = br_ad(i-1) + temp_ad7
7908 b0_ad(i-1) = b0_ad(i-1) - cfl*temp_ad7
7910 c_ad(i, j) = c_ad(i, j) + rdx(i-1, j)*cfl_ad
7912 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
7914 cfl = c(i, j)*rdx(i, j)
7916 temp_ad8 = (cfl+1.)*fx0_ad(i)
7917 cfl_ad = b0(i)*temp_ad8 + (bl(i)+cfl*b0(i))*fx0_ad(i)
7918 bl_ad(i) = bl_ad(i) + temp_ad8
7919 b0_ad(i) = b0_ad(i) + cfl*temp_ad8
7921 c_ad(i, j) = c_ad(i, j) + rdx(i, j)*cfl_ad
7925 IF (branch .EQ. 0) i = is - 2
7929 IF (branch .LT. 2)
THEN 7930 IF (branch .EQ. 0)
THEN 7931 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
7934 cfl = c(i, j)*rdx(i, j)
7935 temp_ad6 = (cfl+1.)*flux_ad(i, j)
7936 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
7937 cfl_ad = b0(i)*temp_ad6 + (bl(i)+cfl*b0(i))*flux_ad(i&
7939 bl_ad(i) = bl_ad(i) + temp_ad6
7940 b0_ad(i) = b0_ad(i) + cfl*temp_ad6
7942 c_ad(i, j) = c_ad(i, j) + rdx(i, j)*cfl_ad
7944 ELSE IF (branch .EQ. 2)
THEN 7945 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
7948 cfl = c(i, j)*rdx(i-1, j)
7949 temp_ad5 = (1.-cfl)*flux_ad(i, j)
7950 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
7951 cfl_ad = -(b0(i-1)*temp_ad5) - (br(i-1)-cfl*b0(i-1))*&
7953 br_ad(i-1) = br_ad(i-1) + temp_ad5
7954 b0_ad(i-1) = b0_ad(i-1) - cfl*temp_ad5
7956 c_ad(i, j) = c_ad(i, j) + rdx(i-1, j)*cfl_ad
7961 ELSE IF (branch .EQ. 2)
THEN 7964 IF (branch .EQ. 0)
THEN 7965 cfl = c(i, j)*rdx(i, j)
7966 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
7967 cfl_ad = fx0(i)*flux_ad(i, j)
7968 fx0_ad(i) = fx0_ad(i) + (cfl+1.)*flux_ad(i, j)
7971 IF (branch .EQ. 0)
THEN 7973 bl_ad(i) = bl_ad(i) + fx0_ad(i)
7974 cfl_ad = cfl_ad + b0(i)*fx0_ad(i)
7975 b0_ad(i) = b0_ad(i) + cfl*fx0_ad(i)
7977 ELSE IF (branch .EQ. 1)
THEN 7979 min2_ad = sign(1.d0, min2*bl(i))*fx0_ad(i)
7982 IF (branch .EQ. 0)
THEN 7992 IF (branch .EQ. 0)
THEN 7993 br_ad(i) = br_ad(i) + y2_ad
7995 br_ad(i) = br_ad(i) - y2_ad
7998 IF (branch .EQ. 0)
THEN 7999 bl_ad(i) = bl_ad(i) + x3_ad
8001 bl_ad(i) = bl_ad(i) - x3_ad
8004 c_ad(i, j) = c_ad(i, j) + rdx(i, j)*cfl_ad
8006 cfl = c(i, j)*rdx(i-1, j)
8007 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
8008 cfl_ad = -(fx0(i)*flux_ad(i, j))
8009 fx0_ad(i) = fx0_ad(i) + (1.-cfl)*flux_ad(i, j)
8012 IF (branch .EQ. 0)
THEN 8014 br_ad(i-1) = br_ad(i-1) + fx0_ad(i)
8015 cfl_ad = cfl_ad - b0(i-1)*fx0_ad(i)
8016 b0_ad(i-1) = b0_ad(i-1) - cfl*fx0_ad(i)
8018 ELSE IF (branch .EQ. 1)
THEN 8020 min1_ad = sign(1.d0, min1*br(i-1))*fx0_ad(i)
8023 IF (branch .EQ. 0)
THEN 8033 IF (branch .EQ. 0)
THEN 8034 br_ad(i-1) = br_ad(i-1) + y1_ad
8036 br_ad(i-1) = br_ad(i-1) - y1_ad
8039 IF (branch .EQ. 0)
THEN 8040 bl_ad(i-1) = bl_ad(i-1) + x2_ad
8042 bl_ad(i-1) = bl_ad(i-1) - x2_ad
8045 c_ad(i, j) = c_ad(i, j) + rdx(i-1, j)*cfl_ad
8056 IF (branch .EQ. 0)
THEN 8057 cfl = c(i, j)*rdx(i, j)
8058 temp_ad4 = (cfl+1.)*flux_ad(i, j)
8059 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
8060 cfl_ad = b0(i)*temp_ad4 + (bl(i)+cfl*b0(i))*flux_ad(i, j)
8061 bl_ad(i) = bl_ad(i) + temp_ad4
8062 b0_ad(i) = b0_ad(i) + cfl*temp_ad4
8064 c_ad(i, j) = c_ad(i, j) + rdx(i, j)*cfl_ad
8066 cfl = c(i, j)*rdx(i-1, j)
8067 temp_ad3 = (1.-cfl)*flux_ad(i, j)
8068 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
8069 cfl_ad = -(b0(i-1)*temp_ad3) - (br(i-1)-cfl*b0(i-1))*&
8071 br_ad(i-1) = br_ad(i-1) + temp_ad3
8072 b0_ad(i-1) = b0_ad(i-1) - cfl*temp_ad3
8074 c_ad(i, j) = c_ad(i, j) + rdx(i-1, j)*cfl_ad
8080 bl_ad(i) = bl_ad(i) + b0_ad(i)
8081 br_ad(i) = br_ad(i) + b0_ad(i)
8085 IF (branch .LT. 2)
THEN 8086 IF (branch .EQ. 0)
GOTO 100
8088 IF (branch .EQ. 2)
THEN 8090 u_ad(npx, j) = u_ad(npx, j) + (
c3-1.0)*br_ad(npx)
8091 u_ad(npx+1, j) = u_ad(npx+1, j) +
c2*br_ad(npx)
8092 u_ad(npx+2, j) = u_ad(npx+2, j) +
c1*br_ad(npx)
8095 xt_ad = br_ad(npx-1) + bl_ad(npx)
8096 u_ad(npx, j) = u_ad(npx, j) - bl_ad(npx)
8099 temp_ad1 = 0.5*xt_ad/(dx(npx-1, j)+dx(npx-2, j))
8100 u_ad(npx-1, j) = u_ad(npx-1, j) + (dx(npx-1, j)*2.+dx(npx-2&
8101 & , j))*temp_ad1 - br_ad(npx-1)
8103 temp_ad2 = 0.5*xt_ad/(dx(npx, j)+dx(npx+1, j))
8104 u_ad(npx-2, j) = u_ad(npx-2, j) - dx(npx-1, j)*temp_ad1
8105 u_ad(npx, j) = u_ad(npx, j) + (dx(npx, j)*2.+dx(npx+1, j))*&
8107 u_ad(npx+1, j) = u_ad(npx+1, j) - dx(npx, j)*temp_ad2
8119 xt_ad = br_ad(npx-2) + bl_ad(npx-1)
8120 u_ad(npx-1, j) = u_ad(npx-1, j) - bl_ad(npx-1)
8123 u_ad(npx-2, j) = u_ad(npx-2, j) - br_ad(npx-2)
8125 u_ad(npx-3, j) = u_ad(npx-3, j) +
c1*xt_ad
8126 u_ad(npx-2, j) = u_ad(npx-2, j) +
c2*xt_ad
8127 u_ad(npx-1, j) = u_ad(npx-1, j) +
c3*xt_ad
8129 al_ad(npx-2) = al_ad(npx-2) + bl_ad(npx-2)
8130 u_ad(npx-2, j) = u_ad(npx-2, j) - bl_ad(npx-2)
8134 IF (branch .EQ. 0)
THEN 8143 ELSE IF (branch .EQ. 1)
THEN 8145 xt_ad = br_ad(0) + bl_ad(1)
8146 u_ad(1, j) = u_ad(1, j) - bl_ad(1)
8149 temp_ad = 0.5*xt_ad/(dx(0, j)+dx(-1, j))
8150 u_ad(0, j) = u_ad(0, j) + (dx(0, j)*2.+dx(-1, j))*temp_ad - &
8153 temp_ad0 = 0.5*xt_ad/(dx(1, j)+dx(2, j))
8154 u_ad(-1, j) = u_ad(-1, j) - dx(0, j)*temp_ad
8155 u_ad(1, j) = u_ad(1, j) + (dx(1, j)*2.+dx(2, j))*temp_ad0
8156 u_ad(2, j) = u_ad(2, j) - dx(1, j)*temp_ad0
8158 u_ad(-2, j) = u_ad(-2, j) +
c1*bl_ad(0)
8159 u_ad(-1, j) = u_ad(-1, j) +
c2*bl_ad(0)
8160 u_ad(0, j) = u_ad(0, j) + (
c3-1.0)*bl_ad(0)
8166 al_ad(3) = al_ad(3) + br_ad(2)
8167 u_ad(2, j) = u_ad(2, j) - bl_ad(2) - br_ad(2)
8170 xt_ad = br_ad(1) + bl_ad(2)
8173 u_ad(1, j) = u_ad(1, j) +
c3*xt_ad - br_ad(1)
8175 u_ad(2, j) = u_ad(2, j) +
c2*xt_ad
8176 u_ad(3, j) = u_ad(3, j) +
c1*xt_ad
8179 al_ad(i+1) = al_ad(i+1) + br_ad(i)
8180 u_ad(i, j) = u_ad(i, j) - bl_ad(i) - br_ad(i)
8183 al_ad(i) = al_ad(i) + bl_ad(i)
8187 u_ad(i-1, j) = u_ad(i-1, j) +
p1*al_ad(i)
8188 u_ad(i, j) = u_ad(i, j) +
p1*al_ad(i)
8189 u_ad(i-2, j) = u_ad(i-2, j) +
p2*al_ad(i)
8190 u_ad(i+1, j) = u_ad(i+1, j) +
p2*al_ad(i)
8199 xt = 0.25*(u(i+1, j)-u(i-1, j))
8200 IF (xt .GE. 0.)
THEN 8207 IF (u(i-1, j) .LT. u(i, j))
THEN 8208 IF (u(i, j) .LT. u(i+1, j))
THEN 8215 ELSE IF (u(i-1, j) .LT. u(i+1, j))
THEN 8223 IF (u(i-1, j) .GT. u(i, j))
THEN 8224 IF (u(i, j) .GT. u(i+1, j))
THEN 8231 ELSE IF (u(i-1, j) .GT. u(i+1, j))
THEN 8239 IF (x4 .GT. y3)
THEN 8240 IF (y3 .GT. z1)
THEN 8249 ELSE IF (x4 .GT. z1)
THEN 8258 dm(i) = sign(min3, xt)
8261 dq(i) = u(i+1, j) - u(i, j)
8265 al(i) = 0.5*(u(i-1, j)+u(i, j)) +
r3*(dm(i-1)-dm(i))
8268 IF (iord .EQ. 8)
THEN 8272 IF (xt .GE. 0.)
THEN 8279 IF (al(i) - u(i, j) .GE. 0.)
THEN 8280 y4 = al(i) - u(i, j)
8283 y4 = -(al(i)-u(i, j))
8286 IF (x5 .GT. y4)
THEN 8296 bl(i) = -sign(min4, xt)
8297 IF (xt .GE. 0.)
THEN 8304 IF (al(i+1) - u(i, j) .GE. 0.)
THEN 8305 y5 = al(i+1) - u(i, j)
8308 y5 = -(al(i+1)-u(i, j))
8311 IF (x6 .GT. y5)
THEN 8321 br(i) = sign(min5, xt)
8324 ELSE IF (iord .EQ. 9)
THEN 8327 lac_1 = pmp_1 + 1.5*dq(i+1)
8328 IF (0. .LT. pmp_1)
THEN 8329 IF (pmp_1 .LT. lac_1)
THEN 8336 ELSE IF (0. .LT. lac_1)
THEN 8343 IF (0. .GT. pmp_1)
THEN 8344 IF (pmp_1 .GT. lac_1)
THEN 8351 ELSE IF (0. .GT. lac_1)
THEN 8358 IF (al(i) - u(i, j) .LT. y12)
THEN 8362 y6 = al(i) - u(i, j)
8365 IF (x7 .GT. y6)
THEN 8375 lac_2 = pmp_2 - 1.5*dq(i-2)
8376 IF (0. .LT. pmp_2)
THEN 8377 IF (pmp_2 .LT. lac_2)
THEN 8384 ELSE IF (0. .LT. lac_2)
THEN 8391 IF (0. .GT. pmp_2)
THEN 8392 IF (pmp_2 .GT. lac_2)
THEN 8399 ELSE IF (0. .GT. lac_2)
THEN 8406 IF (al(i+1) - u(i, j) .LT. y13)
THEN 8410 y7 = al(i+1) - u(i, j)
8413 IF (x8 .GT. y7)
THEN 8424 ELSE IF (iord .EQ. 10)
THEN 8427 bl(i) = al(i) - u(i, j)
8429 br(i) = al(i+1) - u(i, j)
8430 IF (dm(i) .GE. 0.)
THEN 8437 IF (dm(i-1) .GE. 0.)
THEN 8442 IF (dm(i+1) .GE. 0.)
THEN 8456 IF (3.*(bl(i)+br(i)) .GE. 0.)
THEN 8457 abs3 = 3.*(bl(i)+br(i))
8459 abs3 = -(3.*(bl(i)+br(i)))
8461 IF (bl(i) - br(i) .GE. 0.)
THEN 8462 abs6 = bl(i) - br(i)
8464 abs6 = -(bl(i)-br(i))
8466 IF (abs3 .GT. abs6)
THEN 8468 lac_1 = pmp_1 + 1.5*dq(i+1)
8469 IF (0. .LT. pmp_1)
THEN 8470 IF (pmp_1 .LT. lac_1)
THEN 8477 ELSE IF (0. .LT. lac_1)
THEN 8484 IF (0. .GT. pmp_1)
THEN 8485 IF (pmp_1 .GT. lac_1)
THEN 8492 ELSE IF (0. .GT. lac_1)
THEN 8499 IF (bl(i) .LT. y14)
THEN 8506 IF (x9 .GT. y8)
THEN 8514 lac_2 = pmp_2 - 1.5*dq(i-2)
8515 IF (0. .LT. pmp_2)
THEN 8516 IF (pmp_2 .LT. lac_2)
THEN 8523 ELSE IF (0. .LT. lac_2)
THEN 8530 IF (0. .GT. pmp_2)
THEN 8531 IF (pmp_2 .GT. lac_2)
THEN 8538 ELSE IF (0. .GT. lac_2)
THEN 8545 IF (br(i) .LT. y15)
THEN 8552 IF (x10 .GT. y9)
THEN 8569 bl(i) = al(i) - u(i, j)
8571 br(i) = al(i+1) - u(i, j)
8579 IF (is .EQ. 1 .AND. (.NOT.nested))
THEN 8581 br(2) = al(3) - u(2, j)
8583 xt =
s15*u(1, j) +
s11*u(2, j) -
s14*dm(2)
8585 bl(2) = xt - u(2, j)
8587 br(1) = xt - u(1, j)
8588 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 8604 bl(0) =
s14*dm(-1) -
s11*dq(-1)
8605 x0l = 0.5*((2.*dx(0, j)+dx(-1, j))*u(0, j)-dx(0, j)*u(-1, &
8606 & j))/(dx(0, j)+dx(-1, j))
8607 x0r = 0.5*((2.*dx(1, j)+dx(2, j))*u(1, j)-dx(1, j)*u(2, j)&
8608 & )/(dx(1, j)+dx(2, j))
8611 br(0) = xt - u(0, j)
8613 bl(1) = xt - u(1, j)
8618 CALL pert_ppm(1, u(2:2, j), bl(2:2), br(2:2), -1)
8623 IF (ie + 1 .EQ. npx .AND. (.NOT.nested))
THEN 8625 bl(npx-2) = al(npx-2) - u(npx-2, j)
8627 xt =
s15*u(npx-1, j) +
s11*u(npx-2, j) +
s14*dm(npx-2)
8629 br(npx-2) = xt - u(npx-2, j)
8631 bl(npx-1) = xt - u(npx-1, j)
8632 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 8648 br(npx) =
s11*dq(npx) -
s14*dm(npx+1)
8649 x0l = 0.5*((2.*dx(npx-1, j)+dx(npx-2, j))*u(npx-1, j)-dx(&
8650 & npx-1, j)*u(npx-2, j))/(dx(npx-1, j)+dx(npx-2, j))
8651 x0r = 0.5*((2.*dx(npx, j)+dx(npx+1, j))*u(npx, j)-dx(npx, &
8652 & j)*u(npx+1, j))/(dx(npx, j)+dx(npx+1, j))
8655 br(npx-1) = xt - u(npx-1, j)
8657 bl(npx) = xt - u(npx, j)
8662 CALL pert_ppm(1, u(npx-2:npx-2, j), bl(npx-2:npx-2), br(npx-&
8671 al(i) = 0.5*(u(i-1, j)+u(i, j)) +
r3*(dm(i-1)-dm(i))
8675 lac = pmp + 1.5*dq(i+1)
8676 IF (0. .LT. pmp)
THEN 8677 IF (pmp .LT. lac)
THEN 8684 ELSE IF (0. .LT. lac)
THEN 8691 IF (0. .GT. pmp)
THEN 8692 IF (pmp .GT. lac)
THEN 8699 ELSE IF (0. .GT. lac)
THEN 8706 IF (al(i) - u(i, j) .LT. y16)
THEN 8710 y10 = al(i) - u(i, j)
8713 IF (x11 .GT. y10)
THEN 8723 lac = pmp - 1.5*dq(i-2)
8724 IF (0. .LT. pmp)
THEN 8725 IF (pmp .LT. lac)
THEN 8732 ELSE IF (0. .LT. lac)
THEN 8739 IF (0. .GT. pmp)
THEN 8740 IF (pmp .GT. lac)
THEN 8747 ELSE IF (0. .GT. lac)
THEN 8754 IF (al(i+1) - u(i, j) .LT. y17)
THEN 8758 y11 = al(i+1) - u(i, j)
8761 IF (x12 .GT. y11)
THEN 8774 IF (c(i, j) .GT. 0.)
THEN 8789 IF (branch .EQ. 0)
THEN 8790 cfl = c(i, j)*rdx(i, j)
8791 temp_ad14 = (cfl+1.)*flux_ad(i, j)
8792 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
8793 cfl_ad = (bl(i)+br(i))*temp_ad14 + (bl(i)+cfl*(bl(i)+br(i)))&
8795 bl_ad(i) = bl_ad(i) + (cfl+1.0)*temp_ad14
8796 br_ad(i) = br_ad(i) + cfl*temp_ad14
8798 c_ad(i, j) = c_ad(i, j) + rdx(i, j)*cfl_ad
8800 cfl = c(i, j)*rdx(i-1, j)
8801 temp = bl(i-1) + br(i-1)
8802 temp_ad13 = (1.-cfl)*flux_ad(i, j)
8803 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
8804 cfl_ad = -(temp*temp_ad13) - (br(i-1)-cfl*temp)*flux_ad(i, j&
8806 br_ad(i-1) = br_ad(i-1) + (1.0-cfl)*temp_ad13
8807 bl_ad(i-1) = bl_ad(i-1) - cfl*temp_ad13
8809 c_ad(i, j) = c_ad(i, j) + rdx(i-1, j)*cfl_ad
8813 IF (branch .EQ. 0)
THEN 8816 IF (branch .EQ. 0)
THEN 8828 IF (branch .EQ. 0)
THEN 8831 al_ad(i+1) = al_ad(i+1) + y11_ad
8832 u_ad(i, j) = u_ad(i, j) - y11_ad
8836 IF (branch .LT. 2)
THEN 8837 IF (branch .EQ. 0)
THEN 8845 IF (branch .EQ. 2)
THEN 8853 IF (branch .LT. 2)
THEN 8854 IF (branch .EQ. 0)
THEN 8855 lac_ad = lac_ad + x12_ad
8857 pmp_ad = pmp_ad + x12_ad
8859 ELSE IF (branch .EQ. 2)
THEN 8860 lac_ad = lac_ad + x12_ad
8862 pmp_ad = pmp_ad + lac_ad
8863 dq_ad(i-2) = dq_ad(i-2) - 1.5*lac_ad
8864 dq_ad(i-1) = dq_ad(i-1) + 2.*pmp_ad
8866 IF (branch .EQ. 0)
THEN 8878 IF (branch .EQ. 0)
THEN 8881 al_ad(i) = al_ad(i) + y10_ad
8882 u_ad(i, j) = u_ad(i, j) - y10_ad
8886 IF (branch .LT. 2)
THEN 8887 IF (branch .EQ. 0)
THEN 8895 IF (branch .EQ. 2)
THEN 8903 IF (branch .LT. 2)
THEN 8904 IF (branch .EQ. 0)
THEN 8905 lac_ad = lac_ad + x11_ad
8907 pmp_ad = pmp_ad + x11_ad
8909 ELSE IF (branch .EQ. 2)
THEN 8910 lac_ad = lac_ad + x11_ad
8912 pmp_ad = pmp_ad + lac_ad
8913 dq_ad(i+1) = dq_ad(i+1) + 1.5*lac_ad
8914 dq_ad(i) = dq_ad(i) - 2.*pmp_ad
8917 u_ad(i-1, j) = u_ad(i-1, j) + 0.5*al_ad(i)
8918 u_ad(i, j) = u_ad(i, j) + 0.5*al_ad(i)
8919 dm_ad(i-1) = dm_ad(i-1) +
r3*al_ad(i)
8920 dm_ad(i) = dm_ad(i) -
r3*al_ad(i)
8924 IF (branch .NE. 1)
THEN 8927 CALL pert_ppm_adm(1, u(npx-2:npx-2, j), bl(npx-2:npx-2), &
8928 & bl_ad(npx-2:npx-2), br(npx-2:npx-2), br_ad(npx-2&
8931 IF (branch .EQ. 0)
THEN 8942 xt_ad = br_ad(npx-1) + bl_ad(npx)
8943 u_ad(npx, j) = u_ad(npx, j) - bl_ad(npx)
8946 u_ad(npx-1, j) = u_ad(npx-1, j) - br_ad(npx-1)
8950 temp_ad11 = 0.5*x0r_ad/(dx(npx, j)+dx(npx+1, j))
8951 u_ad(npx, j) = u_ad(npx, j) + (dx(npx, j)*2.+dx(npx+1, j))&
8953 u_ad(npx+1, j) = u_ad(npx+1, j) - dx(npx, j)*temp_ad11
8954 temp_ad12 = 0.5*x0l_ad/(dx(npx-1, j)+dx(npx-2, j))
8955 u_ad(npx-1, j) = u_ad(npx-1, j) + (dx(npx-1, j)*2.+dx(npx-&
8957 u_ad(npx-2, j) = u_ad(npx-2, j) - dx(npx-1, j)*temp_ad12
8959 dq_ad(npx) = dq_ad(npx) +
s11*br_ad(npx)
8960 dm_ad(npx+1) = dm_ad(npx+1) -
s14*br_ad(npx)
8964 xt_ad = br_ad(npx-2) + bl_ad(npx-1)
8965 u_ad(npx-1, j) = u_ad(npx-1, j) - bl_ad(npx-1)
8968 u_ad(npx-2, j) = u_ad(npx-2, j) - br_ad(npx-2)
8971 u_ad(npx-1, j) = u_ad(npx-1, j) +
s15*xt_ad
8972 u_ad(npx-2, j) = u_ad(npx-2, j) +
s11*xt_ad - bl_ad(npx-2)
8973 dm_ad(npx-2) = dm_ad(npx-2) +
s14*xt_ad
8975 al_ad(npx-2) = al_ad(npx-2) + bl_ad(npx-2)
8979 IF (branch .EQ. 0)
THEN 8982 CALL pert_ppm_adm(1, u(2:2, j), bl(2:2), bl_ad(2:2), br(2:2)&
8985 IF (branch .EQ. 0)
THEN 8996 xt_ad = br_ad(0) + bl_ad(1)
8997 u_ad(1, j) = u_ad(1, j) - bl_ad(1)
9000 u_ad(0, j) = u_ad(0, j) - br_ad(0)
9004 temp_ad9 = 0.5*x0r_ad/(dx(1, j)+dx(2, j))
9005 u_ad(1, j) = u_ad(1, j) + (dx(1, j)*2.+dx(2, j))*temp_ad9
9006 u_ad(2, j) = u_ad(2, j) - dx(1, j)*temp_ad9
9007 temp_ad10 = 0.5*x0l_ad/(dx(0, j)+dx(-1, j))
9008 u_ad(0, j) = u_ad(0, j) + (dx(0, j)*2.+dx(-1, j))*&
9010 u_ad(-1, j) = u_ad(-1, j) - dx(0, j)*temp_ad10
9012 dm_ad(-1) = dm_ad(-1) +
s14*bl_ad(0)
9013 dq_ad(-1) = dq_ad(-1) -
s11*bl_ad(0)
9017 xt_ad = bl_ad(2) + br_ad(1)
9018 u_ad(1, j) = u_ad(1, j) - br_ad(1)
9021 u_ad(2, j) = u_ad(2, j) - bl_ad(2)
9024 u_ad(1, j) = u_ad(1, j) +
s15*xt_ad
9025 u_ad(2, j) = u_ad(2, j) +
s11*xt_ad - br_ad(2)
9026 dm_ad(2) = dm_ad(2) -
s14*xt_ad
9028 al_ad(3) = al_ad(3) + br_ad(2)
9032 IF (branch .LT. 2)
THEN 9033 IF (branch .EQ. 0)
THEN 9036 min5_ad = sign(1.d0, min5*xt)*br_ad(i)
9039 IF (branch .EQ. 0)
THEN 9049 IF (branch .EQ. 0)
THEN 9050 al_ad(i+1) = al_ad(i+1) + y5_ad
9051 u_ad(i, j) = u_ad(i, j) - y5_ad
9053 u_ad(i, j) = u_ad(i, j) + y5_ad
9054 al_ad(i+1) = al_ad(i+1) - y5_ad
9057 IF (branch .EQ. 0)
THEN 9063 min4_ad = -(sign(1.d0, min4*xt)*bl_ad(i))
9066 IF (branch .EQ. 0)
THEN 9076 IF (branch .EQ. 0)
THEN 9077 al_ad(i) = al_ad(i) + y4_ad
9078 u_ad(i, j) = u_ad(i, j) - y4_ad
9080 u_ad(i, j) = u_ad(i, j) + y4_ad
9081 al_ad(i) = al_ad(i) - y4_ad
9084 IF (branch .EQ. 0)
THEN 9085 xt_ad = xt_ad + x5_ad
9087 xt_ad = xt_ad - x5_ad
9090 dm_ad(i) = dm_ad(i) + 2.*xt_ad
9095 IF (branch .EQ. 0)
THEN 9107 IF (branch .EQ. 0)
THEN 9110 al_ad(i+1) = al_ad(i+1) + y7_ad
9111 u_ad(i, j) = u_ad(i, j) - y7_ad
9115 IF (branch .LT. 2)
THEN 9116 IF (branch .EQ. 0)
THEN 9124 IF (branch .EQ. 2)
THEN 9132 IF (branch .LT. 2)
THEN 9133 IF (branch .EQ. 0)
THEN 9134 lac_2_ad = lac_2_ad + x8_ad
9136 pmp_2_ad = pmp_2_ad + x8_ad
9138 ELSE IF (branch .EQ. 2)
THEN 9139 lac_2_ad = lac_2_ad + x8_ad
9141 pmp_2_ad = pmp_2_ad + lac_2_ad
9142 dq_ad(i-2) = dq_ad(i-2) - 1.5*lac_2_ad
9143 dq_ad(i-1) = dq_ad(i-1) + 2.*pmp_2_ad
9145 IF (branch .EQ. 0)
THEN 9157 IF (branch .EQ. 0)
THEN 9160 al_ad(i) = al_ad(i) + y6_ad
9161 u_ad(i, j) = u_ad(i, j) - y6_ad
9165 IF (branch .LT. 2)
THEN 9166 IF (branch .EQ. 0)
THEN 9174 IF (branch .EQ. 2)
THEN 9182 IF (branch .LT. 2)
THEN 9183 IF (branch .EQ. 0)
THEN 9184 lac_1_ad = lac_1_ad + x7_ad
9186 pmp_1_ad = pmp_1_ad + x7_ad
9188 ELSE IF (branch .EQ. 2)
THEN 9189 lac_1_ad = lac_1_ad + x7_ad
9191 pmp_1_ad = pmp_1_ad + lac_1_ad
9192 dq_ad(i+1) = dq_ad(i+1) + 1.5*lac_1_ad
9193 dq_ad(i) = dq_ad(i) - 2.*pmp_1_ad
9196 ELSE IF (branch .EQ. 2)
THEN 9199 IF (branch .LT. 2)
THEN 9200 IF (branch .EQ. 0)
THEN 9207 ELSE IF (branch .EQ. 2)
THEN 9212 IF (branch .NE. 3)
THEN 9219 IF (branch .EQ. 0)
THEN 9222 br_ad(i) = br_ad(i) + y9_ad
9226 IF (branch .LT. 2)
THEN 9227 IF (branch .EQ. 0)
THEN 9235 IF (branch .EQ. 2)
THEN 9243 IF (branch .LT. 2)
THEN 9244 IF (branch .EQ. 0)
THEN 9245 lac_2_ad = lac_2_ad + x10_ad
9247 pmp_2_ad = pmp_2_ad + x10_ad
9249 ELSE IF (branch .EQ. 2)
THEN 9250 lac_2_ad = lac_2_ad + x10_ad
9252 pmp_2_ad = pmp_2_ad + lac_2_ad
9253 dq_ad(i-2) = dq_ad(i-2) - 1.5*lac_2_ad
9254 dq_ad(i-1) = dq_ad(i-1) + 2.*pmp_2_ad
9256 IF (branch .EQ. 0)
THEN 9266 IF (branch .EQ. 0)
THEN 9269 bl_ad(i) = bl_ad(i) + y8_ad
9273 IF (branch .LT. 2)
THEN 9274 IF (branch .EQ. 0)
THEN 9282 IF (branch .EQ. 2)
THEN 9290 IF (branch .LT. 2)
THEN 9291 IF (branch .EQ. 0)
THEN 9292 lac_1_ad = lac_1_ad + x9_ad
9294 pmp_1_ad = pmp_1_ad + x9_ad
9296 ELSE IF (branch .EQ. 2)
THEN 9297 lac_1_ad = lac_1_ad + x9_ad
9299 pmp_1_ad = pmp_1_ad + lac_1_ad
9300 dq_ad(i+1) = dq_ad(i+1) + 1.5*lac_1_ad
9301 dq_ad(i) = dq_ad(i) - 2.*pmp_1_ad
9303 al_ad(i+1) = al_ad(i+1) + br_ad(i)
9304 u_ad(i, j) = u_ad(i, j) - bl_ad(i) - br_ad(i)
9307 al_ad(i) = al_ad(i) + bl_ad(i)
9313 al_ad(i+1) = al_ad(i+1) + br_ad(i)
9314 u_ad(i, j) = u_ad(i, j) - bl_ad(i) - br_ad(i)
9317 al_ad(i) = al_ad(i) + bl_ad(i)
9322 u_ad(i-1, j) = u_ad(i-1, j) + 0.5*al_ad(i)
9323 u_ad(i, j) = u_ad(i, j) + 0.5*al_ad(i)
9324 dm_ad(i-1) = dm_ad(i-1) +
r3*al_ad(i)
9325 dm_ad(i) = dm_ad(i) -
r3*al_ad(i)
9330 u_ad(i+1, j) = u_ad(i+1, j) + dq_ad(i)
9331 u_ad(i, j) = u_ad(i, j) - dq_ad(i)
9335 xt = 0.25*(u(i+1, j)-u(i-1, j))
9336 min3_ad = sign(1.d0, min3*xt)*dm_ad(i)
9339 IF (branch .LT. 2)
THEN 9340 IF (branch .EQ. 0)
THEN 9351 IF (branch .EQ. 2)
THEN 9362 u_ad(i, j) = u_ad(i, j) + z1_ad
9365 IF (branch .LT. 2)
THEN 9366 IF (branch .EQ. 0)
THEN 9367 u_ad(i+1, j) = u_ad(i+1, j) + min6_ad
9369 u_ad(i, j) = u_ad(i, j) + min6_ad
9371 ELSE IF (branch .EQ. 2)
THEN 9372 u_ad(i+1, j) = u_ad(i+1, j) + min6_ad
9374 u_ad(i-1, j) = u_ad(i-1, j) + min6_ad
9377 u_ad(i, j) = u_ad(i, j) - y3_ad
9379 IF (branch .LT. 2)
THEN 9380 IF (branch .EQ. 0)
THEN 9381 u_ad(i+1, j) = u_ad(i+1, j) + max1_ad
9383 u_ad(i, j) = u_ad(i, j) + max1_ad
9385 ELSE IF (branch .EQ. 2)
THEN 9386 u_ad(i+1, j) = u_ad(i+1, j) + max1_ad
9388 u_ad(i-1, j) = u_ad(i-1, j) + max1_ad
9391 IF (branch .EQ. 0)
THEN 9397 u_ad(i+1, j) = u_ad(i+1, j) + 0.25*xt_ad
9398 u_ad(i-1, j) = u_ad(i-1, j) - 0.25*xt_ad
9404 SUBROUTINE xtp_u(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, &
9405 & iord, dx, rdx, npx, npy, grid_type, nested)
9407 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
9408 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
9409 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
9410 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
9411 REAL,
INTENT(OUT) :: flux(is:ie+1, js:je+1)
9412 REAL,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
9413 REAL,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
9414 INTEGER,
INTENT(IN) :: iord, npx, npy, grid_type
9415 LOGICAL,
INTENT(IN) :: nested
9417 REAL,
DIMENSION(is-1:ie+1) :: bl, br, b0
9418 LOGICAL,
DIMENSION(is-1:ie+1) :: smt5, smt6
9419 REAL :: fx0(is:ie+1)
9420 REAL :: al(is-1:ie+2), dm(is-2:ie+2)
9421 REAL :: dq(is-3:ie+2)
9422 REAL :: dl, dr, xt, pmp, lac, cfl
9423 REAL :: pmp_1, lac_1, pmp_2, lac_2
9424 REAL :: x0, x1, x0l, x0r
9479 IF (3 .LT. is - 1)
THEN 9484 IF (npx - 3 .GT. ie + 1)
THEN 9490 IF (iord .EQ. 1)
THEN 9493 IF (c(i, j) .GT. 0.)
THEN 9494 flux(i, j) = u(i-1, j)
9496 flux(i, j) = u(i, j)
9500 ELSE IF (iord .LT. 8)
THEN 9504 al(i) =
p1*(u(i-1, j)+u(i, j)) +
p2*(u(i-2, j)+u(i+1, j))
9507 bl(i) = al(i) - u(i, j)
9508 br(i) = al(i+1) - u(i, j)
9510 IF (.NOT.nested .AND.
grid_type .LT. 3)
THEN 9512 xt =
c3*u(1, j) +
c2*u(2, j) +
c1*u(3, j)
9513 br(1) = xt - u(1, j)
9514 bl(2) = xt - u(2, j)
9515 br(2) = al(3) - u(2, j)
9516 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 9526 bl(0) =
c1*u(-2, j) +
c2*u(-1, j) +
c3*u(0, j) - u(0, j)
9527 xt = 0.5*(((2.*dx(0, j)+dx(-1, j))*u(0, j)-dx(0, j)*u(-1, &
9528 & j))/(dx(0, j)+dx(-1, j))+((2.*dx(1, j)+dx(2, j))*u(1, j)&
9529 & -dx(1, j)*u(2, j))/(dx(1, j)+dx(2, j)))
9530 br(0) = xt - u(0, j)
9531 bl(1) = xt - u(1, j)
9535 IF (ie + 1 .EQ. npx)
THEN 9536 bl(npx-2) = al(npx-2) - u(npx-2, j)
9537 xt =
c1*u(npx-3, j) +
c2*u(npx-2, j) +
c3*u(npx-1, j)
9538 br(npx-2) = xt - u(npx-2, j)
9539 bl(npx-1) = xt - u(npx-1, j)
9540 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 9550 xt = 0.5*(((2.*dx(npx-1, j)+dx(npx-2, j))*u(npx-1, j)-dx(&
9551 & npx-1, j)*u(npx-2, j))/(dx(npx-1, j)+dx(npx-2, j))+((2.*&
9552 & dx(npx, j)+dx(npx+1, j))*u(npx, j)-dx(npx, j)*u(npx+1, j&
9553 & ))/(dx(npx, j)+dx(npx+1, j)))
9554 br(npx-1) = xt - u(npx-1, j)
9555 bl(npx) = xt - u(npx, j)
9556 br(npx) =
c3*u(npx, j) +
c2*u(npx+1, j) +
c1*u(npx+2, j) -&
9563 b0(i) = bl(i) + br(i)
9565 IF (iord .EQ. 2)
THEN 9569 IF (c(i, j) .GT. 0.)
THEN 9570 cfl = c(i, j)*rdx(i-1, j)
9571 flux(i, j) = u(i-1, j) + (1.-cfl)*(br(i-1)-cfl*b0(i-1))
9573 cfl = c(i, j)*rdx(i, j)
9574 flux(i, j) = u(i, j) + (1.+cfl)*(bl(i)+cfl*b0(i))
9577 ELSE IF (iord .EQ. 3)
THEN 9579 IF (b0(i) .GE. 0.)
THEN 9584 IF (bl(i) - br(i) .GE. 0.)
THEN 9589 smt5(i) = x0 .LT. x1
9590 smt6(i) = 3.*x0 .LT. x1
9596 IF (c(i, j) .GT. 0.)
THEN 9597 cfl = c(i, j)*rdx(i-1, j)
9598 IF (smt6(i-1) .OR. smt5(i))
THEN 9599 fx0(i) = br(i-1) - cfl*b0(i-1)
9600 ELSE IF (smt5(i-1))
THEN 9601 IF (bl(i-1) .GE. 0.)
THEN 9606 IF (br(i-1) .GE. 0.)
THEN 9611 IF (x2 .GT. y1)
THEN 9616 fx0(i) = sign(min1, br(i-1))
9618 flux(i, j) = u(i-1, j) + (1.-cfl)*fx0(i)
9620 cfl = c(i, j)*rdx(i, j)
9621 IF (smt6(i) .OR. smt5(i-1))
THEN 9622 fx0(i) = bl(i) + cfl*b0(i)
9623 ELSE IF (smt5(i))
THEN 9624 IF (bl(i) .GE. 0.)
THEN 9629 IF (br(i) .GE. 0.)
THEN 9634 IF (x3 .GT. y2)
THEN 9639 fx0(i) = sign(min2, bl(i))
9641 flux(i, j) = u(i, j) + (1.+cfl)*fx0(i)
9644 ELSE IF (iord .EQ. 4)
THEN 9647 IF (b0(i) .GE. 0.)
THEN 9652 IF (bl(i) - br(i) .GE. 0.)
THEN 9657 smt5(i) = x0 .LT. x1
9659 smt6(i) = 3.*x0 .LT. x1
9662 IF (c(i, j) .GT. 0.)
THEN 9663 IF (smt6(i-1) .OR. smt5(i))
THEN 9664 cfl = c(i, j)*rdx(i-1, j)
9665 flux(i, j) = u(i-1, j) + (1.-cfl)*(br(i-1)-cfl*b0(i-1))
9668 flux(i, j) = u(i-1, j)
9670 ELSE IF (smt6(i) .OR. smt5(i-1))
THEN 9671 cfl = c(i, j)*rdx(i, j)
9672 flux(i, j) = u(i, j) + (1.+cfl)*(bl(i)+cfl*b0(i))
9674 flux(i, j) = u(i, j)
9679 IF (iord .EQ. 5)
THEN 9681 smt5(i) = bl(i)*br(i) .LT. 0.
9685 IF (3.*b0(i) .GE. 0.)
THEN 9690 IF (bl(i) - br(i) .GE. 0.)
THEN 9691 abs4 = bl(i) - br(i)
9693 abs4 = -(bl(i)-br(i))
9695 smt5(i) = abs0 .LT. abs4
9700 IF (c(i, j) .GT. 0.)
THEN 9701 cfl = c(i, j)*rdx(i-1, j)
9702 fx0(i) = (1.-cfl)*(br(i-1)-cfl*b0(i-1))
9703 flux(i, j) = u(i-1, j)
9705 cfl = c(i, j)*rdx(i, j)
9706 fx0(i) = (1.+cfl)*(bl(i)+cfl*b0(i))
9707 flux(i, j) = u(i, j)
9709 IF (smt5(i-1) .OR. smt5(i)) flux(i, j) = flux(i, j) + fx0(i)
9717 xt = 0.25*(u(i+1, j)-u(i-1, j))
9718 IF (xt .GE. 0.)
THEN 9723 IF (u(i-1, j) .LT. u(i, j))
THEN 9724 IF (u(i, j) .LT. u(i+1, j))
THEN 9729 ELSE IF (u(i-1, j) .LT. u(i+1, j))
THEN 9735 IF (u(i-1, j) .GT. u(i, j))
THEN 9736 IF (u(i, j) .GT. u(i+1, j))
THEN 9741 ELSE IF (u(i-1, j) .GT. u(i+1, j))
THEN 9747 IF (x4 .GT. y3)
THEN 9748 IF (y3 .GT. z1)
THEN 9753 ELSE IF (x4 .GT. z1)
THEN 9758 dm(i) = sign(min3, xt)
9761 dq(i) = u(i+1, j) - u(i, j)
9765 al(i) = 0.5*(u(i-1, j)+u(i, j)) +
r3*(dm(i-1)-dm(i))
9768 IF (iord .EQ. 8)
THEN 9771 IF (xt .GE. 0.)
THEN 9776 IF (al(i) - u(i, j) .GE. 0.)
THEN 9777 y4 = al(i) - u(i, j)
9779 y4 = -(al(i)-u(i, j))
9781 IF (x5 .GT. y4)
THEN 9786 bl(i) = -sign(min4, xt)
9787 IF (xt .GE. 0.)
THEN 9792 IF (al(i+1) - u(i, j) .GE. 0.)
THEN 9793 y5 = al(i+1) - u(i, j)
9795 y5 = -(al(i+1)-u(i, j))
9797 IF (x6 .GT. y5)
THEN 9802 br(i) = sign(min5, xt)
9804 ELSE IF (iord .EQ. 9)
THEN 9807 lac_1 = pmp_1 + 1.5*dq(i+1)
9808 IF (0. .LT. pmp_1)
THEN 9809 IF (pmp_1 .LT. lac_1)
THEN 9814 ELSE IF (0. .LT. lac_1)
THEN 9819 IF (0. .GT. pmp_1)
THEN 9820 IF (pmp_1 .GT. lac_1)
THEN 9825 ELSE IF (0. .GT. lac_1)
THEN 9830 IF (al(i) - u(i, j) .LT. y12)
THEN 9833 y6 = al(i) - u(i, j)
9835 IF (x7 .GT. y6)
THEN 9841 lac_2 = pmp_2 - 1.5*dq(i-2)
9842 IF (0. .LT. pmp_2)
THEN 9843 IF (pmp_2 .LT. lac_2)
THEN 9848 ELSE IF (0. .LT. lac_2)
THEN 9853 IF (0. .GT. pmp_2)
THEN 9854 IF (pmp_2 .GT. lac_2)
THEN 9859 ELSE IF (0. .GT. lac_2)
THEN 9864 IF (al(i+1) - u(i, j) .LT. y13)
THEN 9867 y7 = al(i+1) - u(i, j)
9869 IF (x8 .GT. y7)
THEN 9875 ELSE IF (iord .EQ. 10)
THEN 9877 bl(i) = al(i) - u(i, j)
9878 br(i) = al(i+1) - u(i, j)
9879 IF (dm(i) .GE. 0.)
THEN 9886 IF (dm(i-1) .GE. 0.)
THEN 9891 IF (dm(i+1) .GE. 0.)
THEN 9902 IF (3.*(bl(i)+br(i)) .GE. 0.)
THEN 9903 abs3 = 3.*(bl(i)+br(i))
9905 abs3 = -(3.*(bl(i)+br(i)))
9907 IF (bl(i) - br(i) .GE. 0.)
THEN 9908 abs6 = bl(i) - br(i)
9910 abs6 = -(bl(i)-br(i))
9912 IF (abs3 .GT. abs6)
THEN 9914 lac_1 = pmp_1 + 1.5*dq(i+1)
9915 IF (0. .LT. pmp_1)
THEN 9916 IF (pmp_1 .LT. lac_1)
THEN 9921 ELSE IF (0. .LT. lac_1)
THEN 9926 IF (0. .GT. pmp_1)
THEN 9927 IF (pmp_1 .GT. lac_1)
THEN 9932 ELSE IF (0. .GT. lac_1)
THEN 9937 IF (bl(i) .LT. y14)
THEN 9942 IF (x9 .GT. y8)
THEN 9948 lac_2 = pmp_2 - 1.5*dq(i-2)
9949 IF (0. .LT. pmp_2)
THEN 9950 IF (pmp_2 .LT. lac_2)
THEN 9955 ELSE IF (0. .LT. lac_2)
THEN 9960 IF (0. .GT. pmp_2)
THEN 9961 IF (pmp_2 .GT. lac_2)
THEN 9966 ELSE IF (0. .GT. lac_2)
THEN 9971 IF (br(i) .LT. y15)
THEN 9976 IF (x10 .GT. y9)
THEN 9987 bl(i) = al(i) - u(i, j)
9988 br(i) = al(i+1) - u(i, j)
9995 IF (is .EQ. 1 .AND. (.NOT.nested))
THEN 9996 br(2) = al(3) - u(2, j)
9997 xt =
s15*u(1, j) +
s11*u(2, j) -
s14*dm(2)
9998 bl(2) = xt - u(2, j)
9999 br(1) = xt - u(1, j)
10000 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 10010 bl(0) =
s14*dm(-1) -
s11*dq(-1)
10011 x0l = 0.5*((2.*dx(0, j)+dx(-1, j))*u(0, j)-dx(0, j)*u(-1, &
10012 & j))/(dx(0, j)+dx(-1, j))
10013 x0r = 0.5*((2.*dx(1, j)+dx(2, j))*u(1, j)-dx(1, j)*u(2, j)&
10014 & )/(dx(1, j)+dx(2, j))
10016 br(0) = xt - u(0, j)
10017 bl(1) = xt - u(1, j)
10019 CALL pert_ppm(1, u(2:2, j), bl(2:2), br(2:2), -1)
10021 IF (ie + 1 .EQ. npx .AND. (.NOT.nested))
THEN 10022 bl(npx-2) = al(npx-2) - u(npx-2, j)
10023 xt =
s15*u(npx-1, j) +
s11*u(npx-2, j) +
s14*dm(npx-2)
10024 br(npx-2) = xt - u(npx-2, j)
10025 bl(npx-1) = xt - u(npx-1, j)
10026 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 10036 br(npx) =
s11*dq(npx) -
s14*dm(npx+1)
10037 x0l = 0.5*((2.*dx(npx-1, j)+dx(npx-2, j))*u(npx-1, j)-dx(&
10038 & npx-1, j)*u(npx-2, j))/(dx(npx-1, j)+dx(npx-2, j))
10039 x0r = 0.5*((2.*dx(npx, j)+dx(npx+1, j))*u(npx, j)-dx(npx, &
10040 & j)*u(npx+1, j))/(dx(npx, j)+dx(npx+1, j))
10042 br(npx-1) = xt - u(npx-1, j)
10043 bl(npx) = xt - u(npx, j)
10045 CALL pert_ppm(1, u(npx-2:npx-2, j), bl(npx-2:npx-2), br(npx-&
10051 al(i) = 0.5*(u(i-1, j)+u(i, j)) +
r3*(dm(i-1)-dm(i))
10055 lac = pmp + 1.5*dq(i+1)
10056 IF (0. .LT. pmp)
THEN 10057 IF (pmp .LT. lac)
THEN 10062 ELSE IF (0. .LT. lac)
THEN 10067 IF (0. .GT. pmp)
THEN 10068 IF (pmp .GT. lac)
THEN 10073 ELSE IF (0. .GT. lac)
THEN 10078 IF (al(i) - u(i, j) .LT. y16)
THEN 10081 y10 = al(i) - u(i, j)
10083 IF (x11 .GT. y10)
THEN 10089 lac = pmp - 1.5*dq(i-2)
10090 IF (0. .LT. pmp)
THEN 10091 IF (pmp .LT. lac)
THEN 10096 ELSE IF (0. .LT. lac)
THEN 10101 IF (0. .GT. pmp)
THEN 10102 IF (pmp .GT. lac)
THEN 10107 ELSE IF (0. .GT. lac)
THEN 10112 IF (al(i+1) - u(i, j) .LT. y17)
THEN 10115 y11 = al(i+1) - u(i, j)
10117 IF (x12 .GT. y11)
THEN 10125 IF (c(i, j) .GT. 0.)
THEN 10126 cfl = c(i, j)*rdx(i-1, j)
10127 flux(i, j) = u(i-1, j) + (1.-cfl)*(br(i-1)-cfl*(bl(i-1)+br(i&
10130 cfl = c(i, j)*rdx(i, j)
10131 flux(i, j) = u(i, j) + (1.+cfl)*(bl(i)+cfl*(bl(i)+br(i)))
10136 END SUBROUTINE xtp_u 10157 SUBROUTINE ytp_v_adm(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u, v&
10158 & , v_ad, flux, flux_ad, jord, dy, rdy, npx, npy, grid_type, nested)
10160 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
10161 INTEGER,
INTENT(IN) :: jord
10162 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
10163 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
10164 REAL :: v_ad(isd:ied+1, jsd:jed)
10166 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
10167 REAL :: c_ad(is:ie+1, js:je+1)
10168 REAL :: flux(is:ie+1, js:je+1)
10169 REAL :: flux_ad(is:ie+1, js:je+1)
10170 REAL,
INTENT(IN) :: dy(isd:ied+1, jsd:jed)
10171 REAL,
INTENT(IN) :: rdy(isd:ied+1, jsd:jed)
10172 INTEGER,
INTENT(IN) :: npx, npy, grid_type
10173 LOGICAL,
INTENT(IN) :: nested
10175 LOGICAL,
DIMENSION(is:ie+1, js-1:je+1) :: smt5, smt6
10176 REAL :: fx0(is:ie+1)
10177 REAL :: fx0_ad(is:ie+1)
10178 REAL :: dm(is:ie+1, js-2:je+2)
10179 REAL :: dm_ad(is:ie+1, js-2:je+2)
10180 REAL :: al(is:ie+1, js-1:je+2)
10181 REAL :: al_ad(is:ie+1, js-1:je+2)
10182 REAL,
DIMENSION(is:ie+1, js-1:je+1) :: bl, br, b0
10183 REAL,
DIMENSION(is:ie+1, js-1:je+1) :: bl_ad, br_ad, b0_ad
10184 REAL :: dq(is:ie+1, js-3:je+2)
10185 REAL :: dq_ad(is:ie+1, js-3:je+2)
10186 REAL :: xt, dl, dr, pmp, lac, cfl
10187 REAL :: xt_ad, pmp_ad, lac_ad, cfl_ad
10188 REAL :: pmp_1, lac_1, pmp_2, lac_2
10189 REAL :: pmp_1_ad, lac_1_ad, pmp_2_ad, lac_2_ad
10190 REAL :: x0, x1, x0r, x0l
10191 REAL :: x0r_ad, x0l_ad
10192 INTEGER :: i, j, is1, ie1, js3, je3
10301 IF (3 .LT. js - 1)
THEN 10306 IF (npy - 3 .GT. je + 1)
THEN 10314 IF (jord .EQ. 1)
THEN 10317 IF (c(i, j) .GT. 0.)
THEN 10327 IF (branch .EQ. 0)
THEN 10328 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
10329 flux_ad(i, j) = 0.0
10331 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
10332 flux_ad(i, j) = 0.0
10336 ELSE IF (jord .LT. 8)
THEN 10340 al(i, j) =
p1*(v(i, j-1)+v(i, j)) +
p2*(v(i, j-2)+v(i, j+1))
10345 bl(i, j) = al(i, j) - v(i, j)
10346 br(i, j) = al(i, j+1) - v(i, j)
10349 IF (.NOT.nested .AND.
grid_type .LT. 3)
THEN 10350 IF (js .EQ. 1)
THEN 10352 bl(i, 0) =
c1*v(i, -2) +
c2*v(i, -1) +
c3*v(i, 0) - v(i, 0)
10353 xt = 0.5*(((2.*dy(i, 0)+dy(i, -1))*v(i, 0)-dy(i, 0)*v(i, -1)&
10354 & )/(dy(i, 0)+dy(i, -1))+((2.*dy(i, 1)+dy(i, 2))*v(i, 1)-dy(&
10355 & i, 1)*v(i, 2))/(dy(i, 1)+dy(i, 2)))
10356 br(i, 0) = xt - v(i, 0)
10357 bl(i, 1) = xt - v(i, 1)
10358 xt =
c3*v(i, 1) +
c2*v(i, 2) +
c1*v(i, 3)
10359 br(i, 1) = xt - v(i, 1)
10360 bl(i, 2) = xt - v(i, 2)
10361 br(i, 2) = al(i, 3) - v(i, 2)
10363 IF (is .EQ. 1)
THEN 10376 IF (ie + 1 .EQ. npx)
THEN 10394 IF (je + 1 .EQ. npy)
THEN 10396 bl(i, npy-2) = al(i, npy-2) - v(i, npy-2)
10397 xt =
c1*v(i, npy-3) +
c2*v(i, npy-2) +
c3*v(i, npy-1)
10398 br(i, npy-2) = xt - v(i, npy-2)
10399 bl(i, npy-1) = xt - v(i, npy-1)
10400 xt = 0.5*(((2.*dy(i, npy-1)+dy(i, npy-2))*v(i, npy-1)-dy(i, &
10401 & npy-1)*v(i, npy-2))/(dy(i, npy-1)+dy(i, npy-2))+((2.*dy(i&
10402 & , npy)+dy(i, npy+1))*v(i, npy)-dy(i, npy)*v(i, npy+1))/(dy&
10403 & (i, npy)+dy(i, npy+1)))
10404 br(i, npy-1) = xt - v(i, npy-1)
10405 bl(i, npy) = xt - v(i, npy)
10406 br(i, npy) =
c3*v(i, npy) +
c2*v(i, npy+1) +
c1*v(i, npy+2) &
10409 IF (is .EQ. 1)
THEN 10422 IF (ie + 1 .EQ. npx)
THEN 10424 bl(npx, npy-1) = 0.
10426 br(npx, npy-1) = 0.
10445 b0(i, j) = bl(i, j) + br(i, j)
10448 IF (jord .EQ. 2)
THEN 10453 IF (c(i, j) .GT. 0.)
THEN 10466 IF (branch .EQ. 0)
THEN 10467 cfl = c(i, j)*rdy(i, j)
10468 temp_ad4 = (cfl+1.)*flux_ad(i, j)
10469 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
10470 cfl_ad = b0(i, j)*temp_ad4 + (bl(i, j)+cfl*b0(i, j))*&
10472 bl_ad(i, j) = bl_ad(i, j) + temp_ad4
10473 b0_ad(i, j) = b0_ad(i, j) + cfl*temp_ad4
10474 flux_ad(i, j) = 0.0
10475 c_ad(i, j) = c_ad(i, j) + rdy(i, j)*cfl_ad
10477 cfl = c(i, j)*rdy(i, j-1)
10478 temp_ad3 = (1.-cfl)*flux_ad(i, j)
10479 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
10480 cfl_ad = -(b0(i, j-1)*temp_ad3) - (br(i, j-1)-cfl*b0(i, j-&
10481 & 1))*flux_ad(i, j)
10482 br_ad(i, j-1) = br_ad(i, j-1) + temp_ad3
10483 b0_ad(i, j-1) = b0_ad(i, j-1) - cfl*temp_ad3
10484 flux_ad(i, j) = 0.0
10485 c_ad(i, j) = c_ad(i, j) + rdy(i, j-1)*cfl_ad
10489 ELSE IF (jord .EQ. 3)
THEN 10492 IF (b0(i, j) .GE. 0.)
THEN 10497 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 10498 x1 = bl(i, j) - br(i, j)
10500 x1 = -(bl(i, j)-br(i, j))
10502 smt5(i, j) = x0 .LT. x1
10503 smt6(i, j) = 3.*x0 .LT. x1
10512 IF (c(i, j) .GT. 0.)
THEN 10513 cfl = c(i, j)*rdy(i, j-1)
10514 IF (smt6(i, j-1) .OR. smt5(i, j))
THEN 10516 fx0(i) = br(i, j-1) - cfl*b0(i, j-1)
10518 ELSE IF (smt5(i, j-1))
THEN 10519 IF (bl(i, j-1) .GE. 0.)
THEN 10526 IF (br(i, j-1) .GE. 0.)
THEN 10533 IF (x2 .GT. y1)
THEN 10544 fx0(i) = sign(min1, br(i, j-1))
10551 cfl = c(i, j)*rdy(i, j)
10552 IF (smt6(i, j) .OR. smt5(i, j-1))
THEN 10554 fx0(i) = bl(i, j) + cfl*b0(i, j)
10556 ELSE IF (smt5(i, j))
THEN 10557 IF (bl(i, j) .GE. 0.)
THEN 10564 IF (br(i, j) .GE. 0.)
THEN 10571 IF (x3 .GT. y2)
THEN 10581 fx0(i) = sign(min2, bl(i, j))
10597 IF (branch .EQ. 0)
THEN 10598 cfl = c(i, j)*rdy(i, j)
10599 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
10600 cfl_ad = fx0(i)*flux_ad(i, j)
10601 fx0_ad(i) = fx0_ad(i) + (cfl+1.)*flux_ad(i, j)
10602 flux_ad(i, j) = 0.0
10604 IF (branch .EQ. 0)
THEN 10606 bl_ad(i, j) = bl_ad(i, j) + fx0_ad(i)
10607 cfl_ad = cfl_ad + b0(i, j)*fx0_ad(i)
10608 b0_ad(i, j) = b0_ad(i, j) + cfl*fx0_ad(i)
10610 ELSE IF (branch .EQ. 1)
THEN 10612 min2_ad = sign(1.d0, min2*bl(i, j))*fx0_ad(i)
10615 IF (branch .EQ. 0)
THEN 10625 IF (branch .EQ. 0)
THEN 10626 br_ad(i, j) = br_ad(i, j) + y2_ad
10628 br_ad(i, j) = br_ad(i, j) - y2_ad
10631 IF (branch .EQ. 0)
THEN 10632 bl_ad(i, j) = bl_ad(i, j) + x3_ad
10634 bl_ad(i, j) = bl_ad(i, j) - x3_ad
10637 c_ad(i, j) = c_ad(i, j) + rdy(i, j)*cfl_ad
10639 cfl = c(i, j)*rdy(i, j-1)
10640 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
10641 cfl_ad = -(fx0(i)*flux_ad(i, j))
10642 fx0_ad(i) = fx0_ad(i) + (1.-cfl)*flux_ad(i, j)
10643 flux_ad(i, j) = 0.0
10645 IF (branch .EQ. 0)
THEN 10647 br_ad(i, j-1) = br_ad(i, j-1) + fx0_ad(i)
10648 cfl_ad = cfl_ad - b0(i, j-1)*fx0_ad(i)
10649 b0_ad(i, j-1) = b0_ad(i, j-1) - cfl*fx0_ad(i)
10651 ELSE IF (branch .EQ. 1)
THEN 10653 min1_ad = sign(1.d0, min1*br(i, j-1))*fx0_ad(i)
10656 IF (branch .EQ. 0)
THEN 10666 IF (branch .EQ. 0)
THEN 10667 br_ad(i, j-1) = br_ad(i, j-1) + y1_ad
10669 br_ad(i, j-1) = br_ad(i, j-1) - y1_ad
10672 IF (branch .EQ. 0)
THEN 10673 bl_ad(i, j-1) = bl_ad(i, j-1) + x2_ad
10675 bl_ad(i, j-1) = bl_ad(i, j-1) - x2_ad
10678 c_ad(i, j) = c_ad(i, j) + rdy(i, j-1)*cfl_ad
10689 ELSE IF (jord .EQ. 4)
THEN 10692 IF (b0(i, j) .GE. 0.)
THEN 10697 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 10698 x1 = bl(i, j) - br(i, j)
10700 x1 = -(bl(i, j)-br(i, j))
10702 smt5(i, j) = x0 .LT. x1
10703 smt6(i, j) = 3.*x0 .LT. x1
10708 IF (c(i, j) .GT. 0.)
THEN 10709 IF (smt6(i, j-1) .OR. smt5(i, j))
THEN 10714 ELSE IF (smt6(i, j) .OR. smt5(i, j-1))
THEN 10727 IF (branch .LT. 2)
THEN 10728 IF (branch .EQ. 0)
THEN 10729 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
10730 flux_ad(i, j) = 0.0
10732 cfl = c(i, j)*rdy(i, j)
10733 temp_ad6 = (cfl+1.)*flux_ad(i, j)
10734 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
10735 cfl_ad = b0(i, j)*temp_ad6 + (bl(i, j)+cfl*b0(i, j))*&
10737 bl_ad(i, j) = bl_ad(i, j) + temp_ad6
10738 b0_ad(i, j) = b0_ad(i, j) + cfl*temp_ad6
10739 flux_ad(i, j) = 0.0
10740 c_ad(i, j) = c_ad(i, j) + rdy(i, j)*cfl_ad
10742 ELSE IF (branch .EQ. 2)
THEN 10743 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
10744 flux_ad(i, j) = 0.0
10746 cfl = c(i, j)*rdy(i, j-1)
10747 temp_ad5 = (1.-cfl)*flux_ad(i, j)
10748 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
10749 cfl_ad = -(b0(i, j-1)*temp_ad5) - (br(i, j-1)-cfl*b0(i, j-&
10750 & 1))*flux_ad(i, j)
10751 br_ad(i, j-1) = br_ad(i, j-1) + temp_ad5
10752 b0_ad(i, j-1) = b0_ad(i, j-1) - cfl*temp_ad5
10753 flux_ad(i, j) = 0.0
10754 c_ad(i, j) = c_ad(i, j) + rdy(i, j-1)*cfl_ad
10764 IF (jord .EQ. 5)
THEN 10768 smt5(i, j) = bl(i, j)*br(i, j) .LT. 0.
10775 IF (3.*b0(i, j) .GE. 0.)
THEN 10778 abs0 = -(3.*b0(i, j))
10780 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 10781 abs4 = bl(i, j) - br(i, j)
10783 abs4 = -(bl(i, j)-br(i, j))
10785 smt5(i, j) = abs0 .LT. abs4
10793 IF (c(i, j) .GT. 0.)
THEN 10798 IF (smt5(i, j-1) .OR. smt5(i, j))
THEN 10812 IF (branch .NE. 0) fx0_ad(i) = fx0_ad(i) + flux_ad(i, j)
10814 IF (branch .EQ. 0)
THEN 10815 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
10816 flux_ad(i, j) = 0.0
10817 cfl = c(i, j)*rdy(i, j-1)
10818 temp_ad7 = (1.-cfl)*fx0_ad(i)
10819 cfl_ad = -(b0(i, j-1)*temp_ad7) - (br(i, j-1)-cfl*b0(i, j-&
10821 br_ad(i, j-1) = br_ad(i, j-1) + temp_ad7
10822 b0_ad(i, j-1) = b0_ad(i, j-1) - cfl*temp_ad7
10824 c_ad(i, j) = c_ad(i, j) + rdy(i, j-1)*cfl_ad
10826 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
10827 flux_ad(i, j) = 0.0
10828 cfl = c(i, j)*rdy(i, j)
10829 temp_ad8 = (cfl+1.)*fx0_ad(i)
10830 cfl_ad = b0(i, j)*temp_ad8 + (bl(i, j)+cfl*b0(i, j))*&
10832 bl_ad(i, j) = bl_ad(i, j) + temp_ad8
10833 b0_ad(i, j) = b0_ad(i, j) + cfl*temp_ad8
10835 c_ad(i, j) = c_ad(i, j) + rdy(i, j)*cfl_ad
10840 IF (branch .EQ. 0)
THEN 10848 bl_ad(i, j) = bl_ad(i, j) + b0_ad(i, j)
10849 br_ad(i, j) = br_ad(i, j) + b0_ad(i, j)
10854 IF (branch .LT. 2)
THEN 10855 IF (branch .EQ. 0)
THEN 10862 IF (branch .NE. 2)
THEN 10863 br_ad(npx, npy) = 0.0
10864 bl_ad(npx, npy) = 0.0
10865 br_ad(npx, npy-1) = 0.0
10866 bl_ad(npx, npy-1) = 0.0
10869 IF (branch .EQ. 0)
THEN 10870 br_ad(1, npy) = 0.0
10871 bl_ad(1, npy) = 0.0
10872 br_ad(1, npy-1) = 0.0
10873 bl_ad(1, npy-1) = 0.0
10877 v_ad(i, npy) = v_ad(i, npy) + (
c3-1.0)*br_ad(i, npy)
10878 v_ad(i, npy+1) = v_ad(i, npy+1) +
c2*br_ad(i, npy)
10879 v_ad(i, npy+2) = v_ad(i, npy+2) +
c1*br_ad(i, npy)
10880 br_ad(i, npy) = 0.0
10881 xt_ad = br_ad(i, npy-1) + bl_ad(i, npy)
10882 v_ad(i, npy) = v_ad(i, npy) - bl_ad(i, npy)
10883 bl_ad(i, npy) = 0.0
10884 temp_ad1 = 0.5*xt_ad/(dy(i, npy-1)+dy(i, npy-2))
10885 v_ad(i, npy-1) = v_ad(i, npy-1) + (dy(i, npy-1)*2.+dy(i, npy-2&
10886 & ))*temp_ad1 - br_ad(i, npy-1)
10887 br_ad(i, npy-1) = 0.0
10888 temp_ad2 = 0.5*xt_ad/(dy(i, npy)+dy(i, npy+1))
10889 v_ad(i, npy-2) = v_ad(i, npy-2) - dy(i, npy-1)*temp_ad1
10890 v_ad(i, npy) = v_ad(i, npy) + (dy(i, npy)*2.+dy(i, npy+1))*&
10892 v_ad(i, npy+1) = v_ad(i, npy+1) - dy(i, npy)*temp_ad2
10893 xt_ad = br_ad(i, npy-2) + bl_ad(i, npy-1)
10894 v_ad(i, npy-1) = v_ad(i, npy-1) - bl_ad(i, npy-1)
10895 bl_ad(i, npy-1) = 0.0
10896 v_ad(i, npy-2) = v_ad(i, npy-2) - br_ad(i, npy-2)
10897 br_ad(i, npy-2) = 0.0
10898 v_ad(i, npy-3) = v_ad(i, npy-3) +
c1*xt_ad
10899 v_ad(i, npy-2) = v_ad(i, npy-2) +
c2*xt_ad
10900 v_ad(i, npy-1) = v_ad(i, npy-1) +
c3*xt_ad
10901 al_ad(i, npy-2) = al_ad(i, npy-2) + bl_ad(i, npy-2)
10902 v_ad(i, npy-2) = v_ad(i, npy-2) - bl_ad(i, npy-2)
10903 bl_ad(i, npy-2) = 0.0
10907 IF (branch .EQ. 0)
THEN 10908 br_ad(npx, 1) = 0.0
10909 bl_ad(npx, 1) = 0.0
10910 br_ad(npx, 0) = 0.0
10911 bl_ad(npx, 0) = 0.0
10912 ELSE IF (branch .NE. 1)
THEN 10916 IF (branch .EQ. 0)
THEN 10923 al_ad(i, 3) = al_ad(i, 3) + br_ad(i, 2)
10924 v_ad(i, 2) = v_ad(i, 2) - bl_ad(i, 2) - br_ad(i, 2)
10926 xt_ad = br_ad(i, 1) + bl_ad(i, 2)
10928 v_ad(i, 1) = v_ad(i, 1) +
c3*xt_ad - br_ad(i, 1)
10930 v_ad(i, 2) = v_ad(i, 2) +
c2*xt_ad
10931 v_ad(i, 3) = v_ad(i, 3) +
c1*xt_ad
10932 xt_ad = br_ad(i, 0) + bl_ad(i, 1)
10933 v_ad(i, 1) = v_ad(i, 1) - bl_ad(i, 1)
10935 temp_ad = 0.5*xt_ad/(dy(i, 0)+dy(i, -1))
10936 v_ad(i, 0) = v_ad(i, 0) + (dy(i, 0)*2.+dy(i, -1))*temp_ad - &
10939 temp_ad0 = 0.5*xt_ad/(dy(i, 1)+dy(i, 2))
10940 v_ad(i, -1) = v_ad(i, -1) - dy(i, 0)*temp_ad
10941 v_ad(i, 1) = v_ad(i, 1) + (dy(i, 1)*2.+dy(i, 2))*temp_ad0
10942 v_ad(i, 2) = v_ad(i, 2) - dy(i, 1)*temp_ad0
10943 v_ad(i, -2) = v_ad(i, -2) +
c1*bl_ad(i, 0)
10944 v_ad(i, -1) = v_ad(i, -1) +
c2*bl_ad(i, 0)
10945 v_ad(i, 0) = v_ad(i, 0) + (
c3-1.0)*bl_ad(i, 0)
10948 100
DO j=je3,js3,-1
10950 al_ad(i, j+1) = al_ad(i, j+1) + br_ad(i, j)
10951 v_ad(i, j) = v_ad(i, j) - bl_ad(i, j) - br_ad(i, j)
10953 al_ad(i, j) = al_ad(i, j) + bl_ad(i, j)
10959 v_ad(i, j-1) = v_ad(i, j-1) +
p1*al_ad(i, j)
10960 v_ad(i, j) = v_ad(i, j) +
p1*al_ad(i, j)
10961 v_ad(i, j-2) = v_ad(i, j-2) +
p2*al_ad(i, j)
10962 v_ad(i, j+1) = v_ad(i, j+1) +
p2*al_ad(i, j)
10970 xt = 0.25*(v(i, j+1)-v(i, j-1))
10971 IF (xt .GE. 0.)
THEN 10978 IF (v(i, j-1) .LT. v(i, j))
THEN 10979 IF (v(i, j) .LT. v(i, j+1))
THEN 10986 ELSE IF (v(i, j-1) .LT. v(i, j+1))
THEN 10993 y3 = max1 - v(i, j)
10994 IF (v(i, j-1) .GT. v(i, j))
THEN 10995 IF (v(i, j) .GT. v(i, j+1))
THEN 11002 ELSE IF (v(i, j-1) .GT. v(i, j+1))
THEN 11009 z1 = v(i, j) - min6
11010 IF (x4 .GT. y3)
THEN 11011 IF (y3 .GT. z1)
THEN 11020 ELSE IF (x4 .GT. z1)
THEN 11029 dm(i, j) = sign(min3, xt)
11034 dq(i, j) = v(i, j+1) - v(i, j)
11040 al(i, j) = 0.5*(v(i, j-1)+v(i, j)) +
r3*(dm(i, j-1)-dm(i, j)&
11044 IF (jord .EQ. 8)
THEN 11048 IF (xt .GE. 0.)
THEN 11055 IF (al(i, j) - v(i, j) .GE. 0.)
THEN 11056 y4 = al(i, j) - v(i, j)
11059 y4 = -(al(i, j)-v(i, j))
11062 IF (x5 .GT. y4)
THEN 11071 bl(i, j) = -sign(min4, xt)
11072 IF (xt .GE. 0.)
THEN 11079 IF (al(i, j+1) - v(i, j) .GE. 0.)
THEN 11080 y5 = al(i, j+1) - v(i, j)
11083 y5 = -(al(i, j+1)-v(i, j))
11086 IF (x6 .GT. y5)
THEN 11095 br(i, j) = sign(min5, xt)
11099 ELSE IF (jord .EQ. 9)
THEN 11102 pmp_1 = -(2.*dq(i, j))
11103 lac_1 = pmp_1 + 1.5*dq(i, j+1)
11104 IF (0. .LT. pmp_1)
THEN 11105 IF (pmp_1 .LT. lac_1)
THEN 11112 ELSE IF (0. .LT. lac_1)
THEN 11119 IF (0. .GT. pmp_1)
THEN 11120 IF (pmp_1 .GT. lac_1)
THEN 11127 ELSE IF (0. .GT. lac_1)
THEN 11134 IF (al(i, j) - v(i, j) .LT. y12)
THEN 11138 y6 = al(i, j) - v(i, j)
11141 IF (x7 .GT. y6)
THEN 11148 pmp_2 = 2.*dq(i, j-1)
11149 lac_2 = pmp_2 - 1.5*dq(i, j-2)
11150 IF (0. .LT. pmp_2)
THEN 11151 IF (pmp_2 .LT. lac_2)
THEN 11158 ELSE IF (0. .LT. lac_2)
THEN 11165 IF (0. .GT. pmp_2)
THEN 11166 IF (pmp_2 .GT. lac_2)
THEN 11173 ELSE IF (0. .GT. lac_2)
THEN 11180 IF (al(i, j+1) - v(i, j) .LT. y13)
THEN 11184 y7 = al(i, j+1) - v(i, j)
11187 IF (x8 .GT. y7)
THEN 11197 ELSE IF (jord .EQ. 10)
THEN 11200 bl(i, j) = al(i, j) - v(i, j)
11201 br(i, j) = al(i, j+1) - v(i, j)
11202 IF (dm(i, j) .GE. 0.)
THEN 11209 IF (dm(i, j-1) .GE. 0.)
THEN 11214 IF (dm(i, j+1) .GE. 0.)
THEN 11227 IF (3.*(bl(i, j)+br(i, j)) .GE. 0.)
THEN 11228 abs3 = 3.*(bl(i, j)+br(i, j))
11230 abs3 = -(3.*(bl(i, j)+br(i, j)))
11232 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 11233 abs6 = bl(i, j) - br(i, j)
11235 abs6 = -(bl(i, j)-br(i, j))
11237 IF (abs3 .GT. abs6)
THEN 11238 pmp_1 = -(2.*dq(i, j))
11239 lac_1 = pmp_1 + 1.5*dq(i, j+1)
11240 IF (0. .LT. pmp_1)
THEN 11241 IF (pmp_1 .LT. lac_1)
THEN 11248 ELSE IF (0. .LT. lac_1)
THEN 11255 IF (0. .GT. pmp_1)
THEN 11256 IF (pmp_1 .GT. lac_1)
THEN 11263 ELSE IF (0. .GT. lac_1)
THEN 11270 IF (bl(i, j) .LT. y14)
THEN 11277 IF (x9 .GT. y8)
THEN 11284 pmp_2 = 2.*dq(i, j-1)
11285 lac_2 = pmp_2 - 1.5*dq(i, j-2)
11286 IF (0. .LT. pmp_2)
THEN 11287 IF (pmp_2 .LT. lac_2)
THEN 11294 ELSE IF (0. .LT. lac_2)
THEN 11301 IF (0. .GT. pmp_2)
THEN 11302 IF (pmp_2 .GT. lac_2)
THEN 11309 ELSE IF (0. .GT. lac_2)
THEN 11316 IF (br(i, j) .LT. y15)
THEN 11323 IF (x10 .GT. y9)
THEN 11341 bl(i, j) = al(i, j) - v(i, j)
11342 br(i, j) = al(i, j+1) - v(i, j)
11350 IF (js .EQ. 1 .AND. (.NOT.nested))
THEN 11352 br(i, 2) = al(i, 3) - v(i, 2)
11353 xt =
s15*v(i, 1) +
s11*v(i, 2) -
s14*dm(i, 2)
11354 br(i, 1) = xt - v(i, 1)
11355 bl(i, 2) = xt - v(i, 2)
11356 bl(i, 0) =
s14*dm(i, -1) -
s11*dq(i, -1)
11357 x0l = 0.5*((2.*dy(i, 0)+dy(i, -1))*v(i, 0)-dy(i, 0)*v(i, -1)&
11358 & )/(dy(i, 0)+dy(i, -1))
11359 x0r = 0.5*((2.*dy(i, 1)+dy(i, 2))*v(i, 1)-dy(i, 1)*v(i, 2))/&
11360 & (dy(i, 1)+dy(i, 2))
11362 bl(i, 1) = xt - v(i, 1)
11363 br(i, 0) = xt - v(i, 0)
11365 IF (is .EQ. 1)
THEN 11378 IF (ie + 1 .EQ. npx)
THEN 11395 CALL pert_ppm(arg1, v(is:ie+1, j), bl(is:ie+1, j), br(is:ie+1&
11401 IF (je + 1 .EQ. npy .AND. (.NOT.nested))
THEN 11403 bl(i, npy-2) = al(i, npy-2) - v(i, npy-2)
11404 xt =
s15*v(i, npy-1) +
s11*v(i, npy-2) +
s14*dm(i, npy-2)
11405 br(i, npy-2) = xt - v(i, npy-2)
11406 bl(i, npy-1) = xt - v(i, npy-1)
11407 br(i, npy) =
s11*dq(i, npy) -
s14*dm(i, npy+1)
11408 x0l = 0.5*((2.*dy(i, npy-1)+dy(i, npy-2))*v(i, npy-1)-dy(i, &
11409 & npy-1)*v(i, npy-2))/(dy(i, npy-1)+dy(i, npy-2))
11410 x0r = 0.5*((2.*dy(i, npy)+dy(i, npy+1))*v(i, npy)-dy(i, npy)&
11411 & *v(i, npy+1))/(dy(i, npy)+dy(i, npy+1))
11413 br(i, npy-1) = xt - v(i, npy-1)
11414 bl(i, npy) = xt - v(i, npy)
11416 IF (is .EQ. 1)
THEN 11429 IF (ie + 1 .EQ. npx)
THEN 11431 bl(npx, npy-1) = 0.
11433 br(npx, npy-1) = 0.
11446 CALL pert_ppm(arg1, v(is:ie+1, j), bl(is:ie+1, j), br(is:ie+1&
11455 al(i, j) = 0.5*(v(i, j-1)+v(i, j)) +
r3*(dm(i, j-1)-dm(i, j)&
11461 pmp = 2.*dq(i, j-1)
11462 lac = pmp - 1.5*dq(i, j-2)
11463 IF (0. .LT. pmp)
THEN 11464 IF (pmp .LT. lac)
THEN 11471 ELSE IF (0. .LT. lac)
THEN 11478 IF (0. .GT. pmp)
THEN 11479 IF (pmp .GT. lac)
THEN 11486 ELSE IF (0. .GT. lac)
THEN 11493 IF (al(i, j+1) - v(i, j) .LT. y16)
THEN 11497 y10 = al(i, j+1) - v(i, j)
11500 IF (x11 .GT. y10)
THEN 11507 pmp = -(2.*dq(i, j))
11508 lac = pmp + 1.5*dq(i, j+1)
11509 IF (0. .LT. pmp)
THEN 11510 IF (pmp .LT. lac)
THEN 11517 ELSE IF (0. .LT. lac)
THEN 11524 IF (0. .GT. pmp)
THEN 11525 IF (pmp .GT. lac)
THEN 11532 ELSE IF (0. .GT. lac)
THEN 11539 IF (al(i, j) - v(i, j) .LT. y17)
THEN 11543 y11 = al(i, j) - v(i, j)
11546 IF (x12 .GT. y11)
THEN 11560 IF (c(i, j) .GT. 0.)
THEN 11572 IF (branch .EQ. 0)
THEN 11573 cfl = c(i, j)*rdy(i, j)
11574 temp0 = bl(i, j) + br(i, j)
11575 temp_ad14 = (cfl+1.)*flux_ad(i, j)
11576 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
11577 cfl_ad = temp0*temp_ad14 + (bl(i, j)+cfl*temp0)*flux_ad(i, j&
11579 bl_ad(i, j) = bl_ad(i, j) + (cfl+1.0)*temp_ad14
11580 br_ad(i, j) = br_ad(i, j) + cfl*temp_ad14
11581 flux_ad(i, j) = 0.0
11582 c_ad(i, j) = c_ad(i, j) + rdy(i, j)*cfl_ad
11584 cfl = c(i, j)*rdy(i, j-1)
11585 temp = bl(i, j-1) + br(i, j-1)
11586 temp_ad13 = (1.-cfl)*flux_ad(i, j)
11587 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
11588 cfl_ad = -(temp*temp_ad13) - (br(i, j-1)-cfl*temp)*flux_ad(i&
11590 br_ad(i, j-1) = br_ad(i, j-1) + (1.0-cfl)*temp_ad13
11591 bl_ad(i, j-1) = bl_ad(i, j-1) - cfl*temp_ad13
11592 flux_ad(i, j) = 0.0
11593 c_ad(i, j) = c_ad(i, j) + rdy(i, j-1)*cfl_ad
11599 IF (branch .EQ. 0)
THEN 11605 IF (branch .EQ. 0)
THEN 11606 y11_ad = bl_ad(i, j)
11610 x12_ad = bl_ad(i, j)
11615 IF (branch .EQ. 0)
THEN 11618 al_ad(i, j) = al_ad(i, j) + y11_ad
11619 v_ad(i, j) = v_ad(i, j) - y11_ad
11623 IF (branch .LT. 2)
THEN 11624 IF (branch .EQ. 0)
THEN 11632 IF (branch .EQ. 2)
THEN 11640 IF (branch .LT. 2)
THEN 11641 IF (branch .EQ. 0)
THEN 11642 lac_ad = lac_ad + x12_ad
11644 pmp_ad = pmp_ad + x12_ad
11646 ELSE IF (branch .EQ. 2)
THEN 11647 lac_ad = lac_ad + x12_ad
11649 pmp_ad = pmp_ad + lac_ad
11650 dq_ad(i, j+1) = dq_ad(i, j+1) + 1.5*lac_ad
11651 dq_ad(i, j) = dq_ad(i, j) - 2.*pmp_ad
11653 IF (branch .EQ. 0)
THEN 11654 y10_ad = br_ad(i, j)
11658 x11_ad = br_ad(i, j)
11663 IF (branch .EQ. 0)
THEN 11666 al_ad(i, j+1) = al_ad(i, j+1) + y10_ad
11667 v_ad(i, j) = v_ad(i, j) - y10_ad
11671 IF (branch .LT. 2)
THEN 11672 IF (branch .EQ. 0)
THEN 11680 IF (branch .EQ. 2)
THEN 11688 IF (branch .LT. 2)
THEN 11689 IF (branch .EQ. 0)
THEN 11690 lac_ad = lac_ad + x11_ad
11692 pmp_ad = pmp_ad + x11_ad
11694 ELSE IF (branch .EQ. 2)
THEN 11695 lac_ad = lac_ad + x11_ad
11697 pmp_ad = pmp_ad + lac_ad
11698 dq_ad(i, j-2) = dq_ad(i, j-2) - 1.5*lac_ad
11699 dq_ad(i, j-1) = dq_ad(i, j-1) + 2.*pmp_ad
11705 v_ad(i, j-1) = v_ad(i, j-1) + 0.5*al_ad(i, j)
11706 v_ad(i, j) = v_ad(i, j) + 0.5*al_ad(i, j)
11707 dm_ad(i, j-1) = dm_ad(i, j-1) +
r3*al_ad(i, j)
11708 dm_ad(i, j) = dm_ad(i, j) -
r3*al_ad(i, j)
11713 IF (branch .EQ. 1)
THEN 11721 CALL pert_ppm_adm(arg1, v(is:ie+1, j), bl(is:ie+1, j), bl_ad(&
11722 & is:ie+1, j), br(is:ie+1, j), br_ad(is:ie+1, j), -1&
11725 IF (branch .EQ. 0)
THEN 11726 br_ad(npx, npy) = 0.0
11727 bl_ad(npx, npy) = 0.0
11728 br_ad(npx, npy-1) = 0.0
11729 bl_ad(npx, npy-1) = 0.0
11732 IF (branch .EQ. 0)
THEN 11733 br_ad(1, npy) = 0.0
11734 bl_ad(1, npy) = 0.0
11735 br_ad(1, npy-1) = 0.0
11736 bl_ad(1, npy-1) = 0.0
11742 xt_ad = br_ad(i, npy-1) + bl_ad(i, npy)
11743 v_ad(i, npy) = v_ad(i, npy) - bl_ad(i, npy)
11744 bl_ad(i, npy) = 0.0
11745 v_ad(i, npy-1) = v_ad(i, npy-1) - br_ad(i, npy-1)
11746 br_ad(i, npy-1) = 0.0
11749 temp_ad11 = 0.5*x0r_ad/(dy(i, npy)+dy(i, npy+1))
11750 v_ad(i, npy) = v_ad(i, npy) + (dy(i, npy)*2.+dy(i, npy+1))*&
11752 v_ad(i, npy+1) = v_ad(i, npy+1) - dy(i, npy)*temp_ad11
11753 temp_ad12 = 0.5*x0l_ad/(dy(i, npy-1)+dy(i, npy-2))
11754 v_ad(i, npy-1) = v_ad(i, npy-1) + (dy(i, npy-1)*2.+dy(i, npy&
11756 v_ad(i, npy-2) = v_ad(i, npy-2) - dy(i, npy-1)*temp_ad12
11757 dq_ad(i, npy) = dq_ad(i, npy) +
s11*br_ad(i, npy)
11758 dm_ad(i, npy+1) = dm_ad(i, npy+1) -
s14*br_ad(i, npy)
11759 br_ad(i, npy) = 0.0
11760 xt_ad = br_ad(i, npy-2) + bl_ad(i, npy-1)
11761 v_ad(i, npy-1) = v_ad(i, npy-1) - bl_ad(i, npy-1)
11762 bl_ad(i, npy-1) = 0.0
11763 v_ad(i, npy-2) = v_ad(i, npy-2) - br_ad(i, npy-2)
11764 br_ad(i, npy-2) = 0.0
11765 v_ad(i, npy-1) = v_ad(i, npy-1) +
s15*xt_ad
11766 v_ad(i, npy-2) = v_ad(i, npy-2) +
s11*xt_ad - bl_ad(i, npy-2&
11768 dm_ad(i, npy-2) = dm_ad(i, npy-2) +
s14*xt_ad
11769 al_ad(i, npy-2) = al_ad(i, npy-2) + bl_ad(i, npy-2)
11770 bl_ad(i, npy-2) = 0.0
11774 IF (branch .EQ. 0)
THEN 11779 CALL pert_ppm_adm(arg1, v(is:ie+1, j), bl(is:ie+1, j), bl_ad(&
11780 & is:ie+1, j), br(is:ie+1, j), br_ad(is:ie+1, j), -1&
11783 IF (branch .EQ. 0)
THEN 11784 br_ad(npx, 1) = 0.0
11785 bl_ad(npx, 1) = 0.0
11786 br_ad(npx, 0) = 0.0
11787 bl_ad(npx, 0) = 0.0
11790 IF (branch .EQ. 0)
THEN 11797 xt_ad = bl_ad(i, 1) + br_ad(i, 0)
11798 v_ad(i, 0) = v_ad(i, 0) - br_ad(i, 0)
11802 temp_ad9 = 0.5*x0r_ad/(dy(i, 1)+dy(i, 2))
11803 v_ad(i, 1) = v_ad(i, 1) + (dy(i, 1)*2.+dy(i, 2))*temp_ad9 - &
11806 v_ad(i, 2) = v_ad(i, 2) - dy(i, 1)*temp_ad9
11807 temp_ad10 = 0.5*x0l_ad/(dy(i, 0)+dy(i, -1))
11808 v_ad(i, 0) = v_ad(i, 0) + (dy(i, 0)*2.+dy(i, -1))*temp_ad10
11809 v_ad(i, -1) = v_ad(i, -1) - dy(i, 0)*temp_ad10
11810 dm_ad(i, -1) = dm_ad(i, -1) +
s14*bl_ad(i, 0)
11811 dq_ad(i, -1) = dq_ad(i, -1) -
s11*bl_ad(i, 0)
11813 xt_ad = br_ad(i, 1) + bl_ad(i, 2)
11814 v_ad(i, 2) = v_ad(i, 2) - bl_ad(i, 2)
11816 v_ad(i, 1) = v_ad(i, 1) +
s15*xt_ad - br_ad(i, 1)
11818 v_ad(i, 2) = v_ad(i, 2) +
s11*xt_ad - br_ad(i, 2)
11819 dm_ad(i, 2) = dm_ad(i, 2) -
s14*xt_ad
11820 al_ad(i, 3) = al_ad(i, 3) + br_ad(i, 2)
11825 IF (branch .LT. 2)
THEN 11826 IF (branch .EQ. 0)
THEN 11830 min5_ad = sign(1.d0, min5*xt)*br_ad(i, j)
11833 IF (branch .EQ. 0)
THEN 11843 IF (branch .EQ. 0)
THEN 11844 al_ad(i, j+1) = al_ad(i, j+1) + y5_ad
11845 v_ad(i, j) = v_ad(i, j) - y5_ad
11847 v_ad(i, j) = v_ad(i, j) + y5_ad
11848 al_ad(i, j+1) = al_ad(i, j+1) - y5_ad
11851 IF (branch .EQ. 0)
THEN 11856 min4_ad = -(sign(1.d0, min4*xt)*bl_ad(i, j))
11859 IF (branch .EQ. 0)
THEN 11869 IF (branch .EQ. 0)
THEN 11870 al_ad(i, j) = al_ad(i, j) + y4_ad
11871 v_ad(i, j) = v_ad(i, j) - y4_ad
11873 v_ad(i, j) = v_ad(i, j) + y4_ad
11874 al_ad(i, j) = al_ad(i, j) - y4_ad
11877 IF (branch .EQ. 0)
THEN 11878 xt_ad = xt_ad + x5_ad
11880 xt_ad = xt_ad - x5_ad
11882 dm_ad(i, j) = dm_ad(i, j) + 2.*xt_ad
11889 IF (branch .EQ. 0)
THEN 11890 y7_ad = br_ad(i, j)
11894 x8_ad = br_ad(i, j)
11899 IF (branch .EQ. 0)
THEN 11902 al_ad(i, j+1) = al_ad(i, j+1) + y7_ad
11903 v_ad(i, j) = v_ad(i, j) - y7_ad
11907 IF (branch .LT. 2)
THEN 11908 IF (branch .EQ. 0)
THEN 11916 IF (branch .EQ. 2)
THEN 11924 IF (branch .LT. 2)
THEN 11925 IF (branch .EQ. 0)
THEN 11926 lac_2_ad = lac_2_ad + x8_ad
11928 pmp_2_ad = pmp_2_ad + x8_ad
11930 ELSE IF (branch .EQ. 2)
THEN 11931 lac_2_ad = lac_2_ad + x8_ad
11933 pmp_2_ad = pmp_2_ad + lac_2_ad
11934 dq_ad(i, j-2) = dq_ad(i, j-2) - 1.5*lac_2_ad
11935 dq_ad(i, j-1) = dq_ad(i, j-1) + 2.*pmp_2_ad
11937 IF (branch .EQ. 0)
THEN 11938 y6_ad = bl_ad(i, j)
11942 x7_ad = bl_ad(i, j)
11947 IF (branch .EQ. 0)
THEN 11950 al_ad(i, j) = al_ad(i, j) + y6_ad
11951 v_ad(i, j) = v_ad(i, j) - y6_ad
11955 IF (branch .LT. 2)
THEN 11956 IF (branch .EQ. 0)
THEN 11964 IF (branch .EQ. 2)
THEN 11972 IF (branch .LT. 2)
THEN 11973 IF (branch .EQ. 0)
THEN 11974 lac_1_ad = lac_1_ad + x7_ad
11976 pmp_1_ad = pmp_1_ad + x7_ad
11978 ELSE IF (branch .EQ. 2)
THEN 11979 lac_1_ad = lac_1_ad + x7_ad
11981 pmp_1_ad = pmp_1_ad + lac_1_ad
11982 dq_ad(i, j+1) = dq_ad(i, j+1) + 1.5*lac_1_ad
11983 dq_ad(i, j) = dq_ad(i, j) - 2.*pmp_1_ad
11987 ELSE IF (branch .EQ. 2)
THEN 11991 IF (branch .LT. 2)
THEN 11992 IF (branch .EQ. 0)
THEN 11995 y9_ad = br_ad(i, j)
11999 ELSE IF (branch .EQ. 2)
THEN 12000 x10_ad = br_ad(i, j)
12004 IF (branch .NE. 3)
THEN 12011 IF (branch .EQ. 0)
THEN 12014 br_ad(i, j) = br_ad(i, j) + y9_ad
12018 IF (branch .LT. 2)
THEN 12019 IF (branch .EQ. 0)
THEN 12027 IF (branch .EQ. 2)
THEN 12035 IF (branch .LT. 2)
THEN 12036 IF (branch .EQ. 0)
THEN 12037 lac_2_ad = lac_2_ad + x10_ad
12039 pmp_2_ad = pmp_2_ad + x10_ad
12041 ELSE IF (branch .EQ. 2)
THEN 12042 lac_2_ad = lac_2_ad + x10_ad
12044 pmp_2_ad = pmp_2_ad + lac_2_ad
12045 dq_ad(i, j-2) = dq_ad(i, j-2) - 1.5*lac_2_ad
12046 dq_ad(i, j-1) = dq_ad(i, j-1) + 2.*pmp_2_ad
12048 IF (branch .EQ. 0)
THEN 12049 y8_ad = bl_ad(i, j)
12053 x9_ad = bl_ad(i, j)
12058 IF (branch .EQ. 0)
THEN 12061 bl_ad(i, j) = bl_ad(i, j) + y8_ad
12065 IF (branch .LT. 2)
THEN 12066 IF (branch .EQ. 0)
THEN 12074 IF (branch .EQ. 2)
THEN 12082 IF (branch .LT. 2)
THEN 12083 IF (branch .EQ. 0)
THEN 12084 lac_1_ad = lac_1_ad + x9_ad
12086 pmp_1_ad = pmp_1_ad + x9_ad
12088 ELSE IF (branch .EQ. 2)
THEN 12089 lac_1_ad = lac_1_ad + x9_ad
12091 pmp_1_ad = pmp_1_ad + lac_1_ad
12092 dq_ad(i, j+1) = dq_ad(i, j+1) + 1.5*lac_1_ad
12093 dq_ad(i, j) = dq_ad(i, j) - 2.*pmp_1_ad
12094 110 al_ad(i, j+1) = al_ad(i, j+1) + br_ad(i, j)
12095 v_ad(i, j) = v_ad(i, j) - bl_ad(i, j) - br_ad(i, j)
12097 al_ad(i, j) = al_ad(i, j) + bl_ad(i, j)
12104 al_ad(i, j+1) = al_ad(i, j+1) + br_ad(i, j)
12105 v_ad(i, j) = v_ad(i, j) - bl_ad(i, j) - br_ad(i, j)
12107 al_ad(i, j) = al_ad(i, j) + bl_ad(i, j)
12114 v_ad(i, j-1) = v_ad(i, j-1) + 0.5*al_ad(i, j)
12115 v_ad(i, j) = v_ad(i, j) + 0.5*al_ad(i, j)
12116 dm_ad(i, j-1) = dm_ad(i, j-1) +
r3*al_ad(i, j)
12117 dm_ad(i, j) = dm_ad(i, j) -
r3*al_ad(i, j)
12124 v_ad(i, j+1) = v_ad(i, j+1) + dq_ad(i, j)
12125 v_ad(i, j) = v_ad(i, j) - dq_ad(i, j)
12131 xt = 0.25*(v(i, j+1)-v(i, j-1))
12132 min3_ad = sign(1.d0, min3*xt)*dm_ad(i, j)
12135 IF (branch .LT. 2)
THEN 12136 IF (branch .EQ. 0)
THEN 12147 IF (branch .EQ. 2)
THEN 12158 v_ad(i, j) = v_ad(i, j) + z1_ad
12161 IF (branch .LT. 2)
THEN 12162 IF (branch .EQ. 0)
THEN 12163 v_ad(i, j+1) = v_ad(i, j+1) + min6_ad
12165 v_ad(i, j) = v_ad(i, j) + min6_ad
12167 ELSE IF (branch .EQ. 2)
THEN 12168 v_ad(i, j+1) = v_ad(i, j+1) + min6_ad
12170 v_ad(i, j-1) = v_ad(i, j-1) + min6_ad
12173 v_ad(i, j) = v_ad(i, j) - y3_ad
12175 IF (branch .LT. 2)
THEN 12176 IF (branch .EQ. 0)
THEN 12177 v_ad(i, j+1) = v_ad(i, j+1) + max1_ad
12179 v_ad(i, j) = v_ad(i, j) + max1_ad
12181 ELSE IF (branch .EQ. 2)
THEN 12182 v_ad(i, j+1) = v_ad(i, j+1) + max1_ad
12184 v_ad(i, j-1) = v_ad(i, j-1) + max1_ad
12187 IF (branch .EQ. 0)
THEN 12192 v_ad(i, j+1) = v_ad(i, j+1) + 0.25*xt_ad
12193 v_ad(i, j-1) = v_ad(i, j-1) - 0.25*xt_ad
12199 SUBROUTINE ytp_v(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, &
12200 & jord, dy, rdy, npx, npy, grid_type, nested)
12202 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
12203 INTEGER,
INTENT(IN) :: jord
12204 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
12205 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
12207 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
12208 REAL,
INTENT(OUT) :: flux(is:ie+1, js:je+1)
12209 REAL,
INTENT(IN) :: dy(isd:ied+1, jsd:jed)
12210 REAL,
INTENT(IN) :: rdy(isd:ied+1, jsd:jed)
12211 INTEGER,
INTENT(IN) :: npx, npy, grid_type
12212 LOGICAL,
INTENT(IN) :: nested
12214 LOGICAL,
DIMENSION(is:ie+1, js-1:je+1) :: smt5, smt6
12215 REAL :: fx0(is:ie+1)
12216 REAL :: dm(is:ie+1, js-2:je+2)
12217 REAL :: al(is:ie+1, js-1:je+2)
12218 REAL,
DIMENSION(is:ie+1, js-1:je+1) :: bl, br, b0
12219 REAL :: dq(is:ie+1, js-3:je+2)
12220 REAL :: xt, dl, dr, pmp, lac, cfl
12221 REAL :: pmp_1, lac_1, pmp_2, lac_2
12222 REAL :: x0, x1, x0r, x0l
12223 INTEGER :: i, j, is1, ie1, js3, je3
12276 IF (3 .LT. js - 1)
THEN 12281 IF (npy - 3 .GT. je + 1)
THEN 12287 IF (jord .EQ. 1)
THEN 12290 IF (c(i, j) .GT. 0.)
THEN 12291 flux(i, j) = v(i, j-1)
12293 flux(i, j) = v(i, j)
12297 ELSE IF (jord .LT. 8)
THEN 12301 al(i, j) =
p1*(v(i, j-1)+v(i, j)) +
p2*(v(i, j-2)+v(i, j+1))
12306 bl(i, j) = al(i, j) - v(i, j)
12307 br(i, j) = al(i, j+1) - v(i, j)
12310 IF (.NOT.nested .AND.
grid_type .LT. 3)
THEN 12311 IF (js .EQ. 1)
THEN 12313 bl(i, 0) =
c1*v(i, -2) +
c2*v(i, -1) +
c3*v(i, 0) - v(i, 0)
12314 xt = 0.5*(((2.*dy(i, 0)+dy(i, -1))*v(i, 0)-dy(i, 0)*v(i, -1)&
12315 & )/(dy(i, 0)+dy(i, -1))+((2.*dy(i, 1)+dy(i, 2))*v(i, 1)-dy(&
12316 & i, 1)*v(i, 2))/(dy(i, 1)+dy(i, 2)))
12317 br(i, 0) = xt - v(i, 0)
12318 bl(i, 1) = xt - v(i, 1)
12319 xt =
c3*v(i, 1) +
c2*v(i, 2) +
c1*v(i, 3)
12320 br(i, 1) = xt - v(i, 1)
12321 bl(i, 2) = xt - v(i, 2)
12322 br(i, 2) = al(i, 3) - v(i, 2)
12324 IF (is .EQ. 1)
THEN 12334 IF (ie + 1 .EQ. npx)
THEN 12347 IF (je + 1 .EQ. npy)
THEN 12349 bl(i, npy-2) = al(i, npy-2) - v(i, npy-2)
12350 xt =
c1*v(i, npy-3) +
c2*v(i, npy-2) +
c3*v(i, npy-1)
12351 br(i, npy-2) = xt - v(i, npy-2)
12352 bl(i, npy-1) = xt - v(i, npy-1)
12353 xt = 0.5*(((2.*dy(i, npy-1)+dy(i, npy-2))*v(i, npy-1)-dy(i, &
12354 & npy-1)*v(i, npy-2))/(dy(i, npy-1)+dy(i, npy-2))+((2.*dy(i&
12355 & , npy)+dy(i, npy+1))*v(i, npy)-dy(i, npy)*v(i, npy+1))/(dy&
12356 & (i, npy)+dy(i, npy+1)))
12357 br(i, npy-1) = xt - v(i, npy-1)
12358 bl(i, npy) = xt - v(i, npy)
12359 br(i, npy) =
c3*v(i, npy) +
c2*v(i, npy+1) +
c1*v(i, npy+2) &
12362 IF (is .EQ. 1)
THEN 12372 IF (ie + 1 .EQ. npx)
THEN 12374 bl(npx, npy-1) = 0.
12376 br(npx, npy-1) = 0.
12388 b0(i, j) = bl(i, j) + br(i, j)
12391 IF (jord .EQ. 2)
THEN 12396 IF (c(i, j) .GT. 0.)
THEN 12397 cfl = c(i, j)*rdy(i, j-1)
12398 flux(i, j) = v(i, j-1) + (1.-cfl)*(br(i, j-1)-cfl*b0(i, j-&
12401 cfl = c(i, j)*rdy(i, j)
12402 flux(i, j) = v(i, j) + (1.+cfl)*(bl(i, j)+cfl*b0(i, j))
12406 ELSE IF (jord .EQ. 3)
THEN 12409 IF (b0(i, j) .GE. 0.)
THEN 12414 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 12415 x1 = bl(i, j) - br(i, j)
12417 x1 = -(bl(i, j)-br(i, j))
12419 smt5(i, j) = x0 .LT. x1
12420 smt6(i, j) = 3.*x0 .LT. x1
12428 IF (c(i, j) .GT. 0.)
THEN 12429 cfl = c(i, j)*rdy(i, j-1)
12430 IF (smt6(i, j-1) .OR. smt5(i, j))
THEN 12431 fx0(i) = br(i, j-1) - cfl*b0(i, j-1)
12432 ELSE IF (smt5(i, j-1))
THEN 12433 IF (bl(i, j-1) .GE. 0.)
THEN 12438 IF (br(i, j-1) .GE. 0.)
THEN 12443 IF (x2 .GT. y1)
THEN 12449 fx0(i) = sign(min1, br(i, j-1))
12451 flux(i, j) = v(i, j-1) + (1.-cfl)*fx0(i)
12453 cfl = c(i, j)*rdy(i, j)
12454 IF (smt6(i, j) .OR. smt5(i, j-1))
THEN 12455 fx0(i) = bl(i, j) + cfl*b0(i, j)
12456 ELSE IF (smt5(i, j))
THEN 12457 IF (bl(i, j) .GE. 0.)
THEN 12462 IF (br(i, j) .GE. 0.)
THEN 12467 IF (x3 .GT. y2)
THEN 12472 fx0(i) = sign(min2, bl(i, j))
12474 flux(i, j) = v(i, j) + (1.+cfl)*fx0(i)
12478 ELSE IF (jord .EQ. 4)
THEN 12481 IF (b0(i, j) .GE. 0.)
THEN 12486 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 12487 x1 = bl(i, j) - br(i, j)
12489 x1 = -(bl(i, j)-br(i, j))
12491 smt5(i, j) = x0 .LT. x1
12492 smt6(i, j) = 3.*x0 .LT. x1
12497 IF (c(i, j) .GT. 0.)
THEN 12498 IF (smt6(i, j-1) .OR. smt5(i, j))
THEN 12499 cfl = c(i, j)*rdy(i, j-1)
12500 flux(i, j) = v(i, j-1) + (1.-cfl)*(br(i, j-1)-cfl*b0(i, &
12503 flux(i, j) = v(i, j-1)
12505 ELSE IF (smt6(i, j) .OR. smt5(i, j-1))
THEN 12506 cfl = c(i, j)*rdy(i, j)
12507 flux(i, j) = v(i, j) + (1.+cfl)*(bl(i, j)+cfl*b0(i, j))
12509 flux(i, j) = v(i, j)
12516 IF (jord .EQ. 5)
THEN 12519 smt5(i, j) = bl(i, j)*br(i, j) .LT. 0.
12526 IF (3.*b0(i, j) .GE. 0.)
THEN 12529 abs0 = -(3.*b0(i, j))
12531 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 12532 abs4 = bl(i, j) - br(i, j)
12534 abs4 = -(bl(i, j)-br(i, j))
12536 smt5(i, j) = abs0 .LT. abs4
12543 IF (c(i, j) .GT. 0.)
THEN 12544 cfl = c(i, j)*rdy(i, j-1)
12545 fx0(i) = (1.-cfl)*(br(i, j-1)-cfl*b0(i, j-1))
12546 flux(i, j) = v(i, j-1)
12548 cfl = c(i, j)*rdy(i, j)
12549 fx0(i) = (1.+cfl)*(bl(i, j)+cfl*b0(i, j))
12550 flux(i, j) = v(i, j)
12552 IF (smt5(i, j-1) .OR. smt5(i, j)) flux(i, j) = flux(i, j) + &
12561 xt = 0.25*(v(i, j+1)-v(i, j-1))
12562 IF (xt .GE. 0.)
THEN 12567 IF (v(i, j-1) .LT. v(i, j))
THEN 12568 IF (v(i, j) .LT. v(i, j+1))
THEN 12573 ELSE IF (v(i, j-1) .LT. v(i, j+1))
THEN 12578 y3 = max1 - v(i, j)
12579 IF (v(i, j-1) .GT. v(i, j))
THEN 12580 IF (v(i, j) .GT. v(i, j+1))
THEN 12585 ELSE IF (v(i, j-1) .GT. v(i, j+1))
THEN 12590 z1 = v(i, j) - min6
12591 IF (x4 .GT. y3)
THEN 12592 IF (y3 .GT. z1)
THEN 12597 ELSE IF (x4 .GT. z1)
THEN 12602 dm(i, j) = sign(min3, xt)
12607 dq(i, j) = v(i, j+1) - v(i, j)
12613 al(i, j) = 0.5*(v(i, j-1)+v(i, j)) +
r3*(dm(i, j-1)-dm(i, j)&
12617 IF (jord .EQ. 8)
THEN 12621 IF (xt .GE. 0.)
THEN 12626 IF (al(i, j) - v(i, j) .GE. 0.)
THEN 12627 y4 = al(i, j) - v(i, j)
12629 y4 = -(al(i, j)-v(i, j))
12631 IF (x5 .GT. y4)
THEN 12636 bl(i, j) = -sign(min4, xt)
12637 IF (xt .GE. 0.)
THEN 12642 IF (al(i, j+1) - v(i, j) .GE. 0.)
THEN 12643 y5 = al(i, j+1) - v(i, j)
12645 y5 = -(al(i, j+1)-v(i, j))
12647 IF (x6 .GT. y5)
THEN 12652 br(i, j) = sign(min5, xt)
12655 ELSE IF (jord .EQ. 9)
THEN 12658 pmp_1 = -(2.*dq(i, j))
12659 lac_1 = pmp_1 + 1.5*dq(i, j+1)
12660 IF (0. .LT. pmp_1)
THEN 12661 IF (pmp_1 .LT. lac_1)
THEN 12666 ELSE IF (0. .LT. lac_1)
THEN 12671 IF (0. .GT. pmp_1)
THEN 12672 IF (pmp_1 .GT. lac_1)
THEN 12677 ELSE IF (0. .GT. lac_1)
THEN 12682 IF (al(i, j) - v(i, j) .LT. y12)
THEN 12685 y6 = al(i, j) - v(i, j)
12687 IF (x7 .GT. y6)
THEN 12692 pmp_2 = 2.*dq(i, j-1)
12693 lac_2 = pmp_2 - 1.5*dq(i, j-2)
12694 IF (0. .LT. pmp_2)
THEN 12695 IF (pmp_2 .LT. lac_2)
THEN 12700 ELSE IF (0. .LT. lac_2)
THEN 12705 IF (0. .GT. pmp_2)
THEN 12706 IF (pmp_2 .GT. lac_2)
THEN 12711 ELSE IF (0. .GT. lac_2)
THEN 12716 IF (al(i, j+1) - v(i, j) .LT. y13)
THEN 12719 y7 = al(i, j+1) - v(i, j)
12721 IF (x8 .GT. y7)
THEN 12728 ELSE IF (jord .EQ. 10)
THEN 12731 bl(i, j) = al(i, j) - v(i, j)
12732 br(i, j) = al(i, j+1) - v(i, j)
12733 IF (dm(i, j) .GE. 0.)
THEN 12740 IF (dm(i, j-1) .GE. 0.)
THEN 12745 IF (dm(i, j+1) .GE. 0.)
THEN 12755 IF (3.*(bl(i, j)+br(i, j)) .GE. 0.)
THEN 12756 abs3 = 3.*(bl(i, j)+br(i, j))
12758 abs3 = -(3.*(bl(i, j)+br(i, j)))
12760 IF (bl(i, j) - br(i, j) .GE. 0.)
THEN 12761 abs6 = bl(i, j) - br(i, j)
12763 abs6 = -(bl(i, j)-br(i, j))
12765 IF (abs3 .GT. abs6)
THEN 12766 pmp_1 = -(2.*dq(i, j))
12767 lac_1 = pmp_1 + 1.5*dq(i, j+1)
12768 IF (0. .LT. pmp_1)
THEN 12769 IF (pmp_1 .LT. lac_1)
THEN 12774 ELSE IF (0. .LT. lac_1)
THEN 12779 IF (0. .GT. pmp_1)
THEN 12780 IF (pmp_1 .GT. lac_1)
THEN 12785 ELSE IF (0. .GT. lac_1)
THEN 12790 IF (bl(i, j) .LT. y14)
THEN 12795 IF (x9 .GT. y8)
THEN 12800 pmp_2 = 2.*dq(i, j-1)
12801 lac_2 = pmp_2 - 1.5*dq(i, j-2)
12802 IF (0. .LT. pmp_2)
THEN 12803 IF (pmp_2 .LT. lac_2)
THEN 12808 ELSE IF (0. .LT. lac_2)
THEN 12813 IF (0. .GT. pmp_2)
THEN 12814 IF (pmp_2 .GT. lac_2)
THEN 12819 ELSE IF (0. .GT. lac_2)
THEN 12824 IF (br(i, j) .LT. y15)
THEN 12829 IF (x10 .GT. y9)
THEN 12842 bl(i, j) = al(i, j) - v(i, j)
12843 br(i, j) = al(i, j+1) - v(i, j)
12850 IF (js .EQ. 1 .AND. (.NOT.nested))
THEN 12852 br(i, 2) = al(i, 3) - v(i, 2)
12853 xt =
s15*v(i, 1) +
s11*v(i, 2) -
s14*dm(i, 2)
12854 br(i, 1) = xt - v(i, 1)
12855 bl(i, 2) = xt - v(i, 2)
12856 bl(i, 0) =
s14*dm(i, -1) -
s11*dq(i, -1)
12857 x0l = 0.5*((2.*dy(i, 0)+dy(i, -1))*v(i, 0)-dy(i, 0)*v(i, -1)&
12858 & )/(dy(i, 0)+dy(i, -1))
12859 x0r = 0.5*((2.*dy(i, 1)+dy(i, 2))*v(i, 1)-dy(i, 1)*v(i, 2))/&
12860 & (dy(i, 1)+dy(i, 2))
12862 bl(i, 1) = xt - v(i, 1)
12863 br(i, 0) = xt - v(i, 0)
12865 IF (is .EQ. 1)
THEN 12875 IF (ie + 1 .EQ. npx)
THEN 12887 CALL pert_ppm(arg1, v(is:ie+1, j), bl(is:ie+1, j), br(is:ie+1&
12890 IF (je + 1 .EQ. npy .AND. (.NOT.nested))
THEN 12892 bl(i, npy-2) = al(i, npy-2) - v(i, npy-2)
12893 xt =
s15*v(i, npy-1) +
s11*v(i, npy-2) +
s14*dm(i, npy-2)
12894 br(i, npy-2) = xt - v(i, npy-2)
12895 bl(i, npy-1) = xt - v(i, npy-1)
12896 br(i, npy) =
s11*dq(i, npy) -
s14*dm(i, npy+1)
12897 x0l = 0.5*((2.*dy(i, npy-1)+dy(i, npy-2))*v(i, npy-1)-dy(i, &
12898 & npy-1)*v(i, npy-2))/(dy(i, npy-1)+dy(i, npy-2))
12899 x0r = 0.5*((2.*dy(i, npy)+dy(i, npy+1))*v(i, npy)-dy(i, npy)&
12900 & *v(i, npy+1))/(dy(i, npy)+dy(i, npy+1))
12902 br(i, npy-1) = xt - v(i, npy-1)
12903 bl(i, npy) = xt - v(i, npy)
12905 IF (is .EQ. 1)
THEN 12915 IF (ie + 1 .EQ. npx)
THEN 12917 bl(npx, npy-1) = 0.
12919 br(npx, npy-1) = 0.
12927 CALL pert_ppm(arg1, v(is:ie+1, j), bl(is:ie+1, j), br(is:ie+1&
12933 al(i, j) = 0.5*(v(i, j-1)+v(i, j)) +
r3*(dm(i, j-1)-dm(i, j)&
12939 pmp = 2.*dq(i, j-1)
12940 lac = pmp - 1.5*dq(i, j-2)
12941 IF (0. .LT. pmp)
THEN 12942 IF (pmp .LT. lac)
THEN 12947 ELSE IF (0. .LT. lac)
THEN 12952 IF (0. .GT. pmp)
THEN 12953 IF (pmp .GT. lac)
THEN 12958 ELSE IF (0. .GT. lac)
THEN 12963 IF (al(i, j+1) - v(i, j) .LT. y16)
THEN 12966 y10 = al(i, j+1) - v(i, j)
12968 IF (x11 .GT. y10)
THEN 12973 pmp = -(2.*dq(i, j))
12974 lac = pmp + 1.5*dq(i, j+1)
12975 IF (0. .LT. pmp)
THEN 12976 IF (pmp .LT. lac)
THEN 12981 ELSE IF (0. .LT. lac)
THEN 12986 IF (0. .GT. pmp)
THEN 12987 IF (pmp .GT. lac)
THEN 12992 ELSE IF (0. .GT. lac)
THEN 12997 IF (al(i, j) - v(i, j) .LT. y17)
THEN 13000 y11 = al(i, j) - v(i, j)
13002 IF (x12 .GT. y11)
THEN 13012 IF (c(i, j) .GT. 0.)
THEN 13013 cfl = c(i, j)*rdy(i, j-1)
13014 flux(i, j) = v(i, j-1) + (1.-cfl)*(br(i, j-1)-cfl*(bl(i, j-1&
13017 cfl = c(i, j)*rdy(i, j)
13018 flux(i, j) = v(i, j) + (1.+cfl)*(bl(i, j)+cfl*(bl(i, j)+br(i&
13024 END SUBROUTINE ytp_v 13050 SUBROUTINE d2a2c_vect_fwd(u, v, ua, va, uc, vc, ut, vt, dord4, &
13051 & gridstruct, bd, npx, npy, nested, grid_type)
13056 LOGICAL,
INTENT(IN) :: dord4
13057 REAL,
INTENT(IN) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1)
13058 REAL,
INTENT(IN) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed)
13059 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: uc
13060 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: vc
13061 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua, va, ut, vt
13062 INTEGER,
INTENT(IN) :: npx, npy,
grid_type 13063 LOGICAL,
INTENT(IN) :: nested
13066 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: utmp, vtmp
13067 INTEGER :: npt, i, j, ifirst, ilast, id
13068 INTEGER :: is, ie, js, je
13069 INTEGER :: isd, ied, jsd, jed
13070 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
13071 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
13072 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsin2
13073 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
13089 INTEGER :: ad_from0
13128 sin_sg => gridstruct%sin_sg
13129 cosa_u => gridstruct%cosa_u
13130 cosa_v => gridstruct%cosa_v
13131 cosa_s => gridstruct%cosa_s
13132 rsin_u => gridstruct%rsin_u
13133 rsin_v => gridstruct%rsin_v
13134 rsin2 => gridstruct%rsin2
13135 dxa => gridstruct%dxa
13136 dya => gridstruct%dya
13142 IF (
grid_type .LT. 3 .AND. (.NOT.nested))
THEN 13153 utmp(i, j) =
a2*(u(i, j-1)+u(i, j+2)) +
a1*(u(i, j)+u(i, j+1))
13158 utmp(i, jsd) = 0.5*(u(i, jsd)+u(i, jsd+1))
13160 utmp(i, jed) = 0.5*(u(i, jed)+u(i, jed+1))
13164 vtmp(i, j) =
a2*(v(i-1, j)+v(i+2, j)) +
a1*(v(i, j)+v(i+1, j))
13167 vtmp(isd, j) = 0.5*(v(isd, j)+v(isd+1, j))
13169 vtmp(ied, j) = 0.5*(v(ied, j)+v(ied+1, j))
13174 ua(i, j) = (utmp(i, j)-vtmp(i, j)*cosa_s(i, j))*rsin2(i, j)
13176 va(i, j) = (vtmp(i, j)-utmp(i, j)*cosa_s(i, j))*rsin2(i, j)
13181 IF (npt .LT. js - 1)
THEN 13186 IF (npy - npt .GT. je + 1)
THEN 13195 IF (npt .LT. isd)
THEN 13200 IF (npx - npt .GT. ied)
THEN 13207 utmp(i, j) =
a2*(u(i, j-1)+u(i, j+2)) +
a1*(u(i, j)+u(i, j+1))
13212 IF (npt .LT. jsd)
THEN 13217 IF (npy - npt .GT. jed)
THEN 13223 IF (npt .LT. is - 1)
THEN 13228 IF (npx - npt .GT. ie + 1)
THEN 13235 vtmp(i, j) =
a2*(v(i-1, j)+v(i+2, j)) +
a1*(v(i, j)+v(i+1, j))
13244 IF (js .EQ. 1 .OR. jsd .LT. npt)
THEN 13247 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
13248 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
13255 IF (je + 1 .EQ. npy .OR. jed .GE. npy - npt)
THEN 13258 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
13259 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
13266 IF (is .EQ. 1 .OR. isd .LT. npt)
THEN 13267 IF (npt .LT. jsd)
THEN 13272 IF (npy - npt .GT. jed)
THEN 13279 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
13280 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
13287 IF (ie + 1 .EQ. npx .OR. ied .GE. npx - npt)
THEN 13288 IF (npt .LT. jsd)
THEN 13295 IF (npy - npt .GT. jed)
THEN 13304 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
13305 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
13316 DO j=js-1-id,je+1+id
13317 DO i=is-1-id,ie+1+id
13319 ua(i, j) = (utmp(i, j)-vtmp(i, j)*cosa_s(i, j))*rsin2(i, j)
13321 va(i, j) = (vtmp(i, j)-utmp(i, j)*cosa_s(i, j))*rsin2(i, j)
13331 IF (gridstruct%sw_corner)
THEN 13333 utmp(i, 0) = -vtmp(0, 1-i)
13339 IF (gridstruct%se_corner)
THEN 13341 utmp(npx+i, 0) = vtmp(npx, i+1)
13347 IF (gridstruct%ne_corner)
THEN 13349 utmp(npx+i, npy) = -vtmp(npx, je-i)
13355 IF (gridstruct%nw_corner)
THEN 13357 utmp(i, npy) = vtmp(0, je+i)
13363 IF (
grid_type .LT. 3 .AND. (.NOT.nested))
THEN 13364 IF (3 .LT. is - 1)
THEN 13369 IF (npx - 2 .GT. ie + 2)
THEN 13386 uc(i, j) =
a2*(utmp(i-2, j)+utmp(i+1, j)) +
a1*(utmp(i-1, j)+&
13389 ut(i, j) = (uc(i, j)-v(i, j)*cosa_u(i, j))*rsin_u(i, j)
13394 IF (gridstruct%sw_corner)
THEN 13396 ua(-1, 0) = -va(0, 2)
13398 ua(0, 0) = -va(0, 1)
13403 IF (gridstruct%se_corner)
THEN 13405 ua(npx, 0) = va(npx, 1)
13407 ua(npx+1, 0) = va(npx, 2)
13412 IF (gridstruct%ne_corner)
THEN 13414 ua(npx, npy) = -va(npx, npy-1)
13416 ua(npx+1, npy) = -va(npx, npy-2)
13421 IF (gridstruct%nw_corner)
THEN 13423 ua(-1, npy) = va(0, npy-2)
13425 ua(0, npy) = va(0, npy-1)
13430 IF (is .EQ. 1 .AND. (.NOT.nested))
THEN 13432 uc(0, j) =
c1*utmp(-2, j) +
c2*utmp(-1, j) +
c3*utmp(0, j)
13436 IF (ut(1, j) .GT. 0.)
THEN 13437 uc(1, j) = ut(1, j)*sin_sg(0, j, 3)
13440 uc(1, j) = ut(1, j)*sin_sg(1, j, 1)
13443 uc(2, j) =
c1*utmp(3, j) +
c2*utmp(2, j) +
c3*utmp(1, j)
13445 ut(0, j) = (uc(0, j)-v(0, j)*cosa_u(0, j))*rsin_u(0, j)
13447 ut(2, j) = (uc(2, j)-v(2, j)*cosa_u(2, j))*rsin_u(2, j)
13453 IF (ie + 1 .EQ. npx .AND. (.NOT.nested))
THEN 13455 uc(npx-1, j) =
c1*utmp(npx-3, j) +
c2*utmp(npx-2, j) +
c3*utmp&
13460 IF (ut(npx, j) .GT. 0.)
THEN 13461 uc(npx, j) = ut(npx, j)*sin_sg(npx-1, j, 3)
13464 uc(npx, j) = ut(npx, j)*sin_sg(npx, j, 1)
13467 uc(npx+1, j) =
c3*utmp(npx, j) +
c2*utmp(npx+1, j) +
c1*utmp(&
13470 ut(npx-1, j) = (uc(npx-1, j)-v(npx-1, j)*cosa_u(npx-1, j))*&
13473 ut(npx+1, j) = (uc(npx+1, j)-v(npx+1, j)*cosa_u(npx+1, j))*&
13486 IF (gridstruct%sw_corner)
THEN 13488 vtmp(0, j) = -utmp(1-j, 0)
13494 IF (gridstruct%nw_corner)
THEN 13496 vtmp(0, npy+j) = utmp(j+1, npy)
13502 IF (gridstruct%se_corner)
THEN 13504 vtmp(npx, j) = utmp(ie+j, 0)
13510 IF (gridstruct%ne_corner)
THEN 13512 vtmp(npx, npy+j) = -utmp(ie-j, npy)
13518 IF (gridstruct%sw_corner)
THEN 13520 va(0, -1) = -ua(2, 0)
13522 va(0, 0) = -ua(1, 0)
13527 IF (gridstruct%se_corner)
THEN 13529 va(npx, 0) = ua(npx-1, 0)
13531 va(npx, -1) = ua(npx-2, 0)
13536 IF (gridstruct%ne_corner)
THEN 13538 va(npx, npy) = -ua(npx-1, npy)
13540 va(npx, npy+1) = -ua(npx-2, npy)
13545 IF (gridstruct%nw_corner)
THEN 13547 va(0, npy) = ua(1, npy)
13549 va(0, npy+1) = ua(2, npy)
13556 IF (j .EQ. 1 .AND. (.NOT.nested))
THEN 13560 IF (vt(i, j) .GT. 0.)
THEN 13561 vc(i, j) = vt(i, j)*sin_sg(i, j-1, 4)
13564 vc(i, j) = vt(i, j)*sin_sg(i, j, 2)
13569 ELSE IF (j .EQ. 0 .OR. (j .EQ. npy - 1 .AND. (.NOT.nested))) &
13572 vc(i, j) =
c1*vtmp(i, j-2) +
c2*vtmp(i, j-1) +
c3*vtmp(i, j)
13574 vt(i, j) = (vc(i, j)-u(i, j)*cosa_v(i, j))*rsin_v(i, j)
13577 ELSE IF (j .EQ. 2 .OR. (j .EQ. npy + 1 .AND. (.NOT.nested))) &
13580 vc(i, j) =
c1*vtmp(i, j+1) +
c2*vtmp(i, j) +
c3*vtmp(i, j-1)
13582 vt(i, j) = (vc(i, j)-u(i, j)*cosa_v(i, j))*rsin_v(i, j)
13585 ELSE IF (j .EQ. npy .AND. (.NOT.nested))
THEN 13590 IF (vt(i, j) .GT. 0.)
THEN 13591 vc(i, j) = vt(i, j)*sin_sg(i, j-1, 4)
13594 vc(i, j) = vt(i, j)*sin_sg(i, j, 2)
13602 vc(i, j) =
a2*(vtmp(i, j-2)+vtmp(i, j+1)) +
a1*(vtmp(i, j-1)&
13605 vt(i, j) = (vc(i, j)-u(i, j)*cosa_v(i, j))*rsin_v(i, j)
13640 vc(i, j) =
a2*(vtmp(i, j-2)+vtmp(i, j+1)) +
a1*(vtmp(i, j-1)+&
13643 vt(i, j) = vc(i, j)
13696 SUBROUTINE d2a2c_vect_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, uc, &
13697 & uc_ad, vc, vc_ad, ut, ut_ad, vt, vt_ad, dord4, gridstruct, bd, npx, &
13698 & npy, nested, grid_type)
13703 LOGICAL,
INTENT(IN) :: dord4
13704 REAL,
INTENT(IN) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1)
13705 REAL :: u_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1)
13706 REAL,
INTENT(IN) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed)
13707 REAL :: v_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed)
13708 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: uc
13709 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: uc_ad
13710 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: vc
13711 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: vc_ad
13712 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua, va, ut, vt
13713 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua_ad, va_ad, ut_ad&
13715 INTEGER,
INTENT(IN) :: npx, npy,
grid_type 13716 LOGICAL,
INTENT(IN) :: nested
13718 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: utmp, vtmp
13719 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: utmp_ad, vtmp_ad
13720 INTEGER :: npt, i, j, ifirst, ilast, id
13721 INTEGER :: is, ie, js, je
13722 INTEGER :: isd, ied, jsd, jed
13723 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
13724 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
13725 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsin2
13726 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
13755 INTEGER :: ad_from0
13801 sin_sg => gridstruct%sin_sg
13802 cosa_u => gridstruct%cosa_u
13803 cosa_v => gridstruct%cosa_v
13804 cosa_s => gridstruct%cosa_s
13805 rsin_u => gridstruct%rsin_u
13806 rsin_v => gridstruct%rsin_v
13807 rsin2 => gridstruct%rsin2
13808 dxa => gridstruct%dxa
13809 dya => gridstruct%dya
13815 IF (
grid_type .LT. 3 .AND. (.NOT.nested))
THEN 13821 IF (branch .EQ. 0)
THEN 13828 dxa => gridstruct%dxa
13830 cosa_v => gridstruct%cosa_v
13835 sin_sg => gridstruct%sin_sg
13837 dya => gridstruct%dya
13841 rsin_v => gridstruct%rsin_v
13855 IF (branch .LT. 2)
THEN 13856 IF (branch .EQ. 0)
THEN 13859 temp_ad10 = rsin_v(i, j)*vt_ad(i, j)
13860 vc_ad(i, j) = vc_ad(i, j) + temp_ad10
13861 u_ad(i, j) = u_ad(i, j) - cosa_v(i, j)*temp_ad10
13863 vtmp_ad(i, j-2) = vtmp_ad(i, j-2) +
a2*vc_ad(i, j)
13864 vtmp_ad(i, j+1) = vtmp_ad(i, j+1) +
a2*vc_ad(i, j)
13865 vtmp_ad(i, j-1) = vtmp_ad(i, j-1) +
a1*vc_ad(i, j)
13866 vtmp_ad(i, j) = vtmp_ad(i, j) +
a1*vc_ad(i, j)
13872 IF (branch .EQ. 0)
THEN 13873 vt_ad(i, j) = vt_ad(i, j) + sin_sg(i, j, 2)*vc_ad(i, j)
13876 vt_ad(i, j) = vt_ad(i, j) + sin_sg(i, j-1, 4)*vc_ad(i, j&
13881 & 1), dya(i, j-2:j+1), vt_ad(i, j))
13886 ELSE IF (branch .EQ. 2)
THEN 13889 temp_ad9 = rsin_v(i, j)*vt_ad(i, j)
13890 vc_ad(i, j) = vc_ad(i, j) + temp_ad9
13891 u_ad(i, j) = u_ad(i, j) - cosa_v(i, j)*temp_ad9
13893 vtmp_ad(i, j+1) = vtmp_ad(i, j+1) +
c1*vc_ad(i, j)
13894 vtmp_ad(i, j) = vtmp_ad(i, j) +
c2*vc_ad(i, j)
13895 vtmp_ad(i, j-1) = vtmp_ad(i, j-1) +
c3*vc_ad(i, j)
13898 ELSE IF (branch .EQ. 3)
THEN 13901 temp_ad8 = rsin_v(i, j)*vt_ad(i, j)
13902 vc_ad(i, j) = vc_ad(i, j) + temp_ad8
13903 u_ad(i, j) = u_ad(i, j) - cosa_v(i, j)*temp_ad8
13905 vtmp_ad(i, j-2) = vtmp_ad(i, j-2) +
c1*vc_ad(i, j)
13906 vtmp_ad(i, j-1) = vtmp_ad(i, j-1) +
c2*vc_ad(i, j)
13907 vtmp_ad(i, j) = vtmp_ad(i, j) +
c3*vc_ad(i, j)
13913 IF (branch .EQ. 0)
THEN 13914 vt_ad(i, j) = vt_ad(i, j) + sin_sg(i, j, 2)*vc_ad(i, j)
13917 vt_ad(i, j) = vt_ad(i, j) + sin_sg(i, j-1, 4)*vc_ad(i, j)
13921 & i, -1:2), vt_ad(i, j))
13934 dxa => gridstruct%dxa
13939 sin_sg => gridstruct%sin_sg
13956 vc_ad(i, j) = vc_ad(i, j) + vt_ad(i, j)
13958 vtmp_ad(i, j-2) = vtmp_ad(i, j-2) +
a2*vc_ad(i, j)
13959 vtmp_ad(i, j+1) = vtmp_ad(i, j+1) +
a2*vc_ad(i, j)
13960 vtmp_ad(i, j-1) = vtmp_ad(i, j-1) +
a1*vc_ad(i, j)
13961 vtmp_ad(i, j) = vtmp_ad(i, j) +
a1*vc_ad(i, j)
13967 IF (branch .EQ. 0)
THEN 13969 ua_ad(2, npy) = ua_ad(2, npy) + va_ad(0, npy+1)
13970 va_ad(0, npy+1) = 0.0
13972 ua_ad(1, npy) = ua_ad(1, npy) + va_ad(0, npy)
13973 va_ad(0, npy) = 0.0
13976 IF (branch .EQ. 0)
THEN 13978 ua_ad(npx-2, npy) = ua_ad(npx-2, npy) - va_ad(npx, npy+1)
13979 va_ad(npx, npy+1) = 0.0
13981 ua_ad(npx-1, npy) = ua_ad(npx-1, npy) - va_ad(npx, npy)
13982 va_ad(npx, npy) = 0.0
13985 IF (branch .EQ. 0)
THEN 13987 ua_ad(npx-2, 0) = ua_ad(npx-2, 0) + va_ad(npx, -1)
13988 va_ad(npx, -1) = 0.0
13990 ua_ad(npx-1, 0) = ua_ad(npx-1, 0) + va_ad(npx, 0)
13991 va_ad(npx, 0) = 0.0
13994 IF (branch .EQ. 0)
THEN 13996 ua_ad(1, 0) = ua_ad(1, 0) - va_ad(0, 0)
13999 ua_ad(2, 0) = ua_ad(2, 0) - va_ad(0, -1)
14003 IF (branch .EQ. 0)
THEN 14006 utmp_ad(ie-j, npy) = utmp_ad(ie-j, npy) - vtmp_ad(npx, npy+j)
14007 vtmp_ad(npx, npy+j) = 0.0
14013 IF (branch .EQ. 0)
THEN 14015 utmp_ad(ie+j, 0) = utmp_ad(ie+j, 0) + vtmp_ad(npx, j)
14016 vtmp_ad(npx, j) = 0.0
14020 IF (branch .EQ. 0)
THEN 14022 utmp_ad(j+1, npy) = utmp_ad(j+1, npy) + vtmp_ad(0, npy+j)
14023 vtmp_ad(0, npy+j) = 0.0
14027 IF (branch .EQ. 0)
THEN 14029 utmp_ad(1-j, 0) = utmp_ad(1-j, 0) - vtmp_ad(0, j)
14030 vtmp_ad(0, j) = 0.0
14033 cosa_u => gridstruct%cosa_u
14034 rsin_u => gridstruct%rsin_u
14036 IF (branch .EQ. 0)
THEN 14039 temp_ad6 = rsin_u(npx+1, j)*ut_ad(npx+1, j)
14040 uc_ad(npx+1, j) = uc_ad(npx+1, j) + temp_ad6
14041 v_ad(npx+1, j) = v_ad(npx+1, j) - cosa_u(npx+1, j)*temp_ad6
14042 ut_ad(npx+1, j) = 0.0
14044 temp_ad7 = rsin_u(npx-1, j)*ut_ad(npx-1, j)
14045 uc_ad(npx-1, j) = uc_ad(npx-1, j) + temp_ad7
14046 v_ad(npx-1, j) = v_ad(npx-1, j) - cosa_u(npx-1, j)*temp_ad7
14047 ut_ad(npx-1, j) = 0.0
14048 utmp_ad(npx, j) = utmp_ad(npx, j) +
c3*uc_ad(npx+1, j)
14049 utmp_ad(npx+1, j) = utmp_ad(npx+1, j) +
c2*uc_ad(npx+1, j)
14050 utmp_ad(npx+2, j) = utmp_ad(npx+2, j) +
c1*uc_ad(npx+1, j)
14051 uc_ad(npx+1, j) = 0.0
14053 IF (branch .EQ. 0)
THEN 14054 ut_ad(npx, j) = ut_ad(npx, j) + sin_sg(npx-1, j, 3)*uc_ad(npx&
14056 uc_ad(npx, j) = 0.0
14058 ut_ad(npx, j) = ut_ad(npx, j) + sin_sg(npx, j, 1)*uc_ad(npx, j&
14060 uc_ad(npx, j) = 0.0
14063 & , j), dxa(npx-2:npx+1, j), ut_ad(npx, j))
14064 ut_ad(npx, j) = 0.0
14066 utmp_ad(npx-3, j) = utmp_ad(npx-3, j) +
c1*uc_ad(npx-1, j)
14067 utmp_ad(npx-2, j) = utmp_ad(npx-2, j) +
c2*uc_ad(npx-1, j)
14068 utmp_ad(npx-1, j) = utmp_ad(npx-1, j) +
c3*uc_ad(npx-1, j)
14069 uc_ad(npx-1, j) = 0.0
14071 ELSE IF (branch .NE. 1)
THEN 14075 IF (branch .EQ. 0)
THEN 14078 temp_ad4 = rsin_u(2, j)*ut_ad(2, j)
14079 uc_ad(2, j) = uc_ad(2, j) + temp_ad4
14080 v_ad(2, j) = v_ad(2, j) - cosa_u(2, j)*temp_ad4
14083 temp_ad5 = rsin_u(0, j)*ut_ad(0, j)
14084 uc_ad(0, j) = uc_ad(0, j) + temp_ad5
14085 v_ad(0, j) = v_ad(0, j) - cosa_u(0, j)*temp_ad5
14087 utmp_ad(3, j) = utmp_ad(3, j) +
c1*uc_ad(2, j)
14088 utmp_ad(2, j) = utmp_ad(2, j) +
c2*uc_ad(2, j)
14089 utmp_ad(1, j) = utmp_ad(1, j) +
c3*uc_ad(2, j)
14092 IF (branch .EQ. 0)
THEN 14093 ut_ad(1, j) = ut_ad(1, j) + sin_sg(0, j, 3)*uc_ad(1, j)
14096 ut_ad(1, j) = ut_ad(1, j) + sin_sg(1, j, 1)*uc_ad(1, j)
14100 & , j), ut_ad(1, j))
14103 utmp_ad(-2, j) = utmp_ad(-2, j) +
c1*uc_ad(0, j)
14104 utmp_ad(-1, j) = utmp_ad(-1, j) +
c2*uc_ad(0, j)
14105 utmp_ad(0, j) = utmp_ad(0, j) +
c3*uc_ad(0, j)
14110 IF (branch .EQ. 0)
THEN 14112 va_ad(0, npy-1) = va_ad(0, npy-1) + ua_ad(0, npy)
14113 ua_ad(0, npy) = 0.0
14115 va_ad(0, npy-2) = va_ad(0, npy-2) + ua_ad(-1, npy)
14116 ua_ad(-1, npy) = 0.0
14119 IF (branch .EQ. 0)
THEN 14121 va_ad(npx, npy-2) = va_ad(npx, npy-2) - ua_ad(npx+1, npy)
14122 ua_ad(npx+1, npy) = 0.0
14124 va_ad(npx, npy-1) = va_ad(npx, npy-1) - ua_ad(npx, npy)
14125 ua_ad(npx, npy) = 0.0
14128 IF (branch .EQ. 0)
THEN 14130 va_ad(npx, 2) = va_ad(npx, 2) + ua_ad(npx+1, 0)
14131 ua_ad(npx+1, 0) = 0.0
14133 va_ad(npx, 1) = va_ad(npx, 1) + ua_ad(npx, 0)
14134 ua_ad(npx, 0) = 0.0
14137 IF (branch .EQ. 0)
THEN 14139 va_ad(0, 1) = va_ad(0, 1) - ua_ad(0, 0)
14142 va_ad(0, 2) = va_ad(0, 2) - ua_ad(-1, 0)
14145 100
DO j=je+1,js-1,-1
14146 DO i=ilast,ifirst,-1
14148 temp_ad3 = rsin_u(i, j)*ut_ad(i, j)
14149 uc_ad(i, j) = uc_ad(i, j) + temp_ad3
14150 v_ad(i, j) = v_ad(i, j) - cosa_u(i, j)*temp_ad3
14152 utmp_ad(i-2, j) = utmp_ad(i-2, j) +
a2*uc_ad(i, j)
14153 utmp_ad(i+1, j) = utmp_ad(i+1, j) +
a2*uc_ad(i, j)
14154 utmp_ad(i-1, j) = utmp_ad(i-1, j) +
a1*uc_ad(i, j)
14155 utmp_ad(i, j) = utmp_ad(i, j) +
a1*uc_ad(i, j)
14161 IF (branch .EQ. 0)
THEN 14163 vtmp_ad(0, je+i) = vtmp_ad(0, je+i) + utmp_ad(i, npy)
14164 utmp_ad(i, npy) = 0.0
14168 IF (branch .EQ. 0)
THEN 14170 vtmp_ad(npx, je-i) = vtmp_ad(npx, je-i) - utmp_ad(npx+i, npy)
14171 utmp_ad(npx+i, npy) = 0.0
14175 IF (branch .EQ. 0)
THEN 14177 vtmp_ad(npx, i+1) = vtmp_ad(npx, i+1) + utmp_ad(npx+i, 0)
14178 utmp_ad(npx+i, 0) = 0.0
14182 IF (branch .EQ. 0)
THEN 14184 vtmp_ad(0, 1-i) = vtmp_ad(0, 1-i) - utmp_ad(i, 0)
14185 utmp_ad(i, 0) = 0.0
14188 rsin2 => gridstruct%rsin2
14189 cosa_s => gridstruct%cosa_s
14191 IF (branch .EQ. 0)
THEN 14194 temp_ad0 = rsin2(i, j)*ua_ad(i, j)
14196 temp_ad = rsin2(i, j)*va_ad(i, j)
14197 vtmp_ad(i, j) = vtmp_ad(i, j) + temp_ad - cosa_s(i, j)*&
14199 utmp_ad(i, j) = utmp_ad(i, j) + temp_ad0 - cosa_s(i, j)*&
14207 v_ad(ied, j) = v_ad(ied, j) + 0.5*vtmp_ad(ied, j)
14208 v_ad(ied+1, j) = v_ad(ied+1, j) + 0.5*vtmp_ad(ied, j)
14209 vtmp_ad(ied, j) = 0.0
14210 v_ad(isd, j) = v_ad(isd, j) + 0.5*vtmp_ad(isd, j)
14211 v_ad(isd+1, j) = v_ad(isd+1, j) + 0.5*vtmp_ad(isd, j)
14212 vtmp_ad(isd, j) = 0.0
14213 DO i=ied-1,isd+1,-1
14214 v_ad(i-1, j) = v_ad(i-1, j) +
a2*vtmp_ad(i, j)
14215 v_ad(i+2, j) = v_ad(i+2, j) +
a2*vtmp_ad(i, j)
14216 v_ad(i, j) = v_ad(i, j) +
a1*vtmp_ad(i, j)
14217 v_ad(i+1, j) = v_ad(i+1, j) +
a1*vtmp_ad(i, j)
14218 vtmp_ad(i, j) = 0.0
14222 u_ad(i, jed) = u_ad(i, jed) + 0.5*utmp_ad(i, jed)
14223 u_ad(i, jed+1) = u_ad(i, jed+1) + 0.5*utmp_ad(i, jed)
14224 utmp_ad(i, jed) = 0.0
14225 u_ad(i, jsd) = u_ad(i, jsd) + 0.5*utmp_ad(i, jsd)
14226 u_ad(i, jsd+1) = u_ad(i, jsd+1) + 0.5*utmp_ad(i, jsd)
14227 utmp_ad(i, jsd) = 0.0
14229 DO j=jed-1,jsd+1,-1
14231 u_ad(i, j-1) = u_ad(i, j-1) +
a2*utmp_ad(i, j)
14232 u_ad(i, j+2) = u_ad(i, j+2) +
a2*utmp_ad(i, j)
14233 u_ad(i, j) = u_ad(i, j) +
a1*utmp_ad(i, j)
14234 u_ad(i, j+1) = u_ad(i, j+1) +
a1*utmp_ad(i, j)
14235 utmp_ad(i, j) = 0.0
14239 DO j=je+id+1,js-1-id,-1
14240 DO i=ie+id+1,is-1-id,-1
14241 temp_ad2 = rsin2(i, j)*ua_ad(i, j)
14243 temp_ad1 = rsin2(i, j)*va_ad(i, j)
14244 vtmp_ad(i, j) = vtmp_ad(i, j) + temp_ad1 - cosa_s(i, j)*&
14246 utmp_ad(i, j) = utmp_ad(i, j) + temp_ad2 - cosa_s(i, j)*&
14254 IF (branch .NE. 0)
THEN 14255 IF (branch .NE. 1)
THEN 14257 DO i=ied,npx-npt+1,-1
14258 v_ad(i, j) = v_ad(i, j) + 0.5*vtmp_ad(i, j)
14259 v_ad(i+1, j) = v_ad(i+1, j) + 0.5*vtmp_ad(i, j)
14260 vtmp_ad(i, j) = 0.0
14261 u_ad(i, j) = u_ad(i, j) + 0.5*utmp_ad(i, j)
14262 u_ad(i, j+1) = u_ad(i, j+1) + 0.5*utmp_ad(i, j)
14263 utmp_ad(i, j) = 0.0
14267 IF (branch .EQ. 0) jed = bd%jed
14269 IF (branch .EQ. 0) jsd = bd%jsd
14273 IF (branch .EQ. 0)
THEN 14276 v_ad(i, j) = v_ad(i, j) + 0.5*vtmp_ad(i, j)
14277 v_ad(i+1, j) = v_ad(i+1, j) + 0.5*vtmp_ad(i, j)
14278 vtmp_ad(i, j) = 0.0
14279 u_ad(i, j) = u_ad(i, j) + 0.5*utmp_ad(i, j)
14280 u_ad(i, j+1) = u_ad(i, j+1) + 0.5*utmp_ad(i, j)
14281 utmp_ad(i, j) = 0.0
14286 IF (branch .EQ. 0)
THEN 14287 DO j=jed,npy-npt+1,-1
14289 v_ad(i, j) = v_ad(i, j) + 0.5*vtmp_ad(i, j)
14290 v_ad(i+1, j) = v_ad(i+1, j) + 0.5*vtmp_ad(i, j)
14291 vtmp_ad(i, j) = 0.0
14292 u_ad(i, j) = u_ad(i, j) + 0.5*utmp_ad(i, j)
14293 u_ad(i, j+1) = u_ad(i, j+1) + 0.5*utmp_ad(i, j)
14294 utmp_ad(i, j) = 0.0
14299 IF (branch .EQ. 0)
THEN 14302 v_ad(i, j) = v_ad(i, j) + 0.5*vtmp_ad(i, j)
14303 v_ad(i+1, j) = v_ad(i+1, j) + 0.5*vtmp_ad(i, j)
14304 vtmp_ad(i, j) = 0.0
14305 u_ad(i, j) = u_ad(i, j) + 0.5*utmp_ad(i, j)
14306 u_ad(i, j+1) = u_ad(i, j+1) + 0.5*utmp_ad(i, j)
14307 utmp_ad(i, j) = 0.0
14315 DO i=ad_to0,ad_from0,-1
14316 v_ad(i-1, j) = v_ad(i-1, j) +
a2*vtmp_ad(i, j)
14317 v_ad(i+2, j) = v_ad(i+2, j) +
a2*vtmp_ad(i, j)
14318 v_ad(i, j) = v_ad(i, j) +
a1*vtmp_ad(i, j)
14319 v_ad(i+1, j) = v_ad(i+1, j) +
a1*vtmp_ad(i, j)
14320 vtmp_ad(i, j) = 0.0
14326 DO i=ad_to,ad_from,-1
14327 u_ad(i, j-1) = u_ad(i, j-1) +
a2*utmp_ad(i, j)
14328 u_ad(i, j+2) = u_ad(i, j+2) +
a2*utmp_ad(i, j)
14329 u_ad(i, j) = u_ad(i, j) +
a1*utmp_ad(i, j)
14330 u_ad(i, j+1) = u_ad(i, j+1) +
a1*utmp_ad(i, j)
14331 utmp_ad(i, j) = 0.0
14341 SUBROUTINE d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct&
14342 & , bd, npx, npy, nested, grid_type)
14345 LOGICAL,
INTENT(IN) :: dord4
14346 REAL,
INTENT(IN) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1)
14347 REAL,
INTENT(IN) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed)
14348 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(OUT) :: uc
14349 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(OUT) :: vc
14350 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(OUT) :: ua, va&
14352 INTEGER,
INTENT(IN) :: npx, npy,
grid_type 14353 LOGICAL,
INTENT(IN) :: nested
14356 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: utmp, vtmp
14357 INTEGER :: npt, i, j, ifirst, ilast, id
14358 INTEGER :: is, ie, js, je
14359 INTEGER :: isd, ied, jsd, jed
14360 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
14361 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
14362 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsin2
14363 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
14386 sin_sg => gridstruct%sin_sg
14387 cosa_u => gridstruct%cosa_u
14388 cosa_v => gridstruct%cosa_v
14389 cosa_s => gridstruct%cosa_s
14390 rsin_u => gridstruct%rsin_u
14391 rsin_v => gridstruct%rsin_v
14392 rsin2 => gridstruct%rsin2
14393 dxa => gridstruct%dxa
14394 dya => gridstruct%dya
14400 IF (
grid_type .LT. 3 .AND. (.NOT.nested))
THEN 14411 utmp(i, j) =
a2*(u(i, j-1)+u(i, j+2)) +
a1*(u(i, j)+u(i, j+1))
14416 utmp(i, jsd) = 0.5*(u(i, jsd)+u(i, jsd+1))
14418 utmp(i, jed) = 0.5*(u(i, jed)+u(i, jed+1))
14422 vtmp(i, j) =
a2*(v(i-1, j)+v(i+2, j)) +
a1*(v(i, j)+v(i+1, j))
14425 vtmp(isd, j) = 0.5*(v(isd, j)+v(isd+1, j))
14427 vtmp(ied, j) = 0.5*(v(ied, j)+v(ied+1, j))
14431 ua(i, j) = (utmp(i, j)-vtmp(i, j)*cosa_s(i, j))*rsin2(i, j)
14432 va(i, j) = (vtmp(i, j)-utmp(i, j)*cosa_s(i, j))*rsin2(i, j)
14436 IF (npt .LT. js - 1)
THEN 14441 IF (npy - npt .GT. je + 1)
THEN 14450 IF (npt .LT. isd)
THEN 14455 IF (npx - npt .GT. ied)
THEN 14461 utmp(i, j) =
a2*(u(i, j-1)+u(i, j+2)) +
a1*(u(i, j)+u(i, j+1))
14464 IF (npt .LT. jsd)
THEN 14469 IF (npy - npt .GT. jed)
THEN 14475 IF (npt .LT. is - 1)
THEN 14480 IF (npx - npt .GT. ie + 1)
THEN 14486 vtmp(i, j) =
a2*(v(i-1, j)+v(i+2, j)) +
a1*(v(i, j)+v(i+1, j))
14493 IF (js .EQ. 1 .OR. jsd .LT. npt)
THEN 14496 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
14497 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
14501 IF (je + 1 .EQ. npy .OR. jed .GE. npy - npt)
THEN 14504 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
14505 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
14509 IF (is .EQ. 1 .OR. isd .LT. npt)
THEN 14510 IF (npt .LT. jsd)
THEN 14515 IF (npy - npt .GT. jed)
THEN 14522 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
14523 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
14527 IF (ie + 1 .EQ. npx .OR. ied .GE. npx - npt)
THEN 14528 IF (npt .LT. jsd)
THEN 14533 IF (npy - npt .GT. jed)
THEN 14540 utmp(i, j) = 0.5*(u(i, j)+u(i, j+1))
14541 vtmp(i, j) = 0.5*(v(i, j)+v(i+1, j))
14547 DO j=js-1-id,je+1+id
14548 DO i=is-1-id,ie+1+id
14549 ua(i, j) = (utmp(i, j)-vtmp(i, j)*cosa_s(i, j))*rsin2(i, j)
14550 va(i, j) = (vtmp(i, j)-utmp(i, j)*cosa_s(i, j))*rsin2(i, j)
14559 IF (gridstruct%sw_corner)
THEN 14561 utmp(i, 0) = -vtmp(0, 1-i)
14564 IF (gridstruct%se_corner)
THEN 14566 utmp(npx+i, 0) = vtmp(npx, i+1)
14569 IF (gridstruct%ne_corner)
THEN 14571 utmp(npx+i, npy) = -vtmp(npx, je-i)
14574 IF (gridstruct%nw_corner)
THEN 14576 utmp(i, npy) = vtmp(0, je+i)
14579 IF (
grid_type .LT. 3 .AND. (.NOT.nested))
THEN 14580 IF (3 .LT. is - 1)
THEN 14585 IF (npx - 2 .GT. ie + 2)
THEN 14599 uc(i, j) =
a2*(utmp(i-2, j)+utmp(i+1, j)) +
a1*(utmp(i-1, j)+&
14601 ut(i, j) = (uc(i, j)-v(i, j)*cosa_u(i, j))*rsin_u(i, j)
14606 IF (gridstruct%sw_corner)
THEN 14607 ua(-1, 0) = -va(0, 2)
14608 ua(0, 0) = -va(0, 1)
14610 IF (gridstruct%se_corner)
THEN 14611 ua(npx, 0) = va(npx, 1)
14612 ua(npx+1, 0) = va(npx, 2)
14614 IF (gridstruct%ne_corner)
THEN 14615 ua(npx, npy) = -va(npx, npy-1)
14616 ua(npx+1, npy) = -va(npx, npy-2)
14618 IF (gridstruct%nw_corner)
THEN 14619 ua(-1, npy) = va(0, npy-2)
14620 ua(0, npy) = va(0, npy-1)
14622 IF (is .EQ. 1 .AND. (.NOT.nested))
THEN 14624 uc(0, j) =
c1*utmp(-2, j) +
c2*utmp(-1, j) +
c3*utmp(0, j)
14627 IF (ut(1, j) .GT. 0.)
THEN 14628 uc(1, j) = ut(1, j)*sin_sg(0, j, 3)
14630 uc(1, j) = ut(1, j)*sin_sg(1, j, 1)
14632 uc(2, j) =
c1*utmp(3, j) +
c2*utmp(2, j) +
c3*utmp(1, j)
14633 ut(0, j) = (uc(0, j)-v(0, j)*cosa_u(0, j))*rsin_u(0, j)
14634 ut(2, j) = (uc(2, j)-v(2, j)*cosa_u(2, j))*rsin_u(2, j)
14637 IF (ie + 1 .EQ. npx .AND. (.NOT.nested))
THEN 14639 uc(npx-1, j) =
c1*utmp(npx-3, j) +
c2*utmp(npx-2, j) +
c3*utmp&
14643 IF (ut(npx, j) .GT. 0.)
THEN 14644 uc(npx, j) = ut(npx, j)*sin_sg(npx-1, j, 3)
14646 uc(npx, j) = ut(npx, j)*sin_sg(npx, j, 1)
14648 uc(npx+1, j) =
c3*utmp(npx, j) +
c2*utmp(npx+1, j) +
c1*utmp(&
14650 ut(npx-1, j) = (uc(npx-1, j)-v(npx-1, j)*cosa_u(npx-1, j))*&
14652 ut(npx+1, j) = (uc(npx+1, j)-v(npx+1, j)*cosa_u(npx+1, j))*&
14660 IF (gridstruct%sw_corner)
THEN 14662 vtmp(0, j) = -utmp(1-j, 0)
14665 IF (gridstruct%nw_corner)
THEN 14667 vtmp(0, npy+j) = utmp(j+1, npy)
14670 IF (gridstruct%se_corner)
THEN 14672 vtmp(npx, j) = utmp(ie+j, 0)
14675 IF (gridstruct%ne_corner)
THEN 14677 vtmp(npx, npy+j) = -utmp(ie-j, npy)
14680 IF (gridstruct%sw_corner)
THEN 14681 va(0, -1) = -ua(2, 0)
14682 va(0, 0) = -ua(1, 0)
14684 IF (gridstruct%se_corner)
THEN 14685 va(npx, 0) = ua(npx-1, 0)
14686 va(npx, -1) = ua(npx-2, 0)
14688 IF (gridstruct%ne_corner)
THEN 14689 va(npx, npy) = -ua(npx-1, npy)
14690 va(npx, npy+1) = -ua(npx-2, npy)
14692 IF (gridstruct%nw_corner)
THEN 14693 va(0, npy) = ua(1, npy)
14694 va(0, npy+1) = ua(2, npy)
14698 IF (j .EQ. 1 .AND. (.NOT.nested))
THEN 14701 IF (vt(i, j) .GT. 0.)
THEN 14702 vc(i, j) = vt(i, j)*sin_sg(i, j-1, 4)
14704 vc(i, j) = vt(i, j)*sin_sg(i, j, 2)
14707 ELSE IF (j .EQ. 0 .OR. (j .EQ. npy - 1 .AND. (.NOT.nested))) &
14710 vc(i, j) =
c1*vtmp(i, j-2) +
c2*vtmp(i, j-1) +
c3*vtmp(i, j)
14711 vt(i, j) = (vc(i, j)-u(i, j)*cosa_v(i, j))*rsin_v(i, j)
14713 ELSE IF (j .EQ. 2 .OR. (j .EQ. npy + 1 .AND. (.NOT.nested))) &
14716 vc(i, j) =
c1*vtmp(i, j+1) +
c2*vtmp(i, j) +
c3*vtmp(i, j-1)
14717 vt(i, j) = (vc(i, j)-u(i, j)*cosa_v(i, j))*rsin_v(i, j)
14719 ELSE IF (j .EQ. npy .AND. (.NOT.nested))
THEN 14723 IF (vt(i, j) .GT. 0.)
THEN 14724 vc(i, j) = vt(i, j)*sin_sg(i, j-1, 4)
14726 vc(i, j) = vt(i, j)*sin_sg(i, j, 2)
14732 vc(i, j) =
a2*(vtmp(i, j-2)+vtmp(i, j+1)) +
a1*(vtmp(i, j-1)&
14734 vt(i, j) = (vc(i, j)-u(i, j)*cosa_v(i, j))*rsin_v(i, j)
14742 vc(i, j) =
a2*(vtmp(i, j-2)+vtmp(i, j+1)) +
a1*(vtmp(i, j-1)+&
14744 vt(i, j) = vc(i, j)
14771 REAL,
INTENT(IN) :: ua(4)
14772 REAL,
INTENT(IN) :: dxa(4)
14775 t1 = dxa(1) + dxa(2)
14776 t2 = dxa(3) + dxa(4)
14778 & dxa(3))*ua(3)-dxa(3)*ua(4))/t2)
14803 REAL,
INTENT(IN) :: ua(4)
14805 REAL,
INTENT(IN) :: dxa(4)
14808 REAL :: edge_interpolate4_ad
14809 REAL :: edge_interpolate4
14810 t1 = dxa(1) + dxa(2)
14811 t2 = dxa(3) + dxa(4)
14812 temp_ad = 0.5*edge_interpolate4_ad
14813 ua_ad(2) = ua_ad(2) + (t1+dxa(2))*temp_ad/t1
14814 ua_ad(1) = ua_ad(1) - dxa(2)*temp_ad/t1
14815 ua_ad(3) = ua_ad(3) + (t2+dxa(3))*temp_ad/t2
14816 ua_ad(4) = ua_ad(4) - dxa(3)*temp_ad/t2
14820 REAL,
INTENT(IN) :: ua(4)
14821 REAL,
INTENT(IN) :: dxa(4)
14823 t1 = dxa(1) + dxa(2)
14824 t2 = dxa(3) + dxa(4)
14826 & dxa(3))*ua(3)-dxa(3)*ua(4))/t2)
14828 SUBROUTINE fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, &
14829 & se_corner, ne_corner, nw_corner)
14831 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
14834 INTEGER,
INTENT(IN) :: dir
14835 REAL,
INTENT(INOUT) :: q1(bd%isd:bd%ied, bd%jsd:bd%jed)
14836 REAL,
INTENT(INOUT) :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
14837 REAL,
INTENT(INOUT) :: q3(bd%isd:bd%ied, bd%jsd:bd%jed)
14838 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
14839 INTEGER,
INTENT(IN) :: npx, npy
14841 INTEGER :: is, ie, js, je
14842 INTEGER :: isd, ied, jsd, jed
14853 IF (sw_corner)
THEN 14854 q1(-1, 0) = q1(0, 2)
14855 q1(0, 0) = q1(0, 1)
14856 q1(0, -1) = q1(-1, 1)
14857 q2(-1, 0) = q2(0, 2)
14858 q2(0, 0) = q2(0, 1)
14859 q2(0, -1) = q2(-1, 1)
14860 q3(-1, 0) = q3(0, 2)
14861 q3(0, 0) = q3(0, 1)
14862 q3(0, -1) = q3(-1, 1)
14864 IF (se_corner)
THEN 14865 q1(npx+1, 0) = q1(npx, 2)
14866 q1(npx, 0) = q1(npx, 1)
14867 q1(npx, -1) = q1(npx+1, 1)
14868 q2(npx+1, 0) = q2(npx, 2)
14869 q2(npx, 0) = q2(npx, 1)
14870 q2(npx, -1) = q2(npx+1, 1)
14871 q3(npx+1, 0) = q3(npx, 2)
14872 q3(npx, 0) = q3(npx, 1)
14873 q3(npx, -1) = q3(npx+1, 1)
14875 IF (ne_corner)
THEN 14876 q1(npx, npy) = q1(npx, npy-1)
14877 q1(npx+1, npy) = q1(npx, npy-2)
14878 q1(npx, npy+1) = q1(npx+1, npy-1)
14879 q2(npx, npy) = q2(npx, npy-1)
14880 q2(npx+1, npy) = q2(npx, npy-2)
14881 q2(npx, npy+1) = q2(npx+1, npy-1)
14882 q3(npx, npy) = q3(npx, npy-1)
14883 q3(npx+1, npy) = q3(npx, npy-2)
14884 q3(npx, npy+1) = q3(npx+1, npy-1)
14886 IF (nw_corner)
THEN 14887 q1(0, npy) = q1(0, npy-1)
14888 q1(-1, npy) = q1(0, npy-2)
14889 q1(0, npy+1) = q1(-1, npy-1)
14890 q2(0, npy) = q2(0, npy-1)
14891 q2(-1, npy) = q2(0, npy-2)
14892 q2(0, npy+1) = q2(-1, npy-1)
14893 q3(0, npy) = q3(0, npy-1)
14894 q3(-1, npy) = q3(0, npy-2)
14895 q3(0, npy+1) = q3(-1, npy-1)
14898 IF (sw_corner)
THEN 14899 q1(0, 0) = q1(1, 0)
14900 q1(0, -1) = q1(2, 0)
14901 q1(-1, 0) = q1(1, -1)
14902 q2(0, 0) = q2(1, 0)
14903 q2(0, -1) = q2(2, 0)
14904 q2(-1, 0) = q2(1, -1)
14905 q3(0, 0) = q3(1, 0)
14906 q3(0, -1) = q3(2, 0)
14907 q3(-1, 0) = q3(1, -1)
14909 IF (se_corner)
THEN 14910 q1(npx, 0) = q1(npx-1, 0)
14911 q1(npx, -1) = q1(npx-2, 0)
14912 q1(npx+1, 0) = q1(npx-1, -1)
14913 q2(npx, 0) = q2(npx-1, 0)
14914 q2(npx, -1) = q2(npx-2, 0)
14915 q2(npx+1, 0) = q2(npx-1, -1)
14916 q3(npx, 0) = q3(npx-1, 0)
14917 q3(npx, -1) = q3(npx-2, 0)
14918 q3(npx+1, 0) = q3(npx-1, -1)
14920 IF (ne_corner)
THEN 14921 q1(npx, npy) = q1(npx-1, npy)
14922 q1(npx, npy+1) = q1(npx-2, npy)
14923 q1(npx+1, npy) = q1(npx-1, npy+1)
14924 q2(npx, npy) = q2(npx-1, npy)
14925 q2(npx, npy+1) = q2(npx-2, npy)
14926 q2(npx+1, npy) = q2(npx-1, npy+1)
14927 q3(npx, npy) = q3(npx-1, npy)
14928 q3(npx, npy+1) = q3(npx-2, npy)
14929 q3(npx+1, npy) = q3(npx-1, npy+1)
14931 IF (nw_corner)
THEN 14932 q1(0, npy) = q1(1, npy)
14933 q1(0, npy+1) = q1(2, npy)
14934 q1(-1, npy) = q1(1, npy+1)
14935 q2(0, npy) = q2(1, npy)
14936 q2(0, npy+1) = q2(2, npy)
14937 q2(-1, npy) = q2(1, npy+1)
14938 q3(0, npy) = q3(1, npy)
14939 q3(0, npy+1) = q3(2, npy)
14940 q3(-1, npy) = q3(1, npy+1)
14965 & se_corner, ne_corner, nw_corner)
14967 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
14970 INTEGER,
INTENT(IN) :: dir
14971 REAL,
INTENT(INOUT) :: q1(bd%isd:bd%ied, bd%jsd:bd%jed)
14972 REAL,
INTENT(INOUT) :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
14973 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
14974 INTEGER,
INTENT(IN) :: npx, npy
14975 INTEGER :: is, ie, js, je
14976 INTEGER :: isd, ied, jsd, jed
14989 IF (sw_corner)
THEN 14991 q1(-1, 0) = q1(0, 2)
14993 q1(0, 0) = q1(0, 1)
14995 q2(-1, 0) = q2(0, 2)
14997 q2(0, 0) = q2(0, 1)
15002 IF (se_corner)
THEN 15004 q1(npx+1, 0) = q1(npx, 2)
15006 q1(npx, 0) = q1(npx, 1)
15008 q2(npx+1, 0) = q2(npx, 2)
15010 q2(npx, 0) = q2(npx, 1)
15015 IF (nw_corner)
THEN 15017 q1(0, npy) = q1(0, npy-1)
15019 q1(-1, npy) = q1(0, npy-2)
15021 q2(0, npy) = q2(0, npy-1)
15023 q2(-1, npy) = q2(0, npy-2)
15028 IF (ne_corner)
THEN 15030 q1(npx, npy) = q1(npx, npy-1)
15032 q1(npx+1, npy) = q1(npx, npy-2)
15034 q2(npx, npy) = q2(npx, npy-1)
15036 q2(npx+1, npy) = q2(npx, npy-2)
15042 IF (sw_corner)
THEN 15044 q1(0, 0) = q1(1, 0)
15046 q1(0, -1) = q1(2, 0)
15048 q2(0, 0) = q2(1, 0)
15050 q2(0, -1) = q2(2, 0)
15055 IF (se_corner)
THEN 15057 q1(npx, 0) = q1(npx-1, 0)
15059 q1(npx, -1) = q1(npx-2, 0)
15061 q2(npx, 0) = q2(npx-1, 0)
15063 q2(npx, -1) = q2(npx-2, 0)
15068 IF (nw_corner)
THEN 15070 q1(0, npy) = q1(1, npy)
15072 q1(0, npy+1) = q1(2, npy)
15074 q2(0, npy) = q2(1, npy)
15076 q2(0, npy+1) = q2(2, npy)
15081 IF (ne_corner)
THEN 15083 q1(npx, npy) = q1(npx-1, npy)
15085 q1(npx, npy+1) = q1(npx-2, npy)
15087 q2(npx, npy) = q2(npx-1, npy)
15089 q2(npx, npy+1) = q2(npx-2, npy)
15119 & , sw_corner, se_corner, ne_corner, nw_corner)
15121 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
15122 INTEGER,
INTENT(IN) :: dir
15123 REAL,
INTENT(INOUT) :: q1(bd%isd:bd%ied, bd%jsd:bd%jed)
15124 REAL,
INTENT(INOUT) :: q1_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
15125 REAL,
INTENT(INOUT) :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
15126 REAL,
INTENT(INOUT) :: q2_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
15127 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
15128 INTEGER,
INTENT(IN) :: npx, npy
15129 INTEGER :: is, ie, js, je
15130 INTEGER :: isd, ied, jsd, jed
15144 IF (branch .LT. 2)
THEN 15145 IF (branch .EQ. 0)
GOTO 100
15146 ELSE IF (branch .EQ. 2)
THEN 15148 q2_ad(npx, npy-2) = q2_ad(npx, npy-2) + q2_ad(npx+1, npy)
15149 q2_ad(npx+1, npy) = 0.0
15151 q2_ad(npx, npy-1) = q2_ad(npx, npy-1) + q2_ad(npx, npy)
15152 q2_ad(npx, npy) = 0.0
15154 q1_ad(npx, npy-2) = q1_ad(npx, npy-2) + q1_ad(npx+1, npy)
15155 q1_ad(npx+1, npy) = 0.0
15157 q1_ad(npx, npy-1) = q1_ad(npx, npy-1) + q1_ad(npx, npy)
15158 q1_ad(npx, npy) = 0.0
15160 IF (branch .NE. 3)
THEN 15162 q2_ad(npx-2, npy) = q2_ad(npx-2, npy) + q2_ad(npx, npy+1)
15163 q2_ad(npx, npy+1) = 0.0
15165 q2_ad(npx-1, npy) = q2_ad(npx-1, npy) + q2_ad(npx, npy)
15166 q2_ad(npx, npy) = 0.0
15168 q1_ad(npx-2, npy) = q1_ad(npx-2, npy) + q1_ad(npx, npy+1)
15169 q1_ad(npx, npy+1) = 0.0
15171 q1_ad(npx-1, npy) = q1_ad(npx-1, npy) + q1_ad(npx, npy)
15172 q1_ad(npx, npy) = 0.0
15175 IF (branch .EQ. 0)
THEN 15177 q2_ad(2, npy) = q2_ad(2, npy) + q2_ad(0, npy+1)
15178 q2_ad(0, npy+1) = 0.0
15180 q2_ad(1, npy) = q2_ad(1, npy) + q2_ad(0, npy)
15181 q2_ad(0, npy) = 0.0
15183 q1_ad(2, npy) = q1_ad(2, npy) + q1_ad(0, npy+1)
15184 q1_ad(0, npy+1) = 0.0
15186 q1_ad(1, npy) = q1_ad(1, npy) + q1_ad(0, npy)
15187 q1_ad(0, npy) = 0.0
15190 IF (branch .EQ. 0)
THEN 15192 q2_ad(npx-2, 0) = q2_ad(npx-2, 0) + q2_ad(npx, -1)
15193 q2_ad(npx, -1) = 0.0
15195 q2_ad(npx-1, 0) = q2_ad(npx-1, 0) + q2_ad(npx, 0)
15196 q2_ad(npx, 0) = 0.0
15198 q1_ad(npx-2, 0) = q1_ad(npx-2, 0) + q1_ad(npx, -1)
15199 q1_ad(npx, -1) = 0.0
15201 q1_ad(npx-1, 0) = q1_ad(npx-1, 0) + q1_ad(npx, 0)
15202 q1_ad(npx, 0) = 0.0
15205 IF (branch .EQ. 0)
THEN 15207 q2_ad(2, 0) = q2_ad(2, 0) + q2_ad(0, -1)
15210 q2_ad(1, 0) = q2_ad(1, 0) + q2_ad(0, 0)
15213 q1_ad(2, 0) = q1_ad(2, 0) + q1_ad(0, -1)
15216 q1_ad(1, 0) = q1_ad(1, 0) + q1_ad(0, 0)
15222 IF (branch .EQ. 0)
THEN 15224 q2_ad(0, npy-2) = q2_ad(0, npy-2) + q2_ad(-1, npy)
15225 q2_ad(-1, npy) = 0.0
15227 q2_ad(0, npy-1) = q2_ad(0, npy-1) + q2_ad(0, npy)
15228 q2_ad(0, npy) = 0.0
15230 q1_ad(0, npy-2) = q1_ad(0, npy-2) + q1_ad(-1, npy)
15231 q1_ad(-1, npy) = 0.0
15233 q1_ad(0, npy-1) = q1_ad(0, npy-1) + q1_ad(0, npy)
15234 q1_ad(0, npy) = 0.0
15237 IF (branch .EQ. 0)
THEN 15239 q2_ad(npx, 1) = q2_ad(npx, 1) + q2_ad(npx, 0)
15240 q2_ad(npx, 0) = 0.0
15242 q2_ad(npx, 2) = q2_ad(npx, 2) + q2_ad(npx+1, 0)
15243 q2_ad(npx+1, 0) = 0.0
15245 q1_ad(npx, 1) = q1_ad(npx, 1) + q1_ad(npx, 0)
15246 q1_ad(npx, 0) = 0.0
15248 q1_ad(npx, 2) = q1_ad(npx, 2) + q1_ad(npx+1, 0)
15249 q1_ad(npx+1, 0) = 0.0
15252 IF (branch .EQ. 0)
THEN 15254 q2_ad(0, 1) = q2_ad(0, 1) + q2_ad(0, 0)
15257 q2_ad(0, 2) = q2_ad(0, 2) + q2_ad(-1, 0)
15260 q1_ad(0, 1) = q1_ad(0, 1) + q1_ad(0, 0)
15263 q1_ad(0, 2) = q1_ad(0, 2) + q1_ad(-1, 0)
15268 SUBROUTINE fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, &
15269 & se_corner, ne_corner, nw_corner)
15271 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
15274 INTEGER,
INTENT(IN) :: dir
15275 REAL,
INTENT(INOUT) :: q1(bd%isd:bd%ied, bd%jsd:bd%jed)
15276 REAL,
INTENT(INOUT) :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
15277 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
15278 INTEGER,
INTENT(IN) :: npx, npy
15279 INTEGER :: is, ie, js, je
15280 INTEGER :: isd, ied, jsd, jed
15291 IF (sw_corner)
THEN 15292 q1(-1, 0) = q1(0, 2)
15293 q1(0, 0) = q1(0, 1)
15294 q2(-1, 0) = q2(0, 2)
15295 q2(0, 0) = q2(0, 1)
15297 IF (se_corner)
THEN 15298 q1(npx+1, 0) = q1(npx, 2)
15299 q1(npx, 0) = q1(npx, 1)
15300 q2(npx+1, 0) = q2(npx, 2)
15301 q2(npx, 0) = q2(npx, 1)
15303 IF (nw_corner)
THEN 15304 q1(0, npy) = q1(0, npy-1)
15305 q1(-1, npy) = q1(0, npy-2)
15306 q2(0, npy) = q2(0, npy-1)
15307 q2(-1, npy) = q2(0, npy-2)
15309 IF (ne_corner)
THEN 15310 q1(npx, npy) = q1(npx, npy-1)
15311 q1(npx+1, npy) = q1(npx, npy-2)
15312 q2(npx, npy) = q2(npx, npy-1)
15313 q2(npx+1, npy) = q2(npx, npy-2)
15316 IF (sw_corner)
THEN 15317 q1(0, 0) = q1(1, 0)
15318 q1(0, -1) = q1(2, 0)
15319 q2(0, 0) = q2(1, 0)
15320 q2(0, -1) = q2(2, 0)
15322 IF (se_corner)
THEN 15323 q1(npx, 0) = q1(npx-1, 0)
15324 q1(npx, -1) = q1(npx-2, 0)
15325 q2(npx, 0) = q2(npx-1, 0)
15326 q2(npx, -1) = q2(npx-2, 0)
15328 IF (nw_corner)
THEN 15329 q1(0, npy) = q1(1, npy)
15330 q1(0, npy+1) = q1(2, npy)
15331 q2(0, npy) = q2(1, npy)
15332 q2(0, npy+1) = q2(2, npy)
15334 IF (ne_corner)
THEN 15335 q1(npx, npy) = q1(npx-1, npy)
15336 q1(npx, npy+1) = q1(npx-2, npy)
15337 q2(npx, npy) = q2(npx-1, npy)
15338 q2(npx, npy+1) = q2(npx-2, npy)
15363 & se_corner, ne_corner, nw_corner)
15368 INTEGER,
INTENT(IN) :: dir
15369 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed)
15370 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
15371 INTEGER,
INTENT(IN) :: npx, npy
15372 INTEGER :: is, ie, js, je
15373 INTEGER :: isd, ied, jsd, jed
15386 IF (sw_corner)
THEN 15395 IF (se_corner)
THEN 15397 q(npx+1, 0) = q(npx, 2)
15399 q(npx, 0) = q(npx, 1)
15404 IF (nw_corner)
THEN 15406 q(0, npy) = q(0, npy-1)
15408 q(-1, npy) = q(0, npy-2)
15413 IF (ne_corner)
THEN 15415 q(npx, npy) = q(npx, npy-1)
15417 q(npx+1, npy) = q(npx, npy-2)
15423 IF (sw_corner)
THEN 15432 IF (se_corner)
THEN 15434 q(npx, 0) = q(npx-1, 0)
15436 q(npx, -1) = q(npx-2, 0)
15441 IF (nw_corner)
THEN 15443 q(0, npy) = q(1, npy)
15445 q(0, npy+1) = q(2, npy)
15450 IF (ne_corner)
THEN 15452 q(npx, npy) = q(npx-1, npy)
15454 q(npx, npy+1) = q(npx-2, npy)
15484 & se_corner, ne_corner, nw_corner)
15487 INTEGER,
INTENT(IN) :: dir
15488 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed)
15489 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
15490 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
15491 INTEGER,
INTENT(IN) :: npx, npy
15492 INTEGER :: is, ie, js, je
15493 INTEGER :: isd, ied, jsd, jed
15507 IF (branch .LT. 2)
THEN 15508 IF (branch .EQ. 0)
GOTO 100
15509 ELSE IF (branch .EQ. 2)
THEN 15511 q_ad(npx, npy-2) = q_ad(npx, npy-2) + q_ad(npx+1, npy)
15512 q_ad(npx+1, npy) = 0.0
15514 q_ad(npx, npy-1) = q_ad(npx, npy-1) + q_ad(npx, npy)
15515 q_ad(npx, npy) = 0.0
15517 IF (branch .NE. 3)
THEN 15519 q_ad(npx-2, npy) = q_ad(npx-2, npy) + q_ad(npx, npy+1)
15520 q_ad(npx, npy+1) = 0.0
15522 q_ad(npx-1, npy) = q_ad(npx-1, npy) + q_ad(npx, npy)
15523 q_ad(npx, npy) = 0.0
15526 IF (branch .EQ. 0)
THEN 15528 q_ad(2, npy) = q_ad(2, npy) + q_ad(0, npy+1)
15529 q_ad(0, npy+1) = 0.0
15531 q_ad(1, npy) = q_ad(1, npy) + q_ad(0, npy)
15535 IF (branch .EQ. 0)
THEN 15537 q_ad(npx-2, 0) = q_ad(npx-2, 0) + q_ad(npx, -1)
15538 q_ad(npx, -1) = 0.0
15540 q_ad(npx-1, 0) = q_ad(npx-1, 0) + q_ad(npx, 0)
15544 IF (branch .EQ. 0)
THEN 15546 q_ad(2, 0) = q_ad(2, 0) + q_ad(0, -1)
15549 q_ad(1, 0) = q_ad(1, 0) + q_ad(0, 0)
15555 IF (branch .EQ. 0)
THEN 15557 q_ad(0, npy-2) = q_ad(0, npy-2) + q_ad(-1, npy)
15558 q_ad(-1, npy) = 0.0
15560 q_ad(0, npy-1) = q_ad(0, npy-1) + q_ad(0, npy)
15564 IF (branch .EQ. 0)
THEN 15566 q_ad(npx, 1) = q_ad(npx, 1) + q_ad(npx, 0)
15569 q_ad(npx, 2) = q_ad(npx, 2) + q_ad(npx+1, 0)
15570 q_ad(npx+1, 0) = 0.0
15573 IF (branch .EQ. 0)
THEN 15575 q_ad(0, 1) = q_ad(0, 1) + q_ad(0, 0)
15578 q_ad(0, 2) = q_ad(0, 2) + q_ad(-1, 0)
15583 SUBROUTINE fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, &
15584 & ne_corner, nw_corner)
15589 INTEGER,
INTENT(IN) :: dir
15590 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed)
15591 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
15592 INTEGER,
INTENT(IN) :: npx, npy
15593 INTEGER :: is, ie, js, je
15594 INTEGER :: isd, ied, jsd, jed
15605 IF (sw_corner)
THEN 15609 IF (se_corner)
THEN 15610 q(npx+1, 0) = q(npx, 2)
15611 q(npx, 0) = q(npx, 1)
15613 IF (nw_corner)
THEN 15614 q(0, npy) = q(0, npy-1)
15615 q(-1, npy) = q(0, npy-2)
15617 IF (ne_corner)
THEN 15618 q(npx, npy) = q(npx, npy-1)
15619 q(npx+1, npy) = q(npx, npy-2)
15622 IF (sw_corner)
THEN 15626 IF (se_corner)
THEN 15627 q(npx, 0) = q(npx-1, 0)
15628 q(npx, -1) = q(npx-2, 0)
15630 IF (nw_corner)
THEN 15631 q(0, npy) = q(1, npy)
15632 q(0, npy+1) = q(2, npy)
15634 IF (ne_corner)
THEN 15635 q(npx, npy) = q(npx-1, npy)
15636 q(npx, npy+1) = q(npx-2, npy)
15660 SUBROUTINE xtp_u_fwd(is, ie, js, je, isd, ied, jsd, jed, c, u, v, &
15661 & flux, iord, dx, rdx, npx, npy, grid_type, nested)
15663 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
15664 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
15665 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
15666 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
15667 REAL :: flux(is:ie+1, js:je+1)
15668 REAL,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
15669 REAL,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
15670 INTEGER,
INTENT(IN) :: iord, npx, npy, grid_type
15671 LOGICAL,
INTENT(IN) :: nested
15673 REAL,
DIMENSION(is-1:ie+1) :: bl, br, b0
15674 LOGICAL,
DIMENSION(is-1:ie+1) :: smt5, smt6
15675 REAL :: fx0(is:ie+1)
15676 REAL :: al(is-1:ie+2), dm(is-2:ie+2)
15677 REAL :: dq(is-3:ie+2)
15678 REAL :: dl, dr, xt, pmp, lac, cfl
15679 REAL :: pmp_1, lac_1, pmp_2, lac_2
15680 REAL :: x0, x1, x0l, x0r
15682 INTEGER :: is3, ie3
15683 INTEGER :: is2, ie2
15718 IF (3 .LT. is - 1)
THEN 15723 IF (npx - 3 .GT. ie + 1)
THEN 15731 IF (iord .EQ. 1)
THEN 15734 IF (c(i, j) .GT. 0.)
THEN 15736 flux(i, j) = u(i-1, j)
15740 flux(i, j) = u(i, j)
15746 ELSE IF (iord .EQ. 333)
THEN 15750 IF (c(i, j) .GT. 0.)
THEN 15751 flux(i, j) = (2.0*u(i, j)+5.0*u(i-1, j)-u(i-2, j))/6.0 - 0.5&
15752 & *c(i, j)*rdx(i-1, j)*(u(i, j)-u(i-1, j)) + c(i, j)*rdx(i-1&
15753 & , j)*c(i, j)*rdx(i-1, j)/6.0*(u(i, j)-2.0*u(i-1, j)+u(i-2&
15756 flux(i, j) = (2.0*u(i-1, j)+5.0*u(i, j)-u(i+1, j))/6.0 - 0.5&
15757 & *c(i, j)*rdx(i, j)*(u(i, j)-u(i-1, j)) + c(i, j)*rdx(i, j)&
15758 & *c(i, j)*rdx(i, j)/6.0*(u(i+1, j)-2.0*u(i, j)+u(i-1, j))
15763 ELSE IF (iord .LT. 8)
THEN 15767 al(i) =
p1*(u(i-1, j)+u(i, j)) +
p2*(u(i-2, j)+u(i+1, j))
15771 bl(i) = al(i) - u(i, j)
15773 br(i) = al(i+1) - u(i, j)
15775 IF (.NOT.nested .AND.
grid_type .LT. 3)
THEN 15776 IF (is .EQ. 1)
THEN 15777 xt =
c3*u(1, j) +
c2*u(2, j) +
c1*u(3, j)
15779 br(1) = xt - u(1, j)
15781 bl(2) = xt - u(2, j)
15783 br(2) = al(3) - u(2, j)
15784 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 15800 bl(0) =
c1*u(-2, j) +
c2*u(-1, j) +
c3*u(0, j) - u(0, j)
15801 xt = 0.5*(((2.*dx(0, j)+dx(-1, j))*u(0, j)-dx(0, j)*u(-1, &
15802 & j))/(dx(0, j)+dx(-1, j))+((2.*dx(1, j)+dx(2, j))*u(1, j)&
15803 & -dx(1, j)*u(2, j))/(dx(1, j)+dx(2, j)))
15805 br(0) = xt - u(0, j)
15807 bl(1) = xt - u(1, j)
15814 IF (ie + 1 .EQ. npx)
THEN 15816 bl(npx-2) = al(npx-2) - u(npx-2, j)
15817 xt =
c1*u(npx-3, j) +
c2*u(npx-2, j) +
c3*u(npx-1, j)
15819 br(npx-2) = xt - u(npx-2, j)
15821 bl(npx-1) = xt - u(npx-1, j)
15822 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 15837 xt = 0.5*(((2.*dx(npx-1, j)+dx(npx-2, j))*u(npx-1, j)-dx(&
15838 & npx-1, j)*u(npx-2, j))/(dx(npx-1, j)+dx(npx-2, j))+((2.*&
15839 & dx(npx, j)+dx(npx+1, j))*u(npx, j)-dx(npx, j)*u(npx+1, j&
15840 & ))/(dx(npx, j)+dx(npx+1, j)))
15842 br(npx-1) = xt - u(npx-1, j)
15844 bl(npx) = xt - u(npx, j)
15846 br(npx) =
c3*u(npx, j) +
c2*u(npx+1, j) +
c1*u(npx+2, j) -&
15859 b0(i) = bl(i) + br(i)
15861 IF (iord .EQ. 2)
THEN 15865 IF (c(i, j) .GT. 0.)
THEN 15866 cfl = c(i, j)*rdx(i-1, j)
15868 flux(i, j) = u(i-1, j) + (1.-cfl)*(br(i-1)-cfl*b0(i-1))
15871 cfl = c(i, j)*rdx(i, j)
15873 flux(i, j) = u(i, j) + (1.+cfl)*(bl(i)+cfl*b0(i))
15912 SUBROUTINE xtp_u_bwd(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u&
15913 & , u_ad, v, flux, flux_ad, iord, dx, rdx, npx, npy, grid_type, nested&
15916 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
15917 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
15918 REAL :: u_ad(isd:ied, jsd:jed+1)
15919 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
15920 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
15921 REAL :: c_ad(is:ie+1, js:je+1)
15922 REAL :: flux(is:ie+1, js:je+1)
15923 REAL :: flux_ad(is:ie+1, js:je+1)
15924 REAL,
INTENT(IN) :: dx(isd:ied, jsd:jed+1)
15925 REAL,
INTENT(IN) :: rdx(isd:ied, jsd:jed+1)
15926 INTEGER,
INTENT(IN) :: iord, npx, npy, grid_type
15927 LOGICAL,
INTENT(IN) :: nested
15928 REAL,
DIMENSION(is-1:ie+1) :: bl, br, b0
15929 REAL,
DIMENSION(is-1:ie+1) :: bl_ad, br_ad, b0_ad
15930 LOGICAL,
DIMENSION(is-1:ie+1) :: smt5, smt6
15931 REAL :: fx0(is:ie+1)
15932 REAL :: al(is-1:ie+2), dm(is-2:ie+2)
15933 REAL :: al_ad(is-1:ie+2)
15934 REAL :: dq(is-3:ie+2)
15935 REAL :: dl, dr, xt, pmp, lac, cfl
15936 REAL :: xt_ad, cfl_ad
15937 REAL :: pmp_1, lac_1, pmp_2, lac_2
15938 REAL :: x0, x1, x0l, x0r
15940 INTEGER :: is3, ie3
15941 INTEGER :: is2, ie2
15990 IF (branch .LT. 2)
THEN 15991 IF (branch .EQ. 0)
THEN 15995 IF (branch .EQ. 0)
THEN 15997 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
15998 flux_ad(i, j) = 0.0
16001 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
16002 flux_ad(i, j) = 0.0
16010 IF (c(i, j) .GT. 0.)
THEN 16018 IF (branch .EQ. 0)
THEN 16019 temp_ad10 = flux_ad(i, j)/6.0
16020 temp_ad11 = -(rdx(i, j)*0.5*flux_ad(i, j))
16021 temp_ad12 = c(i, j)*temp_ad11
16022 temp_ad13 = rdx(i, j)**2*flux_ad(i, j)
16023 temp_ad14 = c(i, j)**2*temp_ad13/6.0
16024 u_ad(i-1, j) = u_ad(i-1, j) + temp_ad14 - temp_ad12 + 2.0*&
16026 u_ad(i, j) = u_ad(i, j) + temp_ad12 - 2.0*temp_ad14 + 5.0*&
16028 u_ad(i+1, j) = u_ad(i+1, j) + temp_ad14 - temp_ad10
16029 c_ad(i, j) = c_ad(i, j) + (u(i+1, j)-2.0*u(i, j)+u(i-1, j)&
16030 & )*2*c(i, j)*temp_ad13/6.0 + (u(i, j)-u(i-1, j))*&
16032 flux_ad(i, j) = 0.0
16034 temp_ad5 = flux_ad(i, j)/6.0
16035 temp_ad6 = -(rdx(i-1, j)*0.5*flux_ad(i, j))
16036 temp_ad7 = c(i, j)*temp_ad6
16037 temp_ad8 = rdx(i-1, j)**2*flux_ad(i, j)
16038 temp_ad9 = c(i, j)**2*temp_ad8/6.0
16039 u_ad(i, j) = u_ad(i, j) + temp_ad9 + temp_ad7 + 2.0*&
16041 u_ad(i-1, j) = u_ad(i-1, j) + 5.0*temp_ad5 - temp_ad7 - &
16043 u_ad(i-2, j) = u_ad(i-2, j) + temp_ad9 - temp_ad5
16044 c_ad(i, j) = c_ad(i, j) + (u(i, j)-2.0*u(i-1, j)+u(i-2, j)&
16045 & )*2*c(i, j)*temp_ad8/6.0 + (u(i, j)-u(i-1, j))*temp_ad6
16046 flux_ad(i, j) = 0.0
16051 ELSE IF (branch .NE. 2)
THEN 16063 IF (branch .NE. 0)
THEN 16066 IF (branch .EQ. 0)
THEN 16067 cfl = c(i, j)*rdx(i, j)
16069 temp_ad4 = (cfl+1.)*flux_ad(i, j)
16070 u_ad(i, j) = u_ad(i, j) + flux_ad(i, j)
16071 cfl_ad = b0(i)*temp_ad4 + (bl(i)+cfl*b0(i))*flux_ad(i, j)
16072 bl_ad(i) = bl_ad(i) + temp_ad4
16073 b0_ad(i) = b0_ad(i) + cfl*temp_ad4
16074 flux_ad(i, j) = 0.0
16075 c_ad(i, j) = c_ad(i, j) + rdx(i, j)*cfl_ad
16077 cfl = c(i, j)*rdx(i-1, j)
16079 temp_ad3 = (1.-cfl)*flux_ad(i, j)
16080 u_ad(i-1, j) = u_ad(i-1, j) + flux_ad(i, j)
16081 cfl_ad = -(b0(i-1)*temp_ad3) - (br(i-1)-cfl*b0(i-1))*&
16083 br_ad(i-1) = br_ad(i-1) + temp_ad3
16084 b0_ad(i-1) = b0_ad(i-1) - cfl*temp_ad3
16085 flux_ad(i, j) = 0.0
16086 c_ad(i, j) = c_ad(i, j) + rdx(i-1, j)*cfl_ad
16092 bl_ad(i) = bl_ad(i) + b0_ad(i)
16093 br_ad(i) = br_ad(i) + b0_ad(i)
16097 IF (branch .LT. 2)
THEN 16098 IF (branch .EQ. 0)
GOTO 100
16100 IF (branch .EQ. 2)
THEN 16102 u_ad(npx, j) = u_ad(npx, j) + (
c3-1.0)*br_ad(npx)
16103 u_ad(npx+1, j) = u_ad(npx+1, j) +
c2*br_ad(npx)
16104 u_ad(npx+2, j) = u_ad(npx+2, j) +
c1*br_ad(npx)
16107 xt_ad = br_ad(npx-1) + bl_ad(npx)
16108 u_ad(npx, j) = u_ad(npx, j) - bl_ad(npx)
16111 temp_ad1 = 0.5*xt_ad/(dx(npx-1, j)+dx(npx-2, j))
16112 u_ad(npx-1, j) = u_ad(npx-1, j) + (dx(npx-1, j)*2.+dx(npx-2&
16113 & , j))*temp_ad1 - br_ad(npx-1)
16115 temp_ad2 = 0.5*xt_ad/(dx(npx, j)+dx(npx+1, j))
16116 u_ad(npx-2, j) = u_ad(npx-2, j) - dx(npx-1, j)*temp_ad1
16117 u_ad(npx, j) = u_ad(npx, j) + (dx(npx, j)*2.+dx(npx+1, j))*&
16119 u_ad(npx+1, j) = u_ad(npx+1, j) - dx(npx, j)*temp_ad2
16131 xt_ad = br_ad(npx-2) + bl_ad(npx-1)
16132 u_ad(npx-1, j) = u_ad(npx-1, j) - bl_ad(npx-1)
16135 u_ad(npx-2, j) = u_ad(npx-2, j) - br_ad(npx-2)
16137 u_ad(npx-3, j) = u_ad(npx-3, j) +
c1*xt_ad
16138 u_ad(npx-2, j) = u_ad(npx-2, j) +
c2*xt_ad
16139 u_ad(npx-1, j) = u_ad(npx-1, j) +
c3*xt_ad
16141 al_ad(npx-2) = al_ad(npx-2) + bl_ad(npx-2)
16142 u_ad(npx-2, j) = u_ad(npx-2, j) - bl_ad(npx-2)
16146 IF (branch .EQ. 0)
THEN 16155 ELSE IF (branch .EQ. 1)
THEN 16157 xt_ad = br_ad(0) + bl_ad(1)
16158 u_ad(1, j) = u_ad(1, j) - bl_ad(1)
16161 temp_ad = 0.5*xt_ad/(dx(0, j)+dx(-1, j))
16162 u_ad(0, j) = u_ad(0, j) + (dx(0, j)*2.+dx(-1, j))*temp_ad - &
16165 temp_ad0 = 0.5*xt_ad/(dx(1, j)+dx(2, j))
16166 u_ad(-1, j) = u_ad(-1, j) - dx(0, j)*temp_ad
16167 u_ad(1, j) = u_ad(1, j) + (dx(1, j)*2.+dx(2, j))*temp_ad0
16168 u_ad(2, j) = u_ad(2, j) - dx(1, j)*temp_ad0
16170 u_ad(-2, j) = u_ad(-2, j) +
c1*bl_ad(0)
16171 u_ad(-1, j) = u_ad(-1, j) +
c2*bl_ad(0)
16172 u_ad(0, j) = u_ad(0, j) + (
c3-1.0)*bl_ad(0)
16178 al_ad(3) = al_ad(3) + br_ad(2)
16179 u_ad(2, j) = u_ad(2, j) - bl_ad(2) - br_ad(2)
16182 xt_ad = br_ad(1) + bl_ad(2)
16185 u_ad(1, j) = u_ad(1, j) +
c3*xt_ad - br_ad(1)
16187 u_ad(2, j) = u_ad(2, j) +
c2*xt_ad
16188 u_ad(3, j) = u_ad(3, j) +
c1*xt_ad
16189 100
DO i=ie3,is3,-1
16191 al_ad(i+1) = al_ad(i+1) + br_ad(i)
16192 u_ad(i, j) = u_ad(i, j) - bl_ad(i) - br_ad(i)
16195 al_ad(i) = al_ad(i) + bl_ad(i)
16199 u_ad(i-1, j) = u_ad(i-1, j) +
p1*al_ad(i)
16200 u_ad(i, j) = u_ad(i, j) +
p1*al_ad(i)
16201 u_ad(i-2, j) = u_ad(i-2, j) +
p2*al_ad(i)
16202 u_ad(i+1, j) = u_ad(i+1, j) +
p2*al_ad(i)
16229 SUBROUTINE ytp_v_fwd(is, ie, js, je, isd, ied, jsd, jed, c, u, v, &
16230 & flux, jord, dy, rdy, npx, npy, grid_type, nested)
16232 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
16233 INTEGER,
INTENT(IN) :: jord
16234 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
16235 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
16237 REAL,
INTENT(IN) :: c(is:ie+1, js:je+1)
16238 REAL :: flux(is:ie+1, js:je+1)
16239 REAL,
INTENT(IN) :: dy(isd:ied+1, jsd:jed)
16240 REAL,
INTENT(IN) :: rdy(isd:ied+1, jsd:jed)
16241 INTEGER,
INTENT(IN) :: npx, npy, grid_type
16242 LOGICAL,
INTENT(IN) :: nested
16244 LOGICAL,
DIMENSION(is:ie+1, js-1:je+1) :: smt5, smt6
16245 REAL :: fx0(is:ie+1)
16246 REAL :: dm(is:ie+1, js-2:je+2)
16247 REAL :: al(is:ie+1, js-1:je+2)
16248 REAL,
DIMENSION(is:ie+1, js-1:je+1) :: bl, br, b0
16249 REAL :: dq(is:ie+1, js-3:je+2)
16250 REAL :: xt, dl, dr, pmp, lac, cfl
16251 REAL :: pmp_1, lac_1, pmp_2, lac_2
16252 REAL :: x0, x1, x0r, x0l
16253 INTEGER :: i, j, is1, ie1, js3, je3
16288 IF (3 .LT. js - 1)
THEN 16293 IF (npy - 3 .GT. je + 1)
THEN 16301 IF (jord .EQ. 1)
THEN 16304 IF (c(i, j) .GT. 0.)
THEN 16305 flux(i, j) = v(i, j-1)
16308 flux(i, j) = v(i, j)
16314 ELSE IF (jord .EQ. 333)
THEN 16318 IF (c(i, j) .GT. 0.)
THEN 16319 flux(i, j) = (2.0*v(i, j)+5.0*v(i, j-1)-v(i, j-2))/6.0 - 0.5&
16320 & *c(i, j)*rdy(i, j-1)*(v(i, j)-v(i, j-1)) + c(i, j)*rdy(i, &
16321 & j-1)*c(i, j)*rdy(i, j-1)/6.0*(v(i, j)-2.0*v(i, j-1)+v(i, j&
16324 flux(i, j) = (2.0*v(i, j-1)+5.0*v(i, j)-v(i, j+1))/6.0 - 0.5&
16325 & *c(i, j)*rdy(i, j)*(v(i, j)-v(i, j-1)) + c(i, j)*rdy(i, j)&
16326 & *c(i, j)*rdy(i, j)/6.0*(v(i, j+1)-2.0*v(i, j)+v(i, j-1))
16331 ELSE IF (jord .LT. 8)
THEN 16335 al(i, j) =
p1*(v(i, j-1)+v(i, j)) +
p2*(v(i, j-2)+v(i, j+1))
16340 bl(i, j) = al(i, j) - v(i, j)
16341 br(i, j) = al(i, j+1) - v(i, j)
16344 IF (.NOT.nested .AND.
grid_type .LT. 3)
THEN 16345 IF (js .EQ. 1)
THEN 16347 bl(i, 0) =
c1*v(i, -2) +
c2*v(i, -1) +
c3*v(i, 0) - v(i, 0)
16348 xt = 0.5*(((2.*dy(i, 0)+dy(i, -1))*v(i, 0)-dy(i, 0)*v(i, -1)&
16349 & )/(dy(i, 0)+dy(i, -1))+((2.*dy(i, 1)+dy(i, 2))*v(i, 1)-dy(&
16350 & i, 1)*v(i, 2))/(dy(i, 1)+dy(i, 2)))
16351 br(i, 0) = xt - v(i, 0)
16352 bl(i, 1) = xt - v(i, 1)
16353 xt =
c3*v(i, 1) +
c2*v(i, 2) +
c1*v(i, 3)
16354 br(i, 1) = xt - v(i, 1)
16355 bl(i, 2) = xt - v(i, 2)
16356 br(i, 2) = al(i, 3) - v(i, 2)
16358 IF (is .EQ. 1)
THEN 16371 IF (ie + 1 .EQ. npx)
THEN 16389 IF (je + 1 .EQ. npy)
THEN 16391 bl(i, npy-2) = al(i, npy-2) - v(i, npy-2)
16392 xt =
c1*v(i, npy-3) +
c2*v(i, npy-2) +
c3*v(i, npy-1)
16393 br(i, npy-2) = xt - v(i, npy-2)
16394 bl(i, npy-1) = xt - v(i, npy-1)
16395 xt = 0.5*(((2.*dy(i, npy-1)+dy(i, npy-2))*v(i, npy-1)-dy(i, &
16396 & npy-1)*v(i, npy-2))/(dy(i, npy-1)+dy(i, npy-2))+((2.*dy(i&
16397 & , npy)+dy(i, npy+1))*v(i, npy)-dy(i, npy)*v(i, npy+1))/(dy&
16398 & (i, npy)+dy(i, npy+1)))
16399 br(i, npy-1) = xt - v(i, npy-1)
16400 bl(i, npy) = xt - v(i, npy)
16401 br(i, npy) =
c3*v(i, npy) +
c2*v(i, npy+1) +
c1*v(i, npy+2) &
16404 IF (is .EQ. 1)
THEN 16417 IF (ie + 1 .EQ. npx)
THEN 16419 bl(npx, npy-1) = 0.
16421 br(npx, npy-1) = 0.
16440 b0(i, j) = bl(i, j) + br(i, j)
16443 IF (jord .EQ. 2)
THEN 16448 IF (c(i, j) .GT. 0.)
THEN 16450 cfl = c(i, j)*rdy(i, j-1)
16451 flux(i, j) = v(i, j-1) + (1.-cfl)*(br(i, j-1)-cfl*b0(i, j-&
16456 cfl = c(i, j)*rdy(i, j)
16457 flux(i, j) = v(i, j) + (1.+cfl)*(bl(i, j)+cfl*b0(i, j))
16498 SUBROUTINE ytp_v_bwd(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u&
16499 & , v, v_ad, flux, flux_ad, jord, dy, rdy, npx, npy, grid_type, nested&
16502 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed
16503 INTEGER,
INTENT(IN) :: jord
16504 REAL,
INTENT(IN) :: u(isd:ied, jsd:jed+1)
16505 REAL,
INTENT(IN) :: v(isd:ied+1, jsd:jed)
16506 REAL :: v_ad(isd:ied+1, jsd:jed)
16507 REAL,
INTENT(INOUT) :: c(is:ie+1, js:je+1)
16508 REAL :: c_ad(is:ie+1, js:je+1)
16509 REAL :: flux(is:ie+1, js:je+1)
16510 REAL :: flux_ad(is:ie+1, js:je+1)
16511 REAL,
INTENT(IN) :: dy(isd:ied+1, jsd:jed)
16512 REAL,
INTENT(IN) :: rdy(isd:ied+1, jsd:jed)
16513 INTEGER,
INTENT(IN) :: npx, npy, grid_type
16514 LOGICAL,
INTENT(IN) :: nested
16515 LOGICAL,
DIMENSION(is:ie+1, js-1:je+1) :: smt5, smt6
16516 REAL :: fx0(is:ie+1)
16517 REAL :: dm(is:ie+1, js-2:je+2)
16518 REAL :: al(is:ie+1, js-1:je+2)
16519 REAL :: al_ad(is:ie+1, js-1:je+2)
16520 REAL,
DIMENSION(is:ie+1, js-1:je+1) :: bl, br, b0
16521 REAL,
DIMENSION(is:ie+1, js-1:je+1) :: bl_ad, br_ad, b0_ad
16522 REAL :: dq(is:ie+1, js-3:je+2)
16523 REAL :: xt, dl, dr, pmp, lac, cfl
16524 REAL :: xt_ad, cfl_ad
16525 REAL :: pmp_1, lac_1, pmp_2, lac_2
16526 REAL :: x0, x1, x0r, x0l
16527 INTEGER :: i, j, is1, ie1, js3, je3
16576 IF (branch .LT. 2)
THEN 16577 IF (branch .EQ. 0)
THEN 16581 IF (branch .EQ. 0)
THEN 16582 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
16583 flux_ad(i, j) = 0.0
16585 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
16586 flux_ad(i, j) = 0.0
16594 IF (c(i, j) .GT. 0.)
THEN 16602 IF (branch .EQ. 0)
THEN 16603 temp_ad10 = flux_ad(i, j)/6.0
16604 temp_ad11 = -(rdy(i, j)*0.5*flux_ad(i, j))
16605 temp_ad12 = c(i, j)*temp_ad11
16606 temp_ad13 = rdy(i, j)**2*flux_ad(i, j)
16607 temp_ad14 = c(i, j)**2*temp_ad13/6.0
16608 v_ad(i, j-1) = v_ad(i, j-1) + temp_ad14 - temp_ad12 + 2.0*&
16610 v_ad(i, j) = v_ad(i, j) + temp_ad12 - 2.0*temp_ad14 + 5.0*&
16612 v_ad(i, j+1) = v_ad(i, j+1) + temp_ad14 - temp_ad10
16613 c_ad(i, j) = c_ad(i, j) + (v(i, j+1)-2.0*v(i, j)+v(i, j-1)&
16614 & )*2*c(i, j)*temp_ad13/6.0 + (v(i, j)-v(i, j-1))*&
16616 flux_ad(i, j) = 0.0
16618 temp_ad5 = flux_ad(i, j)/6.0
16619 temp_ad6 = -(rdy(i, j-1)*0.5*flux_ad(i, j))
16620 temp_ad7 = c(i, j)*temp_ad6
16621 temp_ad8 = rdy(i, j-1)**2*flux_ad(i, j)
16622 temp_ad9 = c(i, j)**2*temp_ad8/6.0
16623 v_ad(i, j) = v_ad(i, j) + temp_ad9 + temp_ad7 + 2.0*&
16625 v_ad(i, j-1) = v_ad(i, j-1) + 5.0*temp_ad5 - temp_ad7 - &
16627 v_ad(i, j-2) = v_ad(i, j-2) + temp_ad9 - temp_ad5
16628 c_ad(i, j) = c_ad(i, j) + (v(i, j)-2.0*v(i, j-1)+v(i, j-2)&
16629 & )*2*c(i, j)*temp_ad8/6.0 + (v(i, j)-v(i, j-1))*temp_ad6
16630 flux_ad(i, j) = 0.0
16635 ELSE IF (branch .NE. 2)
THEN 16636 IF (branch .EQ. 3)
THEN 16655 IF (branch .EQ. 0)
THEN 16656 temp_ad4 = (cfl+1.)*flux_ad(i, j)
16657 v_ad(i, j) = v_ad(i, j) + flux_ad(i, j)
16658 cfl_ad = b0(i, j)*temp_ad4 + (bl(i, j)+cfl*b0(i, j))*&
16660 bl_ad(i, j) = bl_ad(i, j) + temp_ad4
16661 b0_ad(i, j) = b0_ad(i, j) + cfl*temp_ad4
16662 flux_ad(i, j) = 0.0
16664 c_ad(i, j) = c_ad(i, j) + rdy(i, j)*cfl_ad
16666 temp_ad3 = (1.-cfl)*flux_ad(i, j)
16667 v_ad(i, j-1) = v_ad(i, j-1) + flux_ad(i, j)
16668 cfl_ad = -(b0(i, j-1)*temp_ad3) - (br(i, j-1)-cfl*b0(i, j-&
16669 & 1))*flux_ad(i, j)
16670 br_ad(i, j-1) = br_ad(i, j-1) + temp_ad3
16671 b0_ad(i, j-1) = b0_ad(i, j-1) - cfl*temp_ad3
16672 flux_ad(i, j) = 0.0
16674 c_ad(i, j) = c_ad(i, j) + rdy(i, j-1)*cfl_ad
16681 bl_ad(i, j) = bl_ad(i, j) + b0_ad(i, j)
16682 br_ad(i, j) = br_ad(i, j) + b0_ad(i, j)
16687 IF (branch .LT. 2)
THEN 16688 IF (branch .EQ. 0)
THEN 16695 IF (branch .NE. 2)
THEN 16696 br_ad(npx, npy) = 0.0
16697 bl_ad(npx, npy) = 0.0
16698 br_ad(npx, npy-1) = 0.0
16699 bl_ad(npx, npy-1) = 0.0
16702 IF (branch .EQ. 0)
THEN 16703 br_ad(1, npy) = 0.0
16704 bl_ad(1, npy) = 0.0
16705 br_ad(1, npy-1) = 0.0
16706 bl_ad(1, npy-1) = 0.0
16710 v_ad(i, npy) = v_ad(i, npy) + (
c3-1.0)*br_ad(i, npy)
16711 v_ad(i, npy+1) = v_ad(i, npy+1) +
c2*br_ad(i, npy)
16712 v_ad(i, npy+2) = v_ad(i, npy+2) +
c1*br_ad(i, npy)
16713 br_ad(i, npy) = 0.0
16714 xt_ad = br_ad(i, npy-1) + bl_ad(i, npy)
16715 v_ad(i, npy) = v_ad(i, npy) - bl_ad(i, npy)
16716 bl_ad(i, npy) = 0.0
16717 temp_ad1 = 0.5*xt_ad/(dy(i, npy-1)+dy(i, npy-2))
16718 v_ad(i, npy-1) = v_ad(i, npy-1) + (dy(i, npy-1)*2.+dy(i, npy-2&
16719 & ))*temp_ad1 - br_ad(i, npy-1)
16720 br_ad(i, npy-1) = 0.0
16721 temp_ad2 = 0.5*xt_ad/(dy(i, npy)+dy(i, npy+1))
16722 v_ad(i, npy-2) = v_ad(i, npy-2) - dy(i, npy-1)*temp_ad1
16723 v_ad(i, npy) = v_ad(i, npy) + (dy(i, npy)*2.+dy(i, npy+1))*&
16725 v_ad(i, npy+1) = v_ad(i, npy+1) - dy(i, npy)*temp_ad2
16726 xt_ad = br_ad(i, npy-2) + bl_ad(i, npy-1)
16727 v_ad(i, npy-1) = v_ad(i, npy-1) - bl_ad(i, npy-1)
16728 bl_ad(i, npy-1) = 0.0
16729 v_ad(i, npy-2) = v_ad(i, npy-2) - br_ad(i, npy-2)
16730 br_ad(i, npy-2) = 0.0
16731 v_ad(i, npy-3) = v_ad(i, npy-3) +
c1*xt_ad
16732 v_ad(i, npy-2) = v_ad(i, npy-2) +
c2*xt_ad
16733 v_ad(i, npy-1) = v_ad(i, npy-1) +
c3*xt_ad
16734 al_ad(i, npy-2) = al_ad(i, npy-2) + bl_ad(i, npy-2)
16735 v_ad(i, npy-2) = v_ad(i, npy-2) - bl_ad(i, npy-2)
16736 bl_ad(i, npy-2) = 0.0
16740 IF (branch .EQ. 0)
THEN 16741 br_ad(npx, 1) = 0.0
16742 bl_ad(npx, 1) = 0.0
16743 br_ad(npx, 0) = 0.0
16744 bl_ad(npx, 0) = 0.0
16745 ELSE IF (branch .NE. 1)
THEN 16749 IF (branch .EQ. 0)
THEN 16756 al_ad(i, 3) = al_ad(i, 3) + br_ad(i, 2)
16757 v_ad(i, 2) = v_ad(i, 2) - bl_ad(i, 2) - br_ad(i, 2)
16759 xt_ad = br_ad(i, 1) + bl_ad(i, 2)
16761 v_ad(i, 1) = v_ad(i, 1) +
c3*xt_ad - br_ad(i, 1)
16763 v_ad(i, 2) = v_ad(i, 2) +
c2*xt_ad
16764 v_ad(i, 3) = v_ad(i, 3) +
c1*xt_ad
16765 xt_ad = br_ad(i, 0) + bl_ad(i, 1)
16766 v_ad(i, 1) = v_ad(i, 1) - bl_ad(i, 1)
16768 temp_ad = 0.5*xt_ad/(dy(i, 0)+dy(i, -1))
16769 v_ad(i, 0) = v_ad(i, 0) + (dy(i, 0)*2.+dy(i, -1))*temp_ad - &
16772 temp_ad0 = 0.5*xt_ad/(dy(i, 1)+dy(i, 2))
16773 v_ad(i, -1) = v_ad(i, -1) - dy(i, 0)*temp_ad
16774 v_ad(i, 1) = v_ad(i, 1) + (dy(i, 1)*2.+dy(i, 2))*temp_ad0
16775 v_ad(i, 2) = v_ad(i, 2) - dy(i, 1)*temp_ad0
16776 v_ad(i, -2) = v_ad(i, -2) +
c1*bl_ad(i, 0)
16777 v_ad(i, -1) = v_ad(i, -1) +
c2*bl_ad(i, 0)
16778 v_ad(i, 0) = v_ad(i, 0) + (
c3-1.0)*bl_ad(i, 0)
16781 100
DO j=je3,js3,-1
16783 al_ad(i, j+1) = al_ad(i, j+1) + br_ad(i, j)
16784 v_ad(i, j) = v_ad(i, j) - bl_ad(i, j) - br_ad(i, j)
16786 al_ad(i, j) = al_ad(i, j) + bl_ad(i, j)
16792 v_ad(i, j-1) = v_ad(i, j-1) +
p1*al_ad(i, j)
16793 v_ad(i, j) = v_ad(i, j) +
p1*al_ad(i, j)
16794 v_ad(i, j-2) = v_ad(i, j-2) +
p2*al_ad(i, j)
16795 v_ad(i, j+1) = v_ad(i, j+1) +
p2*al_ad(i, j)
16825 & dt, vort, vort_ad, ptc, ptc_ad, delpc, delpc_ad, ke, ke_ad, u, u_ad&
16826 & , v, v_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, divg_d, &
16827 & divg_d_ad, wk, wk_ad, gridstruct, flagstruct, bd)
16830 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
16831 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
16832 TYPE(FV_FLAGS_TYPE),
INTENT(IN),
TARGET :: flagstruct
16833 INTEGER,
INTENT(IN) :: nord
16834 REAL,
INTENT(IN) :: d2_bg, d4_bg, dddmp, dt
16835 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
16836 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua_ad, va_ad
16837 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
16838 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u_ad
16839 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
16840 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: v_ad
16842 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: wk
16843 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
16845 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: vort
16846 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
16848 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
16850 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
16852 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
16854 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
16856 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: vc
16857 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
16859 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: uc
16860 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: &
16862 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
16864 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
16867 REAL :: damp, dd8, damp2, da_min, da_min_c, absdt
16868 REAL :: damp_ad, damp2_ad
16869 INTEGER :: is, ie, js, je, npx, npy, is2, ie1
16870 LOGICAL :: nested, fill_c
16871 INTEGER :: i, j, n, n2, nt
16872 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
16873 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
16874 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
16875 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
16876 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
16877 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
16878 REAL,
DIMENSION(:, :),
POINTER :: f0, rsin2, divg_u, divg_v
16879 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
16910 INTEGER :: ad_from0
16912 INTEGER :: ad_from1
16914 INTEGER :: ad_from2
16916 INTEGER :: ad_from3
16918 INTEGER :: ad_from4
16920 INTEGER :: ad_from5
16922 INTEGER :: ad_from6
16927 sin_sg => gridstruct%sin_sg
16928 cosa_u => gridstruct%cosa_u
16929 cosa_v => gridstruct%cosa_v
16930 sina_u => gridstruct%sina_u
16931 sina_v => gridstruct%sina_v
16932 divg_u => gridstruct%divg_u
16933 divg_v => gridstruct%divg_v
16934 dxc => gridstruct%dxc
16935 dyc => gridstruct%dyc
16936 sw_corner = gridstruct%sw_corner
16937 se_corner = gridstruct%se_corner
16938 nw_corner = gridstruct%nw_corner
16939 ne_corner = gridstruct%ne_corner
16944 npx = flagstruct%npx
16945 npy = flagstruct%npy
16946 nested = gridstruct%nested
16952 IF (2 .LT. is)
THEN 16957 IF (npx - 1 .GT. ie + 1)
THEN 16969 IF (nord .EQ. 0)
THEN 16975 ptc(i, j) = (u(i, j)-0.5*(va(i, j-1)+va(i, j))*cosa_v(i, j))&
16976 & *dyc(i, j)*sina_v(i, j)
16981 vort(i, j) = (v(i, j)-0.5*(ua(i-1, j)+ua(i, j))*cosa_u(i, j)&
16982 & )*dxc(i, j)*sina_u(i, j)
16988 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 16990 IF (vc(i, j) .GT. 0)
THEN 16992 ptc(i, j) = u(i, j)*dyc(i, j)*sin_sg(i, j-1, 4)
16996 ptc(i, j) = u(i, j)*dyc(i, j)*sin_sg(i, j, 2)
17004 ptc(i, j) = (u(i, j)-0.5*(va(i, j-1)+va(i, j))*cosa_v(i, j&
17005 & ))*dyc(i, j)*sina_v(i, j)
17012 vort(i, j) = (v(i, j)-0.5*(ua(i-1, j)+ua(i, j))*cosa_u(i, j)&
17013 & )*dxc(i, j)*sina_u(i, j)
17015 IF (is .EQ. 1)
THEN 17016 IF (uc(1, j) .GT. 0)
THEN 17017 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(0, j, 3)
17020 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(1, j, 1)
17026 IF (ie + 1 .EQ. npx)
THEN 17027 IF (uc(npx, j) .GT. 0)
THEN 17028 vort(npx, j) = v(npx, j)*dxc(npx, j)*sin_sg(npx-1, j, 3)
17031 vort(npx, j) = v(npx, j)*dxc(npx, j)*sin_sg(npx, j, 1)
17043 delpc(i, j) = vort(i, j-1) - vort(i, j) + ptc(i-1, j) - ptc(i&
17048 IF (sw_corner)
THEN 17050 delpc(1, 1) = delpc(1, 1) - vort(1, 0)
17055 IF (se_corner)
THEN 17057 delpc(npx, 1) = delpc(npx, 1) - vort(npx, 0)
17062 IF (ne_corner)
THEN 17064 delpc(npx, npy) = delpc(npx, npy) + vort(npx, npy)
17069 IF (nw_corner)
THEN 17071 delpc(1, npy) = delpc(1, npy) + vort(1, npy)
17079 delpc(i, j) = gridstruct%rarea_c(i, j)*delpc(i, j)
17080 IF (delpc(i, j)*dt .GE. 0.)
THEN 17081 abs2 = delpc(i, j)*dt
17084 abs2 = -(delpc(i, j)*dt)
17088 IF (0.20 .GT. y3)
THEN 17095 IF (d2_bg .LT. y1)
THEN 17103 damp = gridstruct%da_min_c*max1
17108 vort_ad(i, j) = vort_ad(i, j) + ke_ad(i, j)
17109 damp_ad = delpc(i, j)*vort_ad(i, j)
17110 delpc_ad(i, j) = delpc_ad(i, j) + damp*vort_ad(i, j)
17111 vort_ad(i, j) = 0.0
17113 max1_ad = gridstruct%da_min_c*damp_ad
17115 IF (branch .EQ. 0)
THEN 17121 IF (branch .EQ. 0)
THEN 17126 abs2_ad = dddmp*y3_ad
17128 IF (branch .EQ. 0)
THEN 17129 delpc_ad(i, j) = delpc_ad(i, j) + dt*abs2_ad
17131 delpc_ad(i, j) = delpc_ad(i, j) - dt*abs2_ad
17134 delpc_ad(i, j) = gridstruct%rarea_c(i, j)*delpc_ad(i, j)
17138 IF (branch .NE. 0)
THEN 17140 vort_ad(1, npy) = vort_ad(1, npy) + delpc_ad(1, npy)
17143 IF (branch .EQ. 0)
THEN 17145 vort_ad(npx, npy) = vort_ad(npx, npy) + delpc_ad(npx, npy)
17148 IF (branch .EQ. 0)
THEN 17150 vort_ad(npx, 0) = vort_ad(npx, 0) - delpc_ad(npx, 1)
17153 IF (branch .EQ. 0)
THEN 17155 vort_ad(1, 0) = vort_ad(1, 0) - delpc_ad(1, 1)
17160 vort_ad(i, j-1) = vort_ad(i, j-1) + delpc_ad(i, j)
17161 vort_ad(i, j) = vort_ad(i, j) - delpc_ad(i, j)
17162 ptc_ad(i-1, j) = ptc_ad(i-1, j) + delpc_ad(i, j)
17163 ptc_ad(i, j) = ptc_ad(i, j) - delpc_ad(i, j)
17164 delpc_ad(i, j) = 0.0
17168 IF (branch .EQ. 0)
THEN 17171 IF (branch .NE. 0)
THEN 17172 IF (branch .EQ. 1)
THEN 17173 v_ad(npx, j) = v_ad(npx, j) + sin_sg(npx, j, 1)*dxc(npx, j&
17174 & )*vort_ad(npx, j)
17175 vort_ad(npx, j) = 0.0
17177 v_ad(npx, j) = v_ad(npx, j) + sin_sg(npx-1, j, 3)*dxc(npx&
17178 & , j)*vort_ad(npx, j)
17179 vort_ad(npx, j) = 0.0
17183 IF (branch .EQ. 0)
THEN 17184 v_ad(1, j) = v_ad(1, j) + sin_sg(0, j, 3)*dxc(1, j)*vort_ad(&
17186 vort_ad(1, j) = 0.0
17187 ELSE IF (branch .EQ. 1)
THEN 17188 v_ad(1, j) = v_ad(1, j) + sin_sg(1, j, 1)*dxc(1, j)*vort_ad(&
17190 vort_ad(1, j) = 0.0
17193 temp_ad5 = dxc(i, j)*sina_u(i, j)*vort_ad(i, j)
17194 temp_ad6 = -(cosa_u(i, j)*0.5*temp_ad5)
17195 v_ad(i, j) = v_ad(i, j) + temp_ad5
17196 ua_ad(i-1, j) = ua_ad(i-1, j) + temp_ad6
17197 ua_ad(i, j) = ua_ad(i, j) + temp_ad6
17198 vort_ad(i, j) = 0.0
17203 IF (branch .EQ. 0)
THEN 17206 temp_ad3 = dyc(i, j)*sina_v(i, j)*ptc_ad(i, j)
17207 temp_ad4 = -(cosa_v(i, j)*0.5*temp_ad3)
17208 u_ad(i, j) = u_ad(i, j) + temp_ad3
17209 va_ad(i, j-1) = va_ad(i, j-1) + temp_ad4
17210 va_ad(i, j) = va_ad(i, j) + temp_ad4
17216 IF (branch .EQ. 0)
THEN 17218 u_ad(i, j) = u_ad(i, j) + sin_sg(i, j, 2)*dyc(i, j)*&
17223 u_ad(i, j) = u_ad(i, j) + sin_sg(i, j-1, 4)*dyc(i, j)*&
17233 temp_ad1 = dxc(i, j)*sina_u(i, j)*vort_ad(i, j)
17234 temp_ad2 = -(cosa_u(i, j)*0.5*temp_ad1)
17235 v_ad(i, j) = v_ad(i, j) + temp_ad1
17236 ua_ad(i-1, j) = ua_ad(i-1, j) + temp_ad2
17237 ua_ad(i, j) = ua_ad(i, j) + temp_ad2
17238 vort_ad(i, j) = 0.0
17244 temp_ad = dyc(i, j)*sina_v(i, j)*ptc_ad(i, j)
17245 temp_ad0 = -(cosa_v(i, j)*0.5*temp_ad)
17246 u_ad(i, j) = u_ad(i, j) + temp_ad
17247 va_ad(i, j-1) = va_ad(i, j-1) + temp_ad0
17248 va_ad(i, j) = va_ad(i, j) + temp_ad0
17261 delpc(i, j) = divg_d(i, j)
17268 fill_c = nt .NE. 0 .AND. flagstruct%grid_type .LT. 3 .AND. (((&
17269 & sw_corner .OR. se_corner) .OR. ne_corner) .OR. nw_corner) &
17270 & .AND. (.NOT.nested)
17277 DO j=ad_from0,je+1+nt
17278 ad_from = is - 1 - nt
17290 ad_from2 = js - 1 - nt
17291 DO j=ad_from2,je+1+nt
17305 DO j=ad_from4,je+1+nt
17314 IF (sw_corner)
THEN 17319 IF (se_corner)
THEN 17324 IF (ne_corner)
THEN 17329 IF (nw_corner)
THEN 17334 IF (.NOT.gridstruct%stretched_grid)
THEN 17336 DO j=ad_from6,je+1+nt
17350 IF (dddmp .LT. 1.e-5)
THEN 17353 ELSE IF (flagstruct%grid_type .LT. 3)
THEN 17356 CALL a2b_ord4(wk, vort, gridstruct, npx, npy, is, ie, js, je, ng&
17360 IF (dt .GE. 0.)
THEN 17371 vort(i, j) = abs0*sqrt(delpc(i, j)**2+vort(i, j)**2)
17376 IF (dt .GE. 0.)
THEN 17383 CALL smag_corner(abs1, u, v, ua, va, vort, bd, npx, npy, &
17387 IF (gridstruct%stretched_grid)
THEN 17389 dd8 = gridstruct%da_min*d4_bg**n2
17391 dd8 = (gridstruct%da_min_c*d4_bg)**n2
17395 IF (0.20 .GT. dddmp*vort(i, j))
THEN 17396 y2 = dddmp*vort(i, j)
17402 IF (d2_bg .LT. y2)
THEN 17411 damp2 = gridstruct%da_min_c*max2
17416 vort_ad(i, j) = vort_ad(i, j) + ke_ad(i, j)
17417 damp2_ad = delpc(i, j)*vort_ad(i, j)
17418 delpc_ad(i, j) = delpc_ad(i, j) + damp2*vort_ad(i, j)
17419 divg_d_ad(i, j) = divg_d_ad(i, j) + dd8*vort_ad(i, j)
17420 vort_ad(i, j) = 0.0
17422 max2_ad = gridstruct%da_min_c*damp2_ad
17424 IF (branch .EQ. 0)
THEN 17430 IF (branch .EQ. 0) vort_ad(i, j) = vort_ad(i, j) + dddmp*y2_ad
17434 IF (branch .NE. 0)
THEN 17435 IF (branch .EQ. 1)
THEN 17439 IF (delpc(i, j)**2 + vort(i, j)**2 .EQ. 0.0)
THEN 17442 temp_ad9 = abs0*vort_ad(i, j)/(2.0*sqrt(delpc(i, j)**2+&
17445 delpc_ad(i, j) = delpc_ad(i, j) + 2*delpc(i, j)*temp_ad9
17446 vort_ad(i, j) = 2*vort(i, j)*temp_ad9
17448 IF (branch .EQ. 0)
THEN 17456 CALL a2b_ord4_adm(wk, wk_ad, vort, vort_ad, gridstruct, npx, &
17457 & npy, is, ie, js, je, ng, .false.)
17461 & vort_ad, bd, npx, npy, gridstruct, ng)
17466 IF (branch .NE. 0)
THEN 17469 DO j=ad_to6,ad_from6,-1
17472 DO i=ad_to5,ad_from5,-1
17473 divg_d_ad(i, j) = gridstruct%rarea_c(i, j)*divg_d_ad(i, j)
17478 IF (branch .EQ. 0) uc_ad(1, npy) = uc_ad(1, npy) + divg_d_ad(1, &
17481 IF (branch .EQ. 0) uc_ad(npx, npy) = uc_ad(npx, npy) + divg_d_ad&
17484 IF (branch .EQ. 0) uc_ad(npx, 0) = uc_ad(npx, 0) - divg_d_ad(npx&
17487 IF (branch .EQ. 0) uc_ad(1, 0) = uc_ad(1, 0) - divg_d_ad(1, 1)
17490 DO j=ad_to4,ad_from4,-1
17493 DO i=ad_to3,ad_from3,-1
17494 uc_ad(i, j-1) = uc_ad(i, j-1) + divg_d_ad(i, j)
17495 uc_ad(i, j) = uc_ad(i, j) - divg_d_ad(i, j)
17496 vc_ad(i-1, j) = vc_ad(i-1, j) + divg_d_ad(i, j)
17497 vc_ad(i, j) = vc_ad(i, j) - divg_d_ad(i, j)
17498 divg_d_ad(i, j) = 0.0
17503 & npx, npy, dgrid=.true., &
17507 DO j=ad_to2,ad_from2,-1
17510 DO i=ad_to1,ad_from1,-1
17511 temp_ad8 = divg_v(i, j)*uc_ad(i, j)
17512 divg_d_ad(i, j+1) = divg_d_ad(i, j+1) + temp_ad8
17513 divg_d_ad(i, j) = divg_d_ad(i, j) - temp_ad8
17519 & , npy, fill=ydir, bgrid=&
17523 DO j=ad_to0,ad_from0,-1
17526 DO i=ad_to,ad_from,-1
17527 temp_ad7 = divg_u(i, j)*vc_ad(i, j)
17528 divg_d_ad(i+1, j) = divg_d_ad(i+1, j) + temp_ad7
17529 divg_d_ad(i, j) = divg_d_ad(i, j) - temp_ad7
17535 & , npy, fill=xdir, bgrid=&
17541 divg_d_ad(i, j) = divg_d_ad(i, j) + delpc_ad(i, j)
17542 delpc_ad(i, j) = 0.0
17569 & smag_c_ad, bd, npx, npy, gridstruct, ng)
17573 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
17574 REAL,
INTENT(IN) :: dt
17575 INTEGER,
INTENT(IN) :: npx, npy, ng
17576 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
17577 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u_ad
17578 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
17579 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: v_ad
17580 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
17581 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: smag_c
17582 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: smag_c_ad
17583 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
17585 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
17586 REAL :: ut_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed)
17587 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
17588 REAL :: vt_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1)
17590 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
17591 REAL :: wk_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
17592 REAL :: sh(bd%isd:bd%ied, bd%jsd:bd%jed)
17593 REAL :: sh_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
17595 INTEGER :: is2, ie1
17596 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc, dx, dy, rarea, rarea_c
17597 INTEGER :: is, ie, js, je
17598 INTEGER :: isd, ied, jsd, jed
17613 dxc => gridstruct%dxc
17614 dyc => gridstruct%dyc
17615 dx => gridstruct%dx
17616 dy => gridstruct%dy
17617 rarea => gridstruct%rarea
17618 rarea_c => gridstruct%rarea_c
17624 ut(i, j) = u(i, j)*dyc(i, j)
17629 vt(i, j) = v(i, j)*dxc(i, j)
17634 smag_c(i, j) = rarea_c(i, j)*(vt(i, j-1)-vt(i, j)+(ut(i, j)-ut(i&
17642 vt(i, j) = u(i, j)*dx(i, j)
17647 ut(i, j) = v(i, j)*dy(i, j)
17652 wk(i, j) = rarea(i, j)*(vt(i, j)-vt(i, j+1)+(ut(i, j)-ut(i+1, j)&
17656 CALL a2b_ord4(wk, sh, gridstruct, npx, npy, is, ie, js, je, ng, &
17661 IF (sh(i, j)**2 + smag_c(i, j)**2 .EQ. 0.0)
THEN 17664 temp_ad1 = dt*smag_c_ad(i, j)/(2.0*sqrt(sh(i, j)**2+smag_c(i, &
17667 sh_ad(i, j) = sh_ad(i, j) + 2*sh(i, j)*temp_ad1
17668 smag_c_ad(i, j) = 2*smag_c(i, j)*temp_ad1
17672 CALL a2b_ord4_adm(wk, wk_ad, sh, sh_ad, gridstruct, npx, npy, is, ie&
17673 & , js, je, ng, .false.)
17678 temp_ad0 = rarea(i, j)*wk_ad(i, j)
17679 vt_ad(i, j) = vt_ad(i, j) + temp_ad0
17680 vt_ad(i, j+1) = vt_ad(i, j+1) - temp_ad0
17681 ut_ad(i, j) = ut_ad(i, j) + temp_ad0
17682 ut_ad(i+1, j) = ut_ad(i+1, j) - temp_ad0
17688 v_ad(i, j) = v_ad(i, j) + dy(i, j)*ut_ad(i, j)
17694 u_ad(i, j) = u_ad(i, j) + dx(i, j)*vt_ad(i, j)
17700 temp_ad = rarea_c(i, j)*smag_c_ad(i, j)
17701 vt_ad(i, j-1) = vt_ad(i, j-1) + temp_ad
17702 vt_ad(i, j) = vt_ad(i, j) - temp_ad
17703 ut_ad(i, j) = ut_ad(i, j) + temp_ad
17704 ut_ad(i-1, j) = ut_ad(i-1, j) - temp_ad
17705 smag_c_ad(i, j) = 0.0
17710 v_ad(i, j) = v_ad(i, j) + dxc(i, j)*vt_ad(i, j)
17716 u_ad(i, j) = u_ad(i, j) + dyc(i, j)*ut_ad(i, j)
17722 & vort, ptc, delpc, ke, u, v, uc, vc, ua, va, divg_d, wk, gridstruct, &
17726 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
17727 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
17728 TYPE(FV_FLAGS_TYPE),
INTENT(IN),
TARGET :: flagstruct
17729 INTEGER,
INTENT(IN) :: nord
17730 REAL,
INTENT(IN) :: d2_bg, d4_bg, dddmp, dt
17731 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
17732 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
17733 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
17735 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: wk
17736 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: vort
17737 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
17739 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
17741 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: vc
17742 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: uc
17743 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
17746 REAL :: damp, dd8, damp2, da_min, da_min_c, absdt
17747 INTEGER :: is, ie, js, je, npx, npy, is2, ie1
17748 LOGICAL :: nested, fill_c
17749 INTEGER :: i, j, n, n2, nt
17750 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
17751 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
17752 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
17753 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
17754 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
17755 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
17756 REAL,
DIMENSION(:, :),
POINTER :: f0, rsin2, divg_u, divg_v
17757 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
17771 area => gridstruct%area
17772 rarea => gridstruct%rarea
17773 sin_sg => gridstruct%sin_sg
17774 cosa_u => gridstruct%cosa_u
17775 cosa_v => gridstruct%cosa_v
17776 cosa_s => gridstruct%cosa_s
17777 sina_u => gridstruct%sina_u
17778 sina_v => gridstruct%sina_v
17779 rsin_u => gridstruct%rsin_u
17780 rsin_v => gridstruct%rsin_v
17781 rsina => gridstruct%rsina
17782 f0 => gridstruct%f0
17783 rsin2 => gridstruct%rsin2
17784 divg_u => gridstruct%divg_u
17785 divg_v => gridstruct%divg_v
17786 cosa => gridstruct%cosa
17787 dx => gridstruct%dx
17788 dy => gridstruct%dy
17789 dxc => gridstruct%dxc
17790 dyc => gridstruct%dyc
17791 rdxa => gridstruct%rdxa
17792 rdya => gridstruct%rdya
17793 rdx => gridstruct%rdx
17794 rdy => gridstruct%rdy
17795 sw_corner = gridstruct%sw_corner
17796 se_corner = gridstruct%se_corner
17797 nw_corner = gridstruct%nw_corner
17798 ne_corner = gridstruct%ne_corner
17799 IF (dt .GE. 0.)
THEN 17804 da_min = gridstruct%da_min
17805 da_min_c = gridstruct%da_min_c
17810 npx = flagstruct%npx
17811 npy = flagstruct%npy
17812 nested = gridstruct%nested
17817 IF (2 .LT. is)
THEN 17822 IF (npx - 1 .GT. ie + 1)
THEN 17832 IF (nord .EQ. 0)
THEN 17837 ptc(i, j) = (u(i, j)-0.5*(va(i, j-1)+va(i, j))*cosa_v(i, j))&
17838 & *dyc(i, j)*sina_v(i, j)
17843 vort(i, j) = (v(i, j)-0.5*(ua(i-1, j)+ua(i, j))*cosa_u(i, j)&
17844 & )*dxc(i, j)*sina_u(i, j)
17849 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 17851 IF (vc(i, j) .GT. 0)
THEN 17852 ptc(i, j) = u(i, j)*dyc(i, j)*sin_sg(i, j-1, 4)
17854 ptc(i, j) = u(i, j)*dyc(i, j)*sin_sg(i, j, 2)
17859 ptc(i, j) = (u(i, j)-0.5*(va(i, j-1)+va(i, j))*cosa_v(i, j&
17860 & ))*dyc(i, j)*sina_v(i, j)
17866 vort(i, j) = (v(i, j)-0.5*(ua(i-1, j)+ua(i, j))*cosa_u(i, j)&
17867 & )*dxc(i, j)*sina_u(i, j)
17869 IF (is .EQ. 1)
THEN 17870 IF (uc(1, j) .GT. 0)
THEN 17871 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(0, j, 3)
17873 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(1, j, 1)
17876 IF (ie + 1 .EQ. npx)
THEN 17877 IF (uc(npx, j) .GT. 0)
THEN 17878 vort(npx, j) = v(npx, j)*dxc(npx, j)*sin_sg(npx-1, j, 3)
17880 vort(npx, j) = v(npx, j)*dxc(npx, j)*sin_sg(npx, j, 1)
17887 delpc(i, j) = vort(i, j-1) - vort(i, j) + ptc(i-1, j) - ptc(i&
17892 IF (sw_corner) delpc(1, 1) = delpc(1, 1) - vort(1, 0)
17893 IF (se_corner) delpc(npx, 1) = delpc(npx, 1) - vort(npx, 0)
17894 IF (ne_corner) delpc(npx, npy) = delpc(npx, npy) + vort(npx, npy)
17895 IF (nw_corner) delpc(1, npy) = delpc(1, npy) + vort(1, npy)
17898 delpc(i, j) = gridstruct%rarea_c(i, j)*delpc(i, j)
17899 IF (delpc(i, j)*dt .GE. 0.)
THEN 17900 abs2 = delpc(i, j)*dt
17902 abs2 = -(delpc(i, j)*dt)
17905 IF (0.20 .GT. y3)
THEN 17910 IF (d2_bg .LT. y1)
THEN 17915 damp = gridstruct%da_min_c*max1
17916 vort(i, j) = damp*delpc(i, j)
17917 ke(i, j) = ke(i, j) + vort(i, j)
17927 delpc(i, j) = divg_d(i, j)
17934 fill_c = nt .NE. 0 .AND. flagstruct%grid_type .LT. 3 .AND. (((&
17935 & sw_corner .OR. se_corner) .OR. ne_corner) .OR. nw_corner) &
17936 & .AND. (.NOT.nested)
17937 IF (fill_c)
CALL fill_corners(divg_d, npx, npy, fill=xdir, bgrid&
17940 DO i=is-1-nt,ie+1+nt
17941 vc(i, j) = (divg_d(i+1, j)-divg_d(i, j))*divg_u(i, j)
17944 IF (fill_c)
CALL fill_corners(divg_d, npx, npy, fill=ydir, bgrid&
17946 DO j=js-1-nt,je+1+nt
17948 uc(i, j) = (divg_d(i, j+1)-divg_d(i, j))*divg_v(i, j)
17951 IF (fill_c)
CALL fill_corners(vc, uc, npx, npy, dgrid=.true., &
17955 divg_d(i, j) = uc(i, j-1) - uc(i, j) + vc(i-1, j) - vc(i, j)
17959 IF (sw_corner) divg_d(1, 1) = divg_d(1, 1) - uc(1, 0)
17960 IF (se_corner) divg_d(npx, 1) = divg_d(npx, 1) - uc(npx, 0)
17961 IF (ne_corner) divg_d(npx, npy) = divg_d(npx, npy) + uc(npx, npy&
17963 IF (nw_corner) divg_d(1, npy) = divg_d(1, npy) + uc(1, npy)
17964 IF (.NOT.gridstruct%stretched_grid)
THEN 17967 divg_d(i, j) = divg_d(i, j)*gridstruct%rarea_c(i, j)
17973 IF (dddmp .LT. 1.e-5)
THEN 17975 ELSE IF (flagstruct%grid_type .LT. 3)
THEN 17977 CALL a2b_ord4(wk, vort, gridstruct, npx, npy, is, ie, js, je, ng&
17981 IF (dt .GE. 0.)
THEN 17987 vort(i, j) = abs0*sqrt(delpc(i, j)**2+vort(i, j)**2)
17991 IF (dt .GE. 0.)
THEN 17997 CALL smag_corner(abs1, u, v, ua, va, vort, bd, npx, npy, &
18000 IF (gridstruct%stretched_grid)
THEN 18002 dd8 = gridstruct%da_min*d4_bg**n2
18004 dd8 = (gridstruct%da_min_c*d4_bg)**n2
18008 IF (0.20 .GT. dddmp*vort(i, j))
THEN 18009 y2 = dddmp*vort(i, j)
18013 IF (d2_bg .LT. y2)
THEN 18019 damp2 = gridstruct%da_min_c*max2
18020 vort(i, j) = damp2*delpc(i, j) + dd8*divg_d(i, j)
18021 ke(i, j) = ke(i, j) + vort(i, j)
18049 & , dt, vort, ptc, delpc, ke, u, v, uc, vc, ua, va, divg_d, wk, &
18050 & gridstruct, flagstruct, bd)
18055 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
18056 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
18057 TYPE(FV_FLAGS_TYPE),
INTENT(IN),
TARGET :: flagstruct
18058 INTEGER,
INTENT(IN) :: nord
18059 REAL,
INTENT(IN) :: d2_bg, d4_bg, dddmp, dt
18060 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
18061 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
18062 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
18064 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: wk
18065 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: vort
18066 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
18068 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18070 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: vc
18071 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: uc
18072 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18075 REAL :: damp, dd8, damp2, da_min, da_min_c, absdt
18076 INTEGER :: is, ie, js, je, npx, npy, is2, ie1
18077 LOGICAL :: nested, fill_c
18078 INTEGER :: i, j, n, n2, nt
18079 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
18080 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
18081 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
18082 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
18083 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
18084 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
18085 REAL,
DIMENSION(:, :),
POINTER :: f0, rsin2, divg_u, divg_v
18086 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
18098 INTEGER :: ad_from0
18099 INTEGER :: ad_from1
18100 INTEGER :: ad_from2
18101 INTEGER :: ad_from3
18102 INTEGER :: ad_from4
18103 INTEGER :: ad_from5
18104 INTEGER :: ad_from6
18143 sin_sg => gridstruct%sin_sg
18144 cosa_u => gridstruct%cosa_u
18145 cosa_v => gridstruct%cosa_v
18146 sina_u => gridstruct%sina_u
18147 sina_v => gridstruct%sina_v
18148 divg_u => gridstruct%divg_u
18149 divg_v => gridstruct%divg_v
18150 dxc => gridstruct%dxc
18151 dyc => gridstruct%dyc
18152 sw_corner = gridstruct%sw_corner
18153 se_corner = gridstruct%se_corner
18154 nw_corner = gridstruct%nw_corner
18155 ne_corner = gridstruct%ne_corner
18160 npx = flagstruct%npx
18161 npy = flagstruct%npy
18162 nested = gridstruct%nested
18168 IF (2 .LT. is)
THEN 18173 IF (npx - 1 .GT. ie + 1)
THEN 18185 IF (nord .EQ. 0)
THEN 18191 ptc(i, j) = (u(i, j)-0.5*(va(i, j-1)+va(i, j))*cosa_v(i, j))&
18192 & *dyc(i, j)*sina_v(i, j)
18197 vort(i, j) = (v(i, j)-0.5*(ua(i-1, j)+ua(i, j))*cosa_u(i, j)&
18198 & )*dxc(i, j)*sina_u(i, j)
18204 IF (j .EQ. 1 .OR. j .EQ. npy)
THEN 18206 IF (vc(i, j) .GT. 0)
THEN 18208 ptc(i, j) = u(i, j)*dyc(i, j)*sin_sg(i, j-1, 4)
18212 ptc(i, j) = u(i, j)*dyc(i, j)*sin_sg(i, j, 2)
18220 ptc(i, j) = (u(i, j)-0.5*(va(i, j-1)+va(i, j))*cosa_v(i, j&
18221 & ))*dyc(i, j)*sina_v(i, j)
18228 vort(i, j) = (v(i, j)-0.5*(ua(i-1, j)+ua(i, j))*cosa_u(i, j)&
18229 & )*dxc(i, j)*sina_u(i, j)
18231 IF (is .EQ. 1)
THEN 18232 IF (uc(1, j) .GT. 0)
THEN 18233 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(0, j, 3)
18236 vort(1, j) = v(1, j)*dxc(1, j)*sin_sg(1, j, 1)
18242 IF (ie + 1 .EQ. npx)
THEN 18243 IF (uc(npx, j) .GT. 0)
THEN 18244 vort(npx, j) = v(npx, j)*dxc(npx, j)*sin_sg(npx-1, j, 3)
18247 vort(npx, j) = v(npx, j)*dxc(npx, j)*sin_sg(npx, j, 1)
18259 delpc(i, j) = vort(i, j-1) - vort(i, j) + (ptc(i-1, j)-ptc(i, &
18264 IF (sw_corner)
THEN 18266 delpc(1, 1) = delpc(1, 1) - vort(1, 0)
18271 IF (se_corner)
THEN 18273 delpc(npx, 1) = delpc(npx, 1) - vort(npx, 0)
18278 IF (ne_corner)
THEN 18280 delpc(npx, npy) = delpc(npx, npy) + vort(npx, npy)
18285 IF (nw_corner)
THEN 18287 delpc(1, npy) = delpc(1, npy) + vort(1, npy)
18295 delpc(i, j) = gridstruct%rarea_c(i, j)*delpc(i, j)
18296 IF (delpc(i, j)*dt .GE. 0.)
THEN 18297 abs2 = delpc(i, j)*dt
18300 abs2 = -(delpc(i, j)*dt)
18304 IF (0.20 .GT. y3)
THEN 18311 IF (d2_bg .LT. y1)
THEN 18319 damp = gridstruct%da_min_c*max1
18320 vort(i, j) = damp*delpc(i, j)
18321 ke(i, j) = ke(i, j) + vort(i, j)
18349 delpc(i, j) = divg_d(i, j)
18356 fill_c = nt .NE. 0 .AND. flagstruct%grid_type .LT. 3 .AND. (((&
18357 & sw_corner .OR. se_corner) .OR. ne_corner) .OR. nw_corner) &
18358 & .AND. (.NOT.nested)
18360 CALL fill_corners(divg_d, npx, npy, fill=xdir, bgrid=.true.)
18366 DO j=ad_from0,je+1+nt
18367 ad_from = is - 1 - nt
18368 DO i=ad_from,ie+1+nt
18369 vc(i, j) = (divg_d(i+1, j)-divg_d(i, j))*divg_u(i, j)
18377 CALL fill_corners(divg_d, npx, npy, fill=ydir, bgrid=.true.)
18382 ad_from2 = js - 1 - nt
18383 DO j=ad_from2,je+1+nt
18385 DO i=ad_from1,ie+1+nt
18386 uc(i, j) = (divg_d(i, j+1)-divg_d(i, j))*divg_v(i, j)
18394 CALL fill_corners(vc, uc, npx, npy, vector=.true., dgrid=&
18401 DO j=ad_from4,je+1+nt
18403 DO i=ad_from3,ie+1+nt
18404 divg_d(i, j) = uc(i, j-1) - uc(i, j) + (vc(i-1, j)-vc(i, j))
18412 IF (sw_corner)
THEN 18413 divg_d(1, 1) = divg_d(1, 1) - uc(1, 0)
18418 IF (se_corner)
THEN 18419 divg_d(npx, 1) = divg_d(npx, 1) - uc(npx, 0)
18424 IF (ne_corner)
THEN 18425 divg_d(npx, npy) = divg_d(npx, npy) + uc(npx, npy)
18430 IF (nw_corner)
THEN 18431 divg_d(1, npy) = divg_d(1, npy) + uc(1, npy)
18436 IF (.NOT.gridstruct%stretched_grid)
THEN 18438 DO j=ad_from6,je+1+nt
18440 DO i=ad_from5,ie+1+nt
18441 divg_d(i, j) = divg_d(i, j)*gridstruct%rarea_c(i, j)
18454 IF (dddmp .LT. 1.e-5)
THEN 18457 ELSE IF (flagstruct%grid_type .LT. 3)
THEN 18459 CALL a2b_ord4_fwd(wk, vort, gridstruct, npx, npy, is, ie, js&
18460 & , je, ng, .false.)
18463 IF (dt .GE. 0.)
THEN 18474 vort(i, j) = abs0*sqrt(delpc(i, j)**2+vort(i, j)**2)
18479 IF (dt .GE. 0.)
THEN 18489 IF (gridstruct%stretched_grid)
THEN 18491 dd8 = gridstruct%da_min*d4_bg**n2
18493 dd8 = (gridstruct%da_min_c*d4_bg)**n2
18497 IF (0.20 .GT. dddmp*vort(i, j))
THEN 18498 y2 = dddmp*vort(i, j)
18504 IF (d2_bg .LT. y2)
THEN 18513 damp2 = gridstruct%da_min_c*max2
18514 vort(i, j) = damp2*delpc(i, j) + dd8*divg_d(i, j)
18515 ke(i, j) = ke(i, j) + vort(i, j)
18552 & , dt, vort, vort_ad, ptc, ptc_ad, delpc, delpc_ad, ke, ke_ad, u, &
18553 & u_ad, v, v_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, divg_d, &
18554 & divg_d_ad, wk, wk_ad, gridstruct, flagstruct, bd)
18558 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
18559 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
18560 TYPE(FV_FLAGS_TYPE),
INTENT(IN),
TARGET :: flagstruct
18561 INTEGER,
INTENT(IN) :: nord
18562 REAL,
INTENT(IN) :: d2_bg, d4_bg, dddmp, dt
18563 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
18564 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ua_ad, va_ad
18565 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
18566 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u_ad
18567 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
18568 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: v_ad
18569 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: wk
18570 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
18572 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: vort
18573 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
18575 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
18577 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(INOUT) :: &
18579 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18581 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18583 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: vc
18584 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18586 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: uc
18587 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(INOUT) :: &
18589 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18591 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed+1),
INTENT(INOUT) :: &
18593 REAL :: damp, dd8, damp2, da_min, da_min_c, absdt
18594 REAL :: damp_ad, damp2_ad
18595 INTEGER :: is, ie, js, je, npx, npy, is2, ie1
18596 LOGICAL :: nested, fill_c
18597 INTEGER :: i, j, n, n2, nt
18598 LOGICAL :: sw_corner, se_corner, ne_corner, nw_corner
18599 REAL,
DIMENSION(:, :),
POINTER :: area, area_c, rarea
18600 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
18601 REAL,
DIMENSION(:, :),
POINTER :: cosa_u, cosa_v, cosa_s
18602 REAL,
DIMENSION(:, :),
POINTER :: sina_u, sina_v
18603 REAL,
DIMENSION(:, :),
POINTER :: rsin_u, rsin_v, rsina
18604 REAL,
DIMENSION(:, :),
POINTER :: f0, rsin2, divg_u, divg_v
18605 REAL,
DIMENSION(:, :),
POINTER :: cosa, dx, dy, dxc, dyc, rdxa, rdya&
18636 INTEGER :: ad_from0
18638 INTEGER :: ad_from1
18640 INTEGER :: ad_from2
18642 INTEGER :: ad_from3
18644 INTEGER :: ad_from4
18646 INTEGER :: ad_from5
18648 INTEGER :: ad_from6
18699 sin_sg => gridstruct%sin_sg
18700 cosa_u => gridstruct%cosa_u
18701 cosa_v => gridstruct%cosa_v
18702 sina_u => gridstruct%sina_u
18703 sina_v => gridstruct%sina_v
18704 divg_u => gridstruct%divg_u
18705 divg_v => gridstruct%divg_v
18706 dxc => gridstruct%dxc
18707 dyc => gridstruct%dyc
18708 sw_corner = gridstruct%sw_corner
18709 se_corner = gridstruct%se_corner
18710 nw_corner = gridstruct%nw_corner
18711 ne_corner = gridstruct%ne_corner
18716 npx = flagstruct%npx
18717 npy = flagstruct%npy
18718 nested = gridstruct%nested
18720 IF (branch .EQ. 0)
THEN 18726 dxc => gridstruct%dxc
18730 cosa_u => gridstruct%cosa_u
18733 cosa_v => gridstruct%cosa_v
18736 sin_sg => gridstruct%sin_sg
18739 dyc => gridstruct%dyc
18743 sina_u => gridstruct%sina_u
18746 sina_v => gridstruct%sina_v
18753 vort_ad(i, j) = vort_ad(i, j) + ke_ad(i, j)
18754 damp_ad = delpc(i, j)*vort_ad(i, j)
18755 delpc_ad(i, j) = delpc_ad(i, j) + damp*vort_ad(i, j)
18756 vort_ad(i, j) = 0.0
18758 max1_ad = gridstruct%da_min_c*damp_ad
18760 IF (branch .EQ. 0)
THEN 18766 IF (branch .EQ. 0)
THEN 18771 abs2_ad = dddmp*y3_ad
18773 IF (branch .EQ. 0)
THEN 18774 delpc_ad(i, j) = delpc_ad(i, j) + dt*abs2_ad
18776 delpc_ad(i, j) = delpc_ad(i, j) - dt*abs2_ad
18779 delpc_ad(i, j) = gridstruct%rarea_c(i, j)*delpc_ad(i, j)
18783 IF (branch .NE. 0)
THEN 18784 npy = flagstruct%npy
18786 vort_ad(1, npy) = vort_ad(1, npy) + delpc_ad(1, npy)
18789 IF (branch .EQ. 0)
THEN 18790 npx = flagstruct%npx
18792 vort_ad(npx, npy) = vort_ad(npx, npy) + delpc_ad(npx, npy)
18795 IF (branch .EQ. 0)
THEN 18797 vort_ad(npx, 0) = vort_ad(npx, 0) - delpc_ad(npx, 1)
18800 IF (branch .EQ. 0)
THEN 18802 vort_ad(1, 0) = vort_ad(1, 0) - delpc_ad(1, 1)
18807 vort_ad(i, j-1) = vort_ad(i, j-1) + delpc_ad(i, j)
18808 vort_ad(i, j) = vort_ad(i, j) - delpc_ad(i, j)
18809 ptc_ad(i-1, j) = ptc_ad(i-1, j) + delpc_ad(i, j)
18810 ptc_ad(i, j) = ptc_ad(i, j) - delpc_ad(i, j)
18811 delpc_ad(i, j) = 0.0
18815 IF (branch .EQ. 0)
THEN 18818 IF (branch .NE. 0)
THEN 18819 IF (branch .EQ. 1)
THEN 18820 v_ad(npx, j) = v_ad(npx, j) + sin_sg(npx, j, 1)*dxc(npx, j&
18821 & )*vort_ad(npx, j)
18822 vort_ad(npx, j) = 0.0
18824 v_ad(npx, j) = v_ad(npx, j) + sin_sg(npx-1, j, 3)*dxc(npx&
18825 & , j)*vort_ad(npx, j)
18826 vort_ad(npx, j) = 0.0
18830 IF (branch .EQ. 0)
THEN 18831 v_ad(1, j) = v_ad(1, j) + sin_sg(0, j, 3)*dxc(1, j)*vort_ad(&
18833 vort_ad(1, j) = 0.0
18834 ELSE IF (branch .EQ. 1)
THEN 18835 v_ad(1, j) = v_ad(1, j) + sin_sg(1, j, 1)*dxc(1, j)*vort_ad(&
18837 vort_ad(1, j) = 0.0
18840 temp_ad5 = dxc(i, j)*sina_u(i, j)*vort_ad(i, j)
18841 temp_ad6 = -(cosa_u(i, j)*0.5*temp_ad5)
18842 v_ad(i, j) = v_ad(i, j) + temp_ad5
18843 ua_ad(i-1, j) = ua_ad(i-1, j) + temp_ad6
18844 ua_ad(i, j) = ua_ad(i, j) + temp_ad6
18845 vort_ad(i, j) = 0.0
18850 IF (branch .EQ. 0)
THEN 18853 temp_ad3 = dyc(i, j)*sina_v(i, j)*ptc_ad(i, j)
18854 temp_ad4 = -(cosa_v(i, j)*0.5*temp_ad3)
18855 u_ad(i, j) = u_ad(i, j) + temp_ad3
18856 va_ad(i, j-1) = va_ad(i, j-1) + temp_ad4
18857 va_ad(i, j) = va_ad(i, j) + temp_ad4
18863 IF (branch .EQ. 0)
THEN 18865 u_ad(i, j) = u_ad(i, j) + sin_sg(i, j, 2)*dyc(i, j)*&
18870 u_ad(i, j) = u_ad(i, j) + sin_sg(i, j-1, 4)*dyc(i, j)*&
18880 temp_ad1 = dxc(i, j)*sina_u(i, j)*vort_ad(i, j)
18881 temp_ad2 = -(cosa_u(i, j)*0.5*temp_ad1)
18882 v_ad(i, j) = v_ad(i, j) + temp_ad1
18883 ua_ad(i-1, j) = ua_ad(i-1, j) + temp_ad2
18884 ua_ad(i, j) = ua_ad(i, j) + temp_ad2
18885 vort_ad(i, j) = 0.0
18891 temp_ad = dyc(i, j)*sina_v(i, j)*ptc_ad(i, j)
18892 temp_ad0 = -(cosa_v(i, j)*0.5*temp_ad)
18893 u_ad(i, j) = u_ad(i, j) + temp_ad
18894 va_ad(i, j-1) = va_ad(i, j-1) + temp_ad0
18895 va_ad(i, j) = va_ad(i, j) + temp_ad0
18911 vort_ad(i, j) = vort_ad(i, j) + ke_ad(i, j)
18912 damp2_ad = delpc(i, j)*vort_ad(i, j)
18913 delpc_ad(i, j) = delpc_ad(i, j) + damp2*vort_ad(i, j)
18914 divg_d_ad(i, j) = divg_d_ad(i, j) + dd8*vort_ad(i, j)
18915 vort_ad(i, j) = 0.0
18917 max2_ad = gridstruct%da_min_c*damp2_ad
18919 IF (branch .EQ. 0)
THEN 18925 IF (branch .EQ. 0) vort_ad(i, j) = vort_ad(i, j) + dddmp*y2_ad
18929 IF (branch .EQ. 0)
THEN 18930 npx = flagstruct%npx
18931 npy = flagstruct%npy
18932 ELSE IF (branch .EQ. 1)
THEN 18936 IF (delpc(i, j)**2 + vort(i, j)**2 .EQ. 0.0)
THEN 18939 temp_ad9 = abs0*vort_ad(i, j)/(2.0*sqrt(delpc(i, j)**2+&
18942 delpc_ad(i, j) = delpc_ad(i, j) + 2*delpc(i, j)*temp_ad9
18943 vort_ad(i, j) = 2*vort(i, j)*temp_ad9
18945 IF (branch .EQ. 0)
THEN 18952 npx = flagstruct%npx
18953 npy = flagstruct%npy
18954 CALL a2b_ord4_bwd(wk, wk_ad, vort, vort_ad, gridstruct, npx, &
18955 & npy, is, ie, js, je, ng, .false.)
18957 npx = flagstruct%npx
18958 npy = flagstruct%npy
18960 & vort_ad, bd, npx, npy, gridstruct, ng)
18962 divg_u => gridstruct%divg_u
18963 divg_v => gridstruct%divg_v
18966 IF (branch .NE. 0)
THEN 18969 DO j=ad_to6,ad_from6,-1
18972 DO i=ad_to5,ad_from5,-1
18973 divg_d_ad(i, j) = gridstruct%rarea_c(i, j)*divg_d_ad(i, j)
18978 IF (branch .EQ. 0) uc_ad(1, npy) = uc_ad(1, npy) + divg_d_ad(1, &
18981 IF (branch .EQ. 0) uc_ad(npx, npy) = uc_ad(npx, npy) + divg_d_ad&
18984 IF (branch .EQ. 0) uc_ad(npx, 0) = uc_ad(npx, 0) - divg_d_ad(npx&
18987 IF (branch .EQ. 0) uc_ad(1, 0) = uc_ad(1, 0) - divg_d_ad(1, 1)
18990 DO j=ad_to4,ad_from4,-1
18993 DO i=ad_to3,ad_from3,-1
18994 uc_ad(i, j-1) = uc_ad(i, j-1) + divg_d_ad(i, j)
18995 uc_ad(i, j) = uc_ad(i, j) - divg_d_ad(i, j)
18996 vc_ad(i-1, j) = vc_ad(i-1, j) + divg_d_ad(i, j)
18997 vc_ad(i, j) = vc_ad(i, j) - divg_d_ad(i, j)
18998 divg_d_ad(i, j) = 0.0
19003 & npx, npy, dgrid=.true., &
19007 DO j=ad_to2,ad_from2,-1
19010 DO i=ad_to1,ad_from1,-1
19011 temp_ad8 = divg_v(i, j)*uc_ad(i, j)
19012 divg_d_ad(i, j+1) = divg_d_ad(i, j+1) + temp_ad8
19013 divg_d_ad(i, j) = divg_d_ad(i, j) - temp_ad8
19019 & , npy, fill=ydir, bgrid=&
19023 DO j=ad_to0,ad_from0,-1
19026 DO i=ad_to,ad_from,-1
19027 temp_ad7 = divg_u(i, j)*vc_ad(i, j)
19028 divg_d_ad(i+1, j) = divg_d_ad(i+1, j) + temp_ad7
19029 divg_d_ad(i, j) = divg_d_ad(i, j) - temp_ad7
19035 & , npy, fill=xdir, bgrid=&
19041 divg_d_ad(i, j) = divg_d_ad(i, j) + delpc_ad(i, j)
19042 delpc_ad(i, j) = 0.0
19075 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
19076 REAL,
INTENT(IN) :: dt
19077 INTEGER,
INTENT(IN) :: npx, npy, ng
19078 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
19079 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
19080 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
19081 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: smag_c
19082 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
19084 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
19085 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
19087 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
19088 REAL :: sh(bd%isd:bd%ied, bd%jsd:bd%jed)
19090 INTEGER :: is2, ie1
19091 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc, dx, dy, rarea, rarea_c
19092 INTEGER :: is, ie, js, je
19093 INTEGER :: isd, ied, jsd, jed
19121 dxc => gridstruct%dxc
19122 dyc => gridstruct%dyc
19123 dx => gridstruct%dx
19124 dy => gridstruct%dy
19125 rarea => gridstruct%rarea
19126 rarea_c => gridstruct%rarea_c
19132 ut(i, j) = u(i, j)*dyc(i, j)
19137 vt(i, j) = v(i, j)*dxc(i, j)
19142 smag_c(i, j) = rarea_c(i, j)*(vt(i, j-1)-vt(i, j)-ut(i-1, j)+ut(&
19150 vt(i, j) = u(i, j)*dx(i, j)
19155 ut(i, j) = v(i, j)*dy(i, j)
19160 wk(i, j) = rarea(i, j)*(vt(i, j)-vt(i, j+1)+ut(i, j)-ut(i+1, j))
19163 CALL a2b_ord4_fwd(wk, sh, gridstruct, npx, npy, is, ie, js, je, &
19168 smag_c(i, j) = dt*sqrt(sh(i, j)**2+smag_c(i, j)**2)
19174 CALL pushrealarray(sh, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
19204 & smag_c_ad, bd, npx, npy, gridstruct, ng)
19208 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
19209 REAL,
INTENT(IN) :: dt
19210 INTEGER,
INTENT(IN) :: npx, npy, ng
19211 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1),
INTENT(IN) :: u
19212 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1) :: u_ad
19213 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed),
INTENT(IN) :: v
19214 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed) :: v_ad
19215 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed),
INTENT(IN) :: ua, va
19216 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: smag_c
19217 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: smag_c_ad
19218 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
19219 REAL :: ut(bd%isd:bd%ied+1, bd%jsd:bd%jed)
19220 REAL :: ut_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed)
19221 REAL :: vt(bd%isd:bd%ied, bd%jsd:bd%jed+1)
19222 REAL :: vt_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1)
19223 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
19224 REAL :: wk_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
19225 REAL :: sh(bd%isd:bd%ied, bd%jsd:bd%jed)
19226 REAL :: sh_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
19228 INTEGER :: is2, ie1
19229 REAL,
DIMENSION(:, :),
POINTER :: dxc, dyc, dx, dy, rarea, rarea_c
19230 INTEGER :: is, ie, js, je
19231 INTEGER :: isd, ied, jsd, jed
19264 dxc => gridstruct%dxc
19265 dyc => gridstruct%dyc
19266 dx => gridstruct%dx
19267 dy => gridstruct%dy
19268 rarea => gridstruct%rarea
19269 rarea_c => gridstruct%rarea_c
19272 dxc => gridstruct%dxc
19274 dx => gridstruct%dx
19276 dy => gridstruct%dy
19278 rarea_c => gridstruct%rarea_c
19280 dyc => gridstruct%dyc
19282 CALL poprealarray(sh, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
19290 IF (sh(i, j)**2 + smag_c(i, j)**2 .EQ. 0.0)
THEN 19293 temp_ad1 = dt*smag_c_ad(i, j)/(2.0*sqrt(sh(i, j)**2+smag_c(i, &
19296 sh_ad(i, j) = sh_ad(i, j) + 2*sh(i, j)*temp_ad1
19297 smag_c_ad(i, j) = 2*smag_c(i, j)*temp_ad1
19301 CALL a2b_ord4_bwd(wk, wk_ad, sh, sh_ad, gridstruct, npx, npy, is&
19302 & , ie, js, je, ng, .false.)
19303 rarea => gridstruct%rarea
19311 temp_ad0 = rarea(i, j)*wk_ad(i, j)
19312 vt_ad(i, j) = vt_ad(i, j) + temp_ad0
19313 vt_ad(i, j+1) = vt_ad(i, j+1) - temp_ad0
19314 ut_ad(i, j) = ut_ad(i, j) + temp_ad0
19315 ut_ad(i+1, j) = ut_ad(i+1, j) - temp_ad0
19321 v_ad(i, j) = v_ad(i, j) + dy(i, j)*ut_ad(i, j)
19327 u_ad(i, j) = u_ad(i, j) + dx(i, j)*vt_ad(i, j)
19333 temp_ad = rarea_c(i, j)*smag_c_ad(i, j)
19334 vt_ad(i, j-1) = vt_ad(i, j-1) + temp_ad
19335 vt_ad(i, j) = vt_ad(i, j) - temp_ad
19336 ut_ad(i, j) = ut_ad(i, j) + temp_ad
19337 ut_ad(i-1, j) = ut_ad(i-1, j) - temp_ad
19338 smag_c_ad(i, j) = 0.0
19343 v_ad(i, j) = v_ad(i, j) + dxc(i, j)*vt_ad(i, j)
19349 u_ad(i, j) = u_ad(i, j) + dyc(i, j)*ut_ad(i, j)
subroutine xtp_u_fwd(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 smag_corner_fwd(dt, u, v, ua, va, smag_c, bd, npx, npy, gridstruct, ng)
subroutine popinteger4(x)
subroutine, public fill_4corners_fwd(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine popcontrol2b(cc)
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
real(kind=kind_real), parameter f0
Coriolis parameter at southern boundary.
subroutine xtp_u_bwd(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u, u_ad, v, flux, flux_ad, iord, dx, rdx, npx, npy, grid_type, nested)
subroutine ytp_v_fwd(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, jord, dy, rdy, npx, npy, grid_type, nested)
subroutine xtp_u(is, ie, js, je, isd, ied, jsd, jed, c, u, v, flux, iord, dx, rdx, npx, npy, grid_type, nested)
subroutine, public c_sw_fwd(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 pushcontrol(ctype, field)
subroutine, public d2a2c_vect_fwd(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, npx, npy, nested, grid_type)
subroutine, public fv_tp_2d_adm(q, q_ad, crx, crx_ad, cry, cry_ad, npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx, xfx_ad, yfx, yfx_ad, gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx, mfx_ad, mfy, mfy_ad, mass, mass_ad, nord, damp_c)
subroutine, public copy_corners(q, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
subroutine ytp_v_adm(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u, v, v_ad, flux, flux_ad, jord, dy, rdy, npx, npy, grid_type, nested)
subroutine compute_divergence_damping_adm(nord, d2_bg, d4_bg, dddmp, dt, vort, vort_ad, ptc, ptc_ad, delpc, delpc_ad, ke, ke_ad, u, u_ad, v, v_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, divg_d, divg_d_ad, wk, wk_ad, gridstruct, flagstruct, bd)
real function edge_interpolate4_fwd(ua, dxa)
subroutine smag_corner_bwd(dt, u, u_ad, v, v_ad, ua, va, smag_c, smag_c_ad, bd, npx, npy, gridstruct, ng)
subroutine, public fv_tp_2d_fwd(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, mfx, mfy, mass, nord, damp_c)
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 pushcontrol1b(cc)
subroutine fill2_4corners_fwd(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public divergence_corner_fwd(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
real, parameter near_zero
subroutine pushcontrol2b(cc)
subroutine, public c_sw_bwd(delpc, delpc_ad, delp, delp_ad, ptc, ptc_ad, pt, pt_ad, u, u_ad, v, v_ad, w, w_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, wc, wc_ad, ut, ut_ad, vt, vt_ad, divg_d, divg_d_ad, nord, dt2, hydrostatic, dord4, bd, gridstruct, flagstruct)
subroutine xtp_u_adm(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u, u_ad, v, flux, flux_ad, iord, dx, rdx, npx, npy, grid_type, nested)
subroutine, public a2b_ord4_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine compute_divergence_damping_fwd(nord, d2_bg, d4_bg, dddmp, dt, vort, ptc, delpc, ke, u, v, uc, vc, ua, va, divg_d, wk, gridstruct, flagstruct, bd)
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)
subroutine compute_divergence_damping_bwd(nord, d2_bg, d4_bg, dddmp, dt, vort, vort_ad, ptc, ptc_ad, delpc, delpc_ad, ke, ke_ad, u, u_ad, v, v_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, divg_d, divg_d_ad, wk, wk_ad, 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)
subroutine smag_corner_adm(dt, u, u_ad, v, v_ad, ua, va, smag_c, smag_c_ad, bd, npx, npy, gridstruct, ng)
subroutine, public d2a2c_vect(u, v, ua, va, uc, vc, ut, vt, dord4, gridstruct, bd, npx, npy, nested, grid_type)
integer, parameter, public ng
subroutine, public del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
subroutine, public divergence_corner_nest_fwd(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
subroutine, public fill_4corners_bwd(q, q_ad, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public divergence_corner_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, divg_d, divg_d_ad, gridstruct, flagstruct, bd)
integer, parameter, public r_grid
subroutine, public fv_tp_2d_bwd(q, q_ad, crx, crx_ad, cry, cry_ad, npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx, xfx_ad, yfx, yfx_ad, gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx, mfx_ad, mfy, mfy_ad, mass, mass_ad, nord, damp_c)
subroutine ytp_v_bwd(is, ie, js, je, isd, ied, jsd, jed, c, c_ad, u, v, v_ad, flux, flux_ad, jord, dy, rdy, npx, npy, grid_type, nested)
subroutine, public divergence_corner_nest(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
subroutine edge_interpolate4_bwd(ua, ua_ad, dxa, edge_interpolate4_ad)
subroutine popcontrol3b(cc)
subroutine popcontrol1b(cc)
subroutine, public d2a2c_vect_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, uc, uc_ad, vc, vc_ad, ut, ut_ad, vt, vt_ad, dord4, gridstruct, bd, npx, npy, nested, grid_type)
subroutine, public d_sw_bwd(delpc, delpc_ad, delp, delp_ad, ptc, ptc_ad, pt, pt_ad, u, u_ad, v, v_ad, w, w_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, divg_d, divg_d_ad, xflux, xflux_ad, yflux, yflux_ad, cx, cx_ad, cy, cy_ad, crx_adv, crx_adv_ad, cry_adv, cry_adv_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, q_con, z_rat, z_rat_ad, kgb, heat_source, heat_source_ad, dpx, dpx_ad, zvir, sphum, nq, q, q_ad, 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, hord_tr_pert, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
subroutine, public a2b_ord4_adm(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine, public pert_ppm_adm(im, a0, al, al_ad, ar, ar_ad, iv)
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, hord_tr_pert, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
subroutine, public d_sw_fwd(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, hord_tr_pert, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
subroutine fill3_4corners(q1, q2, q3, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public copy_corners_adm(q, q_ad, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
real function edge_interpolate4(ua, dxa)
integer, public test_case
subroutine, public divergence_corner(u, v, ua, va, divg_d, gridstruct, flagstruct, bd)
subroutine pushcontrol3b(cc)
subroutine, public divergence_corner_nest_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, divg_d, divg_d_ad, gridstruct, flagstruct, bd)
subroutine compute_divergence_damping(nord, d2_bg, d4_bg, dddmp, dt, vort, ptc, delpc, ke, u, v, uc, vc, ua, va, divg_d, wk, gridstruct, flagstruct, bd)
real, parameter big_number
subroutine, public fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public popcontrol(ctype, field)
Derived type containing the data.
real(kind=kind_real), parameter u2
subroutine fill2_4corners(q1, q2, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine pushinteger4(x)
subroutine, public del6_vt_flux_adm(nord, npx, npy, damp, q, q_ad, d2, d2_ad, fx2, fx2_ad, fy2, fy2_ad, gridstruct, bd)
subroutine, public pert_ppm(im, a0, al, ar, iv)
subroutine, public a2b_ord4_fwd(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine fill2_4corners_bwd(q1, q1_ad, q2, q2_ad, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)