5
6
7
8
9
10
11
12 INTEGER IAM, LDMTYP, LDNBVAL, LDNVAL, LDPVAL, LDQVAL,
13 $ NGRIDS, NMAT, NMTYP, NNB, NOUT, NPROCS
14 REAL THRESH
15
16
17 CHARACTER*3 MATTYP( LDMTYP )
18 CHARACTER*( * ) SUMMRY
19 INTEGER NBVAL( LDNBVAL ), NVAL( 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
111
112
113
114
115
116
117
118
119 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
120 $ LLD_, MB_, M_, NB_, N_, RSRC_
121 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
122 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
123 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
124 INTEGER NIN
125 parameter( nin = 11 )
126
127
128 CHARACTER*79 USRINFO
129 INTEGER I, ICTXT, K
130 DOUBLE PRECISION EPS
131
132
133 EXTERNAL blacs_abort, blacs_get, blacs_gridexit,
134 $ blacs_gridinit, blacs_setup,
icopy, igebr2d,
135 $ igebs2d, sgebr2d, sgebs2d
136
137
138 LOGICAL LSAMEN
139 DOUBLE PRECISION PDLAMCH
141
142
144
145
146
147
148
149
150 IF( iam.EQ.0 ) THEN
151
152
153
154 OPEN( nin, file='INV.dat', status='OLD' )
155 READ( nin, fmt = * ) summry
156 summry = ' '
157
158
159
160 READ( nin, fmt = 9999 ) usrinfo
161
162
163
164 READ( nin, fmt = * ) summry
165 READ( nin, fmt = * ) nout
166 IF( nout.NE.0 .AND. nout.NE.6 )
167 $ OPEN( nout, file = summry, status = 'UNKNOWN' )
168
169
170
171
172
173 READ( nin, fmt = * ) nmtyp
174 IF( nmtyp.LT.1 .OR. nmtyp.GT.ldmtyp ) THEN
175 WRITE( nout, fmt = 9994 ) 'nb of matrix types', ldmtyp
176 GO TO 40
177 END IF
178 READ( nin, fmt = * ) ( mattyp( i ), i = 1, nmtyp )
179
180
181
182 READ( nin, fmt = * ) nmat
183 IF( nmat.LT.1 .OR. nmat.GT.ldnval ) THEN
184 WRITE( nout, fmt = 9994 ) 'N', ldnval
185 GO TO 40
186 END IF
187 READ( nin, fmt = * ) ( nval( i ), i = 1, nmat )
188
189
190
191 READ( nin, fmt = * ) nnb
192 IF( nnb.LT.1 .OR. nnb.GT.ldnbval ) THEN
193 WRITE( nout, fmt = 9994 ) 'NB', ldnbval
194 GO TO 40
195 END IF
196 READ( nin, fmt = * ) ( nbval( i ), i = 1, nnb )
197
198
199
200 READ( nin, fmt = * ) ngrids
201 IF( ngrids.LT.1 .OR. ngrids.GT.ldpval ) THEN
202 WRITE( nout, fmt = 9994 ) 'Grids', ldpval
203 GO TO 40
204 ELSE IF( ngrids.GT.ldqval ) THEN
205 WRITE( nout, fmt = 9994 ) 'Grids', ldqval
206 GO TO 40
207 END IF
208
209
210
211 READ( nin, fmt = * ) ( pval( i ), i = 1, ngrids )
212 READ( nin, fmt = * ) ( qval( i ), i = 1, ngrids )
213
214
215
216 READ( nin, fmt = * ) thresh
217
218
219
220 CLOSE( nin )
221
222
223
224
225 IF( nprocs.LT.1 ) THEN
226 nprocs = 0
227 DO 10 i = 1, ngrids
228 nprocs =
max( nprocs, pval( i ) * qval( i ) )
229 10 CONTINUE
230 CALL blacs_setup( iam, nprocs )
231 END IF
232
233
234
235
236 CALL blacs_get( -1, 0, ictxt )
237 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
238
239
240
242
243
244
245 CALL sgebs2d( ictxt, 'All', ' ', 1, 1, thresh, 1 )
246 work( 1 ) = nmat
247 work( 2 ) = nnb
248 work( 3 ) = ngrids
249 work( 4 ) = nmtyp
250 CALL igebs2d( ictxt, 'All', ' ', 4, 1, work, 4 )
251
252 i = 1
253 DO 20 k = 1, nmtyp
254 IF(
lsamen( 3, mattyp( k ),
'GEN' ) )
THEN
255 work( i ) = 1
256 i = i + 1
257 ELSE IF(
lsamen( 3, mattyp( k ),
'UTR' ) )
THEN
258 work( i ) = 2
259 i = i + 1
260 ELSE IF(
lsamen( 3, mattyp( k ),
'LTR' ) )
THEN
261 work( i ) = 3
262 i = i + 1
263 ELSE IF(
lsamen( 3, mattyp( k ),
'UPD' ) )
THEN
264 work( i ) = 4
265 i = i + 1
266 ELSE IF(
lsamen( 3, mattyp( k ),
'LPD' ) )
THEN
267 work( i ) = 5
268 i = i + 1
269 END IF
270 20 CONTINUE
271
272 CALL icopy( nmat, nval, 1, work( i ), 1 )
273 i = i + nmat
274 CALL icopy( nnb, nbval, 1, work( i ), 1 )
275 i = i + nnb
276 CALL icopy( ngrids, pval, 1, work( i ), 1 )
277 i = i + ngrids
278 CALL icopy( ngrids, qval, 1, work( i ), 1 )
279 i = i + ngrids - 1
280 CALL igebs2d( ictxt, 'All', ' ', i, 1, work, i )
281
282
283
284 WRITE( nout, fmt = 9999 )
285 $ 'SCALAPACK Matrix Inversion routines.'
286 WRITE( nout, fmt = 9999 ) usrinfo
287 WRITE( nout, fmt = * )
288 WRITE( nout, fmt = 9999 )
289 $ 'Tests of the parallel '//
290 $ 'complex single precision Matrix Inversion '//
291 $ 'routines.'
292 WRITE( nout, fmt = 9999 )
293 $ 'The following scaled residual '//
294 $ 'checks will be computed:'
295 WRITE( nout, fmt = 9999 )
296 $ ' Inverse residual = ||inv(A)*A - I|| '//
297 $ '/ (||A|| * eps * N)'
298 WRITE( nout, fmt = 9999 )
299 $ 'The matrix A is randomly '//
300 $ 'generated for each test.'
301 WRITE( nout, fmt = * )
302 WRITE( nout, fmt = 9999 )
303 $ 'An explanation of the input/output '//
304 $ 'parameters follows:'
305 WRITE( nout, fmt = 9999 )
306 $ 'TIME : Indicates whether WALL or '//
307 $ 'CPU time was used.'
308
309 WRITE( nout, fmt = 9999 )
310 $ 'N : The number of rows and columns '//
311 $ 'of the matrix A.'
312 WRITE( nout, fmt = 9999 )
313 $ 'NB : The size of the square blocks'//
314 $ ' the matrix A is split into.'
315 WRITE( nout, fmt = 9999 )
316 $ 'P : The number of process rows.'
317 WRITE( nout, fmt = 9999 )
318 $ 'Q : The number of process columns.'
319 WRITE( nout, fmt = 9999 )
320 $ 'THRESH : If a residual value is less '//
321 $ 'than THRESH, CHECK is flagged as PASSED.'
322 WRITE( nout, fmt = 9999 )
323 $ 'Fct time : Time in seconds to factor the'//
324 $ ' matrix, if needed.'
325 WRITE( nout, fmt = 9999 )
326 $ 'Inv Time : Time in seconds to inverse the'//
327 $ ' matrix.'
328 WRITE( nout, fmt = 9999 )
329 $ 'MFLOPS : Rate of execution for factor '//
330 $ 'and inverse.'
331 WRITE( nout, fmt = * )
332 WRITE( nout, fmt = 9999 )
333 $ 'The following parameter values will be used:'
334 WRITE( nout, fmt = 9996 )
335 $
'N ', ( nval( i ), i = 1,
min( nmat, 10 ) )
336 IF( nmat.GT.10 )
337 $ WRITE( nout, fmt = 9997 ) ( nval( i ), i = 11, nmat )
338 WRITE( nout, fmt = 9996 )
339 $
'NB ', ( nbval( i ), i = 1,
min( nnb, 10 ) )
340 IF( nnb.GT.10 )
341 $ WRITE( nout, fmt = 9997 ) ( nbval( i ), i = 11, nnb )
342 WRITE( nout, fmt = 9996 )
343 $
'P ', ( pval( i ), i = 1,
min( ngrids, 10 ) )
344 IF( ngrids.GT.10 )
345 $ WRITE( nout, fmt = 9997) ( pval( i ), i = 11, ngrids )
346 WRITE( nout, fmt = 9996 )
347 $
'Q ', ( qval( i ), i = 1,
min( ngrids, 10 ) )
348 IF( ngrids.GT.10 )
349 $ WRITE( nout, fmt = 9997 ) ( qval( i ), i = 11, ngrids )
350 WRITE( nout, fmt = 9995 ) eps
351 WRITE( nout, fmt = 9998 ) thresh
352
353 ELSE
354
355
356
357 IF( nprocs.LT.1 )
358 $ CALL blacs_setup( iam, nprocs )
359
360
361
362
363 CALL blacs_get( -1, 0, ictxt )
364 CALL blacs_gridinit( ictxt, 'Row-major', 1, nprocs )
365
366
367
369
370 CALL sgebr2d( ictxt, 'All', ' ', 1, 1, thresh, 1, 0, 0 )
371 CALL igebr2d( ictxt, 'All', ' ', 4, 1, work, 4, 0, 0 )
372 nmat = work( 1 )
373 nnb = work( 2 )
374 ngrids = work( 3 )
375 nmtyp = work( 4 )
376
377 i = nmtyp+nmat+nnb+2*ngrids
378 CALL igebr2d( ictxt, 'All', ' ', i, 1, work, i, 0, 0 )
379
380 DO 30 k = 1, nmtyp
381 IF( work( k ).EQ.1 ) THEN
382 mattyp( k ) = 'GEN'
383 ELSE IF( work( k ).EQ.2 ) THEN
384 mattyp( k ) = 'UTR'
385 ELSE IF( work( k ).EQ.3 ) THEN
386 mattyp( k ) = 'LTR'
387 ELSE IF( work( k ).EQ.4 ) THEN
388 mattyp( k ) = 'UPD'
389 ELSE IF( work( k ).EQ.5 ) THEN
390 mattyp( k ) = 'LPD'
391 END IF
392 30 CONTINUE
393
394 i = nmtyp + 1
395 CALL icopy( nmat, work( i ), 1, nval, 1 )
396 i = i + nmat
397 CALL icopy( nnb, work( i ), 1, nbval, 1 )
398 i = i + nnb
399 CALL icopy( ngrids, work( i ), 1, pval, 1 )
400 i = i + ngrids
401 CALL icopy( ngrids, work( i ), 1, qval, 1 )
402
403 END IF
404
405 CALL blacs_gridexit( ictxt )
406
407 RETURN
408
409 40 WRITE( nout, fmt = 9993 )
410 CLOSE( nin )
411 IF( nout.NE.6 .AND. nout.NE.0 )
412 $ CLOSE( nout )
413 CALL blacs_abort( ictxt, 1 )
414
415 stop
416
417 9999 FORMAT( a )
418 9998 FORMAT( 'Routines pass computational tests if scaled residual ',
419 $ 'is less than ', g12.5 )
420 9997 FORMAT( ' ', 10i6 )
421 9996 FORMAT( 2x, a5, ' : ', 10i6 )
422 9995 FORMAT( 'Relative machine precision (eps) is taken to be ',
423 $ e18.6 )
424 9994 FORMAT( ' Number of values of ',5a, ' is less than 1 or greater ',
425 $ 'than ', i2 )
426 9993 FORMAT( ' Illegal input in file ',40a,'. Aborting run.' )
427
428
429
subroutine icopy(n, sx, incx, sy, incy)
logical function lsamen(n, ca, cb)
double precision function pdlamch(ictxt, cmach)