5
6
7
8
9
10
11
12 LOGICAL EST
13 CHARACTER*( * ) SUMMRY
14 INTEGER IAM, LDNBRVAL, LDNBVAL, LDNRVAL, LDNVAL,
15 $ LDPVAL, LDQVAL, NGRIDS, NMAT, NNB, NNBR,
16 $ NPROCS, NNR, NOUT
17 REAL THRESH
18
19
20 INTEGER MVAL( LDNVAL ), NBRVAL( LDNBRVAL ),
21 $ NBVAL( LDNBVAL ), NRVAL( LDNRVAL ),
22 $ NVAL( LDNVAL ), PVAL( LDPVAL ), QVAL( LDQVAL ),
23 $ WORK( * )
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
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 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
139 $ LLD_, MB_, M_, NB_, N_, RSRC_
140 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
141 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
142 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
143 INTEGER NIN
144 parameter( nin = 11 )
145
146
147 CHARACTER*79 USRINFO
148 INTEGER I, ICTXT
149 DOUBLE PRECISION EPS
150
151
152 EXTERNAL blacs_abort, blacs_get, blacs_gridexit,
153 $ blacs_gridinit, blacs_setup,
icopy, igebr2d,
154 $ igebs2d, sgebr2d, sgebs2d
155
156
157 DOUBLE PRECISION PDLAMCH
159
160
162
163
164
165
166
167
168 IF( iam.EQ.0 ) THEN
169
170
171
172 OPEN( nin, file='LU.dat', status='OLD' )
173 READ( nin, fmt = * ) summry
174 summry = ' '
175
176
177
178 READ( nin, fmt = 9999 ) usrinfo
179
180
181
182 READ( nin, fmt = * ) summry
183 READ( nin, fmt = * ) nout
184 IF( nout.NE.0 .AND. nout.NE.6 )
185 $ OPEN( nout, file = summry, status = 'UNKNOWN' )
186
187
188
189
190
191 READ( nin, fmt = * ) nmat
192 IF( nmat.LT.1 .OR. nmat.GT.ldnval ) THEN
193 WRITE( nout, fmt = 9994 ) 'N', ldnval
194 GO TO 20
195 END IF
196 READ( nin, fmt = * ) ( mval( i ), i = 1, nmat )
197 READ( nin, fmt = * ) ( nval( i ), i = 1, nmat )
198
199
200
201 READ( nin, fmt = * ) nnb
202 IF( nnb.LT.1 .OR. nnb.GT.ldnbval ) THEN
203 WRITE( nout, fmt = 9994 ) 'NB', ldnbval
204 GO TO 20
205 END IF
206 READ( nin, fmt = * ) ( nbval( i ), i = 1, nnb )
207
208
209
210 READ( nin, fmt = * ) nnr
211 IF( nnr.LT.1 .OR. nnr.GT.ldnrval ) THEN
212 WRITE( nout, fmt = 9994 ) 'NRHS', ldnrval
213 GO TO 20
214 END IF
215 READ( nin, fmt = * ) ( nrval( i ), i = 1, nnr )
216
217
218
219 READ( nin, fmt = * ) nnbr
220 IF( nnbr.LT.1 .OR. nnbr.GT.ldnbrval ) THEN
221 WRITE( nout, fmt = 9994 ) 'NBRHS', ldnbrval
222 GO TO 20
223 END IF
224 READ( nin, fmt = * ) ( nbrval( i ), i = 1, nnbr )
225
226
227
228 READ( nin, fmt = * ) ngrids
229 IF( ngrids.LT.1 .OR. ngrids.GT.ldpval ) THEN
230 WRITE( nout, fmt = 9994 ) 'Grids', ldpval
231 GO TO 20
232 ELSE IF( ngrids.GT.ldqval ) THEN
233 WRITE( nout, fmt = 9994 ) 'Grids', ldqval
234 GO TO 20
235 END IF
236
237
238
239 READ( nin, fmt = * ) ( pval( i ), i = 1, ngrids )
240 READ( nin, fmt = * ) ( qval( i ), i = 1, ngrids )
241
242
243
244 READ( nin, fmt = * ) thresh
245
246
247
248
249 READ( nin, fmt = * ) est
250
251
252
253 CLOSE( nin )
254
255
256
257
258 IF( nprocs.LT.1 ) THEN
259 nprocs = 0
260 DO 10 i = 1, ngrids
261 nprocs =
max( nprocs, pval( i )*qval( i ) )
262 10 CONTINUE
263 CALL blacs_setup( iam, nprocs )
264 END IF
265
266
267
268
269 CALL blacs_get( -1, 0, ictxt )
270 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
271
272
273
275
276
277
278 CALL sgebs2d( ictxt, 'All', ' ', 1, 1, thresh, 1 )
279
280 work( 1 ) = nmat
281 work( 2 ) = nnb
282 work( 3 ) = nnr
283 work( 4 ) = nnbr
284 work( 5 ) = ngrids
285 IF( est ) THEN
286 work( 6 ) = 1
287 ELSE
288 work( 6 ) = 0
289 END IF
290 CALL igebs2d( ictxt, 'All', ' ', 6, 1, work, 6 )
291
292 i = 1
293 CALL icopy( nmat, mval, 1, work( i ), 1 )
294 i = i + nmat
295 CALL icopy( nmat, nval, 1, work( i ), 1 )
296 i = i + nmat
297 CALL icopy( nnb, nbval, 1, work( i ), 1 )
298 i = i + nnb
299 CALL icopy( nnr, nrval, 1, work( i ), 1 )
300 i = i + nnr
301 CALL icopy( nnbr, nbrval, 1, work( i ), 1 )
302 i = i + nnbr
303 CALL icopy( ngrids, pval, 1, work( i ), 1 )
304 i = i + ngrids
305 CALL icopy( ngrids, qval, 1, work( i ), 1 )
306 i = i + ngrids - 1
307 CALL igebs2d( ictxt, 'All', ' ', i, 1, work, i )
308
309
310
311 WRITE( nout, fmt = 9999 )
312 $ 'ScaLAPACK Ax=b by LU factorization.'
313 WRITE( nout, fmt = 9999 ) usrinfo
314 WRITE( nout, fmt = * )
315 WRITE( nout, fmt = 9999 )
316 $ 'Tests of the parallel '//
317 $ 'complex double precision LU factorization '//
318 $ 'and solve.'
319 WRITE( nout, fmt = 9999 )
320 $ 'The following scaled residual '//
321 $ 'checks will be computed:'
322 WRITE( nout, fmt = 9999 )
323 $ ' Solve residual = ||Ax - b|| / '//
324 $ '(||x|| * ||A|| * eps * N)'
325 WRITE( nout, fmt = 9999 )
326 $ ' Factorization residual = ||A - LU|| / '//
327 $ '(||A|| * eps * N)'
328 WRITE( nout, fmt = 9999 )
329 $ 'The matrix A is randomly '//
330 $ 'generated for each test.'
331 WRITE( nout, fmt = * )
332 WRITE( nout, fmt = 9999 )
333 $ 'An explanation of the input/output '//
334 $ 'parameters follows:'
335 WRITE( nout, fmt = 9999 )
336 $ 'TIME : Indicates whether WALL or '//
337 $ 'CPU time was used.'
338
339 WRITE( nout, fmt = 9999 )
340 $ 'M : The number of rows in the '//
341 $ 'matrix A.'
342 WRITE( nout, fmt = 9999 )
343 $ 'N : The number of columns in the '//
344 $ 'matrix A.'
345 WRITE( nout, fmt = 9999 )
346 $ 'NB : The size of the square blocks the'//
347 $ ' matrix A is split into.'
348 WRITE( nout, fmt = 9999 )
349 $ 'NRHS : The total number of RHS to solve'//
350 $ ' for.'
351 WRITE( nout, fmt = 9999 )
352 $ 'NBRHS : The number of RHS to be put on '//
353 $ 'a column of processes before going'
354 WRITE( nout, fmt = 9999 )
355 $ ' on to the next column of processes.'
356 WRITE( nout, fmt = 9999 )
357 $ 'P : The number of process rows.'
358 WRITE( nout, fmt = 9999 )
359 $ 'Q : The number of process columns.'
360 WRITE( nout, fmt = 9999 )
361 $ 'THRESH : If a residual value is less than'//
362 $ ' THRESH, CHECK is flagged as PASSED'
363 WRITE( nout, fmt = 9999 )
364 $ 'LU time : Time in seconds to factor the'//
365 $ ' matrix'
366 WRITE( nout, fmt = 9999 )
367 $ 'Sol Time: Time in seconds to solve the'//
368 $ ' system.'
369 WRITE( nout, fmt = 9999 )
370 $ 'MFLOPS : Rate of execution for factor '//
371 $ 'and solve.'
372 WRITE( nout, fmt = * )
373 WRITE( nout, fmt = 9999 )
374 $ 'The following parameter values will be used:'
375 WRITE( nout, fmt = 9996 )
376 $
'M ', ( mval(i), i = 1,
min(nmat, 10) )
377 IF( nmat.GT.10 )
378 $ WRITE( nout, fmt = 9997 ) ( mval(i), i = 11, nmat )
379 WRITE( nout, fmt = 9996 )
380 $
'N ', ( nval(i), i = 1,
min(nmat, 10) )
381 IF( nmat.GT.10 )
382 $ WRITE( nout, fmt = 9997 ) ( nval(i), i = 11, nmat )
383 WRITE( nout, fmt = 9996 )
384 $
'NB ', ( nbval(i), i = 1,
min(nnb, 10) )
385 IF( nnb.GT.10 )
386 $ WRITE( nout, fmt = 9997 ) ( nbval(i), i = 11, nnb )
387 WRITE( nout, fmt = 9996 )
388 $
'NRHS ', ( nrval(i), i = 1,
min(nnr, 10) )
389 IF( nnr.GT.10 )
390 $ WRITE( nout, fmt = 9997 ) ( nrval(i), i = 11, nnr )
391 WRITE( nout, fmt = 9996 )
392 $
'NBRHS', ( nbrval(i), i = 1,
min(nnbr, 10) )
393 IF( nnbr.GT.10 )
394 $ WRITE( nout, fmt = 9997 ) ( nbrval(i), i = 11, nnbr )
395 WRITE( nout, fmt = 9996 )
396 $
'P ', ( pval(i), i = 1,
min(ngrids, 10) )
397 IF( ngrids.GT.10 )
398 $ WRITE( nout, fmt = 9997) ( pval(i), i = 11, ngrids )
399 WRITE( nout, fmt = 9996 )
400 $
'Q ', ( qval(i), i = 1,
min(ngrids, 10) )
401 IF( ngrids.GT.10 )
402 $ WRITE( nout, fmt = 9997 ) ( qval(i), i = 11, ngrids )
403 WRITE( nout, fmt = * )
404 WRITE( nout, fmt = 9995 ) eps
405 WRITE( nout, fmt = 9998 ) thresh
406
407 ELSE
408
409
410
411 IF( nprocs.LT.1 )
412 $ CALL blacs_setup( iam, nprocs )
413
414
415
416
417 CALL blacs_get( -1, 0, ictxt )
418 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
419
420
421
423
424 CALL sgebr2d( ictxt, 'All', ' ', 1, 1, thresh, 1, 0, 0 )
425 CALL igebr2d( ictxt, 'All', ' ', 6, 1, work, 6, 0, 0 )
426 nmat = work( 1 )
427 nnb = work( 2 )
428 nnr = work( 3 )
429 nnbr = work( 4 )
430 ngrids = work( 5 )
431 IF( work( 6 ).EQ.1 ) THEN
432 est = .true.
433 ELSE
434 est = .false.
435 END IF
436
437 i = 2*nmat + nnb + nnr + nnbr + 2*ngrids
438 CALL igebr2d( ictxt, 'All', ' ', i, 1, work, i, 0, 0 )
439 i = 1
440 CALL icopy( nmat, work( i ), 1, mval, 1 )
441 i = i + nmat
442 CALL icopy( nmat, work( i ), 1, nval, 1 )
443 i = i + nmat
444 CALL icopy( nnb, work( i ), 1, nbval, 1 )
445 i = i + nnb
446 CALL icopy( nnr, work( i ), 1, nrval, 1 )
447 i = i + nnr
448 CALL icopy( nnbr, work( i ), 1, nbrval, 1 )
449 i = i + nnbr
450 CALL icopy( ngrids, work( i ), 1, pval, 1 )
451 i = i + ngrids
452 CALL icopy( ngrids, work( i ), 1, qval, 1 )
453
454 END IF
455
456 CALL blacs_gridexit( ictxt )
457
458 RETURN
459
460 20 WRITE( nout, fmt = 9993 )
461 CLOSE( nin )
462 IF( nout.NE.6 .AND. nout.NE.0 )
463 $ CLOSE( nout )
464 CALL blacs_abort( ictxt, 1 )
465
466 stop
467
468 9999 FORMAT( a )
469 9998 FORMAT( 'Routines pass computational tests if scaled residual ',
470 $ 'is less than ', g12.5 )
471 9997 FORMAT( ' ', 10i6 )
472 9996 FORMAT( 2x, a5, ' : ', 10i6 )
473 9995 FORMAT( 'Relative machine precision (eps) is taken to be ',
474 $ e18.6 )
475 9994 FORMAT( ' Number of values of ',5a, ' is less than 1 or greater ',
476 $ 'than ', i2 )
477 9993 FORMAT( ' Illegal input in file ',40a,'. Aborting run.' )
478
479
480
subroutine icopy(n, sx, incx, sy, incy)
double precision function pdlamch(ictxt, cmach)