41
42
43
47
48
49
50 USE spmd_comm_world_mod, ONLY : spmd_comm_world
51#include "implicit_f.inc"
52
53
54
55#include "spmd.inc"
56
57
58
59#include "com01_c.inc"
60#include "task_c.inc"
61#include "sphcom.inc"
62
63
64
65 INTEGER KXSP(NISP,*), WSP2SORT(*)
67 . x(3,*),bminmal(*), spbuf(nspbuf,*)
68
69
70
71#ifdef MPI
72 INTEGER P, KK, I, J, NOD, N, MSGTYP, LOC_PROC, NBIRECV,
73 . IERROR, IERROR1, L, LEN, IDEB, INDEXI, NB,
74 . NBX, NBY, ,
75 . IX1, , IY1, IY2, IZ1, IZ2, IX, IY, IZ,
76 . REQ_RB(NSPMD), REQ_SB(NSPMD), REQ_SD(NSPMD),
77 . REQ_RD(NSPMD), REQ_SD2(NSPMD), REQ_SC(NSPMD),
78 . REQ_RC(NSPMD),
79 . IRINDEXI(NSPMD), ISINDEXI(NSPMD), NBO(NSPMD),
80 . INDEX(NSP2SORT), STATUS(MPI_STATUS_SIZE),
81 . MSGOFF,MSGOFF2,MSGOFF3,MSGOFF4
83 . bminma(6,nspmd),alpha_marge,
84 . xmaxb,ymaxb,zmaxb,xminb,yminb,zminb,
85 . aaa
86 TYPE(real_pointer), DIMENSION(NSPMD) :: BUF
87 my_real,
dimension(:),
allocatable :: sbuf,rbuf
88 DATA msgoff/2023/
89 DATA msgoff2/2024/
90 DATA msgoff3/2025/
91 DATA msgoff4/2026/
92
93 INTEGER :: P_LOC
94 INTEGER :: SEND_SIZE_BMINMA
95 INTEGER :: REQUEST_BMINMA
96 INTEGER :: RCV_SIZE_BMINMA,TOTAL_RCV_SIZE_BMINMA
97
98 INTEGER :: SEND_SIZE_CRVOX
99 INTEGER :: REQUEST_CRVOX
100 INTEGER :: RCV_SIZE_CRVOX,TOTAL_RCV_SIZE_CRVOX
101 INTEGER, DIMENSION(0:LRVOXEL,0:LRVOXEL) :: CRVOXEL_LOC
102
103 INTEGER, DIMENSION(:,:), ALLOCATABLE :: INDEX_P
104 INTEGER, DIMENSION(NSPMD) :: NB_P
105 INTEGER :: REQUEST_NBO
106
107 INTEGER, DIMENSION(NSPMD) :: SEND_SIZE_SBUF,DISPLS_SBUF
108 INTEGER :: TOTAL_SEND_SIZE,TOTAL_RCV_SIZE_RBUF
109 INTEGER, DIMENSION(NSPMD) :: RCV_SIZE_RBUF,DISPLS_RBUF
110 INTEGER :: REQUEST_SBUF
111
112
113
114
115
116
117
118
119
120
121 ALLOCATE( index_p(nsp2sort,nspmd) )
122 alpha_marge = sqrt(one +spasort)
123 loc_proc = ispmd + 1
128
129
130
131 bminma(1,loc_proc) = bminmal(1)
132 bminma(2,loc_proc) = bminmal(2)
133 bminma(3,loc_proc) = bminmal(3)
134 bminma(4,loc_proc) = bminmal(4)
135 bminma(5,loc_proc) = bminmal(5)
136 bminma(6,loc_proc) = bminmal(6)
137
138
139
140 send_size_bminma = 6
141 rcv_size_bminma = 6
142 total_rcv_size_bminma = 6*nspmd
143
144
145
147 . total_rcv_size_bminma,rcv_size_bminma,
148 . request_bminma,spmd_comm_world)
149
150
151
156
157
158
159
161 . total_rcv_size_crvox,rcv_size_crvox,
162 . request_crvox,spmd_comm_world)
163
164
165
166
167
168#if _PLMPI
169
170
171
172#else
173
174
175
176 CALL mpi_wait(request_bminma,status,ierror)
177 CALL mpi_wait(request_crvox,status,ierror)
178
179#endif
180
181
182
183
184 ideb = 1
185 nb_p(1:nspmd) = 0
186 nbo(1:nspmd) = 0
187 DO p = 1, nspmd
188 if(p==loc_proc) cycle
189 l = ideb
190 nb_p(p) = 0
191 xmaxb = bminma(1,p)
192 ymaxb = bminma(2,p)
193 zmaxb = bminma(3,p)
194 xminb = bminma(4,p)
195 yminb = bminma(5,p)
196 zminb = bminma(6,p)
197
198 DO i=1, nsp2sort
199 n=wsp2sort(i)
200 nod=kxsp(3,n)
201 aaa = spbuf(1,n)* alpha_marge
202 ix1=int(nbx*(x(1,nod)-xminb-aaa)/(xmaxb-xminb))
203 ix2=int(nbx*(x(1,nod)-xminb+aaa)/(xmaxb-xminb))
204 IF(ix1 > nbx) cycle
205 IF(ix2 < 0) cycle
206 iy1=int(nby*(x(2,nod)-yminb-aaa)/(ymaxb-yminb))
207 iy2=int(nby*(x(2,nod)-yminb+aaa)/(ymaxb-yminb))
208 IF(iy1 > nby) cycle
209 IF(iy2 < 0) cycle
210 iz1=int(nbz*(x(3,nod)-zminb-aaa)/(zmaxb-zminb))
211 iz2=int(nbz*(x(3,nod)-zminb+aaa)/(zmaxb-zminb))
212 IF(iz1 > nbz) cycle
213 IF(iz2 < 0) cycle
214
221
222
223 DO iz = iz1,iz2
224 DO iy = iy1,iy2
225 DO ix = ix1,ix2
226 IF(btest(
crvoxel(iy,iz,p),ix))
THEN
227 nb_p(p) = nb_p(p) + 1
228 index_p(nb_p(p),p) = n
229 GOTO 100
230 ENDIF
231 ENDDO
232 ENDDO
233 ENDDO
234
235 100 CONTINUE
236
237 ENDDO
238 nbo(p) = nb_p(p)
240 ENDDO
241
242
244
245
246
248 . nspmd,1,request_nbo,spmd_comm_world)
249
250
251
252 l = 0
253 DO p=1,nspmd
255 ENDDO
256 ALLOCATE(sbuf(l))
257
258 l = 0
259 DO p = 1, nspmd
260 if(p==loc_proc) cycle
261 IF (nb_p(p)>0) THEN
262 DO j = 1, nb_p(p)
263 n = index_p(j,p)
264 nod = kxsp(3,n)
265 sbuf(l+1) = n
266 sbuf(l+2) = spbuf(1,n)
267 sbuf(l+3) = x(1,nod)
268 sbuf(l+4) = x(2,nod)
269 sbuf(l+5) = x(3,nod)
270 sbuf(l+6) = kxsp(8,n)
272 END DO
273 END IF
274 END DO
275
276
277
279 DO p = 1, nspmd
280 IF(loc_proc /=p) THEN
282 ENDIF
283 ENDDO
284
285
286
289
290 IF(ALLOCATED(dks))DEALLOCATE(dks)
291 ALLOCATE(dks(
nsphs),stat=ierror1)
292 ierror = ierror1 + ierror
293
294
295 IF(ierror/=0) THEN
296 CALL ancmsg(msgid=20,anmode=aninfo)
298 END IF
300 dks = -one
301
302 ideb = 0
303 l = 0
304 DO p = 1, nspmd
305 IF(loc_proc /=p) THEN
306#include "novectorize.inc"
308 ideb = ideb + 1
309 lsphs(ideb) = sbuf(l+1)
311 ENDDO
312 ENDIF
313 ENDDO
314
315
317 l=0
318#if _PLMPI
319
320
321
322#else
323
324
325 CALL mpi_wait(request_nbo,status,ierror)
326
327#endif
328
329 DO p = 1, nspmd
330
331 IF(loc_proc/=p) THEN
333 l=l+1
334 isindexi(l)=p
336 END IF
337 END IF
338 END DO
339 nbirecv=l
340
341
342
343
344 send_size_sbuf(1:nspmd) = 0
345 displs_sbuf(1:nspmd) = 0
346 rcv_size_rbuf(1:nspmd) = 0
347 displs_rbuf(1:nspmd) = 0
348
349 displs_sbuf(1) = 0
350 send_size_sbuf(1) =
sizspt*nb_p(1)
351 total_send_size = send_size_sbuf(1)
352 DO p=2,nspmd
353 send_size_sbuf(p) =
sizspt*nb_p(p)
354 displs_sbuf(p) = displs_sbuf(p-1) + send_size_sbuf(p-1)
355 total_send_size = total_send_size + send_size_sbuf(p)
356 ENDDO
357
359 total_rcv_size_rbuf = rcv_size_rbuf(1)
360 displs_rbuf(1) = 0
361 DO p=2,nspmd
363 displs_rbuf(p) = displs_rbuf(p-1) + rcv_size_rbuf(p-1)
364 total_rcv_size_rbuf = total_rcv_size_rbuf + rcv_size_rbuf(p)
365 ENDDO
366
367
368 ierror = 0
369 IF(ALLOCATED(xsphr))DEALLOCATE(xsphr)
371 ierror = ierror1 + ierror
372
373 IF(ALLOCATED(dkr))DEALLOCATE(dkr)
374 ALLOCATE(dkr(
nsphr),stat=ierror1)
375 ierror = ierror1 + ierror
376
377 IF(ierror/=0) THEN
378 CALL ancmsg(msgid=20,anmode=aninfo)
380 END IF
381 xsphr = 0
382 dkr = -one
383
384
385
386
387 CALL spmd_ialltoallv(sbuf,xsphr,send_size_sbuf,total_send_size,displs_sbuf,
388 . total_rcv_size_rbuf,rcv_size_rbuf,displs_rbuf,
389 . request_sbuf,spmd_comm_world,nspmd)
390
391
392#if _PLMPI
393
394
395
396#else
397
398
399 CALL mpi_wait(request_sbuf,status,ierror)
400
401#endif
402
403 DEALLOCATE( sbuf )
404 DEALLOCATE( index_p )
405
406#endif
407 RETURN
subroutine mpi_wait(ireq, status, ierr)
integer, dimension(:), allocatable lsphs
integer, dimension(:), allocatable psphr
integer, dimension(:), allocatable psphs
integer, parameter sizspt
integer, dimension(0:lrvoxel, 0:lrvoxel) crvoxel
subroutine spmd_iallgather(sendbuf, recvbuf, send_size, total_rcv_size, rcv_size, request, comm)
subroutine spmd_iallgather_int(sendbuf, recvbuf, send_size, total_rcv_size, rcv_size, request, comm)
subroutine spmd_ialltoall_int(sendbuf, recvbuf, total_send_size, send_size, total_rcv_size, rcv_size, request, comm)
subroutine spmd_ialltoallv(sendbuf, recvbuf, send_size, total_send_size, sdispls, total_rcv_size, rcv_size, rdispls, request, comm, nb_proc)
subroutine ancmsg(msgid, msgtype, anmode, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, r1, r2, r3, r4, r5, r6, r7, r8, r9, c1, c2, c3, c4, c5, c6, c7, c8, c9, prmode)