Reduce real data to root node
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(inout) | :: | array | |||
| integer, | intent(in) | :: | size | |||
| character(len=*), | intent(in) | :: | op | |||
| type(w90_error_type), | intent(out), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm |
subroutine comms_no_sync_reduce_real(array, size, op, error, comm) !! Reduce real data to root node implicit none real(kind=dp), intent(inout) :: array integer, intent(in) :: size character(len=*), intent(in) :: op type(w90_comm_type), intent(in) :: comm type(w90_error_type), allocatable, intent(out) :: error #ifdef W90_MPI integer :: ierr integer :: rank rank = mpirank(comm) select case (op) case ('SUM') if (rank == root_id) then call mpi_reduce(MPI_IN_PLACE, array, size, MPI_DOUBLE_PRECISION, MPI_SUM, root_id, & comm%comm, ierr) else call mpi_reduce(array, array, size, MPI_DOUBLE_PRECISION, MPI_SUM, root_id, comm%comm, & ierr) end if case ('PRD') if (rank == root_id) then call mpi_reduce(MPI_IN_PLACE, array, size, MPI_DOUBLE_PRECISION, MPI_PROD, root_id, & comm%comm, ierr) else call mpi_reduce(array, array, size, MPI_DOUBLE_PRECISION, MPI_PROD, root_id, comm%comm, & ierr) end if case ('MIN') if (rank == root_id) then call mpi_reduce(MPI_IN_PLACE, array, size, MPI_DOUBLE_PRECISION, MPI_MIN, root_id, & comm%comm, ierr) else call mpi_reduce(array, array, size, MPI_DOUBLE_PRECISION, MPI_MIN, root_id, comm%comm, & ierr) end if case ('MAX') if (rank == root_id) then call mpi_reduce(MPI_IN_PLACE, array, size, MPI_DOUBLE_PRECISION, MPI_MAX, root_id, & comm%comm, ierr) else call mpi_reduce(array, array, size, MPI_DOUBLE_PRECISION, MPI_MAX, root_id, comm%comm, & ierr) end if case default call set_base_error(error, 'Unknown operation in comms_reduce_real', code_mpi) return end select if (ierr .ne. MPI_SUCCESS) then call set_base_error(error, 'Error in comms_reduce_real', code_mpi) return end if #endif end subroutine comms_no_sync_reduce_real