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

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

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


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

  ViewVC Help
Powered by ViewVC 1.1.22