mp_sum_partial_cm Subroutine

private subroutine mp_sum_partial_cm(msg, res, gid)

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

Arguments

Type IntentOptional Attributes Name
complex(kind=real_4), intent(in), CONTIGUOUS :: msg(:,:)

Matrix to sum (input)

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

Matrix containing result (output)

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

Message passing environment identifier


Source Code

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

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

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

         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%handle, taskid, ierr)
         IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_rank @ "//routineN)
         IF (msglen > 0) THEN
            CALL mpi_scan(msg, res, msglen, MPI_COMPLEX, MPI_SUM, gid%handle, ierr)
            IF (ierr /= 0) CALL mp_stop(ierr, "mpi_scan @ "//routineN)
         END IF
         CALL add_perf(perf_id=3, msg_size=msglen*(2*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_cm