gather_owned_face_scalar Subroutine

private subroutine gather_owned_face_scalar(flow, nfaces, face_field, global_field)

Arguments

Type IntentOptional Attributes Name
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: nfaces
real(kind=rk), intent(in) :: face_field(:)
real(kind=rk), intent(out) :: global_field(:)

Source Code

   subroutine gather_owned_face_scalar(flow, nfaces, face_field, global_field)
      type(flow_mpi_t), intent(in) :: flow
      integer, intent(in) :: nfaces
      real(rk), intent(in) :: face_field(:)
      real(rk), intent(out) :: global_field(:)

      real(rk), allocatable :: local_field(:)
      integer :: i, f, ierr

      if (size(face_field) < nfaces .or. size(global_field) < nfaces) then
         call fatal_error('restart', 'face field size mismatch during restart write')
      end if

      allocate(local_field(nfaces))
      local_field = zero
      if (allocated(flow%owned_faces)) then
         do i = 1, size(flow%owned_faces)
            f = flow%owned_faces(i)
            if (f >= 1 .and. f <= nfaces) local_field(f) = face_field(f)
         end do
      end if

      call MPI_Allreduce(local_field, global_field, nfaces, MPI_DOUBLE_PRECISION, MPI_SUM, flow%comm, ierr)
      if (ierr /= MPI_SUCCESS) call fatal_error('restart', 'MPI_Allreduce failed gathering face field')
      deallocate(local_field)
   end subroutine gather_owned_face_scalar