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
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
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 )
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 $ 'real double 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.GT. IF( NGRIDS10 )
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.GT. IF( NGRIDS10 )
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.LT. IF( NPROCS1 )
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
368 EPS = PDLAMCH( ICTXT, 'eps' )
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.EQ. IF( WORK( K )1 ) THEN
382 MATTYP( K ) = 'gen'
383.EQ. ELSE IF( WORK( K )2 ) THEN
384 MATTYP( K ) = 'utr'
385.EQ. ELSE IF( WORK( K )3 ) THEN
386 MATTYP( K ) = 'ltr'
387.EQ. ELSE IF( WORK( K )4 ) THEN
388 MATTYP( K ) = 'upd'
389.EQ. ELSE IF( WORK( K )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.NE..AND..NE. IF( NOUT6 NOUT0 )
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
logical function lsamen(n, ca, cb)
LSAMEN
subroutine icopy(n, sx, incx, sy, incy)
ICOPY
subroutine sgebs2d(contxt, scope, top, m, n, a, lda)
subroutine blacs_gridinit(cntxt, c, nprow, npcol)
subroutine sgebr2d(contxt, scope, top, m, n, a, lda)
subroutine blacs_gridexit(cntxt)
double precision function pdlamch(ictxt, cmach)