/[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.2 - (show annotations) (download)
Fri Sep 21 03:55:50 2001 UTC (22 years, 7 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint44e_post, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, release1_p13_pre, checkpoint50c_post, checkpoint46f_post, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint43a-release1mods, checkpoint51o_pre, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, release1_p13, checkpoint51l_post, checkpoint48i_post, checkpoint46l_pre, 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, 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, checkpoint51s_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, release1_p11, checkpoint51n_pre, checkpoint47d_post, icebear5, icebear4, icebear3, icebear2, checkpoint46d_pre, checkpoint48d_post, release1-branch_tutorials, checkpoint48f_post, checkpoint45d_post, checkpoint46j_pre, checkpoint51l_pre, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint51q_post, ecco_c50_e29, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, ecco_c50_e28, chkpt44c_pre, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_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, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, checkpoint46g_post, release1_p12_pre, ecco_c44_e22, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, ecco_c44_e25, checkpoint51i_pre, 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, 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, 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, icebear, checkpoint51n_branch, release1_coupled
Changes since 1.1: +38 -26 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/exch_rx_send_put_x.template,v 1.1 2001/05/29 14:06:38 adcroft 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_DOUBLE_PRECISION
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_DOUBLE_PRECISION
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_DOUBLE_PRECISION
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_DOUBLE_PRECISION
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