1.那篇帖子是针对各种函数库进行的,是说的使用所有函数库的“通则”,不可能说得很详细。
2.帮助里提到:
Include Files
Fortran: mkl.fi
Fortran 95: blas.f90
C: mkl.h
所以,需要 use blas95,如果你不知道具体是那个 module,可以去MKL安装目录的 include 文件夹去找,看有几个 .mod 文件。
加载 mkl_blas95.lib 就去安装目录的 lib 里找。
3.同上。
4.F77接口和F95接口不要混用。
5.是否依赖,我也不确定,应该是不依赖的,你可以用 Dependency Walker 查看一下。具体可参考 http://www.fcode.cn/guide-53-1.html
vvt 发表于 2014-7-23 07:33
1.那篇帖子是针对各种函数库进行的,是说的使用所有函数库的“通则”,不可能说得很详细。
2.帮助里提到:
...
按照你说的,在加载其他文件的时候我还是遇到一些问题。
比如我想利用fortran95接口求矩阵的逆阵:
首先需要将矩阵LU分解,分解函数为getrf(fortran95接口,Page420),求逆阵函数getri,两个函数版主文件相同。帮助里提到:
Include Files
• Fortran: mkl.fi
• Fortran 95: lapack.f90
• C: mkl.h
我在项目—属性—Linker-Input-Additional Dependencies 输入mkl_lapack95.lib
完整代码如下:
Program Main
callTest_getrf
callTest_dot
End program
Subroutine Test_dot!矢量点乘
use BlAS95
implicit none
real x(10), y(10),res
integer::i
do i = 1, 10
x(i) = 1
y(i) = 1
end do
res=5
res=dot(x,y)
write(*,*) res
End subroutine
Subroutine Test_getrf!矩阵分解成LU,并求逆阵
use LAPACK95
implicit none
real(kind=4)::a(3,3)=(/1,1,3,2,1,-1,-1,2,1/)
integer::ipiv=3,info=0,work(1)=3
write(*,*) a(1,:)
write(*,*) a(2,:)
write(*,*) a(3,:)
call getrf(a,ipiv,info)!矩阵分解成LU
call getri(a,ipiv,info)!求逆阵
write(*,*) info
write(*,*) a(1,:)
write(*,*) a(2,:)
write(*,*) a(3,:)
End subroutine
编译之后错误如下:
错误 3 error #5508: Declaration of routine 'TEST_DOT' conflicts with a previous declaration
错误 1 error #6285: There is no matching specific subroutine for this generic subroutine call.
错误 2 error #6285: There is no matching specific subroutine for this generic subroutine call.
错误 4 Compilation Aborted (code 1)
本来能运行的dot函数也不能运行了。
怎么办啊。。。 两个问题:
1.如果你既使用了 mkl_blas95.lib,又使用了 mkl_lapack95.lib,请在项目—属性—Linker-Input-Additional Dependencies 输入 :“mkl_blas95.lib mkl_lapack95.lib”
2.你对 getrf 的使用不对。ipiv 必须是数组,而不能是单变量。integer::ipiv(3)=3 既可 vvt 发表于 2014-7-23 10:20
两个问题:
1.如果你既使用了 mkl_blas95.lib,又使用了 mkl_lapack95.lib,请在项目—属性—Linker-Input- ...
找到问题了,是第二个。但是我又有疑问了:
1、为什么在Fortran77接口中,ipiv可以使一个整数,而不是数组依然可以运行,并计算出来。
2、 getrf(fortran95接口),里面的三个参数是不是只有第一个是必须的,其他两个是可选的。如果是,怎么才能只输入a,不输入ipiv和info;怎么才能只输入a和info,不输入ipiv。
3、在MKL的include中有两个文件夹:ilp64、lp64 。但是里面的Mod文件是一样的,请问这个64位的模块有什么不一样吗?
1. F77 语法本身,对接口的检查就不严格。建议使用 F95 接口
2. 是的,只有第一个参数是必选的。可选参数的问题,可以看看彭叔叔的书。
call getrf(a)
call getrf(a,info=info)
3. 我不知道,我用的 MKL 版本里没有。你看看帮助吧。
页:
1
[2]