1 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_uv_xy_rx.template,v 1.4 2004/09/21 21:10:45 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: EXCH_UV_XY_RX |
8 |
|
9 |
C !INTERFACE: |
10 |
SUBROUTINE EXCH2_UV_XY_RX( |
11 |
U Uphi, Vphi, withSigns, |
12 |
I myThid ) |
13 |
IMPLICIT NONE |
14 |
C !DESCRIPTION: |
15 |
C *==========================================================* |
16 |
C | SUBROUTINE EXCH_UV_XY_RX |
17 |
C | o Handle exchanges for _RX, two-dimensional arrays. |
18 |
C *==========================================================* |
19 |
C | Driver exchange routine which branches to cube sphere or |
20 |
C | global, simple cartesian index grid. Exchange routine is |
21 |
C | called with two arrays that are components of a vector. |
22 |
C | These components are rotated and interchanged on the |
23 |
C | rotated grid during cube exchanges. |
24 |
C *==========================================================* |
25 |
|
26 |
C !USES: |
27 |
C === Global data === |
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 !INPUT/OUTPUT PARAMETERS: |
35 |
C === Routine arguments === |
36 |
C Uphi :: Arrays with overlap regions are to be exchanged |
37 |
C Vphi Note - The interface to EXCH_ assumes that |
38 |
C the standard Fortran 77 sequence association rules |
39 |
C apply. |
40 |
C myThid :: My thread id. |
41 |
C withSigns :: Flag controlling whether vector is signed. |
42 |
_RX Uphi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
43 |
_RX Vphi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
44 |
LOGICAL withSigns |
45 |
INTEGER myThid |
46 |
|
47 |
C !LOCAL VARIABLES: |
48 |
C == Local variables == |
49 |
C OL[wens] :: Overlap extents in west, east, north, south. |
50 |
C exchWidth[XY] :: Extent of regions that will be exchanged. |
51 |
INTEGER OLw, OLe, OLn, OLs, exchWidthX, exchWidthY, myNz |
52 |
INTEGER bi, bj, myTile, i, j |
53 |
CEOP |
54 |
|
55 |
OLw = OLx |
56 |
OLe = OLx |
57 |
OLn = OLy |
58 |
OLs = OLy |
59 |
exchWidthX = OLx |
60 |
exchWidthY = OLy |
61 |
myNz = 1 |
62 |
C ** NOTE ** The exchange routine we use here does not |
63 |
C require the preceeding and following barriers. |
64 |
C However, the slow, simple exchange interface |
65 |
C that is calling it here is meant to ensure |
66 |
C that threads are synchronised before exchanges |
67 |
C begine. |
68 |
IF (useCubedSphereExchange) THEN |
69 |
CALL EXCH2_RX2_CUBE( Uphi, Vphi, withSigns, 'UV', |
70 |
I OLw, OLe, OLs, OLn, myNz, |
71 |
I exchWidthX, exchWidthY, |
72 |
I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
73 |
CALL EXCH2_RX2_CUBE( Uphi, Vphi, withSigns, 'UV', |
74 |
I OLw, OLe, OLs, OLn, myNz, |
75 |
I exchWidthX, exchWidthY, |
76 |
I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
77 |
CALL EXCH2_RX2_CUBE( Uphi, Vphi, withSigns, 'UV', |
78 |
I OLw, OLe, OLs, OLn, myNz, |
79 |
I exchWidthX, exchWidthY, |
80 |
I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
81 |
DO bj=myByLo(myThid),myByHi(myThid) |
82 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
83 |
myTile = W2_myTileList(bi) |
84 |
IF ( exch2_isEedge(myTile) .EQ. 1 .AND. |
85 |
& exch2_isSedge(myTile) .EQ. 1 ) THEN |
86 |
C Uphi(snx+1, 0,bi,bj)= vPhi(snx+1, 1,bi,bj) |
87 |
DO j=1-olx,0 |
88 |
Uphi(snx+1, j,bi,bj)= vPhi(snx+(1-j), 1,bi,bj) |
89 |
ENDDO |
90 |
ENDIF |
91 |
IF ( withSigns ) THEN |
92 |
IF ( exch2_isEedge(myTile) .EQ. 1 .AND. |
93 |
& exch2_isNedge(myTile) .EQ. 1 ) THEN |
94 |
C Uphi(snx+1,sny+1,bi,bj)=-vPhi(snx+1,sny+1,bi,bj) |
95 |
DO j=1,olx |
96 |
Uphi(snx+1,sny+j,bi,bj)=-vPhi(snx+j,sny+1,bi,bj) |
97 |
ENDDO |
98 |
ENDIF |
99 |
ELSE |
100 |
IF ( exch2_isEedge(myTile) .EQ. 1 .AND. |
101 |
& exch2_isNedge(myTile) .EQ. 1 ) THEN |
102 |
C Uphi(snx+1,sny+1,bi,bj)= vPhi(snx+1,sny+1,bi,bj) |
103 |
DO j=1,olx |
104 |
Uphi(snx+1,sny+j,bi,bj)= vPhi(snx+j,sny+1,bi,bj) |
105 |
ENDDO |
106 |
ENDIF |
107 |
ENDIF |
108 |
|
109 |
C Now zero out the null areas that should not be used in the numerics |
110 |
C- Also add one valid u,v value next to the corner, that allows |
111 |
C to compute vorticity on a wider stencil (e.g., vort3(0,1) & (1,0)) |
112 |
IF ( exch2_isWedge(myTile) .EQ. 1 .AND. |
113 |
& exch2_isSedge(myTile) .EQ. 1 ) THEN |
114 |
C Zero SW corner points |
115 |
DO J=1-OLx,0 |
116 |
DO I=1-OLx,0 |
117 |
uPhi(I,J,bi,bj)=0. |
118 |
ENDDO |
119 |
ENDDO |
120 |
DO J=1-OLx,0 |
121 |
DO I=1-OLx,0 |
122 |
vPhi(I,J,bi,bj)=0. |
123 |
ENDDO |
124 |
ENDDO |
125 |
uPhi(0,0,bi,bj)=vPhi(1,0,bi,bj) |
126 |
vPhi(0,0,bi,bj)=uPhi(0,1,bi,bj) |
127 |
ENDIF |
128 |
IF ( exch2_isWedge(myTile) .EQ. 1 .AND. |
129 |
& exch2_isNedge(myTile) .EQ. 1 ) THEN |
130 |
C Zero NW corner points |
131 |
DO J=sNy+1,sNy+OLy |
132 |
DO I=1-OLx,0 |
133 |
uPhi(I,J,bi,bj)=0. |
134 |
ENDDO |
135 |
ENDDO |
136 |
DO J=sNy+2,sNy+OLy |
137 |
DO I=1-OLx,0 |
138 |
vPhi(I,J,bi,bj)=0. |
139 |
ENDDO |
140 |
ENDDO |
141 |
IF ( withSigns ) THEN |
142 |
uPhi(0,sNy+1,bi,bj)=-vPhi(1,sNy+2,bi,bj) |
143 |
vPhi(0,sNy+2,bi,bj)=-uPhi(0,sNy,bi,bj) |
144 |
ELSE |
145 |
uPhi(0,sNy+1,bi,bj)= vPhi(1,sNy+2,bi,bj) |
146 |
vPhi(0,sNy+2,bi,bj)= uPhi(0,sNy,bi,bj) |
147 |
ENDIF |
148 |
ENDIF |
149 |
IF ( exch2_isEedge(myTile) .EQ. 1 .AND. |
150 |
& exch2_isSedge(myTile) .EQ. 1 ) THEN |
151 |
C Zero SE corner points |
152 |
DO J=1-OLx,0 |
153 |
DO I=sNx+2,sNx+OLx |
154 |
uPhi(I,J,bi,bj)=0. |
155 |
ENDDO |
156 |
ENDDO |
157 |
DO J=1-OLx,0 |
158 |
DO I=sNx+1,sNx+OLx |
159 |
vPhi(I,J,bi,bj)=0. |
160 |
ENDDO |
161 |
ENDDO |
162 |
IF ( withSigns ) THEN |
163 |
uPhi(sNx+2,0,bi,bj)=-vPhi(sNx,0,bi,bj) |
164 |
vPhi(sNx+1,0,bi,bj)=-uPhi(sNx+2,1,bi,bj) |
165 |
ELSE |
166 |
uPhi(sNx+2,0,bi,bj)= vPhi(sNx,0,bi,bj) |
167 |
vPhi(sNx+1,0,bi,bj)= uPhi(sNx+2,1,bi,bj) |
168 |
ENDIF |
169 |
ENDIF |
170 |
IF ( exch2_isEedge(myTile) .EQ. 1 .AND. |
171 |
& exch2_isNedge(myTile) .EQ. 1 ) THEN |
172 |
C Zero NE corner points |
173 |
DO J=sNy+1,sNy+OLy |
174 |
DO I=sNx+2,sNx+OLx |
175 |
uPhi(I,J,bi,bj)=0. |
176 |
ENDDO |
177 |
ENDDO |
178 |
DO J=sNy+2,sNy+OLy |
179 |
DO I=sNx+1,sNx+OLx |
180 |
vPhi(I,J,bi,bj)=0. |
181 |
ENDDO |
182 |
ENDDO |
183 |
uPhi(sNx+2,sNy+1,bi,bj)=vPhi(sNx,sNy+2,bi,bj) |
184 |
vPhi(sNx+1,sNy+2,bi,bj)=uPhi(sNx+2,sNy,bi,bj) |
185 |
ENDIF |
186 |
ENDDO |
187 |
ENDDO |
188 |
|
189 |
ELSE |
190 |
c CALL EXCH_RX( Uphi, |
191 |
c I OLw, OLe, OLs, OLn, myNz, |
192 |
c I exchWidthX, exchWidthY, |
193 |
c I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
194 |
c CALL EXCH_RX( Vphi, |
195 |
c I OLw, OLe, OLs, OLn, myNz, |
196 |
c I exchWidthX, exchWidthY, |
197 |
c I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
198 |
c_jmc: for JAM compatibility, replace the 2 CALLs above by the 2 CPP_MACROs: |
199 |
_EXCH_XY_RX( Uphi, myThid ) |
200 |
_EXCH_XY_RX( Vphi, myThid ) |
201 |
ENDIF |
202 |
|
203 |
RETURN |
204 |
END |
205 |
|
206 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
207 |
|
208 |
CEH3 ;;; Local Variables: *** |
209 |
CEH3 ;;; mode:fortran *** |
210 |
CEH3 ;;; End: *** |