/[MITgcm]/MITgcm/eesupp/src/exch_rx_send_put_x.template
ViewVC logotype

Contents of /MITgcm/eesupp/src/exch_rx_send_put_x.template

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


Revision 1.3 - (show annotations) (download)
Wed Nov 12 00:02:44 2003 UTC (20 years, 7 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint52l_pre, hrcube4, hrcube5, checkpoint57g_pre, checkpoint57s_post, checkpoint57b_post, checkpoint52d_pre, checkpoint57g_post, checkpoint56b_post, checkpoint52j_pre, checkpoint54d_post, checkpoint54e_post, checkpoint57r_post, checkpoint57d_post, checkpoint57i_post, checkpoint52l_post, checkpoint52k_post, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint53, checkpoint52f_post, checkpoint57n_post, checkpoint54f_post, checkpoint55i_post, checkpoint57l_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint57t_post, checkpoint55c_post, checkpoint52e_pre, checkpoint57v_post, checkpoint57f_post, checkpoint52e_post, checkpoint53d_post, checkpoint57a_post, checkpoint57h_pre, checkpoint52b_pre, checkpoint54b_post, checkpoint57h_post, checkpoint52m_post, checkpoint55g_post, checkpoint52b_post, checkpoint52c_post, checkpoint57c_post, checkpoint52f_pre, checkpoint55d_post, checkpoint54a_pre, checkpoint53c_post, checkpoint55d_pre, checkpoint57c_pre, checkpoint55j_post, checkpoint54a_post, checkpoint55h_post, checkpoint57e_post, checkpoint55b_post, checkpoint53a_post, checkpoint55f_post, checkpoint52d_post, checkpoint53g_post, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, eckpoint57e_pre, checkpoint52a_pre, checkpoint52i_post, checkpoint52h_pre, checkpoint56a_post, checkpoint53f_post, checkpoint57h_done, checkpoint52j_post, checkpoint57j_post, checkpoint57f_pre, branch-netcdf, checkpoint52n_post, checkpoint53b_pre, checkpoint56c_post, checkpoint57a_pre, checkpoint55a_post, checkpoint57o_post, checkpoint57k_post, checkpoint53b_post, checkpoint52a_post, checkpoint57w_post, checkpoint53d_pre, checkpoint55e_post, checkpoint54c_post
Branch point for: netcdf-sm0
Changes since 1.2: +5 -5 lines
o some bug fixes for #undef REAL4_IS_SLOW

1 C $Header: /usr/local/gcmpack/MITgcm/eesupp/src/exch_rx_send_put_x.template,v 1.2 2001/09/21 03:55:50 cnh Exp $
2 C $Name: $
3 #include "CPP_EEOPTIONS.h"
4
5 CBOP
6
7 C !ROUTINE: EXCH_RX_SEND_PUT_X
8
9 C !INTERFACE:
10 SUBROUTINE EXCH_RX_SEND_PUT_X( array,
11 I myOLw, myOLe, myOLs, myOLn, myNz,
12 I exchWidthX, exchWidthY,
13 I thesimulationMode, thecornerMode, myThid )
14 IMPLICIT NONE
15 C !DESCRIPTION:
16 C *==========================================================*
17 C | SUBROUTINE EXCH_RX_SEND_PUT_X
18 C | o "Send" or "put" X edges for RX array.
19 C *==========================================================*
20 C | Routine that invokes actual message passing send or
21 C | direct "put" of data to update X faces of an XY[R] array.
22 C *==========================================================*
23
24 C !USES:
25 C == Global variables ==
26 #include "SIZE.h"
27 #include "EEPARAMS.h"
28 #include "EESUPPORT.h"
29 #include "EXCH.h"
30
31 C !INPUT/OUTPUT PARAMETERS:
32 C == Routine arguments ==
33 C array :: Array with edges to exchange.
34 C myOLw :: West, East, North and South overlap region sizes.
35 C myOLe
36 C myOLn
37 C myOLs
38 C exchWidthX :: Width of data region exchanged.
39 C exchWidthY
40 C theSimulationMode :: Forward or reverse mode exchange ( provides
41 C support for adjoint integration of code. )
42 C theCornerMode :: Flag indicating whether corner updates are
43 C needed.
44 C myThid :: Thread number of this instance of S/R EXCH...
45 C eBl :: Edge buffer level
46 INTEGER myOLw
47 INTEGER myOLe
48 INTEGER myOLs
49 INTEGER myOLn
50 INTEGER myNz
51 _RX array(1-myOLw:sNx+myOLe,
52 & 1-myOLs:sNy+myOLn,
53 & myNZ, nSx, nSy)
54 INTEGER exchWidthX
55 INTEGER exchWidthY
56 INTEGER theSimulationMode
57 INTEGER theCornerMode
58 INTEGER myThid
59
60 C !LOCAL VARIABLES:
61 C == Local variables ==
62 C I, J, K, iMin, iMax, iB :: Loop counters and extents
63 C bi, bj
64 C biW, bjW :: West tile indices
65 C biE, bjE :: East tile indices
66 C eBl :: Current exchange buffer level
67 C theProc, theTag, theType, :: Variables used in message building
68 C theSize
69 C westCommMode :: Working variables holding type
70 C eastCommMode of communication a particular
71 C tile face uses.
72 INTEGER I, J, K, iMin, iMax, iB
73 INTEGER bi, bj, biW, bjW, biE, bjE
74 INTEGER eBl
75 INTEGER westCommMode
76 INTEGER eastCommMode
77
78 #ifdef ALLOW_USE_MPI
79 INTEGER theProc, theTag, theType, theSize, mpiRc
80 #endif
81 C-- Write data to exchange buffer
82 C Various actions are possible depending on the communication mode
83 C as follows:
84 C Mode Action
85 C -------- ---------------------------
86 C COMM_NONE Do nothing
87 C
88 C COMM_MSG Message passing communication ( e.g. MPI )
89 C Fill west send buffer from this tile.
90 C Send data with tag identifying tile and direction.
91 C Fill east send buffer from this tile.
92 C Send data with tag identifying tile and direction.
93 C
94 C COMM_PUT "Put" communication ( UMP_, shmemput, etc... )
95 C Fill east receive buffer of west-neighbor tile
96 C Fill west receive buffer of east-neighbor tile
97 C Sync. memory
98 C Write data-ready Ack for east edge of west-neighbor
99 C tile
100 C Write data-ready Ack for west edge of east-neighbor
101 C tile
102 C Sync. memory
103 C
104 CEOP
105
106 DO bj=myByLo(myThid),myByHi(myThid)
107 DO bi=myBxLo(myThid),myBxHi(myThid)
108
109 ebL = exchangeBufLevel(1,bi,bj)
110 westCommMode = _tileCommModeW(bi,bj)
111 eastCommMode = _tileCommModeE(bi,bj)
112 biE = _tileBiE(bi,bj)
113 bjE = _tileBjE(bi,bj)
114 biW = _tileBiW(bi,bj)
115 bjW = _tileBjW(bi,bj)
116
117 C o Send or Put west edge
118 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
119 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
120 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
121
122 IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN
123 iMin = 1
124 iMax = 1+exchWidthX-1
125 IF ( westCommMode .EQ. COMM_MSG ) THEN
126 iB = 0
127 DO K=1,myNz
128 DO J=1,sNy
129 DO I=iMin,iMax
130 iB = iB + 1
131 westSendBuf_RX(iB,eBl,bi,bj) = array(I,J,K,bi,bj)
132 ENDDO
133 ENDDO
134 ENDDO
135 C Send the data
136 #ifdef ALLOW_USE_MPI
137 #ifndef ALWAYS_USE_MPI
138 IF ( usingMPI ) THEN
139 #endif
140 theProc = tilePidW(bi,bj)
141 theTag = _tileTagSendW(bi,bj)
142 theSize = iB
143 theType = _MPI_TYPE_RX
144 exchNReqsX(1,bi,bj) = exchNReqsX(1,bi,bj)+1
145 CALL MPI_Isend(westSendBuf_RX(1,eBl,bi,bj), theSize, theType,
146 & theProc, theTag, MPI_COMM_MODEL,
147 & exchReqIdX(exchNReqsX(1,bi,bj),1,bi,bj), mpiRc )
148 #ifndef ALWAYS_USE_MPI
149 ENDIF
150 #endif
151 #endif /* ALLOW_USE_MPI */
152 eastRecvAck(eBl,biW,bjW) = 1.
153 ELSEIF ( westCommMode .EQ. COMM_PUT ) THEN
154 iB = 0
155 DO K=1,myNz
156 DO J=1,sNy
157 DO I=iMin,iMax
158 iB = iB + 1
159 eastRecvBuf_RX(iB,eBl,biW,bjW) = array(I,J,K,bi,bj)
160 ENDDO
161 ENDDO
162 ENDDO
163 ELSEIF ( westCommMode .NE. COMM_NONE
164 & .AND. westCommMode .NE. COMM_GET ) THEN
165 STOP ' S/R EXCH: Invalid commW mode.'
166 ENDIF
167
168 C o Send or Put east edge
169 iMin = sNx-exchWidthX+1
170 iMax = sNx
171 IF ( eastCommMode .EQ. COMM_MSG ) THEN
172 iB = 0
173 DO K=1,myNz
174 DO J=1,sNy
175 DO I=iMin,iMax
176 iB = iB + 1
177 eastSendBuf_RX(iB,eBl,bi,bj) = array(I,J,K,bi,bj)
178 ENDDO
179 ENDDO
180 ENDDO
181 C Send the data
182 #ifdef ALLOW_USE_MPI
183 #ifndef ALWAYS_USE_MPI
184 IF ( usingMPI ) THEN
185 #endif
186 theProc = tilePidE(bi,bj)
187 theTag = _tileTagSendE(bi,bj)
188 theSize = iB
189 theType = _MPI_TYPE_RX
190 exchNReqsX(1,bi,bj) = exchNReqsX(1,bi,bj)+1
191 CALL MPI_Isend(eastSendBuf_RX(1,eBl,bi,bj), theSize, theType,
192 & theProc, theTag, MPI_COMM_MODEL,
193 & exchReqIdX(exchNReqsX(1,bi,bj),1,bi,bj), mpiRc )
194 #ifndef ALWAYS_USE_MPI
195 ENDIF
196 #endif
197 #endif /* ALLOW_USE_MPI */
198 westRecvAck(eBl,biE,bjE) = 1.
199 ELSEIF ( eastCommMode .EQ. COMM_PUT ) THEN
200 iB = 0
201 DO K=1,myNz
202 DO J=1,sNy
203 DO I=iMin,iMax
204 iB = iB + 1
205 westRecvBuf_RX(iB,eBl,biE,bjE) = array(I,J,K,bi,bj)
206 ENDDO
207 ENDDO
208 ENDDO
209 ELSEIF ( eastCommMode .NE. COMM_NONE
210 & .AND. eastCommMode .NE. COMM_GET ) THEN
211 STOP ' S/R EXCH: Invalid commE mode.'
212 ENDIF
213 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
214 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
215 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
216 ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN
217 iMin = 1-exchWidthX
218 iMax = 0
219 IF ( westCommMode .EQ. COMM_MSG ) THEN
220 iB = 0
221 DO K=1,myNz
222 DO J=1,sNy
223 DO I=iMin,iMax
224 iB = iB + 1
225 westSendBuf_RX(iB,eBl,bi,bj) = array(I,J,K,bi,bj)
226 array(I,J,K,bi,bj) = 0.0
227 ENDDO
228 ENDDO
229 ENDDO
230 C Send the data
231 #ifdef ALLOW_USE_MPI
232 #ifndef ALWAYS_USE_MPI
233 IF ( usingMPI ) THEN
234 #endif
235 theProc = tilePidW(bi,bj)
236 theTag = _tileTagSendW(bi,bj)
237 theSize = iB
238 theType = _MPI_TYPE_RX
239 exchNReqsX(1,bi,bj) = exchNReqsX(1,bi,bj)+1
240 CALL MPI_Isend(westSendBuf_RX(1,eBl,bi,bj), theSize, theType,
241 & theProc, theTag, MPI_COMM_MODEL,
242 & exchReqIdX(exchNReqsX(1,bi,bj),1,bi,bj), mpiRc )
243 #ifndef ALWAYS_USE_MPI
244 ENDIF
245 #endif
246 #endif /* ALLOW_USE_MPI */
247 eastRecvAck(eBl,biW,bjW) = 1.
248 ELSEIF ( westCommMode .EQ. COMM_PUT ) THEN
249 iB = 0
250 DO K=1,myNz
251 DO J=1,sNy
252 DO I=iMin,iMax
253 iB = iB + 1
254 eastRecvBuf_RX(iB,eBl,biW,bjW) = array(I,J,K,bi,bj)
255 array(I,J,K,bi,bj) = 0.0
256 ENDDO
257 ENDDO
258 ENDDO
259 ELSEIF ( westCommMode .NE. COMM_NONE
260 & .AND. westCommMode .NE. COMM_GET ) THEN
261 STOP ' S/R EXCH: Invalid commW mode.'
262 ENDIF
263
264 C o Send or Put east edge
265 iMin = sNx+1
266 iMax = sNx+exchWidthX
267 IF ( eastCommMode .EQ. COMM_MSG ) THEN
268 iB = 0
269 DO K=1,myNz
270 DO J=1,sNy
271 DO I=iMin,iMax
272 iB = iB + 1
273 eastSendBuf_RX(iB,eBl,bi,bj) = array(I,J,K,bi,bj)
274 array(I,J,K,bi,bj) = 0.0
275 ENDDO
276 ENDDO
277 ENDDO
278 C Send the data
279 #ifdef ALLOW_USE_MPI
280 #ifndef ALWAYS_USE_MPI
281 IF ( usingMPI ) THEN
282 #endif
283 theProc = tilePidE(bi,bj)
284 theTag = _tileTagSendE(bi,bj)
285 theSize = iB
286 theType = _MPI_TYPE_RX
287 exchNReqsX(1,bi,bj) = exchNReqsX(1,bi,bj)+1
288 CALL MPI_Isend(eastSendBuf_RX(1,eBl,bi,bj), theSize, theType,
289 & theProc, theTag, MPI_COMM_MODEL,
290 & exchReqIdX(exchNReqsX(1,bi,bj),1,bi,bj), mpiRc )
291 #ifndef ALWAYS_USE_MPI
292 ENDIF
293 #endif
294 #endif /* ALLOW_USE_MPI */
295 westRecvAck(eBl,biE,bjE) = 1.
296 ELSEIF ( eastCommMode .EQ. COMM_PUT ) THEN
297 iB = 0
298 DO K=1,myNz
299 DO J=1,sNy
300 DO I=iMin,iMax
301 iB = iB + 1
302 westRecvBuf_RX(iB,eBl,biE,bjE) = array(I,J,K,bi,bj)
303 array(I,J,K,bi,bj) = 0.0
304 ENDDO
305 ENDDO
306 ENDDO
307 ELSEIF ( eastCommMode .NE. COMM_NONE
308 & .AND. eastCommMode .NE. COMM_GET ) THEN
309 STOP ' S/R EXCH: Invalid commE mode.'
310 ENDIF
311
312 ENDIF
313
314 ENDDO
315 ENDDO
316
317 C-- Signal completetion ( making sure system-wide memory state is
318 C-- consistent ).
319
320 C ** NOTE ** We are relying on being able to produce strong-ordered
321 C memory semantics here. In other words we assume that there is a
322 C mechanism which can ensure that by the time the Ack is seen the
323 C overlap region data that will be exchanged is up to date.
324 IF ( exchNeedsMemSync ) CALL MEMSYNC
325
326 DO bj=myByLo(myThid),myByHi(myThid)
327 DO bi=myBxLo(myThid),myBxHi(myThid)
328 ebL = exchangeBufLevel(1,bi,bj)
329 biE = _tileBiE(bi,bj)
330 bjE = _tileBjE(bi,bj)
331 biW = _tileBiW(bi,bj)
332 bjW = _tileBjW(bi,bj)
333 westCommMode = _tileCommModeW(bi,bj)
334 eastCommMode = _tileCommModeE(bi,bj)
335 IF ( westCommMode .EQ. COMM_PUT ) eastRecvAck(eBl,biW,bjW) = 1.
336 IF ( eastCommMode .EQ. COMM_PUT ) westRecvAck(eBl,biE,bjE) = 1.
337 IF ( westCommMode .EQ. COMM_GET ) eastRecvAck(eBl,biW,bjW) = 1.
338 IF ( eastCommMode .EQ. COMM_GET ) westRecvAck(eBl,biE,bjE) = 1.
339 ENDDO
340 ENDDO
341
342 C-- Make sure "ack" setting is seen system-wide.
343 C Here strong-ordering is not an issue but we want to make
344 C sure that processes that might spin on the above Ack settings
345 C will see the setting.
346 C ** NOTE ** On some machines we wont spin on the Ack setting
347 C ( particularly the T90 ), instead we will use s system barrier.
348 C On the T90 the system barrier is very fast and switches out the
349 C thread while it waits. On most machines the system barrier
350 C is much too slow and if we own the machine and have one thread
351 C per process preemption is not a problem.
352 IF ( exchNeedsMemSync ) CALL MEMSYNC
353
354 RETURN
355 END

  ViewVC Help
Powered by ViewVC 1.1.22