/[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.7 by cnh, Sun Feb 4 14:38:43 2001 UTC revision 1.8 by adcroft, Tue May 29 14:01:36 2001 UTC
# Line 32  C     == Global data == Line 32  C     == Global data ==
32  #include "SIZE.h"  #include "SIZE.h"
33  #include "EEPARAMS.h"  #include "EEPARAMS.h"
34  #include "EESUPPORT.h"  #include "EESUPPORT.h"
35    #include "GLOBAL_MAX.h"
36    
37  C     == Routine arguments ==  C     == Routine arguments ==
38  C     maxPhi - Result of max.  C     maxPhi - Result of max.
# Line 41  C     myThid - My thread id. Line 42  C     myThid - My thread id.
42  CEndOfInterface  CEndOfInterface
43    
44  C     == Local variables ==  C     == Local variables ==
 C     phi    - Array to be maxed.  
45  C     I      - Loop counters  C     I      - Loop counters
46  C     mpiRC  - MPI return code  C     mpiRC  - MPI return code
       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          CALL BAR2( myThid )
54  C--   write local max into array  C--   write local max into array
55        phi(1,myThid) = maxPhi        phiGMRS(1,myThid) = maxPhi
56    
57  C--   Can not start until everyone is ready  C--   Can not start until everyone is ready
58        _BARRIER        CALL BAR2( myThid )
59    
60  C--   Max within the process first  C--   Max within the process first
61        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
62         tmp = phi(1,1)         tmp = phiGMRS(1,1)
63         DO I=2,nThreads         DO I=2,nThreads
64          tmp = MAX(tmp,phi(1,I))          tmp = MAX(tmp,phiGMRS(1,I))
65         ENDDO         ENDDO
66         maxPhi = tmp         maxPhi = tmp
67  #ifdef  ALLOW_USE_MPI  #ifdef  ALLOW_USE_MPI
# Line 74  C--   Max within the process first Line 74  C--   Max within the process first
74         ENDIF         ENDIF
75  #endif  #endif
76  #endif /*  ALLOW_USE_MPI */  #endif /*  ALLOW_USE_MPI */
77         phi(1,1) = maxPhi         phiGMRS(1,1) = maxPhi
78        _END_MASTER( myThid )        _END_MASTER( myThid )
79  C--  C--
80        _BARRIER        CALL BAR2( myThid )
81    
82  C--   set result for every process  C--   set result for every process
83        maxPhi = phi(1,1)        maxPhi = phiGMRS(1,1)
84          CALL BAR2( myThid )
85    
86        RETURN        RETURN
87        END        END
# Line 110  C     === Global data === Line 111  C     === Global data ===
111  #include "SIZE.h"  #include "SIZE.h"
112  #include "EEPARAMS.h"  #include "EEPARAMS.h"
113  #include "EESUPPORT.h"  #include "EESUPPORT.h"
114    #include "GLOBAL_MAX.h"
115    
116  C     === Routine arguments ===  C     === Routine arguments ===
117  C     maxPhi - Result of max.  C     maxPhi - Result of max.
# Line 119  C     myThid - My thread id. Line 121  C     myThid - My thread id.
121  CEndOfInterface  CEndOfInterface
122    
123  C     === Local variables ===  C     === Local variables ===
 C     phi    - Array to be maxed.  
124  C     I      - Loop counters  C     I      - Loop counters
125  C     mpiRC  - MPI return code  C     mpiRC  - MPI return code
       Real*8 phi(lShare8,MAX_NO_THREADS)  
126        INTEGER I        INTEGER I
127        Real*8  tmp        Real*8  tmp
128  #ifdef   ALLOW_USE_MPI  #ifdef   ALLOW_USE_MPI
129        INTEGER mpiRC        INTEGER mpiRC
130  #endif   /* ALLOW_USE_MPI */  #endif   /* ALLOW_USE_MPI */
131    
132          CALL BAR2( myThid )
133  C--   write local max into array  C--   write local max into array
134        phi(1,myThid) = maxPhi        phiGMRL(1,myThid) = maxPhi
135    
136  C--   Can not start until everyone is ready  C--   Can not start until everyone is ready
137        _BARRIER        CALL BAR2( myThid )
138    
139  C--   Max within the process first  C--   Max within the process first
140        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
141         tmp = phi(1,1)         tmp = phiGMRL(1,1)
142         DO I=2,nThreads         DO I=2,nThreads
143          tmp = MAX(tmp,phi(1,I))          tmp = MAX(tmp,phiGMRL(1,I))
144         ENDDO         ENDDO
145         maxPhi = tmp         maxPhi = tmp
146  #ifdef  ALLOW_USE_MPI  #ifdef  ALLOW_USE_MPI
# Line 153  C--   Max within the process first Line 154  C--   Max within the process first
154  #endif  #endif
155  #endif /*  ALLOW_USE_MPI */  #endif /*  ALLOW_USE_MPI */
156  C--     Write solution to place where all threads can see it  C--     Write solution to place where all threads can see it
157          phi(1,1) = maxPhi          phiGMRL(1,1) = maxPhi
158        _END_MASTER( myThid )        _END_MASTER( myThid )
159    
160  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
161        _BARRIER        CALL BAR2( myThid )
162    
163  C--   set result for every process  C--   set result for every process
164        maxPhi = phi(1,1)        maxPhi = phiGMRL(1,1)
165          CALL BAR2( myThid )
166    
167        RETURN        RETURN
168        END        END

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22