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

Error in Calling Fortran from Python

ferrad1
New Contributor I
2,543 Views

I had this working fine last year. I am calling my Intel Fortran DLL from Anaconda Python using:

```
import sys
import ctypes as ct
lib = ct.CDLL('..\\..\\bin\\Debug\\x64\\solver_lib.dll')

```
Since then, I have been playing with a trial version of NAG to evaluate their solvers. My linker therefore has NLW6I293E_nag.lib in the Additional Dependencies list. Now when I try to run this python script again, on the "lib =" line, I get a popup which says:

> python.exe - Entry Point Not Found
The procedure entry point for_stop_core_quiet could not be located in the dynamic link library C:\Program Files\NAG\NL29\nlw6i293el\bin\NLW6I293E_nag.dll.

Why is this happening? How do I fix it?

0 Kudos
13 Replies
Ron_Green
Moderator
2,512 Views

That function is part of the Intel Runtime library, libifcore.  I am not sure why a NAG-compiled DLL would need Intel's libifcore.  You did compile NLW61293E_nag.dll with the nag compiler, correct?  

You could try adding the path to Intel's libifcore.dll to your library path environment variable?  Really confused why a NAG compiled DLL would need our Intel runtime library.

0 Kudos
ferrad1
New Contributor I
2,504 Views

No I didn't compile NLW61293E_nag.dll, it comes from NAG with their trial.  I am using the Intel Compiler for my application, and linking in their LIB.

0 Kudos
Ron_Green
Moderator
2,503 Views

I apologize, I simply do not understand your application.

You have a Python main program.  It is calling into the NAG math libraries?  If so, you should not need Intel compiler and libraries at all.  

Are you using the Command Line or Visual Studio? 

Does your python driver also call other DLLs you compiled with the Intel compiler?

 

I am having difficulty seeing how this application needs anything from Intel.

0 Kudos
ferrad1
New Contributor I
2,491 Views

Sorry, here is more detail.

I have an application written in Fortran and compiled and linked under Intel Visual Fortran using Microsoft Visual Studio.  An EXE plus bunch of DLLs.

Last year I wrote a Python wrapper to run this application.  It loads the DLL, locates the entry point, runs it and extracts results using JSON.  This all worked fine last year.

Then last month I wanted to trial a NAG optimizer (nothing to do with Python, just the standalone Fortran application), so I downloaded and installed their trial version.  This required inclusion of their LIB file (NLW6I293E_nag.lib) into my VFPROJ so that I can call their DLL (NLW6I293E_nag.dll).  I did a few tests with mixed results.  But the NAG lib remained in my VFPROJ.

Now today I'm revisiting the Python wrapper I worked on last year.  And I get the above error.  So inclusion of the NAG library leads to the Python error.

0 Kudos
Ron_Green
Moderator
2,482 Views

It may be that the Intel Runtime libraries are not being found.  Specifically libifcore DLLs. 

One year ago Intel had a different directory structure.  Did you upgrade to the 2024.0 compiler?  If so then the location for libifcore has changed.  Here is an article on where we store our runtime DLLs.  

I'll assume it is the same PC and not a new one from last year.

Do you run the python wrapper from the command line or from within Visual Studio? 

 

If command line, what does

echo %PATH% show for Intel paths, and can you find libifcore in those paths?

0 Kudos
ferrad1
New Contributor I
2,470 Views

I run Python from an Anaconda command prompt, which is:

 %windir%\System32\cmd.exe "/K" C:\Users\acf\anaconda3\Scripts\activate.bat C:\Users\acf\anaconda3

I don't see any Intel directories in %PATH% under this cmd

I am running Intel Fortran 64 bit, Version 2021.8.0 Build 20221119_000000

Same PC as last year.

0 Kudos
Ron_Green
Moderator
2,456 Views

From the Anaconda command prompt, can you run the oneAPI setvars.bat?

"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
0 Kudos
ferrad1
New Contributor I
2,385 Views

Yes, that runs.

Also I don't get the Windows pop-up error about the NAG DLL.

However the Anaconda directories are removed from the path after running that batch file.  I'm not sure if that will be a problem regarding Python use in the future.

0 Kudos
andrew_4619
Honored Contributor III
2,364 Views

Normally it creates a load of new path directories and puts the existing paths item on the end so it sounds like it failed. Maybe the path exceeds the max length? 

0 Kudos
Arjen_Markus
Honored Contributor I
2,357 Views

One problem I have encountered regularly wrt DLLs on Windows is that you simply do not always get a message about missing DLLs. Sometimes the program simply stops.

0 Kudos
ferrad1
New Contributor I
2,355 Views

Yes that is what I normally expect.  But it didn't do that.  The anaconda directories were at the beginning of the PATH, see left hand bit below.

 

Snap8.jpg

 

The right hand bit shows what happened after I ran the Intel BAT file.  The anaconda directories were removed (they don't appear later), and replaced by all the Intel directories.

0 Kudos
andrew_4619
Honored Contributor III
2,340 Views

I am using the latest version maybe your older one has some issue?

0 Kudos
ferrad1
New Contributor I
2,339 Views

Who knows, I'm using Version 2021.8.0 Build 20221119_000000. It seems to work so I'll leave things as they are until I really need to upgrade.

0 Kudos
Reply