Routine: PDDBTRS()  File: SRC\pddbtrs.f

 
 
# lines: 747
  # code: 747
  # comment: 0
  # blank:0
# Variables:51
# Callers:1
# Callings:1
# Words:265
# Keywords:167
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PDDBTRS solves a system of linear equations
            A(1:N, JA:JA+N-1) * X = B(IB:IB+N-1, 1:NRHS)
                                    or
            A(1:N, JA:JA+N-1)' * X = B(IB:IB+N-1, 1:NRHS)
  where A(1:N, JA:JA+N-1) is the matrix used to produce the factors
  stored in A(1:N,JA:JA+N-1) and AF by PDDBTRF.
  A(1:N, JA:JA+N-1) is an N-by-N real
  banded diagonally dominant-like distributed
  matrix with bandwidth BWL, BWU.
  Routine PDDBTRF MUST be called first.
  =====================================================================
  Arguments
  =========
  TRANS   (global input) CHARACTER
          = 'N':  Solve with A(1:N, JA:JA+N-1);
          = 'T' or 'C':  Solve with A(1:N, JA:JA+N-1)^T;
  N       (global input) INTEGER
          The number of rows and columns to be operated on, i.e. the
          order of the distributed submatrix A(1:N, JA:JA+N-1). N >= 0.
  BWL     (global input) INTEGER
          Number of subdiagonals. 0 <= BWL <= N-1
  BWU     (global input) INTEGER
          Number of superdiagonals. 0 <= BWU <= N-1
  NRHS    (global input) INTEGER
          The number of right hand sides, i.e., the number of columns
          of the distributed submatrix B(IB:IB+N-1, 1:NRHS).
          NRHS >= 0.
  A       (local input/local output) DOUBLE PRECISION pointer into
          local memory to an array with first dimension
          LLD_A >=(bwl+bwu+1) (stored in DESCA).
          On entry, this array contains the local pieces of the
          N-by-N unsymmetric banded distributed Cholesky factor L or
          L^T A(1:N, JA:JA+N-1).
          This local portion is stored in the packed banded format
            used in LAPACK. Please see the Notes below and the
            ScaLAPACK manual for more detail on the format of
            distributed matrices.
  JA      (global input) INTEGER
          The index in the global array A that points to the start of
          the matrix to be operated on (which may be either all of A
          or a submatrix of A).
  DESCA   (global and local input) INTEGER array of dimension DLEN.
          if 1D type (DTYPE_A=501), DLEN >= 7;
          if 2D type (DTYPE_A=1), DLEN >= 9 .
          The array descriptor for the distributed matrix A.
          Contains information of mapping of A to memory. Please
          see NOTES below for full description and options.
  B       (local input/local output) DOUBLE PRECISION pointer into
          local memory to an array of local lead dimension lld_b>=NB.
          On entry, this array contains the
          the local pieces of the right hand sides
          B(IB:IB+N-1, 1:NRHS).
          On exit, this contains the local piece of the solutions
          distributed matrix X.
  IB      (global input) INTEGER
          The row index in the global array B that points to the first
          row of the matrix to be operated on (which may be either
          all of B or a submatrix of B).
  DESCB   (global and local input) INTEGER array of dimension DLEN.
          if 1D type (DTYPE_B=502), DLEN >=7;
          if 2D type (DTYPE_B=1), DLEN >= 9.
          The array descriptor for the distributed matrix B.
          Contains information of mapping of B to memory. Please
          see NOTES below for full description and options.
  AF      (local output) DOUBLE PRECISION array, dimension LAF.
          Auxiliary Fillin Space.
          Fillin is created during the factorization routine
          PDDBTRF and this is stored in AF. If a linear system
          is to be solved using PDDBTRS after the factorization
          routine, AF *must not be altered* after the factorization.
  LAF     (local input) INTEGER
          Size of user-input Auxiliary Fillin space AF. Must be >=
          NB*(bwl+bwu)+6*max(bwl,bwu)*max(bwl,bwu)
          If LAF is not large enough, an error code will be returned
          and the minimum acceptable size will be returned in AF( 1 )
  WORK    (local workspace/local output)
          DOUBLE PRECISION temporary workspace. This space may
          be overwritten in between calls to routines. WORK must be
          the size given in LWORK.
          On exit, WORK( 1 ) contains the minimal LWORK.
  LWORK   (local input or global input) INTEGER
          Size of user-input workspace WORK.
          If LWORK is too small, the minimal acceptable size will be
          returned in WORK(1) and an error code is returned. LWORK>=
          (max(bwl,bwu)*NRHS)
  INFO    (global output) INTEGER
          = 0:  successful exit
          < 0:  If the i-th argument is an array and the j-entry had
                an illegal value, then INFO = -(i*100+j), if the i-th
                argument is a scalar and had an illegal value, then
                INFO = -i.
  =====================================================================
  Restrictions
  ============
  The following are restrictions on the input parameters. Some of these
    are temporary and will be removed in future releases, while others
    may reflect fundamental technical limitations.
    Non-cyclic restriction: VERY IMPORTANT!
      P*NB>= mod(JA-1,NB)+N.
      The mapping for matrices must be blocked, reflecting the nature
      of the divide and conquer algorithm as a task-parallel algorithm.
      This formula in words is: no processor may have more than one
      chunk of the matrix.
    Blocksize cannot be too small:
      If the matrix spans more than one processor, the following
      restriction on NB, the size of each block on each processor,
      must hold:
      NB >= 2*MAX(BWL,BWU)
      The bulk of parallel computation is done on the matrix of size
      O(NB) on each processor. If this is too small, divide and conquer
      is a poor choice of algorithm.
    Submatrix reference:
      JA = IB
      Alignment restriction that prevents unnecessary communication.
  =====================================================================
  Notes
  =====
  If the factorization routine and the solve routine are to be called
    separately (to solve various sets of righthand sides using the same
    coefficient matrix), the auxiliary space AF *must not be altered*
    between calls to the factorization routine and the solve routine.
  The best algorithm for solving banded and tridiagonal linear systems
    depends on a variety of parameters, especially the bandwidth.
    Currently, only algorithms designed for the case N/P >> bw are
    implemented. These go by many names, including Divide and Conquer,
    Partitioning, domain decomposition-type, etc.
  Algorithm description: Divide and Conquer
    The Divide and Conqer algorithm assumes the matrix is narrowly
      banded compared with the number of equations. In this situation,
      it is best to distribute the input matrix A one-dimensionally,
      with columns atomic and rows divided amongst the processes.
      The basic algorithm divides the banded matrix up into
      P pieces with one stored on each processor,
      and then proceeds in 2 phases for the factorization or 3 for the
      solution of a linear system.
      1) Local Phase:
         The individual pieces are factored independently and in
         parallel. These factors are applied to the matrix creating
         fillin, which is stored in a non-inspectable way in auxiliary
         space AF. Mathematically, this is equivalent to reordering
         the matrix A as P A P^T and then factoring the principal
         leading submatrix of size equal to the sum of the sizes of
         the matrices factored on each processor. The factors of
         these submatrices overwrite the corresponding parts of A
         in memory.
      2) Reduced System Phase:
         A small (max(bwl,bwu)* (P-1)) system is formed representing
         interaction of the larger blocks, and is stored (as are its
         factors) in the space AF. A parallel Block Cyclic Reduction
         algorithm is used. For a linear system, a parallel front solve
         followed by an analagous backsolve, both using the structure
         of the factored matrix, are performed.
      3) Backsubsitution Phase:
         For a linear system, a local backsubstitution is performed on
         each processor in parallel.
  Descriptors
  ===========
  Descriptors now have *types* and differ from ScaLAPACK 1.0.
  Note: banded codes can use either the old two dimensional
    or new one-dimensional descriptors, though the processor grid in
    both cases *must be one-dimensional*. We describe both types below.
  Each global data object is described by an associated description
  vector.  This vector stores the information required to establish
  the mapping between an object element and its corresponding process
  and memory location.
  Let A be a generic term for any 2D block cyclicly distributed array.
  Such a global array has an associated description vector DESCA.
  In the following comments, the character _ should be read as
  "of the global array".
  NOTATION        STORED IN      EXPLANATION
  --------------- -------------- --------------------------------------
  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
                                 DTYPE_A = 1.
  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
                                 the BLACS process grid A is distribu-
                                 ted over. The context itself is glo-
                                 bal, but the handle (the integer
                                 value) may vary.
  M_A    (global) DESCA( M_ )    The number of rows in the global
                                 array A.
  N_A    (global) DESCA( N_ )    The number of columns in the global
                                 array A.
  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
                                 the rows of the array.
  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
                                 the columns of the array.
  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
                                 row of the array A is distributed.
  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
                                 first column of the array A is
                                 distributed.
  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
  Let K be the number of rows or columns of a distributed matrix,
  and assume that its process grid has dimension p x q.
  LOCr( K ) denotes the number of elements of K that a process
  would receive if K were distributed over the p processes of its
  process column.
  Similarly, LOCc( K ) denotes the number of elements of K that a
  process would receive if K were distributed over the q processes of
  its process row.
  The values of LOCr() and LOCc() may be determined via a call to the
  ScaLAPACK tool function, NUMROC:
          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
  An upper bound for these quantities may be computed by:
          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
  One-dimensional descriptors:
  One-dimensional descriptors are a new addition to ScaLAPACK since
    version 1.0. They simplify and shorten the descriptor for 1D
    arrays.
  Since ScaLAPACK supports two-dimensional arrays as the fundamental
    object, we allow 1D arrays to be distributed either over the
    first dimension of the array (as if the grid were P-by-1) or the
    2nd dimension (as if the grid were 1-by-P). This choice is
    indicated by the descriptor type (501 or 502)
    as described below.
    IMPORTANT NOTE: the actual BLACS grid represented by the
    CTXT entry in the descriptor may be *either*  P-by-1 or 1-by-P
    irrespective of which one-dimensional descriptor type
    (501 or 502) is input.
    This routine will interpret the grid properly either way.
    ScaLAPACK routines *do not support intercontext operations* so that
    the grid passed to a single ScaLAPACK routine *must be the same*
    for all array descriptors passed to that routine.
    NOTE: In all cases where 1D descriptors are used, 2D descriptors
    may also be used, since a one-dimensional array is a special case
    of a two-dimensional array with one dimension of size unity.
    The two-dimensional array used in this case *must* be of the
    proper orientation:
      If the appropriate one-dimensional descriptor is DTYPEA=501
      (1 by P type), then the two dimensional descriptor must
      have a CTXT value that refers to a 1 by P BLACS grid;
      If the appropriate one-dimensional descriptor is DTYPEA=502
      (P by 1 type), then the two dimensional descriptor must
      have a CTXT value that refers to a P by 1 BLACS grid.
  Summary of allowed descriptors, types, and BLACS grids:
  DTYPE           501         502         1         1
  BLACS grid      1xP or Px1  1xP or Px1  1xP       Px1
  -----------------------------------------------------
  A               OK          NO          OK        NO
  B               NO          OK          NO        OK
  Note that a consequence of this chart is that it is not possible
    for *both* DTYPE_A and DTYPE_B to be 2D_type(1), as these lead
    to opposite requirements for the orientation of the BLACS grid,
    and as noted before, the *same* BLACS context must be used in
    all descriptors in a single ScaLAPACK subroutine call.
  Let A be a generic term for any 1D block cyclicly distributed array.
  Such a global array has an associated description vector DESCA.
  In the following comments, the character _ should be read as
  "of the global array".
  NOTATION        STORED IN  EXPLANATION
  --------------- ---------- ------------------------------------------
  DTYPE_A(global) DESCA( 1 ) The descriptor type. For 1D grids,
                                TYPE_A = 501: 1-by-P grid.
                                TYPE_A = 502: P-by-1 grid.
  CTXT_A (global) DESCA( 2 ) The BLACS context handle, indicating
                                the BLACS process grid A is distribu-
                                ted over. The context itself is glo-
                                bal, but the handle (the integer
                                value) may vary.
  N_A    (global) DESCA( 3 ) The size of the array dimension being
                                distributed.
  NB_A   (global) DESCA( 4 ) The blocking factor used to distribute
                                the distributed dimension of the array.
  SRC_A  (global) DESCA( 5 ) The process row or column over which the
                                first row or column of the array
                                is distributed.
  LLD_A  (local)  DESCA( 6 ) The leading dimension of the local array
                                storing the local blocks of the distri-
                                buted array A. Minimum value of LLD_A
                                depends on TYPE_A.
                                TYPE_A = 501: LLD_A >=
                                   size of undistributed dimension, 1.
                                TYPE_A = 502: LLD_A >=NB_A, 1.
  Reserved        DESCA( 7 ) Reserved for future use.
  =====================================================================
  Code Developer: Andrew J. Cleary, University of Tennessee.
    Current address: Lawrence Livermore National Labs.
  =====================================================================
     .. Parameters ..

 
Display dynamic version Find AutoScroll Reload FontSize: - + Hide Comments Hide Blanks Frame FullScreen MailPrint

 
001        SUBROUTINE PDDBTRS( TRANS , N , BWL , BWU , NRHS , A , JA , DESCA , B , IB ,
002       $DESCB , AF , LAF , WORK , LWORK , INFO )
003  
004  *     -- ScaLAPACK routine(version 1.7) --
005  *     University of Tennessee , Knoxville , Oak Ridge National Laboratory ,
006  *     and University of California , Berkeley.
007  *     April 3 , 2000
008  
009  *     .. Scalar Arguments ..
010        CHARACTER TRANS
011        INTEGER BWL , BWU , IB , INFO , JA , LAF , LWORK , N , NRHS
012        INTEGER INT_ONE
013        PARAMETER( INT_ONE = 1 )
014        INTEGER DESCMULT , BIGNUM
015        PARAMETER( DESCMULT = 100 , BIGNUM = DESCMULT*DESCMULT )
016        INTEGER BLOCK_CYCLIC_2D , CSRC_ , CTXT_ , DLEN_ , DTYPE_ ,
017       $LLD_ , MB_ , M_ , NB_ , N_ , RSRC_
018        PARAMETER( BLOCK_CYCLIC_2D = 1 , DLEN_ = 9 , DTYPE_ = 1 ,
019       $CTXT_ = 2 , M_ = 3 , N_ = 4 , MB_ = 5 , NB_ = 6 ,
020       $RSRC_ = 7 , CSRC_ = 8 , LLD_ = 9 )
021  *     ..
022  *     .. Local Scalars ..
023        INTEGER CSRC , FIRST_PROC , ICTXT , ICTXT_NEW , ICTXT_SAVE ,
024       $IDUM2 , IDUM3 , JA_NEW , LLDA , LLDB , MYCOL , MYROW ,
025       $NB , NP , NPCOL , NPROW , NP_SAVE , PART_OFFSET ,
026       $RETURN_CODE , STORE_M_B , STORE_N_A ,
027       $WORK_SIZE_MIN
028  *     ..
029  *     .. Local Arrays ..
030        INTEGER DESCA_1XP( 7 ) , DESCB_PX1( 7 ) ,
031       $PARAM_CHECK( 17 , 3 )
032  *     ..
033  *     .. External Subroutines ..
034        EXTERNAL BLACS_GRIDEXIT , BLACS_GRIDINFO , DESC_CONVERT ,
035       $GLOBCHK , PDDBTRSV , PXERBLA , RESHAPE
036  *     ..
037  *     .. External Functions ..
038        LOGICAL LSAME
039        EXTERNAL LSAME
040  *     ..
041  *     .. Intrinsic Functions ..
042        INTRINSIC ICHAR , MAX , MOD
043  *     ..
044  *     .. Executable Statements ..
045  
046  *     Test the input parameters
047  
048        INFO = 0
049  
050  *     Convert descriptor into standard form for easy access to
051  *     parameters , check that grid is of right shape.
052  
053        DESCA_1XP( 1 ) = 501
054        DESCB_PX1( 1 ) = 502
055  
056        CALL DESC_CONVERT( DESCA , DESCA_1XP , RETURN_CODE )
057  
058        IF( RETURN_CODE.NE.0 ) THEN
059            INFO = - ( 8*100 + 2 )
060        END IF
061  
062        CALL DESC_CONVERT( DESCB , DESCB_PX1 , RETURN_CODE )
063  
064        IF( RETURN_CODE.NE.0 ) THEN
065            INFO = - ( 11*100 + 2 )
066        END IF
067  
068  *     Consistency checks for DESCA and DESCB.
069  
070  *     Context must be the same
071        IF( DESCA_1XP( 2 ).NE.DESCB_PX1( 2 ) ) THEN
072            INFO = - ( 11*100 + 2 )
073        END IF
074  
075  *     These are alignment restrictions that may or may not be removed
076  *     in future releases. - Andy Cleary , April 14 , 1996.
077  
078  *     Block sizes must be the same
079        IF( DESCA_1XP( 4 ).NE.DESCB_PX1( 4 ) ) THEN
080            INFO = - ( 11*100 + 4 )
081        END IF
082  
083  *     Source processor must be the same
084  
085        IF( DESCA_1XP( 5 ).NE.DESCB_PX1( 5 ) ) THEN
086            INFO = - ( 11*100 + 5 )
087        END IF
088  
089  *     Get values out of descriptor for use in code.
090  
091        ICTXT = DESCA_1XP( 2 )
092        CSRC = DESCA_1XP( 5 )
093        NB = DESCA_1XP( 4 )
094        LLDA = DESCA_1XP( 6 )
095        STORE_N_A = DESCA_1XP( 3 )
096        LLDB = DESCB_PX1( 6 )
097        STORE_M_B = DESCB_PX1( 3 )
098  
099  *     Get grid parameters
100  
101        CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
102        NP = NPROW*NPCOL
103  
104        IF( LSAME( TRANS , 'N' ) ) THEN
105            IDUM2 = ICHAR( 'N' )
106        ELSE IF( LSAME( TRANS , 'T' ) ) THEN
107            IDUM2 = ICHAR( 'T' )
108        ELSE IF( LSAME( TRANS , 'C' ) ) THEN
109            IDUM2 = ICHAR( 'T' )
110        ELSE
111            INFO = - 1
112        END IF
113  
114        IF( LWORK.LT. - 1 ) THEN
115            INFO = - 15
116        ELSE IF( LWORK.EQ. - 1 ) THEN
117            IDUM3 = - 1
118        ELSE
119            IDUM3 = 1
120        END IF
121  
122        IF( N.LT.0 ) THEN
123            INFO = - 2
124        END IF
125  
126        IF( N + JA - 1.GT.STORE_N_A ) THEN
127            INFO = - ( 8*100 + 6 )
128        END IF
129  
130        IF(( BWL.GT.N - 1 ) .OR.( BWL.LT.0 ) ) THEN
131            INFO = - 3
132        END IF
133  
134        IF(( BWU.GT.N - 1 ) .OR.( BWU.LT.0 ) ) THEN
135            INFO = - 4
136        END IF
137  
138        IF( LLDA.LT.( BWL + BWU + 1 ) ) THEN
139            INFO = - ( 8*100 + 6 )
140        END IF
141  
142        IF( NB.LE.0 ) THEN
143            INFO = - ( 8*100 + 4 )
144        END IF
145  
146        IF( N + IB - 1.GT.STORE_M_B ) THEN
147            INFO = - ( 11*100 + 3 )
148        END IF
149  
150        IF( LLDB.LT.NB ) THEN
151            INFO = - ( 11*100 + 6 )
152        END IF
153  
154        IF( NRHS.LT.0 ) THEN
155            INFO = - 5
156        END IF
157  
158  *     Current alignment restriction
159  
160        IF( JA.NE.IB ) THEN
161            INFO = - 7
162        END IF
163  
164  *     Argument checking that is specific to Divide & Conquer routine
165  
166        IF( NPROW.NE.1 ) THEN
167            INFO = - ( 8*100 + 2 )
168        END IF
169  
170        IF( N.GT.NP*NB - MOD( JA - 1 , NB ) ) THEN
171            INFO = - ( 2 )
172            CALL PXERBLA( ICTXT , 'PDDBTRS , D&C alg. : only 1 block per proc'
173       $    , - INFO )
174            RETURN
175        END IF
176  
177        IF(( JA + N - 1.GT.NB ) .AND.( NB.LT.2*MAX( BWL , BWU ) ) ) THEN
178            INFO = - ( 8*100 + 4 )
179            CALL PXERBLA( ICTXT , 'PDDBTRS , D&C alg. : NB too small' , - INFO )
180            RETURN
181        END IF
182  
183        WORK_SIZE_MIN =( MAX( BWL , BWU )*NRHS )
184  
185        WORK( 1 ) = WORK_SIZE_MIN
186  
187        IF( LWORK.LT.WORK_SIZE_MIN ) THEN
188            IF( LWORK.NE. - 1 ) THEN
189                INFO = - 15
190                CALL PXERBLA( ICTXT , 'PDDBTRS : worksize error' , - INFO )
191            END IF
192            RETURN
193        END IF
194  
195  *     Pack params and positions into arrays for global consistency check
196  
197        PARAM_CHECK( 17 , 1 ) = DESCB( 5 )
198        PARAM_CHECK( 16 , 1 ) = DESCB( 4 )
199        PARAM_CHECK( 15 , 1 ) = DESCB( 3 )
200        PARAM_CHECK( 14 , 1 ) = DESCB( 2 )
201        PARAM_CHECK( 13 , 1 ) = DESCB( 1 )
202        PARAM_CHECK( 12 , 1 ) = IB
203        PARAM_CHECK( 11 , 1 ) = DESCA( 5 )
204        PARAM_CHECK( 10 , 1 ) = DESCA( 4 )
205        PARAM_CHECK( 9 , 1 ) = DESCA( 3 )
206        PARAM_CHECK( 8 , 1 ) = DESCA( 1 )
207        PARAM_CHECK( 7 , 1 ) = JA
208        PARAM_CHECK( 6 , 1 ) = NRHS
209        PARAM_CHECK( 5 , 1 ) = BWU
210        PARAM_CHECK( 4 , 1 ) = BWL
211        PARAM_CHECK( 3 , 1 ) = N
212        PARAM_CHECK( 2 , 1 ) = IDUM3
213        PARAM_CHECK( 1 , 1 ) = IDUM2
214  
215        PARAM_CHECK( 17 , 2 ) = 1105
216        PARAM_CHECK( 16 , 2 ) = 1104
217        PARAM_CHECK( 15 , 2 ) = 1103
218        PARAM_CHECK( 14 , 2 ) = 1102
219        PARAM_CHECK( 13 , 2 ) = 1101
220        PARAM_CHECK( 12 , 2 ) = 10
221        PARAM_CHECK( 11 , 2 ) = 805
222        PARAM_CHECK( 10 , 2 ) = 804
223        PARAM_CHECK( 9 , 2 ) = 803
224        PARAM_CHECK( 8 , 2 ) = 801
225        PARAM_CHECK( 7 , 2 ) = 7
226        PARAM_CHECK( 6 , 2 ) = 5
227        PARAM_CHECK( 5 , 2 ) = 4
228        PARAM_CHECK( 4 , 2 ) = 3
229        PARAM_CHECK( 3 , 2 ) = 2
230        PARAM_CHECK( 2 , 2 ) = 15
231        PARAM_CHECK( 1 , 2 ) = 1
232  
233  *     Want to find errors with MIN( ) , so if no error , set it to a big
234  *     number. If there already is an error , multiply by the the
235  *     descriptor multiplier.
236  
237        IF( INFO.GE.0 ) THEN
238            INFO = BIGNUM
239        ELSE IF( INFO.LT. - DESCMULT ) THEN
240            INFO = - INFO
241        ELSE
242            INFO = - INFO*DESCMULT
243        END IF
244  
245  *     Check consistency across processors
246  
247        CALL GLOBCHK( ICTXT , 17 , PARAM_CHECK , 17 , PARAM_CHECK( 1 , 3 ) ,
248       $INFO )
249  
250  *     Prepare output : set info = 0 if no error , and divide by DESCMULT
251  *     if error is not in a descriptor entry.
252  
253        IF( INFO.EQ.BIGNUM ) THEN
254            INFO = 0
255        ELSE IF( MOD( INFO , DESCMULT ).EQ.0 ) THEN
256            INFO = - INFO / DESCMULT
257        ELSE
258            INFO = - INFO
259        END IF
260  
261        IF( INFO.LT.0 ) THEN
262            CALL PXERBLA( ICTXT , 'PDDBTRS' , - INFO )
263            RETURN
264        END IF
265  
266  *     Quick return if possible
267  
268        IF( N.EQ.0 )
269       $    RETURN
270  
271            IF( NRHS.EQ.0 )
272       $        RETURN
273  
274  *             Adjust addressing into matrix space to properly get into
275  *             the beginning part of the relevant data
276  
277                PART_OFFSET = NB*(( JA - 1 ) / ( NPCOL*NB ) )
278  
279                IF(( MYCOL - CSRC ).LT.( JA - PART_OFFSET - 1 ) / NB ) THEN
280                PART_OFFSET = PART_OFFSET + NB
281            END IF
282  
283            IF( MYCOL.LT.CSRC ) THEN
284                PART_OFFSET = PART_OFFSET - NB
285            END IF
286  
287  *         Form a new BLACS grid(the "standard form" grid) with only procs
288  *         holding part of the matrix , of size 1xNP where NP is adjusted ,
289  *         starting at csrc = 0 , with JA modified to reflect dropped procs.
290  
291  *         First processor to hold part of the matrix :
292  
293            FIRST_PROC = MOD(( JA - 1 ) / NB + CSRC , NPCOL )
294  
295  *         Calculate new JA one while dropping off unused processors.
296  
297            JA_NEW = MOD( JA - 1 , NB ) + 1
298  
299  *         Save and compute new value of NP
300  
301            NP_SAVE = NP
302            NP =( JA_NEW + N - 2 ) / NB + 1
303  
304  *         Call utility routine that forms "standard-form" grid
305  
306            CALL RESHAPE( ICTXT , INT_ONE , ICTXT_NEW , INT_ONE , FIRST_PROC ,
307       $    INT_ONE , NP )
308  
309  *         Use new context from standard grid as context.
310  
311            ICTXT_SAVE = ICTXT
312            ICTXT = ICTXT_NEW
313            DESCA_1XP( 2 ) = ICTXT_NEW
314            DESCB_PX1( 2 ) = ICTXT_NEW
315  
316  *         Get information about new grid.
317  
318            CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
319  
320  *         Drop out processors that do not have part of the matrix.
321  
322            IF( MYROW.LT.0 ) THEN
323                GO TO 20
324            END IF
325  
326  *         Begin main code
327  
328            INFO = 0
329  
330  *         Call frontsolve routine
331  
332            IF( LSAME( TRANS , 'N' ) ) THEN
333  
334                CALL PDDBTRSV ( 'L' , 'N' , N , BWL , BWU , NRHS , A( PART_OFFSET + 1 ) ,
335       $        JA_NEW , DESCA_1XP , B , IB , DESCB_PX1 , AF , LAF ,
336       $        WORK , LWORK , INFO )
337  
338            ELSE
339  
340                CALL PDDBTRSV ( 'U' , 'T' , N , BWL , BWU , NRHS , A( PART_OFFSET + 1 ) ,
341       $        JA_NEW , DESCA_1XP , B , IB , DESCB_PX1 , AF , LAF ,
342       $        WORK , LWORK , INFO )
343  
344            END IF
345  
346  *         Call backsolve routine
347  
348            IF(( LSAME( TRANS , 'C' ) ) .OR.( LSAME( TRANS , 'T' ) ) ) THEN
349  
350                CALL PDDBTRSV ( 'L' , 'T' , N , BWL , BWU , NRHS , A( PART_OFFSET + 1 ) ,
351       $        JA_NEW , DESCA_1XP , B , IB , DESCB_PX1 , AF , LAF ,
352       $        WORK , LWORK , INFO )
353  
354            ELSE
355  
356                CALL PDDBTRSV ( 'U' , 'N' , N , BWL , BWU , NRHS , A( PART_OFFSET + 1 ) ,
357       $        JA_NEW , DESCA_1XP , B , IB , DESCB_PX1 , AF , LAF ,
358       $        WORK , LWORK , INFO )
359  
360            END IF
361     10 CONTINUE
362  
363  *     Free BLACS space used to hold standard - form grid.
364  
365        IF( ICTXT_SAVE.NE.ICTXT_NEW ) THEN
366            CALL BLACS_GRIDEXIT( ICTXT_NEW )
367        END IF
368  
369     20 CONTINUE
370  
371  *     Restore saved input parameters
372  
373        ICTXT = ICTXT_SAVE
374        NP = NP_SAVE
375  
376  *     Output minimum worksize
377  
378        WORK( 1 ) = WORK_SIZE_MIN
379  
380        RETURN
381  
382  *     End of PDDBTRS
383  
384        END