1 DOUBLE PRECISION FUNCTION pzlansy( NORM, UPLO, N, A, IA, JA,
16 DOUBLE PRECISION work( * )
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 )
170 DOUBLE PRECISION one, zero
171 parameter( one = 1.0d+0, zero = 0.0d+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
178 DOUBLE PRECISION sum, value
181 DOUBLE PRECISION ssq( 2 ), colssq( 2 )
184 EXTERNAL blacs_gridinfo, daxpy,
dcombssq,
185 $ dgamx2d, dgsum2d, dgebr2d,
195 INTRINSIC abs,
max,
min, mod, sqrt
201 ictxt = desca( ctxt_ )
202 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
203 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
204 $ iia, jja, iarow, iacol )
206 iroff = mod( ia-1, desca( mb_ ) )
207 icoff = mod( ja-1, desca( nb_ ) )
208 np =
numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
209 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
213 IF( myrow.EQ.iarow )
THEN
219 IF( mycol.EQ.iacol )
THEN
227 in =
min(
iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+n-1 )
272 ELSE IF(
lsame( norm,
'M' ) )
THEN
278 IF(
lsame( uplo,
'U' ) )
THEN
286 IF( mycol.EQ.iacol )
THEN
287 DO 20 k = (jj-1)*lda, (jj+ib-2)*lda, lda
290 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
306 IF( myrow.EQ.iarow )
THEN
307 DO 40 k = ii, ii+ib-1
308 IF( jj.LE.jja+nq-1 )
THEN
309 DO 30 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
310 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
317 ELSE IF( mycol.EQ.iacol )
THEN
321 icurrow = mod( iarow+1, nprow )
322 icurcol = mod( iacol+1, npcol )
326 DO 90 i = in+1, ia+n-1, desca( mb_ )
327 ib =
min( desca( mb_ ), ia+n-i )
331 IF( mycol.EQ.icurcol )
THEN
332 DO 60 k = (jj-1)*lda, (jj+ib-2)*lda, lda
335 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
338 IF( myrow.EQ.icurrow )
344 IF( myrow.EQ.icurrow )
350 IF( myrow.EQ.icurrow )
THEN
351 DO 80 k = ii, ii+ib-1
352 IF( jj.LE.jja+nq-1 )
THEN
353 DO 70 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
354 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
357 IF( mycol.EQ.icurcol )
361 ELSE IF( mycol.EQ.icurcol )
THEN
364 icurrow = mod( icurrow+1, nprow )
365 icurcol = mod( icurcol+1, npcol )
376 IF( mycol.EQ.iacol )
THEN
377 DO 110 k = (jj-1)*lda, (jj+ib-2)*lda, lda
378 IF( ii.LE.iia+np-1 )
THEN
379 DO 100 ll = ii, iia+np-1
380 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
395 IF( myrow.EQ.iarow )
THEN
398 DO 120 ll = (jja-1)*lda, (jj-2)*lda, lda
399 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
406 ELSE IF( mycol.EQ.iacol )
THEN
410 icurrow = mod( iarow+1, nprow )
411 icurcol = mod( iacol+1, npcol )
415 DO 180 i = in+1, ia+n-1, desca( mb_ )
416 ib =
min( desca( mb_ ), ia+n-i )
420 IF( mycol.EQ.icurcol )
THEN
421 DO 150 k = (jj-1)*lda, (jj+ib-2)*lda, lda
422 IF( ii.LE.iia+np-1 )
THEN
423 DO 140 ll = ii, iia+np-1
424 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
427 IF( myrow.EQ.icurrow )
433 IF( myrow.EQ.icurrow )
439 IF( myrow.EQ.icurrow )
THEN
442 DO 160 ll = (jja-1)*lda, (jj-2)*lda, lda
443 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
447 IF( mycol.EQ.icurcol )
450 ELSE IF( mycol.EQ.icurcol )
THEN
453 icurrow = mod( icurrow+1, nprow )
454 icurcol = mod( icurcol+1, npcol )
462 CALL dgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, i, k, -1,
468 ELSE IF(
lsame( norm,
'I' ) .OR.
lsame( norm,
'O' ) .OR.
474 IF(
lsame( uplo,
'U' ) )
THEN
482 IF( mycol.EQ.iacol )
THEN
483 ioffa = ( jj - 1 ) * lda
487 DO 190 ll = iia, ii-1
488 sum = sum + abs( a( ll+ioffa ) )
492 work( jj+k-jja+icsr0 ) = sum
506 IF( myrow.EQ.iarow )
THEN
507 DO 220 k = ii, ii+ib-1
509 IF( jja+nq.GT.jj )
THEN
510 DO 210 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
511 sum = sum + abs( a( k+ll ) )
514 work( k-iia+irsc0 ) = sum
519 ELSE IF( mycol.EQ.iacol )
THEN
523 icurrow = mod( iarow+1, nprow )
524 icurcol = mod( iacol+1, npcol )
528 DO 270 i = in+1, ia+n-1, desca( mb_ )
529 ib =
min( desca( mb_ ), ia+n-i )
533 IF( mycol.EQ.icurcol )
THEN
534 ioffa = ( jj - 1 ) * lda
538 DO 230 ll = iia, ii-1
539 sum = sum + abs( a( ioffa+ll ) )
543 work( jj+k-jja+icsr0 ) = sum
544 IF( myrow.EQ.icurrow )
550 IF( myrow.EQ.icurrow )
557 IF( myrow.EQ.icurrow )
THEN
558 DO 260 k = ii, ii+ib-1
560 IF( jja+nq.GT.jj )
THEN
561 DO 250 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
562 sum = sum + abs( a( k+ll ) )
565 work( k-iia+irsc0 ) = sum
566 IF( mycol.EQ.icurcol )
570 ELSE IF( mycol.EQ.icurcol )
THEN
574 icurrow = mod( icurrow+1, nprow )
575 icurcol = mod( icurcol+1, npcol )
587 IF( mycol.EQ.iacol )
THEN
591 IF( iia+np.GT.ii )
THEN
592 DO 280 ll = ii, iia+np-1
593 sum = sum + abs( a( ioffa+ll ) )
597 work( jj+k-jja+icsr0 ) = sum
611 IF( myrow.EQ.iarow )
THEN
612 DO 310 k = ii, ii+ib-1
615 DO 300 ll = (jja-1)*lda, (jj-2)*lda, lda
616 sum = sum + abs( a( k+ll ) )
619 work( k-iia+irsc0 ) = sum
624 ELSE IF( mycol.EQ.iacol )
THEN
628 icurrow = mod( iarow+1, nprow )
629 icurcol = mod( iacol+1, npcol )
633 DO 360 i = in+1, ia+n-1, desca( mb_ )
634 ib =
min( desca( mb_ ), ia+n-i )
638 IF( mycol.EQ.icurcol )
THEN
639 ioffa = ( jj - 1 ) * lda
642 IF( iia+np.GT.ii )
THEN
643 DO 320 ll = ii, iia+np-1
644 sum = sum + abs( a( ll+ioffa ) )
648 work( jj+k-jja+icsr0 ) = sum
649 IF( myrow.EQ.icurrow )
655 IF( myrow.EQ.icurrow )
662 IF( myrow.EQ.icurrow )
THEN
663 DO 350 k = ii, ii+ib-1
666 DO 340 ll = (jja-1)*lda, (jj-2)*lda, lda
667 sum = sum + abs( a( k+ll ) )
670 work(k-iia+irsc0) = sum
671 IF( mycol.EQ.icurcol )
675 ELSE IF( mycol.EQ.icurcol )
THEN
679 icurrow = mod( icurrow+1, nprow )
680 icurcol = mod( icurcol+1, npcol )
692 CALL dgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work( icsr ), 1,
696 CALL dgsum2d( ictxt,
'Rowwise',
' ', np, 1, work( irsc ),
697 $
max( 1, np ), myrow, iacol )
699 CALL pdcol2row( ictxt, n, 1, desca( mb_ ), work( irsc ),
700 $
max( 1, np ), work( irsr ),
max( 1, nq ),
701 $ iarow, iacol, iarow, iacol, work( irsc+np ) )
703 IF( myrow.EQ.iarow )
THEN
706 CALL daxpy( nq, one, work( irsr0 ), 1, work( icsr0 ), 1 )
710 VALUE = work( idamax( nq, work( icsr0 ), 1 ) )
712 CALL dgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, i, k,
721 ELSE IF(
lsame( norm,
'F' ) .OR.
lsame( norm,
'E' ) )
THEN
730 IF(
lsame( uplo,
'U' ) )
THEN
736 IF( mycol.EQ.iacol )
THEN
737 DO 370 k = (jj-1)*lda, (jj+ib-2)*lda, lda
740 CALL zlassq( ii-iia, a( iia+k ), 1,
741 $ colssq(1), colssq(2) )
744 CALL zlassq( ii-iia, a( iia+k ), 1,
745 $ colssq(1), colssq(2) )
750 ELSE IF( myrow.EQ.iarow )
THEN
754 icurrow = mod( iarow+1, nprow )
755 icurcol = mod( iacol+1, npcol )
759 DO 390 i = in+1, ia+n-1, desca( mb_ )
760 ib =
min( desca( mb_ ), ia+n-i )
762 IF( mycol.EQ.icurcol )
THEN
763 DO 380 k = (jj-1)*lda, (jj+ib-2)*lda, lda
766 CALL zlassq( ii-iia, a( iia+k ), 1,
767 $ colssq(1), colssq(2) )
768 IF( myrow.EQ.icurrow )
770 CALL zlassq( ii-iia, a(iia+k ), 1,
771 $ colssq(1), colssq(2) )
776 ELSE IF( myrow.EQ.icurrow )
THEN
780 icurrow = mod( icurrow+1, nprow )
781 icurcol = mod( icurcol+1, npcol )
791 IF( mycol.EQ.iacol )
THEN
792 DO 400 k = (jj-1)*lda, (jj+ib-2)*lda, lda
795 CALL zlassq( iia+np-ii, a( ii+k ), 1,
796 $ colssq(1), colssq(2) )
799 CALL zlassq( iia+np-ii, a( ii+k ), 1,
800 $ colssq(1), colssq(2) )
805 ELSE IF( myrow.EQ.iarow )
THEN
809 icurrow = mod( iarow+1, nprow )
810 icurcol = mod( iacol+1, npcol )
814 DO 420 i = in+1, ia+n-1, desca( mb_ )
815 ib =
min( desca( mb_ ), ia+n-i )
817 IF( mycol.EQ.icurcol )
THEN
818 DO 410 k = (jj-1)*lda, (jj+ib-2)*lda, lda
821 CALL zlassq( iia+np-ii, a( ii+k ), 1,
822 $ colssq(1), colssq(2) )
823 IF( myrow.EQ.icurrow )
825 CALL zlassq( iia+np-ii, a( ii+k ), 1,
826 $ colssq(1), colssq(2) )
831 ELSE IF( myrow.EQ.icurrow )
THEN
835 icurrow = mod( icurrow+1, nprow )
836 icurcol = mod( icurcol+1, npcol )
844 CALL pdtreecomb( ictxt,
'All', 2, ssq, iarow, iacol,
846 VALUE = ssq( 1 ) * sqrt( ssq( 2 ) )
852 IF( myrow.EQ.iarow .AND. mycol.EQ.iacol )
THEN
853 CALL dgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
855 CALL dgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, iarow,