1 REAL FUNCTION PCLANSY( NORM, UPLO, N, A, IA, JA,
165 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
166 $ lld_, mb_, m_, nb_, n_, rsrc_
167 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
168 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
169 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
171 parameter( one = 1.0e+0, zero = 0.0e+0 )
174 INTEGER i, iarow, iacol, ib, icoff, ictxt, icurcol,
175 $ icurrow, ii, iia, in, iroff, icsr, icsr0,
176 $ ioffa, irsc, irsc0, irsr, irsr0, jj, jja, k,
177 $ lda, ll, mycol, myrow, np, npcol, nprow, nq
181 REAL ssq( 2 ), colssq( 2 )
184 EXTERNAL blacs_gridinfo, classq,
pscol2row,
186 $ sgamx2d, sgsum2d, sgebr2d, sgebs2d
194 INTRINSIC abs,
max,
min, mod, sqrt
200 ictxt = desca( ctxt_ )
201 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
202 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
203 $ iia, jja, iarow, iacol )
205 iroff = mod( ia-1, desca( mb_ ) )
206 icoff = mod( ja-1, desca( nb_ ) )
207 np =
numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
208 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
212 IF( myrow.EQ.iarow )
THEN
218 IF( mycol.EQ.iacol )
THEN
226 in =
min(
iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+n-1 )
271 ELSE IF(
lsame( norm,
'M' ) )
THEN
277 IF(
lsame( uplo,
'U' ) )
THEN
285 IF( mycol.EQ.iacol )
THEN
286 DO 20 k = (jj-1)*lda, (jj+ib-2)*lda, lda
289 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
305 IF( myrow.EQ.iarow )
THEN
306 DO 40 k = ii, ii+ib-1
307 IF( jj.LE.jja+nq-1 )
THEN
308 DO 30 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
309 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
316 ELSE IF( mycol.EQ.iacol )
THEN
320 icurrow = mod( iarow+1, nprow )
321 icurcol = mod( iacol+1, npcol )
325 DO 90 i = in+1, ia+n-1, desca( mb_ )
326 ib =
min( desca( mb_ ), ia+n-i )
330 IF( mycol.EQ.icurcol )
THEN
331 DO 60 k = (jj-1)*lda, (jj+ib-2)*lda, lda
334 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
337 IF( myrow.EQ.icurrow )
343 IF( myrow.EQ.icurrow )
349 IF( myrow.EQ.icurrow )
THEN
350 DO 80 k = ii, ii+ib-1
351 IF( jj.LE.jja+nq-1 )
THEN
352 DO 70 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
353 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
356 IF( mycol.EQ.icurcol )
360 ELSE IF( mycol.EQ.icurcol )
THEN
363 icurrow = mod( icurrow+1, nprow )
364 icurcol = mod( icurcol+1, npcol )
375 IF( mycol.EQ.iacol )
THEN
376 DO 110 k = (jj-1)*lda, (jj+ib-2)*lda, lda
377 IF( ii.LE.iia+np-1 )
THEN
378 DO 100 ll = ii, iia+np-1
379 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
394 IF( myrow.EQ.iarow )
THEN
397 DO 120 ll = (jja-1)*lda, (jj-2)*lda, lda
398 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
405 ELSE IF( mycol.EQ.iacol )
THEN
409 icurrow = mod( iarow+1, nprow )
410 icurcol = mod( iacol+1, npcol )
414 DO 180 i = in+1, ia+n-1, desca( mb_ )
415 ib =
min( desca( mb_ ), ia+n-i )
419 IF( mycol.EQ.icurcol )
THEN
420 DO 150 k = (jj-1)*lda, (jj+ib-2)*lda, lda
421 IF( ii.LE.iia+np-1 )
THEN
422 DO 140 ll = ii, iia+np-1
423 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
426 IF( myrow.EQ.icurrow )
432 IF( myrow.EQ.icurrow )
438 IF( myrow.EQ.icurrow )
THEN
441 DO 160 ll = (jja-1)*lda, (jj-2)*lda, lda
442 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
446 IF( mycol.EQ.icurcol )
449 ELSE IF( mycol.EQ.icurcol )
THEN
452 icurrow = mod( icurrow+1, nprow )
453 icurcol = mod( icurcol+1, npcol )
461 CALL sgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, i, k, -1,
467 ELSE IF(
lsame( norm,
'I' ) .OR.
lsame( norm,
'O' ) .OR.
473 IF(
lsame( uplo,
'U' ) )
THEN
481 IF( mycol.EQ.iacol )
THEN
482 ioffa = ( jj - 1 ) * lda
486 DO 190 ll = iia, ii-1
487 sum = sum + abs( a( ll+ioffa ) )
491 work( jj+k-jja+icsr0 ) = sum
505 IF( myrow.EQ.iarow )
THEN
506 DO 220 k = ii, ii+ib-1
508 IF( jja+nq.GT.jj )
THEN
509 DO 210 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
510 sum = sum + abs( a( k+ll ) )
513 work( k-iia+irsc0 ) = sum
518 ELSE IF( mycol.EQ.iacol )
THEN
522 icurrow = mod( iarow+1, nprow )
523 icurcol = mod( iacol+1, npcol )
527 DO 270 i = in+1, ia+n-1, desca( mb_ )
528 ib =
min( desca( mb_ ), ia+n-i )
532 IF( mycol.EQ.icurcol )
THEN
533 ioffa = ( jj - 1 ) * lda
537 DO 230 ll = iia, ii-1
538 sum = sum + abs( a( ioffa+ll ) )
542 work( jj+k-jja+icsr0 ) = sum
543 IF( myrow.EQ.icurrow )
549 IF( myrow.EQ.icurrow )
556 IF( myrow.EQ.icurrow )
THEN
557 DO 260 k = ii, ii+ib-1
559 IF( jja+nq.GT.jj )
THEN
560 DO 250 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
561 sum = sum + abs( a( k+ll ) )
564 work( k-iia+irsc0 ) = sum
565 IF( mycol.EQ.icurcol )
569 ELSE IF( mycol.EQ.icurcol )
THEN
573 icurrow = mod( icurrow+1, nprow )
574 icurcol = mod( icurcol+1, npcol )
586 IF( mycol.EQ.iacol )
THEN
590 IF( iia+np.GT.ii )
THEN
591 DO 280 ll = ii, iia+np-1
592 sum = sum + abs( a( ioffa+ll ) )
596 work( jj+k-jja+icsr0 ) = sum
610 IF( myrow.EQ.iarow )
THEN
611 DO 310 k = ii, ii+ib-1
614 DO 300 ll = (jja-1)*lda, (jj-2)*lda, lda
615 sum = sum + abs( a( k+ll ) )
618 work( k-iia+irsc0 ) = sum
623 ELSE IF( mycol.EQ.iacol )
THEN
627 icurrow = mod( iarow+1, nprow )
628 icurcol = mod( iacol+1, npcol )
632 DO 360 i = in+1, ia+n-1, desca( mb_ )
633 ib =
min( desca( mb_ ), ia+n-i )
637 IF( mycol.EQ.icurcol )
THEN
638 ioffa = ( jj - 1 ) * lda
641 IF( iia+np.GT.ii )
THEN
642 DO 320 ll = ii, iia+np-1
643 sum = sum + abs( a( ll+ioffa ) )
647 work( jj+k-jja+icsr0 ) = sum
648 IF( myrow.EQ.icurrow )
654 IF( myrow.EQ.icurrow )
661 IF( myrow.EQ.icurrow )
THEN
662 DO 350 k = ii, ii+ib-1
665 DO 340 ll = (jja-1)*lda, (jj-2)*lda, lda
666 sum = sum + abs( a( k+ll ) )
669 work(k-iia+irsc0) = sum
670 IF( mycol.EQ.icurcol )
674 ELSE IF( mycol.EQ.icurcol )
THEN
678 icurrow = mod( icurrow+1, nprow )
679 icurcol = mod( icurcol+1, npcol )
691 CALL sgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work( icsr ), 1,
695 CALL sgsum2d( ictxt,
'Rowwise',
' ', np, 1, work( irsc ),
696 $
max( 1, np ), myrow, iacol )
698 CALL pscol2row( ictxt, n, 1, desca( mb_ ), work( irsc ),
699 $
max( 1, np ), work( irsr ),
max( 1, nq ),
700 $ iarow, iacol, iarow, iacol, work( irsc+np ) )
702 IF( myrow.EQ.iarow )
THEN
705 CALL saxpy( nq, one, work( irsr0 ), 1, work( icsr0 ), 1 )
709 VALUE = work( isamax( nq, work( icsr0 ), 1 ) )
711 CALL sgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, i, k,
720 ELSE IF(
lsame( norm,
'F' ) .OR.
lsame( norm,
'E' ) )
THEN
729 IF(
lsame( uplo,
'U' ) )
THEN
735 IF( mycol.EQ.iacol )
THEN
736 DO 370 k = (jj-1)*lda, (jj+ib-2)*lda, lda
739 CALL classq( ii-iia, a( iia+k ), 1,
740 $ colssq(1), colssq(2) )
743 CALL classq( ii-iia, a( iia+k ), 1,
744 $ colssq(1), colssq(2) )
749 ELSE IF( myrow.EQ.iarow )
THEN
753 icurrow = mod( iarow+1, nprow )
754 icurcol = mod( iacol+1, npcol )
758 DO 390 i = in+1, ia+n-1, desca( mb_ )
759 ib =
min( desca( mb_ ), ia+n-i )
761 IF( mycol.EQ.icurcol )
THEN
762 DO 380 k = (jj-1)*lda, (jj+ib-2)*lda, lda
765 CALL classq( ii-iia, a( iia+k ), 1,
766 $ colssq(1), colssq(2) )
767 IF( myrow.EQ.icurrow )
769 CALL classq( ii-iia, a(iia+k ), 1,
770 $ colssq(1), colssq(2) )
775 ELSE IF( myrow.EQ.icurrow )
THEN
779 icurrow = mod( icurrow+1, nprow )
780 icurcol = mod( icurcol+1, npcol )
790 IF( mycol.EQ.iacol )
THEN
791 DO 400 k = (jj-1)*lda, (jj+ib-2)*lda, lda
794 CALL classq( iia+np-ii, a( ii+k ), 1,
795 $ colssq(1), colssq(2) )
798 CALL classq( iia+np-ii, a( ii+k ), 1,
799 $ colssq(1), colssq(2) )
804 ELSE IF( myrow.EQ.iarow )
THEN
808 icurrow = mod( iarow+1, nprow )
809 icurcol = mod( iacol+1, npcol )
813 DO 420 i = in+1, ia+n-1, desca( mb_ )
814 ib =
min( desca( mb_ ), ia+n-i )
816 IF( mycol.EQ.icurcol )
THEN
817 DO 410 k = (jj-1)*lda, (jj+ib-2)*lda, lda
820 CALL classq( iia+np-ii, a( ii+k ), 1,
821 $ colssq(1), colssq(2) )
822 IF( myrow.EQ.icurrow )
824 CALL classq( iia+np-ii, a( ii+k ), 1,
825 $ colssq(1), colssq(2) )
830 ELSE IF( myrow.EQ.icurrow )
THEN
834 icurrow = mod( icurrow+1, nprow )
835 icurcol = mod( icurcol+1, npcol )
843 CALL pstreecomb( ictxt,
'All', 2, ssq, iarow, iacol,
845 VALUE = ssq( 1 ) * sqrt( ssq( 2 ) )
851 IF( myrow.EQ.iarow .AND. mycol.EQ.iacol )
THEN
852 CALL sgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
854 CALL sgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, iarow,