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

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

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

revision 1.5 by cnh, Mon Nov 7 19:03:36 2005 UTC revision 1.10 by utke, Fri Mar 28 18:39:54 2008 UTC
# Line 81  C                                   tile Line 81  C                                   tile
81  #endif  #endif
82  CEOP  CEOP
83    
 #ifdef USE_SINGLE_THREADED_EXCH_COMMS  
84         INTEGER myBxLoSave(MAX_NO_THREADS)         INTEGER myBxLoSave(MAX_NO_THREADS)
85         INTEGER myBxHiSave(MAX_NO_THREADS)         INTEGER myBxHiSave(MAX_NO_THREADS)
86         INTEGER myByLoSave(MAX_NO_THREADS)         INTEGER myByLoSave(MAX_NO_THREADS)
87         INTEGER myByHiSave(MAX_NO_THREADS)         INTEGER myByHiSave(MAX_NO_THREADS)
88  #endif /* SINGLE_THREADED_EXCH_COMMS */         LOGICAL doingSingleThreadedComms
89    
90  #ifdef USE_SINGLE_THREADED_EXCH_COMMS         doingSingleThreadedComms = .FALSE.
91        _BARRIER  #ifdef ALLOW_USE_MPI
92        IF ( myThid .EQ. 1 ) THEN  #ifndef ALWAYS_USE_MPI
93         DO I=1,nThreads        IF ( usingMPI ) THEN
94          myBxLoSave(I) = myBxLo(I)  #endif
95          myBxHiSave(I) = myBxHi(I)  C      Set default behavior to have MPI comms done by a single thread.
96          myByLoSave(I) = myByLo(I)  C      Most MPI implementations don't support concurrent comms from
97          myByHiSave(I) = myByHi(I)  C      several threads.
98          myBxLo(I) = 0         IF ( nThreads .GT. 1 ) THEN
99          myBxHi(I) = -1          _BARRIER
100          myByLo(I) = 0          _BEGIN_MASTER( myThid )
101          myByHi(I) = -1           DO I=1,nThreads
102         ENDDO            myBxLoSave(I) = myBxLo(I)
103         myBxLo(1) = 1            myBxHiSave(I) = myBxHi(I)
104         myBxHi(1) = nSx            myByLoSave(I) = myByLo(I)
105         myByLo(1) = 1            myByHiSave(I) = myByHi(I)
106         myByHi(1) = nSy           ENDDO
107    C        Comment out loop below and myB[xy][Lo|Hi](1) settings below
108    C        if you want to get multi-threaded MPI comms.
109             DO I=1,nThreads
110              myBxLo(I) = 0
111              myBxHi(I) = -1
112              myByLo(I) = 0
113              myByHi(I) = -1
114             ENDDO
115             myBxLo(1) = 1
116             myBxHi(1) = nSx
117             myByLo(1) = 1
118             myByHi(1) = nSy
119             doingSingleThreadedComms = .TRUE.
120            _END_MASTER( myThid )
121            _BARRIER
122        ENDIF        ENDIF
123        _BARRIER  #ifndef ALWAYS_USE_MPI
124  #endif /* SINGLE_THREADED_EXCH_COMMS */        ENDIF
125    #endif
126    #endif
127    
128  C--   Under a "put" scenario we  C--   Under a "put" scenario we
129  C--     i. set completetion signal for buffer we put into.  C--     i. set completetion signal for buffer we put into.
# Line 139  C--   iii. Set data read flag + memory s Line 154  C--   iii. Set data read flag + memory s
154           theTag  = _tileTagRecvW(bi,bj)           theTag  = _tileTagRecvW(bi,bj)
155           theType = _MPI_TYPE_RX           theType = _MPI_TYPE_RX
156           theSize = sNy*exchWidthX*myNz           theSize = sNy*exchWidthX*myNz
157    # ifndef ALLOW_AUTODIFF_OPENAD
158           CALL MPI_Recv( westRecvBuf_RX(1,eBl,bi,bj), theSize, theType,           CALL MPI_Recv( westRecvBuf_RX(1,eBl,bi,bj), theSize, theType,
159       &                  theProc, theTag, MPI_COMM_MODEL,       &                  theProc, theTag, MPI_COMM_MODEL,
160       &                  mpiStatus, mpiRc )       &                  mpiStatus, mpiRc )
161    # else
162             CALL ampi_recv_RX(
163         & westRecvBuf_RX(1,eBl,bi,bj) ,
164         & theSize ,
165         & theType ,
166         & theProc ,
167         & theTag ,
168         & MPI_COMM_MODEL ,
169         & exchReqIdX(exchNReqsX(1,bi,bj)+1,1,bi,bj),
170         & exchNReqsX(1,bi,bj),
171         & mpiStatus ,
172         & mpiRc )
173    # endif /* ALLOW_AUTODIFF_OPENAD */
174  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
175          ENDIF                          ENDIF                
176  #endif  #endif
# Line 156  C--   iii. Set data read flag + memory s Line 185  C--   iii. Set data read flag + memory s
185           theTag  = _tileTagRecvE(bi,bj)           theTag  = _tileTagRecvE(bi,bj)
186           theType = _MPI_TYPE_RX           theType = _MPI_TYPE_RX
187           theSize = sNy*exchWidthX*myNz           theSize = sNy*exchWidthX*myNz
188    # ifndef ALLOW_AUTODIFF_OPENAD
189           CALL MPI_Recv( eastRecvBuf_RX(1,eBl,bi,bj), theSize, theType,           CALL MPI_Recv( eastRecvBuf_RX(1,eBl,bi,bj), theSize, theType,
190       &                  theProc, theTag, MPI_COMM_MODEL,       &                  theProc, theTag, MPI_COMM_MODEL,
191       &                  mpiStatus, mpiRc )       &                  mpiStatus, mpiRc )
192    # else
193             CALL ampi_recv_RX(
194         & eastRecvBuf_RX(1,eBl,bi,bj) ,
195         & theSize ,
196         & theType ,
197         & theProc ,
198         & theTag ,
199         & MPI_COMM_MODEL ,
200         & exchReqIdX(exchNReqsX(1,bi,bj)+1,1,bi,bj),
201         & exchNReqsX(1,bi,bj),
202         & mpiStatus ,
203         & mpiRc )
204    # endif /* ALLOW_AUTODIFF_OPENAD */
205  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
206          ENDIF                          ENDIF                
207  #endif  #endif
# Line 180  C        i.e. we only lock waiting for d Line 223  C        i.e. we only lock waiting for d
223           ebL = exchangeBufLevel(1,bi,bj)           ebL = exchangeBufLevel(1,bi,bj)
224           westCommMode = _tileCommModeW(bi,bj)           westCommMode = _tileCommModeW(bi,bj)
225           eastCommMode = _tileCommModeE(bi,bj)           eastCommMode = _tileCommModeE(bi,bj)
226    # ifndef ALLOW_AUTODIFF_OPENAD
227     10    CONTINUE     10    CONTINUE
228            CALL FOOL_THE_COMPILER( spinCount )            CALL FOOL_THE_COMPILER( spinCount )
229            spinCount = spinCount+1            spinCount = spinCount+1
# Line 187  C         IF ( myThid .EQ. 1 .AND. spinC Line 231  C         IF ( myThid .EQ. 1 .AND. spinC
231  C          WRITE(*,*) ' eBl = ', ebl  C          WRITE(*,*) ' eBl = ', ebl
232  C          STOP ' S/R EXCH_RECV_GET_X: spinCount .GT. _EXCH_SPIN_LIMIT'  C          STOP ' S/R EXCH_RECV_GET_X: spinCount .GT. _EXCH_SPIN_LIMIT'
233  C         ENDIF  C         ENDIF
234            IF ( westRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10            IF ( westRecvAck(eBl,bi,bj) .EQ. 0 ) GOTO 10
235            IF ( eastRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10            IF ( eastRecvAck(eBl,bi,bj) .EQ. 0 ) GOTO 10
236    # else
237             do while ((westRecvAck(eBl,bi,bj) .EQ. 0.
238         &             .or.
239         &              eastRecvAck(eBl,bi,bj) .EQ. 0. ))
240              CALL FOOL_THE_COMPILER( spinCount )
241              spinCount = spinCount+1
242             end do
243    # endif /* ALLOW_AUTODIFF_OPENAD */
244  C        Clear outstanding requests  C        Clear outstanding requests
245           westRecvAck(eBl,bi,bj) = 0.           westRecvAck(eBl,bi,bj) = 0
246           eastRecvAck(eBl,bi,bj) = 0.           eastRecvAck(eBl,bi,bj) = 0
247    
248           IF ( exchNReqsX(1,bi,bj) .GT. 0 ) THEN           IF ( exchNReqsX(1,bi,bj) .GT. 0 ) THEN
249  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
250  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
251           IF ( usingMPI ) THEN           IF ( usingMPI ) THEN
252  #endif  #endif
253    # ifndef ALLOW_AUTODIFF_OPENAD
254            CALL MPI_Waitall( exchNReqsX(1,bi,bj), exchReqIdX(1,1,bi,bj),            CALL MPI_Waitall( exchNReqsX(1,bi,bj), exchReqIdX(1,1,bi,bj),
255       &                      mpiStatus, mpiRC )       &                      mpiStatus, mpiRC )
256    # else
257              CALL ampi_waitall(
258         & exchNReqsX(1,bi,bj),
259         & exchReqIdX(1,1,bi,bj),
260         & mpiStatus,
261         & mpiRC )
262    # endif /* ALLOW_AUTODIFF_OPENAD */
263  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
264          ENDIF                          ENDIF                
265  #endif  #endif
# Line 346  C--   Read from the buffers Line 406  C--   Read from the buffers
406         ENDDO         ENDDO
407        ENDDO        ENDDO
408    
 #ifdef USE_SINGLE_THREADED_EXCH_COMMS  
409        _BARRIER        _BARRIER
410        IF ( myThid .EQ. 1 ) THEN        IF ( doingSingleThreadedComms ) THEN
411         DO I=1,nThreads  C      Restore saved settings that were stored to allow
412          myBxLo(I) = myBxLoSave(I)  C      single thred comms.
413          myBxHi(I) = myBxHiSave(I)         _BEGIN_MASTER(myThid)
414          myByLo(I) = myByLoSave(I)          DO I=1,nThreads
415          myByHi(I) = myByHiSave(I)           myBxLo(I) = myBxLoSave(I)
416         ENDDO           myBxHi(I) = myBxHiSave(I)
417        ENDIF           myByLo(I) = myByLoSave(I)
418             myByHi(I) = myByHiSave(I)
419            ENDDO
420           _END_MASTER(myThid)
421          ENDIF                
422        _BARRIER        _BARRIER
 #endif /* USE_SINGLE_THREADED_EXCH_COMMS */  
423    
424        RETURN        RETURN
425        END        END

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.22