1      SUBROUTINE PDSYNTRD( UPLO, N, A, IA, JA, DESCA, D, E, TAU, WORK,
2     $                     LWORK, INFO )
3*
4*  -- ScaLAPACK routine (version 1.7) --
5*     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6*     and University of California, Berkeley.
7*     May 25, 2001
8*
9*     .. Scalar Arguments ..
10      CHARACTER          UPLO
11      INTEGER            IA, INFO, JA, LWORK, N
12*     ..
13*     .. Array Arguments ..
14      INTEGER            DESCA( * )
15      DOUBLE PRECISION   A( * ), D( * ), E( * ), TAU( * ), WORK( * )
16*     ..
17*  Bugs
18*  ====
19*
20*
21*  Support for UPLO='U' is limited to calling the old, slow, PDSYTRD
22*  code.
23*
24*
25*  Purpose
26*
27*  =======
28*
29*  PDSYNTRD is a prototype version of PDSYTRD which uses tailored
30*  codes (either the serial, DSYTRD, or the parallel code, PDSYTTRD)
31*  when the workspace provided by the user is adequate.
32*
33*
34*  PDSYNTRD reduces a real symmetric matrix sub( A ) to symmetric
35*  tridiagonal form T by an orthogonal similarity transformation:
36*  Q' * sub( A ) * Q = T, where sub( A ) = A(IA:IA+N-1,JA:JA+N-1).
37*
38*  Features
39*  ========
40*
41*  PDSYNTRD is faster than PDSYTRD on almost all matrices,
42*  particularly small ones (i.e. N < 500 * sqrt(P) ), provided that
43*  enough workspace is available to use the tailored codes.
44*
45*  The tailored codes provide performance that is essentially
46*  independent of the input data layout.
47*
48*  The tailored codes place no restrictions on IA, JA, MB or NB.
49*  At present, IA, JA, MB and NB are restricted to those values allowed
50*  by PDSYTRD to keep the interface simple.  These restrictions are
51*  documented below.  (Search for "restrictions".)
52*
53*  Notes
54*  =====
55*
56*
57*  Each global data object is described by an associated description
58*  vector.  This vector stores the information required to establish
59*  the mapping between an object element and its corresponding process
60*  and memory location.
61*
62*  Let A be a generic term for any 2D block cyclicly distributed array.
63*  Such a global array has an associated description vector DESCA.
64*  In the following comments, the character _ should be read as
65*  "of the global array".
66*
67*  NOTATION        STORED IN      EXPLANATION
68*  --------------- -------------- --------------------------------------
69*  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
70*                                 DTYPE_A = 1.
71*  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
72*                                 the BLACS process grid A is distribu-
73*                                 ted over. The context itself is glo-
74*                                 bal, but the handle (the integer
75*                                 value) may vary.
76*  M_A    (global) DESCA( M_ )    The number of rows in the global
77*                                 array A.
78*  N_A    (global) DESCA( N_ )    The number of columns in the global
79*                                 array A.
80*  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
81*                                 the rows of the array.
82*  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
83*                                 the columns of the array.
84*  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
85*                                 row of the array A is distributed.
86*  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
87*                                 first column of the array A is
88*                                 distributed.
89*  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
90*                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
91*
92*  Let K be the number of rows or columns of a distributed matrix,
93*  and assume that its process grid has dimension p x q.
94*  LOCr( K ) denotes the number of elements of K that a process
95*  would receive if K were distributed over the p processes of its
96*  process column.
97*  Similarly, LOCc( K ) denotes the number of elements of K that a
98*  process would receive if K were distributed over the q processes of
99*  its process row.
100*  The values of LOCr() and LOCc() may be determined via a call to the
101*  ScaLAPACK tool function, NUMROC:
102*          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
103*          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
104*  An upper bound for these quantities may be computed by:
105*          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
106*          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
107*
108*
109*  Arguments
110*  =========
111*
112*  UPLO    (global input) CHARACTER
113*          Specifies whether the upper or lower triangular part of the
114*          symmetric matrix sub( A ) is stored:
115*          = 'U':  Upper triangular
116*          = 'L':  Lower triangular
117*
118*  N       (global input) INTEGER
119*          The number of rows and columns to be operated on, i.e. the
120*          order of the distributed submatrix sub( A ). N >= 0.
121*
122*  A       (local input/local output) DOUBLE PRECISION pointer into the
123*          local memory to an array of dimension (LLD_A,LOCc(JA+N-1)).
124*          On entry, this array contains the local pieces of the
125*          symmetric distributed matrix sub( A ).  If UPLO = 'U', the
126*          leading N-by-N upper triangular part of sub( A ) contains
127*          the upper triangular part of the matrix, and its strictly
128*          lower triangular part is not referenced. If UPLO = 'L', the
129*          leading N-by-N lower triangular part of sub( A ) contains the
130*          lower triangular part of the matrix, and its strictly upper
131*          triangular part is not referenced. On exit, if UPLO = 'U',
132*          the diagonal and first superdiagonal of sub( A ) are over-
133*          written by the corresponding elements of the tridiagonal
134*          matrix T, and the elements above the first superdiagonal,
135*          with the array TAU, represent the orthogonal matrix Q as a
136*          product of elementary reflectors; if UPLO = 'L', the diagonal
137*          and first subdiagonal of sub( A ) are overwritten by the
138*          corresponding elements of the tridiagonal matrix T, and the
139*          elements below the first subdiagonal, with the array TAU,
140*          represent the orthogonal matrix Q as a product of elementary
141*          reflectors. See Further Details.
142*
143*  IA      (global input) INTEGER
144*          The row index in the global array A indicating the first
145*          row of sub( A ).
146*
147*  JA      (global input) INTEGER
148*          The column index in the global array A indicating the
149*          first column of sub( A ).
150*
151*  DESCA   (global and local input) INTEGER array of dimension DLEN_.
152*          The array descriptor for the distributed matrix A.
153*
154*  D       (local output) DOUBLE PRECISION array, dimension LOCc(JA+N-1)
155*          The diagonal elements of the tridiagonal matrix T:
156*          D(i) = A(i,i). D is tied to the distributed matrix A.
157*
158*  E       (local output) DOUBLE PRECISION array, dimension LOCc(JA+N-1)
159*          if UPLO = 'U', LOCc(JA+N-2) otherwise. The off-diagonal
160*          elements of the tridiagonal matrix T: E(i) = A(i,i+1) if
161*          UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'. E is tied to the
162*          distributed matrix A.
163*
164*  TAU     (local output) DOUBLE PRECISION array, dimension
165*          LOCc(JA+N-1). This array contains the scalar factors TAU of
166*          the elementary reflectors. TAU is tied to the distributed
167*          matrix A.
168*
169*  WORK    (local workspace/local output) DOUBLE PRECISION array,
170*                                                  dimension (LWORK)
171*          On exit, WORK( 1 ) returns the optimal LWORK.
172*
173*  LWORK   (local or global input) INTEGER
174*          The dimension of the array WORK.
175*          LWORK is local input and must be at least
176*          LWORK >= MAX( NB * ( NP +1 ), 3 * NB )
177*
178*          For optimal performance, greater workspace is needed, i.e.
179*            LWORK >= 2*( ANB+1 )*( 4*NPS+2 ) + ( NPS + 4 ) * NPS
180*            ICTXT = DESCA( CTXT_ )
181*            ANB = PJLAENV( ICTXT, 3, 'PDSYTTRD', 'L', 0, 0, 0, 0 )
182*            SQNPC = INT( SQRT( DBLE( NPROW * NPCOL ) ) )
183*            NPS = MAX( NUMROC( N, 1, 0, 0, SQNPC ), 2*ANB )
184*
185*            NUMROC is a ScaLAPACK tool functions;
186*            PJLAENV is a ScaLAPACK envionmental inquiry function
187*            MYROW, MYCOL, NPROW and NPCOL can be determined by calling
188*            the subroutine BLACS_GRIDINFO.
189*
190*
191*  INFO    (global output) INTEGER
192*          = 0:  successful exit
193*          < 0:  If the i-th argument is an array and the j-entry had
194*                an illegal value, then INFO = -(i*100+j), if the i-th
195*                argument is a scalar and had an illegal value, then
196*                INFO = -i.
197*
198*  Further Details
199*  ===============
200*
201*  If UPLO = 'U', the matrix Q is represented as a product of elementary
202*  reflectors
203*
204*     Q = H(n-1) . . . H(2) H(1).
205*
206*  Each H(i) has the form
207*
208*     H(i) = I - tau * v * v'
209*
210*  where tau is a real scalar, and v is a real vector with
211*  v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
212*  A(ia:ia+i-2,ja+i), and tau in TAU(ja+i-1).
213*
214*  If UPLO = 'L', the matrix Q is represented as a product of elementary
215*  reflectors
216*
217*     Q = H(1) H(2) . . . H(n-1).
218*
219*  Each H(i) has the form
220*
221*     H(i) = I - tau * v * v'
222*
223*  where tau is a real scalar, and v is a real vector with
224*  v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in
225*  A(ia+i+1:ia+n-1,ja+i-1), and tau in TAU(ja+i-1).
226*
227*  The contents of sub( A ) on exit are illustrated by the following
228*  examples with n = 5:
229*
230*  if UPLO = 'U':                       if UPLO = 'L':
231*
232*    (  d   e   v2  v3  v4 )              (  d                  )
233*    (      d   e   v3  v4 )              (  e   d              )
234*    (          d   e   v4 )              (  v1  e   d          )
235*    (              d   e  )              (  v1  v2  e   d      )
236*    (                  d  )              (  v1  v2  v3  e   d  )
237*
238*  where d and e denote diagonal and off-diagonal elements of T, and vi
239*  denotes an element of the vector defining H(i).
240*
241*  Alignment requirements
242*  ======================
243*
244*  The distributed submatrix sub( A ) must verify some alignment proper-
245*  ties, namely the following expression should be true:
246*  ( MB_A.EQ.NB_A .AND. IROFFA.EQ.ICOFFA .AND. IROFFA.EQ.0 ) with
247*  IROFFA = MOD( IA-1, MB_A ) and ICOFFA = MOD( JA-1, NB_A ).
248*
249*  =====================================================================
250*
251*     .. Parameters ..
252      INTEGER            BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
253     $                   MB_, NB_, RSRC_, CSRC_, LLD_
254      PARAMETER          ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,
255     $                   CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,
256     $                   RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )
257      DOUBLE PRECISION   ONE
258      PARAMETER          ( ONE = 1.0D+0 )
259*     ..
260*     .. Local Scalars ..
261      LOGICAL            LQUERY, UPPER
262      CHARACTER          COLCTOP, ROWCTOP
263      INTEGER            ANB, CTXTB, I, IACOL, IAROW, ICOFFA, ICTXT,
264     $                   IINFO, INDB, INDD, INDE, INDTAU, INDW, IPW,
265     $                   IROFFA, J, JB, JX, K, KK, LLWORK, LWMIN, MINSZ,
266     $                   MYCOL, MYCOLB, MYROW, MYROWB, NB, NP, NPCOL,
267     $                   NPCOLB, NPROW, NPROWB, NPS, NQ, ONEPMIN, SQNPC,
268     $                   TTLWMIN
269*     ..
270*     .. Local Arrays ..
271      INTEGER            DESCB( DLEN_ ), DESCW( DLEN_ ), IDUM1( 2 ),
272     $                   IDUM2( 2 )
273*     ..
274*     .. External Subroutines ..
275      EXTERNAL           BLACS_GET, BLACS_GRIDEXIT, BLACS_GRIDINFO,
276     $                   BLACS_GRIDINIT, CHK1MAT, DESCSET, DSYTRD,
277     $                   IGAMN2D, PCHK1MAT, PDELSET, PDLAMR1D, PDLATRD,
278     $                   PDSYR2K, PDSYTD2, PDSYTTRD, PDTRMR2D,
279     $                   PB_TOPGET, PB_TOPSET, PXERBLA
280*     ..
281*     .. External Functions ..
282      LOGICAL            LSAME
283      INTEGER            INDXG2L, INDXG2P, NUMROC, PJLAENV
284      EXTERNAL           LSAME, INDXG2L, INDXG2P, NUMROC, PJLAENV
285*     ..
286*     .. Intrinsic Functions ..
287      INTRINSIC          DBLE, ICHAR, INT, MAX, MIN, MOD, SQRT
288*     ..
289*     .. Executable Statements ..
290*
291*       This is just to keep ftnchek and toolpack/1 happy
292      IF( BLOCK_CYCLIC_2D*CSRC_*CTXT_*DLEN_*DTYPE_*LLD_*MB_*M_*NB_*N_*
293     $    RSRC_.LT.0 )RETURN
294*     Get grid parameters
295*
296      ICTXT = DESCA( CTXT_ )
297      CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
298*
299*     Test the input parameters
300*
301      INFO = 0
302      IF( NPROW.EQ.-1 ) THEN
303         INFO = -( 600+CTXT_ )
304      ELSE
305         CALL CHK1MAT( N, 2, N, 2, IA, JA, DESCA, 6, INFO )
306         UPPER = LSAME( UPLO, 'U' )
307         IF( INFO.EQ.0 ) THEN
308            NB = DESCA( NB_ )
309            IROFFA = MOD( IA-1, DESCA( MB_ ) )
310            ICOFFA = MOD( JA-1, DESCA( NB_ ) )
311            IAROW = INDXG2P( IA, NB, MYROW, DESCA( RSRC_ ), NPROW )
312            IACOL = INDXG2P( JA, NB, MYCOL, DESCA( CSRC_ ), NPCOL )
313            NP = NUMROC( N, NB, MYROW, IAROW, NPROW )
314            NQ = MAX( 1, NUMROC( N+JA-1, NB, MYCOL, DESCA( CSRC_ ),
315     $           NPCOL ) )
316            LWMIN = MAX( ( NP+1 )*NB, 3*NB )
317            ANB = PJLAENV( ICTXT, 3, 'PDSYTTRD', 'L', 0, 0, 0, 0 )
318            MINSZ = PJLAENV( ICTXT, 5, 'PDSYTTRD', 'L', 0, 0, 0, 0 )
319            SQNPC = INT( SQRT( DBLE( NPROW*NPCOL ) ) )
320            NPS = MAX( NUMROC( N, 1, 0, 0, SQNPC ), 2*ANB )
321            TTLWMIN = 2*( ANB+1 )*( 4*NPS+2 ) + ( NPS+4 )*NPS
322*
323            WORK( 1 ) = DBLE( TTLWMIN )
324            LQUERY = ( LWORK.EQ.-1 )
325            IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
326               INFO = -1
327*
328*            The following two restrictions are not necessary provided
329*            that either of the tailored codes are used.
330*
331            ELSE IF( IROFFA.NE.ICOFFA .OR. ICOFFA.NE.0 ) THEN
332               INFO = -5
333            ELSE IF( DESCA( MB_ ).NE.DESCA( NB_ ) ) THEN
334               INFO = -( 600+NB_ )
335            ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
336               INFO = -11
337            END IF
338         END IF
339         IF( UPPER ) THEN
340            IDUM1( 1 ) = ICHAR( 'U' )
341         ELSE
342            IDUM1( 1 ) = ICHAR( 'L' )
343         END IF
344         IDUM2( 1 ) = 1
345         IF( LWORK.EQ.-1 ) THEN
346            IDUM1( 2 ) = -1
347         ELSE
348            IDUM1( 2 ) = 1
349         END IF
350         IDUM2( 2 ) = 11
351         CALL PCHK1MAT( N, 2, N, 2, IA, JA, DESCA, 6, 2, IDUM1, IDUM2,
352     $                  INFO )
353      END IF
354*
355      IF( INFO.NE.0 ) THEN
356         CALL PXERBLA( ICTXT, 'PDSYNTRD', -INFO )
357         RETURN
358      ELSE IF( LQUERY ) THEN
359         RETURN
360      END IF
361*
362*     Quick return if possible
363*
364      IF( N.EQ.0 )
365     $   RETURN
366*
367*
368      ONEPMIN = N*N + 3*N + 1
369      LLWORK = LWORK
370      CALL IGAMN2D( ICTXT, 'A', ' ', 1, 1, LLWORK, 1, 1, -1, -1, -1,
371     $              -1 )
372*
373*
374*
375*     Use the serial, LAPACK, code:  DTRD on small matrices if we
376*     we have enough space.
377*
378      NPROWB = 0
379      IF( ( N.LT.MINSZ .OR. SQNPC.EQ.1 ) .AND. LLWORK.GE.ONEPMIN .AND.
380     $    .NOT.UPPER ) THEN
381         NPROWB = 1
382         NPS = N
383      ELSE
384         IF( LLWORK.GE.TTLWMIN .AND. .NOT.UPPER ) THEN
385            NPROWB = SQNPC
386         END IF
387      END IF
388*
389      IF( NPROWB.GE.1 ) THEN
390         NPCOLB = NPROWB
391         SQNPC = NPROWB
392         INDB = 1
393         INDD = INDB + NPS*NPS
394         INDE = INDD + NPS
395         INDTAU = INDE + NPS
396         INDW = INDTAU + NPS
397         LLWORK = LLWORK - INDW + 1
398*
399         CALL BLACS_GET( ICTXT, 10, CTXTB )
400         CALL BLACS_GRIDINIT( CTXTB, 'Row major', SQNPC, SQNPC )
401         CALL BLACS_GRIDINFO( CTXTB, NPROWB, NPCOLB, MYROWB, MYCOLB )
402         CALL DESCSET( DESCB, N, N, 1, 1, 0, 0, CTXTB, NPS )
403*
404         CALL PDTRMR2D( UPLO, 'N', N, N, A, IA, JA, DESCA, WORK( INDB ),
405     $                  1, 1, DESCB, ICTXT )
406*
407*
408*        Only those processors in context CTXTB are needed for a while
409*
410         IF( NPROWB.GT.0 ) THEN
411*
412            IF( NPROWB.EQ.1 ) THEN
413               CALL DSYTRD( UPLO, N, WORK( INDB ), NPS, WORK( INDD ),
414     $                      WORK( INDE ), WORK( INDTAU ), WORK( INDW ),
415     $                      LLWORK, INFO )
416            ELSE
417*
418               CALL PDSYTTRD( 'L', N, WORK( INDB ), 1, 1, DESCB,
419     $                        WORK( INDD ), WORK( INDE ),
420     $                        WORK( INDTAU ), WORK( INDW ), LLWORK,
421     $                        INFO )
422*
423            END IF
424         END IF
425*
426*           All processors participate in moving the data back to the
427*           way that PDSYNTRD expects it.
428*
429         CALL PDLAMR1D( N-1, WORK( INDE ), 1, 1, DESCB, E, 1, JA,
430     $                  DESCA )
431*
432         CALL PDLAMR1D( N, WORK( INDD ), 1, 1, DESCB, D, 1, JA, DESCA )
433*
434         CALL PDLAMR1D( N, WORK( INDTAU ), 1, 1, DESCB, TAU, 1, JA,
435     $                  DESCA )
436*
437         CALL PDTRMR2D( UPLO, 'N', N, N, WORK( INDB ), 1, 1, DESCB, A,
438     $                  IA, JA, DESCA, ICTXT )
439*
440         IF( MYROWB.GE.0 )
441     $      CALL BLACS_GRIDEXIT( CTXTB )
442*
443      ELSE
444*
445         CALL PB_TOPGET( ICTXT, 'Combine', 'Columnwise', COLCTOP )
446         CALL PB_TOPGET( ICTXT, 'Combine', 'Rowwise', ROWCTOP )
447         CALL PB_TOPSET( ICTXT, 'Combine', 'Columnwise', '1-tree' )
448         CALL PB_TOPSET( ICTXT, 'Combine', 'Rowwise', '1-tree' )
449*
450         IPW = NP*NB + 1
451*
452         IF( UPPER ) THEN
453*
454*        Reduce the upper triangle of sub( A ).
455*
456            KK = MOD( JA+N-1, NB )
457            IF( KK.EQ.0 )
458     $         KK = NB
459            CALL DESCSET( DESCW, N, NB, NB, NB, IAROW,
460     $                    INDXG2P( JA+N-KK, NB, MYCOL, DESCA( CSRC_ ),
461     $                    NPCOL ), ICTXT, MAX( 1, NP ) )
462*
463            DO 10 K = N - KK + 1, NB + 1, -NB
464               JB = MIN( N-K+1, NB )
465               I = IA + K - 1
466               J = JA + K - 1
467*
468*           Reduce columns I:I+NB-1 to tridiagonal form and form
469*           the matrix W which is needed to update the unreduced part of
470*           the matrix
471*
472               CALL PDLATRD( UPLO, K+JB-1, JB, A, IA, JA, DESCA, D, E,
473     $                       TAU, WORK, 1, 1, DESCW, WORK( IPW ) )
474*
475*           Update the unreduced submatrix A(IA:I-1,JA:J-1), using an
476*           update of the form:
477*           A(IA:I-1,JA:J-1) := A(IA:I-1,JA:J-1) - V*W' - W*V'
478*
479               CALL PDSYR2K( UPLO, 'No transpose', K-1, JB, -ONE, A, IA,
480     $                       J, DESCA, WORK, 1, 1, DESCW, ONE, A, IA,
481     $                       JA, DESCA )
482*
483*           Copy last superdiagonal element back into sub( A )
484*
485               JX = MIN( INDXG2L( J, NB, 0, IACOL, NPCOL ), NQ )
486               CALL PDELSET( A, I-1, J, DESCA, E( JX ) )
487*
488               DESCW( CSRC_ ) = MOD( DESCW( CSRC_ )+NPCOL-1, NPCOL )
489*
490   10       CONTINUE
491*
492*        Use unblocked code to reduce the last or only block
493*
494            CALL PDSYTD2( UPLO, MIN( N, NB ), A, IA, JA, DESCA, D, E,
495     $                    TAU, WORK, LWORK, IINFO )
496*
497         ELSE
498*
499*        Reduce the lower triangle of sub( A )
500*
501            KK = MOD( JA+N-1, NB )
502            IF( KK.EQ.0 )
503     $         KK = NB
504            CALL DESCSET( DESCW, N, NB, NB, NB, IAROW, IACOL, ICTXT,
505     $                    MAX( 1, NP ) )
506*
507            DO 20 K = 1, N - NB, NB
508               I = IA + K - 1
509               J = JA + K - 1
510*
511*           Reduce columns I:I+NB-1 to tridiagonal form and form
512*           the matrix W which is needed to update the unreduced part
513*           of the matrix
514*
515               CALL PDLATRD( UPLO, N-K+1, NB, A, I, J, DESCA, D, E, TAU,
516     $                       WORK, K, 1, DESCW, WORK( IPW ) )
517*
518*           Update the unreduced submatrix A(I+NB:IA+N-1,I+NB:IA+N-1),
519*           using an update of the form: A(I+NB:IA+N-1,I+NB:IA+N-1) :=
520*           A(I+NB:IA+N-1,I+NB:IA+N-1) - V*W' - W*V'
521*
522               CALL PDSYR2K( UPLO, 'No transpose', N-K-NB+1, NB, -ONE,
523     $                       A, I+NB, J, DESCA, WORK, K+NB, 1, DESCW,
524     $                       ONE, A, I+NB, J+NB, DESCA )
525*
526*           Copy last subdiagonal element back into sub( A )
527*
528               JX = MIN( INDXG2L( J+NB-1, NB, 0, IACOL, NPCOL ), NQ )
529               CALL PDELSET( A, I+NB, J+NB-1, DESCA, E( JX ) )
530*
531               DESCW( CSRC_ ) = MOD( DESCW( CSRC_ )+1, NPCOL )
532*
533   20       CONTINUE
534*
535*        Use unblocked code to reduce the last or only block
536*
537            CALL PDSYTD2( UPLO, KK, A, IA+K-1, JA+K-1, DESCA, D, E, TAU,
538     $                    WORK, LWORK, IINFO )
539         END IF
540*
541         CALL PB_TOPSET( ICTXT, 'Combine', 'Columnwise', COLCTOP )
542         CALL PB_TOPSET( ICTXT, 'Combine', 'Rowwise', ROWCTOP )
543*
544      END IF
545*
546      WORK( 1 ) = DBLE( TTLWMIN )
547*
548      RETURN
549*
550*     End of PDSYNTRD
551*
552      END
553