1 SUBROUTINE pzlarzc( 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*16 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.0d+0, 0.0d+0 ),
243 $ zero = ( 0.0d+0, 0.0d+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,
258 $ zaxpy, zcopy, zgebr2d, zgebs2d,
259 $ zgemv, zgerc, zgerv2d, zgesd2d,
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 pbztrnv( 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 zgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
373 tauloc = dconjg( tau( iiv ) )
377 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
378 $ tauloc, 1, ivrow, mycol )
379 tauloc = dconjg( tauloc )
383 IF( tauloc.NE.zero )
THEN
388 CALL zgemv(
'Conjugate transpose', mpv, nqc2,
389 $ one, c( ioffc2 ), ldc, work, 1,
390 $ zero, work( ipw ), 1 )
392 CALL zlaset(
'All', nqc2, 1, zero, zero,
393 $ work( ipw ),
max( 1, nqc2 ) )
395 IF( myrow.EQ.icrow1 )
396 $
CALL zaxpy( nqc2, one, c( ioffc1 ), ldc,
397 $ work( ipw ),
max( 1, nqc2 ) )
399 CALL zgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
400 $ work( ipw ),
max( 1, nqc2 ), rdest,
405 IF( myrow.EQ.icrow1 )
406 $
CALL zaxpy( nqc2, -tauloc, work( ipw ),
407 $
max( 1, nqc2 ), c( ioffc1 ), ldc )
408 CALL zgerc( 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 = dconjg( tau( jjv ) )
426 IF( tauloc.NE.zero )
THEN
431 CALL zgemv(
'Conjugate transpose', mpv, nqc2,
432 $ one, c( ioffc2 ), ldc, v( ioffv ),
435 CALL zlaset(
'All', nqc2, 1, zero, zero,
436 $ work,
max( 1, nqc2 ) )
438 IF( myrow.EQ.icrow1 )
439 $
CALL zaxpy( nqc2, one, c( ioffc1 ), ldc,
440 $ work,
max( 1, nqc2 ) )
442 CALL zgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
443 $ work,
max( 1, nqc2 ), rdest,
448 IF( myrow.EQ.icrow1 )
449 $
CALL zaxpy( nqc2, -tauloc, work,
450 $
max( 1, nqc2 ), c( ioffc1 ),
452 CALL zgerc( mpv, nqc2, -tauloc, v( ioffv ), 1,
453 $ work, 1, c( ioffc2 ), ldc )
462 IF( mycol.EQ.ivcol )
THEN
465 CALL zcopy( mpv, v( ioffv ), 1, work, 1 )
466 work( ipw ) = tau( jjv )
467 CALL zgesd2d( ictxt, ipw, 1, work, ipw, myrow,
470 ELSE IF( mycol.EQ.iccol2 )
THEN
473 CALL zgerv2d( ictxt, ipw, 1, work, ipw, myrow,
475 tauloc = dconjg( work( ipw ) )
477 IF( tauloc.NE.zero )
THEN
482 CALL zgemv(
'Conjugate transpose', mpv, nqc2,
483 $ one, c( ioffc2 ), ldc, work, 1,
484 $ zero, work( ipw ), 1 )
486 CALL zlaset(
'All', nqc2, 1, zero, zero,
487 $ work( ipw ),
max( 1, nqc2 ) )
489 IF( myrow.EQ.icrow1 )
490 $
CALL zaxpy( nqc2, one, c( ioffc1 ), ldc,
491 $ work( ipw ),
max( 1, nqc2 ) )
493 CALL zgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
494 $ work( ipw ),
max( 1, nqc2 ),
499 IF( myrow.EQ.icrow1 )
500 $
CALL zaxpy( nqc2, -tauloc, work( ipw ),
501 $
max( 1, nqc2 ), c( ioffc1 ),
503 CALL zgerc( mpv, nqc2, -tauloc, work, 1,
504 $ work( ipw ), 1, c( ioffc2 ), ldc )
517 IF( descv( m_ ).EQ.incv )
THEN
522 CALL pbztrnv( 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 zgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
534 tauloc = dconjg( tau( iiv ) )
538 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
540 tauloc = dconjg( tauloc )
544 IF( tauloc.NE.zero )
THEN
549 CALL zgemv(
'Conjugate transpose', mpv, nqc2, one,
550 $ c( ioffc2 ), ldc, work, 1, zero,
553 CALL zlaset(
'All', nqc2, 1, zero, zero,
554 $ work( ipw ),
max( 1, nqc2 ) )
556 IF( myrow.EQ.icrow1 )
557 $
CALL zaxpy( nqc2, one, c( ioffc1 ), ldc,
558 $ work( ipw ),
max( 1, nqc2 ) )
560 CALL zgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
561 $ work( ipw ),
max( 1, nqc2 ), rdest,
566 IF( myrow.EQ.icrow1 )
567 $
CALL zaxpy( nqc2, -tauloc, work( ipw ),
568 $
max( 1, nqc2 ), c( ioffc1 ), ldc )
569 CALL zgerc( 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 zcopy( mpv, v( ioffv ), 1, work, 1 )
582 work( ipw ) = tau( jjv )
583 CALL zgebs2d( ictxt,
'Rowwise', rowbtop, ipw, 1,
585 tauloc = dconjg( tau( jjv ) )
590 CALL zgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
591 $ ipw, myrow, ivcol )
592 tauloc = dconjg( work( ipw ) )
596 IF( tauloc.NE.zero )
THEN
601 CALL zgemv(
'Conjugate transpose', mpv, nqc2, one,
602 $ c( ioffc2 ), ldc, work, 1, zero,
605 CALL zlaset(
'All', nqc2, 1, zero, zero,
606 $ work( ipw ),
max( 1, nqc2 ) )
608 IF( myrow.EQ.icrow1 )
609 $
CALL zaxpy( nqc2, one, c( ioffc1 ), ldc,
610 $ work( ipw ),
max( 1, nqc2 ) )
612 CALL zgsum2d( ictxt,
'Columnwise',
' ', nqc2, 1,
613 $ work( ipw ),
max( 1, nqc2 ), rdest,
618 IF( myrow.EQ.icrow1 )
619 $
CALL zaxpy( nqc2, -tauloc, work( ipw ),
620 $
max( 1, nqc2 ), c( ioffc1 ), ldc )
621 CALL zgerc( 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 = dconjg( tau( iiv ) )
653 IF( tauloc.NE.zero )
THEN
658 CALL zgemv(
'No transpose', mpc2, nqv, one,
659 $ c( ioffc2 ), ldc, v( ioffv ),
660 $ ldv, zero, work, 1 )
662 CALL zlaset(
'All', mpc2, 1, zero, zero,
663 $ work,
max( 1, mpc2 ) )
665 IF( mycol.EQ.iccol1 )
666 $
CALL zaxpy( mpc2, one, c( ioffc1 ), 1,
669 CALL zgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
670 $ work,
max( 1, mpc2 ), rdest,
673 IF( mycol.EQ.iccol1 )
674 $
CALL zaxpy( mpc2, -tauloc, work, 1,
679 CALL zgerc( mpc2, nqv, -tauloc, work, 1,
680 $ v( ioffv ), ldv, c( ioffc2 ), ldc )
689 IF( myrow.EQ.ivrow )
THEN
692 CALL zcopy( nqv, v( ioffv ), ldv, work, 1 )
693 work( ipw ) = tau( iiv )
694 CALL zgesd2d( ictxt, ipw, 1, work, ipw, icrow2,
697 ELSE IF( myrow.EQ.icrow2 )
THEN
700 CALL zgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
702 tauloc = dconjg( work( ipw ) )
704 IF( tauloc.NE.zero )
THEN
709 CALL zgemv(
'No transpose', mpc2, nqv, one,
710 $ c( ioffc2 ), ldc, work, 1, zero,
713 CALL zlaset(
'All', mpc2, 1, zero, zero,
714 $ work( ipw ),
max( 1, mpc2 ) )
716 IF( mycol.EQ.iccol1 )
717 $
CALL zaxpy( mpc2, one, c( ioffc1 ), 1,
719 CALL zgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
720 $ work( ipw ),
max( 1, mpc2 ),
722 IF( mycol.EQ.iccol1 )
723 $
CALL zaxpy( mpc2, -tauloc, work( ipw ), 1,
728 CALL zgerc( mpc2, nqv, -tauloc, work( ipw ), 1,
729 $ work, 1, c( ioffc2 ), ldc )
741 CALL pbztrnv( 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 zgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
754 tauloc = dconjg( tau( jjv ) )
758 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
760 tauloc = dconjg( tauloc )
764 IF( tauloc.NE.zero )
THEN
769 CALL zgemv(
'No transpose', mpc2, nqv, one,
770 $ c( ioffc2 ), ldc, work, 1, zero,
773 CALL zlaset(
'All', mpc2, 1, zero, zero,
774 $ work( ipw ),
max( 1, mpc2 ) )
776 IF( mycol.EQ.iccol1 )
777 $
CALL zaxpy( mpc2, one, c( ioffc1 ), 1,
779 CALL zgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
780 $ work( ipw ),
max( 1, mpc2 ), rdest,
782 IF( mycol.EQ.iccol1 )
783 $
CALL zaxpy( mpc2, -tauloc, work( ipw ), 1,
788 CALL zgerc( 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 zcopy( nqv, v( ioffv ), ldv, work, 1 )
810 work( ipw ) = tau( iiv )
811 CALL zgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
813 tauloc = dconjg( tau( iiv ) )
818 CALL zgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
819 $ work, ipw, ivrow, mycol )
820 tauloc = dconjg( work( ipw ) )
824 IF( tauloc.NE.zero )
THEN
829 CALL zgemv(
'No Transpose', mpc2, nqv, one,
830 $ c( ioffc2 ), ldc, work, 1, zero,
833 CALL zlaset(
'All', mpc2, 1, zero, zero,
834 $ work( ipw ),
max( 1, mpc2 ) )
836 IF( mycol.EQ.iccol1 )
837 $
CALL zaxpy( mpc2, one, c( ioffc1 ), 1,
840 CALL zgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
841 $ work( ipw ),
max( 1, mpc2 ), rdest,
843 IF( mycol.EQ.iccol1 )
844 $
CALL zaxpy( mpc2, -tauloc, work( ipw ), 1,
849 CALL zgerc( mpc2, nqv, -tauloc, work( ipw ), 1, work,
850 $ 1, c( ioffc2 ), ldc )
858 CALL pbztrnv( 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 zgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
869 tauloc = dconjg( tau( jjv ) )
873 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
875 tauloc = dconjg( tauloc )
879 IF( tauloc.NE.zero )
THEN
884 CALL zgemv(
'No transpose', mpc2, nqv, one,
885 $ c( ioffc2 ), ldc, work, 1, zero,
888 CALL zlaset(
'All', mpc2, 1, zero, zero,
889 $ work( ipw ),
max( 1, mpc2 ) )
891 IF( mycol.EQ.iccol1 )
892 $
CALL zaxpy( mpc2, one, c( ioffc1 ), 1,
894 CALL zgsum2d( ictxt,
'Rowwise',
' ', mpc2, 1,
895 $ work( ipw ),
max( 1, mpc2 ), rdest,
897 IF( mycol.EQ.iccol1 )
898 $
CALL zaxpy( mpc2, -tauloc, work( ipw ), 1,
903 CALL zgerc( mpc2, nqv, -tauloc, work( ipw ), 1, work,
904 $ 1, c( ioffc2 ), ldc )