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 type(c_ptr) :: null_ptr = c_null_ptr
244 integer :: i, j, ierr, src, dst, thrdid
245 integer,
pointer ::
sp(:)
254 do i = 1,
size(this%recv_pe)
260 associate(recv_data => this%recv_buf(i)%data)
261 call mpi_irecv(recv_data,
size(recv_data), &
263 this%comm, this%recv_buf(i)%request, ierr)
265 this%recv_buf(i)%flag = .false.
271 do i = 1,
size(this%send_pe)
272 dst = this%send_pe(i)
275 sp => this%send_dof(dst)%array()
276 do concurrent(j = 1:this%send_dof(dst)%size())
277 this%send_buf(i)%data(j) = send(
sp(j))
282 associate(send_data => this%send_buf(i)%data)
283 call mpi_isend(send_data, this%send_dof(dst)%size(), &
285 this%comm, this%send_buf(i)%request, ierr)
287 this%send_buf(i)%flag = .false.
294 nreqs =
size(this%recv_pe)
296 do while (nreqs .gt. 0)
297 do i = 1,
size(this%recv_pe)
298 if (.not. this%recv_buf(i)%flag)
then
300 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
301 this%recv_buf(i)%status, ierr)
303 if (this%recv_buf(i)%flag)
then
307 src = this%recv_pe(i)
308 sp => this%recv_dof(src)%array()
310 do concurrent(j = 1:this%recv_dof(src)%size())
311 recv(sp(j)) = this%recv_buf(i)%data(j)
320 nreqs =
size(this%send_pe)
321 do while (nreqs .gt. 0)
322 do i = 1,
size(this%send_pe)
323 if (.not. this%send_buf(i)%flag)
then
324 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
325 mpi_status_ignore, ierr)
326 if (this%send_buf(i)%flag) nreqs = nreqs - 1
336 integer :: i, j, src, ierr
337 integer ,
pointer :: sp(:)
340 nreqs =
size(this%recv_pe)
342 do while (nreqs .gt. 0)
343 do i = 1,
size(this%recv_pe)
344 if (.not. this%recv_buf(i)%flag)
then
346 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
347 this%recv_buf(i)%status, ierr)
349 if (this%recv_buf(i)%flag)
then
359 nreqs =
size(this%send_pe)
360 do while (nreqs .gt. 0)
361 do i = 1,
size(this%send_pe)
362 if (.not. this%send_buf(i)%flag)
then
363 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
364 mpi_status_ignore, ierr)
365 if (this%send_buf(i)%flag) nreqs = nreqs - 1