flow_global_dot_owned Function

public function flow_global_dot_owned(flow, a, b) result(dot)

Computes the global dot product of two vectors over owned cells.

Arguments

Type IntentOptional Attributes Name
type(flow_mpi_t), intent(in) :: flow
real(kind=rk), intent(in) :: a(:)
real(kind=rk), intent(in) :: b(:)

Return Value real(kind=rk)


Source Code

   function flow_global_dot_owned(flow, a, b) result(dot)
      use mod_profiling, only : profiler_start, profiler_stop
      type(flow_mpi_t), intent(in) :: flow
      real(rk), intent(in) :: a(:), b(:)
      real(rk) :: dot, local_dot
      integer :: c, ierr

      local_dot = 0.0_rk
      do c = flow%first_cell, flow%last_cell
         local_dot = local_dot + a(c) * b(c)
      end do

      if (flow%nprocs == 1) then
         dot = local_dot
         return
      end if

      call profiler_start('MPI_Communication')
      call MPI_Allreduce(local_dot, dot, 1, MPI_DOUBLE_PRECISION, MPI_SUM, flow%comm, ierr)
      call check_mpi(ierr, 'MPI_Allreduce flow dot')
      call profiler_stop('MPI_Communication')
   end function flow_global_dot_owned