1 |
C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/exch_recv_get_y.F,v 1.1 1998/09/29 18:53:45 cnh Exp $ |
2 |
#include "CPP_EEOPTIONS.h" |
3 |
|
4 |
SUBROUTINE EXCH_RL_RECV_GET_Y( array, |
5 |
I myOLw, myOLe, myOLs, myOLn, myNz, |
6 |
I exchWidthX, exchWidthY, |
7 |
I theSimulationMode, theCornerMode, myThid ) |
8 |
C /==========================================================\ |
9 |
C | SUBROUTINE RECV_GET_Y | |
10 |
C | o "Send" or "put" Y edges for RL array. | |
11 |
C |==========================================================| |
12 |
C | Routine that invokes actual message passing send or | |
13 |
C | direct "put" of data to update X faces of an XY[R] array.| |
14 |
C \==========================================================/ |
15 |
IMPLICIT NONE |
16 |
|
17 |
C == Global variables == |
18 |
#include "SIZE.h" |
19 |
#include "EEPARAMS.h" |
20 |
#include "EESUPPORT.h" |
21 |
#include "EXCH.h" |
22 |
|
23 |
C == Routine arguments == |
24 |
C array - Array with edges to exchange. |
25 |
C myOLw - West, East, North and South overlap region sizes. |
26 |
C myOLe |
27 |
C myOLn |
28 |
C myOLs |
29 |
C exchWidthX - Width of data region exchanged. |
30 |
C exchWidthY |
31 |
C theSimulationMode - Forward or reverse mode exchange ( provides |
32 |
C support for adjoint integration of code. ) |
33 |
C theCornerMode - Flag indicating whether corner updates are |
34 |
C needed. |
35 |
C myThid - Thread number of this instance of S/R EXCH... |
36 |
C eBl - Edge buffer level |
37 |
INTEGER myOLw |
38 |
INTEGER myOLe |
39 |
INTEGER myOLs |
40 |
INTEGER myOLn |
41 |
INTEGER myNz |
42 |
_RL array(1-myOLw:sNx+myOLe, |
43 |
& 1-myOLs:sNy+myOLn, |
44 |
& myNZ, nSx, nSy) |
45 |
INTEGER exchWidthX |
46 |
INTEGER exchWidthY |
47 |
INTEGER theSimulationMode |
48 |
INTEGER theCornerMode |
49 |
INTEGER myThid |
50 |
CEndOfInterface |
51 |
|
52 |
C == Local variables == |
53 |
C I, J, K, iMin, iMax, iB - Loop counters and extents |
54 |
C bi, bj |
55 |
C biS, bjS - South tile indices |
56 |
C biN, bjN - North tile indices |
57 |
C eBl - Current exchange buffer level |
58 |
C theProc, theTag, theType, - Variables used in message building |
59 |
C theSize |
60 |
C southCommMode - Working variables holding type |
61 |
C northCommMode of communication a particular |
62 |
C tile face uses. |
63 |
C spinCount - Exchange statistics counter |
64 |
INTEGER I, J, K, iMin, iMax, jMin, jMax, iB, iB0 |
65 |
INTEGER bi, bj, biS, bjS, biN, bjN |
66 |
INTEGER eBl |
67 |
INTEGER southCommMode |
68 |
INTEGER northCommMode |
69 |
INTEGER spinCount |
70 |
#ifdef ALLOW_USE_MPI |
71 |
INTEGER theProc, theTag, theType, theSize |
72 |
INTEGER mpiStatus(MPI_STATUS_SIZE), mpiRc |
73 |
#endif |
74 |
|
75 |
|
76 |
C-- Under a "put" scenario we |
77 |
C-- i. set completetion signal for buffer we put into. |
78 |
C-- ii. wait for completetion signal indicating data has been put in |
79 |
C-- our buffer. |
80 |
C-- Under a messaging mode we "receive" the message. |
81 |
C-- Under a "get" scenario we |
82 |
C-- i. Check that the data is ready. |
83 |
C-- ii. Read the data. |
84 |
C-- iii. Set data read flag + memory sync. |
85 |
|
86 |
|
87 |
DO bj=myByLo(myThid),myByHi(myThid) |
88 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
89 |
ebL = exchangeBufLevel(1,bi,bj) |
90 |
southCommMode = _tileCommModeS(bi,bj) |
91 |
northCommMode = _tileCommModeN(bi,bj) |
92 |
biN = _tileBiN(bi,bj) |
93 |
bjN = _tileBjN(bi,bj) |
94 |
biS = _tileBiS(bi,bj) |
95 |
bjS = _tileBjS(bi,bj) |
96 |
IF ( southCommMode .EQ. COMM_MSG ) THEN |
97 |
#ifdef ALLOW_USE_MPI |
98 |
#ifndef ALWAYS_USE_MPI |
99 |
IF ( usingMPI ) THEN |
100 |
#endif |
101 |
theProc = tilePidS(bi,bj) |
102 |
theTag = _tileTagRecvS(bi,bj) |
103 |
theType = MPI_DOUBLE_PRECISION |
104 |
theSize = sNx*exchWidthY*myNz |
105 |
IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) |
106 |
& theSize = (sNx+2*exchWidthX)*exchWidthY*myNz |
107 |
CALL MPI_Recv( southRecvBuf_RL(1,eBl,bi,bj), theSize, theType, |
108 |
& theProc, theTag, MPI_COMM_WORLD, |
109 |
& mpiStatus, mpiRc ) |
110 |
#ifndef ALWAYS_USE_MPI |
111 |
ENDIF |
112 |
#endif |
113 |
#endif /* ALLOW_USE_MPI */ |
114 |
ENDIF |
115 |
IF ( northCommMode .EQ. COMM_MSG ) THEN |
116 |
#ifdef ALLOW_USE_MPI |
117 |
#ifndef ALWAYS_USE_MPI |
118 |
IF ( usingMPI ) THEN |
119 |
#endif |
120 |
theProc = tilePidN(bi,bj) |
121 |
theTag = _tileTagRecvN(bi,bj) |
122 |
theType = MPI_DOUBLE_PRECISION |
123 |
theSize = sNx*exchWidthY*myNz |
124 |
IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) |
125 |
& theSize = (sNx+2*exchWidthX)*exchWidthY*myNz |
126 |
CALL MPI_Recv( northRecvBuf_RL(1,eBl,bi,bj), theSize, theType, |
127 |
& theProc, theTag, MPI_COMM_WORLD, |
128 |
& mpiStatus, mpiRc ) |
129 |
#ifndef ALWAYS_USE_MPI |
130 |
ENDIF |
131 |
#endif |
132 |
#endif /* ALLOW_USE_MPI */ |
133 |
ENDIF |
134 |
ENDDO |
135 |
ENDDO |
136 |
|
137 |
C-- Wait for buffers I am going read to be ready. |
138 |
IF ( exchUsesBarrier ) THEN |
139 |
C o On some machines ( T90 ) use system barrier rather than spinning. |
140 |
CALL BARRIER( myThid ) |
141 |
ELSE |
142 |
C o Spin waiting for completetion flag. This avoids a global-lock |
143 |
C i.e. we only lock waiting for data that we need. |
144 |
DO bj=myByLo(myThid),myByHi(myThid) |
145 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
146 |
ebL = exchangeBufLevel(1,bi,bj) |
147 |
southCommMode = _tileCommModeS(bi,bj) |
148 |
northCommMode = _tileCommModeN(bi,bj) |
149 |
spinCount = 0 |
150 |
10 CONTINUE |
151 |
CALL FOOL_THE_COMPILER |
152 |
spinCount = spinCount+1 |
153 |
C IF ( myThid .EQ. 1 .AND. spinCount .GT. _EXCH_SPIN_LIMIT ) THEN |
154 |
C STOP ' S/R EXCH_RECV_GET_Y: spinCount .GT. _EXCH_SPIN_LIMIT' |
155 |
C ENDIF |
156 |
IF ( southRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10 |
157 |
IF ( northRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10 |
158 |
C Clear requests |
159 |
southRecvAck(eBl,bi,bj) = 0. |
160 |
northRecvAck(eBl,bi,bj) = 0. |
161 |
C Update statistics |
162 |
IF ( exchCollectStatistics ) THEN |
163 |
exchRecvYExchCount(1,bi,bj) = exchRecvYExchCount(1,bi,bj)+1 |
164 |
exchRecvYSpinCount(1,bi,bj) = |
165 |
& exchRecvYSpinCount(1,bi,bj)+spinCount |
166 |
exchRecvYSpinMax(1,bi,bj) = |
167 |
& MAX(exchRecvYSpinMax(1,bi,bj),spinCount) |
168 |
exchRecvYSpinMin(1,bi,bj) = |
169 |
& MIN(exchRecvYSpinMin(1,bi,bj),spinCount) |
170 |
ENDIF |
171 |
|
172 |
|
173 |
IF ( exchNReqsY(1,bi,bj) .GT. 0 ) THEN |
174 |
#ifdef ALLOW_USE_MPI |
175 |
#ifndef ALWAYS_USE_MPI |
176 |
IF ( usingMPI ) THEN |
177 |
#endif |
178 |
CALL MPI_Waitall( exchNReqsY(1,bi,bj), exchReqIdY(1,1,bi,bj), |
179 |
& mpiStatus, mpiRC ) |
180 |
#ifndef ALWAYS_USE_MPI |
181 |
ENDIF |
182 |
#endif |
183 |
#endif /* ALLOW_USE_MPI */ |
184 |
ENDIF |
185 |
C Clear outstanding requests counter |
186 |
exchNReqsY(1,bi,bj) = 0 |
187 |
ENDDO |
188 |
ENDDO |
189 |
ENDIF |
190 |
|
191 |
C-- Read from the buffers |
192 |
DO bj=myByLo(myThid),myByHi(myThid) |
193 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
194 |
|
195 |
ebL = exchangeBufLevel(1,bi,bj) |
196 |
biN = _tileBiN(bi,bj) |
197 |
bjN = _tileBjN(bi,bj) |
198 |
biS = _tileBiS(bi,bj) |
199 |
bjS = _tileBjS(bi,bj) |
200 |
southCommMode = _tileCommModeS(bi,bj) |
201 |
northCommMode = _tileCommModeN(bi,bj) |
202 |
IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) THEN |
203 |
iMin = 1-exchWidthX |
204 |
iMax = sNx+exchWidthX |
205 |
ELSE |
206 |
iMin = 1 |
207 |
iMax = sNx |
208 |
ENDIF |
209 |
IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN |
210 |
jMin = sNy+1 |
211 |
jMax = sNy+exchWidthY |
212 |
iB0 = 0 |
213 |
IF ( northCommMode .EQ. COMM_PUT |
214 |
& .OR. northCommMode .EQ. COMM_MSG ) THEN |
215 |
iB = 0 |
216 |
DO K=1,myNz |
217 |
DO J=jMin,jMax |
218 |
DO I=iMin,iMax |
219 |
iB = iB + 1 |
220 |
array(I,J,K,bi,bj) = northRecvBuf_RL(iB,eBl,bi,bj) |
221 |
ENDDO |
222 |
ENDDO |
223 |
ENDDO |
224 |
ELSEIF ( northCommMode .EQ. COMM_GET ) THEN |
225 |
DO K=1,myNz |
226 |
iB = iB0 |
227 |
DO J=jMin,jMax |
228 |
iB = iB+1 |
229 |
DO I=iMin,iMax |
230 |
array(I,J,K,bi,bj) = array(I,iB,K,biN,bjN) |
231 |
ENDDO |
232 |
ENDDO |
233 |
ENDDO |
234 |
ENDIF |
235 |
ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN |
236 |
jMin = sNy-exchWidthY+1 |
237 |
jMax = sNy |
238 |
iB0 = 1-exchWidthY-1 |
239 |
IF ( northCommMode .EQ. COMM_PUT |
240 |
& .OR. northCommMode .EQ. COMM_MSG ) THEN |
241 |
iB = 0 |
242 |
DO K=1,myNz |
243 |
DO J=jMin,jMax |
244 |
DO I=iMin,iMax |
245 |
iB = iB + 1 |
246 |
array(I,J,K,bi,bj) = |
247 |
& array(I,J,K,bi,bj)+northRecvBuf_RL(iB,eBl,bi,bj) |
248 |
ENDDO |
249 |
ENDDO |
250 |
ENDDO |
251 |
ELSEIF ( northCommMode .EQ. COMM_GET ) THEN |
252 |
DO K=1,myNz |
253 |
iB = iB0 |
254 |
DO J=jMin,jMax |
255 |
iB = iB+1 |
256 |
DO I=iMin,iMax |
257 |
array(I,J,K,bi,bj) = |
258 |
& array(I,J,K,bi,bj)+array(I,iB,K,biN,bjN) |
259 |
ENDDO |
260 |
ENDDO |
261 |
ENDDO |
262 |
ENDIF |
263 |
ENDIF |
264 |
|
265 |
IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN |
266 |
jMin = 1-exchWidthY |
267 |
jMax = 0 |
268 |
iB0 = sNy-exchWidthY |
269 |
IF ( southCommMode .EQ. COMM_PUT |
270 |
& .OR. southCommMode .EQ. COMM_MSG ) THEN |
271 |
iB = 0 |
272 |
DO K=1,myNz |
273 |
DO J=jMin,jMax |
274 |
DO I=iMin,iMax |
275 |
iB = iB + 1 |
276 |
array(I,J,K,bi,bj) = southRecvBuf_RL(iB,eBl,bi,bj) |
277 |
ENDDO |
278 |
ENDDO |
279 |
ENDDO |
280 |
ELSEIF ( southCommMode .EQ. COMM_GET ) THEN |
281 |
DO K=1,myNz |
282 |
iB = iB0 |
283 |
DO J=jMin,jMax |
284 |
iB = iB+1 |
285 |
DO I=iMin,iMax |
286 |
array(I,J,K,bi,bj) = array(I,iB,K,biS,bjS) |
287 |
ENDDO |
288 |
ENDDO |
289 |
ENDDO |
290 |
ENDIF |
291 |
ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN |
292 |
jMin = 1 |
293 |
jMax = 1+exchWidthY-1 |
294 |
iB0 = sNy |
295 |
IF ( southCommMode .EQ. COMM_PUT |
296 |
& .OR. southCommMode .EQ. COMM_MSG ) THEN |
297 |
iB = 0 |
298 |
DO K=1,myNz |
299 |
DO J=jMin,jMax |
300 |
DO I=iMin,iMax |
301 |
iB = iB + 1 |
302 |
array(I,J,K,bi,bj) = |
303 |
& array(I,J,K,bi,bj)+southRecvBuf_RL(iB,eBl,bi,bj) |
304 |
ENDDO |
305 |
ENDDO |
306 |
ENDDO |
307 |
ELSEIF ( southCommMode .EQ. COMM_GET ) THEN |
308 |
DO K=1,myNz |
309 |
iB = iB0 |
310 |
DO J=jMin,jMax |
311 |
iB = iB+1 |
312 |
DO I=iMin,iMax |
313 |
array(I,J,K,bi,bj) = |
314 |
& array(I,J,K,bi,bj)+array(I,iB,K,biS,bjS) |
315 |
ENDDO |
316 |
ENDDO |
317 |
ENDDO |
318 |
ENDIF |
319 |
ENDIF |
320 |
ENDDO |
321 |
ENDDO |
322 |
|
323 |
RETURN |
324 |
END |
325 |
|
326 |
|
327 |
SUBROUTINE EXCH_RS_RECV_GET_Y( array, |
328 |
I myOLw, myOLe, myOLs, myOLn, myNz, |
329 |
I exchWidthX, exchWidthY, |
330 |
I theSimulationMode, theCornerMode, myThid ) |
331 |
C /==========================================================\ |
332 |
C | SUBROUTINE RECV_GET_Y | |
333 |
C | o "Send" or "put" Y edges for RS array. | |
334 |
C |==========================================================| |
335 |
C | Routine that invokes actual message passing send or | |
336 |
C | direct "put" of data to update X faces of an XY[R] array.| |
337 |
C \==========================================================/ |
338 |
IMPLICIT NONE |
339 |
|
340 |
C == Global variables == |
341 |
#include "SIZE.h" |
342 |
#include "EEPARAMS.h" |
343 |
#include "EESUPPORT.h" |
344 |
#include "EXCH.h" |
345 |
|
346 |
C == Routine arguments == |
347 |
C array - Array with edges to exchange. |
348 |
C myOLw - West, East, North and South overlap region sizes. |
349 |
C myOLe |
350 |
C myOLn |
351 |
C myOLs |
352 |
C exchWidthX - Width of data region exchanged. |
353 |
C exchWidthY |
354 |
C theSimulationMode - Forward or reverse mode exchange ( provides |
355 |
C support for adjoint integration of code. ) |
356 |
C theCornerMode - Flag indicating whether corner updates are |
357 |
C needed. |
358 |
C myThid - Thread number of this instance of S/R EXCH... |
359 |
C eBl - Edge buffer level |
360 |
INTEGER myOLw |
361 |
INTEGER myOLe |
362 |
INTEGER myOLs |
363 |
INTEGER myOLn |
364 |
INTEGER myNz |
365 |
_RS array(1-myOLw:sNx+myOLe, |
366 |
& 1-myOLs:sNy+myOLn, |
367 |
& myNZ, nSx, nSy) |
368 |
INTEGER exchWidthX |
369 |
INTEGER exchWidthY |
370 |
INTEGER theSimulationMode |
371 |
INTEGER theCornerMode |
372 |
INTEGER myThid |
373 |
CEndOfInterface |
374 |
|
375 |
C == Local variables == |
376 |
C I, J, K, iMin, iMax, iB - Loop counters and extents |
377 |
C bi, bj |
378 |
C biS, bjS - South tile indices |
379 |
C biN, bjN - North tile indices |
380 |
C eBl - Current exchange buffer level |
381 |
C theProc, theTag, theType, - Variables used in message building |
382 |
C theSize |
383 |
C southCommMode - Working variables holding type |
384 |
C northCommMode of communication a particular |
385 |
C tile face uses. |
386 |
C spinCount - Exchange statistics counter |
387 |
INTEGER I, J, K, iMin, iMax, jMin, jMax, iB, iB0 |
388 |
INTEGER bi, bj, biS, bjS, biN, bjN |
389 |
INTEGER eBl |
390 |
INTEGER southCommMode |
391 |
INTEGER northCommMode |
392 |
INTEGER spinCount |
393 |
#ifdef ALLOW_USE_MPI |
394 |
INTEGER theProc, theTag, theType, theSize |
395 |
INTEGER mpiStatus(MPI_STATUS_SIZE), mpiRc |
396 |
#endif |
397 |
|
398 |
|
399 |
C-- Under a "put" scenario we |
400 |
C-- i. set completetion signal for buffer we put into. |
401 |
C-- ii. wait for completetion signal indicating data has been put in |
402 |
C-- our buffer. |
403 |
C-- Under a messaging mode we "receive" the message. |
404 |
C-- Under a "get" scenario we |
405 |
C-- i. Check that the data is ready. |
406 |
C-- ii. Read the data. |
407 |
C-- iii. Set data read flag + memory sync. |
408 |
|
409 |
|
410 |
DO bj=myByLo(myThid),myByHi(myThid) |
411 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
412 |
ebL = exchangeBufLevel(1,bi,bj) |
413 |
southCommMode = _tileCommModeS(bi,bj) |
414 |
northCommMode = _tileCommModeN(bi,bj) |
415 |
biN = _tileBiN(bi,bj) |
416 |
bjN = _tileBjN(bi,bj) |
417 |
biS = _tileBiS(bi,bj) |
418 |
bjS = _tileBjS(bi,bj) |
419 |
IF ( southCommMode .EQ. COMM_MSG ) THEN |
420 |
#ifdef ALLOW_USE_MPI |
421 |
#ifndef ALWAYS_USE_MPI |
422 |
IF ( usingMPI ) THEN |
423 |
#endif |
424 |
theProc = tilePidS(bi,bj) |
425 |
theTag = _tileTagRecvS(bi,bj) |
426 |
theType = MPI_DOUBLE_PRECISION |
427 |
#ifdef RS_IS_REAL4 |
428 |
theType = MPI_REAL4 |
429 |
#endif |
430 |
theSize = sNx*exchWidthY*myNz |
431 |
IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) |
432 |
& theSize = (sNx+2*exchWidthX)*exchWidthY*myNz |
433 |
CALL MPI_Recv( southRecvBuf_RS(1,eBl,bi,bj), theSize, theType, |
434 |
& theProc, theTag, MPI_COMM_WORLD, |
435 |
& mpiStatus, mpiRc ) |
436 |
#ifndef ALWAYS_USE_MPI |
437 |
ENDIF |
438 |
#endif |
439 |
#endif /* ALLOW_USE_MPI */ |
440 |
ENDIF |
441 |
IF ( northCommMode .EQ. COMM_MSG ) THEN |
442 |
#ifdef ALLOW_USE_MPI |
443 |
#ifndef ALWAYS_USE_MPI |
444 |
IF ( usingMPI ) THEN |
445 |
#endif |
446 |
theProc = tilePidN(bi,bj) |
447 |
theTag = _tileTagRecvN(bi,bj) |
448 |
theType = MPI_DOUBLE_PRECISION |
449 |
#ifdef RS_IS_REAL4 |
450 |
theType = MPI_REAL4 |
451 |
#endif |
452 |
theSize = sNx*exchWidthY*myNz |
453 |
IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) |
454 |
& theSize = (sNx+2*exchWidthX)*exchWidthY*myNz |
455 |
CALL MPI_Recv( northRecvBuf_RS(1,eBl,bi,bj), theSize, theType, |
456 |
& theProc, theTag, MPI_COMM_WORLD, |
457 |
& mpiStatus, mpiRc ) |
458 |
#ifndef ALWAYS_USE_MPI |
459 |
ENDIF |
460 |
#endif |
461 |
#endif /* ALLOW_USE_MPI */ |
462 |
ENDIF |
463 |
ENDDO |
464 |
ENDDO |
465 |
|
466 |
C-- Wait for buffers I am going read to be ready. |
467 |
IF ( exchUsesBarrier ) THEN |
468 |
C o On some machines ( T90 ) use system barrier rather than spinning. |
469 |
CALL BARRIER( myThid ) |
470 |
ELSE |
471 |
C o Spin waiting for completetion flag. This avoids a global-lock |
472 |
C i.e. we only lock waiting for data that we need. |
473 |
DO bj=myByLo(myThid),myByHi(myThid) |
474 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
475 |
ebL = exchangeBufLevel(1,bi,bj) |
476 |
southCommMode = _tileCommModeS(bi,bj) |
477 |
northCommMode = _tileCommModeN(bi,bj) |
478 |
spinCount = 0 |
479 |
10 CONTINUE |
480 |
CALL FOOL_THE_COMPILER |
481 |
spinCount = spinCount+1 |
482 |
C IF ( myThid .EQ. 1 .AND. spinCount .GT. _EXCH_SPIN_LIMIT ) THEN |
483 |
C STOP ' S/R EXCH_RECV_GET_Y: spinCount .GT. _EXCH_SPIN_LIMIT' |
484 |
C ENDIF |
485 |
IF ( southRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10 |
486 |
IF ( northRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10 |
487 |
C Clear requests |
488 |
southRecvAck(eBl,bi,bj) = 0. |
489 |
northRecvAck(eBl,bi,bj) = 0. |
490 |
C Update statistics |
491 |
IF ( exchCollectStatistics ) THEN |
492 |
exchRecvYExchCount(1,bi,bj) = exchRecvYExchCount(1,bi,bj)+1 |
493 |
exchRecvYSpinCount(1,bi,bj) = |
494 |
& exchRecvYSpinCount(1,bi,bj)+spinCount |
495 |
exchRecvYSpinMax(1,bi,bj) = |
496 |
& MAX(exchRecvYSpinMax(1,bi,bj),spinCount) |
497 |
exchRecvYSpinMin(1,bi,bj) = |
498 |
& MIN(exchRecvYSpinMin(1,bi,bj),spinCount) |
499 |
ENDIF |
500 |
|
501 |
|
502 |
IF ( exchNReqsY(1,bi,bj) .GT. 0 ) THEN |
503 |
#ifdef ALLOW_USE_MPI |
504 |
#ifndef ALWAYS_USE_MPI |
505 |
IF ( usingMPI ) THEN |
506 |
#endif |
507 |
CALL MPI_Waitall( exchNReqsY(1,bi,bj), exchReqIdY(1,1,bi,bj), |
508 |
& mpiStatus, mpiRC ) |
509 |
#ifndef ALWAYS_USE_MPI |
510 |
ENDIF |
511 |
#endif |
512 |
#endif /* ALLOW_USE_MPI */ |
513 |
ENDIF |
514 |
C Clear outstanding requests counter |
515 |
exchNReqsY(1,bi,bj) = 0 |
516 |
ENDDO |
517 |
ENDDO |
518 |
ENDIF |
519 |
|
520 |
C-- Read from the buffers |
521 |
DO bj=myByLo(myThid),myByHi(myThid) |
522 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
523 |
|
524 |
ebL = exchangeBufLevel(1,bi,bj) |
525 |
biN = _tileBiN(bi,bj) |
526 |
bjN = _tileBjN(bi,bj) |
527 |
biS = _tileBiS(bi,bj) |
528 |
bjS = _tileBjS(bi,bj) |
529 |
southCommMode = _tileCommModeS(bi,bj) |
530 |
northCommMode = _tileCommModeN(bi,bj) |
531 |
IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) THEN |
532 |
iMin = 1-exchWidthX |
533 |
iMax = sNx+exchWidthX |
534 |
ELSE |
535 |
iMin = 1 |
536 |
iMax = sNx |
537 |
ENDIF |
538 |
IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN |
539 |
jMin = sNy+1 |
540 |
jMax = sNy+exchWidthY |
541 |
iB0 = 0 |
542 |
IF ( northCommMode .EQ. COMM_PUT |
543 |
& .OR. northCommMode .EQ. COMM_MSG ) THEN |
544 |
iB = 0 |
545 |
DO K=1,myNz |
546 |
DO J=jMin,jMax |
547 |
DO I=iMin,iMax |
548 |
iB = iB + 1 |
549 |
array(I,J,K,bi,bj) = northRecvBuf_RS(iB,eBl,bi,bj) |
550 |
ENDDO |
551 |
ENDDO |
552 |
ENDDO |
553 |
ELSEIF ( northCommMode .EQ. COMM_GET ) THEN |
554 |
DO K=1,myNz |
555 |
iB = iB0 |
556 |
DO J=jMin,jMax |
557 |
iB = iB+1 |
558 |
DO I=iMin,iMax |
559 |
array(I,J,K,bi,bj) = array(I,iB,K,biN,bjN) |
560 |
ENDDO |
561 |
ENDDO |
562 |
ENDDO |
563 |
ENDIF |
564 |
ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN |
565 |
jMin = sNy-exchWidthY+1 |
566 |
jMax = sNy |
567 |
iB0 = 1-exchWidthY-1 |
568 |
IF ( northCommMode .EQ. COMM_PUT |
569 |
& .OR. northCommMode .EQ. COMM_MSG ) THEN |
570 |
iB = 0 |
571 |
DO K=1,myNz |
572 |
DO J=jMin,jMax |
573 |
DO I=iMin,iMax |
574 |
iB = iB + 1 |
575 |
array(I,J,K,bi,bj) = |
576 |
& array(I,J,K,bi,bj)+northRecvBuf_RS(iB,eBl,bi,bj) |
577 |
ENDDO |
578 |
ENDDO |
579 |
ENDDO |
580 |
ELSEIF ( northCommMode .EQ. COMM_GET ) THEN |
581 |
DO K=1,myNz |
582 |
iB = iB0 |
583 |
DO J=jMin,jMax |
584 |
iB = iB+1 |
585 |
DO I=iMin,iMax |
586 |
array(I,J,K,bi,bj) = |
587 |
& array(I,J,K,bi,bj)+array(I,iB,K,biN,bjN) |
588 |
ENDDO |
589 |
ENDDO |
590 |
ENDDO |
591 |
ENDIF |
592 |
ENDIF |
593 |
|
594 |
IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN |
595 |
jMin = 1-exchWidthY |
596 |
jMax = 0 |
597 |
iB0 = sNy-exchWidthY |
598 |
IF ( southCommMode .EQ. COMM_PUT |
599 |
& .OR. southCommMode .EQ. COMM_MSG ) THEN |
600 |
iB = 0 |
601 |
DO K=1,myNz |
602 |
DO J=jMin,jMax |
603 |
DO I=iMin,iMax |
604 |
iB = iB + 1 |
605 |
array(I,J,K,bi,bj) = southRecvBuf_RS(iB,eBl,bi,bj) |
606 |
ENDDO |
607 |
ENDDO |
608 |
ENDDO |
609 |
ELSEIF ( southCommMode .EQ. COMM_GET ) THEN |
610 |
DO K=1,myNz |
611 |
iB = iB0 |
612 |
DO J=jMin,jMax |
613 |
iB = iB+1 |
614 |
DO I=iMin,iMax |
615 |
array(I,J,K,bi,bj) = array(I,iB,K,biS,bjS) |
616 |
ENDDO |
617 |
ENDDO |
618 |
ENDDO |
619 |
ENDIF |
620 |
ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN |
621 |
jMin = 1 |
622 |
jMax = 1+exchWidthY-1 |
623 |
iB0 = sNy |
624 |
IF ( southCommMode .EQ. COMM_PUT |
625 |
& .OR. southCommMode .EQ. COMM_MSG ) THEN |
626 |
iB = 0 |
627 |
DO K=1,myNz |
628 |
DO J=jMin,jMax |
629 |
DO I=iMin,iMax |
630 |
iB = iB + 1 |
631 |
array(I,J,K,bi,bj) = |
632 |
& array(I,J,K,bi,bj)+southRecvBuf_RS(iB,eBl,bi,bj) |
633 |
ENDDO |
634 |
ENDDO |
635 |
ENDDO |
636 |
ELSEIF ( southCommMode .EQ. COMM_GET ) THEN |
637 |
DO K=1,myNz |
638 |
iB = iB0 |
639 |
DO J=jMin,jMax |
640 |
iB = iB+1 |
641 |
DO I=iMin,iMax |
642 |
array(I,J,K,bi,bj) = |
643 |
& array(I,J,K,bi,bj)+array(I,iB,K,biS,bjS) |
644 |
ENDDO |
645 |
ENDDO |
646 |
ENDDO |
647 |
ENDIF |
648 |
ENDIF |
649 |
|
650 |
ENDDO |
651 |
ENDDO |
652 |
|
653 |
RETURN |
654 |
END |
655 |
|