1 SUBROUTINE pclarf( SIDE, M, N, V, IV, JV, DESCV, INCV, TAU,
2 $ C, IC, JC, DESCC, WORK )
11 INTEGER IC, INCV, IV, JC, JV, M, N
14 INTEGER DESCC( * ), DESCV( * )
15 COMPLEX C( * ), TAU( * ), V( * ), WORK( * )
229 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
230 $ lld_, mb_, m_, nb_, n_, rsrc_
231 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
232 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
233 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
235 parameter( one = ( 1.0e+0, 0.0e+0 ),
236 $ zero = ( 0.0e+0, 0.0e+0 ) )
239 LOGICAL CCBLCK, CRBLCK
240 CHARACTER COLBTOP, ROWBTOP
241 INTEGER ICCOL, ICOFF, ICROW, ICTXT, IIC, IIV, IOFFC,
242 $ ioffv, ipw, iroff, ivcol, ivrow, jjc, jjv, ldc,
243 $ ldv, mycol, myrow, mp, ncc, ncv, npcol, nprow,
248 EXTERNAL blacs_gridinfo, ccopy, cgebr2d, cgebs2d,
249 $ cgemv, cgerc, cgerv2d, cgesd2d,
250 $ cgsum2d, claset,
infog2l, pb_topget,
256 EXTERNAL lsame, numroc
265 IF( m.LE.0 .OR. n.LE.0 )
270 ictxt = descc( ctxt_ )
271 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
275 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol, iic, jjc,
277 CALL infog2l( iv, jv, descv, nprow, npcol, myrow, mycol, iiv, jjv,
279 ncc = numroc( descc( n_ ), descc( nb_ ), mycol, descc( csrc_ ),
281 ncv = numroc( descv( n_ ), descv( nb_ ), mycol, descv( csrc_ ),
285 iic =
min( iic, ldc )
286 iiv =
min( iiv, ldv )
287 jjc =
min( jjc, ncc )
288 jjv =
min( jjv, ncv )
289 ioffc = iic+(jjc-1)*ldc
290 ioffv = iiv+(jjv-1)*ldv
292 iroff = mod( ic-1, descc( mb_ ) )
293 icoff = mod( jc-1, descc( nb_ ) )
294 mp = numroc( m+iroff, descc( mb_ ), myrow, icrow, nprow )
295 nq = numroc( n+icoff, descc( nb_ ), mycol, iccol, npcol )
303 crblck = ( m.LE.(descc( mb_ )-iroff) )
307 ccblck = ( n.LE.(descc( nb_ )-icoff) )
309 IF( lsame( side,
'L' ) )
THEN
321 IF( descv( m_ ).EQ.incv )
THEN
326 CALL pbctrnv( ictxt,
'Rowwise',
'Transpose', m,
327 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
328 $ work, 1, ivrow, ivcol, icrow, iccol,
333 IF( mycol.EQ.iccol )
THEN
335 IF( myrow.EQ.ivrow )
THEN
337 CALL cgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
343 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
344 $ tauloc, 1, ivrow, mycol )
348 IF( tauloc.NE.zero )
THEN
353 CALL cgemv(
'Conjugate transpose', mp, nq, one,
354 $ c( ioffc ), ldc, work, 1, zero,
357 CALL claset(
'All', nq, 1, zero, zero,
358 $ work( ipw ),
max( 1, nq ) )
360 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
361 $ work( ipw ),
max( 1, nq ), rdest,
366 CALL cgerc( mp, nq, -tauloc, work, 1, work( ipw ),
367 $ 1, c( ioffc ), ldc )
376 IF( ivcol.EQ.iccol )
THEN
380 IF( mycol.EQ.iccol )
THEN
384 IF( tauloc.NE.zero )
THEN
389 CALL cgemv(
'Conjugate transpose', mp, nq,
390 $ one, c( ioffc ), ldc, v( ioffv ), 1,
393 CALL claset(
'All', nq, 1, zero, zero,
394 $ work,
max( 1, nq ) )
396 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
397 $ work,
max( 1, nq ), rdest, mycol )
401 CALL cgerc( mp, nq, -tauloc, v( ioffv ), 1,
402 $ work, 1, c( ioffc ), ldc )
411 IF( mycol.EQ.ivcol )
THEN
414 CALL ccopy( mp, v( ioffv ), 1, work, 1 )
415 work( ipw ) = tau( jjv )
416 CALL cgesd2d( ictxt, ipw, 1, work, ipw, myrow,
419 ELSE IF( mycol.EQ.iccol )
THEN
422 CALL cgerv2d( ictxt, ipw, 1, work, ipw, myrow,
426 IF( tauloc.NE.zero )
THEN
431 CALL cgemv(
'Conjugate transpose', mp, nq,
432 $ one, c( ioffc ), ldc, work, 1,
433 $ zero, work( ipw ), 1 )
435 CALL claset(
'All', nq, 1, zero, zero,
436 $ work( ipw ),
max( 1, nq ) )
438 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
439 $ work( ipw ),
max( 1, nq ), rdest,
444 CALL cgerc( mp, nq, -tauloc, work, 1,
445 $ work( ipw ), 1, c( ioffc ), ldc )
458 IF( descv( m_ ).EQ.incv )
THEN
463 CALL pbctrnv( ictxt,
'Rowwise',
'Transpose', m,
464 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
465 $ work, 1, ivrow, ivcol, icrow, -1,
470 IF( myrow.EQ.ivrow )
THEN
472 CALL cgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
478 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
483 IF( tauloc.NE.zero )
THEN
489 $
CALL cgemv(
'Conjugate transpose', mp, nq, one,
490 $ c( ioffc ), ldc, work, 1, zero,
493 CALL claset(
'All', nq, 1, zero, zero,
494 $ work( ipw ),
max( 1, nq ) )
496 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
497 $ work( ipw ),
max( 1, nq ), rdest,
503 $
CALL cgerc( mp, nq, -tauloc, work, 1, work( ipw ),
504 $ 1, c( ioffc ), ldc )
511 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
512 IF( mycol.EQ.ivcol )
THEN
515 CALL ccopy( mp, v( ioffv ), 1, work, 1 )
516 work(ipw) = tau( jjv )
517 CALL cgebs2d( ictxt,
'Rowwise', rowbtop, ipw, 1,
524 CALL cgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
525 $ ipw, myrow, ivcol )
530 IF( tauloc.NE.zero )
THEN
536 $
CALL cgemv(
'Conjugate transpose', mp, nq, one,
537 $ c( ioffc ), ldc, work, 1, zero,
540 CALL claset(
'All', nq, 1, zero, zero,
541 $ work( ipw ),
max( 1, nq ) )
543 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
544 $ work( ipw ),
max( 1, nq ), rdest,
550 $
CALL cgerc( mp, nq, -tauloc, work, 1, work( ipw ),
551 $ 1, c( ioffc ), ldc )
570 IF( descv( m_ ).EQ.incv )
THEN
574 IF( ivrow.EQ.icrow )
THEN
578 IF( myrow.EQ.icrow )
THEN
582 IF( tauloc.NE.zero )
THEN
587 CALL cgemv(
'No transpose', mp, nq, one,
588 $ c( ioffc ), ldc, v( ioffv ), ldv,
591 CALL claset(
'All', mp, 1, zero, zero,
592 $ work,
max( 1, mp ) )
594 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
595 $ work,
max( 1, mp ), rdest, iccol )
599 IF( ioffv.GT.0 .AND. ioffc.GT.0 )
600 $
CALL cgerc( mp, nq, -tauloc, work, 1,
601 $ v( ioffv ), ldv, c( ioffc ),
611 IF( myrow.EQ.ivrow )
THEN
614 CALL ccopy( nq, v( ioffv ), ldv, work, 1 )
615 work(ipw) = tau( iiv )
616 CALL cgesd2d( ictxt, ipw, 1, work, ipw, icrow,
619 ELSE IF( myrow.EQ.icrow )
THEN
622 CALL cgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
626 IF( tauloc.NE.zero )
THEN
631 CALL cgemv(
'No transpose', mp, nq, one,
632 $ c( ioffc ), ldc, work, 1, zero,
635 CALL claset(
'All', mp, 1, zero, zero,
636 $ work( ipw ),
max( 1, mp ) )
638 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
639 $ work( ipw ),
max( 1, mp ), rdest,
644 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1,
645 $ work, 1, c( ioffc ), ldc )
657 CALL pbctrnv( ictxt,
'Columnwise',
'Transpose', n,
658 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
659 $ work, 1, ivrow, ivcol, icrow, iccol,
664 IF( myrow.EQ.icrow )
THEN
666 IF( mycol.EQ.ivcol )
THEN
668 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
674 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
679 IF( tauloc.NE.zero )
THEN
684 CALL cgemv(
'No transpose', mp, nq, one,
685 $ c( ioffc ), ldc, work, 1, zero,
688 CALL claset(
'All', mp, 1, zero, zero,
689 $ work( ipw ),
max( 1, mp ) )
691 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
692 $ work( ipw ),
max( 1, mp ), rdest,
697 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1, work,
698 $ 1, c( ioffc ), ldc )
709 IF( descv( m_ ).EQ.incv )
THEN
713 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
715 IF( myrow.EQ.ivrow )
THEN
719 $
CALL ccopy( nq, v( ioffv ), ldv, work, 1 )
720 work(ipw) = tau( iiv )
721 CALL cgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
728 CALL cgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
729 $ work, ipw, ivrow, mycol )
734 IF( tauloc.NE.zero )
THEN
739 CALL cgemv(
'No Transpose', mp, nq, one,
740 $ c( ioffc ), ldc, work, 1, zero,
743 CALL claset(
'All', mp, 1, zero, zero,
744 $ work( ipw ),
max( 1, mp ) )
746 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
747 $ work( ipw ),
max( 1, mp ), rdest,
753 $
CALL cgerc( mp, nq, -tauloc, work( ipw ), 1, work,
754 $ 1, c( ioffc ), ldc )
762 CALL pbctrnv( ictxt,
'Columnwise',
'Transpose', n,
763 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
764 $ work, 1, ivrow, ivcol, -1, iccol,
769 IF( mycol.EQ.ivcol )
THEN
771 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
777 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
782 IF( tauloc.NE.zero )
THEN
787 CALL cgemv(
'No transpose', mp, nq, one,
788 $ c( ioffc ), ldc, work, 1, zero,
791 CALL claset(
'All', mp, 1, zero, zero, work( ipw ),
794 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
795 $ work( ipw ),
max( 1, mp ), rdest,
800 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1, work, 1,