ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
pdgeqpf.f
Go to the documentation of this file.
00001       SUBROUTINE PDGEQPF( M, N, A, IA, JA, DESCA, IPIV, TAU, WORK,
00002      $                    LWORK, INFO )
00003 *
00004 *  -- ScaLAPACK routine (version 1.7) --
00005 *     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
00006 *     and University of California, Berkeley.
00007 *     March 14, 2000
00008 *
00009 *     .. Scalar Arguments ..
00010       INTEGER            IA, JA, INFO, LWORK, M, N
00011 *     ..
00012 *     .. Array Arguments ..
00013       INTEGER            DESCA( * ), IPIV( * )
00014       DOUBLE PRECISION   A( * ), TAU( * ), WORK( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  PDGEQPF computes a QR factorization with column pivoting of a
00021 *  M-by-N distributed matrix sub( A ) = A(IA:IA+M-1,JA:JA+N-1):
00022 *
00023 *                         sub( A ) * P = Q * R.
00024 *
00025 *  Notes
00026 *  =====
00027 *
00028 *  Each global data object is described by an associated description
00029 *  vector.  This vector stores the information required to establish
00030 *  the mapping between an object element and its corresponding process
00031 *  and memory location.
00032 *
00033 *  Let A be a generic term for any 2D block cyclicly distributed array.
00034 *  Such a global array has an associated description vector DESCA.
00035 *  In the following comments, the character _ should be read as
00036 *  "of the global array".
00037 *
00038 *  NOTATION        STORED IN      EXPLANATION
00039 *  --------------- -------------- --------------------------------------
00040 *  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
00041 *                                 DTYPE_A = 1.
00042 *  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
00043 *                                 the BLACS process grid A is distribu-
00044 *                                 ted over. The context itself is glo-
00045 *                                 bal, but the handle (the integer
00046 *                                 value) may vary.
00047 *  M_A    (global) DESCA( M_ )    The number of rows in the global
00048 *                                 array A.
00049 *  N_A    (global) DESCA( N_ )    The number of columns in the global
00050 *                                 array A.
00051 *  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
00052 *                                 the rows of the array.
00053 *  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
00054 *                                 the columns of the array.
00055 *  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
00056 *                                 row of the array A is distributed.
00057 *  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
00058 *                                 first column of the array A is
00059 *                                 distributed.
00060 *  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
00061 *                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
00062 *
00063 *  Let K be the number of rows or columns of a distributed matrix,
00064 *  and assume that its process grid has dimension p x q.
00065 *  LOCr( K ) denotes the number of elements of K that a process
00066 *  would receive if K were distributed over the p processes of its
00067 *  process column.
00068 *  Similarly, LOCc( K ) denotes the number of elements of K that a
00069 *  process would receive if K were distributed over the q processes of
00070 *  its process row.
00071 *  The values of LOCr() and LOCc() may be determined via a call to the
00072 *  ScaLAPACK tool function, NUMROC:
00073 *          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
00074 *          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
00075 *  An upper bound for these quantities may be computed by:
00076 *          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
00077 *          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
00078 *
00079 *  Arguments
00080 *  =========
00081 *
00082 *  M       (global input) INTEGER
00083 *          The number of rows to be operated on, i.e. the number of rows
00084 *          of the distributed submatrix sub( A ). M >= 0.
00085 *
00086 *  N       (global input) INTEGER
00087 *          The number of columns to be operated on, i.e. the number of
00088 *          columns of the distributed submatrix sub( A ). N >= 0.
00089 *
00090 *  A       (local input/local output) DOUBLE PRECISION pointer into the
00091 *          local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
00092 *          On entry, the local pieces of the M-by-N distributed matrix
00093 *          sub( A ) which is to be factored. On exit, the elements on
00094 *          and above the diagonal of sub( A ) contain the min(M,N) by N
00095 *          upper trapezoidal matrix R (R is upper triangular if M >= N);
00096 *          the elements below the diagonal, with the array TAU, repre-
00097 *          sent the orthogonal matrix Q as a product of elementary
00098 *          reflectors (see Further Details).
00099 *
00100 *  IA      (global input) INTEGER
00101 *          The row index in the global array A indicating the first
00102 *          row of sub( A ).
00103 *
00104 *  JA      (global input) INTEGER
00105 *          The column index in the global array A indicating the
00106 *          first column of sub( A ).
00107 *
00108 *  DESCA   (global and local input) INTEGER array of dimension DLEN_.
00109 *          The array descriptor for the distributed matrix A.
00110 *
00111 *  IPIV    (local output) INTEGER array, dimension LOCc(JA+N-1).
00112 *          On exit, if IPIV(I) = K, the local i-th column of sub( A )*P
00113 *          was the global K-th column of sub( A ). IPIV is tied to the
00114 *          distributed matrix A.
00115 *
00116 *  TAU     (local output) DOUBLE PRECISION array, dimension
00117 *          LOCc(JA+MIN(M,N)-1). This array contains the scalar factors
00118 *          TAU of the elementary reflectors. TAU is tied to the
00119 *          distributed matrix A.
00120 *
00121 *  WORK    (local workspace/local output) DOUBLE PRECISION array,
00122 *                                                   dimension (LWORK)
00123 *          On exit, WORK(1) returns the minimal and optimal LWORK.
00124 *
00125 *  LWORK   (local or global input) INTEGER
00126 *          The dimension of the array WORK.
00127 *          LWORK is local input and must be at least
00128 *          LWORK >= MAX(3,Mp0 + Nq0) + LOCc(JA+N-1)+Nq0.
00129 *
00130 *          IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ),
00131 *          IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ),
00132 *          IACOL = INDXG2P( JA, NB_A, MYCOL, CSRC_A, NPCOL ),
00133 *          Mp0   = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ),
00134 *          Nq0   = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ),
00135 *          LOCc(JA+N-1) = NUMROC( JA+N-1, NB_A, MYCOL, CSRC_A, NPCOL )
00136 *
00137 *          and NUMROC, INDXG2P are ScaLAPACK tool functions;
00138 *          MYROW, MYCOL, NPROW and NPCOL can be determined by calling
00139 *          the subroutine BLACS_GRIDINFO.
00140 *
00141 *          If LWORK = -1, then LWORK is global input and a workspace
00142 *          query is assumed; the routine only calculates the minimum
00143 *          and optimal size for all work arrays. Each of these
00144 *          values is returned in the first entry of the corresponding
00145 *          work array, and no error message is issued by PXERBLA.
00146 *
00147 *
00148 *  INFO    (global output) INTEGER
00149 *          = 0:  successful exit
00150 *          < 0:  If the i-th argument is an array and the j-entry had
00151 *                an illegal value, then INFO = -(i*100+j), if the i-th
00152 *                argument is a scalar and had an illegal value, then
00153 *                INFO = -i.
00154 *
00155 *  Further Details
00156 *  ===============
00157 *
00158 *  The matrix Q is represented as a product of elementary reflectors
00159 *
00160 *     Q = H(1) H(2) . . . H(n)
00161 *
00162 *  Each H(i) has the form
00163 *
00164 *     H = I - tau * v * v'
00165 *
00166 *  where tau is a real scalar, and v is a real vector with v(1:i-1) = 0
00167 *  and v(i) = 1; v(i+1:m) is stored on exit in A(ia+i-1:ia+m-1,ja+i-1).
00168 *
00169 *  The matrix P is represented in jpvt as follows: If
00170 *     jpvt(j) = i
00171 *  then the jth column of P is the ith canonical unit vector.
00172 *
00173 *  =====================================================================
00174 *
00175 *     .. Parameters ..
00176       INTEGER            BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
00177      $                   LLD_, MB_, M_, NB_, N_, RSRC_
00178       PARAMETER          ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,
00179      $                     CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,
00180      $                     RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )
00181       DOUBLE PRECISION   ONE, ZERO
00182       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00183 *     ..
00184 *     .. Local Scalars ..
00185       LOGICAL            LQUERY
00186       INTEGER            I, IACOL, IAROW, ICOFF, ICTXT, ICURROW,
00187      $                   ICURCOL, II, IIA, IOFFA, IPN, IPCOL, IPW,
00188      $                   IROFF, ITEMP, J, JB, JJ, JJA, JJPVT, JN, KB,
00189      $                   K, KK, KSTART, KSTEP, LDA, LL, LWMIN, MN, MP,
00190      $                   MYCOL, MYROW, NPCOL, NPROW, NQ, NQ0, PVT
00191       DOUBLE PRECISION   AJJ, ALPHA, TEMP, TEMP2
00192 *     ..
00193 *     .. Local Arrays ..
00194       INTEGER            DESCN( DLEN_ ), IDUM1( 1 ), IDUM2( 1 )
00195 *     ..
00196 *     .. External Subroutines ..
00197       EXTERNAL           BLACS_GRIDINFO, CHK1MAT, DCOPY, DESCSET,
00198      $                   DGEBR2D, DGEBS2D, DGERV2D,
00199      $                   DGESD2D, DLARFG, DSWAP, IGERV2D,
00200      $                   IGESD2D, INFOG1L, INFOG2L, PCHK1MAT, PDAMAX,
00201      $                   PDELSET, PDLARF, PDLARFG, PDNRM2,
00202      $                   PXERBLA
00203 *     ..
00204 *     .. External Functions ..
00205       INTEGER            ICEIL, INDXG2P, NUMROC
00206       EXTERNAL           ICEIL, INDXG2P, NUMROC
00207 *     ..
00208 *     .. Intrinsic Functions ..
00209       INTRINSIC          ABS, DBLE, IDINT, MAX, MIN, MOD, SQRT
00210 *     ..
00211 *     .. Executable Statements ..
00212 *
00213 *     Get grid parameters
00214 *
00215       ICTXT = DESCA( CTXT_ )
00216       CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
00217 *
00218 *     Test the input parameters
00219 *
00220       INFO = 0
00221       IF( NPROW.EQ.-1 ) THEN
00222          INFO = -(600+CTXT_)
00223       ELSE
00224          CALL CHK1MAT( M, 1, N, 2, IA, JA, DESCA, 6, INFO )
00225          IF( INFO.EQ.0 ) THEN
00226             IROFF = MOD( IA-1, DESCA( MB_ ) )
00227             ICOFF = MOD( JA-1, DESCA( NB_ ) )
00228             IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ),
00229      $                       NPROW )
00230             IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
00231      $                       NPCOL )
00232             MP = NUMROC( M+IROFF, DESCA( MB_ ), MYROW, IAROW, NPROW )
00233             NQ = NUMROC( N+ICOFF, DESCA( NB_ ), MYCOL, IACOL, NPCOL )
00234             NQ0 = NUMROC( JA+N-1, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
00235      $                    NPCOL )
00236             LWMIN = MAX( 3, MP + NQ ) + NQ0 + NQ
00237 *
00238             WORK( 1 ) = DBLE( LWMIN )
00239             LQUERY = ( LWORK.EQ.-1 )
00240             IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY )
00241      $         INFO = -10
00242          END IF
00243          IF( LWORK.EQ.-1 ) THEN
00244             IDUM1( 1 ) = -1
00245          ELSE
00246             IDUM1( 1 ) = 1
00247          END IF
00248          IDUM2( 1 ) = 10
00249          CALL PCHK1MAT( M, 1, N, 2, IA, JA, DESCA, 6, 1, IDUM1, IDUM2,
00250      $                  INFO )
00251       END IF
00252 *
00253       IF( INFO.NE.0 ) THEN
00254          CALL PXERBLA( ICTXT, 'PDGEQPF', -INFO )
00255          RETURN
00256       ELSE IF( LQUERY ) THEN
00257          RETURN
00258       END IF
00259 *
00260 *     Quick return if possible
00261 *
00262       IF( M.EQ.0 .OR. N.EQ.0 )
00263      $   RETURN
00264 *
00265       CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA,
00266      $              IAROW, IACOL )
00267       IF( MYROW.EQ.IAROW )
00268      $   MP = MP - IROFF
00269       IF( MYCOL.EQ.IACOL )
00270      $   NQ = NQ - ICOFF
00271       MN = MIN( M, N )
00272 *
00273 *     Initialize the array of pivots
00274 *
00275       LDA = DESCA( LLD_ )
00276       JN = MIN( ICEIL( JA, DESCA( NB_ ) ) * DESCA( NB_ ), JA+N-1 )
00277       KSTEP  = NPCOL * DESCA( NB_ )
00278 *
00279       IF( MYCOL.EQ.IACOL ) THEN
00280 *
00281 *        Handle first block separately
00282 *
00283          JB = JN - JA + 1
00284          DO 10 LL = JJA, JJA+JB-1
00285             IPIV( LL ) = JA + LL - JJA
00286    10    CONTINUE
00287          KSTART = JN + KSTEP - DESCA( NB_ )
00288 *
00289 *        Loop over remaining block of columns
00290 *
00291          DO 30 KK = JJA+JB, JJA+NQ-1, DESCA( NB_ )
00292             KB = MIN( JJA+NQ-KK, DESCA( NB_ ) )
00293             DO 20 LL = KK, KK+KB-1
00294                IPIV( LL ) = KSTART+LL-KK+1
00295    20       CONTINUE
00296             KSTART = KSTART + KSTEP
00297    30    CONTINUE
00298       ELSE
00299          KSTART = JN + ( MOD( MYCOL-IACOL+NPCOL, NPCOL )-1 )*
00300      $                        DESCA( NB_ )
00301          DO 50 KK = JJA, JJA+NQ-1, DESCA( NB_ )
00302             KB = MIN( JJA+NQ-KK, DESCA( NB_ ) )
00303             DO 40 LL = KK, KK+KB-1
00304                IPIV( LL ) = KSTART+LL-KK+1
00305    40       CONTINUE
00306             KSTART = KSTART + KSTEP
00307    50    CONTINUE
00308       END IF
00309 *
00310 *     Initialize partial column norms, handle first block separately
00311 *
00312       CALL DESCSET( DESCN, 1, DESCA( N_ ), 1, DESCA( NB_ ), MYROW,
00313      $              DESCA( CSRC_ ), ICTXT, 1 )
00314 *
00315       IPN = 1
00316       IPW = IPN + NQ0 + NQ
00317       JJ = IPN + JJA - 1
00318       IF( MYCOL.EQ.IACOL ) THEN
00319          DO 60 KK = 0, JB-1
00320             CALL PDNRM2( M, WORK( JJ+KK ), A, IA, JA+KK, DESCA, 1 )
00321             WORK( NQ+JJ+KK ) = WORK( JJ+KK )
00322    60    CONTINUE
00323          JJ = JJ + JB
00324       END IF
00325       ICURCOL = MOD( IACOL+1, NPCOL )
00326 *
00327 *     Loop over the remaining blocks of columns
00328 *
00329       DO 80 J = JN+1, JA+N-1, DESCA( NB_ )
00330          JB = MIN( JA+N-J, DESCA( NB_ ) )
00331 *
00332          IF( MYCOL.EQ.ICURCOL ) THEN
00333             DO 70 KK = 0, JB-1
00334                CALL PDNRM2( M, WORK( JJ+KK ), A, IA, J+KK, DESCA, 1 )
00335                WORK( NQ+JJ+KK ) = WORK( JJ+KK )
00336    70       CONTINUE
00337             JJ = JJ + JB
00338          END IF
00339          ICURCOL = MOD( ICURCOL+1, NPCOL )
00340    80 CONTINUE
00341 *
00342 *     Compute factorization
00343 *
00344       DO 120 J = JA, JA+MN-1
00345          I = IA + J - JA
00346 *
00347          CALL INFOG1L( J, DESCA( NB_ ), NPCOL, MYCOL, DESCA( CSRC_ ),
00348      $                 JJ, ICURCOL )
00349          K = JA + N - J
00350          IF( K.GT.1 ) THEN
00351             CALL PDAMAX( K, TEMP, PVT, WORK( IPN ), 1, J, DESCN,
00352      $                   DESCN( M_ ) )
00353          ELSE
00354             PVT = J
00355          END IF
00356          IF( J.NE.PVT ) THEN
00357             CALL INFOG1L( PVT, DESCA( NB_ ), NPCOL, MYCOL,
00358      $                    DESCA( CSRC_ ), JJPVT, IPCOL )
00359             IF( ICURCOL.EQ.IPCOL ) THEN
00360                IF( MYCOL.EQ.ICURCOL ) THEN
00361                   CALL DSWAP( MP, A( IIA+(JJ-1)*LDA ), 1,
00362      $                        A( IIA+(JJPVT-1)*LDA ), 1 )
00363                   ITEMP = IPIV( JJPVT )
00364                   IPIV( JJPVT ) = IPIV( JJ )
00365                   IPIV( JJ ) = ITEMP
00366                   WORK( IPN+JJPVT-1 ) = WORK( IPN+JJ-1 )
00367                   WORK( IPN+NQ+JJPVT-1 ) = WORK( IPN+NQ+JJ-1 )
00368                END IF
00369             ELSE
00370                IF( MYCOL.EQ.ICURCOL ) THEN
00371 *
00372                   CALL DGESD2D( ICTXT, MP, 1, A( IIA+(JJ-1)*LDA ), LDA,
00373      $                          MYROW, IPCOL )
00374                   WORK( IPW )   = DBLE( IPIV( JJ ) )
00375                   WORK( IPW+1 ) = WORK( IPN + JJ - 1 )
00376                   WORK( IPW+2 ) = WORK( IPN + NQ + JJ - 1 )
00377                   CALL DGESD2D( ICTXT, 3, 1, WORK( IPW ), 3, MYROW,
00378      $                          IPCOL )
00379 *
00380                   CALL DGERV2D( ICTXT, MP, 1, A( IIA+(JJ-1)*LDA ), LDA,
00381      $                          MYROW, IPCOL )
00382                   CALL IGERV2D( ICTXT, 1, 1, IPIV( JJ ), 1, MYROW,
00383      $                          IPCOL )
00384 *
00385                ELSE IF( MYCOL.EQ.IPCOL ) THEN
00386 *
00387                   CALL DGESD2D( ICTXT, MP, 1, A( IIA+(JJPVT-1)*LDA ),
00388      $                          LDA, MYROW, ICURCOL )
00389                   CALL IGESD2D( ICTXT, 1, 1, IPIV( JJPVT ), 1, MYROW,
00390      $                          ICURCOL )
00391 *
00392                   CALL DGERV2D( ICTXT, MP, 1, A( IIA+(JJPVT-1)*LDA ),
00393      $                          LDA, MYROW, ICURCOL )
00394                   CALL DGERV2D( ICTXT, 3, 1, WORK( IPW ), 3, MYROW,
00395      $                          ICURCOL )
00396                   IPIV( JJPVT ) = IDINT( WORK( IPW ) )
00397                   WORK( IPN+JJPVT-1 ) = WORK( IPW+1 )
00398                   WORK( IPN+NQ+JJPVT-1 ) = WORK( IPW+2 )
00399 *
00400                END IF
00401 *
00402             END IF
00403 *
00404          END IF
00405 *
00406 *        Generate elementary reflector H(i)
00407 *
00408          CALL INFOG1L( I, DESCA( MB_ ), NPROW, MYROW, DESCA( RSRC_ ),
00409      $                 II, ICURROW )
00410          IF( DESCA( M_ ).EQ.1 ) THEN
00411             IF( MYROW.EQ.ICURROW ) THEN
00412                IF( MYCOL.EQ.ICURCOL ) THEN
00413                   IOFFA = II+(JJ-1)*DESCA( LLD_ )
00414                   AJJ = A( IOFFA )
00415                   CALL DLARFG( 1, AJJ, A( IOFFA ), 1, TAU( JJ ) )
00416                   IF( N.GT.1 ) THEN
00417                      ALPHA = ONE - TAU( JJ )
00418                      CALL DGEBS2D( ICTXT, 'Rowwise', ' ', 1, 1, ALPHA,
00419      $                                  1 )
00420                      CALL DSCAL( NQ-JJ, ALPHA, A( IOFFA+DESCA( LLD_ ) ),
00421      $                           DESCA( LLD_ ) )
00422                   END IF
00423                   CALL DGEBS2D( ICTXT, 'Columnwise', ' ', 1, 1,
00424      $                          TAU( JJ ), 1 )
00425                   A( IOFFA ) = AJJ
00426                ELSE
00427                   IF( N.GT.1 ) THEN
00428                      CALL DGEBR2D( ICTXT, 'Rowwise', ' ', 1, 1, ALPHA,
00429      $                             1, ICURROW, ICURCOL )
00430                      CALL DSCAL( NQ-JJ+1, ALPHA, A( I ), DESCA( LLD_ ) )
00431                   END IF
00432                END IF
00433             ELSE IF( MYCOL.EQ.ICURCOL ) THEN
00434                CALL DGEBR2D( ICTXT, 'Columnwise', ' ', 1, 1, TAU( JJ ),
00435      $                       1, ICURROW, ICURCOL )
00436             END IF
00437 *
00438          ELSE
00439 *
00440             CALL PDLARFG( M-J+JA, AJJ, I, J, A, MIN( I+1, IA+M-1 ), J,
00441      $                    DESCA, 1, TAU )
00442             IF( J.LT.JA+N-1 ) THEN
00443 *
00444 *              Apply H(i) to A(ia+j-ja:ia+m-1,j+1:ja+n-1) from the left
00445 *
00446                CALL PDELSET( A, I, J, DESCA, ONE )
00447                CALL PDLARF( 'Left', M-J+JA, JA+N-1-J, A, I, J, DESCA,
00448      $                      1, TAU, A, I, J+1, DESCA, WORK( IPW ) )
00449             END IF
00450             CALL PDELSET( A, I, J, DESCA, AJJ )
00451 *
00452          END IF
00453 *
00454 *        Update partial columns norms
00455 *
00456          IF( MYCOL.EQ.ICURCOL )
00457      $      JJ = JJ + 1
00458          IF( MOD( J, DESCA( NB_ ) ).EQ.0 )
00459      $      ICURCOL = MOD( ICURCOL+1, NPCOL )
00460          IF( (JJA+NQ-JJ).GT.0 ) THEN
00461             IF( MYROW.EQ.ICURROW ) THEN
00462                CALL DGEBS2D( ICTXT, 'Columnwise', ' ', 1, JJA+NQ-JJ,
00463      $                       A( II+( MIN( JJA+NQ-1, JJ )-1 )*LDA ),
00464      $                       LDA )
00465                CALL DCOPY( JJA+NQ-JJ, A( II+( MIN( JJA+NQ-1, JJ )
00466      $                     -1)*LDA ), LDA, WORK( IPW+MIN( JJA+NQ-1,
00467      $                    JJ )-1 ), 1 )
00468             ELSE
00469                CALL DGEBR2D( ICTXT, 'Columnwise', ' ', JJA+NQ-JJ, 1,
00470      $                       WORK( IPW+MIN( JJA+NQ-1, JJ )-1 ),
00471      $                       MAX( 1, NQ ), ICURROW, MYCOL )
00472             END IF
00473          END IF
00474 *
00475          JN = MIN( ICEIL( J+1, DESCA( NB_ ) ) * DESCA( NB_ ),
00476      $                    JA + N - 1 )
00477          IF( MYCOL.EQ.ICURCOL ) THEN
00478             DO 90 LL = JJ-1, JJ + JN - J - 2
00479                IF( WORK( IPN+LL ).NE.ZERO ) THEN
00480                   TEMP = ONE-( ABS( WORK( IPW+LL ) ) /
00481      $                         WORK( IPN+LL ) )**2
00482                   TEMP = MAX( TEMP, ZERO )
00483                   TEMP2 = ONE + 0.05D+0*TEMP*
00484      $                    ( WORK( IPN+LL ) / WORK( IPN+NQ+LL ) )**2
00485                   IF( TEMP2.EQ.ONE ) THEN
00486                      IF( IA+M-1.GT.I ) THEN
00487                         CALL PDNRM2( IA+M-I-1, WORK( IPN+LL ), A, I+1,
00488      $                               J+LL-JJ+2, DESCA, 1 )
00489                         WORK( IPN+NQ+LL ) = WORK( IPN+LL )
00490                      ELSE
00491                         WORK( IPN+LL ) = ZERO
00492                         WORK( IPN+NQ+LL ) = ZERO
00493                      END IF
00494                   ELSE
00495                      WORK( IPN+LL ) = WORK( IPN+LL ) * SQRT( TEMP )
00496                   END IF
00497                END IF
00498    90       CONTINUE
00499             JJ = JJ + JN - J
00500          END IF
00501          ICURCOL = MOD( ICURCOL+1, NPCOL )
00502 *
00503          DO 110 K = JN+1, JA+N-1, DESCA( NB_ )
00504             KB = MIN( JA+N-K, DESCA( NB_ ) )
00505 *
00506             IF( MYCOL.EQ.ICURCOL ) THEN
00507                DO 100 LL = JJ-1, JJ+KB-2
00508                   IF( WORK( IPN+LL ).NE.ZERO ) THEN
00509                      TEMP = ONE-( ABS( WORK( IPW+LL ) ) /
00510      $                            WORK( IPN+LL ) )**2
00511                      TEMP = MAX( TEMP, ZERO )
00512                      TEMP2 = ONE + 0.05D+0*TEMP*
00513      $                     ( WORK( IPN+LL ) / WORK( IPN+NQ+LL ) )**2
00514                      IF( TEMP2.EQ.ONE ) THEN
00515                         IF( IA+M-1.GT.I ) THEN
00516                            CALL PDNRM2( IA+M-I-1, WORK( IPN+LL ), A,
00517      $                                  I+1, K+LL-JJ+1, DESCA, 1 )
00518                            WORK( IPN+NQ+LL ) = WORK( IPN+LL )
00519                         ELSE
00520                            WORK( IPN+LL ) = ZERO
00521                            WORK( IPN+NQ+LL ) = ZERO
00522                         END IF
00523                      ELSE
00524                         WORK( IPN+LL ) = WORK( IPN+LL ) * SQRT( TEMP )
00525                      END IF
00526                   END IF
00527   100          CONTINUE
00528                JJ = JJ + KB
00529             END IF
00530             ICURCOL = MOD( ICURCOL+1, NPCOL )
00531 *
00532   110    CONTINUE
00533 *
00534   120 CONTINUE
00535 *
00536       WORK( 1 ) = DBLE( LWMIN )
00537 *
00538       RETURN
00539 *
00540 *     End of PDGEQPF
00541 *
00542       END