!======================================================================= ! RCS Header: ! Revision [$Revision: 1.8.1.1 $] Named [$Name: release#2_9_b5 $] ! Last checkin [$Date: 2001/12/06 10:13:59 $] ! Author [$Author: frpb $] !======================================================================= ! *****************************COPYRIGHT******************************* ! (c) CROWN COPYRIGHT 2001, Met Office, All Rights Reserved. ! Please refer to Copyright file in top level GCOM directory ! for further details ! *****************************COPYRIGHT******************************* #include "gc_prolog.h" SUBROUTINE GC_RMIN (LEN, NPROC, ISTAT, SMIN) ! ****************************************************************** ! * Purpose: ! * ! * Finds the real minimum across all processors and distribute ! * the result to all the processors. ! * ! * Input: ! * LEN - number of elements in message ! * NPROC - number of processors ! * SMIN - array with elements of which the elementwise minimum ! * across the nodes is to be found ! * ! * Output: ! * SMIN - array containing the minimums across the nodes ! * ISTAT - status of rsum. 0 is OK (MPI_SRC only), ! * refer to the header files for nonzero status codes ! * ! * NOTES: ! * ! ****************************************************************** IMPLICIT NONE INTEGER LEN, NPROC, ISTAT REAL SMIN(LEN) INTEGER OFFSET,TOT_LEN,PART_LEN OFFSET=0 TOT_LEN=LEN 1000 CONTINUE PART_LEN=MIN(TOT_LEN,MAX_COLL) CALL GC_RMIN_batch(PART_LEN,NPROC,ISTAT,SMIN(1+OFFSET)) OFFSET=OFFSET+PART_LEN TOT_LEN=TOT_LEN-PART_LEN IF (TOT_LEN .GT. 0) GOTO 1000 RETURN END SUBROUTINE GC_RMIN_batch (LEN, NPROC, ISTAT, SMIN) ! ****************************************************************** ! * Purpose: ! * ! * Finds the real minimum across all processors and distribute ! * the result to all the processors. ! * ! * Input: ! * LEN - number of elements in message ! * NPROC - number of processors ! * SMIN - array with elements of which the elementwise minimum ! * across the nodes is to be found ! * ! * Output: ! * SMIN - array containing the minimums across the nodes ! * ISTAT - status of rsum. 0 is OK (MPI_SRC only), ! * refer to the header files for nonzero status codes ! * ! * NOTES: ! * ! ****************************************************************** IMPLICIT NONE INTEGER LEN, NPROC, ISTAT REAL SMIN(LEN) #if defined(SHM_SRC) INCLUDE 'mpp/shmem.fh' #include "gc__shm_common.h" #include "gc__opts_common.h" #include "gc__nam_common.h" INTEGER I #else REAL REDUCE_DATA_WRK(MAX_COLL) #endif #if defined(MPI_SRC) INCLUDE 'mpif.h' INTEGER I #endif #if !defined(SERIAL_SRC) IF (LEN .GT. MAX_COLL) CALL GC__ERRLIM(0, 'RMIN', 'COLL', $ MAX_COLL, LEN) #endif #if defined(SHM_SRC) DO I = 1, LEN NAM_RWORK(I) = SMIN(I) ENDDO CALL BARRIER() #if defined(FLP_64B) CALL SHMEM_REAL8_MIN_TO_ALL(NAM_RWORK,NAM_RWORK,LEN,0,0,NPROC, & REDUCE_DATA_WRK,REDUCE_SYNC_WRK) #else CALL SHMEM_REAL4_MIN_TO_ALL(NAM_RWORK,NAM_RWORK,LEN,0,0,NPROC, & REDUCE_DATA_WRK,REDUCE_SYNC_WRK) #endif DO I = 1, LEN SMIN(I) = NAM_RWORK(I) ENDDO CALL BARRIER() #endif #if defined(MPI_SRC) DO I = 1,LEN REDUCE_DATA_WRK(I) = SMIN(I) ENDDO #if defined(FLP_64B) #if defined(_UNICOS) CALL MPI_ALLREDUCE(REDUCE_DATA_WRK, SMIN, LEN, $ MPI_REAL, MPI_MIN, MPI_COMM_WORLD, ISTAT) #else CALL MPI_ALLREDUCE(REDUCE_DATA_WRK, SMIN, LEN, $ MPI_DOUBLE_PRECISION, MPI_MIN, MPI_COMM_WORLD, ISTAT) #endif #else CALL MPI_ALLREDUCE(REDUCE_DATA_WRK, SMIN, LEN, MPI_REAL, MPI_MIN, $ MPI_COMM_WORLD, ISTAT) #endif #endif #if defined(SHM_SRC) || defined(SERIAL_SRC) ISTAT = GC__OK #endif RETURN END