34 real,
parameter::
r3 = 1./3.
38 real,
parameter::
a1 = 0.5625
39 real,
parameter::
a2 = -0.0625
43 real,
parameter::
b1 = 7./12.
44 real,
parameter::
b2 = -1./12.
72 SUBROUTINE a2b_ord4_adm(qin, qin_ad, qout, qout_ad, gridstruct, npx, &
73 & npy, is, ie, js, je, ng, replace)
75 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
77 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
78 REAL,
INTENT(INOUT) :: qin_ad(is-ng:ie+ng, js-ng:je+ng)
80 REAL,
INTENT(INOUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
81 REAL,
INTENT(INOUT) :: qout_ad(is-ng:ie+ng, js-ng:je+ng)
83 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
85 REAL,
PARAMETER :: c1=2./3.
86 REAL,
PARAMETER :: c2=-(1./6.)
90 REAL :: qx(is:ie+1, js-ng:je+ng)
91 REAL :: qx_ad(is:ie+1, js-ng:je+ng)
92 REAL :: qy(is-ng:ie+ng, js:je+1)
93 REAL :: qy_ad(is-ng:ie+ng, js:je+1)
94 REAL :: qxx(is-ng:ie+ng, js-ng:je+ng)
95 REAL :: qxx_ad(is-ng:ie+ng, js-ng:je+ng)
96 REAL :: qyy(is-ng:ie+ng, js-ng:je+ng)
97 REAL :: qyy_ad(is-ng:ie+ng, js-ng:je+ng)
100 REAL :: q1(is-1:ie+1), q2(js-1:je+1)
101 REAL :: q1_ad(is-1:ie+1), q2_ad(js-1:je+1)
102 INTEGER :: i, j, is1, js1, is2, js2, ie1, je1
103 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
104 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
105 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
184 edge_w => gridstruct%edge_w
185 edge_e => gridstruct%edge_e
186 edge_s => gridstruct%edge_s
187 edge_n => gridstruct%edge_n
188 agrid => gridstruct%agrid
189 grid => gridstruct%grid
190 dxa => gridstruct%dxa
191 dya => gridstruct%dya
192 IF (gridstruct%grid_type .LT. 3)
THEN 193 IF (1 .LT. is - 1)
THEN 198 IF (1 .LT. js - 1)
THEN 213 IF (npx - 1 .GT. ie + 1)
THEN 218 IF (npy - 1 .GT. je + 1)
THEN 225 IF (gridstruct%nested)
THEN 228 IF (gridstruct%sw_corner)
THEN 233 IF (gridstruct%se_corner)
THEN 238 IF (gridstruct%ne_corner)
THEN 243 IF (gridstruct%nw_corner)
THEN 244 p0(1:2) = grid(1, npy, 1:2)
249 IF (1 .LT. js - 2)
THEN 254 IF (npy - 1 .GT. je + 2)
THEN 268 IF (npx - 2 .GT. ie + 1)
THEN 280 IF (1 .LT. js - 2)
THEN 285 IF (npy - 1 .GT. je + 2)
THEN 295 IF (ie + 1 .EQ. npx)
THEN 296 IF (1 .LT. js - 2)
THEN 301 IF (npy - 1 .GT. je + 2)
THEN 314 IF (gridstruct%nested)
THEN 322 IF (npy - 2 .GT. je + 1)
THEN 328 IF (1 .LT. is - 2)
THEN 333 IF (npx - 1 .GT. ie + 2)
THEN 345 IF (1 .LT. is - 2)
THEN 350 IF (npx - 1 .GT. ie + 2)
THEN 360 IF (je + 1 .EQ. npy)
THEN 361 IF (1 .LT. is - 2)
THEN 366 IF (npx - 1 .GT. ie + 2)
THEN 377 IF (gridstruct%nested)
THEN 385 IF (npy - 2 .GT. je + 1)
THEN 396 IF (npx - 1 .GT. ie + 1)
THEN 412 IF (npx - 1 .GT. ie + 1)
THEN 421 IF (je + 1 .EQ. npy)
THEN 427 IF (npx - 1 .GT. ie + 1)
THEN 441 IF (npy - 1 .GT. je + 1)
THEN 452 IF (npx - 2 .GT. ie + 1)
THEN 466 IF (ie + 1 .EQ. npx)
THEN 476 IF (npx - 1 .GT. ie + 1)
THEN 491 IF (
PRESENT(replace))
THEN 495 qout_ad(i, j) = qout_ad(i, j) + qin_ad(i, j)
502 IF (branch .EQ. 0)
THEN 508 qxx_ad(i, j) = qxx_ad(i, j) + 0.5*qout_ad(i, j)
509 qyy_ad(i, j) = qyy_ad(i, j) + 0.5*qout_ad(i, j)
513 qy_ad(i-2, j) = qy_ad(i-2, j) +
a2*qyy_ad(i, j)
514 qy_ad(i+1, j) = qy_ad(i+1, j) +
a2*qyy_ad(i, j)
515 qy_ad(i-1, j) = qy_ad(i-1, j) +
a1*qyy_ad(i, j)
516 qy_ad(i, j) = qy_ad(i, j) +
a1*qyy_ad(i, j)
523 qx_ad(i, j-2) = qx_ad(i, j-2) +
a2*qxx_ad(i, j)
524 qx_ad(i, j+1) = qx_ad(i, j+1) +
a2*qxx_ad(i, j)
525 qx_ad(i, j-1) = qx_ad(i, j-1) +
a1*qxx_ad(i, j)
526 qx_ad(i, j) = qx_ad(i, j) +
a1*qxx_ad(i, j)
530 ELSE IF (branch .EQ. 1)
THEN 537 DO i=ad_to3,ad_from3,-1
538 qxx_ad(i, j) = qxx_ad(i, j) + 0.5*qout_ad(i, j)
539 qyy_ad(i, j) = qyy_ad(i, j) + 0.5*qout_ad(i, j)
543 IF (branch .NE. 0)
THEN 544 qy_ad(npx-2, j) = qy_ad(npx-2, j) + c1*qyy_ad(npx-1, j)
545 qy_ad(npx-1, j) = qy_ad(npx-1, j) + c1*qyy_ad(npx-1, j)
546 qout_ad(npx, j) = qout_ad(npx, j) + c2*qyy_ad(npx-1, j)
547 qyy_ad(npx-2, j) = qyy_ad(npx-2, j) + c2*qyy_ad(npx-1, j)
548 qyy_ad(npx-1, j) = 0.0
551 IF (branch .EQ. 0)
THEN 552 qy_ad(1, j) = qy_ad(1, j) + c1*qyy_ad(2, j)
553 qy_ad(2, j) = qy_ad(2, j) + c1*qyy_ad(2, j)
554 qout_ad(1, j) = qout_ad(1, j) + c2*qyy_ad(2, j)
555 qyy_ad(3, j) = qyy_ad(3, j) + c2*qyy_ad(2, j)
560 DO i=ad_to2,ad_from2,-1
561 qy_ad(i-2, j) = qy_ad(i-2, j) +
a2*qyy_ad(i, j)
562 qy_ad(i+1, j) = qy_ad(i+1, j) +
a2*qyy_ad(i, j)
563 qy_ad(i-1, j) = qy_ad(i-1, j) +
a1*qyy_ad(i, j)
564 qy_ad(i, j) = qy_ad(i, j) +
a1*qyy_ad(i, j)
569 IF (branch .EQ. 0)
THEN 574 qx_ad(i, npy-2) = qx_ad(i, npy-2) + c1*qxx_ad(i, npy-1)
575 qx_ad(i, npy-1) = qx_ad(i, npy-1) + c1*qxx_ad(i, npy-1)
576 qout_ad(i, npy) = qout_ad(i, npy) + c2*qxx_ad(i, npy-1)
577 qxx_ad(i, npy-2) = qxx_ad(i, npy-2) + c2*qxx_ad(i, npy-1)
578 qxx_ad(i, npy-1) = 0.0
582 IF (branch .EQ. 0)
THEN 584 qx_ad(i, 1) = qx_ad(i, 1) + c1*qxx_ad(i, 2)
585 qx_ad(i, 2) = qx_ad(i, 2) + c1*qxx_ad(i, 2)
586 qout_ad(i, 1) = qout_ad(i, 1) + c2*qxx_ad(i, 2)
587 qxx_ad(i, 3) = qxx_ad(i, 3) + c2*qxx_ad(i, 2)
594 DO i=ad_to1,ad_from1,-1
595 qx_ad(i, j-2) = qx_ad(i, j-2) +
a2*qxx_ad(i, j)
596 qx_ad(i, j+1) = qx_ad(i, j+1) +
a2*qxx_ad(i, j)
597 qx_ad(i, j-1) = qx_ad(i, j-1) +
a1*qxx_ad(i, j)
598 qx_ad(i, j) = qx_ad(i, j) +
a1*qxx_ad(i, j)
607 temp_ad23 = 0.5*qout_ad(i, j)
608 temp_ad24 =
a1*temp_ad23
609 temp_ad25 =
a2*temp_ad23
610 qx_ad(i, j-1) = qx_ad(i, j-1) + temp_ad24
611 qx_ad(i, j) = qx_ad(i, j) + temp_ad24
612 qy_ad(i-1, j) = qy_ad(i-1, j) + temp_ad24
613 qy_ad(i, j) = qy_ad(i, j) + temp_ad24
614 qx_ad(i, j-2) = qx_ad(i, j-2) + temp_ad25
615 qx_ad(i, j+1) = qx_ad(i, j+1) + temp_ad25
616 qy_ad(i-2, j) = qy_ad(i-2, j) + temp_ad25
617 qy_ad(i+1, j) = qy_ad(i+1, j) + temp_ad25
623 qin_ad(i, j-1) = qin_ad(i, j-1) +
b1*qy_ad(i, j)
624 qin_ad(i, j) = qin_ad(i, j) +
b1*qy_ad(i, j)
625 qin_ad(i, j-2) = qin_ad(i, j-2) +
b2*qy_ad(i, j)
626 qin_ad(i, j+1) = qin_ad(i, j+1) +
b2*qy_ad(i, j)
632 qin_ad(i-1, j) = qin_ad(i-1, j) +
b1*qx_ad(i, j)
633 qin_ad(i, j) = qin_ad(i, j) +
b1*qx_ad(i, j)
634 qin_ad(i-2, j) = qin_ad(i-2, j) +
b2*qx_ad(i, j)
635 qin_ad(i+1, j) = qin_ad(i+1, j) +
b2*qx_ad(i, j)
642 IF (branch .EQ. 0)
THEN 645 qin_ad(i, j-2) = qin_ad(i, j-2) +
b2*qy_ad(i, j)
646 qin_ad(i, j+1) = qin_ad(i, j+1) +
b2*qy_ad(i, j)
647 qin_ad(i, j-1) = qin_ad(i, j-1) +
b1*qy_ad(i, j)
648 qin_ad(i, j) = qin_ad(i, j) +
b1*qy_ad(i, j)
653 IF (branch .EQ. 1)
THEN 655 g_in = dya(i, npy-2)/dya(i, npy-1)
656 temp_ad19 = qy_ad(i, npy-1)/(g_in*2.+2.)
657 qin_ad(i, npy-2) = qin_ad(i, npy-2) + 3.*temp_ad19
658 qy_ad(i, npy) = qy_ad(i, npy) - g_in*temp_ad19
659 qy_ad(i, npy-2) = qy_ad(i, npy-2) - temp_ad19
660 qy_ad(i, npy-1) = 0.0
661 g_ou = dya(i, npy+1)/dya(i, npy)
662 temp_ad21 = 0.5*qy_ad(i, npy)
663 temp_ad20 = temp_ad21/(g_in+1.)
664 qin_ad(i, npy-1) = qin_ad(i, npy-1) + (g_in+2.)*temp_ad20 + 3.&
666 temp_ad22 = temp_ad21/(g_ou+1.)
667 qin_ad(i, npy-2) = qin_ad(i, npy-2) - temp_ad20
668 qin_ad(i, npy) = qin_ad(i, npy) + (g_ou+2.)*temp_ad22
669 qin_ad(i, npy+1) = qin_ad(i, npy+1) - temp_ad22
674 q1_ad(i-1) = q1_ad(i-1) + edge_n(i)*qout_ad(i, npy)
675 q1_ad(i) = q1_ad(i) + (1.-edge_n(i))*qout_ad(i, npy)
676 qout_ad(i, npy) = 0.0
679 temp_ad18 = q1_ad(i)/(dya(i, npy-1)+dya(i, npy))
680 qin_ad(i, npy-1) = qin_ad(i, npy-1) + dya(i, npy)*temp_ad18
681 qin_ad(i, npy) = qin_ad(i, npy) + dya(i, npy-1)*temp_ad18
688 IF (branch .EQ. 0)
THEN 690 g_in = dya(i, 2)/dya(i, 1)
691 temp_ad14 = qy_ad(i, 2)/(g_in*2.+2.)
692 qin_ad(i, 1) = qin_ad(i, 1) + 3.*g_in*temp_ad14
693 qin_ad(i, 2) = qin_ad(i, 2) + 3.*temp_ad14
694 qy_ad(i, 1) = qy_ad(i, 1) - g_in*temp_ad14
695 qy_ad(i, 3) = qy_ad(i, 3) - temp_ad14
697 g_ou = dya(i, -1)/dya(i, 0)
698 temp_ad15 = 0.5*qy_ad(i, 1)
699 temp_ad16 = temp_ad15/(g_in+1.)
700 temp_ad17 = temp_ad15/(g_ou+1.)
701 qin_ad(i, 1) = qin_ad(i, 1) + (g_in+2.)*temp_ad16
702 qin_ad(i, 2) = qin_ad(i, 2) - temp_ad16
703 qin_ad(i, 0) = qin_ad(i, 0) + (g_ou+2.)*temp_ad17
704 qin_ad(i, -1) = qin_ad(i, -1) - temp_ad17
708 q1_ad(i-1) = q1_ad(i-1) + edge_s(i)*qout_ad(i, 1)
709 q1_ad(i) = q1_ad(i) + (1.-edge_s(i))*qout_ad(i, 1)
713 temp_ad13 = q1_ad(i)/(dya(i, 0)+dya(i, 1))
714 qin_ad(i, 0) = qin_ad(i, 0) + dya(i, 1)*temp_ad13
715 qin_ad(i, 1) = qin_ad(i, 1) + dya(i, 0)*temp_ad13
722 DO i=ad_to0,ad_from0,-1
723 qin_ad(i, j-2) = qin_ad(i, j-2) +
b2*qy_ad(i, j)
724 qin_ad(i, j+1) = qin_ad(i, j+1) +
b2*qy_ad(i, j)
725 qin_ad(i, j-1) = qin_ad(i, j-1) +
b1*qy_ad(i, j)
726 qin_ad(i, j) = qin_ad(i, j) +
b1*qy_ad(i, j)
732 IF (branch .EQ. 0)
THEN 735 qin_ad(i-2, j) = qin_ad(i-2, j) +
b2*qx_ad(i, j)
736 qin_ad(i+1, j) = qin_ad(i+1, j) +
b2*qx_ad(i, j)
737 qin_ad(i-1, j) = qin_ad(i-1, j) +
b1*qx_ad(i, j)
738 qin_ad(i, j) = qin_ad(i, j) +
b1*qx_ad(i, j)
743 IF (branch .EQ. 1)
THEN 745 g_in = dxa(npx-2, j)/dxa(npx-1, j)
746 temp_ad9 = qx_ad(npx-1, j)/(g_in*2.+2.)
747 qin_ad(npx-2, j) = qin_ad(npx-2, j) + 3.*temp_ad9
748 qx_ad(npx, j) = qx_ad(npx, j) - g_in*temp_ad9
749 qx_ad(npx-2, j) = qx_ad(npx-2, j) - temp_ad9
750 qx_ad(npx-1, j) = 0.0
751 g_ou = dxa(npx+1, j)/dxa(npx, j)
752 temp_ad11 = 0.5*qx_ad(npx, j)
753 temp_ad10 = temp_ad11/(g_in+1.)
754 qin_ad(npx-1, j) = qin_ad(npx-1, j) + (g_in+2.)*temp_ad10 + 3.&
756 temp_ad12 = temp_ad11/(g_ou+1.)
757 qin_ad(npx-2, j) = qin_ad(npx-2, j) - temp_ad10
758 qin_ad(npx, j) = qin_ad(npx, j) + (g_ou+2.)*temp_ad12
759 qin_ad(npx+1, j) = qin_ad(npx+1, j) - temp_ad12
764 q2_ad(j-1) = q2_ad(j-1) + edge_e(j)*qout_ad(npx, j)
765 q2_ad(j) = q2_ad(j) + (1.-edge_e(j))*qout_ad(npx, j)
766 qout_ad(npx, j) = 0.0
769 temp_ad8 = q2_ad(j)/(dxa(npx-1, j)+dxa(npx, j))
770 qin_ad(npx-1, j) = qin_ad(npx-1, j) + dxa(npx, j)*temp_ad8
771 qin_ad(npx, j) = qin_ad(npx, j) + dxa(npx-1, j)*temp_ad8
778 IF (branch .EQ. 0)
THEN 780 g_in = dxa(2, j)/dxa(1, j)
781 temp_ad4 = qx_ad(2, j)/(g_in*2.+2.)
782 qin_ad(1, j) = qin_ad(1, j) + 3.*g_in*temp_ad4
783 qin_ad(2, j) = qin_ad(2, j) + 3.*temp_ad4
784 qx_ad(1, j) = qx_ad(1, j) - g_in*temp_ad4
785 qx_ad(3, j) = qx_ad(3, j) - temp_ad4
787 g_ou = dxa(-1, j)/dxa(0, j)
788 temp_ad5 = 0.5*qx_ad(1, j)
789 temp_ad6 = temp_ad5/(g_in+1.)
790 temp_ad7 = temp_ad5/(g_ou+1.)
791 qin_ad(1, j) = qin_ad(1, j) + (g_in+2.)*temp_ad6
792 qin_ad(2, j) = qin_ad(2, j) - temp_ad6
793 qin_ad(0, j) = qin_ad(0, j) + (g_ou+2.)*temp_ad7
794 qin_ad(-1, j) = qin_ad(-1, j) - temp_ad7
798 q2_ad(j-1) = q2_ad(j-1) + edge_w(j)*qout_ad(1, j)
799 q2_ad(j) = q2_ad(j) + (1.-edge_w(j))*qout_ad(1, j)
803 temp_ad3 = q2_ad(j)/(dxa(0, j)+dxa(1, j))
804 qin_ad(0, j) = qin_ad(0, j) + dxa(1, j)*temp_ad3
805 qin_ad(1, j) = qin_ad(1, j) + dxa(0, j)*temp_ad3
812 DO i=ad_to,ad_from,-1
813 qin_ad(i-2, j) = qin_ad(i-2, j) +
b2*qx_ad(i, j)
814 qin_ad(i+1, j) = qin_ad(i+1, j) +
b2*qx_ad(i, j)
815 qin_ad(i-1, j) = qin_ad(i-1, j) +
b1*qx_ad(i, j)
816 qin_ad(i, j) = qin_ad(i, j) +
b1*qx_ad(i, j)
821 IF (branch .NE. 0)
THEN 822 temp_ad2 =
r3*qout_ad(1, npy)
823 result1_ad = temp_ad2
824 result2_ad = temp_ad2
825 result3_ad = temp_ad2
826 qout_ad(1, npy) = 0.0
828 & :2), qin(1, npy), qin_ad(1, npy), qin(2, npy+1)&
829 & , qin_ad(2, npy+1), result3_ad)
831 & , 1:2), qin(0, npy-1), qin_ad(0, npy-1), qin(-1&
832 & , npy-2), qin_ad(-1, npy-2), result2_ad)
834 & , 1:2), qin(1, npy-1), qin_ad(1, npy-1), qin(2&
835 & , npy-2), qin_ad(2, npy-2), result1_ad)
838 IF (branch .EQ. 0)
THEN 839 temp_ad1 =
r3*qout_ad(npx, npy)
840 result1_ad = temp_ad1
841 result2_ad = temp_ad1
842 result3_ad = temp_ad1
843 qout_ad(npx, npy) = 0.0
844 p0(1:2) = grid(npx, npy, 1:2)
846 & npy+1, 1:2), qin(npx-1, npy), qin_ad(npx-1, npy&
847 & ), qin(npx-2, npy+1), qin_ad(npx-2, npy+1), &
850 & npy-2, 1:2), qin(npx, npy-1), qin_ad(npx, npy-1&
851 & ), qin(npx+1, npy-2), qin_ad(npx+1, npy-2), &
854 & , npy-2, 1:2), qin(npx-1, npy-1), qin_ad(npx-1&
855 & , npy-1), qin(npx-2, npy-2), qin_ad(npx-2, npy-&
859 IF (branch .EQ. 0)
THEN 860 temp_ad0 =
r3*qout_ad(npx, 1)
861 result1_ad = temp_ad0
862 result2_ad = temp_ad0
863 result3_ad = temp_ad0
864 qout_ad(npx, 1) = 0.0
865 p0(1:2) = grid(npx, 1, 1:2)
867 & :2), qin(npx, 1), qin_ad(npx, 1), qin(npx+1, 2)&
868 & , qin_ad(npx+1, 2), result3_ad)
870 & , 1:2), qin(npx-1, 0), qin_ad(npx-1, 0), qin(&
871 & npx-2, -1), qin_ad(npx-2, -1), result2_ad)
873 & , 1:2), qin(npx-1, 1), qin_ad(npx-1, 1), qin(&
874 & npx-2, 2), qin_ad(npx-2, 2), result1_ad)
877 IF (branch .EQ. 0)
THEN 878 temp_ad =
r3*qout_ad(1, 1)
882 p0(1:2) = grid(1, 1, 1:2)
884 & qin(1, 0), qin_ad(1, 0), qin(2, -1), qin_ad(2, &
887 & qin(0, 1), qin_ad(0, 1), qin(-1, 2), qin_ad(-1&
890 & qin(1, 1), qin_ad(1, 1), qin(2, 2), qin_ad(2, 2&
896 SUBROUTINE a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, &
899 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
901 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
903 REAL,
INTENT(INOUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
905 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
907 REAL,
PARAMETER :: c1=2./3.
908 REAL,
PARAMETER :: c2=-(1./6.)
912 REAL :: qx(is:ie+1, js-ng:je+ng)
913 REAL :: qy(is-ng:ie+ng, js:je+1)
914 REAL :: qxx(is-ng:ie+ng, js-ng:je+ng)
915 REAL :: qyy(is-ng:ie+ng, js-ng:je+ng)
918 REAL :: q1(is-1:ie+1), q2(js-1:je+1)
919 INTEGER :: i, j, is1, js1, is2, js2, ie1, je1
920 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
921 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
922 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
960 edge_w => gridstruct%edge_w
961 edge_e => gridstruct%edge_e
962 edge_s => gridstruct%edge_s
963 edge_n => gridstruct%edge_n
964 grid => gridstruct%grid
965 agrid => gridstruct%agrid
966 dxa => gridstruct%dxa
967 dya => gridstruct%dya
968 IF (gridstruct%grid_type .LT. 3)
THEN 969 IF (1 .LT. is - 1)
THEN 974 IF (1 .LT. js - 1)
THEN 989 IF (npx - 1 .GT. ie + 1)
THEN 994 IF (npy - 1 .GT. je + 1)
THEN 1001 IF (gridstruct%nested)
THEN 1004 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
1009 IF (gridstruct%sw_corner)
THEN 1010 p0(1:2) = grid(1, 1, 1:2)
1011 result1 =
extrap_corner(p0, agrid(1, 1, 1:2), agrid(2, 2, 1:2)&
1012 & , qin(1, 1), qin(2, 2))
1013 result2 =
extrap_corner(p0, agrid(0, 1, 1:2), agrid(-1, 2, 1:2&
1014 & ), qin(0, 1), qin(-1, 2))
1015 result3 =
extrap_corner(p0, agrid(1, 0, 1:2), agrid(2, -1, 1:2&
1016 & ), qin(1, 0), qin(2, -1))
1017 qout(1, 1) = (result1+result2+result3)*
r3 1019 IF (gridstruct%se_corner)
THEN 1020 p0(1:2) = grid(npx, 1, 1:2)
1021 result1 =
extrap_corner(p0, agrid(npx-1, 1, 1:2), agrid(npx-2&
1022 & , 2, 1:2), qin(npx-1, 1), qin(npx-2, 2))
1023 result2 =
extrap_corner(p0, agrid(npx-1, 0, 1:2), agrid(npx-2&
1024 & , -1, 1:2), qin(npx-1, 0), qin(npx-2, -1))
1025 result3 =
extrap_corner(p0, agrid(npx, 1, 1:2), agrid(npx+1, 2&
1026 & , 1:2), qin(npx, 1), qin(npx+1, 2))
1027 qout(npx, 1) = (result1+result2+result3)*
r3 1029 IF (gridstruct%ne_corner)
THEN 1030 p0(1:2) = grid(npx, npy, 1:2)
1031 result1 =
extrap_corner(p0, agrid(npx-1, npy-1, 1:2), agrid(&
1032 & npx-2, npy-2, 1:2), qin(npx-1, npy-1), qin(npx-2, npy-2))
1033 result2 =
extrap_corner(p0, agrid(npx, npy-1, 1:2), agrid(npx+&
1034 & 1, npy-2, 1:2), qin(npx, npy-1), qin(npx+1, npy-2))
1035 result3 =
extrap_corner(p0, agrid(npx-1, npy, 1:2), agrid(npx-&
1036 & 2, npy+1, 1:2), qin(npx-1, npy), qin(npx-2, npy+1))
1037 qout(npx, npy) = (result1+result2+result3)*
r3 1039 IF (gridstruct%nw_corner)
THEN 1040 p0(1:2) = grid(1, npy, 1:2)
1041 result1 =
extrap_corner(p0, agrid(1, npy-1, 1:2), agrid(2, npy&
1042 & -2, 1:2), qin(1, npy-1), qin(2, npy-2))
1043 result2 =
extrap_corner(p0, agrid(0, npy-1, 1:2), agrid(-1, &
1044 & npy-2, 1:2), qin(0, npy-1), qin(-1, npy-2))
1045 result3 =
extrap_corner(p0, agrid(1, npy, 1:2), agrid(2, npy+1&
1046 & , 1:2), qin(1, npy), qin(2, npy+1))
1047 qout(1, npy) = (result1+result2+result3)*
r3 1049 IF (1 .LT. js - 2)
THEN 1054 IF (npy - 1 .GT. je + 2)
THEN 1068 IF (npx - 2 .GT. ie + 1)
THEN 1074 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
1081 q2(j) = (qin(0, j)*dxa(1, j)+qin(1, j)*dxa(0, j))/(dxa(0, j)&
1085 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
1087 IF (1 .LT. js - 2)
THEN 1092 IF (npy - 1 .GT. je + 2)
THEN 1099 g_in = dxa(2, j)/dxa(1, j)
1100 g_ou = dxa(-1, j)/dxa(0, j)
1101 qx(1, j) = 0.5*(((2.+g_in)*qin(1, j)-qin(2, j))/(1.+g_in)+((&
1102 & 2.+g_ou)*qin(0, j)-qin(-1, j))/(1.+g_ou))
1103 qx(2, j) = (3.*(g_in*qin(1, j)+qin(2, j))-(g_in*qx(1, j)+qx(&
1104 & 3, j)))/(2.+2.*g_in)
1108 IF (ie + 1 .EQ. npx)
THEN 1110 q2(j) = (qin(npx-1, j)*dxa(npx, j)+qin(npx, j)*dxa(npx-1, j)&
1111 & )/(dxa(npx-1, j)+dxa(npx, j))
1114 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
1116 IF (1 .LT. js - 2)
THEN 1121 IF (npy - 1 .GT. je + 2)
THEN 1128 g_in = dxa(npx-2, j)/dxa(npx-1, j)
1129 g_ou = dxa(npx+1, j)/dxa(npx, j)
1130 qx(npx, j) = 0.5*(((2.+g_in)*qin(npx-1, j)-qin(npx-2, j))/(&
1131 & 1.+g_in)+((2.+g_ou)*qin(npx, j)-qin(npx+1, j))/(1.+g_ou))
1132 qx(npx-1, j) = (3.*(qin(npx-2, j)+g_in*qin(npx-1, j))-(g_in*&
1133 & qx(npx, j)+qx(npx-2, j)))/(2.+2.*g_in)
1140 IF (gridstruct%nested)
THEN 1143 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
1153 IF (npy - 2 .GT. je + 1)
THEN 1159 IF (1 .LT. is - 2)
THEN 1164 IF (npx - 1 .GT. ie + 2)
THEN 1170 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
1177 q1(i) = (qin(i, 0)*dya(i, 1)+qin(i, 1)*dya(i, 0))/(dya(i, 0)&
1181 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
1183 IF (1 .LT. is - 2)
THEN 1188 IF (npx - 1 .GT. ie + 2)
THEN 1195 g_in = dya(i, 2)/dya(i, 1)
1196 g_ou = dya(i, -1)/dya(i, 0)
1197 qy(i, 1) = 0.5*(((2.+g_in)*qin(i, 1)-qin(i, 2))/(1.+g_in)+((&
1198 & 2.+g_ou)*qin(i, 0)-qin(i, -1))/(1.+g_ou))
1199 qy(i, 2) = (3.*(g_in*qin(i, 1)+qin(i, 2))-(g_in*qy(i, 1)+qy(&
1200 & i, 3)))/(2.+2.*g_in)
1204 IF (je + 1 .EQ. npy)
THEN 1206 q1(i) = (qin(i, npy-1)*dya(i, npy)+qin(i, npy)*dya(i, npy-1)&
1207 & )/(dya(i, npy-1)+dya(i, npy))
1210 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
1212 IF (1 .LT. is - 2)
THEN 1217 IF (npx - 1 .GT. ie + 2)
THEN 1224 g_in = dya(i, npy-2)/dya(i, npy-1)
1225 g_ou = dya(i, npy+1)/dya(i, npy)
1226 qy(i, npy) = 0.5*(((2.+g_in)*qin(i, npy-1)-qin(i, npy-2))/(&
1227 & 1.+g_in)+((2.+g_ou)*qin(i, npy)-qin(i, npy+1))/(1.+g_ou))
1228 qy(i, npy-1) = (3.*(qin(i, npy-2)+g_in*qin(i, npy-1))-(g_in*&
1229 & qy(i, npy)+qy(i, npy-2)))/(2.+2.*g_in)
1234 IF (gridstruct%nested)
THEN 1237 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
1243 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
1248 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
1257 IF (npy - 2 .GT. je + 1)
THEN 1268 IF (npx - 1 .GT. ie + 1)
THEN 1274 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
1284 IF (npx - 1 .GT. ie + 1)
THEN 1290 qxx(i, 2) = c1*(qx(i, 1)+qx(i, 2)) + c2*(qout(i, 1)+qxx(i, 3&
1294 IF (je + 1 .EQ. npy)
THEN 1300 IF (npx - 1 .GT. ie + 1)
THEN 1306 qxx(i, npy-1) = c1*(qx(i, npy-2)+qx(i, npy-1)) + c2*(qout(i&
1307 & , npy)+qxx(i, npy-2))
1315 IF (npy - 1 .GT. je + 1)
THEN 1326 IF (npx - 2 .GT. ie + 1)
THEN 1332 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
1335 IF (is .EQ. 1) qyy(2, j) = c1*(qy(1, j)+qy(2, j)) + c2*(qout(1&
1337 IF (ie + 1 .EQ. npx) qyy(npx-1, j) = c1*(qy(npx-2, j)+qy(npx-1&
1338 & , j)) + c2*(qout(npx, j)+qyy(npx-2, j))
1344 IF (npx - 1 .GT. ie + 1)
THEN 1351 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
1363 qx(i, j) =
b1*(qin(i-1, j)+qin(i, j)) +
b2*(qin(i-2, j)+qin(i+&
1370 qy(i, j) =
b1*(qin(i, j-1)+qin(i, j)) +
b2*(qin(i, j-2)+qin(i&
1376 qout(i, j) = 0.5*(
a1*(qx(i, j-1)+qx(i, j)+qy(i-1, j)+qy(i, j))&
1377 & +
a2*(qx(i, j-2)+qx(i, j+1)+qy(i-2, j)+qy(i+1, j)))
1381 IF (
PRESENT(replace))
THEN 1385 qin(i, j) = qout(i, j)
1411 SUBROUTINE a2b_ord4_fwd(qin, qout, gridstruct, npx, npy, is, ie, js&
1412 & , je, ng, replace)
1416 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
1418 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
1420 REAL,
INTENT(INOUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
1422 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
1424 REAL,
PARAMETER :: c1=2./3.
1425 REAL,
PARAMETER :: c2=-(1./6.)
1429 REAL :: qx(is:ie+1, js-ng:je+ng)
1430 REAL :: qy(is-ng:ie+ng, js:je+1)
1431 REAL :: qxx(is-ng:ie+ng, js-ng:je+ng)
1432 REAL :: qyy(is-ng:ie+ng, js-ng:je+ng)
1435 REAL :: q1(is-1:ie+1), q2(js-1:je+1)
1436 INTEGER :: i, j, is1, js1, is2, js2, ie1, je1
1437 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
1438 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
1439 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
1539 edge_w => gridstruct%edge_w
1540 edge_e => gridstruct%edge_e
1541 edge_s => gridstruct%edge_s
1542 edge_n => gridstruct%edge_n
1543 grid => gridstruct%grid
1544 agrid => gridstruct%agrid
1545 dxa => gridstruct%dxa
1546 dya => gridstruct%dya
1547 IF (gridstruct%grid_type .LT. 3)
THEN 1548 IF (1 .LT. is - 1)
THEN 1553 IF (1 .LT. js - 1)
THEN 1568 IF (npx - 1 .GT. ie + 1)
THEN 1573 IF (npy - 1 .GT. je + 1)
THEN 1580 IF (gridstruct%nested)
THEN 1583 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
1589 IF (gridstruct%sw_corner)
THEN 1590 p0(1:2) = grid(1, 1, 1:2)
1592 & 2, 1:2), qin(1, 1), qin(2, 2))
1594 & , 2, 1:2), qin(0, 1), qin(-1, 2))
1596 & -1, 1:2), qin(1, 0), qin(2, -1))
1598 qout(1, 1) = (result1+result2+result3)*
r3 1603 IF (gridstruct%se_corner)
THEN 1604 p0(1:2) = grid(npx, 1, 1:2)
1606 & (npx-2, 2, 1:2), qin(npx-1, 1), qin(npx-2, 2))
1608 & (npx-2, -1, 1:2), qin(npx-1, 0), qin(npx-2, -1))
1610 & npx+1, 2, 1:2), qin(npx, 1), qin(npx+1, 2))
1612 qout(npx, 1) = (result1+result2+result3)*
r3 1617 IF (gridstruct%ne_corner)
THEN 1618 p0(1:2) = grid(npx, npy, 1:2)
1620 & agrid(npx-2, npy-2, 1:2), qin(npx-1, npy-1), qin(npx-2, npy-&
1623 & agrid(npx+1, npy-2, 1:2), qin(npx, npy-1), qin(npx+1, npy-2)&
1626 & agrid(npx-2, npy+1, 1:2), qin(npx-1, npy), qin(npx-2, npy+1)&
1629 qout(npx, npy) = (result1+result2+result3)*
r3 1634 IF (gridstruct%nw_corner)
THEN 1635 p0(1:2) = grid(1, npy, 1:2)
1637 & (2, npy-2, 1:2), qin(1, npy-1), qin(2, npy-2))
1639 & (-1, npy-2, 1:2), qin(0, npy-1), qin(-1, npy-2))
1641 & , npy+1, 1:2), qin(1, npy), qin(2, npy+1))
1643 qout(1, npy) = (result1+result2+result3)*
r3 1648 IF (1 .LT. js - 2)
THEN 1653 IF (npy - 1 .GT. je + 2)
THEN 1667 IF (npx - 2 .GT. ie + 1)
THEN 1674 qx(i, j) =
b2*(qin(i-2, j)+qin(i+1, j)) +
b1*(qin(i-1, j)+&
1683 q2(j) = (qin(0, j)*dxa(1, j)+qin(1, j)*dxa(0, j))/(dxa(0, j)&
1688 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
1690 IF (1 .LT. js - 2)
THEN 1695 IF (npy - 1 .GT. je + 2)
THEN 1702 g_in = dxa(2, j)/dxa(1, j)
1703 g_ou = dxa(-1, j)/dxa(0, j)
1704 qx(1, j) = 0.5*(((2.+g_in)*qin(1, j)-qin(2, j))/(1.+g_in)+((&
1705 & 2.+g_ou)*qin(0, j)-qin(-1, j))/(1.+g_ou))
1706 qx(2, j) = (3.*(g_in*qin(1, j)+qin(2, j))-(g_in*qx(1, j)+qx(&
1707 & 3, j)))/(2.+2.*g_in)
1714 IF (ie + 1 .EQ. npx)
THEN 1716 q2(j) = (qin(npx-1, j)*dxa(npx, j)+qin(npx, j)*dxa(npx-1, j)&
1717 & )/(dxa(npx-1, j)+dxa(npx, j))
1721 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
1723 IF (1 .LT. js - 2)
THEN 1728 IF (npy - 1 .GT. je + 2)
THEN 1735 g_in = dxa(npx-2, j)/dxa(npx-1, j)
1736 g_ou = dxa(npx+1, j)/dxa(npx, j)
1737 qx(npx, j) = 0.5*(((2.+g_in)*qin(npx-1, j)-qin(npx-2, j))/(&
1738 & 1.+g_in)+((2.+g_ou)*qin(npx, j)-qin(npx+1, j))/(1.+g_ou))
1739 qx(npx-1, j) = (3.*(qin(npx-2, j)+g_in*qin(npx-1, j))-(g_in*&
1740 & qx(npx, j)+qx(npx-2, j)))/(2.+2.*g_in)
1750 IF (gridstruct%nested)
THEN 1753 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
1764 IF (npy - 2 .GT. je + 1)
THEN 1770 IF (1 .LT. is - 2)
THEN 1775 IF (npx - 1 .GT. ie + 2)
THEN 1782 qy(i, j) =
b2*(qin(i, j-2)+qin(i, j+1)) +
b1*(qin(i, j-1)+&
1791 q1(i) = (qin(i, 0)*dya(i, 1)+qin(i, 1)*dya(i, 0))/(dya(i, 0)&
1796 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
1798 IF (1 .LT. is - 2)
THEN 1803 IF (npx - 1 .GT. ie + 2)
THEN 1810 g_in = dya(i, 2)/dya(i, 1)
1811 g_ou = dya(i, -1)/dya(i, 0)
1812 qy(i, 1) = 0.5*(((2.+g_in)*qin(i, 1)-qin(i, 2))/(1.+g_in)+((&
1813 & 2.+g_ou)*qin(i, 0)-qin(i, -1))/(1.+g_ou))
1814 qy(i, 2) = (3.*(g_in*qin(i, 1)+qin(i, 2))-(g_in*qy(i, 1)+qy(&
1815 & i, 3)))/(2.+2.*g_in)
1822 IF (je + 1 .EQ. npy)
THEN 1824 q1(i) = (qin(i, npy-1)*dya(i, npy)+qin(i, npy)*dya(i, npy-1)&
1825 & )/(dya(i, npy-1)+dya(i, npy))
1829 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
1831 IF (1 .LT. is - 2)
THEN 1836 IF (npx - 1 .GT. ie + 2)
THEN 1843 g_in = dya(i, npy-2)/dya(i, npy-1)
1844 g_ou = dya(i, npy+1)/dya(i, npy)
1845 qy(i, npy) = 0.5*(((2.+g_in)*qin(i, npy-1)-qin(i, npy-2))/(&
1846 & 1.+g_in)+((2.+g_ou)*qin(i, npy)-qin(i, npy+1))/(1.+g_ou))
1847 qy(i, npy-1) = (3.*(qin(i, npy-2)+g_in*qin(i, npy-1))-(g_in*&
1848 & qy(i, npy)+qy(i, npy-2)))/(2.+2.*g_in)
1856 IF (gridstruct%nested)
THEN 1859 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
1865 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
1871 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
1881 IF (npy - 2 .GT. je + 1)
THEN 1892 IF (npx - 1 .GT. ie + 1)
THEN 1899 qxx(i, j) =
a2*(qx(i, j-2)+qx(i, j+1)) +
a1*(qx(i, j-1)+qx(i&
1911 IF (npx - 1 .GT. ie + 1)
THEN 1917 qxx(i, 2) = c1*(qx(i, 1)+qx(i, 2)) + c2*(qout(i, 1)+qxx(i, 3&
1924 IF (je + 1 .EQ. npy)
THEN 1930 IF (npx - 1 .GT. ie + 1)
THEN 1936 qxx(i, npy-1) = c1*(qx(i, npy-2)+qx(i, npy-1)) + c2*(qout(i&
1937 & , npy)+qxx(i, npy-2))
1948 IF (npy - 1 .GT. je + 1)
THEN 1959 IF (npx - 2 .GT. ie + 1)
THEN 1966 qyy(i, j) =
a2*(qy(i-2, j)+qy(i+1, j)) +
a1*(qy(i-1, j)+qy(i&
1972 qyy(2, j) = c1*(qy(1, j)+qy(2, j)) + c2*(qout(1, j)+qyy(3, j&
1978 IF (ie + 1 .EQ. npx)
THEN 1979 qyy(npx-1, j) = c1*(qy(npx-2, j)+qy(npx-1, j)) + c2*(qout(&
1980 & npx, j)+qyy(npx-2, j))
1990 IF (npx - 1 .GT. ie + 1)
THEN 1999 qout(i, j) = 0.5*(qxx(i, j)+qyy(i, j))
2014 qx(i, j) =
b1*(qin(i-1, j)+qin(i, j)) +
b2*(qin(i-2, j)+qin(i+&
2021 qy(i, j) =
b1*(qin(i, j-1)+qin(i, j)) +
b2*(qin(i, j-2)+qin(i&
2028 qout(i, j) = 0.5*(
a1*(qx(i, j-1)+qx(i, j)+qy(i-1, j)+qy(i, j))&
2029 & +
a2*(qx(i, j-2)+qx(i, j+1)+qy(i-2, j)+qy(i+1, j)))
2034 IF (
PRESENT(replace))
THEN 2039 qin(i, j) = qout(i, j)
2151 SUBROUTINE a2b_ord4_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx&
2152 & , npy, is, ie, js, je, ng, replace)
2156 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
2157 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
2158 REAL,
INTENT(INOUT) :: qin_ad(is-ng:ie+ng, js-ng:je+ng)
2159 REAL,
INTENT(INOUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
2160 REAL,
INTENT(INOUT) :: qout_ad(is-ng:ie+ng, js-ng:je+ng)
2162 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
2163 REAL,
PARAMETER :: c1=2./3.
2164 REAL,
PARAMETER :: c2=-(1./6.)
2165 REAL :: qx(is:ie+1, js-ng:je+ng)
2166 REAL :: qx_ad(is:ie+1, js-ng:je+ng)
2167 REAL :: qy(is-ng:ie+ng, js:je+1)
2168 REAL :: qy_ad(is-ng:ie+ng, js:je+1)
2169 REAL :: qxx(is-ng:ie+ng, js-ng:je+ng)
2170 REAL :: qxx_ad(is-ng:ie+ng, js-ng:je+ng)
2171 REAL :: qyy(is-ng:ie+ng, js-ng:je+ng)
2172 REAL :: qyy_ad(is-ng:ie+ng, js-ng:je+ng)
2175 REAL :: q1(is-1:ie+1), q2(js-1:je+1)
2176 REAL :: q1_ad(is-1:ie+1), q2_ad(js-1:je+1)
2177 INTEGER :: i, j, is1, js1, is2, js2, ie1, je1
2178 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
2179 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
2180 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
2325 IF (branch .EQ. 0)
THEN 2337 agrid => gridstruct%agrid
2354 ELSE IF (branch .EQ. 1)
THEN 2366 agrid => gridstruct%agrid
2395 agrid => gridstruct%agrid
2415 qout_ad(i, j) = qout_ad(i, j) + qin_ad(i, j)
2421 IF (branch .EQ. 0)
THEN 2428 qxx_ad(i, j) = qxx_ad(i, j) + 0.5*qout_ad(i, j)
2429 qyy_ad(i, j) = qyy_ad(i, j) + 0.5*qout_ad(i, j)
2433 qy_ad(i-2, j) = qy_ad(i-2, j) +
a2*qyy_ad(i, j)
2434 qy_ad(i+1, j) = qy_ad(i+1, j) +
a2*qyy_ad(i, j)
2435 qy_ad(i-1, j) = qy_ad(i-1, j) +
a1*qyy_ad(i, j)
2436 qy_ad(i, j) = qy_ad(i, j) +
a1*qyy_ad(i, j)
2443 qx_ad(i, j-2) = qx_ad(i, j-2) +
a2*qxx_ad(i, j)
2444 qx_ad(i, j+1) = qx_ad(i, j+1) +
a2*qxx_ad(i, j)
2445 qx_ad(i, j-1) = qx_ad(i, j-1) +
a1*qxx_ad(i, j)
2446 qx_ad(i, j) = qx_ad(i, j) +
a1*qxx_ad(i, j)
2450 ELSE IF (branch .EQ. 1)
THEN 2457 DO i=ad_to3,ad_from3,-1
2459 qxx_ad(i, j) = qxx_ad(i, j) + 0.5*qout_ad(i, j)
2460 qyy_ad(i, j) = qyy_ad(i, j) + 0.5*qout_ad(i, j)
2464 IF (branch .NE. 0)
THEN 2465 qy_ad(npx-2, j) = qy_ad(npx-2, j) + c1*qyy_ad(npx-1, j)
2466 qy_ad(npx-1, j) = qy_ad(npx-1, j) + c1*qyy_ad(npx-1, j)
2467 qout_ad(npx, j) = qout_ad(npx, j) + c2*qyy_ad(npx-1, j)
2468 qyy_ad(npx-2, j) = qyy_ad(npx-2, j) + c2*qyy_ad(npx-1, j)
2469 qyy_ad(npx-1, j) = 0.0
2472 IF (branch .EQ. 0)
THEN 2473 qy_ad(1, j) = qy_ad(1, j) + c1*qyy_ad(2, j)
2474 qy_ad(2, j) = qy_ad(2, j) + c1*qyy_ad(2, j)
2475 qout_ad(1, j) = qout_ad(1, j) + c2*qyy_ad(2, j)
2476 qyy_ad(3, j) = qyy_ad(3, j) + c2*qyy_ad(2, j)
2481 DO i=ad_to2,ad_from2,-1
2482 qy_ad(i-2, j) = qy_ad(i-2, j) +
a2*qyy_ad(i, j)
2483 qy_ad(i+1, j) = qy_ad(i+1, j) +
a2*qyy_ad(i, j)
2484 qy_ad(i-1, j) = qy_ad(i-1, j) +
a1*qyy_ad(i, j)
2485 qy_ad(i, j) = qy_ad(i, j) +
a1*qyy_ad(i, j)
2490 IF (branch .EQ. 0)
THEN 2495 qx_ad(i, npy-2) = qx_ad(i, npy-2) + c1*qxx_ad(i, npy-1)
2496 qx_ad(i, npy-1) = qx_ad(i, npy-1) + c1*qxx_ad(i, npy-1)
2497 qout_ad(i, npy) = qout_ad(i, npy) + c2*qxx_ad(i, npy-1)
2498 qxx_ad(i, npy-2) = qxx_ad(i, npy-2) + c2*qxx_ad(i, npy-1)
2499 qxx_ad(i, npy-1) = 0.0
2503 IF (branch .EQ. 0)
THEN 2505 qx_ad(i, 1) = qx_ad(i, 1) + c1*qxx_ad(i, 2)
2506 qx_ad(i, 2) = qx_ad(i, 2) + c1*qxx_ad(i, 2)
2507 qout_ad(i, 1) = qout_ad(i, 1) + c2*qxx_ad(i, 2)
2508 qxx_ad(i, 3) = qxx_ad(i, 3) + c2*qxx_ad(i, 2)
2515 DO i=ad_to1,ad_from1,-1
2516 qx_ad(i, j-2) = qx_ad(i, j-2) +
a2*qxx_ad(i, j)
2517 qx_ad(i, j+1) = qx_ad(i, j+1) +
a2*qxx_ad(i, j)
2518 qx_ad(i, j-1) = qx_ad(i, j-1) +
a1*qxx_ad(i, j)
2519 qx_ad(i, j) = qx_ad(i, j) +
a1*qxx_ad(i, j)
2529 temp_ad23 = 0.5*qout_ad(i, j)
2530 temp_ad24 =
a1*temp_ad23
2531 temp_ad25 =
a2*temp_ad23
2532 qx_ad(i, j-1) = qx_ad(i, j-1) + temp_ad24
2533 qx_ad(i, j) = qx_ad(i, j) + temp_ad24
2534 qy_ad(i-1, j) = qy_ad(i-1, j) + temp_ad24
2535 qy_ad(i, j) = qy_ad(i, j) + temp_ad24
2536 qx_ad(i, j-2) = qx_ad(i, j-2) + temp_ad25
2537 qx_ad(i, j+1) = qx_ad(i, j+1) + temp_ad25
2538 qy_ad(i-2, j) = qy_ad(i-2, j) + temp_ad25
2539 qy_ad(i+1, j) = qy_ad(i+1, j) + temp_ad25
2545 qin_ad(i, j-1) = qin_ad(i, j-1) +
b1*qy_ad(i, j)
2546 qin_ad(i, j) = qin_ad(i, j) +
b1*qy_ad(i, j)
2547 qin_ad(i, j-2) = qin_ad(i, j-2) +
b2*qy_ad(i, j)
2548 qin_ad(i, j+1) = qin_ad(i, j+1) +
b2*qy_ad(i, j)
2554 qin_ad(i-1, j) = qin_ad(i-1, j) +
b1*qx_ad(i, j)
2555 qin_ad(i, j) = qin_ad(i, j) +
b1*qx_ad(i, j)
2556 qin_ad(i-2, j) = qin_ad(i-2, j) +
b2*qx_ad(i, j)
2557 qin_ad(i+1, j) = qin_ad(i+1, j) +
b2*qx_ad(i, j)
2563 dya => gridstruct%dya
2565 IF (branch .EQ. 0)
THEN 2568 qin_ad(i, j-2) = qin_ad(i, j-2) +
b2*qy_ad(i, j)
2569 qin_ad(i, j+1) = qin_ad(i, j+1) +
b2*qy_ad(i, j)
2570 qin_ad(i, j-1) = qin_ad(i, j-1) +
b1*qy_ad(i, j)
2571 qin_ad(i, j) = qin_ad(i, j) +
b1*qy_ad(i, j)
2576 IF (branch .EQ. 1)
THEN 2578 g_in = dya(i, npy-2)/dya(i, npy-1)
2579 temp_ad19 = qy_ad(i, npy-1)/(g_in*2.+2.)
2580 qin_ad(i, npy-2) = qin_ad(i, npy-2) + 3.*temp_ad19
2581 qy_ad(i, npy) = qy_ad(i, npy) - g_in*temp_ad19
2582 qy_ad(i, npy-2) = qy_ad(i, npy-2) - temp_ad19
2583 qy_ad(i, npy-1) = 0.0
2584 g_ou = dya(i, npy+1)/dya(i, npy)
2585 temp_ad21 = 0.5*qy_ad(i, npy)
2586 temp_ad20 = temp_ad21/(g_in+1.)
2587 qin_ad(i, npy-1) = qin_ad(i, npy-1) + (g_in+2.)*temp_ad20 + 3.&
2589 temp_ad22 = temp_ad21/(g_ou+1.)
2590 qin_ad(i, npy-2) = qin_ad(i, npy-2) - temp_ad20
2591 qin_ad(i, npy) = qin_ad(i, npy) + (g_ou+2.)*temp_ad22
2592 qin_ad(i, npy+1) = qin_ad(i, npy+1) - temp_ad22
2595 edge_n => gridstruct%edge_n
2599 q1_ad(i-1) = q1_ad(i-1) + edge_n(i)*qout_ad(i, npy)
2600 q1_ad(i) = q1_ad(i) + (1.-edge_n(i))*qout_ad(i, npy)
2601 qout_ad(i, npy) = 0.0
2604 temp_ad18 = q1_ad(i)/(dya(i, npy-1)+dya(i, npy))
2605 qin_ad(i, npy-1) = qin_ad(i, npy-1) + dya(i, npy)*temp_ad18
2606 qin_ad(i, npy) = qin_ad(i, npy) + dya(i, npy-1)*temp_ad18
2613 IF (branch .EQ. 0)
THEN 2615 g_in = dya(i, 2)/dya(i, 1)
2616 temp_ad14 = qy_ad(i, 2)/(g_in*2.+2.)
2617 qin_ad(i, 1) = qin_ad(i, 1) + 3.*g_in*temp_ad14
2618 qin_ad(i, 2) = qin_ad(i, 2) + 3.*temp_ad14
2619 qy_ad(i, 1) = qy_ad(i, 1) - g_in*temp_ad14
2620 qy_ad(i, 3) = qy_ad(i, 3) - temp_ad14
2622 g_ou = dya(i, -1)/dya(i, 0)
2623 temp_ad15 = 0.5*qy_ad(i, 1)
2624 temp_ad16 = temp_ad15/(g_in+1.)
2625 temp_ad17 = temp_ad15/(g_ou+1.)
2626 qin_ad(i, 1) = qin_ad(i, 1) + (g_in+2.)*temp_ad16
2627 qin_ad(i, 2) = qin_ad(i, 2) - temp_ad16
2628 qin_ad(i, 0) = qin_ad(i, 0) + (g_ou+2.)*temp_ad17
2629 qin_ad(i, -1) = qin_ad(i, -1) - temp_ad17
2632 edge_s => gridstruct%edge_s
2635 q1_ad(i-1) = q1_ad(i-1) + edge_s(i)*qout_ad(i, 1)
2636 q1_ad(i) = q1_ad(i) + (1.-edge_s(i))*qout_ad(i, 1)
2640 temp_ad13 = q1_ad(i)/(dya(i, 0)+dya(i, 1))
2641 qin_ad(i, 0) = qin_ad(i, 0) + dya(i, 1)*temp_ad13
2642 qin_ad(i, 1) = qin_ad(i, 1) + dya(i, 0)*temp_ad13
2649 DO i=ad_to0,ad_from0,-1
2650 qin_ad(i, j-2) = qin_ad(i, j-2) +
b2*qy_ad(i, j)
2651 qin_ad(i, j+1) = qin_ad(i, j+1) +
b2*qy_ad(i, j)
2652 qin_ad(i, j-1) = qin_ad(i, j-1) +
b1*qy_ad(i, j)
2653 qin_ad(i, j) = qin_ad(i, j) +
b1*qy_ad(i, j)
2658 dxa => gridstruct%dxa
2660 IF (branch .EQ. 0)
THEN 2663 qin_ad(i-2, j) = qin_ad(i-2, j) +
b2*qx_ad(i, j)
2664 qin_ad(i+1, j) = qin_ad(i+1, j) +
b2*qx_ad(i, j)
2665 qin_ad(i-1, j) = qin_ad(i-1, j) +
b1*qx_ad(i, j)
2666 qin_ad(i, j) = qin_ad(i, j) +
b1*qx_ad(i, j)
2671 IF (branch .EQ. 1)
THEN 2673 g_in = dxa(npx-2, j)/dxa(npx-1, j)
2674 temp_ad9 = qx_ad(npx-1, j)/(g_in*2.+2.)
2675 qin_ad(npx-2, j) = qin_ad(npx-2, j) + 3.*temp_ad9
2676 qx_ad(npx, j) = qx_ad(npx, j) - g_in*temp_ad9
2677 qx_ad(npx-2, j) = qx_ad(npx-2, j) - temp_ad9
2678 qx_ad(npx-1, j) = 0.0
2679 g_ou = dxa(npx+1, j)/dxa(npx, j)
2680 temp_ad11 = 0.5*qx_ad(npx, j)
2681 temp_ad10 = temp_ad11/(g_in+1.)
2682 qin_ad(npx-1, j) = qin_ad(npx-1, j) + (g_in+2.)*temp_ad10 + 3.&
2684 temp_ad12 = temp_ad11/(g_ou+1.)
2685 qin_ad(npx-2, j) = qin_ad(npx-2, j) - temp_ad10
2686 qin_ad(npx, j) = qin_ad(npx, j) + (g_ou+2.)*temp_ad12
2687 qin_ad(npx+1, j) = qin_ad(npx+1, j) - temp_ad12
2690 edge_e => gridstruct%edge_e
2694 q2_ad(j-1) = q2_ad(j-1) + edge_e(j)*qout_ad(npx, j)
2695 q2_ad(j) = q2_ad(j) + (1.-edge_e(j))*qout_ad(npx, j)
2696 qout_ad(npx, j) = 0.0
2699 temp_ad8 = q2_ad(j)/(dxa(npx-1, j)+dxa(npx, j))
2700 qin_ad(npx-1, j) = qin_ad(npx-1, j) + dxa(npx, j)*temp_ad8
2701 qin_ad(npx, j) = qin_ad(npx, j) + dxa(npx-1, j)*temp_ad8
2708 IF (branch .EQ. 0)
THEN 2710 g_in = dxa(2, j)/dxa(1, j)
2711 temp_ad4 = qx_ad(2, j)/(g_in*2.+2.)
2712 qin_ad(1, j) = qin_ad(1, j) + 3.*g_in*temp_ad4
2713 qin_ad(2, j) = qin_ad(2, j) + 3.*temp_ad4
2714 qx_ad(1, j) = qx_ad(1, j) - g_in*temp_ad4
2715 qx_ad(3, j) = qx_ad(3, j) - temp_ad4
2717 g_ou = dxa(-1, j)/dxa(0, j)
2718 temp_ad5 = 0.5*qx_ad(1, j)
2719 temp_ad6 = temp_ad5/(g_in+1.)
2720 temp_ad7 = temp_ad5/(g_ou+1.)
2721 qin_ad(1, j) = qin_ad(1, j) + (g_in+2.)*temp_ad6
2722 qin_ad(2, j) = qin_ad(2, j) - temp_ad6
2723 qin_ad(0, j) = qin_ad(0, j) + (g_ou+2.)*temp_ad7
2724 qin_ad(-1, j) = qin_ad(-1, j) - temp_ad7
2727 edge_w => gridstruct%edge_w
2730 q2_ad(j-1) = q2_ad(j-1) + edge_w(j)*qout_ad(1, j)
2731 q2_ad(j) = q2_ad(j) + (1.-edge_w(j))*qout_ad(1, j)
2735 temp_ad3 = q2_ad(j)/(dxa(0, j)+dxa(1, j))
2736 qin_ad(0, j) = qin_ad(0, j) + dxa(1, j)*temp_ad3
2737 qin_ad(1, j) = qin_ad(1, j) + dxa(0, j)*temp_ad3
2744 DO i=ad_to,ad_from,-1
2745 qin_ad(i-2, j) = qin_ad(i-2, j) +
b2*qx_ad(i, j)
2746 qin_ad(i+1, j) = qin_ad(i+1, j) +
b2*qx_ad(i, j)
2747 qin_ad(i-1, j) = qin_ad(i-1, j) +
b1*qx_ad(i, j)
2748 qin_ad(i, j) = qin_ad(i, j) +
b1*qx_ad(i, j)
2753 IF (branch .NE. 0)
THEN 2755 temp_ad2 =
r3*qout_ad(1, npy)
2756 result1_ad = temp_ad2
2757 result2_ad = temp_ad2
2758 result3_ad = temp_ad2
2759 qout_ad(1, npy) = 0.0
2761 & , 1:2), qin(1, npy), qin_ad(1, npy), qin(2, &
2762 & npy+1), qin_ad(2, npy+1), result3_ad)
2764 & npy-2, 1:2), qin(0, npy-1), qin_ad(0, npy-1)&
2765 & , qin(-1, npy-2), qin_ad(-1, npy-2), &
2768 & -2, 1:2), qin(1, npy-1), qin_ad(1, npy-1), &
2769 & qin(2, npy-2), qin_ad(2, npy-2), result1_ad)
2772 IF (branch .EQ. 0)
THEN 2774 temp_ad1 =
r3*qout_ad(npx, npy)
2775 result1_ad = temp_ad1
2776 result2_ad = temp_ad1
2777 result3_ad = temp_ad1
2778 qout_ad(npx, npy) = 0.0
2780 & 2, npy+1, 1:2), qin(npx-1, npy), qin_ad(npx-&
2781 & 1, npy), qin(npx-2, npy+1), qin_ad(npx-2, &
2782 & npy+1), result3_ad)
2784 & 1, npy-2, 1:2), qin(npx, npy-1), qin_ad(npx&
2785 & , npy-1), qin(npx+1, npy-2), qin_ad(npx+1, &
2786 & npy-2), result2_ad)
2788 & npx-2, npy-2, 1:2), qin(npx-1, npy-1), &
2789 & qin_ad(npx-1, npy-1), qin(npx-2, npy-2), &
2790 & qin_ad(npx-2, npy-2), result1_ad)
2793 IF (branch .EQ. 0)
THEN 2795 temp_ad0 =
r3*qout_ad(npx, 1)
2796 result1_ad = temp_ad0
2797 result2_ad = temp_ad0
2798 result3_ad = temp_ad0
2799 qout_ad(npx, 1) = 0.0
2801 & , 1:2), qin(npx, 1), qin_ad(npx, 1), qin(npx&
2802 & +1, 2), qin_ad(npx+1, 2), result3_ad)
2804 & , -1, 1:2), qin(npx-1, 0), qin_ad(npx-1, 0)&
2805 & , qin(npx-2, -1), qin_ad(npx-2, -1), &
2808 & , 2, 1:2), qin(npx-1, 1), qin_ad(npx-1, 1), &
2809 & qin(npx-2, 2), qin_ad(npx-2, 2), result1_ad)
2812 IF (branch .EQ. 0)
THEN 2814 temp_ad =
r3*qout_ad(1, 1)
2815 result1_ad = temp_ad
2816 result2_ad = temp_ad
2817 result3_ad = temp_ad
2820 & ), qin(1, 0), qin_ad(1, 0), qin(2, -1), &
2821 & qin_ad(2, -1), result3_ad)
2823 & ), qin(0, 1), qin_ad(0, 1), qin(-1, 2), &
2824 & qin_ad(-1, 2), result2_ad)
2826 & , qin(1, 1), qin_ad(1, 1), qin(2, 2), qin_ad&
2827 & (2, 2), result1_ad)
2852 SUBROUTINE a2b_ord2_fwd(qin, qout, gridstruct, npx, npy, is, ie, js, &
2855 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
2857 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
2859 REAL :: qout(is-ng:ie+ng, js-ng:je+ng)
2861 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
2863 REAL :: q1(npx), q2(npy)
2865 INTEGER :: is1, js1, is2, js2, ie1, je1
2866 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
2867 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
2868 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
2885 edge_w => gridstruct%edge_w
2886 edge_e => gridstruct%edge_e
2887 edge_s => gridstruct%edge_s
2888 edge_n => gridstruct%edge_n
2889 IF (gridstruct%grid_type .LT. 3)
THEN 2890 IF (gridstruct%nested)
THEN 2894 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
2900 IF (1 .LT. is - 1)
THEN 2905 IF (1 .LT. js - 1)
THEN 2920 IF (npx - 1 .GT. ie + 1)
THEN 2925 IF (npy - 1 .GT. je + 1)
THEN 2933 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
2938 IF (gridstruct%sw_corner)
THEN 2940 qout(1, 1) =
r3*(qin(1, 1)+qin(1, 0)+qin(0, 1))
2945 IF (gridstruct%se_corner)
THEN 2947 qout(npx, 1) =
r3*(qin(npx-1, 1)+qin(npx-1, 0)+qin(npx, 1))
2952 IF (gridstruct%ne_corner)
THEN 2954 qout(npx, npy) =
r3*(qin(npx-1, npy-1)+qin(npx, npy-1)+qin(npx&
2960 IF (gridstruct%nw_corner)
THEN 2962 qout(1, npy) =
r3*(qin(1, npy-1)+qin(0, npy-1)+qin(1, npy))
2970 q2(j) = 0.5*(qin(0, j)+qin(1, j))
2974 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
2981 IF (ie + 1 .EQ. npx)
THEN 2983 q2(j) = 0.5*(qin(npx-1, j)+qin(npx, j))
2987 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
2996 q1(i) = 0.5*(qin(i, 0)+qin(i, 1))
3000 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
3007 IF (je + 1 .EQ. npy)
THEN 3009 q1(i) = 0.5*(qin(i, npy-1)+qin(i, npy))
3013 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
3024 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin(i&
3030 IF (
PRESENT(replace))
THEN 3035 qin(i, j) = qout(i, j)
3084 SUBROUTINE a2b_ord2_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx, &
3085 & npy, is, ie, js, je, ng, replace)
3087 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
3088 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
3089 REAL,
INTENT(INOUT) :: qin_ad(is-ng:ie+ng, js-ng:je+ng)
3090 REAL :: qout(is-ng:ie+ng, js-ng:je+ng)
3091 REAL :: qout_ad(is-ng:ie+ng, js-ng:je+ng)
3093 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
3094 REAL :: q1(npx), q2(npy)
3095 REAL :: q1_ad(npx), q2_ad(npy)
3097 INTEGER :: is1, js1, is2, js2, ie1, je1
3098 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
3099 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
3100 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
3127 IF (branch .EQ. 0)
THEN 3134 ELSE IF (branch .EQ. 1)
THEN 3151 qout_ad(i, j) = qout_ad(i, j) + qin_ad(i, j)
3156 edge_n => gridstruct%edge_n
3158 IF (branch .LT. 2)
THEN 3159 IF (branch .EQ. 0)
THEN 3163 temp_ad = 0.25*qout_ad(i, j)
3164 qin_ad(i-1, j-1) = qin_ad(i-1, j-1) + temp_ad
3165 qin_ad(i, j-1) = qin_ad(i, j-1) + temp_ad
3166 qin_ad(i-1, j) = qin_ad(i-1, j) + temp_ad
3167 qin_ad(i, j) = qin_ad(i, j) + temp_ad
3176 q1_ad(i-1) = q1_ad(i-1) + edge_n(i)*qout_ad(i, npy)
3177 q1_ad(i) = q1_ad(i) + (1.-edge_n(i))*qout_ad(i, npy)
3178 qout_ad(i, npy) = 0.0
3181 qin_ad(i, npy-1) = qin_ad(i, npy-1) + 0.5*q1_ad(i)
3182 qin_ad(i, npy) = qin_ad(i, npy) + 0.5*q1_ad(i)
3186 ELSE IF (branch .EQ. 2)
THEN 3192 temp_ad5 = 0.25*qout_ad(i, j)
3193 qin_ad(i-1, j-1) = qin_ad(i-1, j-1) + temp_ad5
3194 qin_ad(i, j-1) = qin_ad(i, j-1) + temp_ad5
3195 qin_ad(i-1, j) = qin_ad(i-1, j) + temp_ad5
3196 qin_ad(i, j) = qin_ad(i, j) + temp_ad5
3202 edge_s => gridstruct%edge_s
3204 IF (branch .EQ. 0)
THEN 3207 q1_ad(i-1) = q1_ad(i-1) + edge_s(i)*qout_ad(i, 1)
3208 q1_ad(i) = q1_ad(i) + (1.-edge_s(i))*qout_ad(i, 1)
3212 qin_ad(i, 0) = qin_ad(i, 0) + 0.5*q1_ad(i)
3213 qin_ad(i, 1) = qin_ad(i, 1) + 0.5*q1_ad(i)
3217 edge_e => gridstruct%edge_e
3219 IF (branch .EQ. 0)
THEN 3223 q2_ad(j-1) = q2_ad(j-1) + edge_e(j)*qout_ad(npx, j)
3224 q2_ad(j) = q2_ad(j) + (1.-edge_e(j))*qout_ad(npx, j)
3225 qout_ad(npx, j) = 0.0
3228 qin_ad(npx-1, j) = qin_ad(npx-1, j) + 0.5*q2_ad(j)
3229 qin_ad(npx, j) = qin_ad(npx, j) + 0.5*q2_ad(j)
3235 edge_w => gridstruct%edge_w
3237 IF (branch .EQ. 0)
THEN 3240 q2_ad(j-1) = q2_ad(j-1) + edge_w(j)*qout_ad(1, j)
3241 q2_ad(j) = q2_ad(j) + (1.-edge_w(j))*qout_ad(1, j)
3245 qin_ad(0, j) = qin_ad(0, j) + 0.5*q2_ad(j)
3246 qin_ad(1, j) = qin_ad(1, j) + 0.5*q2_ad(j)
3251 IF (branch .EQ. 0)
THEN 3253 temp_ad4 =
r3*qout_ad(1, npy)
3254 qin_ad(1, npy-1) = qin_ad(1, npy-1) + temp_ad4
3255 qin_ad(0, npy-1) = qin_ad(0, npy-1) + temp_ad4
3256 qin_ad(1, npy) = qin_ad(1, npy) + temp_ad4
3257 qout_ad(1, npy) = 0.0
3260 IF (branch .EQ. 0)
THEN 3262 temp_ad3 =
r3*qout_ad(npx, npy)
3263 qin_ad(npx-1, npy-1) = qin_ad(npx-1, npy-1) + temp_ad3
3264 qin_ad(npx, npy-1) = qin_ad(npx, npy-1) + temp_ad3
3265 qin_ad(npx-1, npy) = qin_ad(npx-1, npy) + temp_ad3
3266 qout_ad(npx, npy) = 0.0
3269 IF (branch .EQ. 0)
THEN 3271 temp_ad2 =
r3*qout_ad(npx, 1)
3272 qin_ad(npx-1, 1) = qin_ad(npx-1, 1) + temp_ad2
3273 qin_ad(npx-1, 0) = qin_ad(npx-1, 0) + temp_ad2
3274 qin_ad(npx, 1) = qin_ad(npx, 1) + temp_ad2
3275 qout_ad(npx, 1) = 0.0
3278 IF (branch .EQ. 0)
THEN 3280 temp_ad1 =
r3*qout_ad(1, 1)
3281 qin_ad(1, 1) = qin_ad(1, 1) + temp_ad1
3282 qin_ad(1, 0) = qin_ad(1, 0) + temp_ad1
3283 qin_ad(0, 1) = qin_ad(0, 1) + temp_ad1
3289 temp_ad0 = 0.25*qout_ad(i, j)
3290 qin_ad(i-1, j-1) = qin_ad(i-1, j-1) + temp_ad0
3291 qin_ad(i, j-1) = qin_ad(i, j-1) + temp_ad0
3292 qin_ad(i-1, j) = qin_ad(i-1, j) + temp_ad0
3293 qin_ad(i, j) = qin_ad(i, j) + temp_ad0
3299 SUBROUTINE a2b_ord2(qin, qout, gridstruct, npx, npy, is, ie, js, je, &
3302 INTEGER,
INTENT(IN) :: npx, npy, is, ie, js, je, ng
3304 REAL,
INTENT(INOUT) :: qin(is-ng:ie+ng, js-ng:je+ng)
3306 REAL,
INTENT(OUT) :: qout(is-ng:ie+ng, js-ng:je+ng)
3308 LOGICAL,
OPTIONAL,
INTENT(IN) :: replace
3310 REAL :: q1(npx), q2(npy)
3312 INTEGER :: is1, js1, is2, js2, ie1, je1
3313 REAL,
DIMENSION(:, :, :),
POINTER :: grid, agrid
3314 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya
3315 REAL(kind=r_grid),
DIMENSION(:),
POINTER :: edge_w, edge_e, edge_s, &
3320 edge_w => gridstruct%edge_w
3321 edge_e => gridstruct%edge_e
3322 edge_s => gridstruct%edge_s
3323 edge_n => gridstruct%edge_n
3324 grid => gridstruct%grid
3325 agrid => gridstruct%agrid
3326 dxa => gridstruct%dxa
3327 dya => gridstruct%dya
3328 IF (gridstruct%grid_type .LT. 3)
THEN 3329 IF (gridstruct%nested)
THEN 3332 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
3337 IF (1 .LT. is - 1)
THEN 3342 IF (1 .LT. js - 1)
THEN 3357 IF (npx - 1 .GT. ie + 1)
THEN 3362 IF (npy - 1 .GT. je + 1)
THEN 3369 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin&
3374 IF (gridstruct%sw_corner) qout(1, 1) =
r3*(qin(1, 1)+qin(1, 0)+&
3376 IF (gridstruct%se_corner) qout(npx, 1) =
r3*(qin(npx-1, 1)+qin(&
3377 & npx-1, 0)+qin(npx, 1))
3378 IF (gridstruct%ne_corner) qout(npx, npy) =
r3*(qin(npx-1, npy-1)&
3379 & +qin(npx, npy-1)+qin(npx-1, npy))
3380 IF (gridstruct%nw_corner) qout(1, npy) =
r3*(qin(1, npy-1)+qin(0&
3381 & , npy-1)+qin(1, npy))
3385 q2(j) = 0.5*(qin(0, j)+qin(1, j))
3388 qout(1, j) = edge_w(j)*q2(j-1) + (1.-edge_w(j))*q2(j)
3392 IF (ie + 1 .EQ. npx)
THEN 3394 q2(j) = 0.5*(qin(npx-1, j)+qin(npx, j))
3397 qout(npx, j) = edge_e(j)*q2(j-1) + (1.-edge_e(j))*q2(j)
3403 q1(i) = 0.5*(qin(i, 0)+qin(i, 1))
3406 qout(i, 1) = edge_s(i)*q1(i-1) + (1.-edge_s(i))*q1(i)
3410 IF (je + 1 .EQ. npy)
THEN 3412 q1(i) = 0.5*(qin(i, npy-1)+qin(i, npy))
3415 qout(i, npy) = edge_n(i)*q1(i-1) + (1.-edge_n(i))*q1(i)
3422 qout(i, j) = 0.25*(qin(i-1, j-1)+qin(i, j-1)+qin(i-1, j)+qin(i&
3427 IF (
PRESENT(replace))
THEN 3431 qin(i, j) = qout(i, j)
3460 REAL,
DIMENSION(2),
INTENT(IN) :: p0, p1, p2
3461 REAL,
INTENT(IN) :: q1, q2
3462 REAL :: q1_ad, q2_ad
3465 REAL(r_grid),
DIMENSION(2) :: arg1
3466 REAL(r_grid),
DIMENSION(2) :: arg2
3468 REAL :: extrap_corner_ad
3469 REAL :: extrap_corner
3470 arg1(:) =
REAL(p1, kind=
r_grid)
3471 arg2(:) =
REAL(p0, kind=
r_grid)
3472 x1 = great_circle_dist(
REAL(p1, kind=r_grid),
REAL(p0, kind=
r_grid))
3473 arg1(:) =
REAL(p2, kind=
r_grid)
3474 arg2(:) =
REAL(p0, kind=
r_grid)
3475 x2 = great_circle_dist(
REAL(p2, kind=r_grid),
REAL(p0, kind=
r_grid))
3476 temp_ad = x1*extrap_corner_ad/(x2-x1)
3477 q1_ad = q1_ad + temp_ad + extrap_corner_ad
3478 q2_ad = q2_ad - temp_ad
3482 REAL,
DIMENSION(2),
INTENT(IN) :: p0, p1, p2
3483 REAL,
INTENT(IN) :: q1, q2
3486 REAL(r_grid),
DIMENSION(2) :: arg1
3487 REAL(r_grid),
DIMENSION(2) :: arg2
3488 arg1(:) =
REAL(p1, kind=
r_grid)
3489 arg2(:) =
REAL(p0, kind=
r_grid)
3490 x1 = great_circle_dist(arg1(:), arg2(:))
3491 arg1(:) =
REAL(p2, kind=
r_grid)
3492 arg2(:) =
REAL(p0, kind=
r_grid)
3493 x2 = great_circle_dist(arg1(:), arg2(:))
3518 REAL,
DIMENSION(2),
INTENT(IN) :: p0, p1, p2
3519 REAL,
INTENT(IN) :: q1, q2
3522 REAL(r_grid),
DIMENSION(2) :: arg1
3523 REAL(r_grid),
DIMENSION(2) :: arg2
3525 arg1(:) =
REAL(p1, kind=
r_grid)
3526 arg2(:) =
REAL(p0, kind=
r_grid)
3527 x1 = great_circle_dist(
REAL(p1, kind=r_grid),
REAL(p0, kind=
r_grid))
3528 arg1(:) =
REAL(p2, kind=
r_grid)
3529 arg2(:) =
REAL(p0, kind=
r_grid)
3530 x2 = great_circle_dist(
REAL(p2, kind=r_grid),
REAL(p0, kind=
r_grid))
3559 REAL,
DIMENSION(2),
INTENT(IN) :: p0, p1, p2
3560 REAL,
INTENT(IN) :: q1, q2
3561 REAL :: q1_ad, q2_ad
3564 REAL(r_grid),
DIMENSION(2) :: arg1
3565 REAL(r_grid),
DIMENSION(2) :: arg2
3567 REAL :: extrap_corner
3568 REAL :: extrap_corner_ad
3571 temp_ad = x1*extrap_corner_ad/(x2-x1)
3572 q1_ad = q1_ad + temp_ad + extrap_corner_ad
3573 q2_ad = q2_ad - temp_ad
subroutine, public a2b_ord2_fwd(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine popinteger4(x)
subroutine popcontrol2b(cc)
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine, public a2b_ord2_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine, public pushcontrol(ctype, field)
real function extrap_corner(p0, p1, p2, q1, q2)
real function extrap_corner_fwd(p0, p1, p2, q1, q2)
subroutine pushcontrol1b(cc)
subroutine extrap_corner_bwd(p0, p1, p2, q1, q1_ad, q2, q2_ad, extrap_corner_ad)
void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, double *qout, int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
subroutine pushcontrol2b(cc)
subroutine, public a2b_ord4_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
integer, parameter, public r_grid
real function, public great_circle_dist(q1, q2, radius)
subroutine popcontrol1b(cc)
subroutine, public a2b_ord4_adm(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine extrap_corner_adm(p0, p1, p2, q1, q1_ad, q2, q2_ad, extrap_corner_ad)
subroutine, public popcontrol(ctype, field)
subroutine pushinteger4(x)
subroutine, public a2b_ord4_fwd(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)