我正在尝试为以下FORTRAN模块构建扩展模块:
module mod
integer i
integer :: x(4)
real, dimension(2,3) :: a
real, allocatable, dimension(:,:) :: b
contains
subroutine foo
integer k
print*, "i=",i
print*, "x=[",x,"]"
print*, "a=["
print*, "[",a(1,1),",",a(1,2),",",a(1,3),"]"
print*, "[",a(2,1),",",a(2,2),",",a(2,3),"]"
print*, "]"
print*, "Setting a(1,2)=a(1,2)+3"
a(1,2) = a(1,2)+3
end subroutine foo
end module mod
我在Windows Powershell中运行了以下命令:
f2py -c -m moddata moddata.f90
但是我得到以下输出,但有很多错误:
call "C:\Anaconda2\Scripts\\..\python.exe" "C:\Anaconda2\Scripts\\f2py.py" -c -m moddata moddata.f90
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 "moddata" sources
f2py options: []
f2py:> c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c
creating c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
Reading fortran codes...
Reading file 'moddata.f90' (format:free)
Post-processing...
Block: moddata
Block: mod
Block: foo
Post-processing (stage 2)...
Block: moddata
Block: unknown_interface
Block: mod
Block: foo
Building modules...
Building module "moddata"...
Constructing F90 module support for "mod"...
Variables: i x b a
getarrdims:warning: assumed shape array, using 0 instead of ':'
getarrdims:warning: assumed shape array, using 0 instead of ':'
Constructing wrapper function "mod.foo"...
foo()
Wrote C/API module "moddata" to file "c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c"
Fortran 90 wrappers are saved to "c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddata-f2pywrappers2.f90"
adding 'c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7' to include_dirs.
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
adding 'c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddata-f2pywrappers2.f90' to sources.
build_src: building npy-pkg config files
running build_ext
Cannot build msvcr library: "msvcr90d.dll" not found
customize Mingw32CCompiler
customize Mingw32CCompiler 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
Found executable C:\cygwin64\bin\DF.exe
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\cygwin64\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'moddata' extension
compiling C sources
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c -o c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.o
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyport.h:171:33: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Py_uintptr_t'
typedef unsigned PY_LONG_LONG Py_uintptr_t;
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:8:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\include/pyport.h:172:9: note: in expansion of macro 'PY_LONG_LONG'
typedef PY_LONG_LONG Py_intptr_t;
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyport.h:895:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
^~~~~
In file included from C:\Anaconda2\include/Python.h:86:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/intobject.h:46:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyInt_AsUnsignedLongLongMask'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:88:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/longobject.h:50:1: warning: parameter names (without types) in function declaration
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
^~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\include/pyport.h:802:34: note: in definition of macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) RTYPE
^~~~~
C:\Anaconda2\include/longobject.h:52:12: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:88:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/longobject.h:53:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyLong_AsUnsignedLongLong'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~
C:\Anaconda2\include/longobject.h:54:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyLong_AsUnsignedLongLongMask'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\include/pyport.h:802:34: note: in definition of macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) RTYPE
^~~~~
C:\Anaconda2\include/longobject.h:55:12: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
^~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:221:9: error: unknown type name 'Py_uintptr_t'
typedef Py_uintptr_t npy_uintp;
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:8:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:311:9: note: in expansion of macro 'PY_LONG_LONG'
typedef PY_LONG_LONG npy_longlong;
^~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:312:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'npy_ulonglong'
typedef unsigned PY_LONG_LONG npy_ulonglong;
^~~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:614:17: error: unknown type name 'npy_ulonglong'
typedef npy_ulonglong npy_uint64;
^~~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:1809:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^~~~~~~
error: Command "gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c -o c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.o" failed with exit status 1
我的FORTRAN编译器是GNU Fortran(GCC)6.4.0。 我的C编译器是gcc(GCC)6.4.0。 我正在使用Numpy V1.13.3。 我正在使用f2py V2。
能否让我知道如何解决错误?
谢谢!