[f2py] f2py with C multidimensional array

Richard Shaw jrs65 at cam.ac.uk
Thu Mar 8 13:04:01 EET 2007


Hello,

I'm trying to use f2py to wrap some C that requires input of some
multi-dimensional arrays, and I'm getting a little stuck!! The function
I'm using has defintion:

int lensmapper(double ** source, double *** deflection, double ** image,
int msx,
               int msy, int mdx, int mdy, double scale, double px_map);

Where source, image are 2d arrays (array of pointers) and deflection is
3d (array of pointers to pointers), and msx etc. are the bounds on the
arrays. My pyf file is included below.

My question is what exactly does f2py pass in? Is it just a flat double
array (eg. [x00, x01, x03, .... x10, x11, x12,....]) or does it have all
the pointers set for proper multidimensional access, such that the above
is valid. At the moment the segfaults I'm getting would seem to indicate
the former. But this isn't entirely clear to me.

Cheers,
Richard



===

python module lensmapper
interface
  subroutine
lensmapper(source,deflection,image,msx,msy,mdx,mdy,scale,px_map)
    intent(c) lensmapper           
    intent(c)                   

    double precision intent(in), dimension(msx,msy)     :: source
    double precision intent(in), dimension(mdx,mdy,2)   :: deflection
    double precision intent(in,out), dimension(msx,msy) :: image

    integer intent(in), depend(source) :: msx = shape(source,0)
    integer intent(in), depend(source) :: msy = shape(source,1)
    integer intent(in), depend(deflection) :: mdx = shape(deflection,0)
    integer intent(in), depend(deflection) :: mdy = shape(deflection,1)


    double precision intent(in) :: scale
    double precision intent(in) :: px_map
                                                 !
  end subroutine lensmapper
end interface
end python module lensmapper




More information about the f2py-users mailing list