32bit整数配列の総和Allreduceをin-placeで実行する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mpi_context), | intent(in) | :: | ctx | |||
| integer(kind=i32), | intent(inout) | :: | values(:) |
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