/[MITgcm]/MITgcm/pkg/autodiff/global_max_ad.F
ViewVC logotype

Contents of /MITgcm/pkg/autodiff/global_max_ad.F

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


Revision 1.2 - (show annotations) (download)
Sat Jul 13 03:30:30 2002 UTC (21 years, 10 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint57m_post, checkpoint52l_pre, hrcube4, hrcube5, checkpoint46l_post, checkpoint57g_pre, checkpoint46g_pre, checkpoint47c_post, checkpoint50c_post, checkpoint57s_post, checkpoint58b_post, checkpoint57b_post, checkpoint46f_post, checkpoint52d_pre, checkpoint57g_post, checkpoint48e_post, checkpoint56b_post, checkpoint50c_pre, checkpoint57y_post, checkpoint46b_post, checkpoint52j_pre, checkpoint51o_pre, checkpoint54d_post, checkpoint54e_post, checkpoint51l_post, checkpoint48i_post, checkpoint57r_post, checkpoint46l_pre, checkpoint57d_post, checkpoint57i_post, checkpoint52l_post, checkpoint52k_post, checkpoint59, checkpoint58, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint51, checkpoint50, checkpoint53, checkpoint52, checkpoint50d_post, checkpoint58f_post, checkpoint52f_post, checkpoint57n_post, checkpoint58d_post, checkpoint58a_post, checkpoint50b_pre, checkpoint57z_post, checkpoint54f_post, checkpoint51f_post, checkpoint58y_post, checkpoint48b_post, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint51t_post, checkpoint58t_post, c49_autodiff, checkpoint51n_post, checkpoint55i_post, checkpoint58m_post, checkpoint57l_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint51s_post, checkpoint47a_post, checkpoint57t_post, checkpoint55c_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, checkpoint52e_pre, checkpoint57v_post, checkpoint57f_post, checkpoint52e_post, checkpoint51n_pre, checkpoint47d_post, checkpoint53d_post, checkpoint46d_pre, checkpoint60, checkpoint57a_post, checkpoint48d_post, checkpoint57h_pre, checkpoint48f_post, checkpoint52b_pre, checkpoint54b_post, checkpoint46j_pre, checkpoint58w_post, checkpoint57h_post, checkpoint51l_pre, checkpoint52m_post, checkpoint57y_pre, checkpoint55g_post, checkpoint48h_post, checkpoint51q_post, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint52b_post, checkpoint52c_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, checkpoint58o_post, checkpoint48a_post, checkpoint57c_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint58p_post, checkpoint58q_post, checkpoint52f_pre, checkpoint55d_post, checkpoint58e_post, checkpoint47j_post, checkpoint54a_pre, checkpoint53c_post, checkpoint55d_pre, checkpoint57c_pre, checkpoint58r_post, checkpoint55j_post, branch-exfmods-tag, branchpoint-genmake2, checkpoint54a_post, checkpoint46e_pre, checkpoint55h_post, checkpoint58n_post, checkpoint51r_post, checkpoint48c_post, checkpoint46b_pre, checkpoint51i_post, checkpoint57e_post, checkpoint55b_post, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint53a_post, checkpoint46, checkpoint47b_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint55f_post, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint46h_pre, checkpoint52d_post, checkpoint53g_post, checkpoint46m_post, checkpoint57p_post, checkpint57u_post, checkpoint46a_pre, checkpoint50g_post, checkpoint57q_post, eckpoint57e_pre, checkpoint46g_post, checkpoint58k_post, checkpoint52a_pre, checkpoint58v_post, checkpoint50h_post, checkpoint52i_post, checkpoint50e_pre, checkpoint50i_post, checkpoint51i_pre, checkpoint52h_pre, checkpoint56a_post, checkpoint58l_post, checkpoint53f_post, checkpoint57h_done, checkpoint52j_post, checkpoint47f_post, checkpoint50e_post, checkpoint46i_post, checkpoint57j_post, checkpoint57f_pre, checkpoint46c_post, checkpoint58g_post, branch-netcdf, checkpoint50d_pre, checkpoint58x_post, checkpoint52n_post, checkpoint53b_pre, checkpoint46e_post, checkpoint59j, checkpoint58h_post, checkpoint56c_post, checkpoint58j_post, checkpoint51e_post, checkpoint57a_pre, checkpoint55a_post, checkpoint47, checkpoint48, checkpoint49, checkpoint57o_post, checkpoint46h_post, checkpoint51o_post, checkpoint57k_post, checkpoint51f_pre, checkpoint48g_post, checkpoint53b_post, checkpoint47h_post, checkpoint52a_post, checkpoint57w_post, checkpoint58i_post, checkpoint51g_post, ecco_c52_e35, checkpoint57x_post, checkpoint46d_post, checkpoint50b_post, checkpoint58c_post, checkpoint58u_post, checkpoint51m_post, checkpoint53d_pre, checkpoint58s_post, checkpoint55e_post, checkpoint54c_post, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: branch-exfmods-curt, branch-genmake2, branch-nonh, tg2-branch, netcdf-sm0, checkpoint51n_branch
Changes since 1.1: +191 -0 lines
Merging from release1_p5
o flow directives:
  - new for S/R do_the_model_io
  - enhanced for S/R checkpoint
  - new gmredi.flow
o Introduced CPP option ALLOW_AUTODIFF_MONITOR to
  disable adcommon.h/g_common.h by default.
o fixed problem for adjoint of global_max

1 C $Header: /u/gcmpack/MITgcm/pkg/autodiff/Attic/global_max_ad.F,v 1.1.2.1 2002/04/17 01:35:52 heimbach Exp $
2 C $Name: release1_p5 $
3
4 C-- File global_max.F: Routines that perform global max reduction on an array
5 C of thread values.
6 C
7 C Adjoint routines are identical to forward routines,
8 C but parameter list is reversed to be consistent with
9 C call statement generated by TAMC/TAF
10 C P. Heimbach, 16-Apr-2002
11 C
12 C Contents
13 C o global_admax_r4
14 C o global_admax_r8
15 #include "CPP_EEOPTIONS.h"
16
17 CBOP
18
19 C !ROUTINE: GLOBAL_ADMAX_R4
20
21 C !INTERFACE:
22 SUBROUTINE GLOBAL_ADMAX_R4(
23 I myThid,
24 U maxPhi
25 & )
26 IMPLICIT NONE
27 C !DESCRIPTION:
28 C *==========================================================*
29 C | SUBROUTINE GLOBAL_ADMAX_R4
30 C | o Handle max for real*4 data.
31 C *==========================================================*
32 C | Perform max on array of one value per thread and then
33 C | max result of all the processes.
34 C | Notes
35 C | =====
36 C | Within a process only one thread does the max, each
37 C | thread is assumed to have already maxed its local data.
38 C | The same thread also does the inter-process max for
39 C | example with MPI and then writes the result into a shared
40 C | location. All threads wait until the max is avaiailable.
41 C *==========================================================*
42
43 C !USES:
44 C == Global data ==
45 #include "SIZE.h"
46 #include "EEPARAMS.h"
47 #include "EESUPPORT.h"
48 #include "GLOBAL_MAX.h"
49
50 C !INPUT/OUTPUT PARAMETERS:
51 C == Routine arguments ==
52 C maxPhi :: Result of max.
53 C myThid :: My thread id.
54 Real*4 maxPhi
55 INTEGER myThid
56
57 C !LOCAL VARIABLES:
58 C == Local variables ==
59 C I :: Loop counters
60 C mpiRC :: MPI return code
61 INTEGER I
62 Real*4 tmp
63 #ifdef ALLOW_USE_MPI
64 INTEGER mpiRC
65 #endif /* ALLOW_USE_MPI */
66 CEOP
67
68 CALL BAR2( myThid )
69 C-- write local max into array
70 phiGMRS(1,myThid) = maxPhi
71
72 C-- Can not start until everyone is ready
73 CALL BAR2( myThid )
74
75 C-- Max within the process first
76 _BEGIN_MASTER( myThid )
77 tmp = phiGMRS(1,1)
78 DO I=2,nThreads
79 tmp = MAX(tmp,phiGMRS(1,I))
80 ENDDO
81 maxPhi = tmp
82 #ifdef ALLOW_USE_MPI
83 #ifndef ALWAYS_USE_MPI
84 IF ( usingMPI ) THEN
85 #endif
86 CALL MPI_Allreduce(tmp,maxPhi,1,MPI_REAL,MPI_MAX,
87 & MPI_COMM_WORLD,mpiRC)
88 #ifndef ALWAYS_USE_MPI
89 ENDIF
90 #endif
91 #endif /* ALLOW_USE_MPI */
92 phiGMRS(1,1) = maxPhi
93 _END_MASTER( myThid )
94 C--
95 CALL BAR2( myThid )
96
97 C-- set result for every process
98 maxPhi = phiGMRS(1,1)
99 CALL BAR2( myThid )
100
101 RETURN
102 END
103
104 CBOP
105
106 C !ROUTINE: GLOBAL_ADMAX_R8
107
108 C !INTERFACE:
109 SUBROUTINE GLOBAL_ADMAX_R8(
110 I myThid,
111 O maxPhi
112 & )
113 IMPLICIT NONE
114 C !DESCRIPTION:
115 C *==========================================================*
116 C | SUBROUTINE GLOBAL_ADMAX_R8
117 C | o Handle max for real*8 data.
118 C *==========================================================*
119 C | Perform max on array of one value per thread and then
120 C | max result of all the processes.
121 C | Notes
122 C | =====
123 C | Within a process only one thread does the max, each
124 C | thread is assumed to have already maxed its local data.
125 C | The same thread also does the inter-process max for
126 C | example with MPI and then writes the result into a shared
127 C | location. All threads wait until the max is avaiailable.
128 C *==========================================================*
129
130 C !USES:
131 C === Global data ===
132 #include "SIZE.h"
133 #include "EEPARAMS.h"
134 #include "EESUPPORT.h"
135 #include "GLOBAL_MAX.h"
136
137 C !INPUT/OUTPUT PARAMETERS:
138 C === Routine arguments ===
139 C maxPhi :: Result of max.
140 C myThid :: My thread id.
141 Real*8 maxPhi
142 INTEGER myThid
143
144 C !LOCAL VARIABLES:
145 C === Local variables ===
146 C I :: Loop counters
147 C mpiRC :: MPI return code
148 INTEGER I
149 Real*8 tmp
150 #ifdef ALLOW_USE_MPI
151 INTEGER mpiRC
152 #endif /* ALLOW_USE_MPI */
153 CEOP
154
155 CALL BAR2( myThid )
156 C-- write local max into array
157 phiGMRL(1,myThid) = maxPhi
158
159 C-- Can not start until everyone is ready
160 CALL BAR2( myThid )
161
162 C-- Max within the process first
163 _BEGIN_MASTER( myThid )
164 tmp = phiGMRL(1,1)
165 DO I=2,nThreads
166 tmp = MAX(tmp,phiGMRL(1,I))
167 ENDDO
168 maxPhi = tmp
169 #ifdef ALLOW_USE_MPI
170 #ifndef ALWAYS_USE_MPI
171 IF ( usingMPI ) THEN
172 #endif
173 CALL MPI_Allreduce(tmp,maxPhi,1,MPI_DOUBLE_PRECISION,MPI_MAX,
174 & MPI_COMM_WORLD,mpiRC)
175 #ifndef ALWAYS_USE_MPI
176 ENDIF
177 #endif
178 #endif /* ALLOW_USE_MPI */
179 C-- Write solution to place where all threads can see it
180 phiGMRL(1,1) = maxPhi
181 _END_MASTER( myThid )
182
183 C-- Do not leave until we are sure that the max is done
184 CALL BAR2( myThid )
185
186 C-- set result for every process
187 maxPhi = phiGMRL(1,1)
188 CALL BAR2( myThid )
189
190 RETURN
191 END

  ViewVC Help
Powered by ViewVC 1.1.22