我有一個問題,將lapack鏈接到Fortran示例程序。這裏是example.f95從英特爾MKL鏈接LAPACK與gfortran
Program LinearEquations
! solving the matrix equation A*x=b using LAPACK
Implicit none
! declarations
double precision :: A(3,3), b(3)
integer :: i, pivot(3), ok
! matrix A
A(1,:)=(/3, 1, 3/)
A(2,:)=(/1, 5, 9/)
A(3,:)=(/2, 6, 5/)
! vector b
b(:)=(/-1, 3, -3/)
!b(:)=(/2, 2, 9/)
! find the solution using the LAPACK routine DGESV
call DGESV(3, 1, A, 3, pivot, b, 3, ok)
! print the solution x
do i=1, 3
write(*,9) i, b(i)
end do
9 format('x[', i1, ']= ', f5.2)
end program LinearEquations
這裏我已經安裝了庫
/opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64_lin/libmkl_lapack95_ilp64.a
我使用gfortran編譯程序的程序:
gfortran -o example example.f95 -L/opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64_lin/libmkl_lapack95_ilp64.a
它抱怨
/tmp/ccWtxMFP.o: In function `MAIN__':
example.f95:(.text+0xf0): undefined reference to `dgesv_'
collect2: error: ld returned 1 exit status
有人可以幫我解決這個問題嗎?非常感謝
您似乎使用默認的32位整數,同時指定需要64位整數的庫。請參閱英特爾®mkl鏈接顧問程序小程序以獲取一整套所需的庫。 – tim18
我試過ia32,但它不起作用。 – Vlada
正如您發現的那樣,閱讀文檔比通過反覆試驗更容易。 – tim18