Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Issue with FileNotFoundError when calling Fortran DLL in Python related to dgesv

411390
Beginner
362 Views

Dear Intel Fortran Community,

I hope this message finds you well. I am currently working with Intel Fortran and Python, and I have encountered an issue that I am hoping you might be able to help me with.

After compiling a Fortran code using the command:

 

ifx /dll /libs:static /Qmkl sample.f90

 

I attempt to call resulting 'sample.dll' via 'ctypes.CDLL' in Python, but I receive the following error:

 

FileNotFoundError : Could not find module '{sample.dll's folder path}' (or one of its dependencies). Try using the full path with constructor syntax.

 

The file path to 'sample.dll' is correct, and it exists on the system. I have verified that there are no errors in the code or the compilation, but the call from Python does not work, and I have been unable to resolve the issue.
 
Here is a snippet of the Fortran code I am working with, which includes a call to the 'dgesv' routine for solving linear systems:

 

module sample
    use ISO_C_binding
    implicit none
    contains
!*****************************************************************************************************************
    subroutine solve_linear_system(imax, jmax, matA, matB, info, matX) bind(C, name = "solve_linear_system")
        !DEC$ ATTRIBUTES DLLEXPORT :: solve_linear_system
        integer(c_int), intent(in) :: imax
        integer(c_int), intent(in) :: jmax
        real(c_double), intent(in) :: matA(imax, imax)
        real(c_double), intent(in) :: matB(imax, jmax)
        integer(c_int), intent(out) :: info
        real(c_double), intent(out) :: matX(imax, jmax)

        integer(c_int) :: ipiv(imax)

        external dgesv
        call dgesv(imax, jmax, matA, imax, ipiv, matB, imax, info)
        matX = matB

    end subroutine solve_linear_system
!*****************************************************************************************************************
end module sample

 

To resolve this issue, I have tried adding environment variables with dependent DLL folders and experimented with different compile options such as /Qmkl-ilp64, but to no avail.

Any insights or suggestions would be greatly appreciated. Thank you very much for your time and assistance.

Best regards,

0 Kudos
1 Reply
Steve_Lionel
Honored Contributor III
304 Views

I don't think (my experiments were inconclusive) that /libs:static affects which MKL libraries are linked in with /Qmkl. I suggest that you take this to the MKL forum, and/or make sure that the MKL DLLs are included in PATH.

0 Kudos
Reply