Solving the Fortran LAPACK DSYEV Error with a 3x3 Matrix

  • Context: Fortran 
  • Thread starter Thread starter tarekph
  • Start date Start date
  • Tags Tags
    Fortran Lapack
Click For Summary
SUMMARY

The forum discussion addresses a common error encountered when using the LAPACK DSYEV function in Fortran to compute eigenvalues of a 3x3 matrix. The user faced the error message indicating an illegal value for parameter number 5, which was due to incorrectly passing the matrix variable. The correct syntax requires using the matrix A instead of Q in the DSYEV call. Additionally, a syntax error in the declaration of the matrix A was identified, where a comma was needed instead of a period.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with LAPACK library functions, specifically DSYEV
  • Knowledge of matrix operations and eigenvalue computation
  • Basic debugging skills in Fortran
NEXT STEPS
  • Review LAPACK DSYEV documentation for parameter requirements
  • Practice debugging Fortran code to identify syntax errors
  • Learn about matrix initialization and manipulation in Fortran
  • Explore additional LAPACK functions for different matrix operations
USEFUL FOR

This discussion is beneficial for beginner Fortran programmers, students learning numerical methods, and developers working with LAPACK for linear algebra computations.

tarekph
Messages
1
Reaction score
0
Hello
I am a beginner in programming with Fortran and I want to use the LAPACK DSYEV in my program.
I am an example to determine the eigenvalues ​​of a matrix (3x3) after I use it in my program but when I compile I get this error
"" "" "** One entry to DSYEV parameter number 5 Had an illegal value" "" ""
Here is my example:
Program eigenvalue

implicit none

! statements
double precision :: A (3.3), w (3), Work (3)
integer :: i INFO, LWORK, LDA = 3
character :: N, U

! A matrix
A (1 : ) = (/ 3, 1, 3 /)
A (2, : ) = (/ 1, 5, 6 /)
A (3 : ) = (/ 3, 6, 5 /)




CALL DSYEV ('N', 'U', 3, Q, W, LDA, WORK, LWORK, INFO)

! print the solution
do i = 1, 3
write (*, 9) i, w (i)
end do

9 format ('x [' i1 '] =', f5.2)
end programs eigenvalue
I know not how I met the LDA or WORK .. LWORK...
thank you
 
Technology news on Phys.org


tarekph said:
Hello
I am a beginner in programming with Fortran and I want to use the LAPACK DSYEV in my program.
I am an example to determine the eigenvalues ​​of a matrix (3x3) after I use it in my program but when I compile I get this error
"" "" "** One entry to DSYEV parameter number 5 Had an illegal value" "" ""
Here is my example:
Program eigenvalue

implicit none

! statements
double precision :: A (3.3), w (3), Work (3)
integer :: i INFO, LWORK, LDA = 3
character :: N, U

! A matrix
A (1 : ) = (/ 3, 1, 3 /)
A (2, : ) = (/ 1, 5, 6 /)
A (3 : ) = (/ 3, 6, 5 /)




CALL DSYEV ('N', 'U', 3, Q, W, LDA, WORK, LWORK, INFO)

! print the solution
do i = 1, 3
write (*, 9) i, w (i)
end do

9 format ('x [' i1 '] =', f5.2)
end programs eigenvalue
I know not how I met the LDA or WORK .. LWORK...
thank you

I see a couple of mistakes in your code.
1) In this line -- double precision :: A (3.3) -- there should be a comma between the two 3s, not a period.
2) You passed Q in the call to DSYEV. That's the parameter that should be the array A.

I found a link to some documentation on DSYEV - it explains what the parameters need to be - http://www.netlib.org/lapack/double/dsyev.f
 
  • Like
Likes   Reactions: GadhaR

Similar threads

  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 18 ·
Replies
18
Views
7K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 22 ·
Replies
22
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K