4
5
6
7
8
9
10
11 CHARACTER UPLO
12 INTEGER IAM, LDNBVAL, LDNVAL, LDPVAL, LDQVAL,
13 $ NGRIDS, NMAT, NNB, NPROCS, NOUT
14 REAL THRESH
15
16
17 CHARACTER*( * ) SUMMRY*(*)
18 INTEGER NBVAL( LDNBVAL ), NVAL( LDNVAL ),
19 $ PVAL( LDPVAL ), QVAL( LDQVAL ), WORK( * )
20
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 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
110 $ LLD_, MB_, M_, NB_, N_, RSRC_
111 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
112 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
113 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
114 INTEGER NIN
115 parameter( nin = 11 )
116
117
118 CHARACTER*79 USRINFO
119 INTEGER I, ICTXT
120 DOUBLE PRECISION EPS
121
122
123 EXTERNAL blacs_abort, blacs_get, blacs_gridexit,
124 $ blacs_gridinit, blacs_setup,
icopy, igebr2d,
125 $ igebs2d, sgebr2d, sgebs2d
126
127
128 LOGICAL LSAME
129 DOUBLE PRECISION PDLAMCH
131
132
134
135
136
137
138
139
140 IF( iam.EQ.0 ) THEN
141
142
143
144 OPEN( nin, file='TRD.dat', status='OLD' )
145 READ( nin, fmt = * ) summry
146 summry = ' '
147
148
149
150 READ( nin, fmt = 9999 ) 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( nout, file = summry, status = 'UNKNOWN' )
158
159
160
161
162
163 READ( nin, fmt = * ) uplo
164
165
166
167 READ( nin, fmt = * ) nmat
168 IF( nmat.LT.1 .OR. nmat.GT.ldnval ) THEN
169 WRITE( nout, fmt = 9994 ) 'N', ldnval
170 GOTO 20
171 END IF
172 READ( nin, fmt = * ) ( nval( i ), i = 1, nmat )
173
174
175
176 READ( nin, fmt = * ) nnb
177 IF( nnb.LT.1 .OR. nnb.GT.ldnbval ) THEN
178 WRITE( nout, fmt = 9994 ) 'NB', ldnbval
179 GOTO 20
180 END IF
181 READ( nin, fmt = * ) ( nbval( i ), i = 1, nnb )
182
183
184
185 READ( nin, fmt = * ) ngrids
186 IF( ngrids.LT.1 .OR. ngrids.GT.ldpval ) THEN
187 WRITE( nout, fmt = 9994 ) 'Grids', ldpval
188 GOTO 20
189 ELSE IF( ngrids.GT.ldqval ) THEN
190 WRITE( nout, fmt = 9994 ) 'Grids', ldqval
191 GOTO 20
192 END IF
193
194
195
196 READ( nin, fmt = * ) ( pval( i ), i = 1, ngrids )
197 READ( nin, fmt = * ) ( qval( i ), i = 1, ngrids )
198
199
200
201 READ( nin, fmt = * ) thresh
202
203
204
205 CLOSE( nin )
206
207
208
209
210 IF( nprocs.LT.1 ) THEN
211 nprocs = 0
212 DO 10 i = 1, ngrids
213 nprocs =
max( nprocs, pval( i )*qval( i ) )
214 10 CONTINUE
215 CALL blacs_setup( iam, nprocs )
216 END IF
217
218
219
220
221 CALL blacs_get( -1, 0, ictxt )
222 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
223
224
225
227
228
229
230 CALL sgebs2d( ictxt, 'All', ' ', 1, 1, thresh, 1 )
231
232 work( 1 ) = nmat
233 work( 2 ) = nnb
234 work( 3 ) = ngrids
235 IF(
lsame( uplo,
'L' ) )
THEN
236 work( 4 ) = 1
237 ELSE
238 work( 4 ) = 2
239 END IF
240 CALL igebs2d( ictxt, 'All', ' ', 4, 1, work, 4 )
241
242 i = 1
243 CALL icopy( nmat, nval, 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', ' ', i, 1, work, i )
252
253
254
255 WRITE( nout, fmt = 9999 )
256 $ 'ScaLAPACK Reduction Routine to symmetric '//
257 $ 'tridiagonal form.'
258 WRITE( nout, fmt = 9999 ) usrinfo
259 WRITE( nout, fmt = * )
260 WRITE( nout, fmt = 9999 )
261 $ 'Tests of the parallel '//
262 $ 'real double precision symmetric '//
263 $ 'tridiagonal'
264 WRITE( nout, fmt = 9999 ) 'reduction routines.'
265 WRITE( nout, fmt = 9999 )
266 $ 'The following scaled residual '//
267 $ 'checks will be computed:'
268 WRITE( nout, fmt = 9999 )
269 $ ' ||A - QTQ''|| / (||A|| * eps * N)'
270 WRITE( nout, fmt = 9999 )
271 $ 'The matrix A is randomly '//
272 $ 'generated for each test.'
273 WRITE( nout, fmt = * )
274 WRITE( nout, fmt = 9999 )
275 $ 'An explanation of the input/output '//
276 $ 'parameters follows:'
277 WRITE( nout, fmt = 9999 )
278 $ 'UPLO : Whether the ''Upper'' or ''Low'//
279 $ 'er'' part of A is to be referenced.'
280 WRITE( nout, fmt = 9999 )
281 $ 'TIME : Indicates whether WALL or '//
282 $ 'CPU time was used.'
283 WRITE( nout, fmt = 9999 )
284 $ 'N : The number of rows and columns '//
285 $ 'of the matrix A.'
286 WRITE( nout, fmt = 9999 )
287 $ 'NB : The size of the square blocks'//
288 $ ' the matrix A is split into.'
289 WRITE( nout, fmt = 9999 )
290 $ 'P : The number of process rows.'
291 WRITE( nout, fmt = 9999 )
292 $ 'Q : The number of process columns.'
293 WRITE( nout, fmt = 9999 )
294 $ 'THRESH : If a residual value is less'//
295 $ 'than THRESH, CHECK is flagged as PASSED.'
296 WRITE( nout, fmt = 9999 )
297 $ 'TRD time : Time in seconds to reduce the'//
298 $ ' matrix to tridiagonal form.'
299 WRITE( nout, fmt = 9999 )
300 $ 'MFLOPS : Rate of execution for '//
301 $ 'symmetric tridiagonal reduction.'
302 WRITE( nout, fmt = * )
303 WRITE( nout, fmt = 9999 )
304 $ 'The following parameter values will be used:'
305 WRITE( nout, fmt = 9999 )
306 $ ' UPLO : '//uplo
307 WRITE( nout, fmt = 9996 )
308 $
'N ', ( nval( i ), i = 1,
min( nmat, 10 ) )
309 IF( nmat.GT.10 )
310 $ WRITE( nout, fmt = 9997 ) ( nval( i ), i = 11, nmat )
311 WRITE( nout, fmt = 9996 )
312 $
'NB ', ( nbval( i ), i = 1,
min( nnb, 10 ) )
313 IF( nnb.GT.10 )
314 $ WRITE( nout, fmt = 9997 ) ( nbval( i ), i = 11, nnb )
315 WRITE( nout, fmt = 9996 )
316 $
'P ', ( pval( i ), i = 1,
min( ngrids, 10 ) )
317 IF( ngrids.GT.10 )
318 $ WRITE( nout, fmt = 9997 ) ( pval( i ), i = 11, ngrids )
319 WRITE( nout, fmt = 9996 )
320 $
'Q ', ( qval( i ), i = 1,
min( ngrids, 10 ) )
321 IF( ngrids.GT.10 )
322 $ WRITE( nout, fmt = 9997 ) ( qval( i ), i = 11, ngrids )
323 WRITE( nout, fmt = * )
324 WRITE( nout, fmt = 9995 ) eps
325 WRITE( nout, fmt = 9998 ) thresh
326
327 ELSE
328
329
330
331 IF( nprocs.LT.1 )
332 $ CALL blacs_setup( iam, nprocs )
333
334
335
336
337 CALL blacs_get( -1, 0, ictxt )
338 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
339
340
341
343
344 CALL sgebr2d( ictxt, 'All', ' ', 1, 1, thresh, 1, 0, 0 )
345 CALL igebr2d( ictxt, 'All', ' ', 4, 1, work, 4, 0, 0 )
346 nmat = work( 1 )
347 nnb = work( 2 )
348 ngrids = work( 3 )
349 IF( work( 4 ).EQ.1 ) THEN
350 uplo = 'L'
351 ELSE
352 uplo = 'U'
353 END IF
354
355 i = nmat + nnb + 2*ngrids
356 CALL igebr2d( ictxt, 'All', ' ', i, 1, work, i, 0, 0 )
357 i = 1
358 CALL icopy( nmat, work( i ), 1, nval, 1 )
359 i = i + nmat
360 CALL icopy( nnb, work( i ), 1, nbval, 1 )
361 i = i + nnb
362 CALL icopy( ngrids, work( i ), 1, pval, 1 )
363 i = i + ngrids
364 CALL icopy( ngrids, work( i ), 1, qval, 1 )
365
366 END IF
367
368 CALL blacs_gridexit( ictxt )
369
370 RETURN
371
372 20 WRITE( nout, fmt = 9993 )
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( 'Routines pass computational tests if scaled residual ',
382 $ 'is less than ', g12.5 )
383 9997 FORMAT( ' ', 10i6 )
384 9996 FORMAT( 2x, a5, ' : ', 10i6 )
385 9995 FORMAT( 'Relative machine precision (eps) is taken to be ',
386 $ e18.6 )
387 9994 FORMAT( ' Number of values of ',5a, ' is less than 1 or greater ',
388 $ 'than ', i2 )
389 9993 FORMAT( ' Illegal input in file ',40a,'. Aborting run.' )
390
391
392
subroutine icopy(n, sx, incx, sy, incy)
double precision function pdlamch(ictxt, cmach)