Reputation: 9
I have a number of fortran codes that I need to run through python. As a first step, I'm trying a simple subroutine:
subroutine multiply(a,b,n,c)
double precision, intent(in) :: a(n), b(n)
integer, intent(in) :: n
double precision(out) :: c(n)
integer :: i
do i=1,n
c(i)=a(i)*b(i)
end do
end subroutine multiply
Then I'm trying to compile using f2py.py:
f2py -c --fcompiler=gnu95 --compiler=mingw32 -m foo mult.f
I get an error when looking for python27.dll: File format not recognized. here's the output from the compiler:
C:\Users\Richard\Documents\Code\fortran>f2py -c --fcompiler=gnu95 --compiler=mingw32 -m foo mult.f
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "foo" sources
f2py options: []
f2py:> c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7\foomodule.c
creating c:\users\richard\appdata\local\temp\tmpxwldfw
creating c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7
Reading fortran codes...
Reading file 'mult.f' (format:fix,strict)
Post-processing...
Block: foo
Block: multiply
Post-processing (stage 2)...
Building modules...
Building module "foo"...
Constructing wrapper function "multiply"...
multiply(a,b,c,[n])
Wrote C/API module "foo" to file "c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7\foomodule.c"
adding 'c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7' to include_dirs.
copying C:\Users\Richard\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7
copying C:\Users\Richard\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\richard\appdata\local\temp\tmpxwldfw\src.win-amd64-2.7
build_src: building npy-pkg config files
running build_ext
Looking for python27.dll
Building import library (arch=AMD64): "C:\Users\Richard\AppData\Local\Enthought\Canopy\User\libs\libpython27.a" (from C:\Users\Richard\AppData\Local\Enthought\Canopy\User\python27.dll)
**objdump.exe: C:\Users\Richard\AppData\Local\Enthought\Canopy\User\python27.dll: File format not recognized**
Traceback (most recent call last):
File "C:\Users\Richard\AppData\Local\Enthought\Canopy\User\Scripts\f2py-script.py", line 24, in <module> main()
..removed details of stack trace, finally ending with
File "C:\Users\Richard\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 399, in _build_import_library_amd64 generate_def(dll_file, def_file)
File "C:\Users\Richard\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 278, in generate_def raise ValueError("Symbol table not found")
ValueError: Symbol table not found
I'm really not sure what's causing this. Any suggestions would be greatly appreciated.
Upvotes: 1
Views: 1873
Reputation: 1271
The error is the same as the one mentioned here, "Method 3". See the OP's solution there
Compile fortran module with f2py and Python 3.6 on Windows 10
Upvotes: 0