mp_sum_partial_rm Subroutine

private subroutine mp_sum_partial_rm(msg, res, gid)

Partial sum of data from all processes with result on each process.

Arguments

TypeIntentOptionalAttributesName
real(kind=real_4), intent(in), CONTIGUOUS:: msg(:,:)

Matrix to sum (input)

real(kind=real_4), intent(out), CONTIGUOUS:: res(:,:)

Matrix containing result (output)

integer, intent(in) :: gid

Message passing environment identifier


Contents

Source Code


Source Code

      SUBROUTINE mp_sum_partial_rm(msg, res, gid)
      !! Partial sum of data from all processes with result on each process.

         REAL(kind=real_4), CONTIGUOUS, INTENT(IN)  :: msg(:, :)
         !! Matrix to sum (input)
         REAL(kind=real_4), CONTIGUOUS, INTENT(OUT) :: res(:, :)
         !! Matrix containing result (output)
         INTEGER, INTENT(IN)                :: gid
         !! Message passing environment identifier

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

         INTEGER                            :: handle, ierr, msglen
#if defined(__parallel)
         INTEGER                            :: taskid
#endif

         ierr = 0
         CALL timeset(routineN, handle)

         msglen = SIZE(msg)
#if defined(__parallel)
         CALL mpi_comm_rank(gid, taskid, ierr)
         IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_rank @ "//routineN)
         IF (msglen > 0) THEN
            CALL mpi_scan(msg, res, msglen, MPI_REAL, MPI_SUM, gid, ierr)
            IF (ierr /= 0) CALL mp_stop(ierr, "mpi_scan @ "//routineN)
         END IF
         CALL add_perf(perf_id=3, msg_size=msglen*real_4_size)
         ! perf_id is same as for other summation routines
#else
         res = msg
         MARK_USED(gid)
#endif
         CALL timestop(handle)
      END SUBROUTINE mp_sum_partial_rm