1 SUBROUTINE pclarfc( 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,
339 tauloc = conjg( tau( iiv ) )
343 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
344 $ tauloc, 1, ivrow, mycol )
345 tauloc = conjg( tauloc )
349 IF( tauloc.NE.zero )
THEN
354 CALL cgemv(
'Conjugate transpose', mp, nq, one,
355 $ c( ioffc ), ldc, work, 1, zero,
358 CALL claset(
'All', nq, 1, zero, zero,
359 $ work( ipw ),
max( 1, nq ) )
361 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
362 $ work( ipw ),
max( 1, nq ), rdest,
367 CALL cgerc( mp, nq, -tauloc, work, 1, work( ipw ),
368 $ 1, c( ioffc ), ldc )
377 IF( ivcol.EQ.iccol )
THEN
381 IF( mycol.EQ.iccol )
THEN
383 tauloc = conjg( tau( jjv ) )
385 IF( tauloc.NE.zero )
THEN
390 CALL cgemv(
'Conjugate transpose', mp, nq,
391 $ one, c( ioffc ), ldc, v( ioffv ), 1,
394 CALL claset(
'All', nq, 1, zero, zero,
395 $ work,
max( 1, nq ) )
397 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
398 $ work,
max( 1, nq ), rdest, mycol )
402 CALL cgerc( mp, nq, -tauloc, v( ioffv ), 1,
403 $ work, 1, c( ioffc ), ldc )
412 IF( mycol.EQ.ivcol )
THEN
415 CALL ccopy( mp, v( ioffv ), 1, work, 1 )
416 work( ipw ) = tau( jjv )
417 CALL cgesd2d( ictxt, ipw, 1, work, ipw, myrow,
420 ELSE IF( mycol.EQ.iccol )
THEN
423 CALL cgerv2d( ictxt, ipw, 1, work, ipw, myrow,
425 tauloc = conjg( work( ipw ) )
427 IF( tauloc.NE.zero )
THEN
432 CALL cgemv(
'Conjugate transpose', mp, nq,
433 $ one, c( ioffc ), ldc, work, 1,
434 $ zero, work( ipw ), 1 )
436 CALL claset(
'All', nq, 1, zero, zero,
437 $ work( ipw ),
max( 1, nq ) )
439 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
440 $ work( ipw ),
max( 1, nq ), rdest,
445 CALL cgerc( mp, nq, -tauloc, work, 1,
446 $ work( ipw ), 1, c( ioffc ), ldc )
459 IF( descv( m_ ).EQ.incv )
THEN
464 CALL pbctrnv( ictxt,
'Rowwise',
'Transpose', m,
465 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
466 $ work, 1, ivrow, ivcol, icrow, -1,
471 IF( myrow.EQ.ivrow )
THEN
473 CALL cgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
475 tauloc = conjg( tau( iiv ) )
479 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
481 tauloc = conjg( tauloc )
485 IF( tauloc.NE.zero )
THEN
490 CALL cgemv(
'Conjugate transpose', mp, nq, one,
491 $ c( ioffc ), ldc, work, 1, zero,
494 CALL claset(
'All', nq, 1, zero, zero,
495 $ work( ipw ),
max( 1, nq ) )
497 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
498 $ work( ipw ),
max( 1, nq ), rdest,
503 CALL cgerc( mp, nq, -tauloc, work, 1, work( ipw ), 1,
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,
519 tauloc = conjg( tau( jjv ) )
524 CALL cgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
525 $ ipw, myrow, ivcol )
526 tauloc = conjg( work( ipw ) )
530 IF( tauloc.NE.zero )
THEN
535 CALL cgemv(
'Conjugate transpose', mp, nq, one,
536 $ c( ioffc ), ldc, work, 1, zero,
539 CALL claset(
'All', nq, 1, zero, zero,
540 $ work( ipw ),
max( 1, nq ) )
542 CALL cgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
543 $ work( ipw ),
max( 1, nq ), rdest,
548 CALL cgerc( mp, nq, -tauloc, work, 1, work( ipw ), 1,
568 IF( descv( m_ ).EQ.incv )
THEN
572 IF( ivrow.EQ.icrow )
THEN
576 IF( myrow.EQ.icrow )
THEN
578 tauloc = conjg( tau( iiv ) )
580 IF( tauloc.NE.zero )
THEN
585 CALL cgemv(
'No transpose', mp, nq, one,
586 $ c( ioffc ), ldc, v( ioffv ), ldv,
589 CALL claset(
'All', mp, 1, zero, zero,
590 $ work,
max( 1, mp ) )
592 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
593 $ work,
max( 1, mp ), rdest, iccol )
597 CALL cgerc( mp, nq, -tauloc, work, 1,
598 $ v( ioffv ), ldv, c( ioffc ), ldc )
607 IF( myrow.EQ.ivrow )
THEN
610 CALL ccopy( nq, v( ioffv ), ldv, work, 1 )
611 work(ipw) = tau( iiv )
612 CALL cgesd2d( ictxt, ipw, 1, work, ipw, icrow,
615 ELSE IF( myrow.EQ.icrow )
THEN
618 CALL cgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
620 tauloc = conjg( work( ipw ) )
622 IF( tauloc.NE.zero )
THEN
627 CALL cgemv(
'No transpose', mp, nq, one,
628 $ c( ioffc ), ldc, work, 1, zero,
631 CALL claset(
'All', mp, 1, zero, zero,
632 $ work( ipw ),
max( 1, mp ) )
634 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
635 $ work( ipw ),
max( 1, mp ), rdest,
640 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1,
641 $ work, 1, c( ioffc ), ldc )
653 CALL pbctrnv( ictxt,
'Columnwise',
'Transpose', n,
654 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
655 $ work, 1, ivrow, ivcol, icrow, iccol,
660 IF( myrow.EQ.icrow )
THEN
662 IF( mycol.EQ.ivcol )
THEN
664 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
666 tauloc = conjg( tau( jjv ) )
670 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
672 tauloc = conjg( tauloc )
676 IF( tauloc.NE.zero )
THEN
681 CALL cgemv(
'No transpose', mp, nq, one,
682 $ c( ioffc ), ldc, work, 1, zero,
685 CALL claset(
'All', mp, 1, zero, zero,
686 $ work( ipw ),
max( 1, mp ) )
688 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
689 $ work( ipw ),
max( 1, mp ), rdest,
694 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1, work,
695 $ 1, c( ioffc ), ldc )
706 IF( descv( m_ ).EQ.incv )
THEN
710 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
712 IF( myrow.EQ.ivrow )
THEN
715 CALL ccopy( nq, v( ioffv ), ldv, work, 1 )
716 work(ipw) = tau( iiv )
717 CALL cgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
719 tauloc = conjg( tau( iiv ) )
724 CALL cgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
725 $ work, ipw, ivrow, mycol )
726 tauloc = conjg( work( ipw ) )
730 IF( tauloc.NE.zero )
THEN
735 CALL cgemv(
'No Transpose', mp, nq, one,
736 $ c( ioffc ), ldc, work, 1, zero,
739 CALL claset(
'All', mp, 1, zero, zero,
740 $ work( ipw ),
max( 1, mp ) )
742 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
743 $ work( ipw ),
max( 1, mp ), rdest,
748 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1, work, 1,
757 CALL pbctrnv( ictxt,
'Columnwise',
'Transpose', n,
758 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
759 $ work, 1, ivrow, ivcol, -1, iccol,
764 IF( mycol.EQ.ivcol )
THEN
766 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
768 tauloc = conjg( tau( jjv ) )
772 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
774 tauloc = conjg( tauloc )
778 IF( tauloc.NE.zero )
THEN
783 CALL cgemv(
'No transpose', mp, nq, one,
784 $ c( ioffc ), ldc, work, 1, zero,
787 CALL claset(
'All', mp, 1, zero, zero, work( ipw ),
790 CALL cgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
791 $ work( ipw ),
max( 1, mp ), rdest,
796 CALL cgerc( mp, nq, -tauloc, work( ipw ), 1, work, 1,