/[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.9 - (show annotations) (download)
Sat May 30 21:26:31 2009 UTC (15 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint61r, checkpoint61p, checkpoint61q
Changes since 1.8: +194 -156 lines
- take buffer copy from/to array out of S/R exch2_send/recv into new
  S/R exch2_put/get ; Exch of local variable now works with MPI+MTH
  (tested by removing commom block statement in SOLVE_FOR_PRESSURE.h).
- simplify argument list of S/R exch2_get_uv_bounds & get_scal_bounds
- implement EXCH_IGNORE_CORNERS in scalar exchange (rx1);

1 C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_rx1_cube.template,v 1.8 2009/05/12 19:44:58 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 fieldCode,
13 I myOLw, myOLe, myOLn, myOLs, myNz,
14 I exchWidthX, exchWidthY,
15 I simulationMode, 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 fieldCode :: field code (position on staggered grid)
36 C myOLw,myOLe :: West and East overlap region sizes.
37 C myOLn,myOLs :: North and South overlap region sizes.
38 C exchWidthX :: Width of data region exchanged in X.
39 C exchWidthY :: Width of data region exchanged in Y.
40 C cornerMode :: halo-corner-region treatment: update/ignore corner region
41 C myThid :: my Thread Id. number
42
43 INTEGER myOLw, myOLe, myOLn, myOLs, myNz
44 _RX array(1-myOLw:sNx+myOLe,
45 & 1-myOLs:sNy+myOLn,
46 & myNz, nSx, nSy)
47 CHARACTER*2 fieldCode
48 INTEGER exchWidthX
49 INTEGER exchWidthY
50 INTEGER simulationMode
51 INTEGER cornerMode
52 INTEGER myThid
53
54 C !LOCAL VARIABLES:
55 C e2_msgHandles :: Synchronization and coordination data structure used to
56 C :: coordinate access to e2Bufr1_RX or to regulate message
57 C :: buffering. In PUT communication sender will increment
58 C :: handle entry once data is ready in buffer. Receiver will
59 C :: decrement handle once data is consumed from buffer.
60 C :: For MPI MSG communication MPI_Wait uses hanlde to check
61 C :: Isend has cleared. This is done in routine after receives.
62 C note: a) current implementation does not use e2_msgHandles for communication
63 C between threads: all-threads barriers are used (see CNH note below).
64 C For a 2-threads synchro communication (future version),
65 C e2_msgHandles should be shared (in common block, moved to BUFFER.h)
66 C b) 1rst dim=2 so that it could be used also by exch2_rx2_cube.
67 INTEGER bi, bj
68 C Variables for working through W2 topology
69 INTEGER e2_msgHandles( 2, W2_maxNeighbours, nSx, nSy )
70 INTEGER thisTile, farTile, N, nN, oN
71 INTEGER tIlo, tIhi, tJlo, tJhi, tKlo, tKhi
72 INTEGER tIStride, tJStride, tKStride
73 INTEGER i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi
74 LOGICAL updateCorners
75
76 #ifdef ALLOW_USE_MPI
77 INTEGER iBufr, nri, nrj
78 C MPI stuff (should be in a routine call)
79 INTEGER mpiStatus(MPI_STATUS_SIZE)
80 INTEGER mpiRc
81 INTEGER wHandle
82 #endif
83 CEOP
84
85 updateCorners = cornerMode .EQ. EXCH_UPDATE_CORNERS
86 C- Tile size of array to exchange:
87 i1Lo = 1-myOLw
88 i1Hi = sNx+myOLe
89 j1Lo = 1-myOLs
90 j1Hi = sNy+myOLn
91 k1Lo = 1
92 k1Hi = myNz
93
94 C For now tile <-> tile exchanges are sequentialised through
95 C thread 1. This is a temporary feature for preliminary testing until
96 C general tile decomposition is in place (CNH April 11, 2001)
97 CALL BAR2( myThid )
98
99 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
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)
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),
128 O e2Bufr1_RX(1,N,bi,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), myThid )
133 ENDDO
134 ENDDO
135 ENDDO
136
137 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
138
139 #ifdef ALLOW_USE_MPI
140 C wait until all threads finish filling buffer
141 CALL BAR2( myThid )
142 _BEGIN_MASTER( myThid )
143
144 C-- Send my data (in buffer, level 1) to target Process
145 DO bj=1,nSy
146 DO bi=1,nSx
147 thisTile=W2_myTileList(bi)
148 nN=exch2_nNeighbours(thisTile)
149 DO N=1,nN
150 C- Skip the call if this is an internal exchange
151 IF ( W2_myCommFlag(N,bi) .EQ. 'M' ) THEN
152 CALL EXCH2_SEND_RX1(
153 I thisTile, N,
154 I e2BufrRecSize,
155 I iBuf1Filled(N,bi),
156 I e2Bufr1_RX(1,N,bi,1),
157 O e2_msgHandles(1,N,bi,bj),
158 I W2_myCommFlag(N,bi), myThid )
159 ENDIF
160 ENDDO
161 ENDDO
162 ENDDO
163
164 C-- Receive data (in buffer, level 2) from source Process
165 DO bj=1,nSy
166 DO bi=1,nSx
167 thisTile=W2_myTileList(bi)
168 nN=exch2_nNeighbours(thisTile)
169 DO N=1,nN
170 C- Skip the call if this is an internal exchange
171 IF ( W2_myCommFlag(N,bi) .EQ. 'M' ) THEN
172 CALL EXCH2_GET_SCAL_BOUNDS(
173 I fieldCode, exchWidthX, updateCorners,
174 I thisTile, N,
175 O tIlo, tiHi, tjLo, tjHi,
176 O tiStride, tjStride,
177 I myThid )
178 nri = 1 + (tIhi-tIlo)/tiStride
179 nrj = 1 + (tJhi-tJlo)/tjStride
180 iBufr = nri*nrj*myNz
181 C Receive from neighbour N to fill buffer and later on the array
182 CALL EXCH2_RECV_RX1(
183 I thisTile, N,
184 I e2BufrRecSize,
185 I iBufr,
186 O e2Bufr1_RX(1,N,bi,2),
187 I W2_myCommFlag(N,bi), myThid )
188 ENDIF
189 ENDDO
190 ENDDO
191 ENDDO
192
193 C-- Clear message handles/locks
194 DO bj=1,nSy
195 DO bi=1,nSx
196 thisTile=W2_myTileList(bi)
197 nN=exch2_nNeighbours(thisTile)
198 DO N=1,nN
199 C Note: In a between process tile-tile data transport using
200 C MPI the sender needs to clear an Isend wait handle here.
201 C In a within process tile-tile data transport using true
202 C shared address space/or direct transfer through commonly
203 C addressable memory blocks the receiver needs to assert
204 C that he has consumed the buffer the sender filled here.
205 farTile=exch2_neighbourId(N,thisTile)
206 IF ( W2_myCommFlag(N,bi) .EQ. 'M' ) THEN
207 wHandle = e2_msgHandles(1,N,bi,bj)
208 CALL MPI_Wait( wHandle, mpiStatus, mpiRc )
209 ELSEIF ( W2_myCommFlag(N,bi) .EQ. 'P' ) THEN
210 ELSE
211 ENDIF
212 ENDDO
213 ENDDO
214 ENDDO
215
216 _END_MASTER( myThid )
217 #endif /* ALLOW_USE_MPI */
218
219 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
220 C Wait until all threads finish receiving or filling buffer
221 CALL BAR2( myThid )
222
223 C-- Extract from buffer (either from level 1 if local exch,
224 C or level 2 if coming from an other Proc)
225 DO bj=myByLo(myThid), myByHi(myThid)
226 DO bi=myBxLo(myThid), myBxHi(myThid)
227 thisTile=W2_myTileList(bi)
228 nN=exch2_nNeighbours(thisTile)
229 DO N=1,nN
230 CALL EXCH2_GET_SCAL_BOUNDS(
231 I fieldCode, exchWidthX, updateCorners,
232 I thisTile, N,
233 O tIlo, tiHi, tjLo, tjHi,
234 O tiStride, tjStride,
235 I myThid )
236 tKLo=1
237 tKHi=myNz
238 tKStride=1
239
240 C From buffer, get my points
241 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride) in "array":
242 C Note: when transferring data within a process:
243 C o e2Bufr entry to read is entry associated with opposing send record
244 C o e2_msgHandle entry to read is entry associated with opposing send record.
245 CALL EXCH2_GET_RX1(
246 I tIlo, tIhi, tiStride,
247 I tJlo, tJhi, tjStride,
248 I tKlo, tKhi, tkStride,
249 I thisTile, N, bi, bj,
250 I e2BufrRecSize, W2_maxNeighbours, nSx, nSy,
251 I e2Bufr1_RX,
252 U array(1-myOLw,1-myOLs,1,bi,bj),
253 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
254 U e2_msgHandles,
255 I W2_myCommFlag(N,bi), myThid )
256 ENDDO
257 ENDDO
258 ENDDO
259
260 CALL BAR2(myThid)
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