5
6
7
8
9
10
11
12 INTEGER IAM, LDNBVAL, LDNVAL, LDPVAL, LDQVAL,
13 $ NGRIDS, NMAT, NNB, NOUT, NPROCS
14 REAL THRESH
15
16
17 CHARACTER*( * ) SUMMRY
18 INTEGER NBVAL( LDNBVAL ), NVAL( LDNVAL ),
19 $ NVHI( LDNVAL ), NVLO( LDNVAL ),
20 $ PVAL( LDPVAL ), QVAL( LDQVAL ), WORK( * )
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
111 $ LLD_, MB_, M_, NB_, N_, RSRC_
112 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
113 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
114 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
115 INTEGER NIN
116 parameter( nin = 11 )
117
118
119 CHARACTER*79 USRINFO
120 INTEGER I, ICTXT
121 REAL EPS
122
123
124 EXTERNAL blacs_abort, blacs_get, blacs_gridexit,
125 $ blacs_gridinit, blacs_setup,
icopy, igebr2d,
126 $ igebs2d, sgebr2d, sgebs2d
127
128
129 REAL PSLAMCH
131
132
134
135
136
137
138
139
140 IF( iam.EQ.0 ) THEN
141
142
143
144 OPEN( unit = nin, file = 'HRD.dat', status = 'OLD' )
145 READ( nin, fmt = * )summry
146 summry = ' '
147
148
149
150 READ( nin, fmt = * ) usrinfo
151
152
153
154 READ( nin, fmt = * ) summry
155 READ( nin, fmt = * ) nout
156 IF( nout.NE.0 .AND. nout.NE.6 )
157 $ OPEN( unit = nout, file = summry, status = 'UNKNOWN' )
158
159
160
161
162
163 READ( nin, fmt = * ) nmat
164 IF( nmat.LT.1. .OR. nmat.GT.ldnval ) THEN
165 WRITE( nout, fmt = 9997 ) 'N', ldnval
166 GO TO 20
167 END IF
168
169
170
171 READ( nin, fmt = * ) ( nval( i ), i = 1, nmat )
172 READ( nin, fmt = * ) ( nvlo( i ), i = 1, nmat )
173 READ( nin, fmt = * ) ( nvhi( i ), i = 1, nmat )
174
175
176
177 READ( nin, fmt = * ) nnb
178 IF( nnb.LT.1 .OR. nnb.GT.ldnbval ) THEN
179 WRITE( nout, fmt = 9997 ) 'NB', ldnbval
180 GO TO 20
181 END IF
182 READ( nin, fmt = * ) ( nbval( i ), i = 1, nnb )
183
184
185
186 READ( nin, fmt = * ) ngrids
187 IF( ngrids.LT.1 .OR. ngrids.GT.ldpval ) THEN
188 WRITE( nout, fmt = 9997 ) 'Grids', ldpval
189 GO TO 20
190 ELSE IF( ngrids.GT.ldqval ) THEN
191 WRITE( nout, fmt = 9997 ) 'Grids', ldqval
192 GO TO 20
193 END IF
194
195
196
197 READ( nin, fmt = * ) ( pval( i ), i = 1, ngrids )
198 READ( nin, fmt = * ) ( qval( i ), i = 1, ngrids )
199
200
201
202 READ( nin, fmt = * ) thresh
203
204
205
206 CLOSE( nin )
207
208
209
210
211 IF( nprocs.LT.1 ) THEN
212 nprocs = 0
213 DO 10 i = 1, ngrids
214 nprocs =
max( nprocs, pval( i )*qval( i ) )
215 10 CONTINUE
216 CALL blacs_setup( iam, nprocs )
217 END IF
218
219
220
221
222 CALL blacs_get( -1, 0, ictxt )
223 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
224
225
226
228
229
230
231 CALL sgebs2d( ictxt, 'All', ' ', 1, 1, thresh, 1 )
232
233 work( 1 ) = nmat
234 work( 2 ) = nnb
235 work( 3 ) = ngrids
236 CALL igebs2d( ictxt, 'All', ' ', 1, 3, work, 1 )
237
238 i = 1
239 CALL icopy( nmat, nval, 1, work( i ), 1 )
240 i = i + nmat
241 CALL icopy( nmat, nvlo, 1, work( i ), 1 )
242 i = i + nmat
243 CALL icopy( nmat, nvhi, 1, work( i ), 1 )
244 i = i + nmat
245 CALL icopy( nnb, nbval, 1, work( i ), 1 )
246 i = i + nnb
247 CALL icopy( ngrids, pval, 1, work( i ), 1 )
248 i = i + ngrids
249 CALL icopy( ngrids, qval, 1, work( i ), 1 )
250 i = i + ngrids -1
251 CALL igebs2d( ictxt, 'All', ' ', 1, i, work, 1 )
252
253
254
255 WRITE( nout, fmt = 9999 )
256 $ 'ScaLAPACK Reduction routine to Hessenberg form.'
257 WRITE( nout, fmt = 9999 ) usrinfo
258 WRITE( nout, fmt = * )
259 WRITE( nout, fmt = 9999 )
260 $ 'Tests of the parallel '//
261 $ 'real single precision Hessenberg '
262 WRITE( nout, fmt = 9999 ) 'reduction routines.'
263 WRITE( nout, fmt = 9999 )
264 $ 'The following scaled residual '//
265 $ 'checks will be computed:'
266 WRITE( nout, fmt = 9999 )
267 $ ' ||A - Q H Q''|| / (||A|| * eps * N)'
268 WRITE( nout, fmt = 9999 )
269 $ 'The matrix A is randomly '//
270 $ 'generated for each test.'
271 WRITE( nout, fmt = * )
272 WRITE( nout, fmt = 9999 )
273 $ 'An explanation of the input/output '//
274 $ 'parameters follows:'
275 WRITE( nout, fmt = 9999 )
276 $ 'TIME : Indicates whether WALL or '//
277 $ 'CPU time was used.'
278 WRITE( nout, fmt = 9999 )
279 $ 'N : The number of rows and columns '//
280 $ 'of the matrix A.'
281 WRITE( nout, fmt = 9999 )
282 $ 'NB : The size of the square blocks'//
283 $ ' the matrix A is split into.'
284 WRITE( nout, fmt = 9999 )
285 $ ' on to the next column of processes.'
286 WRITE( nout, fmt = 9999 )
287 $ 'P : The number of process rows.'
288 WRITE( nout, fmt = 9999 )
289 $ 'Q : The number of process columns.'
290 WRITE( nout, fmt = 9999 )
291 $ 'HRD time : Time in seconds to compute HRD '
292 WRITE( nout, fmt = 9999 )
293 $ 'MFLOPS : Rate of execution for HRD ' //
294 $ 'reduction.'
295 WRITE( nout, fmt = * )
296 WRITE( nout, fmt = 9999 )
297 $ 'The following parameter values will be used:'
298 WRITE( nout, fmt = 9995 )
299 $
'N ', ( nval( i ), i = 1,
min( nmat, 10 ) )
300 IF( nmat.GT.10 )
301 $ WRITE( nout, fmt = 9994 ) ( nval( i ), i = 11, nmat )
302 WRITE( nout, fmt = 9995 )
303 $
'ILO ', ( nvlo( i ), i = 1,
min( nmat, 10 ) )
304 IF( nmat.GT.10 )
305 $ WRITE( nout, fmt = 9994 ) ( nvlo( i ), i = 11, nmat )
306 WRITE( nout, fmt = 9995 )
307 $
'IHI ', ( nvhi( i ), i = 1,
min( nmat, 10 ) )
308 IF( nmat.GT.10 )
309 $ WRITE( nout, fmt = 9994 ) ( nvhi( i ), i = 11, nmat )
310 WRITE( nout, fmt = 9995 )
311 $
'NB ', ( nbval( i ), i = 1,
min( nnb, 10 ) )
312 IF( nnb.GT.10 )
313 $ WRITE( nout, fmt = 9994 ) ( nbval( i ), i = 11, nnb )
314 WRITE( nout, fmt = 9995 )
315 $
'P ', ( pval( i ), i = 1,
min( ngrids, 10 ) )
316 IF( ngrids.GT.10 )
317 $ WRITE( nout, fmt = 9994 ) ( pval( i ), i = 11, ngrids )
318 WRITE( nout, fmt = 9995 )
319 $
'Q ', ( qval( i ), i = 1,
min( ngrids, 10 ) )
320 IF( ngrids.GT.10 )
321 $ WRITE( nout, fmt = 9994 ) ( qval( i ), i = 11, ngrids )
322 WRITE( nout, fmt = * )
323 WRITE( nout, fmt = 9996 ) eps
324 WRITE( nout, fmt = 9993 ) thresh
325
326 ELSE
327
328
329
330 IF( nprocs.LT.1 )
331 $ CALL blacs_setup( iam, nprocs )
332
333
334
335
336 CALL blacs_get( -1, 0, ictxt )
337 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
338
339
340
342
343 CALL sgebr2d( ictxt, 'All', ' ', 1, 1, thresh, 1, 0, 0 )
344 CALL igebr2d( ictxt, 'All', ' ', 1, 3, work, 1, 0, 0 )
345 nmat = work( 1 )
346 nnb = work( 2 )
347 ngrids = work( 3 )
348
349 i = 3*nmat + nnb + 2*ngrids
350 CALL igebr2d( ictxt, 'All', ' ', 1, i, work, 1, 0, 0 )
351
352 i = 1
353 CALL icopy( nmat, work( i ), 1, nval, 1 )
354 i = i + nmat
355 CALL icopy( nmat, work( i ), 1, nvlo, 1 )
356 i = i + nmat
357 CALL icopy( nmat, work( i ), 1, nvhi, 1 )
358 i = i + nmat
359 CALL icopy( nnb, work( i ), 1, nbval, 1 )
360 i = i + nnb
361 CALL icopy( ngrids, work( i ), 1, pval, 1 )
362 i = i + ngrids
363 CALL icopy( ngrids, work( i ), 1, qval, 1 )
364
365 END IF
366
367 CALL blacs_gridexit( ictxt )
368
369 RETURN
370
371 20 CONTINUE
372 WRITE( nout, fmt = 9998 )
373 CLOSE( nin )
374 IF( nout.NE.6 .AND. nout.NE.0 )
375 $ CLOSE( nout )
376 CALL blacs_abort( ictxt, 1 )
377
378 stop
379
380 9999 FORMAT( a )
381 9998 FORMAT( ' ILLEGAL INPUT IN FILE ', 40a, '. ABORTING RUN.' )
382 9997 FORMAT( ' NUMBER OF VALUES OF ', 5a,
383 $ ' IS LESS THAN 1 OR GREATER ', 'THAN ', i2 )
384 9996 FORMAT( 'Relative machine precision (eps) is taken to be ',
385 $ e18.6 )
386 9995 FORMAT( 2x, a5, ': ', 10i6 )
387 9994 FORMAT( ' ', 10i6 )
388 9993 FORMAT( 'Routines pass computational tests if scaled residual is',
389 $ ' less than ', g14.7 )
390
391
392
subroutine icopy(n, sx, incx, sy, incy)
real function pslamch(ictxt, cmach)