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 | |
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" |
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-- Can't start until everyone is ready |
C-- write local max into array |
54 |
|
phi(1,myThid) = maxPhi |
55 |
|
|
56 |
|
C-- Can not start until everyone is ready |
57 |
_BARRIER |
_BARRIER |
58 |
|
|
59 |
C-- Max within the process first |
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 /==========================================================\ |
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" |
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-- Can't start until everyone is ready |
C-- write local max into array |
132 |
|
phi(1,myThid) = maxPhi |
133 |
|
|
134 |
|
C-- Can not start until everyone is ready |
135 |
_BARRIER |
_BARRIER |
136 |
|
|
137 |
C-- Max within the process first |
C-- Max within the process first |
155 |
phi(1,1) = maxPhi |
phi(1,1) = maxPhi |
156 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
157 |
|
|
158 |
C-- Don't 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 |
|
|
|
|
C $Id$ |
|