1      SUBROUTINE RS(NM,N,A,W,MATZ,Z,FV1,FV2,IERR)
2C***BEGIN PROLOGUE  RS
3C***DATE WRITTEN   760101   (YYMMDD)
4C***REVISION DATE  830518   (YYMMDD)
5C***CATEGORY NO.  D4A1
6C***KEYWORDS  EIGENVALUES,EIGENVECTORS,EISPACK
7C***AUTHOR  SMITH, B. T., ET AL.
8C***PURPOSE  Computes eigenvalues and, optionally, eigenvectors of
9C            real symmetric matrix.
10C***DESCRIPTION
11C
12C     This subroutine calls the recommended sequence of
13C     subroutines from the eigensystem subroutine package (EISPACK)
14C     to find the eigenvalues and eigenvectors (if desired)
15C     of a REAL SYMMETRIC matrix.
16C
17C     On Input
18C
19C        NM  must be set to the row dimension of the two-dimensional
20C        array parameters as declared in the calling program
21C        dimension statement.
22C
23C        N  is the order of the matrix  A.
24C
25C        A  contains the real symmetric matrix.
26C
27C        MATZ  is an integer variable set equal to zero if
28C        only eigenvalues are desired.  Otherwise it is set to
29C        any non-zero integer for both eigenvalues and eigenvectors.
30C
31C     On Output
32C
33C        W  contains the eigenvalues in ascending order.
34C
35C        Z  contains the eigenvectors if MATZ is not zero.
36C
37C        IERR  is an integer output variable set equal to an
38C        error completion code described in section 2B of the
39C        documentation.  The normal completion code is zero.
40C
41C        FV1  and  FV2  are temporary storage arrays.
42C
43C     Questions and comments should be directed to B. S. Garbow,
44C     APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
45C     ------------------------------------------------------------------
46C***REFERENCES  B. T. SMITH, J. M. BOYLE, J. J. DONGARRA, B. S. GARBOW,
47C                 Y. IKEBE, V. C. KLEMA, C. B. MOLER, *MATRIX EIGEN-
48C                 SYSTEM ROUTINES - EISPACK GUIDE*, SPRINGER-VERLAG,
49C                 1976.
50C***ROUTINES CALLED  TQL2,TQLRAT,TRED1,TRED2
51C***END PROLOGUE  RS
52C
53      INTEGER N,NM,IERR,MATZ
54      REAL A(NM,N),W(N),Z(NM,N),FV1(N),FV2(N)
55C
56C***FIRST EXECUTABLE STATEMENT  RS
57      IF (N .LE. NM) GO TO 10
58      IERR = 10 * N
59      GO TO 50
60C
61   10 IF (MATZ .NE. 0) GO TO 20
62C     .......... FIND EIGENVALUES ONLY ..........
63      CALL  TRED1(NM,N,A,W,FV1,FV2)
64      CALL  TQLRAT(N,W,FV2,IERR)
65      GO TO 50
66C     .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
67   20 CALL  TRED2(NM,N,A,W,FV1,Z)
68      CALL  TQL2(NM,N,W,FV1,Z,IERR)
69   50 RETURN
70      END
71