1 SUBROUTINE pspttrs( N, NRHS, D, E, JA, DESCA, B, IB, DESCB, AF,
2 $ LAF, WORK, LWORK, INFO )
10 INTEGER IB, INFO, JA, LAF, LWORK, N, NRHS
13 INTEGER DESCA( * ), DESCB( * )
14 REAL AF( * ), B( * ), D( * ), E( * ), WORK( * )
367 parameter( one = 1.0e+0 )
369 parameter( int_one = 1 )
370 INTEGER DESCMULT, BIGNUM
371 parameter( descmult = 100, bignum = descmult*descmult )
372 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
373 $ lld_, mb_, m_, nb_, n_, rsrc_
374 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
375 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
376 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
379 INTEGER CSRC, FIRST_PROC, I, ICTXT, ICTXT_NEW,
380 $ ictxt_save, idum3, ja_new, llda, lldb, mycol,
381 $ myrow, my_num_cols, nb, np, npcol, nprow,
382 $ np_save, odd_size, part_offset, part_size,
383 $ return_code, store_m_b, store_n_a, temp,
387 INTEGER DESCA_1XP( 7 ), DESCB_PX1( 7 ),
388 $ param_check( 14, 3 )
399 INTRINSIC min, mod, real
413 temp = desca( dtype_ )
414 IF( temp.EQ.502 )
THEN
416 desca( dtype_ ) = 501
421 desca( dtype_ ) = temp
423 IF( return_code.NE.0 )
THEN
429 IF( return_code.NE.0 )
THEN
436 IF( desca_1xp( 2 ).NE.descb_px1( 2 ) )
THEN
444 IF( desca_1xp( 4 ).NE.descb_px1( 4 ) )
THEN
450 IF( desca_1xp( 5 ).NE.descb_px1( 5 ) )
THEN
456 ictxt = desca_1xp( 2 )
457 csrc = desca_1xp( 5 )
459 llda = desca_1xp( 6 )
460 store_n_a = desca_1xp( 3 )
461 lldb = descb_px1( 6 )
462 store_m_b = descb_px1( 3 )
467 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
472 IF( lwork.LT.-1 )
THEN
474 ELSE IF( lwork.EQ.-1 )
THEN
484 IF( n+ja-1.GT.store_n_a )
THEN
488 IF( n+ib-1.GT.store_m_b )
THEN
492 IF( lldb.LT.nb )
THEN
508 IF( nprow.NE.1 )
THEN
512 IF( n.GT.np*nb-mod( ja-1, nb ) )
THEN
514 CALL pxerbla( ictxt,
'PSPTTRS, D&C alg.: only 1 block per proc'
519 IF( ( ja+n-1.GT.nb ) .AND. ( nb.LT.2*int_one ) )
THEN
521 CALL pxerbla( ictxt,
'PSPTTRS, D&C alg.: NB too small', -info )
526 work_size_min = ( 10+2*
min( 100, nrhs ) )*npcol + 4*nrhs
528 work( 1 ) = work_size_min
530 IF( lwork.LT.work_size_min )
THEN
531 IF( lwork.NE.-1 )
THEN
533 CALL pxerbla( ictxt,
'PSPTTRS: worksize error', -info )
540 param_check( 14, 1 ) = descb( 5 )
541 param_check( 13, 1 ) = descb( 4 )
542 param_check( 12, 1 ) = descb( 3 )
543 param_check( 11, 1 ) = descb( 2 )
544 param_check( 10, 1 ) = descb( 1 )
545 param_check( 9, 1 ) = ib
546 param_check( 8, 1 ) = desca( 5 )
547 param_check( 7, 1 ) = desca( 4 )
548 param_check( 6, 1 ) = desca( 3 )
549 param_check( 5, 1 ) = desca( 1 )
550 param_check( 4, 1 ) = ja
551 param_check( 3, 1 ) = nrhs
552 param_check( 2, 1 ) = n
553 param_check( 1, 1 ) = idum3
555 param_check( 14, 2 ) = 905
556 param_check( 13, 2 ) = 904
557 param_check( 12, 2 ) = 903
558 param_check( 11, 2 ) = 902
559 param_check( 10, 2 ) = 901
560 param_check( 9, 2 ) = 8
561 param_check( 8, 2 ) = 505
562 param_check( 7, 2 ) = 504
563 param_check( 6, 2 ) = 503
564 param_check( 5, 2 ) = 501
565 param_check( 4, 2 ) = 4
566 param_check( 3, 2 ) = 2
567 param_check( 2, 2 ) = 1
568 param_check( 1, 2 ) = 12
576 ELSE IF( info.LT.-descmult )
THEN
579 info = -info*descmult
584 CALL globchk( ictxt, 14, param_check, 14, param_check( 1, 3 ),
590 IF( info.EQ.bignum )
THEN
592 ELSE IF( mod( info, descmult ).EQ.0 )
THEN
593 info = -info / descmult
599 CALL pxerbla( ictxt,
'PSPTTRS', -info )
615 part_offset = nb*( ( ja-1 ) / ( npcol*nb ) )
617 IF( ( mycol-csrc ).LT.( ja-part_offset-1 ) / nb )
THEN
618 part_offset = part_offset + nb
621 IF( mycol.LT.csrc )
THEN
622 part_offset = part_offset - nb
631 first_proc = mod( ( ja-1 ) / nb+csrc, npcol )
635 ja_new = mod( ja-1, nb ) + 1
640 np = ( ja_new+n-2 ) / nb + 1
644 CALL reshape( ictxt, int_one, ictxt_new, int_one, first_proc,
651 desca_1xp( 2 ) = ictxt_new
652 descb_px1( 2 ) = ictxt_new
656 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
660 IF( myrow.LT.0 )
THEN
673 my_num_cols = numroc( n, part_size, mycol, 0, npcol )
677 IF( mycol.EQ.0 )
THEN
678 part_offset = part_offset + mod( ja_new-1, part_size )
679 my_num_cols = my_num_cols - mod( ja_new-1, part_size )
684 odd_size = my_num_cols
685 IF( mycol.LT.np-1 )
THEN
686 odd_size = odd_size - int_one
698 CALL pspttrsv(
'L', n, nrhs, d( part_offset+1 ),
699 $ e( part_offset+1 ), ja_new, desca_1xp, b, ib,
700 $ descb_px1, af, laf, work, lwork, info )
706 DO 10 i = part_offset + 1, part_offset + odd_size
707 CALL sscal( nrhs, real( one / d( i ) ), b( i ), lldb )
712 IF( mycol.LT.npcol-1 )
THEN
713 i = part_offset + odd_size + 1
714 CALL sscal( nrhs, one / af( odd_size+2 ), b( i ), lldb )
720 CALL pspttrsv(
'U', n, nrhs, d( part_offset+1 ),
721 $ e( part_offset+1 ), ja_new, desca_1xp, b, ib,
722 $ descb_px1, af, laf, work, lwork, info )
728 IF( ictxt_save.NE.ictxt_new )
THEN
729 CALL blacs_gridexit( ictxt_new )
741 work( 1 ) = work_size_min