[Numpy-discussion] Possible bug -- importing numpy before f2py compiled module gives seg fault

Kurt Smith kwmsmith@gmail....
Thu Jul 26 14:15:50 CDT 2007


Hello -

I've come up with the following test case to illustrate my problem:

file empty.f:
          subroutine empty(arr, nx,ny )
          implicit none
          integer, intent(in) :: nx,ny
          real, dimension(nx,ny), intent(out) :: arr
          print *, "in empty."
          arr = 1.0e0
          end subroutine empty

using the following to compile:
f2py -c -m empty -lSystemStubs --opt=-O3 --fcompiler=ibm --f90exec=/
opt/ibmcmp/xlf/8.1/bin/xlf90 --f90flags=-O3 empty.f

Builds empty.so just fine.

Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
>>> from empty import empty as myempty
>>> from numpy import * # for illustration purposes.
>>> myempty(1,1)
 in empty.
array([[ 1.]], dtype=float32)
>>>

But when I import numpy first, I get the following:

Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
>>> from numpy import *
>>> from empty import empty as myempty
>>> myempty(1,1)
Segmentation fault
$

Platform: Mac OS X, 10.4.10, using ibm-xlfortran v. 8.1.

$ f2py -v
2_3844


More information about the Numpy-discussion mailing list