1 REAL FUNCTION PCLANHE( NORM, UPLO, N, A, IA, JA,
164 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
165 $ lld_, mb_, m_, nb_, n_, rsrc_
166 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
167 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
168 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
170 parameter( one = 1.0e+0, zero = 0.0e+0 )
173 INTEGER i, iarow, iacol, ib, icoff, ictxt, icurcol,
174 $ icurrow, ii, iia, in, iroff, icsr, icsr0,
175 $ ioffa, irsc, irsc0, irsr, irsr0, jj, jja, k,
176 $ lda, ll, mycol, myrow, np, npcol, nprow, nq
177 REAL absa, scale, sum, value
183 EXTERNAL blacs_gridinfo, classq,
pscol2row,
185 $ sgamx2d, sgsum2d, sgebr2d, sgebs2d
193 INTRINSIC abs,
max,
min, mod, real, sqrt
199 ictxt = desca( ctxt_ )
200 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
201 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
202 $ iia, jja, iarow, iacol )
204 iroff = mod( ia-1, desca( mb_ ) )
205 icoff = mod( ja-1, desca( nb_ ) )
206 np =
numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
207 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
211 IF( myrow.EQ.iarow )
THEN
217 IF( mycol.EQ.iacol )
THEN
225 in =
min(
iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+n-1 )
267 ELSE IF( lsame( norm,
'M' ) )
THEN
273 IF( lsame( uplo,
'U' ) )
THEN
281 IF( mycol.EQ.iacol )
THEN
282 DO 20 k = (jj-1)*lda, (jj+ib-2)*lda, lda
285 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
301 IF( myrow.EQ.iarow )
THEN
302 DO 40 k = ii, ii+ib-1
303 IF( mycol.EQ.iacol )
THEN
304 IF( jj.LE.jja+nq-1 )
THEN
306 $ abs( real( a( k+(jj-1)*lda ) ) ) )
307 DO 30 ll = jj*lda, (jja+nq-2)*lda, lda
308 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
312 IF( jj.LE.jja+nq-1 )
THEN
313 DO 35 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
314 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
322 ELSE IF( mycol.EQ.iacol )
THEN
326 icurrow = mod( iarow+1, nprow )
327 icurcol = mod( iacol+1, npcol )
331 DO 90 i = in+1, ia+n-1, desca( mb_ )
332 ib =
min( desca( mb_ ), ia+n-i )
336 IF( mycol.EQ.icurcol )
THEN
337 DO 60 k = (jj-1)*lda, (jj+ib-2)*lda, lda
340 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
343 IF( myrow.EQ.icurrow )
349 IF( myrow.EQ.icurrow )
355 IF( myrow.EQ.icurrow )
THEN
356 DO 80 k = ii, ii+ib-1
357 IF( mycol.EQ.icurcol )
THEN
358 IF( jj.LE.jja+nq-1 )
THEN
360 $ abs( real( a( k+(jj-1)*lda ) ) ) )
361 DO 70 ll = jj*lda, (jja+nq-2)*lda, lda
362 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
366 IF( jj.LE.jja+nq-1 )
THEN
367 DO 75 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
368 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
372 IF( mycol.EQ.icurcol )
376 ELSE IF( mycol.EQ.icurcol )
THEN
379 icurrow = mod( icurrow+1, nprow )
380 icurcol = mod( icurcol+1, npcol )
391 IF( mycol.EQ.iacol )
THEN
392 DO 110 k = (jj-1)*lda, (jj+ib-2)*lda, lda
393 IF( myrow.EQ.iarow )
THEN
394 IF( ii.LE.iia+np-1 )
THEN
395 VALUE =
max(
VALUE, abs( real( a( ii+k ) ) ) )
396 DO 100 ll = ii+1, iia+np-1
397 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
401 IF( ii.LE.iia+np-1 )
THEN
402 DO 105 ll = ii, iia+np-1
403 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
419 IF( myrow.EQ.iarow )
THEN
422 DO 120 ll = (jja-1)*lda, (jj-2)*lda, lda
423 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
430 ELSE IF( mycol.EQ.iacol )
THEN
434 icurrow = mod( iarow+1, nprow )
435 icurcol = mod( iacol+1, npcol )
439 DO 180 i = in+1, ia+n-1, desca( mb_ )
440 ib =
min( desca( mb_ ), ia+n-i )
444 IF( mycol.EQ.icurcol )
THEN
445 DO 150 k = (jj-1)*lda, (jj+ib-2)*lda, lda
446 IF( myrow.EQ.icurrow )
THEN
447 IF( ii.LE.iia+np-1 )
THEN
449 $ abs( real( a( ii+k ) ) ) )
450 DO 140 ll = ii+1, iia+np-1
451 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
455 IF( ii.LE.iia+np-1 )
THEN
456 DO 145 ll = ii, iia+np-1
457 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
461 IF( myrow.EQ.icurrow )
467 IF( myrow.EQ.icurrow )
473 IF( myrow.EQ.icurrow )
THEN
476 DO 160 ll = (jja-1)*lda, (jj-2)*lda, lda
477 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
481 IF( mycol.EQ.icurcol )
484 ELSE IF( mycol.EQ.icurcol )
THEN
487 icurrow = mod( icurrow+1, nprow )
488 icurcol = mod( icurcol+1, npcol )
496 CALL sgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, i, k, -1,
499 ELSE IF( lsame( norm,
'I' ) .OR. lsame( norm,
'O' ) .OR.
505 IF( lsame( uplo,
'U' ) )
THEN
513 IF( mycol.EQ.iacol )
THEN
514 ioffa = ( jj - 1 ) * lda
518 DO 190 ll = iia, ii-1
519 sum = sum + abs( a( ll+ioffa ) )
523 work( jj+k-jja+icsr0 ) = sum
537 IF( myrow.EQ.iarow )
THEN
538 DO 220 k = ii, ii+ib-1
540 IF( mycol.EQ.iacol )
THEN
541 IF( jja+nq.GT.jj )
THEN
542 sum = abs( real( a( k+(jj-1)*lda ) ) )
543 DO 210 ll = jj*lda, (jja+nq-2)*lda, lda
544 sum = sum + abs( a( k+ll ) )
548 IF( jja+nq.GT.jj )
THEN
549 DO 215 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
550 sum = sum + abs( a( k+ll ) )
554 work( k-iia+irsc0 ) = sum
559 ELSE IF( mycol.EQ.iacol )
THEN
563 icurrow = mod( iarow+1, nprow )
564 icurcol = mod( iacol+1, npcol )
568 DO 270 i = in+1, ia+n-1, desca( mb_ )
569 ib =
min( desca( mb_ ), ia+n-i )
573 IF( mycol.EQ.icurcol )
THEN
574 ioffa = ( jj - 1 ) * lda
578 DO 230 ll = iia, ii-1
579 sum = sum + abs( a( ioffa+ll ) )
583 work( jj+k-jja+icsr0 ) = sum
584 IF( myrow.EQ.icurrow )
590 IF( myrow.EQ.icurrow )
597 IF( myrow.EQ.icurrow )
THEN
598 DO 260 k = ii, ii+ib-1
600 IF( mycol.EQ.icurcol )
THEN
601 IF( jja+nq.GT.jj )
THEN
602 sum = abs( real( a( k+(jj-1)*lda ) ) )
603 DO 250 ll = jj*lda, (jja+nq-2)*lda, lda
604 sum = sum + abs( a( k+ll ) )
608 IF( jja+nq.GT.jj )
THEN
609 DO 255 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
610 sum = sum + abs( a( k+ll ) )
614 work( k-iia+irsc0 ) = sum
615 IF( mycol.EQ.icurcol )
619 ELSE IF( mycol.EQ.icurcol )
THEN
623 icurrow = mod( icurrow+1, nprow )
624 icurcol = mod( icurcol+1, npcol )
636 IF( mycol.EQ.iacol )
THEN
640 IF( myrow.EQ.iarow )
THEN
641 IF( iia+np.GT.ii )
THEN
642 sum = abs( real( a( ioffa+ii ) ) )
643 DO 280 ll = ii+1, iia+np-1
644 sum = sum + abs( a( ioffa+ll ) )
648 DO 285 ll = ii, iia+np-1
649 sum = sum + abs( a( ioffa+ll ) )
653 work( jj+k-jja+icsr0 ) = sum
667 IF( myrow.EQ.iarow )
THEN
668 DO 310 k = ii, ii+ib-1
671 DO 300 ll = (jja-1)*lda, (jj-2)*lda, lda
672 sum = sum + abs( a( k+ll ) )
675 work( k-iia+irsc0 ) = sum
680 ELSE IF( mycol.EQ.iacol )
THEN
684 icurrow = mod( iarow+1, nprow )
685 icurcol = mod( iacol+1, npcol )
689 DO 360 i = in+1, ia+n-1, desca( mb_ )
690 ib =
min( desca( mb_ ), ia+n-i )
694 IF( mycol.EQ.icurcol )
THEN
695 ioffa = ( jj - 1 ) * lda
698 IF( myrow.EQ.icurrow )
THEN
699 IF( iia+np.GT.ii )
THEN
700 sum = abs( real( a( ii+ioffa ) ) )
701 DO 320 ll = ii+1, iia+np-1
702 sum = sum + abs( a( ll+ioffa ) )
704 ELSE IF( ii.EQ.iia+np-1 )
THEN
705 sum = abs( real( a( ii+ioffa ) ) )
708 DO 325 ll = ii, iia+np-1
709 sum = sum + abs( a( ll+ioffa ) )
713 work( jj+k-jja+icsr0 ) = sum
714 IF( myrow.EQ.icurrow )
720 IF( myrow.EQ.icurrow )
727 IF( myrow.EQ.icurrow )
THEN
728 DO 350 k = ii, ii+ib-1
731 DO 340 ll = (jja-1)*lda, (jj-2)*lda, lda
732 sum = sum + abs( a( k+ll ) )
735 work(k-iia+irsc0) = sum
736 IF( mycol.EQ.icurcol )
740 ELSE IF( mycol.EQ.icurcol )
THEN
744 icurrow = mod( icurrow+1, nprow )
745 icurcol = mod( icurcol+1, npcol )
757 CALL sgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work( icsr ), 1,
761 CALL sgsum2d( ictxt,
'Rowwise',
' ', np, 1, work( irsc ),
762 $
max( 1, np ), myrow, iacol )
764 CALL pscol2row( ictxt, n, 1, desca( mb_ ), work( irsc ),
765 $
max( 1, np ), work( irsr ),
max( 1, nq ),
766 $ iarow, iacol, iarow, iacol, work( irsc+np ) )
768 IF( myrow.EQ.iarow )
THEN
771 CALL saxpy( nq, one, work( irsr0 ), 1, work( icsr0 ), 1 )
775 VALUE = work( isamax( nq, work( icsr0 ), 1 ) )
777 CALL sgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, i, k,
781 ELSE IF( lsame( norm,
'F' ) .OR. lsame( norm,
'E' ) )
THEN
790 IF( lsame( uplo,
'U' ) )
THEN
796 IF( mycol.EQ.iacol )
THEN
797 DO 370 k = (jj-1)*lda, (jj+ib-2)*lda, lda
798 CALL classq( ii-iia, a( iia+k ), 1, scale, sum )
799 CALL classq( ii-iia, a( iia+k ), 1, scale, sum )
800 IF( myrow.EQ.iarow )
THEN
801 IF( real( a( ii+k ) ).NE.zero )
THEN
802 absa = abs( real( a( ii+k ) ) )
803 IF( scale.LT.absa )
THEN
804 sum = one + sum * ( scale / absa )**2
807 sum = sum + ( absa / scale )**2
815 ELSE IF( myrow.EQ.iarow )
THEN
819 icurrow = mod( iarow+1, nprow )
820 icurcol = mod( iacol+1, npcol )
824 DO 390 i = in+1, ia+n-1, desca( mb_ )
825 ib =
min( desca( mb_ ), ia+n-i )
827 IF( mycol.EQ.icurcol )
THEN
828 DO 380 k = (jj-1)*lda, (jj+ib-2)*lda, lda
829 CALL classq( ii-iia, a( iia+k ), 1, scale, sum )
830 CALL classq( ii-iia, a( iia+k ), 1, scale, sum )
831 IF( myrow.EQ.icurrow )
THEN
832 IF( real( a( ii+k ) ).NE.zero )
THEN
833 absa = abs( real( a( ii+k ) ) )
834 IF( scale.LT.absa )
THEN
835 sum = one + sum*( scale / absa )**2
838 sum = sum + ( absa / scale )**2
846 ELSE IF( myrow.EQ.icurrow )
THEN
850 icurrow = mod( icurrow+1, nprow )
851 icurcol = mod( icurcol+1, npcol )
861 IF( mycol.EQ.iacol )
THEN
862 DO 400 k = (jj-1)*lda, (jj+ib-2)*lda, lda
863 IF( myrow.EQ.iarow )
THEN
864 IF( real( a( ii+k ) ).NE.zero )
THEN
865 absa = abs( real( a( ii+k ) ) )
866 IF( scale.LT.absa )
THEN
867 sum = one + sum * ( scale / absa )**2
870 sum = sum + ( absa / scale )**2
875 CALL classq( iia+np-ii, a( ii+k ), 1, scale, sum )
876 CALL classq( iia+np-ii, a( ii+k ), 1, scale, sum )
880 ELSE IF( myrow.EQ.iarow )
THEN
884 icurrow = mod( iarow+1, nprow )
885 icurcol = mod( iacol+1, npcol )
889 DO 420 i = in+1, ia+n-1, desca( mb_ )
890 ib =
min( desca( mb_ ), ia+n-i )
892 IF( mycol.EQ.icurcol )
THEN
893 DO 410 k = (jj-1)*lda, (jj+ib-2)*lda, lda
894 IF( myrow.EQ.icurrow )
THEN
895 IF( real( a( ii+k ) ).NE.zero )
THEN
896 absa = abs( real( a( ii+k ) ) )
897 IF( scale.LT.absa )
THEN
898 sum = one + sum * ( scale / absa )**2
901 sum = sum + ( absa / scale )**2
906 CALL classq( iia+np-ii, a( ii+k ), 1, scale, sum )
907 CALL classq( iia+np-ii, a( ii+k ), 1, scale, sum )
911 ELSE IF( myrow.EQ.icurrow )
THEN
915 icurrow = mod( icurrow+1, nprow )
916 icurcol = mod( icurcol+1, npcol )
927 CALL pstreecomb( ictxt,
'All', 2, rwork, iarow, iacol,
929 VALUE = rwork( 1 ) * sqrt( rwork( 2 ) )
935 IF( myrow.EQ.iarow .AND. mycol.EQ.iacol )
THEN
936 CALL sgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
938 CALL sgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, iarow,