/[MITgcm]/MITgcm/eesupp/src/global_max.F
ViewVC logotype

Diff of /MITgcm/eesupp/src/global_max.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5 by adcroft, Mon Mar 22 17:37:43 1999 UTC revision 1.6 by adcroft, Tue May 18 17:35:23 1999 UTC
# Line 9  C      o global_max_r8 Line 9  C      o global_max_r8
9    
10  CStartOfInterface  CStartOfInterface
11        SUBROUTINE GLOBAL_MAX_R4(        SUBROUTINE GLOBAL_MAX_R4(
12       I                       phi,       U                       maxPhi,
      O                       maxPhi,  
13       I                       myThid )       I                       myThid )
14  C     /==========================================================\  C     /==========================================================\
15  C     | SUBROUTINE GLOBAL_MAX_R4                                 |  C     | SUBROUTINE GLOBAL_MAX_R4                                 |
# Line 26  C     | The same thread also does the in Line 25  C     | The same thread also does the in
25  C     | example with MPI and then writes the result into a shared|  C     | example with MPI and then writes the result into a shared|
26  C     | location. All threads wait until the max is avaiailable. |  C     | location. All threads wait until the max is avaiailable. |
27  C     \==========================================================/  C     \==========================================================/
28          IMPLICIT NONE
29    
30  C     == Global data ==  C     == Global data ==
31  #include "SIZE.h"  #include "SIZE.h"
# Line 33  C     == Global data == Line 33  C     == Global data ==
33  #include "EESUPPORT.h"  #include "EESUPPORT.h"
34    
35  C     == Routine arguments ==  C     == Routine arguments ==
 C     phi    - Array to be maxed.  
36  C     maxPhi - Result of max.  C     maxPhi - Result of max.
37  C     myThid - My thread id.  C     myThid - My thread id.
       Real*4 phi(lShare4,MAX_NO_THREADS)  
38        Real*4 maxPhi        Real*4 maxPhi
39        INTEGER myThid        INTEGER myThid
40  CEndOfInterface  CEndOfInterface
41    
42  C     == Local variables ==  C     == Local variables ==
43    C     phi    - Array to be maxed.
44  C     I      - Loop counters  C     I      - Loop counters
45  C     mpiRC  - MPI return code  C     mpiRC  - MPI return code
46          Real*4 phi(lShare4,MAX_NO_THREADS)
47        INTEGER I        INTEGER I
48        Real*4  tmp        Real*4  tmp
49  #ifdef   ALLOW_USE_MPI  #ifdef   ALLOW_USE_MPI
50        INTEGER mpiRC        INTEGER mpiRC
51  #endif /* ALLOW_USE_MPI */  #endif /* ALLOW_USE_MPI */
52    
53    C--   write local max into array
54          phi(1,myThid) = maxPhi
55    
56  C--   Can not start until everyone is ready  C--   Can not start until everyone is ready
57        _BARRIER        _BARRIER
58    
# Line 65  C--   Max within the process first Line 68  C--   Max within the process first
68         IF ( usingMPI ) THEN         IF ( usingMPI ) THEN
69  #endif  #endif
70          CALL MPI_Allreduce(tmp,maxPhi,1,MPI_REAL,MPI_MAX,          CALL MPI_Allreduce(tmp,maxPhi,1,MPI_REAL,MPI_MAX,
71       &                   MPI_COMM_MODEL,mpiRC)       &                   MPI_COMM_WORLD,mpiRC)
72  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
73         ENDIF         ENDIF
74  #endif  #endif
# Line 74  C--   Max within the process first Line 77  C--   Max within the process first
77        _END_MASTER( myThid )        _END_MASTER( myThid )
78  C--  C--
79        _BARRIER        _BARRIER
80  C  
81    C--   set result for every process
82          maxPhi = phi(1,1)
83    
84        RETURN        RETURN
85        END        END
86                
87    
88  CStartOfInterface  CStartOfInterface
89        SUBROUTINE GLOBAL_MAX_R8(        SUBROUTINE GLOBAL_MAX_R8(
      I                       phi,  
90       O                       maxPhi,       O                       maxPhi,
91       I                       myThid )       I                       myThid )
92  C     /==========================================================\  C     /==========================================================\
# Line 98  C     | The same thread also does the in Line 103  C     | The same thread also does the in
103  C     | example with MPI and then writes the result into a shared|  C     | example with MPI and then writes the result into a shared|
104  C     | location. All threads wait until the max is avaiailable. |  C     | location. All threads wait until the max is avaiailable. |
105  C     \==========================================================/  C     \==========================================================/
106          IMPLICIT NONE
107    
108  C     === Global data ===  C     === Global data ===
109  #include "SIZE.h"  #include "SIZE.h"
# Line 105  C     === Global data === Line 111  C     === Global data ===
111  #include "EESUPPORT.h"  #include "EESUPPORT.h"
112    
113  C     === Routine arguments ===  C     === Routine arguments ===
 C     phi    - Array to be maxed.  
114  C     maxPhi - Result of max.  C     maxPhi - Result of max.
115  C     myThid - My thread id.  C     myThid - My thread id.
       Real*8 phi(lShare8,MAX_NO_THREADS)  
116        Real*8 maxPhi        Real*8 maxPhi
117        INTEGER myThid        INTEGER myThid
118  CEndOfInterface  CEndOfInterface
119    
120  C     === Local variables ===  C     === Local variables ===
121    C     phi    - Array to be maxed.
122  C     I      - Loop counters  C     I      - Loop counters
123  C     mpiRC  - MPI return code  C     mpiRC  - MPI return code
124          Real*8 phi(lShare8,MAX_NO_THREADS)
125        INTEGER I        INTEGER I
126        Real*8  tmp        Real*8  tmp
127  #ifdef   ALLOW_USE_MPI  #ifdef   ALLOW_USE_MPI
128        INTEGER mpiRC        INTEGER mpiRC
129  #endif   /* ALLOW_USE_MPI */  #endif   /* ALLOW_USE_MPI */
130    
131    C--   write local max into array
132          phi(1,myThid) = maxPhi
133    
134  C--   Can not start until everyone is ready  C--   Can not start until everyone is ready
135        _BARRIER        _BARRIER
136    
# Line 137  C--   Max within the process first Line 146  C--   Max within the process first
146         IF ( usingMPI ) THEN         IF ( usingMPI ) THEN
147  #endif  #endif
148          CALL MPI_Allreduce(tmp,maxPhi,1,MPI_DOUBLE_PRECISION,MPI_MAX,          CALL MPI_Allreduce(tmp,maxPhi,1,MPI_DOUBLE_PRECISION,MPI_MAX,
149       &                   MPI_COMM_MODEL,mpiRC)       &                   MPI_COMM_WORLD,mpiRC)
150  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
151         ENDIF         ENDIF
152  #endif  #endif
# Line 148  C--     Write solution to place where al Line 157  C--     Write solution to place where al
157    
158  C--   Do not leave until we are sure that the max is done  C--   Do not leave until we are sure that the max is done
159        _BARRIER        _BARRIER
160  C  
161    C--   set result for every process
162          maxPhi = phi(1,1)
163    
164        RETURN        RETURN
165        END        END

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.22