/[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.5 - (show annotations) (download)
Tue Jul 29 20:25:23 2008 UTC (15 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61j, checkpoint61h, checkpoint61i
Changes since 1.4: +10 -10 lines
- change index-bounds storage (move from target to local tile,
  more intuitive this way)
- rename/remove some variables

1 C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_rx1_cube.template,v 1.4 2006/08/31 22:11:01 jmc Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 #undef Dbg
7
8 CBOP
9 C !ROUTINE: EXCH_RX_CUBE
10
11 C !INTERFACE:
12 SUBROUTINE EXCH2_RX1_CUBE(
13 U array, 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 regi 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 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 array(1-myOLw:sNx+myOLe,
51 & 1-myOLs:sNy+myOLn,
52 & myNZ, nSx, nSy)
53
54 C !LOCAL VARIABLES:
55 C theSimulationMode :: Holds working copy of simulation mode
56 C theCornerMode :: Holds working copy of corner mode
57 C I,J,K,bl,bt,bn,bs :: Loop and index counters
58 C be,bw
59 INTEGER theSimulationMode
60 INTEGER theCornerMode
61 c INTEGER I,J,K
62 c INTEGER bl,bt,bn,bs,be,bw
63 INTEGER I
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 tIlo, tIhi, tJlo, tJhi, tKlo, tKhi
68 INTEGER tIStride, tJStride, tKStride
69 INTEGER i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi
70 INTEGER bi1Lo, bi1Hi, bj1Lo, bj1Hi
71 C == Statement function ==
72 C tilemod - Permutes indices to return neighboring tile index on
73 C six face cube.
74 c INTEGER tilemod
75
76 C MPI stuff (should be in a routine call)
77 #ifdef ALLOW_USE_MPI
78 INTEGER mpiStatus(MPI_STATUS_SIZE)
79 INTEGER mpiRc
80 INTEGER wHandle
81 #endif
82 CEOP
83
84 theSimulationMode = simulationMode
85 theCornerMode = cornerMode
86
87 C For now tile<->tile exchanges are sequentialised through
88 C thread 1. This is a temporary feature for preliminary testing until
89 C general tile decomposistion is in place (CNH April 11, 2001)
90 CALL BAR2( myThid )
91
92 C Post sends as messages or buffer copies
93 DO I=myBxLo(myThid), myBxHi(myThid)
94 thisTile=W2_myTileList(I)
95 nN=exch2_nNeighbours(thisTile)
96 DO N=1,nN
97 farTile=exch2_neighbourId(N,thisTile)
98 oN=exch2_opposingSend(N,thisTile)
99 tIlo =exch2_iLo(oN,farTile)
100 tIhi =exch2_iHi(oN,farTile)
101 tJlo =exch2_jLo(oN,farTile)
102 tJhi =exch2_jHi(oN,farTile)
103 CALL EXCH2_GET_SEND_BOUNDS(
104 I fieldCode, exchWidthX,
105 O tiStride, tjStride,
106 U tIlo, tiHi, tjLo, tjHi )
107 tKLo=1
108 tKHi=myNz
109 tKStride=1
110 i1Lo = 1-myOLw
111 i1Hi = sNx+myOLe
112 j1Lo = 1-myOLs
113 j1Hi = sNy+myOLs
114 k1Lo = 1
115 k1Hi = myNz
116 bi1Lo = I
117 bi1Hi = I
118 bj1Lo = 1
119 bj1Hi = 1
120 C Send to neighbour N to fill neighbor points
121 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride)
122 C in its copy of "array".
123 CALL EXCH2_SEND_RX1(
124 I tIlo, tIhi, tiStride,
125 I tJlo, tJhi, tjStride,
126 I tKlo, tKhi, tkStride,
127 I thisTile, N,
128 I e2Bufr1_RX(1,N,I,1), e2BufrRecSize,
129 I array(1-myOLw,1-myOLs,1,I,1),
130 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
131 O e2_msgHandles(1,N,I),
132 I W2_myCommFlag(N,I),
133 I myThid )
134 ENDDO
135 ENDDO
136
137 C without MPI: wait until all threads finish filling buffer
138 CALL BAR2( myThid )
139
140 C Receive messages or extract buffer copies
141 DO I=myBxLo(myThid), myBxHi(myThid)
142 thisTile=W2_myTileList(I)
143 nN=exch2_nNeighbours(thisTile)
144 DO N=1,nN
145 farTile=exch2_neighbourId(N,thisTile)
146 tIlo =exch2_iLo(N,thisTile)
147 tIhi =exch2_iHi(N,thisTile)
148 tJlo =exch2_jLo(N,thisTile)
149 tJhi =exch2_jHi(N,thisTile)
150 CALL EXCH2_GET_RECV_BOUNDS(
151 I fieldCode, exchWidthX,
152 O tiStride, tjStride,
153 U tIlo, tiHi, tjLo, tjHi )
154 tKLo=1
155 tKHi=myNz
156 tKStride=1
157 i1Lo = 1-myOLw
158 i1Hi = sNx+myOLe
159 j1Lo = 1-myOLs
160 j1Hi = sNy+myOLs
161 k1Lo = 1
162 k1Hi = myNz
163 bi1Lo = I
164 bi1Hi = I
165 bj1Lo = 1
166 bj1Hi = 1
167
168 C Receive from neighbour N to fill my points
169 C (tIlo:tIhi:tiStride,tJlo:tJhi,tJStride,tKlo:tKhi,tKStride)
170 C in "array".
171 C Note: when transferring data within a process:
172 C o e2Bufr entry to read is entry associated with opposing send record
173 C o e2_msgHandle entry to read is entry associated with opposing send
174 C record.
175 CALL EXCH2_RECV_RX1(
176 I tIlo, tIhi, tiStride,
177 I tJlo, tJhi, tjStride,
178 I tKlo, tKhi, tkStride,
179 I thisTile, I, N,
180 I e2Bufr1_RX, e2BufrRecSize,
181 I MAX_NEIGHBOURS, nSx,
182 I array(1-myOLw,1-myOLs,1,I,1),
183 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
184 U e2_msgHandles,
185 I W2_myTileList,
186 I W2_myCommFlag(N,I),
187 I myThid )
188 ENDDO
189 ENDDO
190
191 C Clear message handles/locks
192 DO I=1,nSx
193 thisTile=W2_myTileList(I)
194 nN=exch2_nNeighbours(thisTile)
195 DO N=1,nN
196 C Note: In a between process tile-tile data transport using
197 C MPI the sender needs to clear an Isend wait handle here.
198 C In a within process tile-tile data transport using true
199 C shared address space/or direct transfer through commonly
200 C addressable memory blocks the receiver needs to assert
201 C that is has consumed the buffer the sender filled here.
202 farTile=exch2_neighbourId(N,thisTile)
203 IF ( W2_myCommFlag(N,I) .EQ. 'M' ) THEN
204 #ifdef ALLOW_USE_MPI
205 wHandle = e2_msgHandles(1,N,I)
206 CALL MPI_Wait( wHandle, mpiStatus, mpiRc )
207 #endif
208 ELSEIF ( W2_myCommFlag(N,I) .EQ. 'P' ) THEN
209 ELSE
210 ENDIF
211 ENDDO
212 ENDDO
213
214 CALL BAR2(myThid)
215
216 RETURN
217 END
218
219 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
220
221 CEH3 ;;; Local Variables: ***
222 CEH3 ;;; mode:fortran ***
223 CEH3 ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22