我有一个问题,将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