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

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

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


Revision 1.2 - (hide annotations) (download)
Fri Sep 21 03:55:50 2001 UTC (22 years, 8 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: +34 -25 lines
Starting to bring comments up to date and format comments
for document extraction of "prototypes".

1 cnh 1.2 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/exch_rx_recv_get_x.template,v 1.1 2001/05/29 14:06:38 adcroft Exp $
2     C $Name: $
3 adcroft 1.1 #include "CPP_EEOPTIONS.h"
4    
5 cnh 1.2 CBOP
6     C !ROUTINE: EXCH_RX_RECV_GET_X
7    
8     C !INTERFACE:
9 adcroft 1.1 SUBROUTINE EXCH_RX_RECV_GET_X( array,
10     I myOLw, myOLe, myOLs, myOLn, myNz,
11     I exchWidthX, exchWidthY,
12     I theSimulationMode, theCornerMode, myThid )
13     IMPLICIT NONE
14    
15 cnh 1.2 C !DESCRIPTION:
16     C *==========================================================*
17     C | SUBROUTINE RECV_RX_GET_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 adcroft 1.1 C == Global variables ==
26     #include "SIZE.h"
27     #include "EEPARAMS.h"
28     #include "EESUPPORT.h"
29     #include "EXCH.h"
30    
31 cnh 1.2 C !INPUT/OUTPUT PARAMETERS:
32 adcroft 1.1 C == Routine arguments ==
33 cnh 1.2 C array :: Array with edges to exchange.
34     C myOLw :: West, East, North and South overlap region sizes.
35 adcroft 1.1 C myOLe
36     C myOLn
37     C myOLs
38 cnh 1.2 C exchWidthX :: Width of data region exchanged.
39 adcroft 1.1 C exchWidthY
40 cnh 1.2 C theSimulationMode :: Forward or reverse mode exchange ( provides
41 adcroft 1.1 C support for adjoint integration of code. )
42 cnh 1.2 C theCornerMode :: Flag indicating whether corner updates are
43 adcroft 1.1 C needed.
44 cnh 1.2 C myThid :: Thread number of this instance of S/R EXCH...
45     C eBl :: Edge buffer level
46 adcroft 1.1 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 cnh 1.2 C !LOCAL VARIABLES:
61 adcroft 1.1 C == Local variables ==
62 cnh 1.2 C I, J, K, iMin, iMax, iB :: Loop counters and extents
63 adcroft 1.1 C bi, bj
64 cnh 1.2 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 adcroft 1.1 C theSize
69 cnh 1.2 C westCommMode :: Working variables holding type
70     C eastCommMode of communication a particular
71     C tile face uses.
72 adcroft 1.1 INTEGER I, J, K, iMin, iMax, iB, iB0
73     INTEGER bi, bj, biW, bjW, biE, bjE
74     INTEGER eBl
75     INTEGER westCommMode
76     INTEGER eastCommMode
77     INTEGER spinCount
78     #ifdef ALLOW_USE_MPI
79     INTEGER theProc, theTag, theType, theSize
80     INTEGER mpiStatus(MPI_STATUS_SIZE,4), mpiRc
81     #endif
82 cnh 1.2 CEOP
83 adcroft 1.1
84    
85     C-- Under a "put" scenario we
86     C-- i. set completetion signal for buffer we put into.
87     C-- ii. wait for completetion signal indicating data has been put in
88     C-- our buffer.
89     C-- Under a messaging mode we "receive" the message.
90     C-- Under a "get" scenario we
91     C-- i. Check that the data is ready.
92     C-- ii. Read the data.
93     C-- iii. Set data read flag + memory sync.
94    
95    
96     DO bj=myByLo(myThid),myByHi(myThid)
97     DO bi=myBxLo(myThid),myBxHi(myThid)
98     ebL = exchangeBufLevel(1,bi,bj)
99     westCommMode = _tileCommModeW(bi,bj)
100     eastCommMode = _tileCommModeE(bi,bj)
101     biE = _tileBiE(bi,bj)
102     bjE = _tileBjE(bi,bj)
103     biW = _tileBiW(bi,bj)
104     bjW = _tileBjW(bi,bj)
105     IF ( westCommMode .EQ. COMM_MSG ) THEN
106     #ifdef ALLOW_USE_MPI
107     #ifndef ALWAYS_USE_MPI
108     IF ( usingMPI ) THEN
109     #endif
110     theProc = tilePidW(bi,bj)
111     theTag = _tileTagRecvW(bi,bj)
112     theType = MPI_DOUBLE_PRECISION
113     theSize = sNy*exchWidthX*myNz
114     CALL MPI_Recv( westRecvBuf_RX(1,eBl,bi,bj), theSize, theType,
115     & theProc, theTag, MPI_COMM_MODEL,
116     & mpiStatus, mpiRc )
117     #ifndef ALWAYS_USE_MPI
118     ENDIF
119     #endif
120     #endif /* ALLOW_USE_MPI */
121     ENDIF
122     IF ( eastCommMode .EQ. COMM_MSG ) THEN
123     #ifdef ALLOW_USE_MPI
124     #ifndef ALWAYS_USE_MPI
125     IF ( usingMPI ) THEN
126     #endif
127     theProc = tilePidE(bi,bj)
128     theTag = _tileTagRecvE(bi,bj)
129     theType = MPI_DOUBLE_PRECISION
130     theSize = sNy*exchWidthX*myNz
131     CALL MPI_Recv( eastRecvBuf_RX(1,eBl,bi,bj), theSize, theType,
132     & theProc, theTag, MPI_COMM_MODEL,
133     & mpiStatus, mpiRc )
134     #ifndef ALWAYS_USE_MPI
135     ENDIF
136     #endif
137     #endif /* ALLOW_USE_MPI */
138     ENDIF
139     ENDDO
140     ENDDO
141    
142     C-- Wait for buffers I am going read to be ready.
143     IF ( exchUsesBarrier ) THEN
144     C o On some machines ( T90 ) use system barrier rather than spinning.
145     CALL BARRIER( myThid )
146     ELSE
147     C o Spin waiting for completetion flag. This avoids a global-lock
148     C i.e. we only lock waiting for data that we need.
149     DO bj=myByLo(myThid),myByHi(myThid)
150     DO bi=myBxLo(myThid),myBxHi(myThid)
151     spinCount = 0
152     ebL = exchangeBufLevel(1,bi,bj)
153     westCommMode = _tileCommModeW(bi,bj)
154     eastCommMode = _tileCommModeE(bi,bj)
155     10 CONTINUE
156     CALL FOOL_THE_COMPILER
157     spinCount = spinCount+1
158     C IF ( myThid .EQ. 1 .AND. spinCount .GT. _EXCH_SPIN_LIMIT ) THEN
159     C WRITE(*,*) ' eBl = ', ebl
160     C STOP ' S/R EXCH_RECV_GET_X: spinCount .GT. _EXCH_SPIN_LIMIT'
161     C ENDIF
162     IF ( westRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10
163     IF ( eastRecvAck(eBl,bi,bj) .EQ. 0. ) GOTO 10
164     C Clear outstanding requests
165     westRecvAck(eBl,bi,bj) = 0.
166     eastRecvAck(eBl,bi,bj) = 0.
167    
168     IF ( exchNReqsX(1,bi,bj) .GT. 0 ) THEN
169     #ifdef ALLOW_USE_MPI
170     #ifndef ALWAYS_USE_MPI
171     IF ( usingMPI ) THEN
172     #endif
173     CALL MPI_Waitall( exchNReqsX(1,bi,bj), exchReqIdX(1,1,bi,bj),
174     & mpiStatus, mpiRC )
175     #ifndef ALWAYS_USE_MPI
176     ENDIF
177     #endif
178     #endif /* ALLOW_USE_MPI */
179     ENDIF
180     C Clear outstanding requests counter
181     exchNReqsX(1,bi,bj) = 0
182     C Update statistics
183     IF ( exchCollectStatistics ) THEN
184     exchRecvXExchCount(1,bi,bj) = exchRecvXExchCount(1,bi,bj)+1
185     exchRecvXSpinCount(1,bi,bj) =
186     & exchRecvXSpinCount(1,bi,bj)+spinCount
187     exchRecvXSpinMax(1,bi,bj) =
188     & MAX(exchRecvXSpinMax(1,bi,bj),spinCount)
189     exchRecvXSpinMin(1,bi,bj) =
190     & MIN(exchRecvXSpinMin(1,bi,bj),spinCount)
191     ENDIF
192     ENDDO
193     ENDDO
194     ENDIF
195    
196     C-- Read from the buffers
197     DO bj=myByLo(myThid),myByHi(myThid)
198     DO bi=myBxLo(myThid),myBxHi(myThid)
199    
200     ebL = exchangeBufLevel(1,bi,bj)
201     biE = _tileBiE(bi,bj)
202     bjE = _tileBjE(bi,bj)
203     biW = _tileBiW(bi,bj)
204     bjW = _tileBjW(bi,bj)
205     westCommMode = _tileCommModeW(bi,bj)
206     eastCommMode = _tileCommModeE(bi,bj)
207     IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN
208     iMin = sNx+1
209     iMax = sNx+exchWidthX
210     iB0 = 0
211     IF ( eastCommMode .EQ. COMM_PUT
212     & .OR. eastCommMode .EQ. COMM_MSG ) THEN
213     iB = 0
214     DO K=1,myNz
215     DO J=1,sNy
216     DO I=iMin,iMax
217     iB = iB + 1
218     array(I,J,K,bi,bj) = eastRecvBuf_RX(iB,eBl,bi,bj)
219     ENDDO
220     ENDDO
221     ENDDO
222     ELSEIF ( eastCommMode .EQ. COMM_GET ) THEN
223     DO K=1,myNz
224     DO J=1,sNy
225     iB = iB0
226     DO I=iMin,iMax
227     iB = iB+1
228     array(I,J,K,bi,bj) = array(iB,J,K,biE,bjE)
229     ENDDO
230     ENDDO
231     ENDDO
232     ENDIF
233     ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN
234     iMin = sNx-exchWidthX+1
235     iMax = sNx
236     iB0 = 1-exchWidthX-1
237     IF ( eastCommMode .EQ. COMM_PUT
238     & .OR. eastCommMode .EQ. COMM_MSG ) THEN
239     iB = 0
240     DO K=1,myNz
241     DO J=1,sNy
242     DO I=iMin,iMax
243     iB = iB + 1
244     array(I,J,K,bi,bj) =
245     & array(I,J,K,bi,bj)+eastRecvBuf_RX(iB,eBl,bi,bj)
246     ENDDO
247     ENDDO
248     ENDDO
249     ELSEIF ( eastCommMode .EQ. COMM_GET ) THEN
250     DO K=1,myNz
251     DO J=1,sNy
252     iB = iB0
253     DO I=iMin,iMax
254     iB = iB+1
255     array(I,J,K,bi,bj) =
256     & array(I,J,K,bi,bj)+array(iB,J,K,biE,bjE)
257     ENDDO
258     ENDDO
259     ENDDO
260     ENDIF
261     ENDIF
262     IF ( _theSimulationMode .EQ. FORWARD_SIMULATION ) THEN
263     iMin = 1-exchWidthX
264     iMax = 0
265     iB0 = sNx-exchWidthX
266     IF ( westCommMode .EQ. COMM_PUT
267     & .OR. westCommMode .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     array(I,J,K,bi,bj) = westRecvBuf_RX(iB,eBl,bi,bj)
274     ENDDO
275     ENDDO
276     ENDDO
277     ELSEIF ( westCommMode .EQ. COMM_GET ) THEN
278     DO K=1,myNz
279     DO J=1,sNy
280     iB = iB0
281     DO I=iMin,iMax
282     iB = iB+1
283     array(I,J,K,bi,bj) = array(iB,J,K,biW,bjW)
284     ENDDO
285     ENDDO
286     ENDDO
287     ENDIF
288     ELSEIF ( _theSimulationMode .EQ. REVERSE_SIMULATION ) THEN
289     iMin = 1
290     iMax = 1+exchWidthX-1
291     iB0 = sNx
292     IF ( westCommMode .EQ. COMM_PUT
293     & .OR. westCommMode .EQ. COMM_MSG ) THEN
294     iB = 0
295     DO K=1,myNz
296     DO J=1,sNy
297     DO I=iMin,iMax
298     iB = iB + 1
299     array(I,J,K,bi,bj) =
300     & array(I,J,K,bi,bj)+westRecvBuf_RX(iB,eBl,bi,bj)
301     ENDDO
302     ENDDO
303     ENDDO
304     ELSEIF ( westCommMode .EQ. COMM_GET ) THEN
305     DO K=1,myNz
306     DO J=1,sNy
307     iB = iB0
308     DO I=iMin,iMax
309     iB = iB+1
310     array(I,J,K,bi,bj) =
311     & array(I,J,K,bi,bj)+array(iB,J,K,biW,bjW)
312     ENDDO
313     ENDDO
314     ENDDO
315     ENDIF
316     ENDIF
317    
318     ENDDO
319     ENDDO
320    
321     RETURN
322     END

  ViewVC Help
Powered by ViewVC 1.1.22