- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Intel Fortran Community,
After compiling a Fortran code using the command "ifx /dll Sample.f90", when calling it via "ctypes.CDLL" in Python, I encountered the error: "FileNotFoundError : Could not find module '{folderpath}Sample.dll' (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.
Upon investigation, I found that the cause of the issue is the dcos function in line 18 of Sample.f90, which uses the input variable ("sweep" in my code). For example, if I replace "dcos(0d0 * pi / 180d0)" with a real number such as 0d0, the FileNotFoundError is resolved. However, I would like to be able to use sweep in the dcos function and still call the DLL from Python.
module Sample
use ISO_C_binding
implicit none
contains
!*****************************************************************************************************************
subroutine Samplecode(imax, xc, zc, sweep, node_pos) bind(C, name = "Samplecode")
!DEC$ ATTRIBUTES DLLEXPORT :: Samplecode
integer(c_int), intent(in) :: imax
real(c_double), intent(in) :: xc(imax)
real(c_double), intent(in) :: zc(imax)
real(c_double), intent(in) :: sweep
real(c_double), intent(out) :: node_pos(imax, 2)
real(c_double) :: pi
pi = dasin(1d0) * 2d0
node_pos(:, 1) = xc(:)
node_pos(:, 2) = zc(:) / dcos(sweep * pi / 180d0)
end subroutine Samplecode
!*****************************************************************************************************************
end module Sample
To resolve the issue, I have tried the following steps, but none of them were effective:
1. Added the folder containing the DLL to the environment variables using "os.environ['Path']" in Python.
2. Replaced the dcos function with cos in the Fortran code.
3. Used an intermediate variable to store the result of "dcos(sweep * pi / 180d0)" in Fortran.
4. Verified ucrtbase.dll using the "sfc /scannow" command.
5. Tried various compilation commands:
・ifx /dll /Od Sample.f90
・ifx /dll /Od /fp:precise Sample.f90
・ifx /dll /fp:source Sample.f90
・ifx /dll /Qimf-arch-consistency:true Sample.f90
6. Verified the architecture of the DLL:
・Sample.dll architecture: 8664 machine (x64)
・Python architecture: 64-bit
7. Checked the runtime libraries by executing "ifx /?", which displayed the Intel Fortran Compiler Help as expected.
8. Used the "dumpbin /exports Sample.dll" command to verify the correct export of functions from "Sample.dll".
Despite these efforts, the issue persists. I would appreciate any insights or suggestions on how to resolve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"one of its dependencies" - this is the key. the DCOS function is supported by libmmd.dll - this needs to be in PATH or in one of the other places Windows looks for DLLs. However, if you use this DLL only from Python, and not other Fortran code, the simple solution is to add /libs:static to your ifx command.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"one of its dependencies" - this is the key. the DCOS function is supported by libmmd.dll - this needs to be in PATH or in one of the other places Windows looks for DLLs. However, if you use this DLL only from Python, and not other Fortran code, the simple solution is to add /libs:static to your ifx command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply.
Among the solutions you suggested, I added "/libs:static" to the ifx command to resolve the issue.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page