Quantcast
Channel: Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 2652

Cannot use MKL F95 eigensolver routines

$
0
0

I am using Intel Parallel Studio XE with Visual Studio. I would like to use the heev()/heevr() routines. I have written a simple code to test it, and I have enabled the "Use MKL libraries" option in Project Properties:

include 'lapack.f90'
program heev_test
    use lapack95
    implicit none
    integer , parameter :: dp = kind(0.0d0)
    complex(dp) :: matrix(4,4)
    real(dp) :: eigs(4)
    integer :: i
    matrix = (1.0_dp,0.0_dp)
    call heevr(matrix, eigs, info=i)
    print*, i
    print*, eigs
    read(*,*)
    stop  
end program

This code produces the error:

error LNK2019: unresolved external symbol _ZHEEVR_F95 referenced in function _MAIN__		
fatal error LNK1120: 1 unresolved externals		

So the linker is not finding the ZHEEVR_F95 subroutine whose interface is provided in the lapack.f90 file. Replacing HEEVR with HEEV produces the same results. I should say that I am also using the VSL and DFT libraries without any issue. 

I noticed in the documentation for ?heev it says to include the mkl.fi file (which I don't normally include for the VSL or DFT libraries), but doing so produces the following errors: 

Error       error #6218: This statement is positioned incorrectly and/or has syntax errors.     C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\\mkl\include\lapack.f90    21  
Error       error #6790: This is an invalid statement; an END [PROGRAM]  statement is required.     C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\\mkl\include\lapack.f90    24  
Error       error #6785: This name does not match the unit name.   [F95_PRECISION]      C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\\mkl\include\lapack.f90    24  
Error       Compilation Aborted (code 1)        
Warning     warning #5427: Program may contain only one main entry routine

The line numbers are referring to these lines from the lapack.f90 file:

21  MODULE F95_PRECISION
22      INTEGER, PARAMETER :: SP = KIND(1.0E0)
23      INTEGER, PARAMETER :: DP = KIND(1.0D0)
24  END MODULE F95_PRECISION

which doesn't really tell me much.

I need to figure out why the linker can't find the f95 subroutines, any help appreciated. 

EDIT:

I tried using the F77 interface with the following code:

 

include 'lapack.f90'
program heev_test
    use lapack95
    implicit none
    integer , parameter :: dp = kind(0.0d0)
    complex(dp) :: matrix(4,4)
    real(dp) :: eigs(4)
    integer :: i
    matrix = (1.0_dp,0.0_dp)
    call eigenvalues(matrix,eigs)
    print*, eigs
    read(*,*)
    stop  
    
contains
    
    subroutine eigenvalues(H,eigs)
        complex(dp) :: H(:,:)
        real(dp)    :: eigs(:)
        integer   :: d
        integer   :: info
        integer   :: lwork, liwork
        real(dp), allocatable  :: work(:)
        integer , allocatable  :: iwork(:)
        
        d = size(eigs)
        
        lwork = 4*d
        liwork = 10
        allocate(work(lwork))
        allocate(iwork(liwork))
        
        call zheevr('N','U',d,H,d,eigs,work,-1,iwork,-1,info)
        
        lwork = work(1)
        liwork = iwork(1)
        deallocate(work,iwork)        
        allocate(work(lwork))
        allocate(iwork(liwork))
        
        call zheevr('N','U',d,H,d,eigs,work,lwork,iwork,liwork,info)
        
        deallocate(work,iwork)
        
        if (info /= 0) then
            print*, "diagonalization failed, info = ", info
            read(*,*)
            stop
        end if
                
    end subroutine
end program

but this causes a seg fault as soon as zheevr is called, and now I have absolutely no idea what is going on. 

 


Viewing all articles
Browse latest Browse all 2652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>