- #1

- 31

- 1

## Main Question or Discussion Point

I am trying to use the LAPACK routine dsyev to solve for the eigenvalues of a matrix, and I designed a program to test this and make sure I am getting the right results. It isn't recognizing the subroutine however.

The subroutine is dsyev, which I can post or can be found on the LAPACK site.

My program is

PROGRAM EIGENVALUE

IMPLICIT NONE

! Statements

Double Precision :: A (6,6), w (6), Work (6)

INTEGER :: i, INFO, LWORK, LDA = 6

CHARACTER :: N, U

! External Subroutines

EXTERNAL :: dsyev

! A matrix

A (1, : ) = (/ 0, 1, 0, 0, 0, 0 /)

A (2, : ) = (/ 0, 0, 1, 0, 0, 0 /)

A (3, : ) = (/ 1, 0, 0, 0, 0, 0 /)

A (4, : ) = (/ 0, 0, 0, 0, 0, 1 /)

A (5, : ) = (/ 0, 0, 0, 1, 0, 0 /)

A (6, : ) = (/ 0, 0, 0, 0, 1, 0 /)

CALL dsyev( 'N', 'U', 6, W, LDA, WORK, LWORK, INFO )

! Print the solution

DO i = 1, 6

WRITE (*, 9) i, w (i)

END DO

9 format ('x [' i1 '] =', f5.2)

END PROGRAM EIGENVALUE

And when I try to compile the error I am getting is:

collins@piccard $ gfortran Eigenvalue.f90

/tmp/ccczm4lt.o: In function `MAIN__':

Eigenvalue.f90:(.text+0x1b9): undefined reference to `dsyev_'

collect2: ld returned 1 exit status

The subroutine is dsyev, which I can post or can be found on the LAPACK site.

My program is

PROGRAM EIGENVALUE

IMPLICIT NONE

! Statements

Double Precision :: A (6,6), w (6), Work (6)

INTEGER :: i, INFO, LWORK, LDA = 6

CHARACTER :: N, U

! External Subroutines

EXTERNAL :: dsyev

! A matrix

A (1, : ) = (/ 0, 1, 0, 0, 0, 0 /)

A (2, : ) = (/ 0, 0, 1, 0, 0, 0 /)

A (3, : ) = (/ 1, 0, 0, 0, 0, 0 /)

A (4, : ) = (/ 0, 0, 0, 0, 0, 1 /)

A (5, : ) = (/ 0, 0, 0, 1, 0, 0 /)

A (6, : ) = (/ 0, 0, 0, 0, 1, 0 /)

CALL dsyev( 'N', 'U', 6, W, LDA, WORK, LWORK, INFO )

! Print the solution

DO i = 1, 6

WRITE (*, 9) i, w (i)

END DO

9 format ('x [' i1 '] =', f5.2)

END PROGRAM EIGENVALUE

And when I try to compile the error I am getting is:

collins@piccard $ gfortran Eigenvalue.f90

/tmp/ccczm4lt.o: In function `MAIN__':

Eigenvalue.f90:(.text+0x1b9): undefined reference to `dsyev_'

collect2: ld returned 1 exit status