ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
pzpttrs.f
Go to the documentation of this file.
00001       SUBROUTINE PZPTTRS( UPLO, N, NRHS, D, E, JA, DESCA, B, IB, DESCB,
00002      $                    AF, LAF, WORK, LWORK, INFO )
00003 *
00004 *
00005 *
00006 *  -- ScaLAPACK routine (version 1.7) --
00007 *     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
00008 *     and University of California, Berkeley.
00009 *     August 7, 2001 
00010 *
00011 *     .. Scalar Arguments ..
00012       CHARACTER          UPLO
00013       INTEGER            IB, INFO, JA, LAF, LWORK, N, NRHS
00014 *     ..
00015 *     .. Array Arguments ..
00016       INTEGER            DESCA( * ), DESCB( * )
00017       COMPLEX*16         AF( * ), B( * ), E( * ), WORK( * )
00018       DOUBLE PRECISION   D( * )
00019 *     ..
00020 *
00021 *
00022 *  Purpose
00023 *  =======
00024 *
00025 *  PZPTTRS solves a system of linear equations
00026 *
00027 *            A(1:N, JA:JA+N-1) * X = B(IB:IB+N-1, 1:NRHS)
00028 *
00029 *  where A(1:N, JA:JA+N-1) is the matrix used to produce the factors
00030 *  stored in A(1:N,JA:JA+N-1) and AF by PZPTTRF.
00031 *  A(1:N, JA:JA+N-1) is an N-by-N complex
00032 *  tridiagonal symmetric positive definite distributed
00033 *  matrix.
00034 *  Depending on the value of UPLO, A stores either U or L in the equn
00035 *  A(1:N, JA:JA+N-1) = U'D *U or L*D L' as computed by PZPTTRF.
00036 *
00037 *  Routine PZPTTRF MUST be called first.
00038 *
00039 *  =====================================================================
00040 *
00041 *  Arguments
00042 *  =========
00043 *
00044 *  UPLO    (global input) CHARACTER
00045 *          = 'U':  Upper triangle of A(1:N, JA:JA+N-1) is stored;
00046 *          = 'L':  Lower triangle of A(1:N, JA:JA+N-1) is stored.
00047 *
00048 *  N       (global input) INTEGER
00049 *          The number of rows and columns to be operated on, i.e. the
00050 *          order of the distributed submatrix A(1:N, JA:JA+N-1). N >= 0.
00051 *
00052 *  NRHS    (global input) INTEGER
00053 *          The number of right hand sides, i.e., the number of columns
00054 *          of the distributed submatrix B(IB:IB+N-1, 1:NRHS).
00055 *          NRHS >= 0.
00056 *
00057 *  D       (local input/local output) COMPLEX*16 pointer to local
00058 *          part of global vector storing the main diagonal of the
00059 *          matrix.
00060 *          On exit, this array contains information containing the
00061 *            factors of the matrix.
00062 *          Must be of size >= DESCA( NB_ ).
00063 *
00064 *  E       (local input/local output) COMPLEX*16 pointer to local
00065 *          part of global vector storing the upper diagonal of the
00066 *          matrix. Globally, DU(n) is not referenced, and DU must be
00067 *          aligned with D.
00068 *          On exit, this array contains information containing the
00069 *            factors of the matrix.
00070 *          Must be of size >= DESCA( NB_ ).
00071 *
00072 *  JA      (global input) INTEGER
00073 *          The index in the global array A that points to the start of
00074 *          the matrix to be operated on (which may be either all of A
00075 *          or a submatrix of A).
00076 *
00077 *  DESCA   (global and local input) INTEGER array of dimension DLEN.
00078 *          if 1D type (DTYPE_A=501 or 502), DLEN >= 7;
00079 *          if 2D type (DTYPE_A=1), DLEN >= 9.
00080 *          The array descriptor for the distributed matrix A.
00081 *          Contains information of mapping of A to memory. Please
00082 *          see NOTES below for full description and options.
00083 *
00084 *  B       (local input/local output) COMPLEX*16 pointer into
00085 *          local memory to an array of local lead dimension lld_b>=NB.
00086 *          On entry, this array contains the
00087 *          the local pieces of the right hand sides
00088 *          B(IB:IB+N-1, 1:NRHS).
00089 *          On exit, this contains the local piece of the solutions
00090 *          distributed matrix X.
00091 *
00092 *  IB      (global input) INTEGER
00093 *          The row index in the global array B that points to the first
00094 *          row of the matrix to be operated on (which may be either
00095 *          all of B or a submatrix of B).
00096 *          IMPORTANT NOTE: The current version of this code supports
00097 *          only IB=JA
00098 *
00099 *  DESCB   (global and local input) INTEGER array of dimension DLEN.
00100 *          if 1D type (DTYPE_B=502), DLEN >=7;
00101 *          if 2D type (DTYPE_B=1), DLEN >= 9.
00102 *          The array descriptor for the distributed matrix B.
00103 *          Contains information of mapping of B to memory. Please
00104 *          see NOTES below for full description and options.
00105 *
00106 *  AF      (local output) COMPLEX*16 array, dimension LAF.
00107 *          Auxiliary Fillin Space.
00108 *          Fillin is created during the factorization routine
00109 *          PZPTTRF and this is stored in AF. If a linear system
00110 *          is to be solved using PZPTTRS after the factorization
00111 *          routine, AF *must not be altered* after the factorization.
00112 *
00113 *  LAF     (local input) INTEGER
00114 *          Size of user-input Auxiliary Fillin space AF. Must be >=
00115 *          (NB+2)
00116 *          If LAF is not large enough, an error code will be returned
00117 *          and the minimum acceptable size will be returned in AF( 1 )
00118 *
00119 *  WORK    (local workspace/local output)
00120 *          COMPLEX*16 temporary workspace. This space may
00121 *          be overwritten in between calls to routines. WORK must be
00122 *          the size given in LWORK.
00123 *          On exit, WORK( 1 ) contains the minimal LWORK.
00124 *
00125 *  LWORK   (local input or global input) INTEGER
00126 *          Size of user-input workspace WORK.
00127 *          If LWORK is too small, the minimal acceptable size will be
00128 *          returned in WORK(1) and an error code is returned. LWORK>=
00129 *          (10+2*min(100,NRHS))*NPCOL+4*NRHS
00130 *
00131 *  INFO    (local output) INTEGER
00132 *          = 0:  successful exit
00133 *          < 0:  If the i-th argument is an array and the j-entry had
00134 *                an illegal value, then INFO = -(i*100+j), if the i-th
00135 *                argument is a scalar and had an illegal value, then
00136 *                INFO = -i.
00137 *
00138 *  =====================================================================
00139 *
00140 *
00141 *  Restrictions
00142 *  ============
00143 *
00144 *  The following are restrictions on the input parameters. Some of these
00145 *    are temporary and will be removed in future releases, while others
00146 *    may reflect fundamental technical limitations.
00147 *
00148 *    Non-cyclic restriction: VERY IMPORTANT!
00149 *      P*NB>= mod(JA-1,NB)+N.
00150 *      The mapping for matrices must be blocked, reflecting the nature
00151 *      of the divide and conquer algorithm as a task-parallel algorithm.
00152 *      This formula in words is: no processor may have more than one
00153 *      chunk of the matrix.
00154 *
00155 *    Blocksize cannot be too small:
00156 *      If the matrix spans more than one processor, the following
00157 *      restriction on NB, the size of each block on each processor,
00158 *      must hold:
00159 *      NB >= 2
00160 *      The bulk of parallel computation is done on the matrix of size
00161 *      O(NB) on each processor. If this is too small, divide and conquer
00162 *      is a poor choice of algorithm.
00163 *
00164 *    Submatrix reference:
00165 *      JA = IB
00166 *      Alignment restriction that prevents unnecessary communication.
00167 *
00168 *
00169 *  =====================================================================
00170 *
00171 *
00172 *  Notes
00173 *  =====
00174 *
00175 *  If the factorization routine and the solve routine are to be called
00176 *    separately (to solve various sets of righthand sides using the same
00177 *    coefficient matrix), the auxiliary space AF *must not be altered*
00178 *    between calls to the factorization routine and the solve routine.
00179 *
00180 *  The best algorithm for solving banded and tridiagonal linear systems
00181 *    depends on a variety of parameters, especially the bandwidth.
00182 *    Currently, only algorithms designed for the case N/P >> bw are
00183 *    implemented. These go by many names, including Divide and Conquer,
00184 *    Partitioning, domain decomposition-type, etc.
00185 *    For tridiagonal matrices, it is obvious: N/P >> bw(=1), and so D&C
00186 *    algorithms are the appropriate choice.
00187 *
00188 *  Algorithm description: Divide and Conquer
00189 *
00190 *    The Divide and Conqer algorithm assumes the matrix is narrowly
00191 *      banded compared with the number of equations. In this situation,
00192 *      it is best to distribute the input matrix A one-dimensionally,
00193 *      with columns atomic and rows divided amongst the processes.
00194 *      The basic algorithm divides the tridiagonal matrix up into
00195 *      P pieces with one stored on each processor,
00196 *      and then proceeds in 2 phases for the factorization or 3 for the
00197 *      solution of a linear system.
00198 *      1) Local Phase:
00199 *         The individual pieces are factored independently and in
00200 *         parallel. These factors are applied to the matrix creating
00201 *         fillin, which is stored in a non-inspectable way in auxiliary
00202 *         space AF. Mathematically, this is equivalent to reordering
00203 *         the matrix A as P A P^T and then factoring the principal
00204 *         leading submatrix of size equal to the sum of the sizes of
00205 *         the matrices factored on each processor. The factors of
00206 *         these submatrices overwrite the corresponding parts of A
00207 *         in memory.
00208 *      2) Reduced System Phase:
00209 *         A small ((P-1)) system is formed representing
00210 *         interaction of the larger blocks, and is stored (as are its
00211 *         factors) in the space AF. A parallel Block Cyclic Reduction
00212 *         algorithm is used. For a linear system, a parallel front solve
00213 *         followed by an analagous backsolve, both using the structure
00214 *         of the factored matrix, are performed.
00215 *      3) Backsubsitution Phase:
00216 *         For a linear system, a local backsubstitution is performed on
00217 *         each processor in parallel.
00218 *
00219 *
00220 *  Descriptors
00221 *  ===========
00222 *
00223 *  Descriptors now have *types* and differ from ScaLAPACK 1.0.
00224 *
00225 *  Note: tridiagonal codes can use either the old two dimensional
00226 *    or new one-dimensional descriptors, though the processor grid in
00227 *    both cases *must be one-dimensional*. We describe both types below.
00228 *
00229 *  Each global data object is described by an associated description
00230 *  vector.  This vector stores the information required to establish
00231 *  the mapping between an object element and its corresponding process
00232 *  and memory location.
00233 *
00234 *  Let A be a generic term for any 2D block cyclicly distributed array.
00235 *  Such a global array has an associated description vector DESCA.
00236 *  In the following comments, the character _ should be read as
00237 *  "of the global array".
00238 *
00239 *  NOTATION        STORED IN      EXPLANATION
00240 *  --------------- -------------- --------------------------------------
00241 *  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
00242 *                                 DTYPE_A = 1.
00243 *  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
00244 *                                 the BLACS process grid A is distribu-
00245 *                                 ted over. The context itself is glo-
00246 *                                 bal, but the handle (the integer
00247 *                                 value) may vary.
00248 *  M_A    (global) DESCA( M_ )    The number of rows in the global
00249 *                                 array A.
00250 *  N_A    (global) DESCA( N_ )    The number of columns in the global
00251 *                                 array A.
00252 *  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
00253 *                                 the rows of the array.
00254 *  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
00255 *                                 the columns of the array.
00256 *  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
00257 *                                 row of the array A is distributed.
00258 *  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
00259 *                                 first column of the array A is
00260 *                                 distributed.
00261 *  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
00262 *                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
00263 *
00264 *  Let K be the number of rows or columns of a distributed matrix,
00265 *  and assume that its process grid has dimension p x q.
00266 *  LOCr( K ) denotes the number of elements of K that a process
00267 *  would receive if K were distributed over the p processes of its
00268 *  process column.
00269 *  Similarly, LOCc( K ) denotes the number of elements of K that a
00270 *  process would receive if K were distributed over the q processes of
00271 *  its process row.
00272 *  The values of LOCr() and LOCc() may be determined via a call to the
00273 *  ScaLAPACK tool function, NUMROC:
00274 *          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
00275 *          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
00276 *  An upper bound for these quantities may be computed by:
00277 *          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
00278 *          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
00279 *
00280 *
00281 *  One-dimensional descriptors:
00282 *
00283 *  One-dimensional descriptors are a new addition to ScaLAPACK since
00284 *    version 1.0. They simplify and shorten the descriptor for 1D
00285 *    arrays.
00286 *
00287 *  Since ScaLAPACK supports two-dimensional arrays as the fundamental
00288 *    object, we allow 1D arrays to be distributed either over the
00289 *    first dimension of the array (as if the grid were P-by-1) or the
00290 *    2nd dimension (as if the grid were 1-by-P). This choice is
00291 *    indicated by the descriptor type (501 or 502)
00292 *    as described below.
00293 *    However, for tridiagonal matrices, since the objects being
00294 *    distributed are the individual vectors storing the diagonals, we
00295 *    have adopted the convention that both the P-by-1 descriptor and
00296 *    the 1-by-P descriptor are allowed and are equivalent for
00297 *    tridiagonal matrices. Thus, for tridiagonal matrices,
00298 *    DTYPE_A = 501 or 502 can be used interchangeably
00299 *    without any other change.
00300 *  We require that the distributed vectors storing the diagonals of a
00301 *    tridiagonal matrix be aligned with each other. Because of this, a
00302 *    single descriptor, DESCA, serves to describe the distribution of
00303 *    of all diagonals simultaneously.
00304 *
00305 *    IMPORTANT NOTE: the actual BLACS grid represented by the
00306 *    CTXT entry in the descriptor may be *either*  P-by-1 or 1-by-P
00307 *    irrespective of which one-dimensional descriptor type
00308 *    (501 or 502) is input.
00309 *    This routine will interpret the grid properly either way.
00310 *    ScaLAPACK routines *do not support intercontext operations* so that
00311 *    the grid passed to a single ScaLAPACK routine *must be the same*
00312 *    for all array descriptors passed to that routine.
00313 *
00314 *    NOTE: In all cases where 1D descriptors are used, 2D descriptors
00315 *    may also be used, since a one-dimensional array is a special case
00316 *    of a two-dimensional array with one dimension of size unity.
00317 *    The two-dimensional array used in this case *must* be of the
00318 *    proper orientation:
00319 *      If the appropriate one-dimensional descriptor is DTYPEA=501
00320 *      (1 by P type), then the two dimensional descriptor must
00321 *      have a CTXT value that refers to a 1 by P BLACS grid;
00322 *      If the appropriate one-dimensional descriptor is DTYPEA=502
00323 *      (P by 1 type), then the two dimensional descriptor must
00324 *      have a CTXT value that refers to a P by 1 BLACS grid.
00325 *
00326 *
00327 *  Summary of allowed descriptors, types, and BLACS grids:
00328 *  DTYPE           501         502         1         1
00329 *  BLACS grid      1xP or Px1  1xP or Px1  1xP       Px1
00330 *  -----------------------------------------------------
00331 *  A               OK          OK          OK        NO
00332 *  B               NO          OK          NO        OK
00333 *
00334 *  Note that a consequence of this chart is that it is not possible
00335 *    for *both* DTYPE_A and DTYPE_B to be 2D_type(1), as these lead
00336 *    to opposite requirements for the orientation of the BLACS grid,
00337 *    and as noted before, the *same* BLACS context must be used in
00338 *    all descriptors in a single ScaLAPACK subroutine call.
00339 *
00340 *  Let A be a generic term for any 1D block cyclicly distributed array.
00341 *  Such a global array has an associated description vector DESCA.
00342 *  In the following comments, the character _ should be read as
00343 *  "of the global array".
00344 *
00345 *  NOTATION        STORED IN  EXPLANATION
00346 *  --------------- ---------- ------------------------------------------
00347 *  DTYPE_A(global) DESCA( 1 ) The descriptor type. For 1D grids,
00348 *                                TYPE_A = 501: 1-by-P grid.
00349 *                                TYPE_A = 502: P-by-1 grid.
00350 *  CTXT_A (global) DESCA( 2 ) The BLACS context handle, indicating
00351 *                                the BLACS process grid A is distribu-
00352 *                                ted over. The context itself is glo-
00353 *                                bal, but the handle (the integer
00354 *                                value) may vary.
00355 *  N_A    (global) DESCA( 3 ) The size of the array dimension being
00356 *                                distributed.
00357 *  NB_A   (global) DESCA( 4 ) The blocking factor used to distribute
00358 *                                the distributed dimension of the array.
00359 *  SRC_A  (global) DESCA( 5 ) The process row or column over which the
00360 *                                first row or column of the array
00361 *                                is distributed.
00362 *  Ignored         DESCA( 6 ) Ignored for tridiagonal matrices.
00363 *  Reserved        DESCA( 7 ) Reserved for future use.
00364 *
00365 *
00366 *
00367 *  =====================================================================
00368 *
00369 *  Code Developer: Andrew J. Cleary, University of Tennessee.
00370 *    Current address: Lawrence Livermore National Labs.
00371 *  This version released: August, 2001.
00372 *
00373 *  =====================================================================
00374 *
00375 *     ..
00376 *     .. Parameters ..
00377       DOUBLE PRECISION   ONE, ZERO
00378       PARAMETER          ( ONE = 1.0D+0 )
00379       PARAMETER          ( ZERO = 0.0D+0 )
00380       COMPLEX*16         CONE, CZERO
00381       PARAMETER          ( CONE = ( 1.0D+0, 0.0D+0 ) )
00382       PARAMETER          ( CZERO = ( 0.0D+0, 0.0D+0 ) )
00383       INTEGER            INT_ONE
00384       PARAMETER          ( INT_ONE = 1 )
00385       INTEGER            DESCMULT, BIGNUM
00386       PARAMETER          (DESCMULT = 100, BIGNUM = DESCMULT * DESCMULT)
00387       INTEGER            BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
00388      $                   LLD_, MB_, M_, NB_, N_, RSRC_
00389       PARAMETER          ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,
00390      $                     CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,
00391      $                     RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )
00392 *     ..
00393 *     .. Local Scalars ..
00394       INTEGER            CSRC, FIRST_PROC, I, ICTXT, ICTXT_NEW,
00395      $                   ICTXT_SAVE, IDUM1, IDUM3, JA_NEW, LLDA, LLDB,
00396      $                   MYCOL, MYROW, MY_NUM_COLS, NB, NP, NPCOL,
00397      $                   NPROW, NP_SAVE, ODD_SIZE,
00398      $                   PART_OFFSET, PART_SIZE, RETURN_CODE, STORE_M_B,
00399      $                   STORE_N_A, TEMP, WORK_SIZE_MIN
00400 *     ..
00401 *     .. Local Arrays ..
00402       INTEGER            DESCA_1XP( 7 ), DESCB_PX1( 7 ),
00403      $                   PARAM_CHECK( 15, 3 )
00404 *     ..
00405 *     .. External Subroutines ..
00406       EXTERNAL           BLACS_GRIDINFO, DESC_CONVERT, GLOBCHK, PXERBLA,
00407      $                   PZPTTRSV, RESHAPE
00408 *     ..
00409 *     .. External Functions ..
00410       LOGICAL            LSAME
00411       INTEGER            NUMROC
00412       EXTERNAL           LSAME, NUMROC
00413 *     ..
00414 *     .. Intrinsic Functions ..
00415       INTRINSIC          ICHAR, MIN, MOD
00416 *     ..
00417 *     .. Executable Statements ..
00418 *
00419 *     Test the input parameters
00420 *
00421       INFO = 0
00422 *
00423 *     Convert descriptor into standard form for easy access to
00424 *        parameters, check that grid is of right shape.
00425 *
00426       DESCA_1XP( 1 ) = 501
00427       DESCB_PX1( 1 ) = 502
00428 *
00429       TEMP = DESCA( DTYPE_ )
00430       IF( TEMP .EQ. 502 ) THEN
00431 *        Temporarily set the descriptor type to 1xP type
00432          DESCA( DTYPE_ ) = 501
00433       ENDIF
00434 *
00435       CALL DESC_CONVERT( DESCA, DESCA_1XP, RETURN_CODE )
00436 *
00437       DESCA( DTYPE_ ) = TEMP
00438 *
00439       IF( RETURN_CODE .NE. 0) THEN
00440          INFO = -( 6*100 + 2 )
00441       ENDIF
00442 *
00443       CALL DESC_CONVERT( DESCB, DESCB_PX1, RETURN_CODE )
00444 *
00445       IF( RETURN_CODE .NE. 0) THEN
00446          INFO = -( 9*100 + 2 )
00447       ENDIF
00448 *
00449 *     Consistency checks for DESCA and DESCB.
00450 *
00451 *     Context must be the same
00452       IF( DESCA_1XP( 2 ) .NE. DESCB_PX1( 2 ) ) THEN
00453          INFO = -( 9*100 + 2 )
00454       ENDIF
00455 *
00456 *        These are alignment restrictions that may or may not be removed
00457 *        in future releases. -Andy Cleary, April 14, 1996.
00458 *
00459 *     Block sizes must be the same
00460       IF( DESCA_1XP( 4 ) .NE. DESCB_PX1( 4 ) ) THEN
00461          INFO = -( 9*100 + 4 )
00462       ENDIF
00463 *
00464 *     Source processor must be the same
00465 *
00466       IF( DESCA_1XP( 5 ) .NE. DESCB_PX1( 5 ) ) THEN
00467          INFO = -( 9*100 + 5 )
00468       ENDIF
00469 *
00470 *     Get values out of descriptor for use in code.
00471 *
00472       ICTXT = DESCA_1XP( 2 )
00473       CSRC = DESCA_1XP( 5 )
00474       NB = DESCA_1XP( 4 )
00475       LLDA = DESCA_1XP( 6 )
00476       STORE_N_A = DESCA_1XP( 3 )
00477       LLDB = DESCB_PX1( 6 )
00478       STORE_M_B = DESCB_PX1( 3 )
00479 *
00480 *     Get grid parameters
00481 *
00482 *
00483       CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
00484       NP = NPROW * NPCOL
00485 *
00486 *
00487 *
00488       IF( LSAME( UPLO, 'U' ) ) THEN
00489          IDUM1 = ICHAR( 'U' )
00490       ELSE IF ( LSAME( UPLO, 'L' ) ) THEN
00491          IDUM1 = ICHAR( 'L' )
00492       ELSE
00493          INFO = -1
00494       END IF
00495 *
00496       IF( LWORK .LT. -1) THEN
00497          INFO = -13
00498       ELSE IF ( LWORK .EQ. -1 ) THEN
00499          IDUM3 = -1
00500       ELSE
00501          IDUM3 = 1
00502       ENDIF
00503 *
00504       IF( N .LT. 0 ) THEN
00505          INFO = -2
00506       ENDIF
00507 *
00508       IF( N+JA-1 .GT. STORE_N_A ) THEN
00509          INFO = -( 6*100 + 6 )
00510       ENDIF
00511 *
00512       IF( N+IB-1 .GT. STORE_M_B ) THEN
00513          INFO = -( 9*100 + 3 )
00514       ENDIF
00515 *
00516       IF( LLDB .LT. NB ) THEN
00517          INFO = -( 9*100 + 6 )
00518       ENDIF
00519 *
00520       IF( NRHS .LT. 0 ) THEN
00521          INFO = -3
00522       ENDIF
00523 *
00524 *     Current alignment restriction
00525 *
00526       IF( JA .NE. IB) THEN
00527          INFO = -5
00528       ENDIF
00529 *
00530 *     Argument checking that is specific to Divide & Conquer routine
00531 *
00532       IF( NPROW .NE. 1 ) THEN
00533          INFO = -( 6*100+2 )
00534       ENDIF
00535 *
00536       IF( N .GT. NP*NB-MOD( JA-1, NB )) THEN
00537          INFO = -( 2 )
00538          CALL PXERBLA( ICTXT,
00539      $      'PZPTTRS, D&C alg.: only 1 block per proc',
00540      $      -INFO )
00541          RETURN
00542       ENDIF
00543 *
00544       IF((JA+N-1.GT.NB) .AND. ( NB.LT.2*INT_ONE )) THEN
00545          INFO = -( 6*100+4 )
00546          CALL PXERBLA( ICTXT,
00547      $      'PZPTTRS, D&C alg.: NB too small',
00548      $      -INFO )
00549          RETURN
00550       ENDIF
00551 *
00552 *
00553       WORK_SIZE_MIN =
00554      $           (10+2*MIN(100,NRHS))*NPCOL+4*NRHS
00555 *
00556       WORK( 1 ) = WORK_SIZE_MIN
00557 *
00558       IF( LWORK .LT. WORK_SIZE_MIN ) THEN
00559          IF( LWORK .NE. -1 ) THEN
00560          INFO = -13
00561          CALL PXERBLA( ICTXT,
00562      $      'PZPTTRS: worksize error',
00563      $      -INFO )
00564          ENDIF
00565          RETURN
00566       ENDIF
00567 *
00568 *     Pack params and positions into arrays for global consistency check
00569 *
00570       PARAM_CHECK( 15, 1 ) = DESCB(5)
00571       PARAM_CHECK( 14, 1 ) = DESCB(4)
00572       PARAM_CHECK( 13, 1 ) = DESCB(3)
00573       PARAM_CHECK( 12, 1 ) = DESCB(2)
00574       PARAM_CHECK( 11, 1 ) = DESCB(1)
00575       PARAM_CHECK( 10, 1 ) = IB
00576       PARAM_CHECK(  9, 1 ) = DESCA(5)
00577       PARAM_CHECK(  8, 1 ) = DESCA(4)
00578       PARAM_CHECK(  7, 1 ) = DESCA(3)
00579       PARAM_CHECK(  6, 1 ) = DESCA(1)
00580       PARAM_CHECK(  5, 1 ) = JA
00581       PARAM_CHECK(  4, 1 ) = NRHS
00582       PARAM_CHECK(  3, 1 ) = N
00583       PARAM_CHECK(  2, 1 ) = IDUM3
00584       PARAM_CHECK(  1, 1 ) = IDUM1
00585 *
00586       PARAM_CHECK( 15, 2 ) = 905
00587       PARAM_CHECK( 14, 2 ) = 904
00588       PARAM_CHECK( 13, 2 ) = 903
00589       PARAM_CHECK( 12, 2 ) = 902
00590       PARAM_CHECK( 11, 2 ) = 901
00591       PARAM_CHECK( 10, 2 ) = 8
00592       PARAM_CHECK(  9, 2 ) = 605
00593       PARAM_CHECK(  8, 2 ) = 604
00594       PARAM_CHECK(  7, 2 ) = 603
00595       PARAM_CHECK(  6, 2 ) = 601
00596       PARAM_CHECK(  5, 2 ) = 5
00597       PARAM_CHECK(  4, 2 ) = 3
00598       PARAM_CHECK(  3, 2 ) = 2
00599       PARAM_CHECK(  2, 2 ) = 13
00600       PARAM_CHECK(  1, 2 ) = 1
00601 *
00602 *     Want to find errors with MIN( ), so if no error, set it to a big
00603 *     number. If there already is an error, multiply by the the
00604 *     descriptor multiplier.
00605 *
00606       IF( INFO.GE.0 ) THEN
00607          INFO = BIGNUM
00608       ELSE IF( INFO.LT.-DESCMULT ) THEN
00609          INFO = -INFO
00610       ELSE
00611          INFO = -INFO * DESCMULT
00612       END IF
00613 *
00614 *     Check consistency across processors
00615 *
00616       CALL GLOBCHK( ICTXT, 15, PARAM_CHECK, 15,
00617      $              PARAM_CHECK( 1, 3 ), INFO )
00618 *
00619 *     Prepare output: set info = 0 if no error, and divide by DESCMULT
00620 *     if error is not in a descriptor entry.
00621 *
00622       IF( INFO.EQ.BIGNUM ) THEN
00623          INFO = 0
00624       ELSE IF( MOD( INFO, DESCMULT ) .EQ. 0 ) THEN
00625          INFO = -INFO / DESCMULT
00626       ELSE
00627          INFO = -INFO
00628       END IF
00629 *
00630       IF( INFO.LT.0 ) THEN
00631          CALL PXERBLA( ICTXT, 'PZPTTRS', -INFO )
00632          RETURN
00633       END IF
00634 *
00635 *     Quick return if possible
00636 *
00637       IF( N.EQ.0 )
00638      $   RETURN
00639 *
00640       IF( NRHS.EQ.0 )
00641      $   RETURN
00642 *
00643 *
00644 *     Adjust addressing into matrix space to properly get into
00645 *        the beginning part of the relevant data
00646 *
00647       PART_OFFSET = NB*( (JA-1)/(NPCOL*NB) )
00648 *
00649       IF ( (MYCOL-CSRC) .LT. (JA-PART_OFFSET-1)/NB ) THEN
00650          PART_OFFSET = PART_OFFSET + NB
00651       ENDIF
00652 *
00653       IF ( MYCOL .LT. CSRC ) THEN
00654          PART_OFFSET = PART_OFFSET - NB
00655       ENDIF
00656 *
00657 *     Form a new BLACS grid (the "standard form" grid) with only procs
00658 *        holding part of the matrix, of size 1xNP where NP is adjusted,
00659 *        starting at csrc=0, with JA modified to reflect dropped procs.
00660 *
00661 *     First processor to hold part of the matrix:
00662 *
00663       FIRST_PROC = MOD( ( JA-1 )/NB+CSRC, NPCOL )
00664 *
00665 *     Calculate new JA one while dropping off unused processors.
00666 *
00667       JA_NEW = MOD( JA-1, NB ) + 1
00668 *
00669 *     Save and compute new value of NP
00670 *
00671       NP_SAVE = NP
00672       NP = ( JA_NEW+N-2 )/NB + 1
00673 *
00674 *     Call utility routine that forms "standard-form" grid
00675 *
00676       CALL RESHAPE( ICTXT, INT_ONE, ICTXT_NEW, INT_ONE,
00677      $              FIRST_PROC, INT_ONE, NP )
00678 *
00679 *     Use new context from standard grid as context.
00680 *
00681       ICTXT_SAVE = ICTXT
00682       ICTXT = ICTXT_NEW
00683       DESCA_1XP( 2 ) = ICTXT_NEW
00684       DESCB_PX1( 2 ) = ICTXT_NEW
00685 *
00686 *     Get information about new grid.
00687 *
00688       CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
00689 *
00690 *     Drop out processors that do not have part of the matrix.
00691 *
00692       IF( MYROW .LT. 0 ) THEN
00693          GOTO 1234
00694       ENDIF
00695 *
00696 *     ********************************
00697 *     Values reused throughout routine
00698 *
00699 *     User-input value of partition size
00700 *
00701       PART_SIZE = NB
00702 *
00703 *     Number of columns in each processor
00704 *
00705       MY_NUM_COLS = NUMROC( N, PART_SIZE, MYCOL, 0, NPCOL )
00706 *
00707 *     Offset in columns to beginning of main partition in each proc
00708 *
00709       IF ( MYCOL .EQ. 0 ) THEN
00710         PART_OFFSET = PART_OFFSET+MOD( JA_NEW-1, PART_SIZE )
00711         MY_NUM_COLS = MY_NUM_COLS - MOD(JA_NEW-1, PART_SIZE )
00712       ENDIF
00713 *
00714 *     Size of main (or odd) partition in each processor
00715 *
00716       ODD_SIZE = MY_NUM_COLS
00717       IF ( MYCOL .LT. NP-1 ) THEN
00718          ODD_SIZE = ODD_SIZE - INT_ONE
00719       ENDIF
00720 *
00721 *
00722 *
00723 *     Begin main code
00724 *
00725       INFO = 0
00726 *
00727 *     Call frontsolve routine
00728 *
00729       IF( LSAME( UPLO, 'L' ) ) THEN
00730 *
00731          CALL PZPTTRSV( 'L', 'N', N, NRHS, D( PART_OFFSET+1 ),
00732      $                  E( PART_OFFSET+1 ), JA_NEW, DESCA_1XP, B, IB,
00733      $                  DESCB_PX1, AF, LAF, WORK, LWORK, INFO )
00734 *
00735       ELSE
00736 *
00737          CALL PZPTTRSV( 'U', 'C', N, NRHS, D( PART_OFFSET+1 ),
00738      $                  E( PART_OFFSET+1 ), JA_NEW, DESCA_1XP, B, IB,
00739      $                  DESCB_PX1, AF, LAF, WORK, LWORK, INFO )
00740 *
00741       ENDIF
00742 *
00743 *     Divide by the main diagonal: B <- D^{-1} B
00744 *
00745 *     The main partition is first
00746 *
00747         DO 10  I=PART_OFFSET+1, PART_OFFSET+ODD_SIZE
00748           CALL ZSCAL( NRHS, DCMPLX( CONE/D( I ) ), B( I ), LLDB )
00749    10   CONTINUE
00750 *
00751 *     Reduced system is next
00752 *
00753       IF( MYCOL .LT. NPCOL-1 ) THEN
00754         I=PART_OFFSET+ODD_SIZE+1
00755           CALL ZSCAL( NRHS, CONE/AF( ODD_SIZE+2 ), B( I ), LLDB )
00756       ENDIF
00757 *
00758 *     Call backsolve routine
00759 *
00760       IF( LSAME( UPLO, 'L' ) ) THEN
00761 *
00762          CALL PZPTTRSV( 'L', 'C', N, NRHS, D( PART_OFFSET+1 ),
00763      $                  E( PART_OFFSET+1 ), JA_NEW, DESCA_1XP, B, IB,
00764      $                  DESCB_PX1, AF, LAF, WORK, LWORK, INFO )
00765 *
00766       ELSE
00767 *
00768          CALL PZPTTRSV( 'U', 'N', N, NRHS, D( PART_OFFSET+1 ),
00769      $                  E( PART_OFFSET+1 ), JA_NEW, DESCA_1XP, B, IB,
00770      $                  DESCB_PX1, AF, LAF, WORK, LWORK, INFO )
00771 *
00772       ENDIF
00773  1000 CONTINUE
00774 *
00775 *
00776 *     Free BLACS space used to hold standard-form grid.
00777 *
00778       IF( ICTXT_SAVE .NE. ICTXT_NEW ) THEN
00779          CALL BLACS_GRIDEXIT( ICTXT_NEW )
00780       ENDIF
00781 *
00782  1234 CONTINUE
00783 *
00784 *     Restore saved input parameters
00785 *
00786       ICTXT = ICTXT_SAVE
00787       NP = NP_SAVE
00788 *
00789 *     Output minimum worksize
00790 *
00791       WORK( 1 ) = WORK_SIZE_MIN
00792 *
00793 *
00794       RETURN
00795 *
00796 *     End of PZPTTRS
00797 *
00798       END