1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "FLT_CPPOPTIONS.h" |
5 |
|
6 |
subroutine flt_exchg ( |
7 |
I myCurrentIter, |
8 |
I myCurrentTime, |
9 |
I myThid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE flt_exchg |
14 |
c ================================================================== |
15 |
c |
16 |
c o |
17 |
c |
18 |
c ================================================================== |
19 |
c SUBROUTINE flt_exchg |
20 |
c ================================================================== |
21 |
|
22 |
c == global variables == |
23 |
|
24 |
#include "SIZE.h" |
25 |
#include "EEPARAMS.h" |
26 |
#include "EESUPPORT.h" |
27 |
#include "EXCH.h" |
28 |
#include "FLT.h" |
29 |
#include "GRID.h" |
30 |
#include "PARAMS.h" |
31 |
|
32 |
c == routine arguments == |
33 |
|
34 |
INTEGER myCurrentIter, myThid |
35 |
_RL myCurrentTime |
36 |
INTEGER bi, bj, ic |
37 |
character*(max_len_mbuf) msgbuf |
38 |
|
39 |
c == local variables == |
40 |
|
41 |
integer ip |
42 |
integer icountE, icountW, icountN, icountS |
43 |
_RL xx, yy |
44 |
INTEGER imax, imax2, m, iG, jG |
45 |
_RL xlo, xhi, ylo, yhi |
46 |
parameter(imax=9) |
47 |
parameter(imax2=imax*max_npart_exch) |
48 |
|
49 |
c buffer for sending/receiving variables (E/W are also used for S/N) |
50 |
_RL fltbuf_sendE(imax2,nSx,nSy) |
51 |
_RL fltbuf_sendW(imax2,nSx,nSy) |
52 |
_RL fltbuf_recvE(imax2,nSx,nSy) |
53 |
_RL fltbuf_recvW(imax2,nSx,nSy) |
54 |
|
55 |
_RL npart_dist |
56 |
c == end of interface == |
57 |
|
58 |
C-- Choose floats that have to exchanged with eastern and western tiles |
59 |
C and pack to arrays |
60 |
|
61 |
|
62 |
DO bj=myByLo(myThid),myByHi(myThid) |
63 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
64 |
|
65 |
c initialize buffers |
66 |
|
67 |
do m=1,imax2 |
68 |
fltbuf_sendE(m,bi,bj) = 0. |
69 |
fltbuf_sendW(m,bi,bj) = 0. |
70 |
fltbuf_recvE(m,bi,bj) = 0. |
71 |
fltbuf_recvW(m,bi,bj) = 0. |
72 |
enddo |
73 |
|
74 |
icountE=0 |
75 |
icountW=0 |
76 |
|
77 |
iG = myXGlobalLo + (bi-1)*sNx |
78 |
xlo = xc(1, 1, bi,bj) - delX(iG) |
79 |
xhi = xc(sNx,1,bi,bj) + delX(iG+sNx-1) |
80 |
c |
81 |
do ip=1,npart_tile(bi,bj) |
82 |
c |
83 |
if (xpart(ip,bi,bj) .ge. xhi) then |
84 |
icountE=icountE+1 |
85 |
if (icountE .gt. max_npart_exch) |
86 |
& stop ' max_npart_exch too low. stop in flt_exchg' |
87 |
|
88 |
ic=(icountE-1)*imax |
89 |
fltbuf_sendE(ic+1,bi,bj) = npart(ip,bi,bj) |
90 |
fltbuf_sendE(ic+2,bi,bj) = tstart(ip,bi,bj) |
91 |
fltbuf_sendE(ic+3,bi,bj) = xpart(ip,bi,bj) |
92 |
fltbuf_sendE(ic+4,bi,bj) = ypart(ip,bi,bj) |
93 |
fltbuf_sendE(ic+5,bi,bj) = kpart(ip,bi,bj) |
94 |
fltbuf_sendE(ic+6,bi,bj) = kfloat(ip,bi,bj) |
95 |
fltbuf_sendE(ic+7,bi,bj) = iup(ip,bi,bj) |
96 |
fltbuf_sendE(ic+8,bi,bj) = itop(ip,bi,bj) |
97 |
fltbuf_sendE(ic+9,bi,bj) = tend(ip,bi,bj) |
98 |
|
99 |
npart(ip,bi,bj) = npart(npart_tile(bi,bj),bi,bj) |
100 |
tstart(ip,bi,bj) = tstart(npart_tile(bi,bj),bi,bj) |
101 |
xpart(ip,bi,bj) = xpart(npart_tile(bi,bj),bi,bj) |
102 |
ypart(ip,bi,bj) = ypart(npart_tile(bi,bj),bi,bj) |
103 |
kpart(ip,bi,bj) = kpart(npart_tile(bi,bj),bi,bj) |
104 |
kfloat(ip,bi,bj) = kfloat(npart_tile(bi,bj),bi,bj) |
105 |
iup(ip,bi,bj) = iup(npart_tile(bi,bj),bi,bj) |
106 |
itop(ip,bi,bj) = itop(npart_tile(bi,bj),bi,bj) |
107 |
tend(ip,bi,bj) = tend(npart_tile(bi,bj),bi,bj) |
108 |
|
109 |
npart_tile(bi,bj) = npart_tile(bi,bj) - 1 |
110 |
|
111 |
endif |
112 |
|
113 |
if (xpart(ip,bi,bj) .le. xlo) then |
114 |
icountW=icountW+1 |
115 |
if (icountW .gt. max_npart_exch) |
116 |
& stop ' max_npart_exch too low. stop in flt_exchg' |
117 |
|
118 |
ic=(icountW-1)*imax |
119 |
fltbuf_sendW(ic+1,bi,bj) = npart(ip,bi,bj) |
120 |
fltbuf_sendW(ic+2,bi,bj) = tstart(ip,bi,bj) |
121 |
fltbuf_sendW(ic+3,bi,bj) = xpart(ip,bi,bj) |
122 |
fltbuf_sendW(ic+4,bi,bj) = ypart(ip,bi,bj) |
123 |
fltbuf_sendW(ic+5,bi,bj) = kpart(ip,bi,bj) |
124 |
fltbuf_sendW(ic+6,bi,bj) = kfloat(ip,bi,bj) |
125 |
fltbuf_sendW(ic+7,bi,bj) = iup(ip,bi,bj) |
126 |
fltbuf_sendW(ic+8,bi,bj) = itop(ip,bi,bj) |
127 |
fltbuf_sendW(ic+9,bi,bj) = tend(ip,bi,bj) |
128 |
|
129 |
npart(ip,bi,bj) = npart(npart_tile(bi,bj),bi,bj) |
130 |
tstart(ip,bi,bj) = tstart(npart_tile(bi,bj),bi,bj) |
131 |
xpart(ip,bi,bj) = xpart(npart_tile(bi,bj),bi,bj) |
132 |
ypart(ip,bi,bj) = ypart(npart_tile(bi,bj),bi,bj) |
133 |
kpart(ip,bi,bj) = kpart(npart_tile(bi,bj),bi,bj) |
134 |
kfloat(ip,bi,bj) = kfloat(npart_tile(bi,bj),bi,bj) |
135 |
iup(ip,bi,bj) = iup(npart_tile(bi,bj),bi,bj) |
136 |
itop(ip,bi,bj) = itop(npart_tile(bi,bj),bi,bj) |
137 |
tend(ip,bi,bj) = tend(npart_tile(bi,bj),bi,bj) |
138 |
|
139 |
npart_tile(bi,bj) = npart_tile(bi,bj) - 1 |
140 |
|
141 |
endif |
142 |
|
143 |
enddo |
144 |
|
145 |
|
146 |
ENDDO |
147 |
ENDDO |
148 |
|
149 |
C-- "Put" east and west edges. |
150 |
CALL EXCH_RL_SEND_PUT_VEC_X( fltbuf_sendE, fltbuf_sendW, |
151 |
I imax2, myThid ) |
152 |
C-- Receive east/west arrays before exchanging north/south arrays |
153 |
CALL EXCH_RL_RECV_GET_VEC_X( fltbuf_recvE, fltbuf_recvW, |
154 |
I imax2, myThid ) |
155 |
|
156 |
C-- Unpack arrays on new tiles |
157 |
|
158 |
DO bj=myByLo(myThid),myByHi(myThid) |
159 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
160 |
|
161 |
do ip=1,max_npart_exch |
162 |
c |
163 |
ic=(ip-1)*imax |
164 |
if (fltbuf_recvE(ic+1,bi,bj) .eq. 0.) goto 100 |
165 |
npart_tile(bi,bj) = npart_tile(bi,bj) + 1 |
166 |
if (npart_tile(bi,bj) .gt. max_npart_tile) |
167 |
& stop ' max_npart_tile too low. stop in flt_exchg' |
168 |
|
169 |
npart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+1,bi,bj) |
170 |
tstart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+2,bi,bj) |
171 |
xpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+3,bi,bj) |
172 |
ypart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+4,bi,bj) |
173 |
kpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+5,bi,bj) |
174 |
kfloat(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+6,bi,bj) |
175 |
iup(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+7,bi,bj) |
176 |
itop(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+8,bi,bj) |
177 |
tend(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+9,bi,bj) |
178 |
|
179 |
enddo |
180 |
100 continue |
181 |
|
182 |
do ip=1,max_npart_exch |
183 |
c |
184 |
ic=(ip-1)*imax |
185 |
if (fltbuf_recvW(ic+1,bi,bj) .eq. 0.) goto 200 |
186 |
npart_tile(bi,bj) = npart_tile(bi,bj) + 1 |
187 |
if (npart_tile(bi,bj) .gt. max_npart_tile) |
188 |
& stop ' max_npart_tile too low. stop in flt_exchg' |
189 |
|
190 |
npart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+1,bi,bj) |
191 |
tstart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+2,bi,bj) |
192 |
xpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+3,bi,bj) |
193 |
ypart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+4,bi,bj) |
194 |
kpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+5,bi,bj) |
195 |
kfloat(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+6,bi,bj) |
196 |
iup(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+7,bi,bj) |
197 |
itop(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+8,bi,bj) |
198 |
itop(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+8,bi,bj) |
199 |
tend(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+9,bi,bj) |
200 |
|
201 |
enddo |
202 |
200 continue |
203 |
|
204 |
ENDDO |
205 |
ENDDO |
206 |
|
207 |
C-- Choose floats that have to exchanged with eastern and western tiles |
208 |
C and pack to arrays |
209 |
|
210 |
|
211 |
DO bj=myByLo(myThid),myByHi(myThid) |
212 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
213 |
|
214 |
c initialize buffers |
215 |
|
216 |
do m=1,imax2 |
217 |
fltbuf_sendE(m,bi,bj) = 0. |
218 |
fltbuf_sendW(m,bi,bj) = 0. |
219 |
fltbuf_recvE(m,bi,bj) = 0. |
220 |
fltbuf_recvW(m,bi,bj) = 0. |
221 |
enddo |
222 |
|
223 |
icountN=0 |
224 |
icountS=0 |
225 |
|
226 |
jG = myYGlobalLo + (bj-1)*sNy |
227 |
ylo = yc(1, 1, bi,bj) - delY(jG) |
228 |
yhi = yc(1,sNy,bi,bj) + delY(jG+sNy-1) |
229 |
|
230 |
do ip=1,npart_tile(bi,bj) |
231 |
|
232 |
if (ypart(ip,bi,bj) .ge. yhi) then |
233 |
icountN=icountN+1 |
234 |
if (icountN .gt. max_npart_exch) |
235 |
& stop ' max_npart_exch too low. stop in flt_exchg' |
236 |
|
237 |
ic=(icountN-1)*imax |
238 |
fltbuf_sendE(ic+1,bi,bj) = npart(ip,bi,bj) |
239 |
fltbuf_sendE(ic+2,bi,bj) = tstart(ip,bi,bj) |
240 |
fltbuf_sendE(ic+3,bi,bj) = xpart(ip,bi,bj) |
241 |
fltbuf_sendE(ic+4,bi,bj) = ypart(ip,bi,bj) |
242 |
fltbuf_sendE(ic+5,bi,bj) = kpart(ip,bi,bj) |
243 |
fltbuf_sendE(ic+6,bi,bj) = kfloat(ip,bi,bj) |
244 |
fltbuf_sendE(ic+7,bi,bj) = iup(ip,bi,bj) |
245 |
fltbuf_sendE(ic+8,bi,bj) = itop(ip,bi,bj) |
246 |
fltbuf_sendE(ic+9,bi,bj) = tend(ip,bi,bj) |
247 |
|
248 |
npart(ip,bi,bj) = npart(npart_tile(bi,bj),bi,bj) |
249 |
tstart(ip,bi,bj) = tstart(npart_tile(bi,bj),bi,bj) |
250 |
xpart(ip,bi,bj) = xpart(npart_tile(bi,bj),bi,bj) |
251 |
ypart(ip,bi,bj) = ypart(npart_tile(bi,bj),bi,bj) |
252 |
kpart(ip,bi,bj) = kpart(npart_tile(bi,bj),bi,bj) |
253 |
kfloat(ip,bi,bj) = kfloat(npart_tile(bi,bj),bi,bj) |
254 |
iup(ip,bi,bj) = iup(npart_tile(bi,bj),bi,bj) |
255 |
itop(ip,bi,bj) = itop(npart_tile(bi,bj),bi,bj) |
256 |
tend(ip,bi,bj) = tend(npart_tile(bi,bj),bi,bj) |
257 |
|
258 |
npart_tile(bi,bj) = npart_tile(bi,bj) - 1 |
259 |
endif |
260 |
|
261 |
if (ypart(ip,bi,bj) .le. ylo) then |
262 |
icountS=icountS+1 |
263 |
if (icountS .gt. max_npart_exch) |
264 |
& stop ' max_npart_exch too low. stop in flt_exchg' |
265 |
|
266 |
ic=(icountS-1)*imax |
267 |
fltbuf_sendW(ic+1,bi,bj) = npart(ip,bi,bj) |
268 |
fltbuf_sendW(ic+2,bi,bj) = tstart(ip,bi,bj) |
269 |
fltbuf_sendW(ic+3,bi,bj) = xpart(ip,bi,bj) |
270 |
fltbuf_sendW(ic+4,bi,bj) = ypart(ip,bi,bj) |
271 |
fltbuf_sendW(ic+5,bi,bj) = kpart(ip,bi,bj) |
272 |
fltbuf_sendW(ic+6,bi,bj) = kfloat(ip,bi,bj) |
273 |
fltbuf_sendW(ic+7,bi,bj) = iup(ip,bi,bj) |
274 |
fltbuf_sendW(ic+8,bi,bj) = itop(ip,bi,bj) |
275 |
fltbuf_sendW(ic+9,bi,bj) = tend(ip,bi,bj) |
276 |
|
277 |
npart(ip,bi,bj) = npart(npart_tile(bi,bj),bi,bj) |
278 |
tstart(ip,bi,bj) = tstart(npart_tile(bi,bj),bi,bj) |
279 |
xpart(ip,bi,bj) = xpart(npart_tile(bi,bj),bi,bj) |
280 |
ypart(ip,bi,bj) = ypart(npart_tile(bi,bj),bi,bj) |
281 |
kpart(ip,bi,bj) = kpart(npart_tile(bi,bj),bi,bj) |
282 |
kfloat(ip,bi,bj) = kfloat(npart_tile(bi,bj),bi,bj) |
283 |
iup(ip,bi,bj) = iup(npart_tile(bi,bj),bi,bj) |
284 |
itop(ip,bi,bj) = itop(npart_tile(bi,bj),bi,bj) |
285 |
tend(ip,bi,bj) = tend(npart_tile(bi,bj),bi,bj) |
286 |
|
287 |
npart_tile(bi,bj) = npart_tile(bi,bj) - 1 |
288 |
endif |
289 |
|
290 |
enddo |
291 |
|
292 |
ENDDO |
293 |
ENDDO |
294 |
|
295 |
C "Put" north and south arrays. |
296 |
CALL EXCH_RL_SEND_PUT_VEC_Y( fltbuf_sendE, fltbuf_sendW, |
297 |
I imax2, myThid ) |
298 |
|
299 |
C Receive north and south arrays |
300 |
CALL EXCH_RL_RECV_GET_VEC_Y( fltbuf_recvE, fltbuf_recvW, |
301 |
I imax2, myThid ) |
302 |
|
303 |
C-- Unpack arrays on new tiles |
304 |
|
305 |
DO bj=myByLo(myThid),myByHi(myThid) |
306 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
307 |
|
308 |
do ip=1,max_npart_exch |
309 |
c |
310 |
ic=(ip-1)*imax |
311 |
if (fltbuf_recvE(ic+1,bi,bj) .eq. 0.) goto 300 |
312 |
npart_tile(bi,bj) = npart_tile(bi,bj) + 1 |
313 |
if (npart_tile(bi,bj) .gt. max_npart_tile) |
314 |
& stop ' max_npart_tile too low. stop in flt_exchg' |
315 |
|
316 |
npart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+1,bi,bj) |
317 |
tstart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+2,bi,bj) |
318 |
xpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+3,bi,bj) |
319 |
ypart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+4,bi,bj) |
320 |
kpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+5,bi,bj) |
321 |
kfloat(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+6,bi,bj) |
322 |
iup(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+7,bi,bj) |
323 |
itop(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+8,bi,bj) |
324 |
tend(npart_tile(bi,bj),bi,bj) = fltbuf_recvE(ic+9,bi,bj) |
325 |
|
326 |
enddo |
327 |
300 continue |
328 |
|
329 |
do ip=1,max_npart_exch |
330 |
c |
331 |
ic=(ip-1)*imax |
332 |
if (fltbuf_recvW(ic+1,bi,bj) .eq. 0.) goto 400 |
333 |
npart_tile(bi,bj) = npart_tile(bi,bj) + 1 |
334 |
if (npart_tile(bi,bj) .gt. max_npart_tile) |
335 |
& stop ' max_npart_tile too low. stop in flt_exchg' |
336 |
|
337 |
npart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+1,bi,bj) |
338 |
tstart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+2,bi,bj) |
339 |
xpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+3,bi,bj) |
340 |
ypart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+4,bi,bj) |
341 |
kpart(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+5,bi,bj) |
342 |
kfloat(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+6,bi,bj) |
343 |
iup(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+7,bi,bj) |
344 |
itop(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+8,bi,bj) |
345 |
tend(npart_tile(bi,bj),bi,bj) = fltbuf_recvW(ic+9,bi,bj) |
346 |
|
347 |
enddo |
348 |
400 continue |
349 |
|
350 |
ENDDO |
351 |
ENDDO |
352 |
|
353 |
return |
354 |
end |