1 REAL FUNCTION PCLANTR( NORM, UPLO, DIAG, M, N, A,
2 $ IA, JA, DESCA, WORK )
11 CHARACTER diag, norm, uplo
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 )
174 INTEGER iacol, iarow, ictxt, ii, iia, icoff, ioffa,
175 $ iroff, j, jb, jj, jja, jn, kk, lda, ll, mp,
176 $ mycol, myrow, np, npcol, nprow, nq
180 REAL ssq( 2 ), colssq( 2 )
193 INTRINSIC abs,
max,
min, mod, real, sqrt
199 ictxt = desca( ctxt_ )
200 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
202 udiag =
lsame( diag,
'U' )
203 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
205 iroff = mod( ia-1, desca( mb_ ) )
206 icoff = mod( ja-1, desca( nb_ ) )
207 mp =
numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
208 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
214 ioffa = ( jja - 1 ) * lda
216 IF(
min( m, n ).EQ.0 )
THEN
223 ELSE IF(
lsame( norm,
'M' ) )
THEN
233 IF(
lsame( uplo,
'U' ) )
THEN
239 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
242 IF( mycol.EQ.iacol )
THEN
243 IF( myrow.EQ.iarow )
THEN
245 DO 20 ll = jj, jj + jb -1
246 DO 10 kk = iia,
min(ii+ll-jj-1,iia+mp-1)
247 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
252 DO 40 ll = jj, jj + jb -1
253 DO 30 kk = iia,
min( ii+ll-jj, iia+mp-1 )
254 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
260 DO 60 ll = jj, jj + jb -1
261 DO 50 kk = iia,
min( ii-1, iia+mp-1 )
262 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
272 iarow = mod( iarow+1, nprow )
273 iacol = mod( iacol+1, npcol )
277 DO 130 j = jn+1, ja+n-1, desca( nb_ )
278 jb =
min( ja+n-j, desca( nb_ ) )
280 IF( mycol.EQ.iacol )
THEN
281 IF( myrow.EQ.iarow )
THEN
283 DO 80 ll = jj, jj + jb -1
284 DO 70 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
285 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
290 DO 100 ll = jj, jj + jb -1
291 DO 90 kk = iia,
min( ii+ll-jj, iia+mp-1 )
292 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
298 DO 120 ll = jj, jj + jb -1
299 DO 110 kk = iia,
min( ii-1, iia+mp-1 )
300 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
310 iarow = mod( iarow+1, nprow )
311 iacol = mod( iacol+1, npcol )
321 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
324 IF( mycol.EQ.iacol )
THEN
325 IF( myrow.EQ.iarow )
THEN
327 DO 150 ll = jj, jj + jb -1
328 DO 140 kk = ii+ll-jj+1, iia+mp-1
329 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
334 DO 170 ll = jj, jj + jb -1
335 DO 160 kk = ii+ll-jj, iia+mp-1
336 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
342 DO 190 ll = jj, jj + jb -1
343 DO 180 kk = ii, iia+mp-1
344 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
354 iarow = mod( iarow+1, nprow )
355 iacol = mod( iacol+1, npcol )
359 DO 260 j = jn+1, ja+n-1, desca( nb_ )
360 jb =
min( ja+n-j, desca( nb_ ) )
362 IF( mycol.EQ.iacol )
THEN
363 IF( myrow.EQ.iarow )
THEN
365 DO 210 ll = jj, jj + jb -1
366 DO 200 kk = ii+ll-jj+1, iia+mp-1
367 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
372 DO 230 ll = jj, jj + jb -1
373 DO 220 kk = ii+ll-jj, iia+mp-1
374 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
380 DO 250 ll = jj, jj + jb -1
381 DO 240 kk = ii, iia+mp-1
382 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
392 iarow = mod( iarow+1, nprow )
393 iacol = mod( iacol+1, npcol )
401 CALL sgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, kk, ll, -1,
407 ELSE IF(
lsame( norm,
'O' ) .OR. norm.EQ.
'1' )
THEN
411 IF(
lsame( uplo,
'U' ) )
THEN
417 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
420 IF( mycol.EQ.iacol )
THEN
421 IF( myrow.EQ.iarow )
THEN
423 DO 280 ll = jj, jj + jb -1
425 DO 270 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
426 sum = sum + abs( a( ioffa+kk ) )
430 IF (kk <= iia+mp-1)
THEN
434 work( ll-jja+1 ) = sum
437 DO 300 ll = jj, jj + jb -1
439 DO 290 kk = iia,
min( ii+ll-jj, iia+mp-1 )
440 sum = sum + abs( a( ioffa+kk ) )
443 work( ll-jja+1 ) = sum
447 DO 320 ll = jj, jj + jb -1
449 DO 310 kk = iia,
min( ii-1, iia+mp-1 )
450 sum = sum + abs( a( ioffa+kk ) )
453 work( ll-jja+1 ) = sum
461 iarow = mod( iarow+1, nprow )
462 iacol = mod( iacol+1, npcol )
466 DO 390 j = jn+1, ja+n-1, desca( nb_ )
467 jb =
min( ja+n-j, desca( nb_ ) )
469 IF( mycol.EQ.iacol )
THEN
470 IF( myrow.EQ.iarow )
THEN
472 DO 340 ll = jj, jj + jb -1
474 DO 330 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
475 sum = sum + abs( a( ioffa+kk ) )
479 IF (kk <= iia+mp-1)
THEN
483 work( ll-jja+1 ) = sum
486 DO 360 ll = jj, jj + jb -1
488 DO 350 kk = iia,
min( ii+ll-jj, iia+mp-1 )
489 sum = sum + abs( a( ioffa+kk ) )
492 work( ll-jja+1 ) = sum
496 DO 380 ll = jj, jj + jb -1
498 DO 370 kk = iia,
min( ii-1, iia+mp-1 )
499 sum = sum + abs( a( ioffa+kk ) )
502 work( ll-jja+1 ) = sum
510 iarow = mod( iarow+1, nprow )
511 iacol = mod( iacol+1, npcol )
521 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
524 IF( mycol.EQ.iacol )
THEN
525 IF( myrow.EQ.iarow )
THEN
527 DO 410 ll = jj, jj + jb -1
529 DO 400 kk = ii+ll-jj+1, iia+mp-1
530 sum = sum + abs( a( ioffa+kk ) )
533 work( ll-jja+1 ) = sum
536 DO 430 ll = jj, jj + jb -1
538 DO 420 kk = ii+ll-jj, iia+mp-1
539 sum = sum + abs( a( ioffa+kk ) )
542 work( ll-jja+1 ) = sum
546 DO 450 ll = jj, jj + jb -1
548 DO 440 kk = ii, iia+mp-1
549 sum = sum + abs( a( ioffa+kk ) )
552 work( ll-jja+1 ) = sum
560 iarow = mod( iarow+1, nprow )
561 iacol = mod( iacol+1, npcol )
565 DO 520 j = jn+1, ja+n-1, desca( nb_ )
566 jb =
min( ja+n-j, desca( nb_ ) )
568 IF( mycol.EQ.iacol )
THEN
569 IF( myrow.EQ.iarow )
THEN
571 DO 470 ll = jj, jj + jb -1
573 DO 460 kk = ii+ll-jj+1, iia+mp-1
574 sum = sum + abs( a( ioffa+kk ) )
577 work( ll-jja+1 ) = sum
580 DO 490 ll = jj, jj + jb -1
582 DO 480 kk = ii+ll-jj, iia+mp-1
583 sum = sum + abs( a( ioffa+kk ) )
586 work( ll-jja+1 ) = sum
590 DO 510 ll = jj, jj + jb -1
592 DO 500 kk = ii, iia+mp-1
593 sum = sum + abs( a( ioffa+kk ) )
596 work( ll-jja+1 ) = sum
604 iarow = mod( iarow+1, nprow )
605 iacol = mod( iacol+1, npcol )
614 CALL sgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work, 1,
619 IF( myrow.EQ.0 )
THEN
621 VALUE = work( isamax( nq, work, 1 ) )
625 CALL sgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, kk, ll,
632 ELSE IF(
lsame( norm,
'I' ) )
THEN
634 IF(
lsame( uplo,
'U' ) )
THEN
635 DO 540 kk = iia, iia+mp-1
639 DO 570 kk = iia, iia+mp-1
644 IF(
lsame( uplo,
'U' ) )
THEN
650 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
653 IF( mycol.EQ.iacol )
THEN
654 IF( myrow.EQ.iarow )
THEN
656 DO 590 ll = jj, jj + jb -1
657 DO 580 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
658 work( kk-iia+1 ) = work( kk-iia+1 ) +
659 $ abs( a( ioffa+kk ) )
663 IF (kk <= iia+mp-1)
THEN
664 work( kk-iia+1 ) = work( kk-iia+1 ) + one
669 DO 610 ll = jj, jj + jb -1
670 DO 600 kk = iia,
min( ii+ll-jj, iia+mp-1 )
671 work( kk-iia+1 ) = work( kk-iia+1 ) +
672 $ abs( a( ioffa+kk ) )
678 DO 630 ll = jj, jj + jb -1
679 DO 620 kk = iia,
min( ii-1, iia+mp-1 )
680 work( kk-iia+1 ) = work( kk-iia+1 ) +
681 $ abs( a( ioffa+kk ) )
691 iarow = mod( iarow+1, nprow )
692 iacol = mod( iacol+1, npcol )
696 DO 700 j = jn+1, ja+n-1, desca( nb_ )
697 jb =
min( ja+n-j, desca( nb_ ) )
699 IF( mycol.EQ.iacol )
THEN
700 IF( myrow.EQ.iarow )
THEN
702 DO 650 ll = jj, jj + jb -1
703 DO 640 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
704 work( kk-iia+1 ) = work( kk-iia+1 ) +
705 $ abs( a( ioffa+kk ) )
709 IF (kk <= iia+mp-1)
THEN
710 work( kk-iia+1 ) = work( kk-iia+1 ) + one
715 DO 670 ll = jj, jj + jb -1
716 DO 660 kk = iia,
min( ii+ll-jj, iia+mp-1 )
717 work( kk-iia+1 ) = work( kk-iia+1 ) +
718 $ abs( a( ioffa+kk ) )
724 DO 690 ll = jj, jj + jb -1
725 DO 680 kk = iia,
min( ii-1, iia+mp-1 )
726 work( kk-iia+1 ) = work( kk-iia+1 ) +
727 $ abs( a( ioffa+kk ) )
737 iarow = mod( iarow+1, nprow )
738 iacol = mod( iacol+1, npcol )
748 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
751 IF( mycol.EQ.iacol )
THEN
752 IF( myrow.EQ.iarow )
THEN
754 DO 720 ll = jj, jj + jb -1
757 work( kk-iia+1 ) = work( kk-iia+1 ) + one
758 DO 710 kk = ii+ll-jj+1, iia+mp-1
759 work( kk-iia+1 ) = work( kk-iia+1 ) +
760 $ abs( a( ioffa+kk ) )
765 DO 740 ll = jj, jj + jb -1
766 DO 730 kk = ii+ll-jj, iia+mp-1
767 work( kk-iia+1 ) = work( kk-iia+1 ) +
768 $ abs( a( ioffa+kk ) )
774 DO 760 ll = jj, jj + jb -1
775 DO 750 kk = ii, iia+mp-1
776 work( kk-iia+1 ) = work( kk-iia+1 ) +
777 $ abs( a( ioffa+kk ) )
787 iarow = mod( iarow+1, nprow )
788 iacol = mod( iacol+1, npcol )
792 DO 830 j = jn+1, ja+n-1, desca( nb_ )
793 jb =
min( ja+n-j, desca( nb_ ) )
795 IF( mycol.EQ.iacol )
THEN
796 IF( myrow.EQ.iarow )
THEN
798 DO 780 ll = jj, jj + jb -1
801 work( kk-iia+1 ) = work( kk-iia+1 ) + one
802 DO 770 kk = ii+ll-jj+1, iia+mp-1
803 work( kk-iia+1 ) = work( kk-iia+1 ) +
804 $ abs( a( ioffa+kk ) )
809 DO 800 ll = jj, jj + jb -1
810 DO 790 kk = ii+ll-jj, iia+mp-1
811 work( kk-iia+1 ) = work( kk-iia+1 ) +
812 $ abs( a( ioffa+kk ) )
818 DO 820 ll = jj, jj + jb -1
819 DO 810 kk = ii, iia+mp-1
820 work( kk-iia+1 ) = work( kk-iia+1 ) +
821 $ abs( a( ioffa+kk ) )
831 iarow = mod( iarow+1, nprow )
832 iacol = mod( iacol+1, npcol )
841 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1, work,
max( 1, mp ),
846 IF( mycol.EQ.0 )
THEN
848 VALUE = work( isamax( mp, work, 1 ) )
852 CALL sgamx2d( ictxt,
'Columnwise',
' ', 1, 1,
VALUE, 1, kk,
861 ELSE IF(
lsame( norm,
'F' ) .OR.
lsame( norm,
'E' ) )
THEN
865 ssq(2) = real(
min( m, n ) ) / real( nprow*npcol )
871 IF(
lsame( uplo,
'U' ) )
THEN
878 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
883 IF( mycol.EQ.iacol )
THEN
884 IF( myrow.EQ.iarow )
THEN
888 DO 840 ll = jj, jj + jb -1
891 CALL classq(
min( ii+ll-jj-1, iia+mp-1 )-iia+1,
893 $ colssq(1), colssq(2) )
898 DO 850 ll = jj, jj + jb -1
901 CALL classq(
min( ii+ll-jj, iia+mp-1 )-iia+1,
903 $ colssq(1), colssq(2) )
912 DO 860 ll = jj, jj + jb -1
915 CALL classq(
min( ii-1, iia+mp-1 )-iia+1,
917 $ colssq(1), colssq(2) )
930 iarow = mod( iarow+1, nprow )
931 iacol = mod( iacol+1, npcol )
935 DO 900 j = jn+1, ja+n-1, desca( nb_ )
936 jb =
min( ja+n-j, desca( nb_ ) )
938 IF( mycol.EQ.iacol )
THEN
939 IF( myrow.EQ.iarow )
THEN
941 DO 870 ll = jj, jj + jb -1
944 CALL classq(
min(ii+ll-jj-1, iia+mp-1)-iia+1,
946 $ colssq(1), colssq(2) )
951 DO 880 ll = jj, jj + jb -1
954 CALL classq(
min( ii+ll-jj, iia+mp-1 )-iia+1,
956 $ colssq(1), colssq(2) )
962 DO 890 ll = jj, jj + jb -1
965 CALL classq(
min( ii-1, iia+mp-1 )-iia+1,
967 $ colssq(1), colssq(2) )
977 iarow = mod( iarow+1, nprow )
978 iacol = mod( iacol+1, npcol )
989 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
992 IF( mycol.EQ.iacol )
THEN
993 IF( myrow.EQ.iarow )
THEN
995 DO 910 ll = jj, jj + jb -1
998 CALL classq( iia+mp-(ii+ll-jj+1),
999 $ a( ii+ll-jj+1+ioffa ), 1,
1000 $ colssq(1), colssq(2) )
1005 DO 920 ll = jj, jj + jb -1
1008 CALL classq( iia+mp-(ii+ll-jj),
1009 $ a( ii+ll-jj+ioffa ), 1,
1010 $ colssq(1), colssq(2) )
1016 DO 930 ll = jj, jj + jb -1
1019 CALL classq( iia+mp-ii, a( ii+ioffa ), 1,
1020 $ colssq(1), colssq(2) )
1028 IF( myrow.EQ.iarow )
1030 iarow = mod( iarow+1, nprow )
1031 iacol = mod( iacol+1, npcol )
1035 DO 970 j = jn+1, ja+n-1, desca( nb_ )
1036 jb =
min( ja+n-j, desca( nb_ ) )
1038 IF( mycol.EQ.iacol )
THEN
1039 IF( myrow.EQ.iarow )
THEN
1041 DO 940 ll = jj, jj + jb -1
1044 CALL classq( iia+mp-(ii+ll-jj+1),
1045 $ a( ii+ll-jj+1+ioffa ), 1,
1046 $ colssq(1), colssq(2) )
1051 DO 950 ll = jj, jj + jb -1
1054 CALL classq( iia+mp-(ii+ll-jj),
1055 $ a( ii+ll-jj+ioffa ), 1,
1056 $ colssq(1), colssq(2) )
1062 DO 960 ll = jj, jj + jb -1
1065 CALL classq( iia+mp-ii, a( ii+ioffa ), 1,
1066 $ colssq(1), colssq(2) )
1074 IF( myrow.EQ.iarow )
1076 iarow = mod( iarow+1, nprow )
1077 iacol = mod( iacol+1, npcol )
1087 VALUE = ssq( 1 ) * sqrt( ssq( 2 ) )
1093 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
1094 CALL sgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
1096 CALL sgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, 0, 0 )