/[MITgcm]/MITgcm/pkg/exch2/exch2_rx1_cube.template
ViewVC logotype

Contents of /MITgcm/pkg/exch2/exch2_rx1_cube.template

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


Revision 1.14 - (show annotations) (download)
Wed May 19 01:25:17 2010 UTC (13 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint63, checkpoint62g, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x
Changes since 1.13: +4 -4 lines
stwich order of arguments myOLn,myOLs to match calling S/R

1 C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_rx1_cube.template,v 1.13 2010/05/06 23:28:44 jmc Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 CBOP
7 C !ROUTINE: EXCH_RX_CUBE
8
9 C !INTERFACE:
10 SUBROUTINE EXCH2_RX1_CUBE(
11 U array,
12 I signOption, fieldCode,
13 I myOLw, myOLe, myOLs, myOLn, myNz,
14 I exchWidthX, exchWidthY,
15 I cornerMode, myThid )
16
17 C !DESCRIPTION:
18 C Scalar field (1 component) Exchange:
19 C Fill-in tile-edge overlap-region of a 1 component scalar field
20 C with corresponding near-edge interior data point
21
22 C !USES:
23 IMPLICIT NONE
24
25 C == Global data ==
26 #include "SIZE.h"
27 #include "EEPARAMS.h"
28 #include "EESUPPORT.h"
29 #include "W2_EXCH2_SIZE.h"
30 #include "W2_EXCH2_TOPOLOGY.h"
31 #include "W2_EXCH2_BUFFER.h"
32
33 C !INPUT/OUTPUT PARAMETERS:
34 C array :: Array with edges to exchange.
35 C signOption :: Flag controlling whether field sign depends on orientation
36 C :: (signOption not yet implemented but needed for SM exch)
37 C fieldCode :: field code (position on staggered grid)
38 C myOLw,myOLe :: West and East overlap region sizes.
39 C myOLs,myOLn :: South and North overlap region sizes.
40 C exchWidthX :: Width of data region exchanged in X.
41 C exchWidthY :: Width of data region exchanged in Y.
42 C cornerMode :: halo-corner-region treatment: update/ignore corner region
43 C myThid :: my Thread Id. number
44
45 INTEGER myOLw, myOLe, myOLs, myOLn, myNz
46 _RX array(1-myOLw:sNx+myOLe,
47 & 1-myOLs:sNy+myOLn,
48 & myNz, nSx, nSy)
49 LOGICAL signOption
50 CHARACTER*2 fieldCode
51 INTEGER exchWidthX
52 INTEGER exchWidthY
53 INTEGER cornerMode
54 INTEGER myThid
55
56 C !LOCAL VARIABLES:
57 C e2_msgHandles :: Synchronization and coordination data structure used to
58 C :: coordinate access to e2Bufr1_RX or to regulate message
59 C :: buffering. In PUT communication sender will increment
60 C :: handle entry once data is ready in buffer. Receiver will
61 C :: decrement handle once data is consumed from buffer.
62 C :: For MPI MSG communication MPI_Wait uses handle to check
63 C :: Isend has cleared. This is done in routine after receives.
64 C note: a) current implementation does not use e2_msgHandles for communication
65 C between threads: all-threads barriers are used (see CNH note below).
66 C For a 2-threads synchro communication (future version),
67 C e2_msgHandles should be shared (in common block, moved to BUFFER.h)
68 C b) 1rst dim=2 so that it could be used also by exch2_rx2_cube.
69 INTEGER bi, bj
70 C Variables for working through W2 topology
71 INTEGER e2_msgHandles( 2, W2_maxNeighbours, nSx, nSy )
72 INTEGER thisTile, farTile, N, nN, oN
73 INTEGER tIlo, tIhi, tJlo, tJhi, tKlo, tKhi
74 INTEGER tIStride, tJStride, tKStride
75 INTEGER i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi
76 LOGICAL updateCorners
77
78 #ifdef ALLOW_USE_MPI
79 INTEGER iBufr, nri, nrj
80 C MPI stuff (should be in a routine call)
81 INTEGER mpiStatus(MPI_STATUS_SIZE)
82 INTEGER mpiRc
83 INTEGER wHandle
84 #endif
85 CEOP
86
87 updateCorners = cornerMode .EQ. EXCH_UPDATE_CORNERS
88 C- Tile size of array to exchange:
89 i1Lo = 1-myOLw
90 i1Hi = sNx+myOLe
91 j1Lo = 1-myOLs
92 j1Hi = sNy+myOLn
93 k1Lo = 1
94 k1Hi = myNz
95
96 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
97
98 C Prevent anyone to access shared buffer while an other thread modifies it
99 CALL BAR2( myThid )
100
101 C-- Post sends into buffer (buffer level 1):
102 DO bj=myByLo(myThid), myByHi(myThid)
103 DO bi=myBxLo(myThid), myBxHi(myThid)
104 thisTile=W2_myTileList(bi,bj)
105 nN=exch2_nNeighbours(thisTile)
106 DO N=1,nN
107 farTile=exch2_neighbourId(N,thisTile)
108 oN = exch2_opposingSend(N,thisTile)
109 CALL EXCH2_GET_SCAL_BOUNDS(
110 I fieldCode, exchWidthX, updateCorners,
111 I farTile, oN,
112 O tIlo, tiHi, tjLo, tjHi,
113 O tiStride, tjStride,
114 I myThid )
115 tKLo=1
116 tKHi=myNz
117 tKStride=1
118 C- Put my points in buffer for neighbour N to fill points
119 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride)
120 C in its copy of "array".
121 CALL EXCH2_PUT_RX1(
122 I tIlo, tIhi, tiStride,
123 I tJlo, tJhi, tjStride,
124 I tKlo, tKhi, tkStride,
125 I thisTile, N,
126 I e2BufrRecSize,
127 O iBuf1Filled(N,bi,bj),
128 O e2Bufr1_RX(1,N,bi,bj,1),
129 I array(1-myOLw,1-myOLs,1,bi,bj),
130 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
131 O e2_msgHandles(1,N,bi,bj),
132 I W2_myCommFlag(N,bi,bj), myThid )
133 ENDDO
134 ENDDO
135 ENDDO
136
137 C Wait until all threads finish filling buffer
138 CALL BAR2( myThid )
139
140 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
141
142 #ifdef ALLOW_USE_MPI
143 _BEGIN_MASTER( myThid )
144
145 C-- Send my data (in buffer, level 1) to target Process
146 DO bj=1,nSy
147 DO bi=1,nSx
148 thisTile=W2_myTileList(bi,bj)
149 nN=exch2_nNeighbours(thisTile)
150 DO N=1,nN
151 C- Skip the call if this is an internal exchange
152 IF ( W2_myCommFlag(N,bi,bj) .EQ. 'M' ) THEN
153 CALL EXCH2_SEND_RX1(
154 I thisTile, N,
155 I e2BufrRecSize,
156 I iBuf1Filled(N,bi,bj),
157 I e2Bufr1_RX(1,N,bi,bj,1),
158 O e2_msgHandles(1,N,bi,bj),
159 I W2_myCommFlag(N,bi,bj), myThid )
160 ENDIF
161 ENDDO
162 ENDDO
163 ENDDO
164
165 C-- Receive data (in buffer, level 2) from source Process
166 DO bj=1,nSy
167 DO bi=1,nSx
168 thisTile=W2_myTileList(bi,bj)
169 nN=exch2_nNeighbours(thisTile)
170 DO N=1,nN
171 C- Skip the call if this is an internal exchange
172 IF ( W2_myCommFlag(N,bi,bj) .EQ. 'M' ) THEN
173 CALL EXCH2_GET_SCAL_BOUNDS(
174 I fieldCode, exchWidthX, updateCorners,
175 I thisTile, N,
176 O tIlo, tiHi, tjLo, tjHi,
177 O tiStride, tjStride,
178 I myThid )
179 nri = 1 + (tIhi-tIlo)/tiStride
180 nrj = 1 + (tJhi-tJlo)/tjStride
181 iBufr = nri*nrj*myNz
182 C Receive from neighbour N to fill buffer and later on the array
183 CALL EXCH2_RECV_RX1(
184 I thisTile, N,
185 I e2BufrRecSize,
186 I iBufr,
187 O e2Bufr1_RX(1,N,bi,bj,2),
188 I W2_myCommFlag(N,bi,bj), myThid )
189 ENDIF
190 ENDDO
191 ENDDO
192 ENDDO
193
194 C-- Clear message handles/locks
195 DO bj=1,nSy
196 DO bi=1,nSx
197 thisTile=W2_myTileList(bi,bj)
198 nN=exch2_nNeighbours(thisTile)
199 DO N=1,nN
200 C Note: In a between process tile-tile data transport using
201 C MPI the sender needs to clear an Isend wait handle here.
202 C In a within process tile-tile data transport using true
203 C shared address space/or direct transfer through commonly
204 C addressable memory blocks the receiver needs to assert
205 C that he has consumed the buffer the sender filled here.
206 farTile=exch2_neighbourId(N,thisTile)
207 IF ( W2_myCommFlag(N,bi,bj) .EQ. 'M' ) THEN
208 wHandle = e2_msgHandles(1,N,bi,bj)
209 CALL MPI_Wait( wHandle, mpiStatus, mpiRc )
210 ELSEIF ( W2_myCommFlag(N,bi,bj) .EQ. 'P' ) THEN
211 ELSE
212 ENDIF
213 ENDDO
214 ENDDO
215 ENDDO
216
217 _END_MASTER( myThid )
218 C Everyone waits until master-thread finishes receiving
219 CALL BAR2( myThid )
220
221 #endif /* ALLOW_USE_MPI */
222
223 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
224
225 C-- Extract from buffer (either from level 1 if local exch,
226 C or level 2 if coming from an other Proc)
227 DO bj=myByLo(myThid), myByHi(myThid)
228 DO bi=myBxLo(myThid), myBxHi(myThid)
229 thisTile=W2_myTileList(bi,bj)
230 nN=exch2_nNeighbours(thisTile)
231 DO N=1,nN
232 CALL EXCH2_GET_SCAL_BOUNDS(
233 I fieldCode, exchWidthX, updateCorners,
234 I thisTile, N,
235 O tIlo, tiHi, tjLo, tjHi,
236 O tiStride, tjStride,
237 I myThid )
238 tKLo=1
239 tKHi=myNz
240 tKStride=1
241
242 C From buffer, get my points
243 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride) in "array":
244 C Note: when transferring data within a process:
245 C o e2Bufr entry to read is entry associated with opposing send record
246 C o e2_msgHandle entry to read is entry associated with opposing send record.
247 CALL EXCH2_GET_RX1(
248 I tIlo, tIhi, tiStride,
249 I tJlo, tJhi, tjStride,
250 I tKlo, tKhi, tkStride,
251 I thisTile, N, bi, bj,
252 I e2BufrRecSize, W2_maxNeighbours, nSx, nSy,
253 I e2Bufr1_RX,
254 U array(1-myOLw,1-myOLs,1,bi,bj),
255 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
256 U e2_msgHandles,
257 I W2_myCommFlag(N,bi,bj), myThid )
258 ENDDO
259 ENDDO
260 ENDDO
261
262 RETURN
263 END
264
265 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
266
267 CEH3 ;;; Local Variables: ***
268 CEH3 ;;; mode:fortran ***
269 CEH3 ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22