0

I'm using FORTRAN 90 in terminal at Ubuntu-Virtualbox I need to write a program that diagonalizes matrix 4X4, calling LAPACK and BLAS and prints the list of its eigenvalues

I install LAPACK and BLAS libraries:

sudo apt-get install libblas3gf libblas-doc libblas-dev liblapack3gf liblapack-doc liblapack-dev

my program is:

program matrices   
implicit none  
double precision :: A (4,4)  
double precision,allocatable :: work (:,:)  
double precision,allocatable :: W (:,:)  
integer :: i, j  
integer :: lwork  
integer :: info, JOBZ, UPLO, N, LDA  
N=4  
do i=1,N  
   do j=1,N  
      A(i,j)=0  
   end do  
end do  
do i = 1, N  
     A(i,i) = 2  
     A(i,i+1) = -1  
     A(i+1,i) = -1  
end do  
LDA=N  
lwork = MAX(1,3*N-1)  
ALLOCATE(work(1:lwork,1:lwork))  
ALLOCATE(W(1:N,1:N))  
CALL dsyev(JOBZ,UPLO,N,A,LDA,W,work,lwork,info)  
WRITE(*,"(3X,A,I3)") 'Diagonalization performed, info equals ',info  
WRITE(*,*)  
end program matrices

this is what I receive:

hila@hila-VirtualBox:~$ gfortran -o tbxu matrices.f90 -lblas -llapack
hila@hila-VirtualBox:~$ gfortran matrices.f90
/tmp/cceiQMkG.o: In function `MAIN__':
matrices.f90:(.text+0x548): undefined reference to `dsyev_'
collect2: error: ld returned 1 exit status

can you help me and tell me what I'm doing wrong?

francescalus
  • 30,576
  • 16
  • 61
  • 96
Hila
  • 1
  • 1

0 Answers0