mpi_allreduce_sum_i64_array Subroutine

public subroutine mpi_allreduce_sum_i64_array(ctx, values)

64bit整数配列の総和Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i64), intent(inout) :: values(:)

Source Code

  subroutine mpi_allreduce_sum_i64_array(ctx, values)
    type(mpi_context), intent(in) :: ctx
    integer(i64), intent(inout) :: values(:)
#ifdef USE_MPI
    integer(i64), allocatable :: recvbuf(:)
    integer :: ierr

    if (.not. ctx%enabled) return
    allocate (recvbuf(size(values)))
    call MPI_Allreduce(values, recvbuf, size(values), MPI_INTEGER8, MPI_SUM, MPI_COMM_WORLD, ierr)
    values = recvbuf
#endif
  end subroutine mpi_allreduce_sum_i64_array