40 use mpi_f08,
only : mpi_test, mpi_status_ignore, mpi_status, &
41 mpi_request, mpi_isend, mpi_irecv, mpi_comm
99 type(mpi_comm),
intent(inout),
optional :: comm
100 integer,
pointer :: sp(:), rp(:)
102 if (
present(
comm))
then
108 call this%init_order(send_pe, recv_pe)
110 allocate(this%send_buf(send_pe%size()))
112 sp => send_pe%array()
113 do i = 1, send_pe%size()
114 allocate(this%send_buf(i)%data(this%send_dof(sp(i))%size()))
117 allocate(this%recv_buf(recv_pe%size()))
119 rp => recv_pe%array()
120 do i = 1, recv_pe%size()
121 allocate(this%recv_buf(i)%data(this%recv_dof(rp(i))%size()))
240 integer,
intent(in) :: n_send, n_recv
241 real(kind=
rp),
dimension(n_send),
intent(inout) :: send
242 real(kind=
rp),
dimension(n_recv),
intent(inout) :: recv
243 integer :: i, j, ierr, src, dst, thrdid
244 integer,
pointer :: sp(:)
253 do i = 1,
size(this%recv_pe)
259 associate(recv_data => this%recv_buf(i)%data)
260 call mpi_irecv(recv_data,
size(recv_data), &
262 this%comm, this%recv_buf(i)%request, ierr)
264 this%recv_buf(i)%flag = .false.
270 do i = 1,
size(this%send_pe)
271 dst = this%send_pe(i)
274 sp => this%send_dof(dst)%array()
275 do concurrent(j = 1:this%send_dof(dst)%size())
276 this%send_buf(i)%data(j) = send(
sp(j))
281 associate(send_data => this%send_buf(i)%data)
282 call mpi_isend(send_data, this%send_dof(dst)%size(), &
284 this%comm, this%send_buf(i)%request, ierr)
286 this%send_buf(i)%flag = .false.
293 nreqs =
size(this%recv_pe)
295 do while (nreqs .gt. 0)
296 do i = 1,
size(this%recv_pe)
297 if (.not. this%recv_buf(i)%flag)
then
299 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
300 this%recv_buf(i)%status, ierr)
302 if (this%recv_buf(i)%flag)
then
306 src = this%recv_pe(i)
307 sp => this%recv_dof(src)%array()
309 do concurrent(j = 1:this%recv_dof(src)%size())
310 recv(sp(j)) = this%recv_buf(i)%data(j)
319 nreqs =
size(this%send_pe)
320 do while (nreqs .gt. 0)
321 do i = 1,
size(this%send_pe)
322 if (.not. this%send_buf(i)%flag)
then
323 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
324 mpi_status_ignore, ierr)
325 if (this%send_buf(i)%flag) nreqs = nreqs - 1
338 nreqs =
size(this%recv_pe)
340 do while (nreqs .gt. 0)
341 do i = 1,
size(this%recv_pe)
342 if (.not. this%recv_buf(i)%flag)
then
344 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
345 this%recv_buf(i)%status, ierr)
347 if (this%recv_buf(i)%flag)
then
357 nreqs =
size(this%send_pe)
358 do while (nreqs .gt. 0)
359 do i = 1,
size(this%send_pe)
360 if (.not. this%send_buf(i)%flag)
then
361 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
362 mpi_status_ignore, ierr)
363 if (this%send_buf(i)%flag) nreqs = nreqs - 1