Compiling a FORTRAN Module using f2py

2k views Asked by At

I used to compile a FORTRAN program with f2py long time ago. But when I failed to re-compile it today. I guess the reason is not pointing to the right compiler. Last time, my machine was clean only has gnu installed as the only compiler, while today it has too many compiles from visualstudio2012 Parallel Studio XE 2013 MinGW32-xy Rtools. In general, I am sure the code is correct. So could anyone give me some suggestions on how the arguments to use f2py? Below is my command:

python C:\Python27\Scripts\f2py.py --fcompiler=gnu95 -c -m geneeb geneec2_edit_unix.for

build_src: building npy-pkg config files
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable c:\Rtools\gcc-4.6.3\bin\gfortran.exe
Found executable c:\Rtools\gcc-4.6.3\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'geneeb' extension
compiling C sources
error: Unable to find vcvarsall.bat

Later, based on this post I added VS90COMNTOOLS=%VS110COMNTOOLS% to my user environment, but got the following error. I really appreciate your help!

I:\Dropbox\REST>python C:\Python27\Scripts\f2py.py --fcompiler=gnu95 -c -m geneec geneec2_edit_unix.for
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 "geneec" sources
f2py options: []
f2py:> c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneecmodule.c
creating c:\users\tao\appdata\local\temp\tmpfjjb_m
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7
Reading fortran codes...
        Reading file 'geneec2_edit_unix.for' (format:fix,strict)
Post-processing...
        Block: geneec
                        Block: geneec2
{}
In: :geneec:geneec2_edit_unix.for:agasae
vars2fortran: No typespec for argument "nasae".
{}
In: :geneec:geneec2_edit_unix.for:agasae
vars2fortran: No typespec for argument "yloc".
{}
In: :geneec:geneec2_edit_unix.for:agasae
vars2fortran: No typespec for argument "pondep".
                        Block: agasae
Post-processing (stage 2)...
Building modules...
        Building module "geneec"...
                Constructing wrapper function "geneec2"...
                  re1,re2,re3,re4,re5,re6,re7,re8 = geneec2(apprat,appnum,apspac,koc,methaf,wetted,method,airflg,ylocen,grnflg,grsize,orcflg,incorp,sol,methap,hydhap,fothap)
                Constructing wrapper function "agasae"...
                  agasae(nasae,yloc,pondep)
        Wrote C/API module "geneec" to file "c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneecmodule.c"
  adding 'c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\fortranobject.c' to sources.
  adding 'c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7' to include_dirs.
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7
build_src: building npy-pkg config files
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize Gnu95FCompiler
Found executable c:\Rtools\gcc-4.6.3\bin\gfortran.exe
Found executable c:\Rtools\gcc-4.6.3\bin\gfortran.exe
customize Gnu95FCompiler using build_ext
building 'geneec' extension
compiling C sources
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m
creating c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7 -IC:\Python27\lib\site-pack
es\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tcc:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneecmodule.c /Foc:\users\tao\appdata\local\temp\tmpfjjb_m\Release\
ers\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneecmodule.obj
Found executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7 -IC:\Python27\lib\site-pack
es\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tcc:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\fortranobject.c /Foc:\users\tao\appdata\local\temp\tmpfjjb_m\Release
sers\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\fortranobject.obj
compiling Fortran sources
Fortran f77 compiler: c:\Rtools\gcc-4.6.3\bin\gfortran.exe -Wall -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: c:\Rtools\gcc-4.6.3\bin\gfortran.exe -Wall -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: c:\Rtools\gcc-4.6.3\bin\gfortran.exe -Wall -ffixed-form -fno-second-underscore -Wall -fno-second-underscore -O3 -funroll-loops
compile options: '-Ic:\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c'
gfortran.exe:f77: geneec2_edit_unix.for
copying c:\rtools\gcc-4.6.3\lib\libgfortran.a -> c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\gfortran.lib
copying c:\rtools\gcc-4.6.3\lib\gcc\i686-w64-mingw32\4.6.3\libgcc.a -> c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\gcc.lib
copying c:\rtools\gcc-4.6.3\i686-w64-mingw32\lib\libmingw32.a -> c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\mingw32.lib
copying c:\rtools\gcc-4.6.3\i686-w64-mingw32\lib\libmingwex.a -> c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\mingwex.lib
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\rtools\gcc-4.6.3\lib /LIBPATH:c:\rtools\gcc-4.6.3\lib\gcc\i686-w64-mingw32\4.6.
/LIBPATH:c:\rtools\gcc-4.6.3\i686-w64-mingw32\lib /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild /LIBPATH:c:\users\tao\appdata\local\temp\tmpfjjb_m\Release /LIBPATH:C:\Python27\lib
/LIBPATH:C:\Python27\PCbuild gfortran.lib gcc.lib mingw32.lib mingwex.lib /EXPORT:initgeneec c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.wi
2-2.7\geneecmodule.obj c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\fortranobject.obj c:\users\tao\appdata\local\temp\tmpfjjb_m\Re
ase\geneec2_edit_unix.o /OUT:.\geneec.pyd /IMPLIB:c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneec.lib /MANIFESTFILE:c:\users\t
\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneec.pyd.manifest
Found executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\link.exe
mt.exe -nologo -manifest c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneec.pyd.manifest -outputresource:.\geneec.pyd;2
Found executable C:\Program Files (x86)\Windows Kits\8.0\bin\x86\mt.exe

c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneec.pyd.manifest : general error c1010070: Failed to load and parse the manifest.
e system cannot find the file specified.
error: Command "mt.exe -nologo -manifest c:\users\tao\appdata\local\temp\tmpfjjb_m\Release\users\tao\appdata\local\temp\tmpfjjb_m\src.win32-2.7\geneec.pyd.manifest -outputresource:.\geneec
yd;2" failed with exit status 31

Update:

The second method of compiling worked, although the compiling process generated errors. I am not sure can I always ignore these errors?

0

There are 0 answers