* F08FDF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NB, NMAX, MMAX PARAMETER (NB=64,NMAX=10,MMAX=5) INTEGER LDA, LDZ, LIWORK, LWORK PARAMETER (LDA=NMAX,LDZ=NMAX,LIWORK=10*NMAX,LWORK=(NB+6) + *NMAX) DOUBLE PRECISION ZERO PARAMETER (ZERO=0.0D+0) * .. Local Scalars .. DOUBLE PRECISION ABSTOL, VL, VU INTEGER I, IFAIL, IL, INFO, IU, J, LIWOPT, LWKOPT, M, N * .. Local Arrays .. DOUBLE PRECISION A(LDA,NMAX), W(NMAX), WORK(LWORK), Z(LDZ,MMAX) INTEGER ISUPPZ(2*MMAX), IWORK(LIWORK) * .. External Subroutines .. EXTERNAL DSYEVR, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F08FDF Example Program Results' WRITE (NOUT,*) * Skip heading in data file and read N and the lower and upper * indices of the smallest and largest eigenvalues to be found READ (NIN,*) READ (NIN,*) N, IL, IU IF (N.LE.NMAX .AND. (IU-IL+1).LE.MMAX) THEN * * Read the upper triangular part of the matrix A from data file * READ (NIN,*) ((A(I,J),J=I,N),I=1,N) * * Set the absolute error tolerance for eigenvalues. With ABSTOL * set to zero, the default value is used instead * ABSTOL = ZERO * * Solve the symmetric eigenvalue problem * CALL DSYEVR('Vectors','I','Upper',N,A,LDA,VL,VU,IL,IU,ABSTOL,M, + W,Z,LDZ,ISUPPZ,WORK,LWORK,IWORK,LIWORK,INFO) * IF (INFO.EQ.0) THEN * * Print solution * WRITE (NOUT,*) 'Selected eigenvalues' WRITE (NOUT,99999) (W(J),J=1,M) * IFAIL = 0 CALL X04CAF('General',' ',N,M,Z,LDZ,'Selected eigenvectors', + IFAIL) * * Print workspace information * LWKOPT = WORK(1) LIWOPT = IWORK(1) IF (LWORK.LT.LWKOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99998) 'Optimum real workspace required = ', + LWKOPT, 'Real workspace provided = ', LWORK END IF IF (LIWORK.LT.LIWOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99998) 'Integer workspace required = ', + LIWOPT, 'Integer workspace provided = ', LIWORK END IF ELSE WRITE (NOUT,99997) 'Failure in DSYEVR. INFO =', INFO END IF ELSE WRITE (NOUT,*) 'NMAX and/or MMAX too small' END IF STOP * 99999 FORMAT (3X,(8F8.4)) 99998 FORMAT (1X,A,I5,/1X,A,I5) 99997 FORMAT (1X,A,I5) END