* F08JVF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER LGNMAX, NMAX, KDMAX PARAMETER (LGNMAX=5,NMAX=2**LGNMAX,KDMAX=8) INTEGER LDAB, LDZ, LIWORK, LRWORK, LWORK PARAMETER (LDAB=KDMAX+1,LDZ=NMAX, + LIWORK=6+6*NMAX+5*NMAX*LGNMAX, + LRWORK=1+3*NMAX+2*NMAX*LGNMAX+3*NMAX*NMAX, + LWORK=NMAX*NMAX) CHARACTER UPLO PARAMETER (UPLO='U') * .. Local Scalars .. INTEGER I, IFAIL, INFO, J, KD, LIWOPT, LRWOPT, LWOPT, N * .. Local Arrays .. COMPLEX *16 AB(LDAB,NMAX), WORK(LWORK), Z(LDZ,NMAX) DOUBLE PRECISION D(NMAX), E(NMAX-1), RWORK(LRWORK) INTEGER IWORK(LIWORK) CHARACTER CLABS(1), RLABS(1) * .. External Subroutines .. EXTERNAL X04DBF, ZHBTRD, ZSTEDC * .. Intrinsic Functions .. INTRINSIC INT, MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F08JVF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N, KD IF (N.LE.NMAX .AND. KD.LE.KDMAX) THEN * * Read the upper or lower triangular part of the band matrix A * from data file * IF (UPLO.EQ.'U') THEN DO 20 I = 1, N READ (NIN,*) (AB(KD+1+I-J,J),J=I,MIN(N,I+KD)) 20 CONTINUE ELSE IF (UPLO.EQ.'L') THEN DO 40 I = 1, N READ (NIN,*) (AB(1+I-J,J),J=MAX(1,I-KD),I) 40 CONTINUE END IF * * Reduce A to tridiagonal form T = (Z**T)*A*Z, and form Z * CALL ZHBTRD('V',UPLO,N,KD,AB,LDAB,D,E,Z,LDZ,WORK,INFO) * * Calculate all the eigenvalues and eigenvectors of A, * from T and Z * CALL ZSTEDC('V',N,D,E,Z,LDZ,WORK,LWORK,RWORK,LRWORK,IWORK, + LIWORK,INFO) LWOPT = INT(WORK(1)) LRWOPT = INT(RWORK(1)) LIWOPT = IWORK(1) * IF (INFO.EQ.0) THEN * * Print eigenvalues and eigenvectors * WRITE (NOUT,*) 'Eigenvalues' WRITE (NOUT,99999) (D(I),I=1,N) * WRITE (NOUT,*) IFAIL = 0 CALL X04DBF('General',' ',N,N,Z,LDZ,'Bracketed','F7.4', + 'Eigenvectors','Integer',RLABS,'Integer',CLABS, + 80,0,IFAIL) * ELSE WRITE (NOUT,99998) 'Failure in ZSTEDC. INFO = ', INFO END IF * * Print workspace information * IF (LWORK.LT.LWOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99997) 'Complex workspace required = ', LWOPT, + 'Complex workspace provided = ', LWORK END IF IF (LRWORK.LT.LRWOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99997) 'Real workspace required = ', LRWOPT, + 'Real workspace provided = ', LRWORK END IF IF (LIWORK.LT.LIWOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99997) 'Integer workspace required = ', LIWOPT, + 'Integer workspace provided = ', LIWORK END IF ELSE WRITE (NOUT,*) 'NMAX and/or KDMAX too small' END IF * 99999 FORMAT (4X,F8.4,3(10X,F8.4)) 99998 FORMAT (1X,A,I10) 99997 FORMAT ((1X,A,I5)) END