    PROGRAM nag_sym_gen_eig_ex01

      ! Example Program Text for nag_sym_gen_eig
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_write_mat, ONLY : nag_write_gen_mat
      USE nag_sym_gen_eig, ONLY : nag_sym_gen_eig_all
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, n
      CHARACTER (1) :: uplo
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: a(:,:), b(:,:), lambda(:), z(:,:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_sym_gen_eig_ex01'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) n, uplo

      ALLOCATE (a(n,n),b(n,n),z(n,n),lambda(n)) ! Allocate storage

      SELECT CASE (uplo)
      CASE ('U','u')
        READ (nag_std_in,*) (a(i,i:),i=1,n)
        READ (nag_std_in,*) (b(i,i:),i=1,n)
      CASE ('L','l')
        READ (nag_std_in,*) (a(i,:i),i=1,n)
        READ (nag_std_in,*) (b(i,:i),i=1,n)
      END SELECT

      ! Compute eigenvalues and eigenvectors

      CALL nag_sym_gen_eig_all(uplo,a,b,lambda,z=z)

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) 'Eigenvalues'
      WRITE (nag_std_out,'(2X,6(F9.3:))') lambda
      WRITE (nag_std_out,*)

      CALL nag_write_gen_mat(z,format='(F9.3)',title='Eigenvectors')

      DEALLOCATE (a,b,lambda,z)    ! Deallocate storage

    END PROGRAM nag_sym_gen_eig_ex01
