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