在 Ubuntu 10.04 LTS 上从 Fortran 源创建 Python C 模块

发布于 2024-08-31 04:03:00 字数 8960 浏览 9 评论 0原文

在我从事的一个项目中,我们使用使用 f2py 从 Fortran 编译的 Python C 模块。我在 Windows 7 32 位(使用 mingw32)和在 32 位 Linux 上构建的服务器上构建它没有任何问题。 但我最近在我用于开发的笔记本电脑上安装了 Ubuntu 10.04 LTS 64 位,当我构建它时,我收到很多警告(即使我显然已经安装了所有 gcc/fortran 库/编译器),但它确实完成构建。然而,当我尝试在应用程序中使用内置模块时,大多数模块似乎运行良好,但随后崩溃并出现错误:

* glibc 检测到 * /home/botondus/Envs/gasit/bin/python: free(): 无效的下一个大小(快速): 0x0000000006a44760 ***

运行时出现警告 f2py -c -m module_name ./fortran/source.f90

customize UnixCCompiler
customize UnixCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Found executable /usr/bin/f77
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize LaheyFCompiler
Could not locate executable lf95
customize PGroupFCompiler
Could not locate executable pgf90
Could not locate executable pgf77
customize AbsoftFCompiler
Could not locate executable f90
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
customize NAGFCompiler
Found executable /usr/bin/f95
customize VastFCompiler
customize GnuFCompiler
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
customize CompaqFCompiler
Could not locate executable fort
customize IntelItaniumFCompiler
Could not locate executable efort
Could not locate executable efc
customize IntelEM64TFCompiler
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext

我尝试通过安装 gfortran multilib 软件包并使用 -m32 选项运行 f2py 来构建 32 位版本(但没有成功):

f2py -c -m module_name ./fortran/source.f90 --f77flags="-m32" --f90flags="-m32"

关于我可以尝试构建 32 位版本或正确构建 64 位版本的任何建议?

编辑:看起来它在子例程结束时崩溃了。 “写入”执行得很好......这很奇怪。

     write(6,*)'Eh=',Eh

end subroutine calcolo_involucro

完整的回溯非常长,我不确定它是否有任何帮助,但这里是:

*** glibc detected *** /home/botondus/Envs/gasit/bin/python: free(): invalid next size (fast): 0x0000000007884690 ***
======= Backtrace: =========
/lib/libc.so.6(+0x775b6)[0x7fe24f8f05b6]
/lib/libc.so.6(cfree+0x73)[0x7fe24f8f6e53]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x4183c)[0x7fe24a18183c]
/home/botondus/Envs/gasit/bin/python[0x46a50d]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x4fbd8)[0x7fe24a18fbd8]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x5aded)[0x7fe24a19aded]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x516e)[0x4a7c5e]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x5a60)[0x4a8550]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python[0x537620]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python[0x427dff]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python[0x477bff]
/home/botondus/Envs/gasit/bin/python[0x46f47f]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4888)[0x4a7378]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4d19)[0x4a7809]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4d19)[0x4a7809]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python[0x537620]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python(PyEval_CallObjectWithKeywords+0x43)[0x4a1b03]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x2ee94)[0x7fe24a16ee94]
/home/botondus/Envs/gasit/bin/python(_PyObject_Str+0x61)[0x454a81]
/home/botondus/Envs/gasit/bin/python(PyObject_Str+0xa)[0x454b3a]
/home/botondus/Envs/gasit/bin/python[0x461ad3]
/home/botondus/Envs/gasit/bin/python[0x46f3b3]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4888)[0x4a7378]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4d19)[0x4a7809]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x5a60)[0x4a8550]
======= Memory map: ========
00400000-0061c000 r-xp 00000000 08:05 399145                             /home/botondus/Envs/gasit/bin/python
0081b000-0081c000 r--p 0021b000 08:05 399145                             /home/botondus/Envs/gasit/bin/python
0081c000-0087e000 rw-p 0021c000 08:05 399145                             /home/botondus/Envs/gasit/bin/python
0087e000-0088d000 rw-p 00000000 00:00 0 
01877000-07a83000 rw-p 00000000 00:00 0                                  [heap]
7fe240000000-7fe240021000 rw-p 00000000 00:00 0 
7fe240021000-7fe244000000 ---p 00000000 00:00 0 
7fe247631000-7fe2476b1000 r-xp 00000000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2476b1000-7fe2478b1000 ---p 00080000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2478b1000-7fe2478b6000 r--p 00080000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2478b6000-7fe2478b7000 rw-p 00085000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2478b7000-7fe2478bb000 r-xp 00000000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe2478bb000-7fe247aba000 ---p 00004000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe247aba000-7fe247abb000 r--p 00003000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe247abb000-7fe247abc000 rw-p 00004000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe247abc000-7fe247abf000 r-xp 00000000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247abf000-7fe247cbf000 ---p 00003000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247cbf000-7fe247cc0000 r--p 00003000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247cc0000-7fe247cc1000 rw-p 00004000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247cc1000-7fe247cc5000 r-xp 00000000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247cc5000-7fe247ec4000 ---p 00004000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247ec4000-7fe247ec5000 r--p 00003000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247ec5000-7fe247ec6000 rw-p 00004000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247ec6000-7fe24800c000 r-xp 00000000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe24800c000-7fe24820b000 ---p 00146000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe24820b000-7fe248213000 r--p 00145000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe248213000-7fe248215000 rw-p 0014d000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe248215000-7fe248216000 rw-p 00000000 00:00 0 
7fe248216000-7fe248229000 r-xp 00000000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe248229000-7fe248428000 ---p 00013000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe248428000-7fe248429000 r--p 00012000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe248429000-7fe24842a000 rw-p 00013000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe24842a000-7fe248464000 r-xp 00000000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248464000-7fe248663000 ---p 0003a000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248663000-7fe248664000 r--p 00039000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248664000-7fe248665000 rw-p 0003a000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248665000-7fe24876e000 r-xp 00000000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe24876e000-7fe24896d000 ---p 00109000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe24896d000-7fe24896e000 r--p 00108000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe24896e000-7fe248999000 rw-p 00109000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe248999000-7fe2489a7000 rw-p 00000000 00:00 0 
7fe2489a7000-7fe2489bd000 r-xp 00000000 08:03 132934                     /lib/libgcc_s.so.1

In a project I work on we use a Python C module compiled from Fortran with f2py. I've had no issues building it on Windows 7 32bit (using mingw32) and on the servers it's built on 32bit Linux.
But I've recently installed Ubuntu 10.04 LTS 64bit on my laptop that I use for development, and when I build it I get a lot of warnings (even though I've apparently installed all gcc/fortran libraries/compilers), but it does finish the build. However when I try to use the built module in the application, most of it seems to run well but then it crashes with an error:

* glibc detected * /home/botondus/Envs/gasit/bin/python: free(): invalid next size (fast): 0x0000000006a44760 ***

Warnings on running f2py -c -m module_name ./fortran/source.f90

customize UnixCCompiler
customize UnixCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Found executable /usr/bin/f77
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize LaheyFCompiler
Could not locate executable lf95
customize PGroupFCompiler
Could not locate executable pgf90
Could not locate executable pgf77
customize AbsoftFCompiler
Could not locate executable f90
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
customize NAGFCompiler
Found executable /usr/bin/f95
customize VastFCompiler
customize GnuFCompiler
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
customize CompaqFCompiler
Could not locate executable fort
customize IntelItaniumFCompiler
Could not locate executable efort
Could not locate executable efc
customize IntelEM64TFCompiler
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext

I have tried building a 32bit version by installing the gfortran multilib packages and running f2py with -m32 option (but with no success):

f2py -c -m module_name ./fortran/source.f90 --f77flags="-m32" --f90flags="-m32"

Any suggestions on what I could try to either build 32bit version or correctly build the 64bit version?

Edit: It looks like it crashes right at the end of a subroutine. The 'write' executes fine... which is strange.

     write(6,*)'Eh=',Eh

end subroutine calcolo_involucro

The full backtrace is very long and I'm not sure if it's any help, but here it is:

*** glibc detected *** /home/botondus/Envs/gasit/bin/python: free(): invalid next size (fast): 0x0000000007884690 ***
======= Backtrace: =========
/lib/libc.so.6(+0x775b6)[0x7fe24f8f05b6]
/lib/libc.so.6(cfree+0x73)[0x7fe24f8f6e53]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x4183c)[0x7fe24a18183c]
/home/botondus/Envs/gasit/bin/python[0x46a50d]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x4fbd8)[0x7fe24a18fbd8]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x5aded)[0x7fe24a19aded]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x516e)[0x4a7c5e]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x5a60)[0x4a8550]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python[0x537620]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python[0x427dff]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python[0x477bff]
/home/botondus/Envs/gasit/bin/python[0x46f47f]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4888)[0x4a7378]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4d19)[0x4a7809]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4d19)[0x4a7809]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python[0x537620]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python(PyEval_CallObjectWithKeywords+0x43)[0x4a1b03]
/usr/local/lib/python2.6/dist-packages/numpy/core/multiarray.so(+0x2ee94)[0x7fe24a16ee94]
/home/botondus/Envs/gasit/bin/python(_PyObject_Str+0x61)[0x454a81]
/home/botondus/Envs/gasit/bin/python(PyObject_Str+0xa)[0x454b3a]
/home/botondus/Envs/gasit/bin/python[0x461ad3]
/home/botondus/Envs/gasit/bin/python[0x46f3b3]
/home/botondus/Envs/gasit/bin/python(PyObject_Call+0x47)[0x41f0c7]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4888)[0x4a7378]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalCodeEx+0x911)[0x4a9671]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x4d19)[0x4a7809]
/home/botondus/Envs/gasit/bin/python(PyEval_EvalFrameEx+0x5a60)[0x4a8550]
======= Memory map: ========
00400000-0061c000 r-xp 00000000 08:05 399145                             /home/botondus/Envs/gasit/bin/python
0081b000-0081c000 r--p 0021b000 08:05 399145                             /home/botondus/Envs/gasit/bin/python
0081c000-0087e000 rw-p 0021c000 08:05 399145                             /home/botondus/Envs/gasit/bin/python
0087e000-0088d000 rw-p 00000000 00:00 0 
01877000-07a83000 rw-p 00000000 00:00 0                                  [heap]
7fe240000000-7fe240021000 rw-p 00000000 00:00 0 
7fe240021000-7fe244000000 ---p 00000000 00:00 0 
7fe247631000-7fe2476b1000 r-xp 00000000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2476b1000-7fe2478b1000 ---p 00080000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2478b1000-7fe2478b6000 r--p 00080000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2478b6000-7fe2478b7000 rw-p 00085000 08:03 140646                     /usr/lib/libfreetype.so.6.3.22
7fe2478b7000-7fe2478bb000 r-xp 00000000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe2478bb000-7fe247aba000 ---p 00004000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe247aba000-7fe247abb000 r--p 00003000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe247abb000-7fe247abc000 rw-p 00004000 08:03 263882                     /usr/lib/python2.6/dist-packages/PIL/_imagingft.so
7fe247abc000-7fe247abf000 r-xp 00000000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247abf000-7fe247cbf000 ---p 00003000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247cbf000-7fe247cc0000 r--p 00003000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247cc0000-7fe247cc1000 rw-p 00004000 08:03 266773                     /usr/lib/python2.6/lib-dynload/_bytesio.so
7fe247cc1000-7fe247cc5000 r-xp 00000000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247cc5000-7fe247ec4000 ---p 00004000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247ec4000-7fe247ec5000 r--p 00003000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247ec5000-7fe247ec6000 rw-p 00004000 08:03 266786                     /usr/lib/python2.6/lib-dynload/_fileio.so
7fe247ec6000-7fe24800c000 r-xp 00000000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe24800c000-7fe24820b000 ---p 00146000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe24820b000-7fe248213000 r--p 00145000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe248213000-7fe248215000 rw-p 0014d000 08:03 141358                     /usr/lib/libxml2.so.2.7.6
7fe248215000-7fe248216000 rw-p 00000000 00:00 0 
7fe248216000-7fe248229000 r-xp 00000000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe248229000-7fe248428000 ---p 00013000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe248428000-7fe248429000 r--p 00012000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe248429000-7fe24842a000 rw-p 00013000 08:03 140632                     /usr/lib/libexslt.so.0.8.15
7fe24842a000-7fe248464000 r-xp 00000000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248464000-7fe248663000 ---p 0003a000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248663000-7fe248664000 r--p 00039000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248664000-7fe248665000 rw-p 0003a000 08:03 141360                     /usr/lib/libxslt.so.1.1.26
7fe248665000-7fe24876e000 r-xp 00000000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe24876e000-7fe24896d000 ---p 00109000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe24896d000-7fe24896e000 r--p 00108000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe24896e000-7fe248999000 rw-p 00109000 08:03 534240                     /usr/local/lib/python2.6/dist-packages/lxml/etree.so
7fe248999000-7fe2489a7000 rw-p 00000000 00:00 0 
7fe2489a7000-7fe2489bd000 r-xp 00000000 08:03 132934                     /lib/libgcc_s.so.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美胚控场 2024-09-07 04:03:00

幸运的是,设法解决了这个问题。
我似乎没有注意到 Ubuntu 10.04 存储库中的 numpy 软件包版本只有 v1.3.0。我删除了 numpy,然后从源代码构建了 v1.4.1。
之后重新运行 f2py 确实给出了相同的警告,但是使用该模块不会再产生崩溃。

Fortunately managed to solve this.
It seems I didn't notice that the numpy package version in the repositories for Ubuntu 10.04 are only v1.3.0. I removed numpy, then built v1.4.1 from source.
After that re-running f2py did give the same warnings, however using the module does not produce the crash anymore.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文