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