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