flow_exchange_face_scalar Subroutine

public subroutine flow_exchange_face_scalar(flow, face_field)

Exchanges owner-computed face scalar values to ranks owning the neighbor cell.

Arguments

Type IntentOptional Attributes Name
type(flow_mpi_t), intent(inout) :: flow
real(kind=rk), intent(inout) :: face_field(:)

Source Code

   subroutine flow_exchange_face_scalar(flow, face_field)
      use mod_profiling, only : profiler_start, profiler_stop
      type(flow_mpi_t), intent(inout) :: flow
      real(rk), intent(inout) :: face_field(:)
      integer, parameter :: face_halo_tag = 9283
      integer :: i, j, nreq, ierr, offset, count

      if (.not. allocated(flow%face_sendbuf)) return
      if (flow%nface_recv_ranks + flow%nface_send_ranks == 0) return

      do i = 1, flow%nface_send_ranks
         offset = flow%face_send_displs(i)
         count = flow%face_send_counts(i)
         do j = 1, count
            flow%face_sendbuf(offset + j) = face_field(flow%face_send_faces(offset + j))
         end do
      end do

      call profiler_start('MPI_Communication')
      nreq = 0
      do i = 1, flow%nface_recv_ranks
         offset = flow%face_recv_displs(i)
         count = flow%face_recv_counts(i)
         nreq = nreq + 1
         call MPI_Irecv(flow%face_recvbuf(offset + 1), count, MPI_DOUBLE_PRECISION, &
                        flow%face_recv_ranks(i), face_halo_tag, flow%comm, flow%face_requests(nreq), ierr)
         call check_mpi(ierr, 'face halo irecv')
      end do
      do i = 1, flow%nface_send_ranks
         offset = flow%face_send_displs(i)
         count = flow%face_send_counts(i)
         nreq = nreq + 1
         call MPI_Isend(flow%face_sendbuf(offset + 1), count, MPI_DOUBLE_PRECISION, &
                        flow%face_send_ranks(i), face_halo_tag, flow%comm, flow%face_requests(nreq), ierr)
         call check_mpi(ierr, 'face halo isend')
      end do
      call MPI_Waitall(nreq, flow%face_requests(1:nreq), MPI_STATUSES_IGNORE, ierr)
      call check_mpi(ierr, 'face halo waitall')
      call profiler_stop('MPI_Communication')

      do i = 1, size(flow%face_recv_faces)
         face_field(flow%face_recv_faces(i)) = flow%face_recvbuf(i)
      end do
   end subroutine flow_exchange_face_scalar