1 SUBROUTINE pclarzc( SIDE, M, N, L, V, IV, JV, DESCV, INCV, TAU, C,
2 $ IC, JC, DESCC, WORK )
11 INTEGER IC, INCV, IV, JC, JV, L, M, N
14 INTEGER DESCC( * ), DESCV( * )
15 COMPLEX C( * ), TAU( * ), V( * ), WORK( * )
236 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
237 $ lld_, mb_, m_, nb_, n_, rsrc_
238 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
239 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
240 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
242 parameter( one = ( 1.0e+0, 0.0e+0 ),
243 $ zero = ( 0.0e+0, 0.0e+0 ) )
246 LOGICAL CCBLCK, CRBLCK, LEFT
247 CHARACTER COLBTOP, ROWBTOP
248 INTEGER ICCOL1, ICCOL2, ICOFFC1, ICOFFC2, ICOFFV,
249 $ icrow1, icrow2, ictxt, iic1, iic2, iiv, ioffc1,
250 $ ioffc2, ioffv, ipw, iroffc1, iroffc2, iroffv,
251 $ ivcol, ivrow, jjc1, jjc2, jjv, ldc, ldv, mpc2,
252 $ mpv, mycol, myrow, ncc, ncv, npcol, nprow,
257 EXTERNAL blacs_gridinfo, caxpy, ccopy, cgebr2d,
258 $ cgebs2d, cgemv, cgerc, cgerv2d,
259 $ cgesd2d, cgsum2d, claset,
infog2l,
265 EXTERNAL lsame, numroc
274 IF( m.LE.0 .OR. n.LE.0 )
279 ictxt = descc( ctxt_ )
280 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
284 left = lsame( side,
'L' )
285 CALL infog2l( iv, jv, descv, nprow, npcol, myrow, mycol, iiv, jjv,
287 iroffv = mod( iv-1, descv( nb_ ) )
288 mpv = numroc( l+iroffv, descv( mb_ ), myrow, ivrow, nprow )
291 icoffv = mod( jv-1, descv( nb_ ) )
292 nqv = numroc( l+icoffv, descv( nb_ ), mycol, ivcol, npcol )
296 ncv = numroc( descv( n_ ), descv( nb_ ), mycol, descv( csrc_ ),
299 iiv =
min( iiv, ldv )
300 jjv =
min( jjv, ncv )
301 ioffv = iiv+(jjv-1)*ldv
302 ncc = numroc( descc( n_ ), descc( nb_ ), mycol, descc( csrc_ ),
304 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol,
305 $ iic1, jjc1, icrow1, iccol1 )
306 iroffc1 = mod( ic-1, descc( mb_ ) )
307 icoffc1 = mod( jc-1, descc( nb_ ) )
309 iic1 =
min( iic1, ldc )
310 jjc1 =
min( jjc1,
max( 1, ncc ) )
311 ioffc1 = iic1 + ( jjc1-1 ) * ldc
314 CALL infog2l( ic+m-l, jc, descc, nprow, npcol, myrow, mycol,
315 $ iic2, jjc2, icrow2, iccol2 )
316 iroffc2 = mod( ic+m-l-1, descc( mb_ ) )
317 icoffc2 = mod( jc-1, descc( nb_ ) )
318 nqc2 = numroc( n+icoffc2, descc( nb_ ), mycol, iccol2, npcol )
319 IF( mycol.EQ.iccol2 )
320 $ nqc2 = nqc2 - icoffc2
322 CALL infog2l( ic, jc+n-l, descc, nprow, npcol, myrow, mycol,
323 $ iic2, jjc2, icrow2, iccol2 )
324 iroffc2 = mod( ic-1, descc( mb_ ) )
325 mpc2 = numroc( m+iroffc2, descc( mb_ ), myrow, icrow2, nprow )
326 IF( myrow.EQ.icrow2 )
327 $ mpc2 = mpc2 - iroffc2
328 icoffc2 = mod( jc+n-l-1, descc( nb_ ) )
330 iic2 =
min( iic2, ldc )
331 jjc2 =
min( jjc2, ncc )
332 ioffc2 = iic2 + ( jjc2-1 ) * ldc
336 crblck = ( m.LE.(descc( mb_ )-iroffc1) )
340 ccblck = ( n.LE.(descc( nb_ )-icoffc1) )
354 IF( descv( m_ ).EQ.incv )
THEN
359 CALL pbctrnv( ictxt,
'Rowwise',
'Transpose', m,
360 $ descv( nb_ ), iroffc2, v( ioffv ), ldv,
362 $ work, 1, ivrow, ivcol, icrow2, iccol2,
367 IF( mycol.EQ.iccol2 )
THEN
369 IF( myrow.EQ.ivrow )
THEN
371 CALL cgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
373 tauloc = conjg( tau( iiv ) )
377 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
378 $ tauloc, 1, ivrow, mycol )
379 tauloc = conjg( tauloc )
383 IF( tauloc.NE.zero )
THEN
388 CALL cgemv(
'Conjugate transpose', mpv, nqc2,
389 $ one, c( ioffc2 ), ldc, work, 1,
390 $ zero, work( ipw ), 1 )
392 CALL claset(
'All', nqc2, 1, zero, zero,
393 $ work( ipw ),
max( 1, nqc2 ) )
395 IF( myrow.EQ.icrow1 )
396 $
CALL caxpy( nqc2, one, c( ioffc1 ), ldc,
397 $ work( ipw ),
max( 1, nqc2 ) )
399 CALL cgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
400 $ work( ipw ),
max( 1, nqc2 ), rdest,
405 IF( myrow.EQ.icrow1 )
406 $
CALL caxpy( nqc2, -tauloc, work( ipw ),
407 $
max( 1, nqc2 ), c( ioffc1 ), ldc )
408 CALL cgerc( mpv, nqc2, -tauloc, work, 1,
409 $ work( ipw ), 1, c( ioffc2 ), ldc )
418 IF( ivcol.EQ.iccol2 )
THEN
422 IF( mycol.EQ.iccol2 )
THEN
424 tauloc = conjg( tau( jjv ) )
426 IF( tauloc.NE.zero )
THEN
431 CALL cgemv(
'Conjugate transpose', mpv, nqc2,
432 $ one, c( ioffc2 ), ldc, v( ioffv ),
435 CALL claset(
'All', nqc2, 1, zero, zero,
436 $ work,
max( 1, nqc2 ) )
438 IF( myrow.EQ.icrow1 )
439 $
CALL caxpy( nqc2, one, c( ioffc1 ), ldc,
440 $ work,
max( 1, nqc2 ) )
442 CALL cgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
443 $ work,
max( 1, nqc2 ), rdest,
448 IF( myrow.EQ.icrow1 )
449 $
CALL caxpy( nqc2, -tauloc, work,
450 $
max( 1, nqc2 ), c( ioffc1 ),
452 CALL cgerc( mpv, nqc2, -tauloc, v( ioffv ), 1,
453 $ work, 1, c( ioffc2 ), ldc )
462 IF( mycol.EQ.ivcol )
THEN
465 CALL ccopy( mpv, v( ioffv ), 1, work, 1 )
466 work( ipw ) = tau( jjv )
467 CALL cgesd2d( ictxt, ipw, 1, work, ipw, myrow,
470 ELSE IF( mycol.EQ.iccol2 )
THEN
473 CALL cgerv2d( ictxt, ipw, 1, work, ipw, myrow,
475 tauloc = conjg( work( ipw ) )
477 IF( tauloc.NE.zero )
THEN
482 CALL cgemv(
'Conjugate transpose', mpv, nqc2,
483 $ one, c( ioffc2 ), ldc, work, 1,
484 $ zero, work( ipw ), 1 )
486 CALL claset(
'All', nqc2, 1, zero, zero,
487 $ work( ipw ),
max( 1, nqc2 ) )
489 IF( myrow.EQ.icrow1 )
490 $
CALL caxpy( nqc2, one, c( ioffc1 ), ldc,
491 $ work( ipw ),
max( 1, nqc2 ) )
493 CALL cgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
494 $ work( ipw ),
max( 1, nqc2 ),
499 IF( myrow.EQ.icrow1 )
500 $
CALL caxpy( nqc2, -tauloc, work( ipw ),
501 $
max( 1, nqc2 ), c( ioffc1 ),
503 CALL cgerc( mpv, nqc2, -tauloc, work, 1,
504 $ work( ipw ), 1, c( ioffc2 ), ldc )
517 IF( descv( m_ ).EQ.incv )
THEN
522 CALL pbctrnv( ictxt,
'Rowwise',
'Transpose', m,
523 $ descv( nb_ ), iroffc2, v( ioffv ), ldv,
525 $ work, 1, ivrow, ivcol, icrow2, -1,
530 IF( myrow.EQ.ivrow )
THEN
532 CALL cgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
534 tauloc = conjg( tau( iiv ) )
538 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
540 tauloc = conjg( tauloc )
544 IF( tauloc.NE.zero )
THEN
549 CALL cgemv(
'Conjugate transpose', mpv, nqc2, one,
550 $ c( ioffc2 ), ldc, work, 1, zero,
553 CALL claset(
'All', nqc2, 1, zero, zero,
554 $ work( ipw ),
max( 1, nqc2 ) )
556 IF( myrow.EQ.icrow1 )
557 $
CALL caxpy( nqc2, one, c( ioffc1 ), ldc,
558 $ work( ipw ),
max( 1, nqc2 ) )
560 CALL cgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
561 $ work( ipw ),
max( 1, nqc2 ), rdest,
566 IF( myrow.EQ.icrow1 )
567 $
CALL caxpy( nqc2, -tauloc, work( ipw ),
568 $
max( 1, nqc2 ), c( ioffc1 ), ldc )
569 CALL cgerc( mpv, nqc2, -tauloc, work, 1, work( ipw ),
570 $ 1, c( ioffc2 ), ldc )
577 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
578 IF( mycol.EQ.ivcol )
THEN
581 CALL ccopy( mpv, v( ioffv ), 1, work, 1 )
582 work( ipw ) = tau( jjv )
583 CALL cgebs2d( ictxt,
'Rowwise', rowbtop, ipw, 1,
585 tauloc = conjg( tau( jjv ) )
590 CALL cgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
591 $ ipw, myrow, ivcol )
592 tauloc = conjg( work( ipw ) )
596 IF( tauloc.NE.zero )
THEN
601 CALL cgemv(
'Conjugate transpose', mpv, nqc2, one,
602 $ c( ioffc2 ), ldc, work, 1, zero,
605 CALL claset(
'All', nqc2, 1, zero, zero,
606 $ work( ipw ),
max( 1, nqc2 ) )
608 IF( myrow.EQ.icrow1 )
609 $
CALL caxpy( nqc2, one, c( ioffc1 ), ldc,
610 $ work( ipw ),
max( 1, nqc2 ) )
612 CALL cgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
613 $ work( ipw ),
max( 1, nqc2 ), rdest,
618 IF( myrow.EQ.icrow1 )
619 $
CALL caxpy( nqc2, -tauloc, work( ipw ),
620 $
max( 1, nqc2 ), c( ioffc1 ), ldc )
621 CALL cgerc( mpv, nqc2, -tauloc, work, 1, work( ipw ),
622 $ 1, c( ioffc2 ), ldc )
641 IF( descv( m_ ).EQ.incv )
THEN
645 IF( ivrow.EQ.icrow2 )
THEN
649 IF( myrow.EQ.icrow2 )
THEN
651 tauloc = conjg( tau( iiv ) )
653 IF( tauloc.NE.zero )
THEN
658 CALL cgemv(
'No transpose', mpc2, nqv, one,
659 $ c( ioffc2 ), ldc, v( ioffv ),
660 $ ldv, zero, work, 1 )
662 CALL claset(
'All', mpc2, 1, zero, zero,
663 $ work,
max( 1, mpc2 ) )
665 IF( mycol.EQ.iccol1 )
666 $
CALL caxpy( mpc2, one, c( ioffc1 ), 1,
669 CALL cgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
670 $ work,
max( 1, mpc2 ), rdest,
673 IF( mycol.EQ.iccol1 )
674 $
CALL caxpy( mpc2, -tauloc, work, 1,
679 CALL cgerc( mpc2, nqv, -tauloc, work, 1,
680 $ v( ioffv ), ldv, c( ioffc2 ), ldc )
689 IF( myrow.EQ.ivrow )
THEN
692 CALL ccopy( nqv, v( ioffv ), ldv, work, 1 )
693 work( ipw ) = tau( iiv )
694 CALL cgesd2d( ictxt, ipw, 1, work, ipw, icrow2,
697 ELSE IF( myrow.EQ.icrow2 )
THEN
700 CALL cgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
702 tauloc = conjg( work( ipw ) )
704 IF( tauloc.NE.zero )
THEN
709 CALL cgemv(
'No transpose', mpc2, nqv, one,
710 $ c( ioffc2 ), ldc, work, 1, zero,
713 CALL claset(
'All', mpc2, 1, zero, zero,
714 $ work( ipw ),
max( 1, mpc2 ) )
716 IF( mycol.EQ.iccol1 )
717 $
CALL caxpy( mpc2, one, c( ioffc1 ), 1,
719 CALL cgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
720 $ work( ipw ),
max( 1, mpc2 ),
722 IF( mycol.EQ.iccol1 )
723 $
CALL caxpy( mpc2, -tauloc, work( ipw ), 1,
728 CALL cgerc( mpc2, nqv, -tauloc, work( ipw ), 1,
729 $ work, 1, c( ioffc2 ), ldc )
741 CALL pbctrnv( ictxt,
'Columnwise',
'Transpose', n,
742 $ descv( mb_ ), icoffc2, v( ioffv ), 1, zero,
743 $ work, 1, ivrow, ivcol, icrow2, iccol2,
748 IF( myrow.EQ.icrow2 )
THEN
750 IF( mycol.EQ.ivcol )
THEN
752 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
754 tauloc = conjg( tau( jjv ) )
758 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
760 tauloc = conjg( tauloc )
764 IF( tauloc.NE.zero )
THEN
769 CALL cgemv(
'No transpose', mpc2, nqv, one,
770 $ c( ioffc2 ), ldc, work, 1, zero,
773 CALL claset(
'All', mpc2, 1, zero, zero,
774 $ work( ipw ),
max( 1, mpc2 ) )
776 IF( mycol.EQ.iccol1 )
777 $
CALL caxpy( mpc2, one, c( ioffc1 ), 1,
779 CALL cgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
780 $ work( ipw ),
max( 1, mpc2 ), rdest,
782 IF( mycol.EQ.iccol1 )
783 $
CALL caxpy( mpc2, -tauloc, work( ipw ), 1,
788 CALL cgerc( mpc2, nqv, -tauloc, work( ipw ), 1,
789 $ work, 1, c( ioffc2 ), ldc )
800 IF( descv( m_ ).EQ.incv )
THEN
804 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
806 IF( myrow.EQ.ivrow )
THEN
809 CALL ccopy( nqv, v( ioffv ), ldv, work, 1 )
810 work( ipw ) = tau( iiv )
811 CALL cgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
813 tauloc = conjg( tau( iiv ) )
818 CALL cgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
819 $ work, ipw, ivrow, mycol )
820 tauloc = conjg( work( ipw ) )
824 IF( tauloc.NE.zero )
THEN
829 CALL cgemv(
'No Transpose', mpc2, nqv, one,
830 $ c( ioffc2 ), ldc, work, 1, zero,
833 CALL claset(
'All', mpc2, 1, zero, zero,
834 $ work( ipw ),
max( 1, mpc2 ) )
836 IF( mycol.EQ.iccol1 )
837 $
CALL caxpy( mpc2, one, c( ioffc1 ), 1,
840 CALL cgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
841 $ work( ipw ),
max( 1, mpc2 ), rdest,
843 IF( mycol.EQ.iccol1 )
844 $
CALL caxpy( mpc2, -tauloc, work( ipw ), 1,
849 CALL cgerc( mpc2, nqv, -tauloc, work( ipw ), 1, work,
850 $ 1, c( ioffc2 ), ldc )
858 CALL pbctrnv( ictxt,
'Columnwise',
'Transpose', n,
859 $ descv( mb_ ), icoffc2, v( ioffv ), 1, zero,
860 $ work, 1, ivrow, ivcol, -1, iccol2,
865 IF( mycol.EQ.ivcol )
THEN
867 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
869 tauloc = conjg( tau( jjv ) )
873 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
875 tauloc = conjg( tauloc )
879 IF( tauloc.NE.zero )
THEN
884 CALL cgemv(
'No transpose', mpc2, nqv, one,
885 $ c( ioffc2 ), ldc, work, 1, zero,
888 CALL claset(
'All', mpc2, 1, zero, zero,
889 $ work( ipw ),
max( 1, mpc2 ) )
891 IF( mycol.EQ.iccol1 )
892 $
CALL caxpy( mpc2, one, c( ioffc1 ), 1,
894 CALL cgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
895 $ work( ipw ),
max( 1, mpc2 ), rdest,
897 IF( mycol.EQ.iccol1 )
898 $
CALL caxpy( mpc2, -tauloc, work( ipw ), 1,
903 CALL cgerc( mpc2, nqv, -tauloc, work( ipw ), 1, work,
904 $ 1, c( ioffc2 ), ldc )