我曾经很久以前用f2py编译FORTRAN程序。但是今天我没能重新编译它。我想原因并不是指向正确的编译器。上次,我的机器很干净,只安装了gnu作为唯一的编译器,而今天它有来自visualstudio2012
Parallel Studio XE 2013
MinGW32-xy
Rtools
的太多编译。一般来说,我确信代码是正确的。那么有人可以给我一些关于如何使用f2py的论据的建议吗?以下是我的命令:
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
稍后,根据此post我将VS90COMNTOOLS =%VS110COMNTOOLS%添加到我的用户环境中,但收到以下错误。我真的很感谢你的帮助!
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
第二种编译方法有效,尽管编译过程会产生错误。我不确定我是否总能忽略这些错误?