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

Intel Fortran and Python f2py

Ian_K_
New Contributor I
2,578 Views

Last year I was able to convert a  block of FORTRAN subroutines into a PYD format library using f2py.  I started a command environment using

Ian_K__0-1682301738226.png

and was able to simply use (I am showing a common Fibonacci number test case which appears in multiple f2py examples, my codes were more elaborate)  

python -m numpy.f2py -c fib1.f -m fib1

This worked with no problems.  Now with my update to ONE API, the same logic fails (apparently at some point after I start the  compile process.

The initial command shows a successful CMD setup

:: initializing oneAPI environment...
Initializing Visual Studio command-line environment...
Visual Studio version 16.11.20 environment configured.
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\"
Visual Studio command-line environment initialized for: 'x64'
: advisor -- latest
: compiler -- latest
: dal -- latest
: debugger -- latest
: dev-utilities -- latest
: dnnl -- latest
: dpcpp-ct -- latest
: dpl -- latest
: inspector -- latest
: intelpython -- latest
: ipp -- latest
: ippcp -- latest
: itac -- latest
: mkl -- latest
: mpi -- latest
: tbb -- latest
: vpl -- latest
: vtune -- latest
:: oneAPI environment initialized ::

C:\Program Files (x86)\Intel\oneAPI>

The traceback is as follows

Found executable C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\bin\intel64\ifort.exe
Traceback (most recent call last):
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\f2py\__main__.py", line 4, in <module>
main()
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\f2py\f2py2e.py", line 690, in main
run_compile()
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\f2py\f2py2e.py", line 657, in run_compile
setup(ext_modules=[ext])
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\core.py", line 169, in setup
return old_setup(**new_attr)
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\command\build.py", line 61, in run
old_build.run(self)
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\command\build_ext.py", line 271, in run
self._f77_compiler = new_fcompiler(compiler=self.fcompiler,
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\fcompiler\__init__.py", line 878, in new_fcompiler
compiler = get_default_fcompiler(plat, requiref90=requiref90,
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\fcompiler\__init__.py", line 849, in get_default_fcompiler
compiler_type = _find_existing_fcompiler(matching_compiler_types,
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\fcompiler\__init__.py", line 801, in _find_existing_fcompiler
v = c.get_version()
File "C:\Program Files (x86)\Intel\oneAPI\intelpython\latest\lib\site-packages\numpy\distutils\fcompiler\intel.py", line 38, in get_version
version = re.search(r'Version\s*([\d.]+)', output).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

 

When I check in the app data I see that wrappers were successful and the failure appears to be associated with compilation. 

I am not sure if this post is appropriate but  I have checked with numerous python with no luck at all.  The fib1.f file is attached.

 

Labels (1)
0 Kudos
1 Solution
Ian_K_
New Contributor I
2,243 Views

I have now come to more or less understand the issue, which I suspect is related to my configuration either of FORTRAN or ANACONDA

 

I can get at f2py by using the anaconda CMD structure and then setting up a ONEAPI environment and then finally accessing Python through a full path to the Anaconda version of Python to avoid the Intel Python.

The ONEAPI  CMD command structure will fail because any attempt to execute Python requires the Anaconda environment ( something I have to work on).

In a sense this is my accepted solution, and it is a combination of the comments of all who responded.

Thanks to all

 

View solution in original post

11 Replies
mecej4
Honored Contributor III
2,571 Views

The traceback and the messages are from your Python build system, not the Fortran compiler.

As for the Fortran source file fib1.f is concerned, you have to make sure that, when the subroutine is called, the array argument A is has a length of at least n.

0 Kudos
Ian_K_
New Contributor I
2,545 Views

Thank you for the comment, first I am only using fib.f as a test because it commonly appears in NUMPY documents, my subroutines are more complex.  The main point is the f2py worked fine before and I was able to use the library in PYTHON.   I realize that the output lines are python comments, but my problem is that it worked last year with version 19.1. Since the Fortran compiler updates to ONE API it no longer works and it appears that the new compiler output (no other steps are visible in the screen output) is not compatible with F2PY, that is why I am seeking help here.   

I noted that when I check python versions I see that in fact I am using Intel Python (which may have been updated in ONE API. 

So to test an alternative I ran used Anaconda (that I use with Spyder for my Python) to create a cmd screen and tried to set the environment by copying the two setvars batch files to my test folder and they ran with no error.  Executing the Python f2py line then cannot find the Fortran compiler.  So a new question, how can I make f2py see the compiler in a command screen.

Thanks in advance for any help 

0 Kudos
mecej4
Honored Contributor III
2,511 Views

Before attempting to run a Python script or program that is expected to call the Fortran compiler, check whether the environment is correctly set up by entering the command ifort . If you do not receive the short response from the compiler with version information, that is an indication that you should run the Intel Fortran startup script setvars.bat, in the same way that you say you did with Anaconda, etc. (whatever that is, I do not know).

0 Kudos
Ian_K_
New Contributor I
2,465 Views

I have tested this approach 

I started with a cmd generated from anaconda (a popular framework for python users through Spyder)

I negotiated to my test folder and ran a copied version setvars with apparent success.  See (1) below

Next I entered IFORT but it was not recognized

Next I used SET to look at the environment (2) below but could not see a pointer to IFORT.  This is getting to the edge of my system skills, I have more than 50 years experience with FORTRAN as a user but have little systems experience. so after I tried to attach the two SETVARS batch files I needed to have, to change them so that so they form 3 and 4 as TXT files. The system still rejects these apparently txt files so I cannot attach them

 

Note that I am using VS2019 for my FORTRAN and the same issues with IFORT arose when I started from a plain CMD start.

When I opened a ONEAPI CMD start a much more detailed startup occurred and IFORT worked 3 below

 

1

Microsoft Windows [Version 10.0.22621.1555]
(c) Microsoft Corporation. All rights reserved.

(base) C:\Users\iking>cd test

(base) C:\Users\iking\test>setvars
:: initializing oneAPI environment...
Initializing Visual Studio command-line environment...
Visual Studio version 16.11.20 environment configured.
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\"
Visual Studio command-line environment initialized for: 'x64'
:: oneAPI environment initialized ::

 

2

(base) C:\Users\iking\test>set
ADVISOR_2022_DIR=C:\Program Files (x86)\Intel\oneAPI\advisor\2022.3.0
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\iking\AppData\Roaming
CommandPromptType=Native
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432=C:\Program Files\Common Files
COMPUTERNAME=RMALEG
COMSPEC=C:\WINDOWS\system32\cmd.exe
CONDA_DEFAULT_ENV=base
CONDA_EXE=C:\Users\iking\anaconda3\Scripts\conda.exe
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=C:\Users\iking\anaconda3\python.exe
CONDA_SHLVL=1
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\
DRIVERDATA=C:\Windows\System32\Drivers\DriverData
EFC_18680=1
ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs
Framework40Version=v4.0
FrameworkDir=C:\Windows\Microsoft.NET\Framework64\
FrameworkDir64=C:\Windows\Microsoft.NET\Framework64\
FrameworkVersion=v4.0.30319
FrameworkVersion64=v4.0.30319
HOMEDRIVE=C:
HOMEPATH=\Users\iking
IFORT_COMPILER21=C:\Program Files (x86)\Intel\oneAPI\compiler\2021.2.0\windows\
IFORT_COMPILER22=C:\Program Files (x86)\Intel\oneAPI\compiler\2022.2.0\windows\
INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt
INSPECTOR_2021_DIR=C:\Program Files (x86)\Intel\oneAPI\inspector\2021.2.0
INTEL_DEV_REDIST=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
INTEL_LICENSE_FILE=C:\Program Files\Common Files\INTEL\lICENSES
I_MPI_ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI\mpi\2021.7.0
I_MPI_ROOT=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\
JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-17.0.5.8-hotspot\
LIB=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0;C:\Windows\Microsoft.NET\Framework64\v4.0.30319
LOCALAPPDATA=C:\Users\iking\AppData\Local
LOGONSERVER=\\RMALEG
NUMBER_OF_PROCESSORS=20
ONEAPI_ROOT=C:\Users\iking\test
ONEDRIVE=C:\Users\iking\OneDrive
ONEDRIVECONSUMER=C:\Users\iking\OneDrive
OS=Windows_NT
PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;C:\Users\iking\anaconda3;C:\Users\iking\anaconda3\Library\mingw-w64\bin;C:\Users\iking\anaconda3\Library\usr\bin;C:\Users\iking\anaconda3\Library\bin;C:\Users\iking\anaconda3\Scripts;C:\Users\iking\anaconda3\bin;C:\Users\iking\anaconda3\condabin;C:\Users\iking\anaconda3;C:\Users\iking\anaconda3\Library\mingw-w64\bin;C:\Users\iking\anaconda3\Library\usr\bin;C:\Users\iking\anaconda3\Library\bin;C:\Users\iking\anaconda3\Scripts;C:\Program Files\Eclipse Adoptium\jdk-17.0.5.8-hotspot\bin;C:\Program Files (x86)\Intel\oneAPI\tbb\latest\redist\intel64\vc_mt;C:\Program Files (x86)\Intel\oneAPI\tbb\latest\redist\ia32\vc_mt;C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\intel64_win\compiler;C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\ia32_win\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\libfabric\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\libfabric\bin\utils;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\ia32;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64;C:\Program Files (x86)\Common Files\Intel\Shared Libraries;c:\wint\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Common Files\Acronis\SnapAPI;C:\Program Files (x86)\Common Files\Acronis\VirtualFile;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64;C:\Program Files (x86)\Common Files\Acronis\FileProtector;C:\Program Files (x86)\Common Files\Acronis\FileProtector64;C:\Users\iking\AppData\Local\Microsoft\WindowsApps;.;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Platform=x64
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 154 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=9a03
PROGRAMDATA=C:\ProgramData
PROGRAMFILES=C:\Program Files
PROGRAMFILES(X86)=C:\Program Files (x86)
PROGRAMW6432=C:\Program Files
PROJ_LIB=C:\Users\iking\anaconda3\Library\share\proj
PROMPT=(base) $P$G
PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SETVARS_COMPLETED=1
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINDOWS
TEMP=C:\Users\iking\AppData\Local\Temp
TMP=C:\Users\iking\AppData\Local\Temp
UCRTVersion=10.0.19041.0
UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\
USERDOMAIN=RMALEG
USERDOMAIN_ROAMINGPROFILE=RMALEG
USERNAME=iking
USERPROFILE=C:\Users\iking
VCIDEInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\
VCToolsInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\
VCToolsRedistDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.29.30133\
VCToolsVersion=14.29.30133
VisualStudioVersion=16.0
VS160COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\
VS2019INSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
VSCMD_ARG_app_plat=Desktop
VSCMD_ARG_HOST_ARCH=x64
VSCMD_ARG_TGT_ARCH=x64
VSCMD_START_DIR=C:\Users\iking\test
VSCMD_VER=16.11.20
VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\
VTUNE_PROFILER_2022_DIR=C:\Program Files (x86)\Intel\oneAPI\vtune\2022.4.0
WINDIR=C:\WINDOWS
WindowsLibPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0
WindowsSdkBinPath=C:\Program Files (x86)\Windows Kits\10\bin\
WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\
WindowsSDKLibVersion=10.0.19041.0\
WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\
WindowsSDKVersion=10.0.19041.0\
WINTER=c:\wint
ZES_ENABLE_SYSMAN=1
CONDA_PREFIX=C:\Users\iking\anaconda3
CONDA_ROOT=C:\Users\iking\anaconda3
__devinit_path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\devinit\devinit.exe
__DOTNET_ADD_64BIT=1
__DOTNET_PREFERRED_BITNESS=64
__MS_VC_INSTALL_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\
__VSCMD_PREINIT_PATH=C:\Users\iking\anaconda3;C:\Users\iking\anaconda3\Library\mingw-w64\bin;C:\Users\iking\anaconda3\Library\usr\bin;C:\Users\iking\anaconda3\Library\bin;C:\Users\iking\anaconda3\Scripts;C:\Users\iking\anaconda3\bin;C:\Users\iking\anaconda3\condabin;C:\Users\iking\anaconda3;C:\Users\iking\anaconda3\Library\mingw-w64\bin;C:\Users\iking\anaconda3\Library\usr\bin;C:\Users\iking\anaconda3\Library\bin;C:\Users\iking\anaconda3\Scripts;C:\Program Files\Eclipse Adoptium\jdk-17.0.5.8-hotspot\bin;C:\Program Files (x86)\Intel\oneAPI\tbb\latest\redist\intel64\vc_mt;C:\Program Files (x86)\Intel\oneAPI\tbb\latest\redist\ia32\vc_mt;C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\intel64_win\compiler;C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\ia32_win\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\libfabric\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\libfabric\bin\utils;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\ia32;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64;C:\Program Files (x86)\Common Files\Intel\Shared Libraries;c:\wint\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Common Files\Acronis\SnapAPI;C:\Program Files (x86)\Common Files\Acronis\VirtualFile;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64;C:\Program Files (x86)\Common Files\Acronis\FileProtector;C:\Program Files (x86)\Common Files\Acronis\FileProtector64;C:\Users\iking\AppData\Local\Microsoft\WindowsApps;.
__VSCMD_script_err_count=0

(base) C:\Users\iking\test>ifort
'ifort' is not recognized as an internal or external command,
operable program or batch file.

:: initializing oneAPI environment...
Initializing Visual Studio command-line environment...
Visual Studio version 16.11.20 environment configured.
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\"
Visual Studio command-line environment initialized for: 'x64'
: advisor -- latest
: compiler -- latest
: dal -- latest
: debugger -- latest
: dev-utilities -- latest
: dnnl -- latest
: dpcpp-ct -- latest
: dpl -- latest
: inspector -- latest
: intelpython -- latest
: ipp -- latest
: ippcp -- latest
: itac -- latest
: mkl -- latest
: mpi -- latest
: tbb -- latest
: vpl -- latest
: vtune -- latest
:: oneAPI environment initialized ::

C:\Program Files (x86)\Intel\oneAPI>ifort
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

 

 

 

 

0 Kudos
Ian_K_
New Contributor I
2,465 Views

another try to attach files

0 Kudos
mecej4
Honored Contributor III
2,436 Views

I am not sure whether the following suggestion will help, but trying it requires almost no effort.

 

Instead of running a copy of the Intel Fortran setvars.bat file, run the original batch file using its full path and provide to it the two command line options "intel64" and "vsnnnn" with "nnnn" replaced by the year that pertains to your version of Visual Studio.

0 Kudos
JohnNichols
Valued Contributor III
2,410 Views

https://numpy.org/doc/stable/f2py/windows/intel.html 

This guide provides the method, I would make sure you can get this working first - following their exact steps, before you move onto harder stuff.  They list the current problems with Intel, interesting really. 

You do not need to plonk down all of the output.  

 

0 Kudos
IanH
Honored Contributor II
2,393 Views

The python traceback suggests that it is getting confused by whatever version string the compiler executable is returning.  The layout of version strings does change from time to time.

Running a test here with numpy 1.20.3 on python 3.9.5 (and not the oneapi distribution of python - I don't have that installed), I can see that the python script is fragile - it is confused by spaces in installation paths and target file paths.  But the version string is being extracted correctly.

What are your python debugging skills like?  It would be handy to know the contents of the "output" variable in the faulting call to re.search. 

 

0 Kudos
Ian_K_
New Contributor I
2,358 Views

First, thank you to all three of you (Mercej4,John Nichols and IanH) who responded.  I now seem to have a viable process.

1   Create a CMD from Anaconda 

2   As suggested: Run SETVARS.BAT with the full path "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"

3   Execute Python as installed by Anaconda with the full path.
      C:\Users\iking\anaconda3\python -m numpy.f2py -c fib1.f -m fib1

 

It thus appears that it is Intel's Python that is the culprit.

I should note that using  the ONEAPI for the CMD or a simple setup from the start box then the full path for Python failed immediately due to missing dlls.

0 Kudos
IanH
Honored Contributor II
2,334 Views

@Ian_K_ wrote:

It thus appears that it is Intel's Python that is the culprit.

I should note that using  the ONEAPI for the CMD or a simple setup from the start box then the full path for Python failed immediately due to missing dlls.


Using f2py works for me on a different machine that has (and also uses) the intel python distribution (2023.1), so I suspect the culprit is something to do with your particular set-up.

I don't follow your last sentence, but as a general statement - environments need to be configured appropriately for the tools that you are running in them.

Ian_K_
New Contributor I
2,244 Views

I have now come to more or less understand the issue, which I suspect is related to my configuration either of FORTRAN or ANACONDA

 

I can get at f2py by using the anaconda CMD structure and then setting up a ONEAPI environment and then finally accessing Python through a full path to the Anaconda version of Python to avoid the Intel Python.

The ONEAPI  CMD command structure will fail because any attempt to execute Python requires the Anaconda environment ( something I have to work on).

In a sense this is my accepted solution, and it is a combination of the comments of all who responded.

Thanks to all

 

Reply