/[MITgcm]/MITgcm/eesupp/src/ini_communication_patterns.F
ViewVC logotype

Contents of /MITgcm/eesupp/src/ini_communication_patterns.F

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


Revision 1.6 - (show annotations) (download)
Fri Sep 21 03:54:35 2001 UTC (22 years, 7 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint52l_pre, checkpoint44e_post, hrcube4, hrcube5, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, release1_p13_pre, checkpoint50c_post, checkpoint46f_post, checkpoint52d_pre, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint52j_pre, checkpoint43a-release1mods, checkpoint51o_pre, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, release1_p13, checkpoint51l_post, checkpoint48i_post, checkpoint46l_pre, checkpoint52l_post, checkpoint52k_post, chkpt44d_post, checkpoint51, checkpoint50, checkpoint52, release1_p8, release1_p9, checkpoint50d_post, release1_p1, release1_p2, release1_p3, release1_p4, release1_p5, release1_p6, release1_p7, checkpoint52f_post, checkpoint50b_pre, checkpoint44e_pre, checkpoint51f_post, release1_b1, ecco_c51_e34d, ecco_c51_e34e, ecco_c51_e34f, ecco_c51_e34g, ecco_c51_e34a, ecco_c51_e34b, ecco_c51_e34c, checkpoint48b_post, checkpoint43, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint51t_post, checkpoint51n_post, release1_chkpt44d_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint51s_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, checkpoint52e_pre, release1_p11, checkpoint52e_post, checkpoint51n_pre, checkpoint47d_post, icebear5, icebear4, icebear3, icebear2, checkpoint46d_pre, checkpoint48d_post, release1-branch_tutorials, checkpoint48f_post, checkpoint45d_post, checkpoint52b_pre, checkpoint46j_pre, checkpoint51l_pre, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint51q_post, ecco_c50_e29, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint52b_post, checkpoint52c_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, ecco_c50_e28, chkpt44c_pre, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint52f_pre, ecco_c44_e19, ecco_c44_e18, ecco_c44_e17, ecco_c44_e16, release1_p12, release1_p10, release1_p16, release1_p17, release1_p14, release1_p15, checkpoint47j_post, ecco_c50_e33a, branch-exfmods-tag, checkpoint44g_post, branchpoint-genmake2, checkpoint46e_pre, checkpoint51r_post, checkpoint48c_post, checkpoint45b_post, checkpoint46b_pre, checkpoint51i_post, release1-branch-end, release1_final_v1, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint46, checkpoint47b_post, checkpoint44b_post, ecco_c51_e34, checkpoint46h_pre, checkpoint52d_post, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, checkpoint46g_post, release1_p12_pre, checkpoint52a_pre, ecco_c44_e22, checkpoint50h_post, checkpoint52i_post, checkpoint50e_pre, checkpoint50i_post, ecco_c44_e25, checkpoint51i_pre, checkpoint52h_pre, checkpoint52j_post, checkpoint47f_post, checkpoint50e_post, chkpt44a_pre, checkpoint46i_post, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, checkpoint46c_post, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5, branch-netcdf, checkpoint50d_pre, checkpoint46e_post, release1_beta1, checkpoint51e_post, checkpoint44b_pre, checkpoint42, checkpoint41, checkpoint47, checkpoint44, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51o_post, checkpoint51f_pre, chkpt44c_post, checkpoint48g_post, checkpoint47h_post, checkpoint52a_post, checkpoint44f_pre, checkpoint51g_post, ecco_c52_e35, checkpoint46d_post, checkpoint50b_post, release1-branch_branchpoint, checkpoint51m_post, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: c24_e25_ice, branch-exfmods-curt, release1_final, release1-branch, branch-genmake2, release1, branch-nonh, tg2-branch, ecco-branch, release1_50yr, netcdf-sm0, icebear, checkpoint51n_branch, release1_coupled
Changes since 1.5: +37 -27 lines
Starting to bring comments up to date and format comments
for document extraction of "prototypes".

1 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/ini_communication_patterns.F,v 1.5 2001/09/05 19:59:31 adcroft Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 CBOP
7
8 C !ROUTINE: INI_COMMUNICATION_PATTERNS
9
10 C !INTERFACE:
11 SUBROUTINE INI_COMMUNICATION_PATTERNS( myThid )
12 IMPLICIT NONE
13 C !DESCRIPTION:
14 C *==========================================================*
15 C | SUBROUTINE INI_COMMUNICATION_PATTERNS
16 C | o Initialise between tile communication data structures.
17 C *==========================================================*
18 C | This routine assigns identifiers to each tile and then
19 C | defines a map of neighbors for each tile.
20 C | For each neighbor a communication method is defined.
21 C *==========================================================*
22
23 C !USES:
24 C === Global data ===
25 #include "SIZE.h"
26 #include "EEPARAMS.h"
27 #include "EESUPPORT.h"
28 #include "EXCH.h"
29
30 C !INPUT/OUTPUT PARAMETERS:
31 C === Routine arguments ===
32 C myThid :: Thread number we are dealing with in this call
33 INTEGER myThid
34
35 C !LOCAL VARIABLES:
36 C === Local variables ===
37 C pxW :: Process X coord of process to west.
38 C pxE :: Process X coord of process to west.
39 C pyN :: Process Y coord of process to north.
40 C pyS :: Process Y coord of process to south.
41 C procW :: Process Id of process to west.
42 C procE :: Process Id of process to east.
43 C procN :: Process Id of process to north.
44 C procS :: Process Id of process to south.
45 C totalTileCount :: Total number of tiles
46 C tagW0, tagE0, tagS0, tagN0, theTag :: Working variables for
47 C calculating message tags.
48 C biW, biE, bjN, bjS :: Tile x and y indices to west, east,
49 C south and north.
50 C bi, bj :: Tile loop counter
51 C pi, pj :: Process loop counter
52 C bi0, bj0 :: Base global index coordinate ( on CS there is no global
53 C coord).
54 INTEGER bi0(nPx)
55 INTEGER bj0(nPy)
56 INTEGER bi, bj, pi, pj
57 INTEGER pxW, pxE, pyN, pyS
58 INTEGER procW, procE, procN, procS
59 INTEGER totalTileCount
60 INTEGER tagW0, tagE0, tagS0, tagN0, theTag
61 INTEGER biE, biW, bjN, bjS
62 INTEGER thePx, thePy, theBj, theBi
63 CEOP
64
65 #ifndef ALWAYS_USE_MPI
66 C-- Turn off memsync by default (e.g. needed for threads on SUNs)
67 exchNeedsMemsync = .TRUE.
68 exchUsesBarrier = .TRUE.
69 #else
70 C-- ... except that MPI needs this until some counter problem is fixed.
71 exchNeedsMemsync = .FALSE.
72 exchUsesBarrier = .FALSE.
73 #endif
74
75 C-- Define a globally unique tile numbers for each tile.
76 C-- We aslo define the tile numbers for our east, west, south
77 C-- and north neighbor tiles here. As coded below this is done from
78 C-- a simple cartesian formula. To handle irregular tile distributions
79 C-- the code below would be changed. For instance we could read
80 C-- the neighbor tile information from a file rather than deriving
81 C-- it in-line. This allows general tile distributions and connectivity
82 C-- both within a thread, between threads and between processors.
83 C Notes --
84 C 1. The cartesian based formula coded below works as follows:
85 C i. Each tile has one west neighbor, one east neighbor
86 C one north neignbor and one south neighbor.
87 C ii. For each of my neighbors store the following
88 C - neighbor tile id
89 C - neighbor process id
90 C 2. The information that is stored is then used to determine
91 C the between tile communication method. The method used
92 C depends on whether the tile is part of the same process,
93 C on the same machine etc...
94 C 3. To initialise a tile distribution with holes in it
95 C i.e. tiles that are not computed on. Set tile number to
96 C the value NULL_TILE. This must also be done for tileNoW,
97 C tileNoE, tileNoS, tileNoN.
98 C 4. The default formula below assigns tile numbers sequentially
99 C in X on the **global** grid. Within a process the tile numbers
100 C will not necessairily be sequential. This means that the tile
101 C numbering label does not change when nTx, nTy, nPx or nPy change.
102 C It will only change if the tile size changes or the global
103 C grid changes.
104 C bi0 and bj0 are the base global tile grid coordinate for the first
105 C tile in this process.
106 DO pi = 1, nPx
107 bi0(pi) = pi
108 ENDDO
109 DO pj = 1, nPy
110 bj0(pj) = pj
111 ENDDO
112 DO bj=myByLo(myThid),myByHi(myThid)
113 DO bi=myBxLo(myThid),myBxHi(myThid)
114 C o My tile identifier
115 Crg tileNo(bi,bj) = (bj0(myPy)-1+bj-1)*nSx*nPx+bi0(myPx)+bi-1
116 thePx = myPx
117 thePy = myPy
118 theBj = bj
119 theBi = bi
120 tileNo(bi,bj) =
121 & ((thePy-1)*nSy+theBj-1)*nSx*nPx
122 & + (thePx-1)*nSx
123 & + theBi
124 C o My west neighbor tile and process identifier
125 biW = bi-1
126 pxW = myPx
127 procW = myPid
128 IF ( biW .LT. 1 ) THEN
129 biW = nSx
130 pxW = myPx-1
131 procW = pidW
132 IF ( pxW .LT. 1 ) pxW = nPx
133 ENDIF
134 Crg tileNoW (bi,bj) = (bj0(myPy)-1+bj-1)*nSx*nPx+bi0(pxW)+biW-1
135 thePx = pxW
136 thePy = myPy
137 theBj = bj
138 theBi = biW
139 tileNoW (bi,bj) =
140 & ((thePy-1)*nSy+theBj-1)*nSx*nPx
141 & + (thePx-1)*nSx
142 & + theBi
143 tilePidW(bi,bj) = procW
144 tileBiW (bi,bj) = biW
145 tileBjW (bi,bj) = bj
146 C o My east neighbor tile and process identifier
147 biE = bi+1
148 pxE = myPx
149 procE = myPid
150 IF ( biE .GT. nSx ) THEN
151 biE = 1
152 pxE = myPx+1
153 procE = pidE
154 IF ( pxE .GT. nPx ) pxE = 1
155 ENDIF
156 Crg tileNoE(bi,bj) = (bj0(myPy)-1+bj-1)*nSx*nPx+bi0(pxE)+biE-1
157 thePx = pxE
158 thePy = myPy
159 theBi = biE
160 theBj = bj
161 tileNoE(bi,bj) =
162 & ((thePy-1)*nSy+theBj-1)*nSx*nPx
163 & + (thePx-1)*nSx
164 & + theBi
165 tilePidE(bi,bj) = procE
166 tileBiE (bi,bj) = biE
167 tileBjE (bi,bj) = bj
168 C o My north neighbor tile and process identifier
169 bjN = bj+1
170 pyN = myPy
171 procN = myPid
172 IF ( bjN .GT. nSy ) THEN
173 bjN = 1
174 pyN = myPy+1
175 procN = pidN
176 IF ( pyN .GT. nPy ) pyN = 1
177 ENDIF
178 Crg tileNoN(bi,bj) = (bj0(pyN)-1+bjN-1)*nSx*nPx+bi0(myPx)+bi-1
179 thePx = myPx
180 thePy = pyN
181 theBi = bi
182 theBj = bjN
183 tileNoN(bi,bj) =
184 & ((thePy-1)*nSy+theBj-1)*nSx*nPx
185 & + (thePx-1)*nSx
186 & + theBi
187 tilePidN(bi,bj) = procN
188 tileBiN(bi,bj) = bi
189 tileBjN(bi,bj) = bjN
190 C o My south neighbor tile and process identifier
191 bjS = bj-1
192 pyS = myPy
193 procS = myPid
194 IF ( bjS .LT. 1 ) THEN
195 bjS = nSy
196 pyS = pyS-1
197 procS = pidS
198 IF ( pyS .LT. 1 ) pyS = nPy
199 ENDIF
200 Crg tileNoS(bi,bj) = (bj0(pyS+1)-1+bjS-1)*nSx*nPx+bi0(myPx+1)+bi-1
201 thePx = myPx
202 thePy = pyS
203 theBi = bi
204 theBj = bjS
205 tileNoS(bi,bj) =
206 & ((thePy-1)*nSy+theBj-1)*nSx*nPx
207 & + (thePx-1)*nSx
208 & + theBi
209 tilePidS(bi,bj) = procS
210 tileBiS(bi,bj) = bi
211 tileBjS(bi,bj) = bjS
212 ENDDO
213 ENDDO
214
215 C-- Define the total count of tiles.
216 totalTileCount = nSx*nSy*nPx*nPy
217
218 C-- Set tags for each tile face.
219 C Tags are used to distinguish exchanges from particular
220 C faces of particular tiles.
221 C Tag numbers are based on
222 C i - The tile number
223 C ii - The direction (N,S,W,E) of the message
224 C We dont check for the NULL_TILE tile number here as it
225 C should not actually be used.
226 TagW0=1
227 TagE0=2
228 TagN0=3
229 TagS0=4
230 DO bj=myByLo(myThid),myByHi(myThid)
231 DO bi=myBxLo(myThid),myBxHi(myThid)
232 C Send tags
233 C o Tag I use for messages I send to west
234 theTag = TagW0*totalTileCount+tileNo(bi,bj)-1
235 tileTagSendW(bi,bj) = theTag
236 C o Tag I use for messages I send to east
237 theTag = TagE0*totalTileCount+tileNo(bi,bj)-1
238 tileTagSendE(bi,bj) = theTag
239 C o Tag I use for messages I send to north
240 theTag = TagN0*totalTileCount+tileNo(bi,bj)-1
241 tileTagSendN(bi,bj) = theTag
242 C o Tag I use for messages I send to south
243 theTag = TagS0*totalTileCount+tileNo(bi,bj)-1
244 tileTagSendS(bi,bj) = theTag
245 C Receive tags
246 C o Tag on messages I receive from my east
247 theTag = TagW0*totalTileCount+tileNoE(bi,bj)-1
248 tileTagRecvE(bi,bj) = theTag
249 C o Tag on messages I receive from my west
250 theTag = TagE0*totalTileCount+tileNoW(bi,bj)-1
251 tileTagRecvW(bi,bj) = theTag
252 C o Tag on messages I receive from my north
253 theTag = TagS0*totalTileCount+tileNoN(bi,bj)-1
254 tileTagRecvN(bi,bj) = theTag
255 C o Tag on messages I receive from my north
256 theTag = TagN0*totalTileCount+tileNoS(bi,bj)-1
257 tileTagRecvS(bi,bj) = theTag
258 ENDDO
259 ENDDO
260
261 C-- Set the form of excahnge to use between neighboring
262 C -- tiles.
263 C For now use either shared memory, messages or nothing. Further
264 C rules can be added later to allow shm regions and ump regions
265 C etc...
266 C Notes -
267 C 1. We require symmetry here. If one face of a tile uses
268 C communication method A then the matching face on its neighbor
269 C tile must also use communication method A.
270 DO bj=myByLo(myThid),myByHi(myThid)
271 DO bi=myBxLo(myThid),myBxHi(myThid)
272 C o West face communication
273 IF ( tileNoW(bi,bj) .EQ. NULL_TILE ) THEN
274 tileCommModeW(bi,bj) = COMM_NONE
275 ELSE
276 IF ( myPid .EQ. tilePidW(bi,bj) ) THEN
277 tileCommModeW(bi,bj) = COMM_PUT
278 ELSE
279 tileCommModeW(bi,bj) = COMM_MSG
280 ENDIF
281 ENDIF
282 C o East face communication
283 IF ( tileNoE(bi,bj) .EQ. NULL_TILE ) THEN
284 tileCommModeE(bi,bj) = COMM_NONE
285 ELSE
286 IF ( myPid .EQ. tilePidE(bi,bj) ) THEN
287 tileCommModeE(bi,bj) = COMM_PUT
288 ELSE
289 tileCommModeE(bi,bj) = COMM_MSG
290 ENDIF
291 ENDIF
292 C o South face communication
293 IF ( tileNoS(bi,bj) .EQ. NULL_TILE ) THEN
294 tileCommModeS(bi,bj) = COMM_NONE
295 ELSE
296 IF ( myPid .EQ. tilePidS(bi,bj) ) THEN
297 tileCommModeS(bi,bj) = COMM_PUT
298 ELSE
299 tileCommModeS(bi,bj) = COMM_MSG
300 ENDIF
301 ENDIF
302 C o North face communication
303 IF ( tileNoN(bi,bj) .EQ. NULL_TILE ) THEN
304 tileCommModeN(bi,bj) = COMM_NONE
305 ELSE
306 IF ( myPid .EQ. tilePidN(bi,bj) ) THEN
307 tileCommModeN(bi,bj) = COMM_PUT
308 ELSE
309 tileCommModeN(bi,bj) = COMM_MSG
310 ENDIF
311 ENDIF
312
313 ENDDO
314 ENDDO
315
316 C Initialise outstanding exchange request counter
317 DO bj=myByLo(myThid),myByHi(myThid)
318 DO bi=myBxLo(myThid),myBxHi(myThid)
319 exchNReqsX(1,bi,bj) = 0
320 exchNReqsY(1,bi,bj) = 0
321 ENDDO
322 ENDDO
323
324 RETURN
325 END

  ViewVC Help
Powered by ViewVC 1.1.22