/[MITgcm]/MITgcm/pkg/exch2/exch2_get_uv_bounds.F
ViewVC logotype

Annotation of /MITgcm/pkg/exch2/exch2_get_uv_bounds.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Tue Sep 4 00:40:25 2012 UTC (11 years, 9 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63s, checkpoint64, checkpoint65, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, HEAD
Changes since 1.3: +3 -1 lines
includes "CPP_EEOPTIONS.h"

1 jmc 1.4 C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_get_uv_bounds.F,v 1.3 2012/03/26 19:13:15 jmc Exp $
2 jmc 1.1 C $Name: $
3    
4 jmc 1.4 #include "CPP_EEOPTIONS.h"
5    
6 jmc 1.1 CBOP
7     C !ROUTINE: EXCH2_GET_UV_BOUNDS
8    
9     C !INTERFACE:
10     SUBROUTINE EXCH2_GET_UV_BOUNDS(
11 jmc 1.3 I fCode, eWdth, updateCorners,
12 jmc 1.2 I tgTile, tgNb,
13     O tIlo1, tIhi1, tJlo1, tJhi1,
14     O tIlo2, tIhi2, tJlo2, tJhi2,
15     O tiStride, tjStride,
16     O e2_oi1, e2_oj1, e2_oi2, e2_oj2,
17     I myThid )
18 jmc 1.1
19     C !DESCRIPTION:
20 jmc 1.2 C Return the index range & step of the part of the array (overlap-region)
21     C which is going to be updated by the exchange with 1 neighbour.
22     C 2 components vector field (UV) version.
23    
24 jmc 1.1
25     C !USES:
26     IMPLICIT NONE
27     C == Global data ==
28 jmc 1.2 #include "SIZE.h"
29     #include "W2_EXCH2_SIZE.h"
30     #include "W2_EXCH2_TOPOLOGY.h"
31 jmc 1.1
32     C !INPUT/OUTPUT PARAMETERS:
33 jmc 1.2 C fCode :: field code (position on staggered grid)
34     C eWdth :: width of data region to exchange
35     C updateCorners :: flag, do update corner halo region if true
36     C tgTile :: target tile
37     C tgNb :: target Neighbour entry
38     C tIlo1, tIhi1 :: index range in I that will be filled in 1rst comp. array
39     C tJlo1, tJhi1 :: index range in J that will be filled in 1rst comp. array
40     C tIlo2, tIhi2 :: index range in I that will be filled in 2nd comp. array
41     C tJlo2, tJhi2 :: index range in J that will be filled in 2nd comp. array
42     C tiStride :: index step in I that will be filled in target arrays
43     C tjStride :: index step in J that will be filled in target arrays
44     C e2_oi1 :: index offset in target to source-1 index relation
45     C e2_oj1 :: index offset in target to source-1 index relation
46     C e2_oi2 :: index offset in target to source-2 index relation
47     C e2_oj2 :: index offset in target to source-2 index relation
48     C myThid :: my Thread Id. number
49 jmc 1.1
50     CHARACTER*2 fCode
51     INTEGER eWdth
52 jmc 1.3 LOGICAL updateCorners
53 jmc 1.2 INTEGER tgTile, tgNb
54 jmc 1.1 INTEGER tIlo1, tIhi1, tJlo1, tJhi1
55     INTEGER tIlo2, tIhi2, tJlo2, tJhi2
56     INTEGER tiStride, tjStride
57     INTEGER e2_oi1, e2_oj1
58     INTEGER e2_oi2, e2_oj2
59     INTEGER myThid
60     C
61     C !LOCAL VARIABLES:
62 jmc 1.2 C soTile :: source tile
63     C soNb :: source Neighbour entry
64     INTEGER soTile
65     INTEGER soNb
66     INTEGER tIlo, tIhi, tJlo, tJhi
67     INTEGER i, e2_pij(4)
68 jmc 1.1
69     C--- exch2 target to source index relation:
70     C is = pij(1)*it + pij(2)*jt + oi
71     C js = pij(3)*it + pij(4)*jt + oj
72    
73 jmc 1.2 C--- Initialise index range from Topology values:
74     tIlo = exch2_iLo(tgNb,tgTile)
75     tIhi = exch2_iHi(tgNb,tgTile)
76     tJlo = exch2_jLo(tgNb,tgTile)
77     tJhi = exch2_jHi(tgNb,tgTile)
78     soNb = exch2_opposingSend(tgNb,tgTile)
79     soTile = exch2_neighbourId(tgNb,tgTile)
80     e2_oi1 = exch2_oi(soNb,soTile)
81     e2_oj1 = exch2_oj(soNb,soTile)
82     DO i=1,4
83     e2_pij(i) = exch2_pij(i,soNb,soTile)
84     ENDDO
85 jmc 1.1
86     C--- Expand index range according to exchange-Width "eWdth"
87     IF ( tIlo.EQ.tIhi .AND. tIlo.EQ.0 ) THEN
88 jmc 1.2 C Filling a west edge overlap
89 jmc 1.1 tIlo1 = 1-eWdth
90     tIhi1 = 0
91 jmc 1.2 tiStride = 1
92 jmc 1.1 IF ( tJlo.LE.tJhi ) THEN
93     tjStride=1
94     ELSE
95     tjStride=-1
96     ENDIF
97 jmc 1.3 IF ( updateCorners ) THEN
98 jmc 1.2 tJlo1 = tJlo-tjStride*(eWdth-1)
99     tJhi1 = tJhi+tjStride*(eWdth-1)
100 jmc 1.3 ELSE
101     tJlo1 = tJlo+tjStride
102     tJhi1 = tJhi-tjStride
103     ENDIF
104 jmc 1.1 ENDIF
105     IF ( tIlo.EQ.tIhi .AND. tIlo.GT.1 ) THEN
106 jmc 1.2 C Filling an east edge overlap
107     tIlo1 = tIlo
108 jmc 1.1 tIhi1 = tIhi+eWdth-1
109 jmc 1.2 tiStride = 1
110 jmc 1.1 IF ( tJlo.LE.tJhi ) THEN
111 jmc 1.2 tjStride = 1
112 jmc 1.1 ELSE
113 jmc 1.2 tjStride =-1
114 jmc 1.1 ENDIF
115 jmc 1.3 IF ( updateCorners ) THEN
116 jmc 1.2 tJlo1 = tJlo-tjStride*(eWdth-1)
117     tJhi1 = tJhi+tjStride*(eWdth-1)
118 jmc 1.3 ELSE
119     tJlo1 = tJlo+tjStride
120     tJhi1 = tJhi-tjStride
121     ENDIF
122 jmc 1.1 ENDIF
123     IF ( tJlo.EQ.tJhi .AND. tJlo.EQ.0 ) THEN
124 jmc 1.2 C Filling a south edge overlap
125 jmc 1.1 tJlo1 = 1-eWdth
126     tJhi1 = 0
127 jmc 1.2 tjStride = 1
128 jmc 1.1 IF ( tIlo .LE. tIhi ) THEN
129 jmc 1.2 tiStride = 1
130 jmc 1.1 ELSE
131 jmc 1.2 tiStride =-1
132 jmc 1.1 ENDIF
133 jmc 1.3 IF ( updateCorners ) THEN
134 jmc 1.2 tIlo1 = tIlo-tiStride*(eWdth-1)
135     tIhi1 = tIhi+tiStride*(eWdth-1)
136 jmc 1.3 ELSE
137     tIlo1 = tIlo+tiStride
138     tIhi1 = tIhi-tiStride
139     ENDIF
140 jmc 1.1 ENDIF
141     IF ( tJlo.EQ.tJhi .AND. tJlo.GT.1 ) THEN
142 jmc 1.2 C Filling a north edge overlap
143     tJlo1 = tJlo
144 jmc 1.1 tJhi1 = tJhi+eWdth-1
145 jmc 1.2 tjStride = 1
146 jmc 1.1 IF ( tIlo.LE.tIhi ) THEN
147 jmc 1.2 tiStride = 1
148 jmc 1.1 ELSE
149 jmc 1.2 tiStride =-1
150 jmc 1.1 ENDIF
151 jmc 1.3 IF ( updateCorners ) THEN
152 jmc 1.2 tIlo1 = tIlo-tiStride*(eWdth-1)
153     tIhi1 = tIhi+tiStride*(eWdth-1)
154 jmc 1.3 ELSE
155     tIlo1 = tIlo+tiStride
156     tIhi1 = tIhi-tiStride
157     ENDIF
158 jmc 1.1 ENDIF
159    
160     C--- copy to 2nd set of indices
161     tIlo2 = tIlo1
162     tIhi2 = tIhi1
163     tJlo2 = tJlo1
164     tJhi2 = tJhi1
165     e2_oi2 = e2_oi1
166     e2_oj2 = e2_oj1
167    
168     IF ( fCode.EQ.'Cg' ) THEN
169     C--- UV C-Grid specific code: start here
170    
171     C--- half grid-cell location with inverse index relation
172     C => increase the offset by 1 (relative to tracer cell-centered offset)
173     C if pij(1) is -1 then +i in source aligns with -i in target
174     C if pij(3) is -1 then +j in source aligns with -i in target
175     IF ( e2_pij(1) .EQ. -1 ) THEN
176     e2_oi1 = e2_oi1 + 1
177     ENDIF
178     IF ( e2_pij(3) .EQ. -1 ) THEN
179     e2_oj1 = e2_oj1 + 1
180     ENDIF
181     C if pij(2) is -1 then +i in source aligns with -j in target
182     C if pij(4) is -1 then +j in source aligns with -j in target
183     IF ( e2_pij(2) .EQ. -1 ) THEN
184     e2_oi2 = e2_oi2 + 1
185     ENDIF
186     IF ( e2_pij(4) .EQ. -1 ) THEN
187     e2_oj2 = e2_oj2 + 1
188     ENDIF
189 jmc 1.3
190     C--- adjust index lower and upper bounds (fct of updateCorners):
191     IF ( updateCorners ) THEN
192    
193 jmc 1.1 C-- as a consequence, need also to increase the index lower bound
194     C (avoid "out-of bounds" problems ; formerly itlreduce,jtlreduce)
195     IF ( e2_pij(1).EQ.-1 .OR. e2_pij(3).EQ.-1 ) tIlo1 = tIlo1+1
196     IF ( e2_pij(2).EQ.-1 .OR. e2_pij(4).EQ.-1 ) tJlo2 = tJlo2+1
197    
198     C--- Avoid updating (some) tile-corner halo region if across faces
199     c IF ( tIlo.EQ.tIhi .AND. tIlo.EQ.0 ) THEN
200 jmc 1.2 c IF ( exch2_isSedge(tgTile).EQ.1 ) THEN
201 jmc 1.1 C- West edge is touching the face S edge
202     c tJlo1 = tJlo+1
203     c tJlo2 = tJlo+1
204     c ENDIF
205 jmc 1.2 c IF ( exch2_isNedge(tgTile).EQ.1 ) THEN
206 jmc 1.1 C- West edge is touching the face N edge
207     c tJhi1 = tJhi-1
208     c tJhi2 = tJhi
209     c ENDIF
210     c ENDIF
211     IF ( tIlo.EQ.tIhi .AND. tIlo.GT.1 ) THEN
212 jmc 1.2 IF ( exch2_isSedge(tgTile).EQ.1 ) THEN
213 jmc 1.1 C- East edge is touching the face S edge
214     tJlo1 = tJlo+1
215     tJlo2 = tJlo+1
216     ENDIF
217 jmc 1.2 IF ( exch2_isNedge(tgTile).EQ.1 ) THEN
218 jmc 1.1 C- East edge is touching the face N edge
219     tJhi1 = tJhi-1
220     tJhi2 = tJhi
221     ENDIF
222     ENDIF
223     c IF ( tJlo.EQ.tJhi .AND. tJlo.EQ.0 ) THEN
224 jmc 1.2 c IF ( exch2_isWedge(tgTile).EQ.1 ) THEN
225 jmc 1.1 C- South edge is touching the face W edge
226     c tIlo1 = tIlo+1
227     c tIlo2 = tIlo+1
228     c ENDIF
229 jmc 1.2 c IF ( exch2_isEedge(tgTile).EQ.1 ) THEN
230 jmc 1.1 C- South Edge is touching the face E edge
231     c tIhi1 = tIhi
232     c tIhi2 = tIhi-1
233     c ENDIF
234     c ENDIF
235     IF ( tJlo.EQ.tJhi .AND. tJlo.GT.1 ) THEN
236 jmc 1.2 IF ( exch2_isWedge(tgTile).EQ.1 ) THEN
237 jmc 1.1 C- North edge is touching the face W edge
238     tIlo1 = tIlo+1
239     tIlo2 = tIlo+1
240     ENDIF
241 jmc 1.2 IF ( exch2_isEedge(tgTile).EQ.1 ) THEN
242 jmc 1.1 C- North Edge is touching the face E edge
243     tIhi1 = tIhi
244     tIhi2 = tIhi-1
245     ENDIF
246     ENDIF
247    
248 jmc 1.3 ELSE
249     C--- adjust index lower and upper bounds (updateCorners = F case):
250     IF ( e2_pij(1).EQ.-1 .OR. e2_pij(3).EQ.-1 ) THEN
251     tIlo1 = tIlo1+1
252     tIhi1 = tIhi1+1
253     ENDIF
254     IF ( e2_pij(2).EQ.-1 .OR. e2_pij(4).EQ.-1 ) THEN
255     tJlo2 = tJlo2+1
256     tJhi2 = tJhi2+1
257     ENDIF
258     ENDIF
259    
260 jmc 1.1 C--- UV C-Grid specific code: end
261    
262     ELSEIF ( fCode.NE.'Ag' ) THEN
263     STOP 'ABNORMAL END: S/R EXCH2_GET_UV_BOUNDS (wrong fCode)'
264     ENDIF
265    
266     RETURN
267     END

  ViewVC Help
Powered by ViewVC 1.1.22