我如何在Fortran中使用(初始化,操作,从中获取输出)mkl句柄?

我正在WSL中使用Intel Fortran编译器,其安装目录为/opt/intel。我想使用稀疏的BLAS函数。 link to intel's documentation of the libaray

这是相关代码的一部分。

double complex,allocatable ::  H(:,:),Hvert(:,Hstar(:,:)
allocate(H(dimH,dimH),Hvert(dimH,Hstar(dimH,dimH))

! initialization of Hstar
info = mkl_sparse_z_create_coo(Hstar,SPARSE_INDEX_BASE_ONE,m**L,2**L,ind(1,ind(2,Hele)

! initialization of empty matrix
ind = 0
info = mkl_sparse_z_create_coo(Hvert,1),H)

! add A and B to form the final matrix
info = mkl_sparse_z_add(SPARSE_OPERATION_NON_TRANSPOSE,Hstar,1d0,Hvert,H)

当我使用以下命令进行编译时

ifort -xHost -parallel full.f90 -o output -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_spblas -lmkl_core -liomp5 -lpthread -lm -qopenmp && ./output

即使我已经提供了库,它也会给我以下错误

source /opt/intel/bin/ifortvars.sh -arch intel64 -platform linux
source /opt/intel/bin/compilervars.sh -arch intel64 -platform linux
full.f90(146): error #6404: This name does not have a type,and must have an explicit type.   [MKL_SPARSE_Z_CREATE_COO]
     info = mkl_sparse_z_create_coo(Hvert,Hele)
------------^
full.f90(226): error #6404: This name does not have a type,and must have an explicit type.   [MKL_SPARSE_Z_ADD]
     info = mkl_sparse_z_add(SPARSE_OPERATION_NON_TRANSPOSE,H)
------------^
full.f90(240): error #6404: This name does not have a type,and must have an explicit type.   [MKL_SPARSE_Z_MV]
       info = mkl_sparse_z_mv(SPARSE_OPERATION_NON_TRANSPOSE,H,SPARSE_MATRIX_TYPE_HERMITIAN,psi(a,0d0,dummy)
--------------^
compilation aborted for full.f90 (code 1)

我认为这是由于我不正确地链接到相关库以及将矩阵初始化为普通可分配数组引起的。

如何使用这些功能?

我也不知道大写变量SPARSE_INDEX_BASE_ONE是什么意思。我应该这样使用吗?

wsetty 回答:我如何在Fortran中使用(初始化,操作,从中获取输出)mkl句柄?

链接路径正确。您不需要链接-mkl_spblas。请始终参考MKL链接顾问(https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor)。 我建议您看一下现有的sparse_z_csrmv.f90示例,该示例显示如何调用类似的稀疏BLAS函数。这个示例称为CSR,但不称为COO格式,但在这种情况下并不重要。

本文链接:https://www.f2er.com/3134360.html

大家都在问