[SciPy-User] f2py segfault

Dag Sverre Seljebotn dagss@student.matnat.uio...
Sun Jan 17 15:28:27 CST 2010


Juan wrote:
> Hi, I don't know if this is the right place (if it is not, please point me in
> the right direction).
> I am using f2py with some own programs and I am going insane with a segmentation
> fault. It is probably a problem in my code but I'd like to know if someone has
> any hint
> to give me since I've been trying different things for two days already.
>
> I've got a few routines in fortran with in/out arrays. When I call one of the
> routines it works well. The second routine I call crashes the program. I've been
> changing routines and it seems that it does not matter with routines I use.
>
> Basically, the fortran routines have the signature:
>
> subroutine sub1(y, Np, Nt)
>   integer(4), intent(IN) :: Np
>   integer(4), intent(IN) :: Nt
>   real(8), intent(INOUT), dimension(6*Np, Nt) :: y
>
> and I call them from python as:
>
> import mymod
> r= np.zeros((Ncoord,Ntraj),dtype=np.float64, order='Fortran')
> mymod.sub1(r)
>
> I am using python 2.6. Probably the statement of the problem is to vague to get
> an answer. But I'll settle for just some ideas on how to proceed. I've used the
> option for debugging: --debug-capi
> but it does not provide with more information. Only tells me that it checks for
> the array and segfaults (before analyzing the integer arguments Np, Nt)
 From what little I know of f2py the "6*Np" seems like the problematic 
part. If f2py isn't smart enough to take the array shape and divide by 6 
(which, in general, requires solving a symbolic equation, and somehow I 
doubt f2py is that smart, though perhaps it deals with simple things 
like this explicitly? *shrug*), then Np is going to passed as a too big 
number (try to print out Np from your Fortran program to confirm...).

Dag Sverre



More information about the SciPy-User mailing list