Finds the location of the maximal element in a vector.
MPI mapping mpi_allreduce with the MPI_MAXLOC reduction function identifier
Invalid data types This routine is invalid for (int_8) data!
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real_8), | intent(inout), | CONTIGUOUS | :: | msg(:) |
Find location of maximum element among these data (input). |
|
type(mp_comm_type), | intent(in) | :: | gid |
Message passing environment identifier |
SUBROUTINE mp_maxloc_dv(msg, gid) !! Finds the location of the maximal element in a vector. !! !! MPI mapping !! mpi_allreduce with the MPI_MAXLOC reduction function identifier !! !! Invalid data types !! This routine is invalid for (int_8) data! REAL(kind=real_8), CONTIGUOUS, INTENT(INOUT) :: msg(:) !! Find location of maximum element among these data (input). TYPE(mp_comm_type), INTENT(IN) :: gid !! Message passing environment identifier CHARACTER(LEN=*), PARAMETER :: routineN = 'mp_maxloc_dv' INTEGER :: handle, ierr #if defined(__parallel) INTEGER :: msglen REAL(kind=real_8), ALLOCATABLE :: res(:) #endif ierr = 0 IF ("d" .EQ. "l" .AND. real_8 .EQ. int_8) THEN DBCSR_ABORT("Maximal location not available with long integers @ "//routineN) END IF CALL timeset(routineN, handle) #if defined(__parallel) msglen = SIZE(msg) ALLOCATE (res(1:msglen)) CALL mpi_allreduce(msg, res, msglen/2, MPI_2DOUBLE_PRECISION, MPI_MAXLOC, gid%handle, ierr) IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN) msg = res DEALLOCATE (res) CALL add_perf(perf_id=3, msg_size=msglen*real_8_size) #else MARK_USED(msg) MARK_USED(gid) #endif CALL timestop(handle) END SUBROUTINE mp_maxloc_dv