Exchanges owned cell matrix values to ranks that keep them as ghosts.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(flow_mpi_t), | intent(inout) | :: | flow | |||
| real(kind=rk), | intent(inout) | :: | field(:,:) |
subroutine flow_exchange_cell_matrix(flow, field) use mod_profiler, only : profiler_start, profiler_stop type(flow_mpi_t), intent(inout) :: flow real(rk), intent(inout) :: field(:,:) integer, parameter :: cell_matrix_halo_tag = 9282 integer :: ncomp, i, j, k, nreq, ierr, offset, count, pos if (.not. allocated(flow%cell_sendbuf)) return if (flow%ncell_recv_ranks + flow%ncell_send_ranks == 0) return ncomp = size(field, 1) if (ncomp > flow%cell_halo_max_components) then call fatal_error('mpi_flow', 'cell matrix halo component count exceeds cached buffer size') end if do i = 1, flow%ncell_send_ranks offset = flow%cell_send_displs(i) count = flow%cell_send_counts(i) do j = 1, count pos = (offset + j - 1) * ncomp do k = 1, ncomp flow%cell_sendbuf(pos + k) = field(k, flow%cell_send_cells(offset + j)) end do end do end do call profiler_start('MPI_Communication') nreq = 0 do i = 1, flow%ncell_recv_ranks offset = flow%cell_recv_displs(i) * ncomp count = flow%cell_recv_counts(i) * ncomp nreq = nreq + 1 call MPI_Irecv(flow%cell_recvbuf(offset + 1), count, MPI_DOUBLE_PRECISION, & flow%cell_recv_ranks(i), cell_matrix_halo_tag, flow%comm, flow%cell_requests(nreq), ierr) call check_mpi(ierr, 'cell matrix halo irecv') end do do i = 1, flow%ncell_send_ranks offset = flow%cell_send_displs(i) * ncomp count = flow%cell_send_counts(i) * ncomp nreq = nreq + 1 call MPI_Isend(flow%cell_sendbuf(offset + 1), count, MPI_DOUBLE_PRECISION, & flow%cell_send_ranks(i), cell_matrix_halo_tag, flow%comm, flow%cell_requests(nreq), ierr) call check_mpi(ierr, 'cell matrix halo isend') end do call MPI_Waitall(nreq, flow%cell_requests(1:nreq), MPI_STATUSES_IGNORE, ierr) call check_mpi(ierr, 'cell matrix halo waitall') call profiler_stop('MPI_Communication') do i = 1, size(flow%cell_recv_cells) pos = (i - 1) * ncomp do k = 1, ncomp field(k, flow%cell_recv_cells(i)) = flow%cell_recvbuf(pos + k) end do end do end subroutine flow_exchange_cell_matrix