Find on MPI rank 'toRank' MAX/MIN/SUM scalar value across MPI ranks.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | scalar_int | |||
| character(len=3), | intent(in) | :: | parOP | |||
| integer, | intent(in) | :: | toRank |
SUBROUTINE par_Reduce_scalar_int(scalar_int,parOP,toRank) ! MODULES USE MODgvec_Globals, ONLY : wp,myRank IMPLICIT NONE !-------------------------------------------------------------------------------------------------------------------------------- ! INPUT VARIABLES INTEGER, INTENT(INOUT) :: scalar_int CHARACTER(LEN=3), INTENT(IN) :: parOP INTEGER, INTENT(IN) :: toRank ! =0 by default !-------------------------------------------------------------------------------------------------------------------------------- ! LOCAL VARIABLES INTEGER :: ierr # if MPI MPI_op_TYPE :: mpiOP !================================================================================================================================ ! BODY SELECT CASE(parOP) CASE('MAX') mpiOP=MPI_MAX CASE('MIN') mpiOP=MPI_MIN CASE('SUM') mpiOP=MPI_SUM END SELECT IF (myRank.EQ.toRank) THEN CALL MPI_Reduce(MPI_IN_PLACE, scalar_int, 1, dType, mpiOP, toRank, worldComm, ierr) ELSE CALL MPI_Reduce(scalar_int, scalar_int, 1, dType, mpiOP, toRank, worldComm, ierr) END IF # endif END SUBROUTINE par_Reduce_scalar_int