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

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

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


Revision 1.6 - (show annotations) (download)
Fri Aug 1 00:45:16 2008 UTC (15 years, 9 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61j, checkpoint61h, checkpoint61i
Changes since 1.5: +99 -55 lines
change index bounds in rx2_cube exchanges (new S/R: EXCH2_GET_UV_BOUNDS)
- no longer depend on the order sequence (N,S,E,W).
- 3rd exchange no longer needed (tested with 24 tiles).
- same modif to hand-written adjoint S/R (global_ocean.cs32x15: zero diff)
- exch_UV_A-grid readily available (but not yet tested).

1 C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_rx2_cube.template,v 1.5 2008/07/29 20:25:23 jmc Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5 #undef LOCAL_DBUG
6
7 CBOP
8 C !ROUTINE: EXCH_RX2_CUBE
9
10 C !INTERFACE:
11 SUBROUTINE EXCH2_RX2_CUBE(
12 U array1, array2, signOption, fieldCode,
13 I myOLw, myOLe, myOLn, myOLs, myNz,
14 I exchWidthX, exchWidthY,
15 I simulationMode, cornerMode, myThid )
16 IMPLICIT NONE
17
18 C !DESCRIPTION:
19
20 C !USES:
21 C == Global data ==
22 #include "SIZE.h"
23 #include "EEPARAMS.h"
24 #include "EESUPPORT.h"
25 #include "EXCH.h"
26 #include "W2_EXCH2_TOPOLOGY.h"
27 #include "W2_EXCH2_PARAMS.h"
28
29 C !INPUT/OUTPUT PARAMETERS:
30 C array :: Array with edges to exchange.
31 C myOLw :: West, East, North and South overlap region sizes.
32 C myOLe
33 C myOLn
34 C myOLs
35 C exchWidthX :: Width of data region exchanged in X.
36 C exchWidthY :: Width of data region exchanged in Y.
37 C myThid :: Thread number of this instance of S/R EXCH...
38 LOGICAL signOption
39 CHARACTER*2 fieldCode
40 INTEGER myOLw
41 INTEGER myOLe
42 INTEGER myOLs
43 INTEGER myOLn
44 INTEGER myNz
45 INTEGER exchWidthX
46 INTEGER exchWidthY
47 INTEGER simulationMode
48 INTEGER cornerMode
49 INTEGER myThid
50 _RX array1(1-myOLw:sNx+myOLe,
51 & 1-myOLs:sNy+myOLn,
52 & myNz, nSx, nSy)
53 _RX array2(1-myOLw:sNx+myOLe,
54 & 1-myOLs:sNy+myOLn,
55 & myNz, nSx, nSy)
56
57 C !LOCAL VARIABLES:
58 C theSimulationMode :: Holds working copy of simulation mode
59 C theCornerMode :: Holds working copy of corner mode
60 C I,J,K :: Loop and index counters
61 INTEGER theSimulationMode
62 INTEGER theCornerMode
63 INTEGER bi
64 C Variables for working through W2 topology
65 INTEGER e2_msgHandles(2,MAX_NEIGHBOURS, nSx)
66 INTEGER thisTile, farTile, N, nN, oN
67 INTEGER tIlo1, tIhi1, tJlo1, tJhi1, oIs1, oJs1
68 INTEGER tIlo2, tIhi2, tJlo2, tJhi2, oIs2, oJs2
69 INTEGER tIStride, tJStride
70 INTEGER tKlo, tKhi, tKStride
71 INTEGER i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi
72 INTEGER i2Lo, i2Hi, j2Lo, j2Hi, k2Lo, k2Hi
73 C == Statement function ==
74 C tilemod - Permutes indices to return neighboring tile index on
75 C six face cube.
76 c INTEGER tilemod
77
78 C MPI stuff (should be in a routine call)
79 #ifdef ALLOW_USE_MPI
80 INTEGER mpiStatus(MPI_STATUS_SIZE)
81 INTEGER mpiRc
82 INTEGER wHandle
83 #endif
84 CEOP
85
86 theSimulationMode = simulationMode
87 theCornerMode = cornerMode
88
89 C For now tile<->tile exchanges are sequentialised through
90 C thread 1. This is a temporary feature for preliminary testing until
91 C general tile decomposistion is in place (CNH April 11, 2001)
92 CALL BAR2( myThid )
93
94 C Post sends as messages or buffer copies
95 DO bi=myBxLo(myThid), myBxHi(myThid)
96 thisTile=W2_myTileList(bi)
97 nN=exch2_nNeighbours(thisTile)
98 DO N=1,nN
99 farTile=exch2_neighbourId(N,thisTile)
100 oN=exch2_opposingSend(N,thisTile)
101 tIlo1 = exch2_iLo(oN,farTile)
102 tIhi1 = exch2_iHi(oN,farTile)
103 tJlo1 = exch2_jLo(oN,farTile)
104 tJhi1 = exch2_jHi(oN,farTile)
105 oIs1 = exch2_oi(N,thisTile)
106 oJs1 = exch2_oj(N,thisTile)
107 #ifdef LOCAL_DBUG
108 WRITE(errorMessageUnit,'(A,2I3,A,4I4,A,2I5)')
109 & 'send_0 bi,N=', bi, N, ' , tI,J_lo,hi=',
110 & tIlo1, tIhi1, tJlo1, tJhi1, ' , oIs,oJs=', oIs1, oJs1
111 #endif
112 CALL EXCH2_GET_UV_BOUNDS(
113 I fieldCode, exchWidthX,
114 I exch2_isWedge(farTile), exch2_isEedge(farTile),
115 I exch2_isSedge(farTile), exch2_isNedge(farTile),
116 U tIlo1, tIhi1, tJlo1, tJhi1,
117 O tIlo2, tIhi2, tJlo2, tJhi2,
118 O tiStride, tjStride,
119 I exch2_pij(1,N,thisTile),
120 U oIs1, oJs1,
121 O oIs2, oJs2,
122 I myThid )
123 #ifdef LOCAL_DBUG
124 WRITE(errorMessageUnit,'(A,2I3,A,4I4,A,2I5)')
125 & 'send_1 bi,N=', bi, N, ' , tI,J_lo,hi=',
126 & tIlo1, tIhi1, tJlo1, tJhi1, ' , oIs,oJs=', oIs1, oJs1
127 WRITE(errorMessageUnit,'(A,2I3,A,4I4,A,2I5)')
128 & 'send_2 bi,N=', bi, N, ' , tI,J_lo,hi=',
129 & tIlo2, tIhi2, tJlo2, tJhi2, ' , oIs,oJs=', oIs2, oJs2
130 #endif
131 tKLo=1
132 tKHi=myNz
133 tKStride=1
134 i1Lo = 1-myOLw
135 i1Hi = sNx+myOLe
136 j1Lo = 1-myOLs
137 j1Hi = sNy+myOLs
138 k1Lo = 1
139 k1Hi = myNz
140 i2Lo = 1-myOLw
141 i2Hi = sNx+myOLe
142 j2Lo = 1-myOLs
143 j2Hi = sNy+myOLs
144 k2Lo = 1
145 k2Hi = myNz
146 C Send to neighbour N to fill neighbor points
147 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride)
148 C in its copy of "array".
149 CALL EXCH2_SEND_RX2(
150 I tIlo1, tIhi1, tIlo2, tIhi2, tiStride,
151 I tJlo1, tJhi1, tJlo2, tJhi2, tjStride,
152 I tKlo, tKhi, tkStride,
153 I thisTile, N, oIs1, oJs1, oIs2, oJs2,
154 O e2Bufr1_RX(1,N,bi,1),
155 O e2Bufr2_RX(1,N,bi,1),
156 I e2BufrRecSize,
157 I array1(1-myOLw,1-myOLs,1,bi,1),
158 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
159 I array2(1-myOLw,1-myOLs,1,bi,1),
160 I i2Lo, i2Hi, j2Lo, j2Hi, k2Lo, k2Hi,
161 O e2_msgHandles(1,N,bi),
162 O e2_msgHandles(2,N,bi),
163 I W2_myCommFlag(N,bi), signOption,
164 I myThid )
165 ENDDO
166 ENDDO
167
168 C without MPI: wait until all threads finish filling buffer
169 CALL BAR2( myThid )
170
171 C Receive messages or extract buffer copies
172 DO bi=myBxLo(myThid), myBxHi(myThid)
173 thisTile=W2_myTileList(bi)
174 nN=exch2_nNeighbours(thisTile)
175 DO N=1,nN
176 farTile=exch2_neighbourId(N,thisTile)
177 oN=exch2_opposingSend(N,thisTile)
178 tIlo1 = exch2_iLo(N,thisTile)
179 tIhi1 = exch2_iHi(N,thisTile)
180 tJlo1 = exch2_jLo(N,thisTile)
181 tJhi1 = exch2_jHi(N,thisTile)
182 oIs1 = exch2_oi(oN,farTile)
183 oJs1 = exch2_oj(oN,farTile)
184 #ifdef LOCAL_DBUG
185 WRITE(errorMessageUnit,'(A,2I3,A,4I4,A,2I5)')
186 & 'recv_0 bi,N=', bi, N, ' , tI,J_lo,hi=',
187 & tIlo1, tIhi1, tJlo1, tJhi1
188 #endif
189 CALL EXCH2_GET_UV_BOUNDS(
190 I fieldCode, exchWidthX,
191 I exch2_isWedge(thisTile), exch2_isEedge(thisTile),
192 I exch2_isSedge(thisTile), exch2_isNedge(thisTile),
193 U tIlo1, tIhi1, tJlo1, tJhi1,
194 O tIlo2, tIhi2, tJlo2, tJhi2,
195 O tiStride, tjStride,
196 I exch2_pij(1,oN,farTile),
197 U oIs1, oJs1,
198 O oIs2, oJs2,
199 I myThid )
200 #ifdef LOCAL_DBUG
201 WRITE(errorMessageUnit,'(A,2I3,A,4I4,A,2I5)')
202 & 'recv_1 bi,N=', bi, N, ' , tI,J_lo,hi=',
203 & tIlo1, tIhi1, tJlo1, tJhi1
204 WRITE(errorMessageUnit,'(A,2I3,A,4I4,A,2I5)')
205 & 'recv_2 bi,N=', bi, N, ' , tI,J_lo,hi=',
206 & tIlo2, tIhi2, tJlo2, tJhi2
207 #endif
208 tKLo=1
209 tKHi=myNz
210 tKStride=1
211 i1Lo = 1-myOLw
212 i1Hi = sNx+myOLe
213 j1Lo = 1-myOLs
214 j1Hi = sNy+myOLs
215 k1Lo = 1
216 k1Hi = myNz
217 i2Lo = 1-myOLw
218 i2Hi = sNx+myOLe
219 j2Lo = 1-myOLs
220 j2Hi = sNy+myOLs
221 k2Lo = 1
222 k2Hi = myNz
223 C Receive from neighbour N to fill my points
224 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride)
225 C in "array".
226 C Note: when transferring data within a process:
227 C o e2Bufr entry to read is entry associated with opposing send record
228 C o e2_msgHandle entry to read is entry associated with opposing send
229 C record.
230 CALL EXCH2_RECV_RX2(
231 I tIlo1, tIhi1, tIlo2, tIhi2, tiStride,
232 I tJlo1, tJhi1, tJlo2, tJhi2, tjStride,
233 I tKlo, tKhi, tkStride,
234 I thisTile, bi, N,
235 I e2Bufr1_RX, e2Bufr2_RX, e2BufrRecSize,
236 I MAX_NEIGHBOURS, nSx,
237 U array1(1-myOLw,1-myOLs,1,bi,1),
238 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
239 U array2(1-myOLw,1-myOLs,1,bi,1),
240 I i2Lo, i2Hi, j2Lo, j2Hi, k2Lo, k2Hi,
241 U e2_msgHandles,
242 I W2_myTileList,
243 I W2_myCommFlag(N,bi),
244 I myThid )
245 ENDDO
246 ENDDO
247
248 C Clear message handles/locks
249 DO bi=1,nSx
250 thisTile=W2_myTileList(bi)
251 nN=exch2_nNeighbours(thisTile)
252 DO N=1,nN
253 C Note: In a between process tile-tile data transport using
254 C MPI the sender needs to clear an Isend wait handle here.
255 C In a within process tile-tile data transport using true
256 C shared address space/or direct transfer through commonly
257 C addressable memory blocks the receiver needs to assert
258 C that is has consumed the buffer the sender filled here.
259 farTile=exch2_neighbourId(N,thisTile)
260 IF ( W2_myCommFlag(N,bi) .EQ. 'M' ) THEN
261 #ifdef ALLOW_USE_MPI
262 wHandle = e2_msgHandles(1,N,bi)
263 CALL MPI_Wait( wHandle, mpiStatus, mpiRc )
264 wHandle = e2_msgHandles(2,N,bi)
265 CALL MPI_Wait( wHandle, mpiStatus, mpiRc )
266 #endif
267 ELSEIF ( W2_myCommFlag(N,bi) .EQ. 'P' ) THEN
268 ELSE
269 ENDIF
270 ENDDO
271 ENDDO
272
273 CALL BAR2(myThid)
274
275 RETURN
276 END
277
278 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
279
280 CEH3 ;;; Local Variables: ***
281 CEH3 ;;; mode:fortran ***
282 CEH3 ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22