mp_sum_r Subroutine

private subroutine mp_sum_r(msg, gid)

Sums a datum from all processes with result left on all processes.

MPI mapping mpi_allreduce

Arguments

Type IntentOptional Attributes Name
real(kind=real_4), intent(inout) :: msg

Datum to sum (input) and result (output)

type(mp_comm_type), intent(in) :: gid

Message passing environment identifier


Source Code

      SUBROUTINE mp_sum_r (msg, gid)
      !! Sums a datum from all processes with result left on all processes.
      !!
      !! MPI mapping
      !! mpi_allreduce

         REAL(kind=real_4), INTENT(INOUT)    :: msg
         !! Datum to sum (input) and result (output)
         TYPE(mp_comm_type), INTENT(IN)         :: gid
         !! Message passing environment identifier

         CHARACTER(LEN=*), PARAMETER :: routineN = 'mp_sum_r'

         INTEGER                     :: handle, ierr, msglen

         ierr = 0
         CALL timeset(routineN, handle)

         msglen = 1
#if defined(__parallel)
         CALL mpi_allreduce(MPI_IN_PLACE, msg, msglen, MPI_REAL, MPI_SUM, gid%handle, ierr)
         IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
         CALL add_perf(perf_id=3, msg_size=msglen*real_4_size)
#else
         MARK_USED(msg)
         MARK_USED(gid)
#endif
         CALL timestop(handle)
      END SUBROUTINE mp_sum_r