6
7
8
9
10
11
12
13
14
15 CHARACTER TRANS
16 CHARACTER*(*) SUMMRY
17 INTEGER IAM,
18 $ LDBWVAL, LDNBRVAL, LDNBVAL, LDNRVAL, LDNVAL,
19 $ LDPVAL, LDQVAL, NGRIDS, NMAT, NNB, NNBR, NBW,
20 $ NPROCS, NNR, NOUT
21 REAL THRESH
22
23
24 INTEGER NBRVAL( LDNBRVAL ), NBVAL( LDNBVAL ),
25 $ NRVAL( LDNRVAL ), NVAL( LDNVAL ),
26 $ BWLVAL( LDBWVAL),BWUVAL( LDBWVAL),
27 $ PVAL( LDPVAL ), QVAL(LDQVAL), WORK( * )
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150 INTEGER NIN
151 parameter( nin = 11 )
152
153
154 INTEGER I, ICTXT
155 CHARACTER*79 USRINFO
156 DOUBLE PRECISION EPS
157
158
159 EXTERNAL blacs_abort, blacs_get, blacs_gridexit,
160 $ blacs_gridinit, blacs_setup,
icopy, igebr2d,
161 $ igebs2d, sgebr2d, sgebs2d
162
163
164 LOGICAL LSAME
165 DOUBLE PRECISION PDLAMCH
167
168
170
171
172
173
174
175
176 IF( iam.EQ.0 ) THEN
177
178
179
180 OPEN( nin, file = 'BLU.dat', status = 'OLD' )
181 READ( nin, fmt = * ) summry
182 summry = ' '
183
184
185
186 READ( nin, fmt = 9999 ) usrinfo
187
188
189
190 READ( nin, fmt = * ) summry
191 READ( nin, fmt = * ) nout
192 IF( nout.NE.0 .AND. nout.NE.6 )
193 $ OPEN( nout, file = summry, status = 'UNKNOWN' )
194
195
196
197
198
199 READ( nin, fmt = * ) trans
200
201
202
203
204 READ( nin, fmt = * ) nmat
205 IF( nmat.LT.1 .OR. nmat.GT.ldnval ) THEN
206 WRITE( nout, fmt = 9994 ) 'N', ldnval
207 GO TO 20
208 END IF
209 READ( nin, fmt = * ) ( nval( i ), i = 1, nmat )
210
211
212
213 READ( nin, fmt = * ) nbw
214 IF( nbw.LT.1 .OR. nbw.GT.ldbwval ) THEN
215 WRITE( nout, fmt = 9994 ) 'BW', ldbwval
216 GO TO 20
217 END IF
218 READ( nin, fmt = * ) ( bwlval( i ), i = 1, nbw )
219 READ( nin, fmt = * ) ( bwuval( i ), i = 1, nbw )
220
221
222
223 READ( nin, fmt = * ) nnb
224 IF( nnb.LT.1 .OR. nnb.GT.ldnbval ) THEN
225 WRITE( nout, fmt = 9994 ) 'NB', ldnbval
226 GO TO 20
227 END IF
228 READ( nin, fmt = * ) ( nbval( i ), i = 1, nnb )
229
230
231
232 READ( nin, fmt = * ) nnr
233 IF( nnr.LT.1 .OR. nnr.GT.ldnrval ) THEN
234 WRITE( nout, fmt = 9994 ) 'NRHS', ldnrval
235 GO TO 20
236 END IF
237 READ( nin, fmt = * ) ( nrval( i ), i = 1, nnr )
238
239
240
241 READ( nin, fmt = * ) nnbr
242 IF( nnbr.LT.1 .OR. nnbr.GT.ldnbrval ) THEN
243 WRITE( nout, fmt = 9994 ) 'NBRHS', ldnbrval
244 GO TO 20
245 END IF
246 READ( nin, fmt = * ) ( nbrval( i ), i = 1, nnbr )
247
248
249
250 READ( nin, fmt = * ) ngrids
251 IF( ngrids.LT.1 .OR. ngrids.GT.ldpval ) THEN
252 WRITE( nout, fmt = 9994 ) 'Grids', ldpval
253 GO TO 20
254 ELSE IF( ngrids.GT.ldqval ) THEN
255 WRITE( nout, fmt = 9994 ) 'Grids', ldqval
256 GO TO 20
257 END IF
258
259
260 DO 8738 i = 1, ngrids
261 pval( i ) = 1
262 8738 CONTINUE
263
264
265
266 READ( nin, fmt = * ) ( qval( i ), i = 1, ngrids )
267
268
269
270 READ( nin, fmt = * ) thresh
271
272
273
274 CLOSE( nin )
275
276
277
278
279 IF( nprocs.LT.1 ) THEN
280 nprocs = 0
281 DO 10 i = 1, ngrids
282 nprocs =
max( nprocs, pval( i )*qval( i ) )
283 10 CONTINUE
284 CALL blacs_setup( iam, nprocs )
285 END IF
286
287
288
289
290 CALL blacs_get( -1, 0, ictxt )
291 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
292
293
294
296
297
298
299 CALL sgebs2d( ictxt, 'All', ' ', 1, 1, thresh, 1 )
300 i = 1
301 work( i ) = nmat
302 i = i+1
303 work( i ) = nbw
304 i = i+1
305 work( i ) = nnb
306 i = i+1
307 work( i ) = nnr
308 i = i+1
309 work( i ) = nnbr
310 i = i+1
311 work( i ) = ngrids
312 i = i+1
313 IF(
lsame( trans,
'N' ) )
THEN
314 work( i ) = 1
315 ELSE
316 trans = 'T'
317 work( i ) = 2
318 END IF
319 i = i+1
320
321 CALL igebs2d( ictxt, 'All', ' ', 1, 1, i-1, 1 )
322
323 CALL igebs2d( ictxt, 'All', ' ', i-1, 1, work, i-1 )
324
325 i = 1
326 CALL icopy( nmat, nval, 1, work( i ), 1 )
327 i = i + nmat
328 CALL icopy( nbw, bwlval, 1, work( i ), 1 )
329 i = i + nbw
330 CALL icopy( nbw, bwuval, 1, work( i ), 1 )
331 i = i + nbw
332 CALL icopy( nnb, nbval, 1, work( i ), 1 )
333 i = i + nnb
334 CALL icopy( nnr, nrval, 1, work( i ), 1 )
335 i = i + nnr
336 CALL icopy( nnbr, nbrval, 1, work( i ), 1 )
337 i = i + nnbr
338 CALL icopy( ngrids, pval, 1, work( i ), 1 )
339 i = i + ngrids
340 CALL icopy( ngrids, qval, 1, work( i ), 1 )
341 i = i + ngrids
342 CALL igebs2d( ictxt, 'All', ' ', i-1, 1, work, i-1 )
343
344
345
346 WRITE( nout, fmt = 9999 )
347 $ 'SCALAPACK banded linear systems.'
348 WRITE( nout, fmt = 9999 ) usrinfo
349 WRITE( nout, fmt = * )
350 WRITE( nout, fmt = 9999 )
351 $ 'Tests of the parallel '//
352 $ 'real double precision band matrix solve '
353 WRITE( nout, fmt = 9999 )
354 $ 'The following scaled residual '//
355 $ 'checks will be computed:'
356 WRITE( nout, fmt = 9999 )
357 $ ' Solve residual = ||Ax - b|| / '//
358 $ '(||x|| * ||A|| * eps * N)'
359 WRITE( nout, fmt = 9999 )
360 $ ' Factorization residual = ||A - LU|| /'//
361 $ ' (||A|| * eps * N)'
362 WRITE( nout, fmt = 9999 )
363 $ 'The matrix A is randomly '//
364 $ 'generated for each test.'
365 WRITE( nout, fmt = * )
366 WRITE( nout, fmt = 9999 )
367 $ 'An explanation of the input/output '//
368 $ 'parameters follows:'
369 WRITE( nout, fmt = 9999 )
370 $ 'TIME : Indicates whether WALL or '//
371 $ 'CPU time was used.'
372
373 WRITE( nout, fmt = 9999 )
374 $ 'N : The number of rows and columns '//
375 $ 'in the matrix A.'
376 WRITE( nout, fmt = 9999 )
377 $ 'bwl, bwu : The number of diagonals '//
378 $ 'in the matrix A.'
379 WRITE( nout, fmt = 9999 )
380 $ 'NB : The size of the column panels the'//
381 $ ' matrix A is split into. [-1 for default]'
382 WRITE( nout, fmt = 9999 )
383 $ 'NRHS : The total number of RHS to solve'//
384 $ ' for.'
385 WRITE( nout, fmt = 9999 )
386 $ 'NBRHS : The number of RHS to be put on '//
387 $ 'a column of processes before going'
388 WRITE( nout, fmt = 9999 )
389 $ ' on to the next column of processes.'
390 WRITE( nout, fmt = 9999 )
391 $ 'P : The number of process rows.'
392 WRITE( nout, fmt = 9999 )
393 $ 'Q : The number of process columns.'
394 WRITE( nout, fmt = 9999 )
395 $ 'THRESH : If a residual value is less than'//
396 $ ' THRESH, CHECK is flagged as PASSED'
397 WRITE( nout, fmt = 9999 )
398 $ 'Fact time: Time in seconds to factor the'//
399 $ ' matrix'
400 WRITE( nout, fmt = 9999 )
401 $ 'Sol Time: Time in seconds to solve the'//
402 $ ' system.'
403 WRITE( nout, fmt = 9999 )
404 $ 'MFLOPS : Rate of execution for factor '//
405 $ 'and solve using sequential operation count.'
406 WRITE( nout, fmt = 9999 )
407 $ 'MFLOP2 : Rough estimate of speed '//
408 $ 'using actual op count (accurate big P,N).'
409 WRITE( nout, fmt = * )
410 WRITE( nout, fmt = 9999 )
411 $ 'The following parameter values will be used:'
412 WRITE( nout, fmt = 9996 )
413 $
'N ', ( nval(i), i = 1,
min(nmat, 10) )
414 IF( nmat.GT.10 )
415 $ WRITE( nout, fmt = 9997 ) ( nval(i), i = 11, nmat )
416 WRITE( nout, fmt = 9996 )
417 $
'bwl ', ( bwlval(i), i = 1,
min(nbw, 10) )
418 IF( nbw.GT.10 )
419 $ WRITE( nout, fmt = 9997 ) ( bwlval(i), i = 11, nbw )
420 WRITE( nout, fmt = 9996 )
421 $
'bwu ', ( bwuval(i), i = 1,
min(nbw, 10) )
422 IF( nbw.GT.10 )
423 $ WRITE( nout, fmt = 9997 ) ( bwuval(i), i = 11, nbw )
424 WRITE( nout, fmt = 9996 )
425 $
'NB ', ( nbval(i), i = 1,
min(nnb, 10) )
426 IF( nnb.GT.10 )
427 $ WRITE( nout, fmt = 9997 ) ( nbval(i), i = 11, nnb )
428 WRITE( nout, fmt = 9996 )
429 $
'NRHS ', ( nrval(i), i = 1,
min(nnr, 10) )
430 IF( nnr.GT.10 )
431 $ WRITE( nout, fmt = 9997 ) ( nrval(i), i = 11, nnr )
432 WRITE( nout, fmt = 9996 )
433 $
'NBRHS', ( nbrval(i), i = 1,
min(nnbr, 10) )
434 IF( nnbr.GT.10 )
435 $ WRITE( nout, fmt = 9997 ) ( nbrval(i), i = 11, nnbr )
436 WRITE( nout, fmt = 9996 )
437 $
'P ', ( pval(i), i = 1,
min(ngrids, 10) )
438 IF( ngrids.GT.10 )
439 $ WRITE( nout, fmt = 9997) ( pval(i), i = 11, ngrids )
440 WRITE( nout, fmt = 9996 )
441 $
'Q ', ( qval(i), i = 1,
min(ngrids, 10) )
442 IF( ngrids.GT.10 )
443 $ WRITE( nout, fmt = 9997 ) ( qval(i), i = 11, ngrids )
444 WRITE( nout, fmt = * )
445 WRITE( nout, fmt = 9995 ) eps
446 WRITE( nout, fmt = 9998 ) thresh
447
448 ELSE
449
450
451
452 IF( nprocs.LT.1 )
453 $ CALL blacs_setup( iam, nprocs )
454
455
456
457
458 CALL blacs_get( -1, 0, ictxt )
459 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
460
461
462
464
465 CALL sgebr2d( ictxt, 'All', ' ', 1, 1, thresh, 1, 0, 0 )
466 CALL igebr2d( ictxt, 'All', ' ', 1, 1, i, 1, 0, 0 )
467 CALL igebr2d( ictxt, 'All', ' ', i, 1, work, i, 0, 0 )
468 i = 1
469 nmat = work( i )
470 i = i+1
471 nbw = work( i )
472 i = i+1
473 nnb = work( i )
474 i = i+1
475 nnr = work( i )
476 i = i+1
477 nnbr = work( i )
478 i = i+1
479 ngrids = work( i )
480 i = i+1
481 IF( work( i ) .EQ. 1 ) THEN
482 trans = 'N'
483 ELSE
484 trans = 'T'
485 END IF
486 i = i+1
487
488 i = nmat + nbw + nnb + nnr + nnbr + 2*ngrids
489 i = i + nbw
490
491 CALL igebr2d( ictxt, 'All', ' ', 1, i, work, 1, 0, 0 )
492 i = 1
493 CALL icopy( nmat, work( i ), 1, nval, 1 )
494 i = i + nmat
495 CALL icopy( nbw, work( i ), 1, bwlval, 1 )
496 i = i + nbw
497 CALL icopy( nbw, work( i ), 1, bwuval, 1 )
498 i = i + nbw
499 CALL icopy( nnb, work( i ), 1, nbval, 1 )
500 i = i + nnb
501 CALL icopy( nnr, work( i ), 1, nrval, 1 )
502 i = i + nnr
503 CALL icopy( nnbr, work( i ), 1, nbrval, 1 )
504 i = i + nnbr
505 CALL icopy( ngrids, work( i ), 1, pval, 1 )
506 i = i + ngrids
507 CALL icopy( ngrids, work( i ), 1, qval, 1 )
508
509 END IF
510
511 CALL blacs_gridexit( ictxt )
512
513 RETURN
514
515 20 WRITE( nout, fmt = 9993 )
516 CLOSE( nin )
517 IF( nout.NE.6 .AND. nout.NE.0 )
518 $ CLOSE( nout )
519
520 CALL blacs_abort( ictxt, 1 )
521 stop
522
523 9999 FORMAT( a )
524 9998 FORMAT( 'Routines pass computational tests if scaled residual ',
525 $ 'is less than ', g12.5 )
526 9997 FORMAT( ' ', 10i6 )
527 9996 FORMAT( 2x, a5, ': ', 10i6 )
528 9995 FORMAT( 'Relative machine precision (eps) is taken to be ',
529 $ e18.6 )
530 9994 FORMAT( ' Number of values of ',5a, ' is less than 1 or greater ',
531 $ 'than ', i2 )
532 9993 FORMAT( ' Illegal input in file ',40a,'. Aborting run.' )
533
534
535
subroutine icopy(n, sx, incx, sy, incy)
double precision function pdlamch(ictxt, cmach)