1 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_uv_agrid_xyz_rx.template,v 1.4 2004/11/17 16:28:12 molod Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
|
6 |
SUBROUTINE EXCH2_UV_AGRID_XYZ_RX( |
7 |
U component1, component2, |
8 |
I withSigns, myThid ) |
9 |
|
10 |
C*=====================================================================* |
11 |
C Purpose: SUBROUTINE exch2_uv_agrid_xyz_RX will |
12 |
C handle exchanges for a 3D vector field on an A-grid. |
13 |
C |
14 |
C Input: component1(lon,lat,levs,bi,bj) - first component of vector |
15 |
C component2(lon,lat,levs,bi,bj) - second component of vector |
16 |
C withSigns (logical) - true to use sign of components |
17 |
C myThid - Thread number |
18 |
C |
19 |
C Output: component1 and component2 are updated (halo regions filled) |
20 |
C |
21 |
C Calls: exch (exch2_xyz_rx ) - twice, once for the first-component, |
22 |
C once for second. |
23 |
C |
24 |
C*=====================================================================* |
25 |
|
26 |
IMPLICIT NONE |
27 |
|
28 |
#include "SIZE.h" |
29 |
#include "EEPARAMS.h" |
30 |
#include "EESUPPORT.h" |
31 |
#include "W2_EXCH2_TOPOLOGY.h" |
32 |
#include "W2_EXCH2_PARAMS.h" |
33 |
|
34 |
C == Argument list variables == |
35 |
_RX component1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
36 |
_RX component2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
37 |
LOGICAL withSigns |
38 |
INTEGER myThid |
39 |
|
40 |
C == Local variables == |
41 |
C i,j,k,bi,bj are DO indices. |
42 |
C OL[wens] - Overlap extents in west, east, north, south. |
43 |
C exchWidth[XY] - Extent of regions that will be exchanged. |
44 |
C dummy[12] - copies of the vector components with haloes filled. |
45 |
|
46 |
INTEGER i,j,k,bi,bj |
47 |
INTEGER OLw, OLe, OLn, OLs, exchWidthX, exchWidthY, myNz |
48 |
_RX dummy1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
49 |
_RX dummy2(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
50 |
INTEGER mytile, myface |
51 |
|
52 |
OLw = OLx |
53 |
OLe = OLx |
54 |
OLn = OLy |
55 |
OLs = OLy |
56 |
exchWidthX = OLx |
57 |
exchWidthY = OLy |
58 |
myNz = Nr |
59 |
|
60 |
IF ( useCubedSphereExchange ) THEN |
61 |
|
62 |
C First CALL the exchanges for the two components |
63 |
|
64 |
CALL EXCH2_XYZ_RX( component1, myThid ) |
65 |
CALL EXCH2_XYZ_RX( component2, myThid ) |
66 |
|
67 |
C Then if we are on the sphere we may need to switch u and v components |
68 |
C and/or the signs depending on which cube face we are located. |
69 |
|
70 |
C-- Loops on tile and level indices: |
71 |
DO bj = myByLo(myThid), myByHi(myThid) |
72 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
73 |
DO k = 1,Nr |
74 |
|
75 |
C First we need to copy the component info into dummy arrays |
76 |
DO j = 1-OLy,sNy+OLy |
77 |
DO i = 1-OLx,sNx+OLx |
78 |
dummy1(i,j) = component1(i,j,k,bi,bj) |
79 |
dummy2(i,j) = component2(i,j,k,bi,bj) |
80 |
ENDDO |
81 |
ENDDO |
82 |
|
83 |
C Now choose what to DO at each edge of the halo based on which face |
84 |
C (we assume that bj is always=1) |
85 |
|
86 |
mytile = W2_myTileList(bi) |
87 |
myface = exch2_myFace(mytile) |
88 |
C odd faces share disposition of all sections of the halo |
89 |
IF ( MOD(myface,2).EQ.1 ) THEN |
90 |
C east (nothing to change) |
91 |
c IF (exch2_isEedge(mytile).EQ.1) THEN |
92 |
c DO j = 1,sNy |
93 |
c DO i = 1,exchWidthX |
94 |
c component1(sNx+i,j,k,bi,bj) = dummy1(sNx+i,j) |
95 |
c component2(sNx+i,j,k,bi,bj) = dummy2(sNx+i,j) |
96 |
c ENDDO |
97 |
c ENDDO |
98 |
c ENDIF |
99 |
C west |
100 |
IF (exch2_isWedge(mytile).EQ.1) THEN |
101 |
IF (withSigns) THEN |
102 |
DO j = 1,sNy |
103 |
DO i = 1,exchWidthX |
104 |
component1(i-OLx,j,k,bi,bj) = dummy2(i-OLx,j) |
105 |
component2(i-OLx,j,k,bi,bj) = -dummy1(i-OLx,j) |
106 |
ENDDO |
107 |
ENDDO |
108 |
ELSE |
109 |
DO j = 1,sNy |
110 |
DO i = 1,exchWidthX |
111 |
component1(i-OLx,j,k,bi,bj) = dummy2(i-OLx,j) |
112 |
component2(i-OLx,j,k,bi,bj) = dummy1(i-OLx,j) |
113 |
ENDDO |
114 |
ENDDO |
115 |
ENDIF |
116 |
ENDIF |
117 |
C north |
118 |
IF (exch2_isNedge(mytile).EQ.1) THEN |
119 |
IF (withSigns) THEN |
120 |
DO j = 1,exchWidthY |
121 |
DO i = 1,sNx |
122 |
component1(i,sNy+j,k,bi,bj) = -dummy2(i,sNy+j) |
123 |
component2(i,sNy+j,k,bi,bj) = dummy1(i,sNy+j) |
124 |
ENDDO |
125 |
ENDDO |
126 |
ELSE |
127 |
DO j = 1,exchWidthY |
128 |
DO i = 1,sNx |
129 |
component1(i,sNy+j,k,bi,bj) = dummy2(i,sNy+j) |
130 |
component2(i,sNy+j,k,bi,bj) = dummy1(i,sNy+j) |
131 |
ENDDO |
132 |
ENDDO |
133 |
ENDIF |
134 |
ENDIF |
135 |
C south (nothing to change) |
136 |
c IF (exch2_isSedge(mytile).EQ.1) THEN |
137 |
c DO j = 1,exchWidthY |
138 |
c DO i = 1,sNx |
139 |
c component1(i,j-OLx,k,bi,bj) = dummy1(i,j-OLx) |
140 |
c component2(i,j-OLx,k,bi,bj) = dummy2(i,j-OLx) |
141 |
c ENDDO |
142 |
c ENDDO |
143 |
c ENDIF |
144 |
|
145 |
ELSE |
146 |
C now the even faces (share disposition of all sections of the halo) |
147 |
|
148 |
C east |
149 |
IF (exch2_isEedge(mytile).EQ.1) THEN |
150 |
IF (withSigns) THEN |
151 |
DO j = 1,sNy |
152 |
DO i = 1,exchWidthX |
153 |
component1(sNx+i,j,k,bi,bj) = dummy2(sNx+i,j) |
154 |
component2(sNx+i,j,k,bi,bj) = -dummy1(sNx+i,j) |
155 |
ENDDO |
156 |
ENDDO |
157 |
ELSE |
158 |
DO j = 1,sNy |
159 |
DO i = 1,exchWidthX |
160 |
component1(sNx+i,j,k,bi,bj) = dummy2(sNx+i,j) |
161 |
component2(sNx+i,j,k,bi,bj) = dummy1(sNx+i,j) |
162 |
ENDDO |
163 |
ENDDO |
164 |
ENDIF |
165 |
ENDIF |
166 |
C west (nothing to change) |
167 |
c IF (exch2_isWedge(mytile).EQ.1) THEN |
168 |
c DO j = 1,sNy |
169 |
c DO i = 1,exchWidthX |
170 |
c component1(i-OLx,j,k,bi,bj) = dummy1(i-OLx,j) |
171 |
c component2(i-OLx,j,k,bi,bj) = dummy2(i-OLx,j) |
172 |
c ENDDO |
173 |
c ENDDO |
174 |
c ENDIF |
175 |
C north (nothing to change) |
176 |
c IF (exch2_isNedge(mytile).EQ.1) THEN |
177 |
c DO j = 1,exchWidthY |
178 |
c DO i = 1,sNx |
179 |
c component1(i,sNy+j,k,bi,bj) = dummy1(i,sNy+j) |
180 |
c component2(i,sNy+j,k,bi,bj) = dummy2(i,sNy+j) |
181 |
c ENDDO |
182 |
c ENDDO |
183 |
c ENDIF |
184 |
C south |
185 |
IF (exch2_isSedge(mytile).EQ.1) THEN |
186 |
IF (withSigns) THEN |
187 |
DO j = 1,exchWidthY |
188 |
DO i = 1,sNx |
189 |
component1(i,j-OLy,k,bi,bj) = -dummy2(i,j-OLy) |
190 |
component2(i,j-OLy,k,bi,bj) = dummy1(i,j-OLy) |
191 |
ENDDO |
192 |
ENDDO |
193 |
ELSE |
194 |
DO j = 1,exchWidthY |
195 |
DO i = 1,sNx |
196 |
component1(i,j-OLy,k,bi,bj) = dummy2(i,j-OLy) |
197 |
component2(i,j-OLy,k,bi,bj) = dummy1(i,j-OLy) |
198 |
ENDDO |
199 |
ENDDO |
200 |
ENDIF |
201 |
ENDIF |
202 |
|
203 |
C end odd / even faces |
204 |
ENDIF |
205 |
|
206 |
C-- end of Loops on tile and level indices (k,bi,bj). |
207 |
ENDDO |
208 |
ENDDO |
209 |
ENDDO |
210 |
|
211 |
ELSE |
212 |
|
213 |
c CALL EXCH_RX( component1, |
214 |
c I OLw, OLe, OLs, OLn, myNz, |
215 |
c I exchWidthX, exchWidthY, |
216 |
c I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
217 |
c CALL EXCH_RX( component2, |
218 |
c I OLw, OLe, OLs, OLn, myNz, |
219 |
c I exchWidthX, exchWidthY, |
220 |
c I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
221 |
C_jmc: for JAM compatibility, replace the 2 CALLs above by the 2 CPP_MACROs: |
222 |
_EXCH_XYZ_RX( component1, myThid ) |
223 |
_EXCH_XYZ_RX( component2, myThid ) |
224 |
|
225 |
ENDIF |
226 |
|
227 |
RETURN |
228 |
END |
229 |
|
230 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
231 |
|
232 |
CEH3 ;;; Local Variables: *** |
233 |
CEH3 ;;; mode:fortran *** |
234 |
CEH3 ;;; End: *** |