1 SUBROUTINE pdsyntrd( UPLO, N, A, IA, JA, DESCA, D, E, TAU, WORK,
11 INTEGER IA, INFO, JA, LWORK, N
15 DOUBLE PRECISION A( * ), D( * ), E( * ), TAU( * ), WORK( * )
252 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
253 $ mb_, nb_, rsrc_, csrc_, lld_
254 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
255 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
256 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
258 parameter( one = 1.0d+0 )
261 LOGICAL LQUERY, UPPER
262 CHARACTER COLCTOP, ROWCTOP
263 INTEGER ANB, CTXTB, I, IACOL, IAROW, ICOFFA, ICTXT,
264 $ iinfo, indb, indd, inde, indtau, indw, ipw,
265 $ iroffa, j, jb, jx, k, kk, llwork, lwmin, minsz,
266 $ mycol, mycolb, myrow, myrowb, nb, np, npcol,
267 $ npcolb, nprow, nprowb, nps, nq, onepmin, sqnpc,
271 INTEGER DESCB( DLEN_ ), DESCW( DLEN_ ), IDUM1( 2 ),
275 EXTERNAL blacs_get, blacs_gridexit, blacs_gridinfo,
279 $ pb_topget, pb_topset,
pxerbla
283 INTEGER INDXG2L, INDXG2P, NUMROC, PJLAENV
284 EXTERNAL lsame, indxg2l, indxg2p, numroc, pjlaenv
287 INTRINSIC dble, ichar, int,
max,
min, mod, sqrt
292 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
296 ictxt = desca( ctxt_ )
297 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
302 IF( nprow.EQ.-1 )
THEN
303 info = -( 600+ctxt_ )
305 CALL chk1mat( n, 2, n, 2, ia, ja, desca, 6, info )
306 upper = lsame( uplo,
'U' )
309 iroffa = mod( ia-1, desca( mb_ ) )
310 icoffa = mod( ja-1, desca( nb_ ) )
311 iarow = indxg2p( ia, nb, myrow, desca( rsrc_ ), nprow )
312 iacol = indxg2p( ja, nb, mycol, desca( csrc_ ), npcol )
313 np = numroc( n, nb, myrow, iarow, nprow )
314 nq =
max( 1, numroc( n+ja-1, nb, mycol, desca( csrc_ ),
316 lwmin =
max( ( np+1 )*nb, 3*nb )
317 anb = pjlaenv( ictxt, 3,
'PDSYTTRD',
'L', 0, 0, 0, 0 )
318 minsz = pjlaenv( ictxt, 5,
'PDSYTTRD',
'L', 0, 0, 0, 0 )
319 sqnpc = int( sqrt( dble( nprow*npcol ) ) )
320 nps =
max( numroc( n, 1, 0, 0, sqnpc ), 2*anb )
321 ttlwmin = 2*( anb+1 )*( 4*nps+2 ) + ( nps+4 )*nps
323 work( 1 ) = dble( ttlwmin )
324 lquery = ( lwork.EQ.-1 )
325 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
331 ELSE IF( iroffa.NE.icoffa .OR. icoffa.NE.0 )
THEN
333 ELSE IF( desca( mb_ ).NE.desca( nb_ ) )
THEN
335 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
340 idum1( 1 ) = ichar(
'U' )
342 idum1( 1 ) = ichar(
'L' )
345 IF( lwork.EQ.-1 )
THEN
351 CALL pchk1mat( n, 2, n, 2, ia, ja, desca, 6, 2, idum1, idum2,
356 CALL pxerbla( ictxt,
'PDSYNTRD', -info )
358 ELSE IF( lquery )
THEN
368 onepmin = n*n + 3*n + 1
370 CALL igamn2d( ictxt,
'A',
' ', 1, 1, llwork, 1, 1, -1, -1, -1,
379 IF( ( n.LT.minsz .OR. sqnpc.EQ.1 ) .AND. llwork.GE.onepmin .AND.
384 IF( llwork.GE.ttlwmin .AND. .NOT.upper )
THEN
389 IF( nprowb.GE.1 )
THEN
393 indd = indb + nps*nps
397 llwork = llwork - indw + 1
399 CALL blacs_get( ictxt, 10, ctxtb )
400 CALL blacs_gridinit( ctxtb,
'Row major', sqnpc, sqnpc )
401 CALL blacs_gridinfo( ctxtb, nprowb, npcolb, myrowb, mycolb )
402 CALL descset( descb, n, n, 1, 1, 0, 0, ctxtb, nps )
404 CALL pdtrmr2d( uplo,
'N', n, n, a, ia, ja, desca, work( indb ),
405 $ 1, 1, descb, ictxt )
410 IF( nprowb.GT.0 )
THEN
412 IF( nprowb.EQ.1 )
THEN
413 CALL dsytrd( uplo, n, work( indb ), nps, work( indd ),
414 $ work( inde ), work( indtau ), work( indw ),
418 CALL pdsyttrd(
'L', n, work( indb ), 1, 1, descb,
419 $ work( indd ), work( inde ),
420 $ work( indtau ), work( indw ), llwork,
429 CALL pdlamr1d( n-1, work( inde ), 1, 1, descb, e, 1, ja,
432 CALL pdlamr1d( n, work( indd ), 1, 1, descb, d, 1, ja, desca )
434 CALL pdlamr1d( n, work( indtau ), 1, 1, descb, tau, 1, ja,
437 CALL pdtrmr2d( uplo,
'N', n, n, work( indb ), 1, 1, descb, a,
438 $ ia, ja, desca, ictxt )
441 $
CALL blacs_gridexit( ctxtb )
445 CALL pb_topget( ictxt,
'Combine',
'Columnwise', colctop )
446 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rowctop )
447 CALL pb_topset( ictxt,
'Combine',
'Columnwise',
'1-tree' )
448 CALL pb_topset( ictxt,
'Combine',
'Rowwise',
'1-tree' )
456 kk = mod( ja+n-1, nb )
459 CALL descset( descw, n, nb, nb, nb, iarow,
460 $ indxg2p( ja+n-kk, nb, mycol, desca( csrc_ ),
461 $ npcol ), ictxt,
max( 1, np ) )
463 DO 10 k = n - kk + 1, nb + 1, -nb
464 jb =
min( n-k+1, nb )
472 CALL pdlatrd( uplo, k+jb-1, jb, a, ia, ja, desca, d, e,
473 $ tau, work, 1, 1, descw, work( ipw ) )
479 CALL pdsyr2k( uplo,
'No transpose', k-1, jb, -one, a, ia,
480 $ j, desca, work, 1, 1, descw, one, a, ia,
485 jx =
min( indxg2l( j, nb, 0, iacol, npcol ), nq )
486 CALL pdelset( a, i-1, j, desca, e( jx ) )
488 descw( csrc_ ) = mod( descw( csrc_ )+npcol-1, npcol )
494 CALL pdsytd2( uplo,
min( n, nb ), a, ia, ja, desca, d, e,
495 $ tau, work, lwork, iinfo )
501 kk = mod( ja+n-1, nb )
504 CALL descset( descw, n, nb, nb, nb, iarow, iacol, ictxt,
507 DO 20 k = 1, n - nb, nb
515 CALL pdlatrd( uplo, n-k+1, nb, a, i, j, desca, d, e, tau,
516 $ work, k, 1, descw, work( ipw ) )
522 CALL pdsyr2k( uplo,
'No transpose', n-k-nb+1, nb, -one,
523 $ a, i+nb, j, desca, work, k+nb, 1, descw,
524 $ one, a, i+nb, j+nb, desca )
528 jx =
min( indxg2l( j+nb-1, nb, 0, iacol, npcol ), nq )
529 CALL pdelset( a, i+nb, j+nb-1, desca, e( jx ) )
531 descw( csrc_ ) = mod( descw( csrc_ )+1, npcol )
537 CALL pdsytd2( uplo, kk, a, ia+k-1, ja+k-1, desca, d, e, tau,
538 $ work, lwork, iinfo )
541 CALL pb_topset( ictxt,
'Combine',
'Columnwise', colctop )
542 CALL pb_topset( ictxt,
'Combine',
'Rowwise', rowctop )
546 work( 1 ) = dble( ttlwmin )