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

Diff of /MITgcm/eesupp/src/exch_rx_recv_get_y.template

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

revision 1.4 by jmc, Thu Sep 2 14:02:50 2004 UTC revision 1.13 by jmc, Fri Jan 9 22:51:12 2009 UTC
# Line 78  C     mpiStatus                  :: MPI Line 78  C     mpiStatus                  :: MPI
78        INTEGER northCommMode        INTEGER northCommMode
79        INTEGER spinCount        INTEGER spinCount
80  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
81        INTEGER theProc, theTag, theType, theSize        INTEGER theProc, theTag, theType, theSize, pReqI
82        INTEGER mpiStatus(MPI_STATUS_SIZE,4), mpiRc        INTEGER mpiStatus(MPI_STATUS_SIZE,4), mpiRc
83  #endif  #endif
84  CEOP  CEOP
85    
86           INTEGER myBxLoSave(MAX_NO_THREADS)
87           INTEGER myBxHiSave(MAX_NO_THREADS)
88           INTEGER myByLoSave(MAX_NO_THREADS)
89           INTEGER myByHiSave(MAX_NO_THREADS)
90           LOGICAL doingSingleThreadedComms
91    
92           doingSingleThreadedComms = .FALSE.
93    #ifdef ALLOW_USE_MPI
94    #ifndef ALWAYS_USE_MPI
95          IF ( usingMPI ) THEN
96    #endif
97    C      Set default behavior to have MPI comms done by a single thread.
98    C      Most MPI implementations do not support concurrent comms from
99    C      several threads.
100           IF ( nThreads .GT. 1 ) THEN
101            _BARRIER
102            _BEGIN_MASTER( myThid )
103             DO I=1,nThreads
104              myBxLoSave(I) = myBxLo(I)
105              myBxHiSave(I) = myBxHi(I)
106              myByLoSave(I) = myByLo(I)
107              myByHiSave(I) = myByHi(I)
108             ENDDO
109    C        Comment out loop below and myB[xy][Lo|Hi](1) settings below
110    C        if you want to get multi-threaded MPI comms.
111             DO I=1,nThreads
112              myBxLo(I) = 0
113              myBxHi(I) = -1
114              myByLo(I) = 0
115              myByHi(I) = -1
116             ENDDO
117             myBxLo(1) = 1
118             myBxHi(1) = nSx
119             myByLo(1) = 1
120             myByHi(1) = nSy
121             doingSingleThreadedComms = .TRUE.
122            _END_MASTER( myThid )
123            _BARRIER
124          ENDIF
125    #ifndef ALWAYS_USE_MPI
126          ENDIF
127    #endif
128    #endif
129  C--   Under a "put" scenario we  C--   Under a "put" scenario we
130  C--     i. set completetion signal for buffer we put into.  C--     i. set completetion signal for buffer we put into.
131  C--    ii. wait for completetion signal indicating data has been put in  C--    ii. wait for completetion signal indicating data has been put in
# Line 114  C--   iii. Set data read flag + memory s Line 157  C--   iii. Set data read flag + memory s
157           theSize = sNx*exchWidthY*myNz           theSize = sNx*exchWidthY*myNz
158           IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS )           IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS )
159       &    theSize = (sNx+2*exchWidthX)*exchWidthY*myNz       &    theSize = (sNx+2*exchWidthX)*exchWidthY*myNz
160    # ifndef ALLOW_AUTODIFF_OPENAD_AMPI
161           CALL MPI_Recv( southRecvBuf_RX(1,eBl,bi,bj), theSize, theType,           CALL MPI_Recv( southRecvBuf_RX(1,eBl,bi,bj), theSize, theType,
162       &                  theProc, theTag, MPI_COMM_MODEL,       &                  theProc, theTag, MPI_COMM_MODEL,
163       &                  mpiStatus, mpiRc )       &                  mpiStatus, mpiRc )
164    # else
165             pReqI=exchNReqsY(1,bi,bj)+1
166             CALL ampi_recv_RX(
167         & southRecvBuf_RX(1,eBl,bi,bj) ,
168         & theSize ,
169         & theType ,
170         & theProc ,
171         & theTag ,
172         & MPI_COMM_MODEL ,
173         & exchReqIdY(pReqI,1,bi,bj),
174         & exchNReqsY(1,bi,bj),
175         & mpiStatus ,
176         & mpiRc )
177    # endif /* ALLOW_AUTODIFF_OPENAD_AMPI */
178  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
179          ENDIF                          ENDIF                
180  #endif  #endif
# Line 133  C--   iii. Set data read flag + memory s Line 191  C--   iii. Set data read flag + memory s
191           theSize = sNx*exchWidthY*myNz           theSize = sNx*exchWidthY*myNz
192           IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS )           IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS )
193       &    theSize = (sNx+2*exchWidthX)*exchWidthY*myNz       &    theSize = (sNx+2*exchWidthX)*exchWidthY*myNz
194    # ifndef ALLOW_AUTODIFF_OPENAD_AMPI
195           CALL MPI_Recv( northRecvBuf_RX(1,eBl,bi,bj), theSize, theType,           CALL MPI_Recv( northRecvBuf_RX(1,eBl,bi,bj), theSize, theType,
196       &                  theProc, theTag, MPI_COMM_MODEL,       &                  theProc, theTag, MPI_COMM_MODEL,
197       &                  mpiStatus, mpiRc )       &                  mpiStatus, mpiRc )
198    # else
199             pReqI=exchNReqsY(1,bi,bj)+1
200             CALL ampi_recv_RX(
201         & northRecvBuf_RX(1,eBl,bi,bj) ,
202         & theSize ,
203         & theType ,
204         & theProc ,
205         & theTag ,
206         & MPI_COMM_MODEL ,
207         & exchReqIdY(pReqI,1,bi,bj),
208         & exchNReqsY(1,bi,bj),
209         & mpiStatus ,
210         & mpiRc )
211    # endif /* ALLOW_AUTODIFF_OPENAD_AMPI */
212  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
213          ENDIF                          ENDIF                
214  #endif  #endif
# Line 157  C        i.e. we only lock waiting for d Line 230  C        i.e. we only lock waiting for d
230           southCommMode = _tileCommModeS(bi,bj)           southCommMode = _tileCommModeS(bi,bj)
231           northCommMode = _tileCommModeN(bi,bj)           northCommMode = _tileCommModeN(bi,bj)
232           spinCount = 0           spinCount = 0
233    # ifndef ALLOW_AUTODIFF_OPENAD_AMPI
234     10    CONTINUE     10    CONTINUE
235            CALL FOOL_THE_COMPILER( spinCount )            CALL FOOL_THE_COMPILER( spinCount )
236            spinCount = spinCount+1            spinCount = spinCount+1
237  C         IF ( myThid .EQ. 1 .AND. spinCount .GT. _EXCH_SPIN_LIMIT ) THEN  C         IF ( myThid .EQ. 1 .AND. spinCount .GT. _EXCH_SPIN_LIMIT ) THEN
238  C          STOP ' S/R EXCH_RECV_GET_Y: spinCount .GT. _EXCH_SPIN_LIMIT'  C          STOP ' S/R EXCH_RECV_GET_Y: spinCount .GT. _EXCH_SPIN_LIMIT'
239  C         ENDIF  C         ENDIF
240            IF ( southRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10            IF ( southRecvAck(eBl,bi,bj) .EQ. 0 ) GOTO 10
241            IF ( northRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10            IF ( northRecvAck(eBl,bi,bj) .EQ. 0 ) GOTO 10
242    # else
243             do while ((southRecvAck(eBl,bi,bj) .EQ. 0.
244         &             .or.
245         &              northRecvAck(eBl,bi,bj) .EQ. 0. ))
246              CALL FOOL_THE_COMPILER( spinCount )
247              spinCount = spinCount+1
248             end do
249    # endif /* ALLOW_AUTODIFF_OPENAD_AMPI */
250  C        Clear requests  C        Clear requests
251           southRecvAck(eBl,bi,bj) = 0.           southRecvAck(eBl,bi,bj) = 0
252           northRecvAck(eBl,bi,bj) = 0.           northRecvAck(eBl,bi,bj) = 0
253  C        Update statistics  C        Update statistics
254           IF ( exchCollectStatistics ) THEN           IF ( exchCollectStatistics ) THEN
255            exchRecvYExchCount(1,bi,bj) = exchRecvYExchCount(1,bi,bj)+1            exchRecvYExchCount(1,bi,bj) = exchRecvYExchCount(1,bi,bj)+1
# Line 185  C        Update statistics Line 267  C        Update statistics
267  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
268           IF ( usingMPI ) THEN           IF ( usingMPI ) THEN
269  #endif  #endif
270    # ifndef ALLOW_AUTODIFF_OPENAD_AMPI
271            CALL MPI_Waitall( exchNReqsY(1,bi,bj), exchReqIdY(1,1,bi,bj),            CALL MPI_Waitall( exchNReqsY(1,bi,bj), exchReqIdY(1,1,bi,bj),
272       &                      mpiStatus, mpiRC )       &                      mpiStatus, mpiRC )
273    # else
274              CALL ampi_waitall(
275         & exchNReqsY(1,bi,bj),
276         & exchReqIdY(1,1,bi,bj),
277         & mpiStatus,
278         & mpiRC )
279    # endif /* ALLOW_AUTODIFF_OPENAD_AMPI */
280  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
281          ENDIF                          ENDIF                
282  #endif  #endif
# Line 330  C--   Read from the buffers Line 420  C--   Read from the buffers
420         ENDDO         ENDDO
421        ENDDO        ENDDO
422    
423          _BARRIER
424          IF ( doingSingleThreadedComms ) THEN
425    C      Restore saved settings that were stored to allow
426    C      single thred comms.
427           _BEGIN_MASTER(myThid)
428            DO I=1,nThreads
429             myBxLo(I) = myBxLoSave(I)
430             myBxHi(I) = myBxHiSave(I)
431             myByLo(I) = myByLoSave(I)
432             myByHi(I) = myByHiSave(I)
433            ENDDO
434           _END_MASTER(myThid)
435          ENDIF                
436          _BARRIER
437    
438        RETURN        RETURN
439        END        END

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22