mpi_allreduce_sum_i32_array Subroutine

public subroutine mpi_allreduce_sum_i32_array(ctx, values)

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

Arguments

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

Called by

proc~~mpi_allreduce_sum_i32_array~~CalledByGraph proc~mpi_allreduce_sum_i32_array mpi_allreduce_sum_i32_array proc~perf_write_outputs perf_write_outputs proc~perf_write_outputs->proc~mpi_allreduce_sum_i32_array program~main main program~main->proc~perf_write_outputs

Source Code

  subroutine mpi_allreduce_sum_i32_array(ctx, values)
    type(mpi_context), intent(in) :: ctx
    integer(i32), intent(inout) :: values(:)
#ifdef USE_MPI
    include 'mpif.h'
    integer, allocatable :: sendbuf(:), recvbuf(:)
    integer :: ierr

    if (.not. ctx%enabled) return
    allocate (sendbuf(size(values)), recvbuf(size(values)))
    sendbuf = int(values, kind=kind(0))
    call MPI_Allreduce(sendbuf, recvbuf, size(values), MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr)
    values = int(recvbuf, kind=i32)
#endif
  end subroutine mpi_allreduce_sum_i32_array