[f2py] f2py, C, and multidimensional arrays.

Daniel Welling <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Greetings.  I am new to F2py and am trying to use it to wrap some simple C
functions.  I've had success with scalars and vectors, but cannot get any
multidimensional arrays to work correctly.  An example:

/* bar.c */
void bar(int n, int m, double **x) {
  int i, j;
  for (i=0; i<n; i++)
    for (j=0; j<m; j++)
      printf("Position %i, %i = %.3f\n", i, j, x[i][j]);
}

! wrapper m.pyf
python module m
interface
  subroutine bar(n, m, x)
    intent(c) bar
    intent(c)
    integer intent() :: n
    integer intent() :: m
    double precision intent(in) :: x(n,m)
  end subroutine bar
end interface
end python module m

Build shared object:
$ f2py2.5 foo.c foo.pyf -c

Try to run it:
>>>import m
>>>import numpy as np
>>>dog = np.zeros((0,0))
>>>m.bar(dog)
Bus error

And that's it.  It drops me out of ipython/python shell and back to the bash
prompt.  I cannot find any examples similar to this, nor any mailing list
threads on this topic.  Does anyone have any experience with such examples?

Thanks for your help.

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.