1 SUBROUTINE pslaqr5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS,
2 $ SR, SI, H, DESCH, ILOZ, IHIZ, Z, DESCZ, WORK,
3 $ LWORK, IWORK, LIWORK )
15 INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, N, NSHFTS,
20 INTEGER DESCH( * ), DESCZ( * ), IWORK( * )
21 REAL H( * ), SI( * ), SR( * ), Z( * ), WORK( * )
126 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
127 $ LLD_, MB_, M_, NB_, N_, RSRC_
128 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
129 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
130 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
132 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
134 parameter( ntiny = 11 )
137 REAL ALPHA, BETA, H11, H12, H21, H22, REFSUM,
138 $ SAFMAX, SAFMIN, SCL, SMLNUM, SWAP, TST1, TST2,
139 $ ulp, tau, elem, stamp, ddum, orth
140 INTEGER I, I2, I4, INCOL, J, J2, J4, JBOT, JCOL, JLEN,
141 $ JROW, JTOP, K, K1, KDU, KMS, KNZ, KRCOL, KZS,
142 $ m, m22, mbot, mend, mstart, mtop, nbmps, ndcol,
143 $ ns, nu, lldh, lldz, lldu, lldv, lldw, lldwh,
144 $ info, ictxt, nprow, npcol, nb, iroffh, itop,
145 $ nwin, myrow, mycol, lns, numwin, lkacc22,
146 $ lchain, win, idonejob, ipnext, anmwin, lenrbuf,
147 $ lencbuf, ichoff, lrsrc, lcsrc, lktop, lkbot,
148 $ ii, jj, swin, ewin, lnwin, dim, llktop, llkbot,
149 $ ipv, ipu, iph, ipw, ku, kwh, kwv, nve, lks,
150 $ idum, nho, dir, winid, indx, iloc, jloc, rsrc1,
151 $ csrc1, rsrc2, csrc2, rsrc3, csrc3, rsrc4, ipuu,
152 $ csrc4, lrows, lcols, indxs, ks, jloc1, iloc1,
153 $ lktop1, lktop2, wchunk, numchunk, oddeven,
154 $ chunknum, dim1, dim4, ipw3, hrows, zrows,
155 $ hcols, ipw1, ipw2, rsrc, east, jloc4, iloc4,
156 $ west, csrc, south, norht, indxe, north,
157 $ ihh, ipiw, lkbot1, nprocs, liroffh,
158 $ winfin, rws3, cls3, indx2, hrows2,
159 $ zrows2, hcols2, mnrbuf,
160 $ mxrbuf, mncbuf, mxcbuf, lwkopt
161 LOGICAL BLK22, BMP22, INTRO, DONEJOB, ODDNPROW,
162 $ ODDNPCOL, LQUERY, BCDONE
163 CHARACTER JBCMPZ*2, JOB
167 INTEGER PILAENVX, ICEIL, INDXG2P, INDXG2L, NUMROC
169 EXTERNAL slamch, pilaenvx, iceil, indxg2p, indxg2l,
170 $ numroc, lsame, slange
173 INTRINSIC abs, float,
max,
min, mod
179 EXTERNAL sgemm, slabad, slamov, slaqr1, slarfg, slaset,
185 ictxt = desch( ctxt_ )
186 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
191 iroffh = mod( ktop - 1, nb )
192 lquery = lwork.EQ.-1 .OR. liwork.EQ.-1
196 IF( .NOT. lquery .AND. nshfts.LT.2 )
202 IF( .NOT. lquery .AND. ktop.GE.kbot )
209 IF( .NOT. lquery )
THEN
210 DO 10 i = 1, nshfts - 2, 2
211 IF( si( i ).NE.-si( i+1 ) )
THEN
215 sr( i+1 ) = sr( i+2 )
220 si( i+1 ) = si( i+2 )
231 ns = nshfts - mod( nshfts, 2 )
235 nwin = pilaenvx( ictxt, 19,
'PSLAQR5', jbcmpz, n, nb, nb, nb )
236 nwin =
min( nwin, kbot-ktop+1 )
242 ns =
max( 2,
min( ns, iceil( kbot-ktop+1, nb )*nwin/3 ) )
243 ns = ns - mod( ns, 2 )
251 lns =
min(
max( 2, nwin / 3 ),
max( 2, ns /
min(nprow,npcol) ) )
252 lns = lns - mod( lns, 2 )
253 numwin =
max( 1,
min( iceil( ns, lns ),
254 $ iceil( kbot-ktop+1, nb ) - 1 ) )
255 IF( nprow.NE.npcol )
THEN
256 numwin =
min( numwin,
min(nprow,npcol) )
257 lns =
min( lns,
max( 2, ns /
min(nprow,npcol) ) )
258 lns = lns - mod( lns, 2 )
263 safmin = slamch(
'SAFE MINIMUM' )
264 safmax = one / safmin
265 CALL slabad( safmin, safmax )
266 ulp = slamch(
'PRECISION' )
267 smlnum = safmin*( float( n ) / ulp )
282 blk22 = ( lns.GT.2 ) .AND. ( kacc22.EQ.2 )
286 IF( .NOT. lquery .AND. ktop+2.LE.kbot )
287 $
CALL pselset( h, ktop+2, ktop, desch, zero )
299 lchain = 3 * nbmps + 1
304 hrows = numroc( n, nb, myrow, desch(rsrc_), nprow )
305 hcols = numroc( n, nb, mycol, desch(csrc_), npcol )
306 lwkopt = (5+2*numwin)*nb**2 + 2*hrows*nb + hcols*nb +
307 $
max( hrows*nb, hcols*nb )
308 work(1) = float(lwkopt)
315 IF( ktop.LT.1 .OR. kbot.GT.n )
RETURN
343 IF( anmwin.GT.0 )
THEN
344 lktop = iwork( 1+(anmwin-1)*5 )
348 IF( intro .AND. (anmwin.EQ.0 .OR. lktop.GT.iceil(ktop,nb)*nb) )
359 iwork( 1+(anmwin-1)*5 ) = ktop
360 iwork( 2+(anmwin-1)*5 ) = ktop +
361 $
min( nwin,nb-iroffh,kbot-ktop+1 ) - 1
362 iwork( 3+(anmwin-1)*5 ) = indxg2p( iwork(1+(anmwin-1)*5), nb,
363 $ myrow, desch(rsrc_), nprow )
364 iwork( 4+(anmwin-1)*5 ) = indxg2p( iwork(2+(anmwin-1)*5), nb,
365 $ mycol, desch(csrc_), npcol )
366 iwork( 5+(anmwin-1)*5 ) = 0
367 ipiw = 6+(anmwin-1)*5
368 IF( anmwin.EQ.numwin ) intro = .false.
379 DO 40 win = 1, anmwin
383 lrsrc = iwork( 3+(win-1)*5 )
384 lcsrc = iwork( 4+(win-1)*5 )
385 lktop = iwork( 1+(win-1)*5 )
386 lkbot = iwork( 2+(win-1)*5 )
387 lnwin = lkbot - lktop + 1
392 IF( iwork(5+(win-1)*5).LT.2 .AND. lnwin.GT.1 .AND.
393 $ (lnwin.GT.lchain .OR. lkbot.EQ.kbot ) )
THEN
394 liroffh = mod(lktop-1,nb)
396 ewin =
min(kbot,lktop-liroffh+nb-1)
398 IF( dim.LE.ntiny .AND. .NOT.lkbot.EQ.kbot )
THEN
399 iwork( 5+(win-1)*5 ) = 2
403 IF( iwork(5+(win-1)*5).EQ.0 )
THEN
404 iwork(5+(win-1)*5) = 1
410 IF( myrow.EQ.lrsrc .AND. mycol.EQ.lcsrc )
THEN
420 llkbot = llktop + lnwin - 1
421 IF( lktop.EQ.ktop .AND. lkbot.EQ.kbot )
THEN
424 ELSEIF( lktop.EQ.ktop )
THEN
425 job =
'Introduce and chase'
426 ELSEIF( lkbot.EQ.kbot )
THEN
427 job =
'Off-chase bulges'
440 ii = indxg2l( swin, nb, myrow, desch(rsrc_), nprow )
441 jj = indxg2l( swin, nb, mycol, desch(csrc_), npcol )
443 llkbot = llktop + lnwin - 1
447 ipuu = iph +
max(ntiny+1,dim)**2
448 ipv = ipuu +
max(ntiny+1,dim)**2
451 IF( lsame( job,
'A' ) .OR. lsame( job,
'O' ) .AND.
452 $ dim.LT.ntiny+1 )
THEN
453 CALL slaset(
'All', ntiny+1, ntiny+1, zero, one,
454 $ work(iph), ntiny+1 )
456 CALL slamov(
'Upper', dim, dim, h(ii+(jj-1)*lldh), lldh,
457 $ work(iph),
max(ntiny+1,dim) )
458 CALL scopy( dim-1, h(ii+(jj-1)*lldh+1), lldh+1,
459 $ work(iph+1),
max(ntiny+1,dim)+1 )
460 IF( lsame( job,
'C' ) .OR. lsame( job,
'O') )
THEN
461 CALL scopy( dim-2, h(ii+(jj-1)*lldh+2), lldh+1,
462 $ work(iph+2),
max(ntiny+1,dim)+1 )
463 CALL scopy( dim-3, h(ii+(jj-1)*lldh+3), lldh+1,
464 $ work(iph+3),
max(ntiny+1,dim)+1 )
465 CALL slaset(
'Lower', dim-4, dim-4, zero,
466 $ zero, work(iph+4),
max(ntiny+1,dim) )
468 CALL slaset(
'Lower', dim-2, dim-2, zero,
469 $ zero, work(iph+2),
max(ntiny+1,dim) )
472 ku =
max(ntiny+1,dim) - kdu + 1
474 nho = (
max(ntiny+1,dim)-kdu+1-4 ) - ( kdu+1 ) + 1
476 nve =
max(ntiny+1,dim) - kdu - kwv + 1
477 CALL slaset(
'All',
max(ntiny+1,dim),
478 $
max(ntiny+1,dim), zero, one, work(ipuu),
483 lks =
max( 1, ns - win*lns + 1 )
484 CALL slaqr6( job, wantt, .true., lkacc22,
485 $
max(ntiny+1,dim), llktop, llkbot, lns, sr( lks ),
486 $ si( lks ), work(iph),
max(ntiny+1,dim), llktop,
487 $ llkbot, work(ipuu),
max(ntiny+1,dim), work(ipu),
488 $ 3, work( iph+ku-1 ),
489 $
max(ntiny+1,dim), nve, work( iph+kwv-1 ),
490 $
max(ntiny+1,dim), nho, work( iph-1+ku+(kwh-1)*
491 $
max(ntiny+1,dim) ),
max(ntiny+1,dim) )
495 CALL slamov(
'Upper', dim, dim, work(iph),
496 $
max(ntiny+1,dim), h(ii+(jj-1)*lldh), lldh )
497 CALL scopy( dim-1, work(iph+1),
max(ntiny+1,dim)+1,
498 $ h(ii+(jj-1)*lldh+1), lldh+1 )
499 IF( lsame( job,
'I' ) .OR. lsame( job,
'C' ) )
THEN
500 CALL scopy( dim-2, work(iph+2), dim+1,
501 $ h(ii+(jj-1)*lldh+2), lldh+1 )
502 CALL scopy( dim-3, work(iph+3), dim+1,
503 $ h(ii+(jj-1)*lldh+3), lldh+1 )
505 CALL slaset(
'Lower', dim-2, dim-2, zero,
506 $ zero, h(ii+(jj-1)*lldh+2), lldh )
512 CALL slamov(
'All', lnwin, lnwin,
513 $ work(ipuu+(
max(ntiny+1,dim)*liroffh)+liroffh),
514 $
max(ntiny+1,dim), work(ipu), lnwin )
522 iwork( 5+(win-1)*5 ) = 2
527 IF( myrow.EQ.lrsrc .OR. mycol.EQ.lcsrc )
THEN
528 IF( idonejob.EQ.1 .AND. iwork(5+(win-1)*5).LT.2 )
THEN
529 IF( myrow.EQ.lrsrc ) lenrbuf = lenrbuf + lnwin*lnwin
530 IF( mycol.EQ.lcsrc ) lencbuf = lencbuf + lnwin*lnwin
537 CALL igsum2d( ictxt,
'All',
'1-Tree', 1, 1, idonejob, 1, -1, -1 )
538 donejob = idonejob.GT.0
543 $
CALL igamx2d( ictxt,
'All',
'1-Tree', 1, 1, ichoff, 1, -1,
554 IF( lenrbuf.GT.0 .OR. lencbuf.GT.0 )
THEN
557 DO 60 win = 1, anmwin
558 IF( ( lenrbuf.EQ.0 .AND. lencbuf.EQ.0 ) .OR.
560 lrsrc = iwork( 3+(win-1)*5 )
561 lcsrc = iwork( 4+(win-1)*5 )
562 IF( myrow.EQ.lrsrc .AND. mycol.EQ.lcsrc )
THEN
563 IF( dir.EQ.1 .AND. lenrbuf.GT.0 .AND.
565 CALL sgebs2d( ictxt,
'Row',
'1-Tree', lenrbuf,
567 ELSEIF( dir.EQ.2 .AND. lencbuf.GT.0 .AND.
569 CALL sgebs2d( ictxt,
'Col',
'1-Tree', lencbuf,
573 $
CALL slamov(
'All', lenrbuf, 1, work, lenrbuf,
574 $ work(1+lenrbuf), lencbuf )
576 ELSEIF( myrow.EQ.lrsrc .AND. dir.EQ.1 )
THEN
577 IF( lenrbuf.GT.0 .AND. npcol.GT.1 )
THEN
578 CALL sgebr2d( ictxt,
'Row',
'1-Tree', lenrbuf,
579 $ 1, work, lenrbuf, lrsrc, lcsrc )
582 ELSEIF( mycol.EQ.lcsrc .AND. dir.EQ.2 )
THEN
583 IF( lencbuf.GT.0 .AND. nprow.GT.1 )
THEN
584 CALL sgebr2d( ictxt,
'Col',
'1-Tree', lencbuf,
585 $ 1, work(1+lenrbuf), lencbuf, lrsrc, lcsrc )
604 DO 70 win = 1, anmwin
605 IF( iwork( 5+(win-1)*5 ).EQ.2 )
GO TO 75
606 lrsrc = iwork( 3+(win-1)*5 )
607 lcsrc = iwork( 4+(win-1)*5 )
608 lktop = iwork( 1+(win-1)*5 )
609 lkbot = iwork( 2+(win-1)*5 )
610 lnwin = lkbot - lktop + 1
611 IF( (myrow.EQ.lrsrc.AND.lenrbuf.GT.0.AND.dir.EQ.1) .OR.
612 $ (mycol.EQ.lcsrc.AND.lencbuf.GT.0.AND.dir.EQ.2 ) )
618 ipnext = ipu + lnwin*lnwin
619 ipw = 1 + lenrbuf + lencbuf
620 liroffh = mod(lktop-1,nb)
626 IF( lktop.EQ.ktop .AND. lkbot.EQ.kbot )
THEN
628 ELSEIF( lktop.EQ.ktop )
THEN
629 job =
'Introduce and chase'
630 ELSEIF( lkbot.EQ.kbot )
THEN
631 job =
'Off-chase bulges'
640 IF( .NOT. blk22 .OR. .NOT. lsame(job,
'C')
641 $ .OR. lns.LE.2 )
THEN
643 IF( dir.EQ.2 .AND. lencbuf.GT.0 .AND.
644 $ mycol.EQ.lcsrc )
THEN
646 DO 80 indx = 1, lktop-liroffh-1, nb
647 CALL infog2l( indx, lktop, desch, nprow,
648 $ npcol, myrow, mycol, iloc, jloc, rsrc1,
650 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
651 lrows =
min( nb, lktop-indx )
652 CALL sgemm(
'No transpose',
'No transpose',
653 $ lrows, lnwin, lnwin, one,
654 $ h((jloc-1)*lldh+iloc), lldh,
655 $ work( ipu ), lnwin, zero,
658 CALL slamov(
'All', lrows, lnwin,
660 $ h((jloc-1)*lldh+iloc), lldh )
665 DO 90 indx = 1, n, nb
666 CALL infog2l( indx, lktop, descz, nprow,
667 $ npcol, myrow, mycol, iloc, jloc, rsrc1,
669 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
670 lrows =
min(nb,n-indx+1)
671 CALL sgemm(
'No transpose',
672 $
'No transpose', lrows, lnwin, lnwin,
673 $ one, z((jloc-1)*lldz+iloc), lldz,
674 $ work( ipu ), lnwin, zero,
676 CALL slamov(
'All', lrows, lnwin,
678 $ z((jloc-1)*lldz+iloc), lldz )
686 IF( dir.EQ.1 .AND. lenrbuf.GT.0 .AND.
687 $ myrow.EQ.lrsrc )
THEN
689 IF( iceil(lkbot,nb).EQ.iceil(kbot,nb) )
THEN
690 lcols =
min(iceil(kbot,nb)*nb,n) - kbot
694 IF( lcols.GT.0 )
THEN
696 CALL infog2l( lktop, indx, desch, nprow,
697 $ npcol, myrow, mycol, iloc, jloc,
699 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
700 CALL sgemm(
'Transpose',
'No Transpose',
701 $ lnwin, lcols, lnwin, one, work(ipu),
702 $ lnwin, h((jloc-1)*lldh+iloc), lldh,
703 $ zero, work(ipw), lnwin )
704 CALL slamov(
'All', lnwin, lcols,
706 $ h((jloc-1)*lldh+iloc), lldh )
710 indxs = iceil(lkbot,nb)*nb + 1
711 DO 95 indx = indxs, n, nb
713 $ desch, nprow, npcol, myrow, mycol,
714 $ iloc, jloc, rsrc1, csrc1 )
715 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
716 lcols =
min( nb, n-indx+1 )
717 CALL sgemm(
'Transpose',
'No Transpose',
718 $ lnwin, lcols, lnwin, one, work(ipu),
719 $ lnwin, h((jloc-1)*lldh+iloc), lldh,
722 CALL slamov(
'All', lnwin, lcols,
724 $ h((jloc-1)*lldh+iloc), lldh )
748 IF( dir.EQ.2 .AND. lencbuf.GT.0 .AND.
749 $ mycol.EQ.lcsrc )
THEN
751 DO 100 indx = 1, lktop-liroffh-1, nb
752 CALL infog2l( indx, lktop, desch, nprow,
753 $ npcol, myrow, mycol, iloc, jloc, rsrc1,
755 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
756 jloc1 = indxg2l( lktop+lnwin-ks, nb,
757 $ mycol, desch( csrc_ ), npcol )
758 lrows =
min( nb, lktop-indx )
759 CALL slamov(
'All', lrows, ks,
760 $ h((jloc1-1)*lldh+iloc ), lldh,
762 CALL strmm(
'Right',
'Upper',
763 $
'No transpose',
'Non-unit', lrows,
764 $ ks, one, work( ipu+lnwin-ks ), lnwin,
766 CALL sgemm(
'No transpose',
'No transpose',
767 $ lrows, ks, lnwin-ks, one,
768 $ h((jloc-1)*lldh+iloc), lldh,
769 $ work( ipu ), lnwin, one, work(ipw),
774 CALL slamov(
'All', lrows, lnwin-ks,
775 $ h((jloc-1)*lldh+iloc), lldh,
776 $ work( ipw+ks*lrows ), lrows )
777 CALL strmm(
'Right',
'Lower',
778 $
'No transpose',
'Non-Unit',
779 $ lrows, lnwin-ks, one,
780 $ work( ipu+lnwin*ks ), lnwin,
781 $ work( ipw+ks*lrows ), lrows )
782 CALL sgemm(
'No transpose',
'No transpose',
783 $ lrows, lnwin-ks, ks, one,
784 $ h((jloc1-1)*lldh+iloc), lldh,
785 $ work( ipu+lnwin*ks+lnwin-ks ), lnwin,
786 $ one, work( ipw+ks*lrows ), lrows )
790 CALL slamov(
'All', lrows, lnwin,
792 $ h((jloc-1)*lldh+iloc), lldh )
801 DO 110 indx = 1, n, nb
802 CALL infog2l( indx, lktop, descz, nprow,
803 $ npcol, myrow, mycol, iloc, jloc, rsrc1,
805 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
806 jloc1 = indxg2l( lktop+lnwin-ks, nb,
807 $ mycol, descz( csrc_ ), npcol )
808 lrows =
min(nb,n-indx+1)
809 CALL slamov(
'All', lrows, ks,
810 $ z((jloc1-1)*lldz+iloc ), lldz,
812 CALL strmm(
'Right',
'Upper',
813 $
'No transpose',
'Non-unit',
814 $ lrows, ks, one, work( ipu+lnwin-ks ),
815 $ lnwin, work(ipw), lrows )
816 CALL sgemm(
'No transpose',
817 $
'No transpose', lrows, ks, lnwin-ks,
818 $ one, z((jloc-1)*lldz+iloc), lldz,
819 $ work( ipu ), lnwin, one, work(ipw),
824 CALL slamov(
'All', lrows, lnwin-ks,
825 $ z((jloc-1)*lldz+iloc), lldz,
826 $ work( ipw+ks*lrows ), lrows)
827 CALL strmm(
'Right',
'Lower',
828 $
'No transpose',
'Non-unit',
829 $ lrows, lnwin-ks, one,
830 $ work( ipu+lnwin*ks ), lnwin,
831 $ work( ipw+ks*lrows ), lrows )
832 CALL sgemm(
'No transpose',
833 $
'No transpose', lrows, lnwin-ks, ks,
834 $ one, z((jloc1-1)*lldz+iloc), lldz,
835 $ work( ipu+lnwin*ks+lnwin-ks ), lnwin,
836 $ one, work( ipw+ks*lrows ),
841 CALL slamov(
'All', lrows, lnwin,
843 $ z((jloc-1)*lldz+iloc), lldz )
849 IF( dir.EQ.1 .AND. lenrbuf.GT.0 .AND.
850 $ myrow.EQ.lrsrc )
THEN
852 indxs = iceil(lkbot,nb)*nb + 1
853 DO 120 indx = indxs, n, nb
855 $ desch, nprow, npcol, myrow, mycol, iloc,
856 $ jloc, rsrc1, csrc1 )
857 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc1 )
THEN
861 iloc1 = indxg2l( lktop+lnwin-ks, nb,
862 $ myrow, desch( rsrc_ ), nprow )
863 lcols =
min( nb, n-indx+1 )
864 CALL slamov(
'All', ks, lcols,
865 $ h((jloc-1)*lldh+iloc1), lldh,
867 CALL strmm(
'Left',
'Upper',
'Transpose',
868 $
'Non-unit', ks, lcols, one,
869 $ work( ipu+lnwin-ks ), lnwin,
871 CALL sgemm(
'Transpose',
'No transpose',
872 $ ks, lcols, lnwin-ks, one, work(ipu),
873 $ lnwin, h((jloc-1)*lldh+iloc), lldh,
874 $ one, work(ipw), lnwin )
878 CALL slamov(
'All', lnwin-ks, lcols,
879 $ h((jloc-1)*lldh+iloc), lldh,
880 $ work( ipw+ks ), lnwin )
881 CALL strmm(
'Left',
'Lower',
'Transpose',
882 $
'Non-unit', lnwin-ks, lcols, one,
883 $ work( ipu+lnwin*ks ), lnwin,
884 $ work( ipw+ks ), lnwin )
885 CALL sgemm(
'Transpose',
'No Transpose',
886 $ lnwin-ks, lcols, ks, one,
887 $ work( ipu+lnwin*ks+lnwin-ks ), lnwin,
888 $ h((jloc-1)*lldh+iloc1), lldh,
889 $ one, work( ipw+ks ), lnwin )
893 CALL slamov(
'All', lnwin, lcols,
895 $ h((jloc-1)*lldh+iloc), lldh )
905 IF( lkbot.EQ.kbot )
THEN
908 iwork( 1+(win-1)*5 ) = lktop
909 iwork( 2+(win-1)*5 ) = lkbot
910 iwork( 5+(win-1)*5 ) = 2
912 lktop =
min( lktop + lnwin - lchain,
913 $ iceil( lktop, nb )*nb - lchain + 1,
915 iwork( 1+(win-1)*5 ) = lktop
916 lkbot =
min( lkbot + lnwin - lchain,
917 $ iceil( lkbot, nb )*nb, kbot )
918 iwork( 2+(win-1)*5 ) = lkbot
919 lnwin = lkbot-lktop+1
920 IF( lnwin.EQ.lchain ) iwork(5+(win-1)*5) = 2
930 IF( ichoff.GT.0 )
THEN
931 DO 128 win = 2, anmwin
932 iwork( 1+(win-2)*5 ) = iwork( 1+(win-1)*5 )
933 iwork( 2+(win-2)*5 ) = iwork( 2+(win-1)*5 )
934 iwork( 3+(win-2)*5 ) = iwork( 3+(win-1)*5 )
935 iwork( 4+(win-2)*5 ) = iwork( 4+(win-1)*5 )
936 iwork( 5+(win-2)*5 ) = iwork( 5+(win-1)*5 )
939 ipiw = 6+(anmwin-1)*5
944 IF( anmwin.LT.1 )
RETURN
960 DO 130 win = 1, anmwin
961 lktop1 = iwork( 1+(win-1)*5 )
962 lkbot = iwork( 2+(win-1)*5 )
963 lnwin =
max( 6,
min( lkbot - lktop1 + 1, lchain ) )
964 lkbot1 =
max(
min( kbot, iceil(lktop1,nb)*nb+lchain),
965 $
min( kbot,
min( lktop1+2*lnwin-1,
966 $ (iceil(lktop1,nb)+1)*nb ) ) )
967 iwork( 2+(win-1)*5 ) = lkbot1
983 DO 135 win = 1, anmwin
984 iwork( 5+(win-1)*5 ) = 0
997 wchunk =
max( 1,
min( anmwin, nprow-1, npcol-1 ) )
998 numchunk = iceil( anmwin, wchunk )
1011 DO 140 oddeven = 1,
min( 2, anmwin )
1012 DO 150 chunknum = 1, numchunk
1014 DO 160 win = oddeven+(chunknum-1)*wchunk,
1015 $
min(anmwin,
max(1,oddeven+(chunknum)*wchunk-1)), 2
1027 IF( iwork( 5+(win-1)*5 ).EQ.2 )
GO TO 165
1028 lktop = iwork( 1+(win-1)*5 )
1029 lkbot = iwork( 2+(win-1)*5 )
1031 lktop2 = iwork( 1+(win-2)*5 )
1035 IF( iceil(lktop,nb).EQ.iceil(lkbot,nb) .OR.
1036 $ lkbot.GE.lktop2 )
GO TO 165
1037 lnwin = lkbot - lktop + 1
1038 IF( lnwin.LE.ntiny .AND. lkbot.NE.kbot .AND.
1039 $ .NOT. mod(lkbot,nb).EQ.0 )
GO TO 165
1043 iwork( 5+(win-1)*5 ) = 1
1052 rsrc1 = iwork( 3+(win-1)*5 )
1053 csrc1 = iwork( 4+(win-1)*5 )
1055 csrc2 = mod( csrc1+1, npcol )
1056 rsrc3 = mod( rsrc1+1, nprow )
1058 rsrc4 = mod( rsrc1+1, nprow )
1059 csrc4 = mod( csrc1+1, npcol )
1063 IF( ( myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1 ) .OR.
1064 $ ( myrow.EQ.rsrc2 .AND. mycol.EQ.csrc2 ) .OR.
1065 $ ( myrow.EQ.rsrc3 .AND. mycol.EQ.csrc3 ) .OR.
1066 $ ( myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4 ) )
THEN
1071 dim1 = nb - mod(lktop-1,nb)
1079 lnwin =
max(ntiny+1,lnwin)
1085 ipuu = iph + lnwin**2
1086 ipv = ipuu + lnwin**2
1088 IF( dim.LT.lnwin )
THEN
1089 CALL slaset(
'All', lnwin, lnwin, zero,
1090 $ one, work( iph ), lnwin )
1092 CALL slaset(
'All', dim, dim, zero,
1093 $ zero, work( iph ), lnwin )
1098 IF( myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1 )
THEN
1099 iloc = indxg2l( lktop, nb, myrow,
1100 $ desch( rsrc_ ), nprow )
1101 jloc = indxg2l( lktop, nb, mycol,
1102 $ desch( csrc_ ), npcol )
1103 CALL slamov(
'All', dim1, dim1,
1104 $ h((jloc-1)*lldh+iloc), lldh, work(iph),
1106 IF( rsrc1.NE.rsrc4 .OR. csrc1.NE.csrc4 )
THEN
1108 CALL sgesd2d( ictxt, dim1, dim1,
1109 $ work(iph), lnwin, rsrc4, csrc4 )
1110 CALL sgerv2d( ictxt, dim4, dim4,
1111 $ work(iph+dim1*lnwin+dim1),
1112 $ lnwin, rsrc4, csrc4 )
1115 IF( myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4 )
THEN
1116 iloc = indxg2l( lktop+dim1, nb, myrow,
1117 $ desch( rsrc_ ), nprow )
1118 jloc = indxg2l( lktop+dim1, nb, mycol,
1119 $ desch( csrc_ ), npcol )
1120 CALL slamov(
'All', dim4, dim4,
1121 $ h((jloc-1)*lldh+iloc), lldh,
1122 $ work(iph+dim1*lnwin+dim1),
1124 IF( rsrc4.NE.rsrc1 .OR. csrc4.NE.csrc1 )
THEN
1126 CALL sgesd2d( ictxt, dim4, dim4,
1127 $ work(iph+dim1*lnwin+dim1),
1128 $ lnwin, rsrc1, csrc1 )
1129 CALL sgerv2d( ictxt, dim1, dim1,
1130 $ work(iph), lnwin, rsrc1, csrc1 )
1133 IF( myrow.EQ.rsrc2 .AND. mycol.EQ.csrc2 )
THEN
1134 iloc = indxg2l( lktop, nb, myrow,
1135 $ desch( rsrc_ ), nprow )
1136 jloc = indxg2l( lktop+dim1, nb, mycol,
1137 $ desch( csrc_ ), npcol )
1138 CALL slamov(
'All', dim1, dim4,
1139 $ h((jloc-1)*lldh+iloc), lldh,
1140 $ work(iph+dim1*lnwin), lnwin )
1141 IF( rsrc2.NE.rsrc1 .OR. csrc2.NE.csrc1 )
THEN
1143 CALL sgesd2d( ictxt, dim1, dim4,
1144 $ work(iph+dim1*lnwin),
1145 $ lnwin, rsrc1, csrc1 )
1148 IF( myrow.EQ.rsrc2 .AND. mycol.EQ.csrc2 )
THEN
1149 IF( rsrc2.NE.rsrc4 .OR. csrc2.NE.csrc4 )
THEN
1151 CALL sgesd2d( ictxt, dim1, dim4,
1152 $ work(iph+dim1*lnwin),
1153 $ lnwin, rsrc4, csrc4 )
1156 IF( myrow.EQ.rsrc3 .AND. mycol.EQ.csrc3 )
THEN
1157 iloc = indxg2l( lktop+dim1, nb, myrow,
1158 $ desch( rsrc_ ), nprow )
1159 jloc = indxg2l( lktop+dim1-1, nb, mycol,
1160 $ desch( csrc_ ), npcol )
1161 CALL slamov(
'All', 1, 1,
1162 $ h((jloc-1)*lldh+iloc), lldh,
1163 $ work(iph+(dim1-1)*lnwin+dim1),
1165 IF( rsrc3.NE.rsrc1 .OR. csrc3.NE.csrc1 )
THEN
1167 CALL sgesd2d( ictxt, 1, 1,
1168 $ work(iph+(dim1-1)*lnwin+dim1),
1169 $ lnwin, rsrc1, csrc1 )
1172 IF( myrow.EQ.rsrc3 .AND. mycol.EQ.csrc3 )
THEN
1173 IF( rsrc3.NE.rsrc4 .OR. csrc3.NE.csrc4 )
THEN
1175 CALL sgesd2d( ictxt, 1, 1,
1176 $ work(iph+(dim1-1)*lnwin+dim1),
1177 $ lnwin, rsrc4, csrc4 )
1180 IF( myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1 )
THEN
1181 IF( rsrc1.NE.rsrc2 .OR. csrc1.NE.csrc2 )
THEN
1183 CALL sgerv2d( ictxt, dim1, dim4,
1184 $ work(iph+dim1*lnwin),
1185 $ lnwin, rsrc2, csrc2 )
1187 IF( rsrc1.NE.rsrc3 .OR. csrc1.NE.csrc3 )
THEN
1189 CALL sgerv2d( ictxt, 1, 1,
1190 $ work(iph+(dim1-1)*lnwin+dim1),
1191 $ lnwin, rsrc3, csrc3 )
1194 IF( myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4 )
THEN
1195 IF( rsrc4.NE.rsrc2 .OR. csrc4.NE.csrc2 )
THEN
1197 CALL sgerv2d( ictxt, dim1, dim4,
1198 $ work(iph+dim1*lnwin),
1199 $ lnwin, rsrc2, csrc2 )
1201 IF( rsrc4.NE.rsrc3 .OR. csrc4.NE.csrc3 )
THEN
1203 CALL sgerv2d( ictxt, 1, 1,
1204 $ work(iph+(dim1-1)*lnwin+dim1),
1205 $ lnwin, rsrc3, csrc3 )
1218 IF( (myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1) .OR.
1219 $ (myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4) )
THEN
1220 IF( lktop.EQ.ktop .AND. lkbot.EQ.kbot .AND.
1221 $ (dim1.LE.lchain .OR. dim1.LE.ntiny ) )
THEN
1224 ELSEIF( lktop.EQ.ktop .AND.
1225 $ ( dim1.LE.lchain .OR. dim1.LE.ntiny ) )
THEN
1226 job =
'Introduce and chase'
1227 ELSEIF( lkbot.EQ.kbot )
THEN
1228 job =
'Off-chase bulges'
1231 job =
'Chase bulges'
1233 ku = lnwin - kdu + 1
1235 nho = ( lnwin-kdu+1-4 ) - ( kdu+1 ) + 1
1237 nve = lnwin - kdu - kwv + 1
1238 CALL slaset(
'All', lnwin, lnwin,
1239 $ zero, one, work(ipuu), lnwin )
1243 lks =
max(1, ns - win*lns + 1)
1244 CALL slaqr6( job, wantt, .true., lkacc22, lnwin,
1245 $ 1, dim, lns, sr( lks ), si( lks ),
1246 $ work(iph), lnwin, 1, dim,
1247 $ work(ipuu), lnwin, work(ipu), 3,
1248 $ work( iph+ku-1 ), lnwin, nve,
1249 $ work( iph+kwv-1 ), lnwin, nho,
1250 $ work( iph-1+ku+(kwh-1)*lnwin ), lnwin )
1254 IF( myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1 )
THEN
1255 iloc = indxg2l( lktop, nb, myrow,
1256 $ desch( rsrc_ ), nprow )
1257 jloc = indxg2l( lktop, nb, mycol,
1258 $ desch( csrc_ ), npcol )
1259 CALL slamov(
'All', dim1, dim1, work(iph),
1260 $ lnwin, h((jloc-1)*lldh+iloc),
1263 IF( myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4 )
THEN
1264 iloc = indxg2l( lktop+dim1, nb, myrow,
1265 $ desch( rsrc_ ), nprow )
1266 jloc = indxg2l( lktop+dim1, nb, mycol,
1267 $ desch( csrc_ ), npcol )
1268 CALL slamov(
'All', dim4, dim4,
1269 $ work(iph+dim1*lnwin+dim1),
1270 $ lnwin, h((jloc-1)*lldh+iloc), lldh )
1276 CALL slamov(
'All', dim, dim,
1277 $ work(ipuu), lnwin, work(ipu), dim )
1284 IF( myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1 )
THEN
1285 IF( rsrc1.NE.rsrc3 .OR. csrc1.NE.csrc3 )
THEN
1287 CALL sgesd2d( ictxt, rws3, cls3,
1288 $ work( iph+(dim1-cls3)*lnwin+dim1 ),
1289 $ lnwin, rsrc3, csrc3 )
1292 IF( myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4 )
THEN
1293 IF( rsrc4.NE.rsrc2 .OR. csrc4.NE.csrc2 )
THEN
1295 CALL sgesd2d( ictxt, dim1, dim4,
1296 $ work( iph+dim1*lnwin),
1297 $ lnwin, rsrc2, csrc2 )
1300 IF( myrow.EQ.rsrc2 .AND. mycol.EQ.csrc2 )
THEN
1301 iloc = indxg2l( lktop, nb, myrow,
1302 $ desch( rsrc_ ), nprow )
1303 jloc = indxg2l( lktop+dim1, nb, mycol,
1304 $ desch( csrc_ ), npcol )
1305 IF( rsrc2.NE.rsrc4 .OR. csrc2.NE.csrc4 )
THEN
1307 CALL sgerv2d( ictxt, dim1, dim4,
1308 $ work(iph+dim1*lnwin),
1309 $ lnwin, rsrc4, csrc4 )
1311 CALL slamov(
'All', dim1, dim4,
1312 $ work( iph+dim1*lnwin ), lnwin,
1313 $ h((jloc-1)*lldh+iloc), lldh )
1315 IF( myrow.EQ.rsrc3 .AND. mycol.EQ.csrc3 )
THEN
1316 iloc = indxg2l( lktop+dim1, nb, myrow,
1317 $ desch( rsrc_ ), nprow )
1318 jloc = indxg2l( lktop+dim1-cls3, nb, mycol,
1319 $ desch( csrc_ ), npcol )
1320 IF( rsrc3.NE.rsrc1 .OR. csrc3.NE.csrc1 )
THEN
1322 CALL sgerv2d( ictxt, rws3, cls3,
1323 $ work( iph+(dim1-cls3)*lnwin+dim1 ),
1324 $ lnwin, rsrc1, csrc1 )
1326 CALL slamov(
'Upper', rws3, cls3,
1327 $ work( iph+(dim1-cls3)*lnwin+dim1 ),
1328 $ lnwin, h((jloc-1)*lldh+iloc),
1330 IF( rws3.GT.1 .AND. cls3.GT.1 )
THEN
1331 elem = work( iph+(dim1-cls3)*lnwin+dim1+1 )
1332 IF( elem.NE.zero )
THEN
1333 CALL slamov(
'Lower', rws3-1, cls3-1,
1334 $ work( iph+(dim1-cls3)*lnwin+dim1+1 ),
1335 $ lnwin, h((jloc-1)*lldh+iloc+1), lldh )
1349 IF( myrow.EQ.rsrc1 .OR. mycol.EQ.csrc1 .OR.
1350 $ myrow.EQ.rsrc4 .OR. mycol.EQ.csrc4 )
THEN
1351 IF( myrow.EQ.rsrc1 .OR. myrow.EQ.rsrc4 )
1352 $ lenrbuf = lenrbuf + lnwin*lnwin
1353 IF( mycol.EQ.csrc1 .OR. mycol.EQ.csrc4 )
1354 $ lencbuf = lencbuf + lnwin*lnwin
1372 DO 180 win = oddeven+(chunknum-1)*wchunk,
1373 $
min(anmwin,
max(1,oddeven+(chunknum)*wchunk-1)), 2
1374 IF( ( lenrbuf.EQ.0 .AND. lencbuf.EQ.0 ) .OR.
1375 $ bcdone )
GO TO 185
1376 rsrc1 = iwork( 3+(win-1)*5 )
1377 csrc1 = iwork( 4+(win-1)*5 )
1378 rsrc4 = mod( rsrc1+1, nprow )
1379 csrc4 = mod( csrc1+1, npcol )
1380 IF( ( myrow.EQ.rsrc1 .AND. mycol.EQ.csrc1 ) .OR.
1381 $ ( myrow.EQ.rsrc4 .AND. mycol.EQ.csrc4 ) )
THEN
1382 IF( dir.EQ.1 .AND. lenrbuf.GT.0 .AND.
1383 $ npcol.GT.1 .AND. nprocs.GT.2 )
THEN
1384 IF( myrow.EQ.rsrc1 .OR. ( myrow.EQ.rsrc4
1385 $ .AND. rsrc4.NE.rsrc1 ) )
THEN
1386 CALL sgebs2d( ictxt,
'Row',
'1-Tree',
1387 $ lenrbuf, 1, work, lenrbuf )
1389 CALL sgebr2d( ictxt,
'Row',
'1-Tree',
1390 $ lenrbuf, 1, work, lenrbuf, rsrc1,
1393 ELSEIF( dir.EQ.2 .AND. lencbuf.GT.0 .AND.
1394 $ nprow.GT.1 .AND. nprocs.GT.2 )
THEN
1395 IF( mycol.EQ.csrc1 .OR. ( mycol.EQ.csrc4
1396 $ .AND. csrc4.NE.csrc1 ) )
THEN
1397 CALL sgebs2d( ictxt,
'Col',
'1-Tree',
1398 $ lencbuf, 1, work, lencbuf )
1400 CALL sgebr2d( ictxt,
'Col',
'1-Tree',
1401 $ lencbuf, 1, work(1+lenrbuf), lencbuf,
1405 IF( lenrbuf.GT.0 .AND. ( mycol.EQ.csrc1 .OR.
1406 $ ( mycol.EQ.csrc4 .AND. csrc4.NE.csrc1 ) ) )
1407 $
CALL slamov(
'All', lenrbuf, 1, work, lenrbuf,
1408 $ work(1+lenrbuf), lencbuf )
1410 ELSEIF( myrow.EQ.rsrc1 .AND. dir.EQ.1 )
THEN
1411 IF( lenrbuf.GT.0 .AND. npcol.GT.1 )
1412 $
CALL sgebr2d( ictxt,
'Row',
'1-Tree', lenrbuf,
1413 $ 1, work, lenrbuf, rsrc1, csrc1 )
1415 ELSEIF( mycol.EQ.csrc1 .AND. dir.EQ.2 )
THEN
1416 IF( lencbuf.GT.0 .AND. nprow.GT.1 )
1417 $
CALL sgebr2d( ictxt,
'Col',
'1-Tree', lencbuf,
1418 $ 1, work(1+lenrbuf), lencbuf, rsrc1, csrc1 )
1420 ELSEIF( myrow.EQ.rsrc4 .AND. dir.EQ.1 )
THEN
1421 IF( lenrbuf.GT.0 .AND. npcol.GT.1 )
1422 $
CALL sgebr2d( ictxt,
'Row',
'1-Tree', lenrbuf,
1423 $ 1, work, lenrbuf, rsrc4, csrc4 )
1425 ELSEIF( mycol.EQ.csrc4 .AND. dir.EQ.2 )
THEN
1426 IF( lencbuf.GT.0 .AND. nprow.GT.1 )
1427 $
CALL sgebr2d( ictxt,
'Col',
'1-Tree', lencbuf,
1428 $ 1, work(1+lenrbuf), lencbuf, rsrc4, csrc4 )
1441 DO 200 win = oddeven+(chunknum-1)*wchunk,
1442 $
min(anmwin,
max(1,oddeven+(chunknum)*wchunk-1)), 2
1443 IF( iwork( 5+(win-1)*5 ).NE.1 )
GO TO 205
1449 lktop = iwork( 1+(win-1)*5 )
1450 lkbot = iwork( 2+(win-1)*5 )
1455 rsrc1 = iwork( 3+(win-1)*5 )
1456 csrc1 = iwork( 4+(win-1)*5 )
1457 rsrc4 = mod( rsrc1+1, nprow )
1458 csrc4 = mod( csrc1+1, npcol )
1463 IF(((mycol.EQ.csrc1.OR.mycol.EQ.csrc4).AND.dir.EQ.2)
1464 $ .OR.((myrow.EQ.rsrc1.OR.myrow.EQ.rsrc4).AND.
1467 lnwin = lkbot - lktop + 1
1469 dim1 = nb - mod(lktop-1,nb)
1471 ipnext = ipu + lnwin*lnwin
1474 zrows = numroc( n, nb, myrow, descz( rsrc_ ),
1480 hrows = numroc( lktop-1, nb, myrow,
1481 $ desch( rsrc_ ), nprow )
1491 hcols = numroc( n - (lktop+dim1-1), nb,
1492 $ mycol, csrc4, npcol )
1493 IF( mycol.EQ.csrc4 ) hcols = hcols - dim4
1500 ipw =
max( 1 + lenrbuf + lencbuf, ipw3 )
1501 ipw1 = ipw + hrows * lnwin
1503 ipw2 = ipw1 + lnwin * hcols
1504 ipw3 = ipw2 + zrows * lnwin
1506 ipw3 = ipw1 + lnwin * hcols
1513 IF( dir.EQ.2 .AND. wantt .AND. lencbuf.GT.0 )
THEN
1514 IF( mycol.EQ.csrc1 .OR. mycol.EQ.csrc4 )
THEN
1515 DO 210 indx = 1, nprow
1516 IF( mycol.EQ.csrc1 )
THEN
1517 CALL infog2l( 1+(indx-1)*nb, lktop, desch,
1518 $ nprow, npcol, myrow, mycol, iloc,
1519 $ jloc1, rsrc, csrc1 )
1520 IF( myrow.EQ.rsrc )
THEN
1521 CALL slamov(
'All', hrows, dim1,
1522 $ h((jloc1-1)*lldh+iloc), lldh,
1523 $ work(ipw), hrows )
1524 IF( npcol.GT.1 )
THEN
1525 east = mod( mycol + 1, npcol )
1526 CALL sgesd2d( ictxt, hrows, dim1,
1527 $ work(ipw), hrows, rsrc, east )
1528 CALL sgerv2d( ictxt, hrows, dim4,
1529 $ work(ipw+hrows*dim1), hrows,
1534 IF( mycol.EQ.csrc4 )
THEN
1535 CALL infog2l( 1+(indx-1)*nb, lktop+dim1,
1536 $ desch, nprow, npcol, myrow, mycol,
1537 $ iloc, jloc4, rsrc, csrc4 )
1538 IF( myrow.EQ.rsrc )
THEN
1539 CALL slamov(
'All', hrows, dim4,
1540 $ h((jloc4-1)*lldh+iloc), lldh,
1541 $ work(ipw+hrows*dim1), hrows )
1542 IF( npcol.GT.1 )
THEN
1543 west = mod( mycol - 1 + npcol,
1545 CALL sgesd2d( ictxt, hrows, dim4,
1546 $ work(ipw+hrows*dim1), hrows,
1548 CALL sgerv2d( ictxt, hrows, dim1,
1549 $ work(ipw), hrows, rsrc, west )
1557 IF( dir.EQ.1 .AND. wantt .AND. lenrbuf.GT.0 )
THEN
1558 IF( myrow.EQ.rsrc1 .OR. myrow.EQ.rsrc4 )
THEN
1559 DO 220 indx = 1, npcol
1560 IF( myrow.EQ.rsrc1 )
THEN
1561 IF( indx.EQ.1 )
THEN
1562 IF( lkbot.LT.n )
THEN
1563 CALL infog2l( lktop, lkbot+1, desch,
1564 $ nprow, npcol, myrow, mycol,
1565 $ iloc1, jloc, rsrc1, csrc )
1569 ELSEIF( mod(lkbot,nb).NE.0 )
THEN
1571 $ (iceil(lkbot,nb)+(indx-2))*nb+1,
1572 $ desch, nprow, npcol, myrow, mycol,
1573 $ iloc1, jloc, rsrc1, csrc )
1576 $ (iceil(lkbot,nb)+(indx-1))*nb+1,
1577 $ desch, nprow, npcol, myrow, mycol,
1578 $ iloc1, jloc, rsrc1, csrc )
1580 IF( mycol.EQ.csrc )
THEN
1581 CALL slamov(
'All', dim1, hcols,
1582 $ h((jloc-1)*lldh+iloc1), lldh,
1583 $ work(ipw1), lnwin )
1584 IF( nprow.GT.1 )
THEN
1585 south = mod( myrow + 1, nprow )
1586 CALL sgesd2d( ictxt, dim1, hcols,
1587 $ work(ipw1), lnwin, south,
1589 CALL sgerv2d( ictxt, dim4, hcols,
1590 $ work(ipw1+dim1), lnwin, south,
1595 IF( myrow.EQ.rsrc4 )
THEN
1596 IF( indx.EQ.1 )
THEN
1597 IF( lkbot.LT.n )
THEN
1598 CALL infog2l( lktop+dim1, lkbot+1,
1599 $ desch, nprow, npcol, myrow,
1600 $ mycol, iloc4, jloc, rsrc4,
1605 ELSEIF( mod(lkbot,nb).NE.0 )
THEN
1607 $ (iceil(lkbot,nb)+(indx-2))*nb+1,
1608 $ desch, nprow, npcol, myrow, mycol,
1609 $ iloc4, jloc, rsrc4, csrc )
1612 $ (iceil(lkbot,nb)+(indx-1))*nb+1,
1613 $ desch, nprow, npcol, myrow, mycol,
1614 $ iloc4, jloc, rsrc4, csrc )
1616 IF( mycol.EQ.csrc )
THEN
1617 CALL slamov(
'All', dim4, hcols,
1618 $ h((jloc-1)*lldh+iloc4), lldh,
1619 $ work(ipw1+dim1), lnwin )
1620 IF( nprow.GT.1 )
THEN
1621 north = mod( myrow - 1 + nprow,
1623 CALL sgesd2d( ictxt, dim4, hcols,
1624 $ work(ipw1+dim1), lnwin, north,
1626 CALL sgerv2d( ictxt, dim1, hcols,
1627 $ work(ipw1), lnwin, north,
1636 IF( dir.EQ.2 .AND. wantz .AND. lencbuf.GT.0)
THEN
1637 IF( mycol.EQ.csrc1 .OR. mycol.EQ.csrc4 )
THEN
1638 DO 230 indx = 1, nprow
1639 IF( mycol.EQ.csrc1 )
THEN
1640 CALL infog2l( 1+(indx-1)*nb, lktop,
1641 $ descz, nprow, npcol, myrow, mycol,
1642 $ iloc, jloc1, rsrc, csrc1 )
1643 IF( myrow.EQ.rsrc )
THEN
1644 CALL slamov(
'All', zrows, dim1,
1645 $ z((jloc1-1)*lldz+iloc), lldz,
1646 $ work(ipw2), zrows )
1647 IF( npcol.GT.1 )
THEN
1648 east = mod( mycol + 1, npcol )
1649 CALL sgesd2d( ictxt, zrows, dim1,
1650 $ work(ipw2), zrows, rsrc,
1652 CALL sgerv2d( ictxt, zrows, dim4,
1653 $ work(ipw2+zrows*dim1),
1654 $ zrows, rsrc, east )
1658 IF( mycol.EQ.csrc4 )
THEN
1660 $ lktop+dim1, descz, nprow, npcol,
1661 $ myrow, mycol, iloc, jloc4, rsrc,
1663 IF( myrow.EQ.rsrc )
THEN
1664 CALL slamov(
'All', zrows, dim4,
1665 $ z((jloc4-1)*lldz+iloc), lldz,
1666 $ work(ipw2+zrows*dim1), zrows )
1667 IF( npcol.GT.1 )
THEN
1668 west = mod( mycol - 1 + npcol,
1670 CALL sgesd2d( ictxt, zrows, dim4,
1671 $ work(ipw2+zrows*dim1),
1672 $ zrows, rsrc, west )
1673 CALL sgerv2d( ictxt, zrows, dim1,
1674 $ work(ipw2), zrows, rsrc,
1697 ipnext = 1 + lenrbuf
1700 DO 240 win = oddeven+(chunknum-1)*wchunk,
1701 $
min(anmwin,
max(1,oddeven+(chunknum)*wchunk-1)), 2
1702 IF( iwork( 5+(win-1)*5 ).NE.1 )
GO TO 245
1707 lktop = iwork( 1+(win-1)*5 )
1708 lkbot = iwork( 2+(win-1)*5 )
1709 lnwin = lkbot - lktop + 1
1714 rsrc1 = iwork( 3+(win-1)*5 )
1715 csrc1 = iwork( 4+(win-1)*5 )
1716 rsrc4 = mod( rsrc1+1, nprow )
1717 csrc4 = mod( csrc1+1, npcol )
1719 IF(((mycol.EQ.csrc1.OR.mycol.EQ.csrc4).AND.dir.EQ.2)
1720 $ .OR.((myrow.EQ.rsrc1.OR.myrow.EQ.rsrc4).AND.
1726 lktop = iwork( 1+(win-1)*5 )
1727 lkbot = iwork( 2+(win-1)*5 )
1728 lnwin = lkbot - lktop + 1
1729 dim1 = nb - mod(lktop-1,nb)
1731 ipu = ipnext + (winid-1)*lnwin*lnwin
1734 zrows = numroc( n, nb, myrow, descz( rsrc_ ),
1740 hrows = numroc( lktop-1, nb, myrow,
1741 $ desch( rsrc_ ), nprow )
1751 hcols = numroc( n - (lktop+dim1-1), nb,
1752 $ mycol, csrc4, npcol )
1753 IF( mycol.EQ.csrc4 ) hcols = hcols - dim4
1767 ipw =
max( 1 + lenrbuf + lencbuf, ipw3 )
1768 ipw1 = ipw + hrows * lnwin
1770 ipw2 = ipw1 + lnwin * hcols
1771 ipw3 = ipw2 + zrows * lnwin
1773 ipw3 = ipw1 + lnwin * hcols
1779 IF( lktop.EQ.ktop .AND. lkbot.EQ.kbot )
THEN
1781 ELSEIF( lktop.EQ.ktop .AND.
1782 $ ( dim1.LT.lchain+1 .OR. dim1.LE.ntiny ) )
1784 job =
'Introduce and chase'
1785 ELSEIF( lkbot.EQ.kbot )
THEN
1786 job =
'Off-chase bulges'
1788 job =
'Chase bulges'
1795 ks = dim1+dim4-lns/2*3
1796 IF( .NOT. blk22 .OR. dim1.NE.ks .OR.
1797 $ dim4.NE.ks .OR. lsame(job,
'I') .OR.
1798 $ lsame(job,
'O') .OR. lns.LE.2 )
THEN
1802 IF( dir.EQ.2 .AND. wantt .AND. lencbuf.GT.0 )
THEN
1803 DO 250 indx = 1,
min(lktop-1,1+(nprow-1)*nb), nb
1804 IF( mycol.EQ.csrc1 )
THEN
1805 CALL infog2l( indx, lktop, desch, nprow,
1806 $ npcol, myrow, mycol, iloc, jloc,
1808 IF( myrow.EQ.rsrc )
THEN
1809 CALL sgemm(
'No transpose',
1810 $
'No transpose', hrows, dim1,
1811 $ lnwin, one, work( ipw ), hrows,
1812 $ work( ipu ), lnwin, zero,
1813 $ work(ipw3), hrows )
1814 CALL slamov(
'All', hrows, dim1,
1815 $ work(ipw3), hrows,
1816 $ h((jloc-1)*lldh+iloc), lldh )
1819 IF( mycol.EQ.csrc4 )
THEN
1820 CALL infog2l( indx, lktop+dim1, desch,
1821 $ nprow, npcol, myrow, mycol, iloc,
1822 $ jloc, rsrc, csrc4 )
1823 IF( myrow.EQ.rsrc )
THEN
1824 CALL sgemm(
'No transpose',
1825 $
'No transpose', hrows, dim4,
1826 $ lnwin, one, work( ipw ), hrows,
1827 $ work( ipu+lnwin*dim1 ), lnwin,
1828 $ zero, work(ipw3), hrows )
1829 CALL slamov(
'All', hrows, dim4,
1830 $ work(ipw3), hrows,
1831 $ h((jloc-1)*lldh+iloc), lldh )
1837 IF( dir.EQ.2 .AND. wantz .AND. lencbuf.GT.0 )
THEN
1838 DO 260 indx = 1,
min(n,1+(nprow-1)*nb), nb
1839 IF( mycol.EQ.csrc1 )
THEN
1840 CALL infog2l( indx, lktop, descz, nprow,
1841 $ npcol, myrow, mycol, iloc, jloc,
1843 IF( myrow.EQ.rsrc )
THEN
1844 CALL sgemm(
'No transpose',
1845 $
'No transpose', zrows, dim1,
1846 $ lnwin, one, work( ipw2 ),
1847 $ zrows, work( ipu ), lnwin,
1848 $ zero, work(ipw3), zrows )
1849 CALL slamov(
'All', zrows, dim1,
1850 $ work(ipw3), zrows,
1851 $ z((jloc-1)*lldz+iloc), lldz )
1854 IF( mycol.EQ.csrc4 )
THEN
1855 CALL infog2l( indx, lktop+dim1, descz,
1856 $ nprow, npcol, myrow, mycol, iloc,
1857 $ jloc, rsrc, csrc4 )
1858 IF( myrow.EQ.rsrc )
THEN
1859 CALL sgemm(
'No transpose',
1860 $
'No transpose', zrows, dim4,
1861 $ lnwin, one, work( ipw2 ),
1863 $ work( ipu+lnwin*dim1 ), lnwin,
1864 $ zero, work(ipw3), zrows )
1865 CALL slamov(
'All', zrows, dim4,
1866 $ work(ipw3), zrows,
1867 $ z((jloc-1)*lldz+iloc), lldz )
1875 IF( dir.EQ.1 .AND. wantt .AND. lenrbuf.GT.0 )
THEN
1876 IF( lkbot.LT.n )
THEN
1877 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc4 .AND.
1878 $ mod(lkbot,nb).NE.0 )
THEN
1880 CALL infog2l( lktop, indx, desch, nprow,
1881 $ npcol, myrow, mycol, iloc, jloc,
1883 CALL sgemm(
'Transpose',
'No Transpose',
1884 $ dim1, hcols, lnwin, one, work(ipu),
1885 $ lnwin, work( ipw1 ), lnwin, zero,
1886 $ work(ipw3), dim1 )
1887 CALL slamov(
'All', dim1, hcols,
1889 $ h((jloc-1)*lldh+iloc), lldh )
1891 IF( myrow.EQ.rsrc4.AND.mycol.EQ.csrc4 .AND.
1892 $ mod(lkbot,nb).NE.0 )
THEN
1894 CALL infog2l( lktop+dim1, indx, desch,
1895 $ nprow, npcol, myrow, mycol, iloc,
1896 $ jloc, rsrc4, csrc4 )
1897 CALL sgemm(
'Transpose',
'No Transpose',
1898 $ dim4, hcols, lnwin, one,
1899 $ work( ipu+dim1*lnwin ), lnwin,
1900 $ work( ipw1), lnwin, zero,
1901 $ work(ipw3), dim4 )
1902 CALL slamov(
'All', dim4, hcols,
1904 $ h((jloc-1)*lldh+iloc), lldh )
1906 indxs = iceil(lkbot,nb)*nb + 1
1907 IF( mod(lkbot,nb).NE.0 )
THEN
1908 indxe =
min(n,indxs+(npcol-2)*nb)
1910 indxe =
min(n,indxs+(npcol-1)*nb)
1912 DO 270 indx = indxs, indxe, nb
1913 IF( myrow.EQ.rsrc1 )
THEN
1914 CALL infog2l( lktop, indx, desch,
1915 $ nprow, npcol, myrow, mycol, iloc,
1916 $ jloc, rsrc1, csrc )
1917 IF( mycol.EQ.csrc )
THEN
1918 CALL sgemm(
'Transpose',
1919 $
'No Transpose', dim1, hcols,
1920 $ lnwin, one, work( ipu ), lnwin,
1921 $ work( ipw1 ), lnwin, zero,
1922 $ work(ipw3), dim1 )
1923 CALL slamov(
'All', dim1, hcols,
1925 $ h((jloc-1)*lldh+iloc), lldh )
1928 IF( myrow.EQ.rsrc4 )
THEN
1929 CALL infog2l( lktop+dim1, indx, desch,
1930 $ nprow, npcol, myrow, mycol, iloc,
1931 $ jloc, rsrc4, csrc )
1932 IF( mycol.EQ.csrc )
THEN
1933 CALL sgemm(
'Transpose',
1934 $
'No Transpose', dim4, hcols,
1936 $ work( ipu+lnwin*dim1 ), lnwin,
1937 $ work( ipw1 ), lnwin,
1938 $ zero, work(ipw3), dim4 )
1939 CALL slamov(
'All', dim4, hcols,
1941 $ h((jloc-1)*lldh+iloc), lldh )
1953 IF( dir.EQ.2 .AND. wantt .AND. lencbuf.GT.0 )
THEN
1954 indxe =
min(lktop-1,1+(nprow-1)*nb)
1955 DO 280 indx = 1, indxe, nb
1956 IF( mycol.EQ.csrc1 )
THEN
1957 CALL infog2l( indx, lktop, desch, nprow,
1958 $ npcol, myrow, mycol, iloc, jloc,
1960 IF( myrow.EQ.rsrc )
THEN
1961 CALL slamov(
'All', hrows, ks,
1962 $ work( ipw+hrows*dim4), hrows,
1963 $ work(ipw3), hrows )
1964 CALL strmm(
'Right',
'Upper',
1966 $
'Non-unit', hrows, ks, one,
1967 $ work( ipu+dim4 ), lnwin,
1968 $ work(ipw3), hrows )
1969 CALL sgemm(
'No transpose',
1970 $
'No transpose', hrows, ks, dim4,
1971 $ one, work( ipw ), hrows,
1972 $ work( ipu ), lnwin, one,
1973 $ work(ipw3), hrows )
1974 CALL slamov(
'All', hrows, ks,
1975 $ work(ipw3), hrows,
1976 $ h((jloc-1)*lldh+iloc), lldh )
1983 IF( mycol.EQ.csrc4 )
THEN
1984 CALL infog2l( indx, lktop+dim1, desch,
1985 $ nprow, npcol, myrow, mycol, iloc,
1986 $ jloc, rsrc, csrc4 )
1987 IF( myrow.EQ.rsrc )
THEN
1988 CALL slamov(
'All', hrows, dim4,
1989 $ work(ipw), hrows, work( ipw3 ),
1991 CALL strmm(
'Right',
'Lower',
1993 $
'Non-unit', hrows, dim4, one,
1994 $ work( ipu+lnwin*ks ), lnwin,
1995 $ work( ipw3 ), hrows )
1996 CALL sgemm(
'No transpose',
1997 $
'No transpose', hrows, dim4, ks,
1998 $ one, work( ipw+hrows*dim4),
2000 $ work( ipu+lnwin*ks+dim4 ), lnwin,
2001 $ one, work( ipw3 ), hrows )
2002 CALL slamov(
'All', hrows, dim4,
2003 $ work(ipw3), hrows,
2004 $ h((jloc-1)*lldh+iloc), lldh )
2010 IF( dir.EQ.2 .AND. wantz .AND. lencbuf.GT.0 )
THEN
2015 indxe =
min(n,1+(nprow-1)*nb)
2016 DO 290 indx = 1, indxe, nb
2017 IF( mycol.EQ.csrc1 )
THEN
2018 CALL infog2l( indx, i, descz, nprow,
2019 $ npcol, myrow, mycol, iloc, jloc,
2021 IF( myrow.EQ.rsrc )
THEN
2022 CALL slamov(
'All', zrows, ks,
2023 $ work( ipw2+zrows*dim4),
2024 $ zrows, work(ipw3), zrows )
2025 CALL strmm(
'Right',
'Upper',
2027 $
'Non-unit', zrows, ks, one,
2028 $ work( ipu+dim4 ), lnwin,
2029 $ work(ipw3), zrows )
2030 CALL sgemm(
'No transpose',
2031 $
'No transpose', zrows, ks,
2032 $ dim4, one, work( ipw2 ),
2033 $ zrows, work( ipu ), lnwin,
2034 $ one, work(ipw3), zrows )
2035 CALL slamov(
'All', zrows, ks,
2036 $ work(ipw3), zrows,
2037 $ z((jloc-1)*lldz+iloc), lldz )
2044 IF( mycol.EQ.csrc4 )
THEN
2045 CALL infog2l( indx, i+dim1, descz,
2046 $ nprow, npcol, myrow, mycol, iloc,
2047 $ jloc, rsrc, csrc4 )
2048 IF( myrow.EQ.rsrc )
THEN
2049 CALL slamov(
'All', zrows, dim4,
2050 $ work(ipw2), zrows,
2051 $ work( ipw3 ), zrows )
2052 CALL strmm(
'Right',
'Lower',
2054 $
'Non-unit', zrows, dim4,
2055 $ one, work( ipu+lnwin*ks ),
2056 $ lnwin, work( ipw3 ), zrows )
2057 CALL sgemm(
'No transpose',
2058 $
'No transpose', zrows, dim4,
2060 $ work( ipw2+zrows*(dim4)),
2062 $ work( ipu+lnwin*ks+dim4 ),
2063 $ lnwin, one, work( ipw3 ),
2065 CALL slamov(
'All', zrows, dim4,
2066 $ work(ipw3), zrows,
2067 $ z((jloc-1)*lldz+iloc), lldz )
2073 IF( dir.EQ.1 .AND. wantt .AND. lenrbuf.GT.0)
THEN
2074 IF ( lkbot.LT.n )
THEN
2079 IF( myrow.EQ.rsrc1.AND.mycol.EQ.csrc4.AND.
2080 $ mod(lkbot,nb).NE.0 )
THEN
2082 CALL infog2l( lktop, indx, desch, nprow,
2083 $ npcol, myrow, mycol, iloc, jloc,
2085 CALL slamov(
'All', ks, hcols,
2086 $ work( ipw1+dim4 ), lnwin,
2088 CALL strmm(
'Left',
'Upper',
'Transpose',
2089 $
'Non-unit', ks, hcols, one,
2090 $ work( ipu+dim4 ), lnwin,
2092 CALL sgemm(
'Transpose',
'No transpose',
2093 $ ks, hcols, dim4, one, work(ipu),
2094 $ lnwin, work(ipw1), lnwin,
2095 $ one, work(ipw3), ks )
2096 CALL slamov(
'All', ks, hcols,
2098 $ h((jloc-1)*lldh+iloc), lldh )
2104 IF( myrow.EQ.rsrc4.AND.mycol.EQ.csrc4.AND.
2105 $ mod(lkbot,nb).NE.0 )
THEN
2107 CALL infog2l( lktop+dim1, indx, desch,
2108 $ nprow, npcol, myrow, mycol, iloc,
2109 $ jloc, rsrc4, csrc4 )
2110 CALL slamov(
'All', dim4, hcols,
2111 $ work( ipw1 ), lnwin,
2112 $ work( ipw3 ), dim4 )
2113 CALL strmm(
'Left',
'Lower',
'Transpose',
2114 $
'Non-unit', dim4, hcols, one,
2115 $ work( ipu+lnwin*ks ), lnwin,
2116 $ work( ipw3 ), dim4 )
2117 CALL sgemm(
'Transpose',
'No Transpose',
2118 $ dim4, hcols, ks, one,
2119 $ work( ipu+lnwin*ks+dim4 ), lnwin,
2120 $ work( ipw1+dim1 ), lnwin,
2121 $ one, work( ipw3), dim4 )
2122 CALL slamov(
'All', dim4, hcols,
2124 $ h((jloc-1)*lldh+iloc), lldh )
2130 indxs = iceil(lkbot,nb)*nb+1
2131 IF( mod(lkbot,nb).NE.0 )
THEN
2132 indxe =
min(n,indxs+(npcol-2)*nb)
2134 indxe =
min(n,indxs+(npcol-1)*nb)
2136 DO 300 indx = indxs, indxe, nb
2137 IF( myrow.EQ.rsrc1 )
THEN
2138 CALL infog2l( lktop, indx, desch,
2139 $ nprow, npcol, myrow, mycol, iloc,
2140 $ jloc, rsrc1, csrc )
2141 IF( mycol.EQ.csrc )
THEN
2142 CALL slamov(
'All', ks, hcols,
2143 $ work( ipw1+dim4 ), lnwin,
2145 CALL strmm(
'Left',
'Upper',
2146 $
'Transpose',
'Non-unit',
2148 $ work( ipu+dim4 ), lnwin,
2150 CALL sgemm(
'Transpose',
2151 $
'No transpose', ks, hcols,
2152 $ dim4, one, work(ipu), lnwin,
2153 $ work(ipw1), lnwin, one,
2155 CALL slamov(
'All', ks, hcols,
2157 $ h((jloc-1)*lldh+iloc), lldh )
2164 IF( myrow.EQ.rsrc4 )
THEN
2165 CALL infog2l( lktop+dim1, indx, desch,
2166 $ nprow, npcol, myrow, mycol, iloc,
2167 $ jloc, rsrc4, csrc )
2168 IF( mycol.EQ.csrc )
THEN
2169 CALL slamov(
'All', dim4, hcols,
2170 $ work( ipw1 ), lnwin,
2171 $ work( ipw3 ), dim4 )
2172 CALL strmm(
'Left',
'Lower',
2173 $
'Transpose',
'Non-unit',
2175 $ work( ipu+lnwin*ks ), lnwin,
2176 $ work( ipw3 ), dim4 )
2177 CALL sgemm(
'Transpose',
2178 $
'No Transpose', dim4, hcols,
2180 $ work( ipu+lnwin*ks+dim4 ),
2181 $ lnwin, work( ipw1+dim1 ),
2182 $ lnwin, one, work( ipw3),
2184 CALL slamov(
'All', dim4, hcols,
2186 $ h((jloc-1)*lldh+iloc), lldh )
2198 IF( lkbot.EQ.kbot )
THEN
2201 iwork( 1+(win-1)*5 ) = lktop
2202 iwork( 2+(win-1)*5 ) = lkbot
2204 lktop =
min( lktop + lnwin - lchain,
2205 $
min( kbot, iceil( lkbot, nb )*nb ) -
2207 iwork( 1+(win-1)*5 ) = lktop
2208 lkbot =
min(
max( lkbot + lnwin - lchain,
2209 $ lktop + nwin - 1),
min( kbot,
2210 $ iceil( lkbot, nb )*nb ) )
2211 iwork( 2+(win-1)*5 ) = lkbot
2213 IF( iwork( 5+(win-1)*5 ).EQ.1 )
2214 $ iwork( 5+(win-1)*5 ) = 2
2215 iwork( 3+(win-1)*5 ) = rsrc4
2216 iwork( 4+(win-1)*5 ) = csrc4
2232 $
CALL igamx2d( ictxt,
'All',
'1-Tree', 1, 1, ichoff, 1,
2233 $ -1, -1, -1, -1, -1 )
2237 IF( ichoff.GT.0 )
THEN
2238 DO 198 win = 2, anmwin
2239 iwork( 1+(win-2)*5 ) = iwork( 1+(win-1)*5 )
2240 iwork( 2+(win-2)*5 ) = iwork( 2+(win-1)*5 )
2241 iwork( 3+(win-2)*5 ) = iwork( 3+(win-1)*5 )
2242 iwork( 4+(win-2)*5 ) = iwork( 4+(win-1)*5 )
2245 ipiw = 6+(anmwin-1)*5
2250 IF( anmwin.LT.1 )
RETURN
2255 DO 199 win = 1, anmwin
2256 winfin = winfin+iwork( 5+(win-1)*5 )
2258 IF( winfin.LT.2*anmwin )
GO TO 137
2263 DO 201 win = 1, anmwin
2264 iwork( 5+(win-1)*5 ) = 0