40 use mpi_f08,
only : mpi_test, mpi_status_ignore, mpi_status, &
41 mpi_request, mpi_isend, mpi_irecv, mpi_comm
98 type(mpi_comm),
intent(inout),
optional :: comm
99 integer,
pointer :: sp(:), rp(:)
101 if (
present(
comm))
then
107 call this%init_order(send_pe, recv_pe)
109 allocate(this%send_buf(send_pe%size()))
111 sp => send_pe%array()
112 do i = 1, send_pe%size()
113 allocate(this%send_buf(i)%data(this%send_dof(sp(i))%size()))
116 allocate(this%recv_buf(recv_pe%size()))
118 rp => recv_pe%array()
119 do i = 1, recv_pe%size()
120 allocate(this%recv_buf(i)%data(this%recv_dof(rp(i))%size()))
239 integer,
intent(in) :: n_send, n_recv
240 real(kind=
rp),
dimension(n_send),
intent(inout) :: send
241 real(kind=
rp),
dimension(n_recv),
intent(inout) :: recv
242 type(c_ptr) :: null_ptr = c_null_ptr
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
335 integer :: i, j, src, ierr
336 integer ,
pointer :: sp(:)
339 nreqs =
size(this%recv_pe)
341 do while (nreqs .gt. 0)
342 do i = 1,
size(this%recv_pe)
343 if (.not. this%recv_buf(i)%flag)
then
345 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
346 this%recv_buf(i)%status, ierr)
348 if (this%recv_buf(i)%flag)
then
358 nreqs =
size(this%send_pe)
359 do while (nreqs .gt. 0)
360 do i = 1,
size(this%send_pe)
361 if (.not. this%send_buf(i)%flag)
then
362 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
363 mpi_status_ignore, ierr)
364 if (this%send_buf(i)%flag) nreqs = nreqs - 1