64 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dt_,
65 $ lld_, mb_, m_, nb_, n_, rsrc_
66 parameter( block_cyclic_2d = 1, dlen_ = 9, dt_ = 1,
67 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
68 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
69 INTEGER cplxsz, totmem, memsiz, ntests
70 parameter( cplxsz = 16, totmem = 200000000,
71 $ memsiz = totmem / cplxsz, ntests = 20 )
72 COMPLEX padval, zero, one
73 parameter( padval = ( -9923.0e+0, -9923.0e+0 ),
74 $ zero = ( 0.0e+0, 0.0e+0 ),
75 $ one = ( 1.0e+0, 0.0e+0 ) )
81 INTEGER i, iam, iaseed, ictxt, iii, imidpad, info, ipa,
82 $ ipostpad, iprepad, ipw, ipwr, ipc, j, k, kfail,
83 $ kpass, kskip, ktests, lda, ldwork, ldz, lwork,
84 $ mycol, myrow, n, nb, ngrids, nmat, nnb, nout,
85 $ np, npcol, nprocs, nprow, nq, worksiz
87 REAL anorm, fresid, qresid, znorm
88 DOUBLE PRECISION nops, tmflops
91 INTEGER desca( dlen_ ), descz( dlen_ ), idum( 1 ),
92 $ ierr( 2 ), nbval( ntests ), nval( ntests ),
93 $ pval( ntests ), qval( ntests )
94 DOUBLE PRECISION ctime( 2 ), wtime( 2 )
98 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
99 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
114 DATA kfail, kpass, kskip, ktests / 4*0 /
120 CALL blacs_pinfo( iam, nprocs )
122 CALL pcnepinfo( outfile, nout, nmat, nval, ntests, nnb, nbval,
123 $ ntests, ngrids, pval, ntests, qval, ntests,
124 $ thresh, mem, iam, nprocs )
125 check = ( thresh.GE.0.0e+0 )
130 WRITE( nout, fmt = * )
131 WRITE( nout, fmt = 9995 )
132 WRITE( nout, fmt = 9994 )
133 WRITE( nout, fmt = * )
146 IF( nprow.LT.1 )
THEN
148 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
150 ELSE IF( npcol.LT.1 )
THEN
152 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
154 ELSE IF( nprow*npcol.GT.nprocs )
THEN
156 $
WRITE( nout, fmt = 9998 )nprow*npcol, nprocs
160 IF( ierr( 1 ).GT.0 )
THEN
162 $
WRITE( nout, fmt = 9997 )
'grid'
169 CALL blacs_get( -1, 0, ictxt )
170 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
171 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
176 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
188 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
194 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
196 IF( ierr( 1 ).GT.0 )
THEN
198 $
WRITE( nout, fmt = 9997 )
'matrix'
213 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
218 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
220 IF( ierr( 1 ).GT.0 )
THEN
222 $
WRITE( nout, fmt = 9997 )
'NB'
229 np =
numroc( n, nb, myrow, 0, nprow )
230 nq =
numroc( n, nb, mycol, 0, npcol )
232 iprepad =
max( nb, np )
234 ipostpad =
max( nb, nq )
235 iprepad = iprepad + 1000
236 imidpad = imidpad + 1000
237 ipostpad = ipostpad + 1000
246 CALL descinit( desca, n, n, nb, nb, 0, 0, ictxt,
247 $
max( 1, np )+imidpad, ierr( 1 ) )
251 CALL descinit( descz, n, n, nb, nb, 0, 0, ictxt,
252 $
max( 1, np )+imidpad, ierr( 2 ) )
256 ldwork = descz( lld_ )
260 CALL igsum2d( ictxt,
'All',
' ', 2, 1, ierr, 2, -1, 0 )
262 IF( ierr( 1 ).LT.0 .OR. ierr( 2 ).LT.0 )
THEN
264 $
WRITE( nout, fmt = 9997 )
'descriptor'
273 ipc = ipa + desca( lld_ )*nq + ipostpad + iprepad
274 ipwr = ipc + descz( lld_ )*nq + ipostpad + iprepad
275 ipw = ipwr + descz( lld_ )*nq + ipostpad + iprepad
279 iii = 7*iii /
ilcm( nprow, npcol )
282 lwork = 3*n +
max( 2*
max( lda, ldz )+2*nq, iii )
283 lwork = lwork +
max( 2*n, ( 8*
ilcm( nprow, npcol )+2 )**
291 worksiz = lwork +
max( np*desca( nb_ ),
292 $ desca( mb_ )*nq ) + ipostpad
296 worksiz = lwork + ipostpad
303 IF( ipw+worksiz.GT.memsiz )
THEN
305 $
WRITE( nout, fmt = 9996 )
'Schur reduction',
306 $ ( ipw+worksiz )*cplxsz
312 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
314 IF( ierr( 1 ).GT.0 )
THEN
316 $
WRITE( nout, fmt = 9997 )
'MEMORY'
323 CALL pclaset(
'All', n, n, zero, one, mem( ipc ), 1, 1,
328 CALL pcmatgen( ictxt,
'No transpose',
'No transpose',
329 $ desca( m_ ), desca( n_ ), desca( mb_ ),
330 $ desca( nb_ ), mem( ipa ), desca( lld_ ),
331 $ desca( rsrc_ ), desca( csrc_ ), iaseed, 0,
332 $ np, 0, nq, myrow, mycol, nprow, npcol )
334 $ zero, zero, mem( ipa ),
min( n, 3 ), 1,
340 CALL pcfillpad( ictxt, np, nq, mem( ipa-iprepad ),
341 $ desca( lld_ ), iprepad, ipostpad,
343 CALL pcfillpad( ictxt, np, nq, mem( ipc-iprepad ),
344 $ descz( lld_ ), iprepad, ipostpad,
346 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
347 $ mem( ipw-iprepad ), worksiz-ipostpad,
348 $ iprepad, ipostpad, padval )
349 anorm =
pclanhs(
'I', n, mem( ipa ), 1, 1, desca,
351 CALL pcchekpad( ictxt,
'PCLANHS', np, nq,
352 $ mem( ipa-iprepad ), desca( lld_ ),
353 $ iprepad, ipostpad, padval )
354 CALL pcchekpad( ictxt,
'PCLANHS', worksiz-ipostpad, 1,
355 $ mem( ipw-iprepad ), worksiz-ipostpad,
356 $ iprepad, ipostpad, padval )
358 CALL pcfillpad( ictxt, n, 1, mem( ipwr-iprepad ), n,
359 $ iprepad, ipostpad, padval )
360 CALL pcfillpad( ictxt, lwork, 1, mem( ipw-iprepad ),
361 $ lwork, iprepad, ipostpad, padval )
366 CALL blacs_barrier( ictxt,
'All' )
371 CALL pclahqr( .true., .true., n, 1, n, mem( ipa ), desca,
372 $ mem( ipwr ), 1, n, mem( ipc ), descz,
373 $ mem( ipw ), lwork, idum, 0, info )
379 $
WRITE( nout, fmt = * )
'PCLAHQR INFO=', info
388 CALL pcchekpad( ictxt,
'PCLAHQR (A)', np, nq,
389 $ mem( ipa-iprepad ), desca( lld_ ),
390 $ iprepad, ipostpad, padval )
391 CALL pcchekpad( ictxt,
'PCLAHQR (Z)', np, nq,
392 $ mem( ipc-iprepad ), descz( lld_ ),
393 $ iprepad, ipostpad, padval )
394 CALL pcchekpad( ictxt,
'PCLAHQR (WR)', n, 1,
395 $ mem( ipwr-iprepad ), n, iprepad,
397 CALL pcchekpad( ictxt,
'PCLAHQR (WORK)', lwork, 1,
398 $ mem( ipw-iprepad ), lwork, iprepad,
401 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
402 $ mem( ipw-iprepad ), worksiz-ipostpad,
403 $ iprepad, ipostpad, padval )
407 CALL pcnepfchk( n, mem( ipa ), 1, 1, desca, iaseed,
408 $ mem( ipc ), 1, 1, descz, anorm,
409 $ fresid, mem( ipw ) )
411 CALL pcchekpad( ictxt,
'PCNEPFCHK (A)', np, nq,
412 $ mem( ipa-iprepad ), desca( lld_ ),
413 $ iprepad, ipostpad, padval )
414 CALL pcchekpad( ictxt,
'PCNEPFCHK (Z)', np, nq,
415 $ mem( ipc-iprepad ), descz( lld_ ),
416 $ iprepad, ipostpad, padval )
417 CALL pcchekpad( ictxt,
'PCNEPFCHK (WORK)',
418 $ worksiz-ipostpad, 1,
419 $ mem( ipw-iprepad ), worksiz-ipostpad,
420 $ iprepad, ipostpad, padval )
424 CALL pclaset(
'All', n, n, zero, one, mem( ipa ), 1,
426 CALL pcgemm(
'Cong Tran',
'No transpose', n, n, n,
427 $ -one, mem( ipc ), 1, 1, descz,
428 $ mem( ipc ), 1, 1, descz, one, mem( ipa ),
430 znorm =
pclange(
'1', n, n, mem( ipa ), 1, 1, desca,
432 qresid = znorm / ( real( n )*
pslamch( ictxt,
'P' ) )
436 IF( ( fresid.LE.thresh ) .AND.
437 $ ( ( fresid-fresid ).EQ.0.0e+0 ) .AND.
438 $ ( qresid.LE.thresh ) .AND.
439 $ ( ( qresid-qresid ).EQ.0.0e+0 ) )
THEN
446 WRITE( nout, fmt = 9986 )fresid
447 WRITE( nout, fmt = 9985 )qresid
456 fresid = fresid - fresid
457 qresid = qresid - qresid
464 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1, wtime )
465 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1, ctime )
469 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
473 nops = 18.0d+0*dble( n )**3
480 IF( wtime( 1 ).GT.0.0d+0 )
THEN
481 tmflops = nops / ( wtime( 1 )*1.0d+6 )
485 IF( wtime( 1 ).GE.0.0d+0 )
486 $
WRITE( nout, fmt = 9993 )
'WALL', n, nb, nprow,
487 $ npcol, wtime( 1 ), tmflops, passed
491 IF( ctime( 1 ).GT.0.0d+0 )
THEN
492 tmflops = nops / ( ctime( 1 )*1.0d+6 )
497 IF( ctime( 1 ).GE.0.0d+0 )
498 $
WRITE( nout, fmt = 9993 )
'CPU ', n, nb, nprow,
499 $ npcol, ctime( 1 ), tmflops, passed
506 CALL blacs_gridexit( ictxt )
513 ktests = kpass + kfail + kskip
514 WRITE( nout, fmt = * )
515 WRITE( nout, fmt = 9992 )ktests
517 WRITE( nout, fmt = 9991 )kpass
518 WRITE( nout, fmt = 9989 )kfail
520 WRITE( nout, fmt = 9990 )kpass
522 WRITE( nout, fmt = 9988 )kskip
523 WRITE( nout, fmt = * )
524 WRITE( nout, fmt = * )
525 WRITE( nout, fmt = 9987 )
526 IF( nout.NE.6 .AND. nout.NE.0 )
532 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
533 $
'; It should be at least 1' )
534 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
536 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
537 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
539 9995
FORMAT(
'TIME N NB P Q NEP Time MFLOPS CHECK' )
540 9994
FORMAT(
'---- ----- --- ---- ---- -------- -------- ------' )
541 9993
FORMAT( a4, 1x, i5, 1x, i3, 1x, i4, 1x, i4, 1x, f8.2, 1x, f8.2,
543 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
544 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
545 9990
FORMAT( i5,
' tests completed without checking.' )
546 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
547 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
548 9987
FORMAT(
'END OF TESTS.' )
549 9986
FORMAT(
'||H - Q*S*Q^T|| / (||H|| * N * eps) = ', g25.7 )
550 9985
FORMAT(
'||Q^T*Q - I|| / ( N * eps ) ', g25.7 )