--- MITgcm/eesupp/src/global_max.F 1999/03/22 17:37:43 1.5 +++ MITgcm/eesupp/src/global_max.F 1999/05/18 17:35:23 1.6 @@ -1,4 +1,4 @@ -C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/eesupp/src/global_max.F,v 1.5 1999/03/22 17:37:43 adcroft Exp $ +C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/eesupp/src/global_max.F,v 1.6 1999/05/18 17:35:23 adcroft Exp $ C-- File global_max.F: Routines that perform global max reduction on an array C of thread values. @@ -9,8 +9,7 @@ CStartOfInterface SUBROUTINE GLOBAL_MAX_R4( - I phi, - O maxPhi, + U maxPhi, I myThid ) C /==========================================================\ C | SUBROUTINE GLOBAL_MAX_R4 | @@ -26,6 +25,7 @@ C | example with MPI and then writes the result into a shared| C | location. All threads wait until the max is avaiailable. | C \==========================================================/ + IMPLICIT NONE C == Global data == #include "SIZE.h" @@ -33,23 +33,26 @@ #include "EESUPPORT.h" C == Routine arguments == -C phi - Array to be maxed. C maxPhi - Result of max. C myThid - My thread id. - Real*4 phi(lShare4,MAX_NO_THREADS) Real*4 maxPhi INTEGER myThid CEndOfInterface C == Local variables == +C phi - Array to be maxed. C I - Loop counters C mpiRC - MPI return code + Real*4 phi(lShare4,MAX_NO_THREADS) INTEGER I Real*4 tmp #ifdef ALLOW_USE_MPI INTEGER mpiRC #endif /* ALLOW_USE_MPI */ +C-- write local max into array + phi(1,myThid) = maxPhi + C-- Can not start until everyone is ready _BARRIER @@ -65,7 +68,7 @@ IF ( usingMPI ) THEN #endif CALL MPI_Allreduce(tmp,maxPhi,1,MPI_REAL,MPI_MAX, - & MPI_COMM_MODEL,mpiRC) + & MPI_COMM_WORLD,mpiRC) #ifndef ALWAYS_USE_MPI ENDIF #endif @@ -74,14 +77,16 @@ _END_MASTER( myThid ) C-- _BARRIER -C + +C-- set result for every process + maxPhi = phi(1,1) + RETURN END CStartOfInterface SUBROUTINE GLOBAL_MAX_R8( - I phi, O maxPhi, I myThid ) C /==========================================================\ @@ -98,6 +103,7 @@ C | example with MPI and then writes the result into a shared| C | location. All threads wait until the max is avaiailable. | C \==========================================================/ + IMPLICIT NONE C === Global data === #include "SIZE.h" @@ -105,23 +111,26 @@ #include "EESUPPORT.h" C === Routine arguments === -C phi - Array to be maxed. C maxPhi - Result of max. C myThid - My thread id. - Real*8 phi(lShare8,MAX_NO_THREADS) Real*8 maxPhi INTEGER myThid CEndOfInterface C === Local variables === +C phi - Array to be maxed. C I - Loop counters C mpiRC - MPI return code + Real*8 phi(lShare8,MAX_NO_THREADS) INTEGER I Real*8 tmp #ifdef ALLOW_USE_MPI INTEGER mpiRC #endif /* ALLOW_USE_MPI */ +C-- write local max into array + phi(1,myThid) = maxPhi + C-- Can not start until everyone is ready _BARRIER @@ -137,7 +146,7 @@ IF ( usingMPI ) THEN #endif CALL MPI_Allreduce(tmp,maxPhi,1,MPI_DOUBLE_PRECISION,MPI_MAX, - & MPI_COMM_MODEL,mpiRC) + & MPI_COMM_WORLD,mpiRC) #ifndef ALWAYS_USE_MPI ENDIF #endif @@ -148,6 +157,9 @@ C-- Do not leave until we are sure that the max is done _BARRIER -C + +C-- set result for every process + maxPhi = phi(1,1) + RETURN END