如何在命令行

时间:2015-07-19 03:30:27

标签: xcode command-line fortran intel-fortran intel-mkl

我刚刚为Fortran OS X *(学生版)安装了英特尔®ParallelStudio XE编辑器版。它附带了数学核心库,这就是我买它的原因。我很难开始使用MKL。这是我一步一步做的。

1)为Fortran OS X *安装的英特尔®ParallelStudio XE Composer版(没问题)。我可以使用ifort运行一个'hello world'脚本,并在最后抛出-mkl链接命令没有问题(暂时不调用任何mkl命令)。

2)关注these instructions我使用intel提供的脚本设置环境变量(确切地说位于opt / intel / bin中)。我有英特尔64位架构(根据ifort -V)所以我使用bash mklvars.sh intel64 mod ilp64。它运行没有错误(或任何输出)。

3)我编写以下代码,以便为fortran95使用MKL的gemm命令。只需乘以2个矩阵。

program test

implicit none
real, dimension(2,2) :: testA, testB, testC

testA = 1
testB = 1
testC = 0  ! I don't think I need this line, but it shouldn't matter

call gemm(testA, testB, testC)

write(*,*) testC

end program test

4)我用ifort test_mkl.f90 -o test -mkl编译。我收到以下错误:

Undefined symbols for architecture x86_64:
  "_gemm_", referenced from:
      _MAIN__ in ifortSTVOrB.o
ld: symbol(s) not found for architecture x86_64

5)我尝试ifort test_mkl.f90 -o test -L/opt/intel/mkl/lib -mkl并获得相同的结果。

我注意到很多人使用MKL开始使用USE mkl95_blas, ONLY: gemm代码,所以我将其放在implicit none上面的上述两个示例中并得到:

    test_mkl.f90(4): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [MKL95_BLAS]
    USE mkl95_blas, ONLY: gemm
--------^
test_mkl.f90(12): error #6406: Conflicting attributes or multiple declaration of name.   [GEMM]
    call gemm(testA, testB, testC )
---------^
test_mkl.f90(4): error #6580: Name in only-list does not exist.   [GEMM]
    USE mkl95_blas, ONLY: gemm
--------------------------^
compilation aborted for test_mkl.f90 (code 1)

有关问题是什么或如何解决此问题的任何想法?我已成功run a simple script in XCODE使用MKL,所以这绝对是我正在做的事情,而不是我的安装。

1 个答案:

答案 0 :(得分:1)

文档告诉您在提供的compilervars.sh脚本上使用“source”命令来使所有资源可用。例如:

来源//bin/compilervars.sh

这会将MKL添加到include和library路径,以便编译器和链接器可以找到它们。如果您需要更多帮助,请在https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x询问您可以https://software.intel.com/en-us/forums/intel-math-kernel-library

获取MKL特定帮助