1 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/fill_cs_corner_tr_rl.F,v 1.3 2007/08/16 02:11:19 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_EEOPTIONS.h" |
6 |
|
7 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
8 |
CBOP |
9 |
C !ROUTINE: FILL_CS_CORNER_AG_RL |
10 |
|
11 |
C !INTERFACE: |
12 |
SUBROUTINE FILL_CS_CORNER_AG_RL( |
13 |
I fill4dirX, withSigns, |
14 |
U uFld, vFld, |
15 |
I bi,bj, myThid) |
16 |
|
17 |
C !DESCRIPTION: |
18 |
C *==========================================================* |
19 |
C | SUBROUTINE FILL_CS_CORNER_AG_RL |
20 |
C | o Fill the corner-halo region of CS-grid, |
21 |
C | for a 2 components vector field on A-grid (center of grid cell) |
22 |
C *==========================================================* |
23 |
C | o the corner halo region is filled with valid values |
24 |
C | in order to compute (later on) gradient in X or Y |
25 |
C | direction, on a wide stencil. |
26 |
C *==========================================================* |
27 |
|
28 |
C !USES: |
29 |
IMPLICIT NONE |
30 |
|
31 |
C == Global variables == |
32 |
#include "SIZE.h" |
33 |
#include "EEPARAMS.h" |
34 |
#ifdef ALLOW_EXCH2 |
35 |
#include "W2_EXCH2_TOPOLOGY.h" |
36 |
#include "W2_EXCH2_PARAMS.h" |
37 |
#endif /* ALLOW_EXCH2 */ |
38 |
|
39 |
C !INPUT/OUTPUT PARAMETERS: |
40 |
C == Routine arguments == |
41 |
C |
42 |
C fill4dirX :: True = prepare for X direction calculations |
43 |
C otherwise, prepare for Y direction |
44 |
C withSigns :: True = account for sign of vector component |
45 |
C uFld :: u-component of vector field array with empty corners to fill |
46 |
C vFld :: v-component of vector field array with empty corners to fill |
47 |
C bi,bj :: tile indices |
48 |
C myThid :: thread number |
49 |
LOGICAL fill4dirX |
50 |
LOGICAL withSigns |
51 |
_RL uFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
52 |
_RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
53 |
INTEGER bi,bj |
54 |
INTEGER myThid |
55 |
|
56 |
C !LOCAL VARIABLES: |
57 |
C == Local variables == |
58 |
C i,j :: loop indices |
59 |
C myTile :: tile number |
60 |
INTEGER i,j |
61 |
LOGICAL southWestCorner |
62 |
LOGICAL southEastCorner |
63 |
LOGICAL northWestCorner |
64 |
LOGICAL northEastCorner |
65 |
_RL negOne |
66 |
#ifdef ALLOW_EXCH2 |
67 |
INTEGER myTile |
68 |
#endif |
69 |
CEOP |
70 |
|
71 |
negOne = 1. |
72 |
IF (withSigns) negOne = -1. |
73 |
|
74 |
IF (useCubedSphereExchange) THEN |
75 |
|
76 |
#ifdef ALLOW_EXCH2 |
77 |
myTile = W2_myTileList(bi) |
78 |
southWestCorner = exch2_isWedge(myTile).EQ.1 |
79 |
& .AND. exch2_isSedge(myTile).EQ.1 |
80 |
southEastCorner = exch2_isEedge(myTile).EQ.1 |
81 |
& .AND. exch2_isSedge(myTile).EQ.1 |
82 |
northEastCorner = exch2_isEedge(myTile).EQ.1 |
83 |
& .AND. exch2_isNedge(myTile).EQ.1 |
84 |
northWestCorner = exch2_isWedge(myTile).EQ.1 |
85 |
& .AND. exch2_isNedge(myTile).EQ.1 |
86 |
#else |
87 |
southWestCorner = .TRUE. |
88 |
southEastCorner = .TRUE. |
89 |
northWestCorner = .TRUE. |
90 |
northEastCorner = .TRUE. |
91 |
#endif |
92 |
|
93 |
IF ( fill4dirX ) THEN |
94 |
C-- Internal exchange for calculations in X |
95 |
|
96 |
C- For cube face corners we need to duplicate the |
97 |
C- i-1 and i+1 values into the null space as follows: |
98 |
C |
99 |
C |
100 |
C o NW corner: copy T( 0,sNy ) into T( 0,sNy+1) e.g. |
101 |
C | |
102 |
C x T(0,sNy+1) | |
103 |
C /\ | |
104 |
C --||------------|----------- |
105 |
C || | |
106 |
C x T(0,sNy) | x T(1,sNy) |
107 |
C | |
108 |
C |
109 |
C o SW corner: copy T(0,1) into T(0,0) e.g. |
110 |
C | |
111 |
C x T(0,1) | x T(1,1) |
112 |
C || | |
113 |
C --||------------|----------- |
114 |
C \/ | |
115 |
C x T(0,0) | |
116 |
C | |
117 |
C |
118 |
C o NE corner: copy T(sNx+1,sNy ) into T(sNx+1,sNy+1) e.g. |
119 |
C | |
120 |
C | x T(sNx+1,sNy+1) |
121 |
C | /\ |
122 |
C ----------------|--||------- |
123 |
C | || |
124 |
C x T(sNx,sNy) | x T(sNx+1,sNy ) |
125 |
C | |
126 |
C o SE corner: copy T(sNx+1,1 ) into T(sNx+1,0 ) e.g. |
127 |
C | |
128 |
C x T(sNx,1) | x T(sNx+1, 1) |
129 |
C | || |
130 |
C ----------------|--||------- |
131 |
C | \/ |
132 |
C | x T(sNx+1, 0) |
133 |
IF ( southWestCorner ) THEN |
134 |
DO j=1,OLy |
135 |
DO i=1,OLx |
136 |
uFld( 1-i , 1-j ) = vFld( 1-j , i )*negOne |
137 |
vFld( 1-i , 1-j ) = uFld( 1-j , i ) |
138 |
ENDDO |
139 |
ENDDO |
140 |
ENDIF |
141 |
IF ( southEastCorner ) THEN |
142 |
DO j=1,OLy |
143 |
DO i=1,OLx |
144 |
uFld(sNx+i, 1-j ) = vFld(sNx+j, i ) |
145 |
vFld(sNx+i, 1-j ) = uFld(sNx+j, i )*negOne |
146 |
ENDDO |
147 |
ENDDO |
148 |
ENDIF |
149 |
IF ( northWestCorner ) THEN |
150 |
DO j=1,OLy |
151 |
DO i=1,OLx |
152 |
uFld( 1-i ,sNy+j) = vFld( 1-j , sNy+1-i ) |
153 |
vFld( 1-i ,sNy+j) = uFld( 1-j , sNy+1-i )*negOne |
154 |
ENDDO |
155 |
ENDDO |
156 |
ENDIF |
157 |
IF ( northEastCorner ) THEN |
158 |
DO j=1,OLy |
159 |
DO i=1,OLx |
160 |
uFld(sNx+i,sNy+j) = vFld(sNx+j, sNy+1-i )*negOne |
161 |
vFld(sNx+i,sNy+j) = uFld(sNx+j, sNy+1-i ) |
162 |
ENDDO |
163 |
ENDDO |
164 |
ENDIF |
165 |
|
166 |
C-- End of X direction ; start Y direction case. |
167 |
|
168 |
ELSE |
169 |
C-- Internal exchange for calculations in Y |
170 |
|
171 |
C- For cube face corners we need to duplicate the |
172 |
C- j-1 and j+1 values into the null space as follows: |
173 |
C |
174 |
C o SW corner: copy T(0,1) into T(0,0) e.g. |
175 |
C | |
176 |
C | x T(1,1) |
177 |
C | |
178 |
C ----------------|----------- |
179 |
C | |
180 |
C x T(0,0)<====== x T(1,0) |
181 |
C | |
182 |
C |
183 |
C o NW corner: copy T( 0,sNy ) into T( 0,sNy+1) e.g. |
184 |
C | |
185 |
C x T(0,sNy+1)<=== x T(1,sNy+1) |
186 |
C | |
187 |
C ----------------|----------- |
188 |
C | |
189 |
C | x T(1,sNy) |
190 |
C | |
191 |
C |
192 |
C o NE corner: copy T(sNx+1,sNy ) into T(sNx+1,sNy+1) e.g. |
193 |
C | |
194 |
C x T(sNx,sNy+1)=====>x T(sNx+1,sNy+1) |
195 |
C | |
196 |
C ----------------|----------- |
197 |
C | |
198 |
C x T(sNx,sNy) | |
199 |
C | |
200 |
C o SE corner: copy T(sNx+1,1 ) into T(sNx+1,0 ) e.g. |
201 |
C | |
202 |
C x T(sNx,1) | |
203 |
C | |
204 |
C ----------------|----------- |
205 |
C | |
206 |
C x T(sNx,0) =====>x T(sNx+1, 0) |
207 |
IF ( southWestCorner ) THEN |
208 |
DO j=1,Oly |
209 |
DO i=1,Olx |
210 |
uFld( 1-i , 1-j ) = vFld( j , 1-i ) |
211 |
vFld( 1-i , 1-j ) = uFld( j , 1-i )*negOne |
212 |
ENDDO |
213 |
ENDDO |
214 |
ENDIF |
215 |
IF ( southEastCorner ) THEN |
216 |
DO j=1,Oly |
217 |
DO i=1,Olx |
218 |
uFld(sNx+i, 1-j ) = vFld(sNx+1-j, 1-i )*negOne |
219 |
vFld(sNx+i, 1-j ) = uFld(sNx+1-j, 1-i ) |
220 |
ENDDO |
221 |
ENDDO |
222 |
ENDIF |
223 |
IF ( northWestCorner ) THEN |
224 |
DO j=1,Oly |
225 |
DO i=1,Olx |
226 |
uFld( 1-i ,sNy+j) = vFld( j ,sNy+i)*negOne |
227 |
vFld( 1-i ,sNy+j) = uFld( j ,sNy+i) |
228 |
ENDDO |
229 |
ENDDO |
230 |
ENDIF |
231 |
IF ( northEastCorner ) THEN |
232 |
DO j=1,Oly |
233 |
DO i=1,Olx |
234 |
uFld(sNx+i,sNy+j) = vFld(sNx+1-j,sNy+i) |
235 |
vFld(sNx+i,sNy+j) = uFld(sNx+1-j,sNy+i)*negOne |
236 |
ENDDO |
237 |
ENDDO |
238 |
ENDIF |
239 |
|
240 |
C- End of Y direction case. |
241 |
ENDIF |
242 |
|
243 |
C-- End useCubedSphereExchange |
244 |
ENDIF |
245 |
|
246 |
RETURN |
247 |
END |