1 |
jmc |
1.4 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch_uv_agrid_xy_rx.template,v 1.3 2004/09/07 17:29:14 edhill Exp $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "PACKAGES_CONFIG.h" |
5 |
molod |
1.1 |
#include "CPP_EEOPTIONS.h" |
6 |
jmc |
1.4 |
|
7 |
|
|
SUBROUTINE EXCH_UV_AGRID_XY_RX( component1,component2, myThid ) |
8 |
|
|
|
9 |
molod |
1.1 |
implicit none |
10 |
|
|
|
11 |
|
|
C*=====================================================================* |
12 |
jmc |
1.4 |
C Purpose: subroutine exch_uv_agrid_xyz_RX will |
13 |
molod |
1.1 |
C handle exchanges for a 2D vector field on an A-grid. |
14 |
|
|
C |
15 |
|
|
C Input: component1(lon,lat,bi,bj) - first component of vector |
16 |
|
|
C component2(lon,lat,bi,bj) - second component of vector |
17 |
|
|
C myThid - tile number |
18 |
|
|
C |
19 |
|
|
C Output: component1 and component2 are updated (halo regions filled) |
20 |
|
|
C |
21 |
|
|
C Calls: exch (either exch_rx_cube or exch_rx) - twice, once |
22 |
|
|
C for the first-component, once for second. |
23 |
|
|
C |
24 |
|
|
C NOTES: 1) This code, as written, only works on ONE PROCESSOR! |
25 |
|
|
C 2) This code assumes that the faces are square (sNx=sNy....) |
26 |
edhill |
1.3 |
C (also - we do not worry about barriers) |
27 |
molod |
1.1 |
C*=====================================================================* |
28 |
|
|
|
29 |
|
|
#include "SIZE.h" |
30 |
|
|
#include "EEPARAMS.h" |
31 |
|
|
#include "EESUPPORT.h" |
32 |
edhill |
1.2 |
#include "EXCH.h" |
33 |
molod |
1.1 |
|
34 |
|
|
C == Argument list variables == |
35 |
|
|
_RX component1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
36 |
|
|
_RX component2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
37 |
|
|
INTEGER myThid |
38 |
|
|
|
39 |
|
|
C == Local variables == |
40 |
|
|
C i,j,L,bi,bj are do indices. |
41 |
|
|
C OL[wens] - Overlap extents in west, east, north, south. |
42 |
|
|
C exchWidth[XY] - Extent of regions that will be exchanged. |
43 |
|
|
C dummy[12] - copies of the vector components with haloes filled. |
44 |
|
|
C b[nsew] - indices of the [nswe] neighboring faces for each face. |
45 |
|
|
|
46 |
|
|
integer i,j,L,bi,bj |
47 |
|
|
integer OLw, OLe, OLn, OLs, exchWidthX, exchWidthY, myNz |
48 |
|
|
_RX dummy1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
49 |
|
|
_RX dummy2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
50 |
|
|
|
51 |
jmc |
1.4 |
#ifdef ALLOW_EXCH2 |
52 |
|
|
CALL EXCH2_UV_AGRID_XY_RX( component1,component2, myThid ) |
53 |
|
|
RETURN |
54 |
|
|
#endif |
55 |
|
|
|
56 |
molod |
1.1 |
OLw = OLx |
57 |
|
|
OLe = OLx |
58 |
|
|
OLn = OLy |
59 |
|
|
OLs = OLy |
60 |
|
|
exchWidthX = OLx |
61 |
|
|
exchWidthY = OLy |
62 |
|
|
myNz = 1 |
63 |
|
|
|
64 |
|
|
C First call the exchanges for the two components |
65 |
|
|
|
66 |
|
|
if (useCubedSphereExchange) then |
67 |
|
|
call exch_RX_cube( component1, |
68 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
69 |
|
|
. exchWidthX, exchWidthY, |
70 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
71 |
|
|
call exch_RX_cube( component2, |
72 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
73 |
|
|
. exchWidthX, exchWidthY, |
74 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
75 |
|
|
else |
76 |
|
|
call exch_RX( component1, |
77 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
78 |
|
|
. exchWidthX, exchWidthY, |
79 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
80 |
|
|
call exch_RX( component2, |
81 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
82 |
|
|
. exchWidthX, exchWidthY, |
83 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
84 |
|
|
endif |
85 |
|
|
|
86 |
|
|
C Then if we are on the sphere we may need to switch u and v components |
87 |
|
|
C and/or the signs depending on which cube face we are located. |
88 |
|
|
|
89 |
|
|
if (useCubedSphereExchange) then |
90 |
|
|
|
91 |
|
|
do bj = myByLo(myThid), myByHi(myThid) |
92 |
|
|
do bi = myBxLo(myThid), myBxHi(myThid) |
93 |
|
|
|
94 |
|
|
C First we need to copy the component info into dummy arrays |
95 |
|
|
do j = 1-OLy,sNy+OLy |
96 |
|
|
do i = 1-OLx,sNx+OLx |
97 |
|
|
dummy1(i,j,bi,bj) = component1(i,j,bi,bj) |
98 |
|
|
dummy2(i,j,bi,bj) = component2(i,j,bi,bj) |
99 |
|
|
enddo |
100 |
|
|
enddo |
101 |
|
|
|
102 |
|
|
C Now choose what to do at each edge of the halo based on which face |
103 |
|
|
C (we assume that bj is always=1) |
104 |
|
|
|
105 |
|
|
C odd faces share disposition of all sections of the halo |
106 |
|
|
if ( mod(bi,2).eq.1 ) then |
107 |
|
|
do j = 1,sNy |
108 |
|
|
do i = 1,exchWidthX |
109 |
|
|
C east |
110 |
|
|
component1(sNx+i,j,bi,bj) = dummy1(sNx+i,j,bi,bj) |
111 |
|
|
component2(sNx+i,j,bi,bj) = dummy2(sNx+i,j,bi,bj) |
112 |
|
|
C west |
113 |
|
|
component1(i-OLx,j,bi,bj) = dummy2(i-OLx,j,bi,bj) |
114 |
|
|
component2(i-OLx,j,bi,bj) = -dummy1(i-OLx,j,bi,bj) |
115 |
|
|
C north |
116 |
|
|
component1(j,sNy+i,bi,bj) = -dummy2(j,sNy+i,bi,bj) |
117 |
|
|
component2(j,sNy+i,bi,bj) = dummy1(j,sNy+i,bi,bj) |
118 |
|
|
C south |
119 |
|
|
component1(j,i-OLx,bi,bj) = dummy1(j,i-OLx,bi,bj) |
120 |
|
|
component2(j,i-OLx,bi,bj) = dummy2(j,i-OLx,bi,bj) |
121 |
|
|
enddo |
122 |
|
|
enddo |
123 |
|
|
C now the even faces (share disposition of all sections of the halo) |
124 |
|
|
elseif ( mod(bi,2).eq.0 ) then |
125 |
|
|
do j = 1,sNy |
126 |
|
|
do i = 1,exchWidthX |
127 |
|
|
C east |
128 |
|
|
component1(sNx+i,j,bi,bj) = dummy2(sNx+i,j,bi,bj) |
129 |
|
|
component2(sNx+i,j,bi,bj) = -dummy1(sNx+i,j,bi,bj) |
130 |
|
|
C west |
131 |
|
|
component1(i-OLx,j,bi,bj) = dummy1(i-OLx,j,bi,bj) |
132 |
|
|
component2(i-OLx,j,bi,bj) = dummy2(i-OLx,j,bi,bj) |
133 |
|
|
C north |
134 |
|
|
component1(j,sNy+i,bi,bj) = dummy1(j,sNy+i,bi,bj) |
135 |
|
|
component2(j,sNy+i,bi,bj) = dummy2(j,sNy+i,bi,bj) |
136 |
|
|
C south |
137 |
|
|
component1(j,i-OLy,bi,bj) = -dummy2(j,i-OLy,bi,bj) |
138 |
|
|
component2(j,i-OLy,bi,bj) = dummy1(j,i-OLy,bi,bj) |
139 |
|
|
enddo |
140 |
|
|
enddo |
141 |
|
|
endif |
142 |
|
|
|
143 |
|
|
enddo |
144 |
|
|
enddo |
145 |
|
|
|
146 |
|
|
endif |
147 |
|
|
|
148 |
|
|
RETURN |
149 |
|
|
END |
150 |
jmc |
1.4 |
|
151 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
152 |
|
|
|
153 |
|
|
CEH3 ;;; Local Variables: *** |
154 |
|
|
CEH3 ;;; mode:fortran *** |
155 |
|
|
CEH3 ;;; End: *** |