[SciPy-Dev] f2py, the fortran integer type, and npy_intp
Charles R Harris
Sat Jul 10 15:49:01 CDT 2010
On Sat, Jul 10, 2010 at 12:30 PM, Kurt Smith <email@example.com> wrote:
> On Sat, Jul 10, 2010 at 12:31 PM, Charles R Harris
> <firstname.lastname@example.org> wrote:
> > I note that some c programs try to call f2py generated fortran interfaces
> > using the npy_intp type for the array dimension. There are two problems
> > here, first the prototype for the generated wrapper uses int causing
> > compiler warnings on a 64 bit os, and second, the fortran subroutines
> > themselves use integer types. So some questions. What precision are
> > integers? Should we be using npy_intp for array dimensions at all? Is
> > any transparent way to have 64 bit support?
> I can comment on some of the above (not the f2py-specific bits, though).
> 1) "What precision are fortran integers?"
> According to a somewhat authoritative interlanguage programming site
> , a fortran 'integer' corresponds to a C 'int'. This can be relied
> upon, but other fortran type declarations cannot (e.g. 'integer*8' !=
> a C 'long' on all platforms, with all compilers). If sizeof(npy_intp)
> == sizeof(int), then everything will be fine, but it's a near
> certainty there are platforms where this doesn't hold, and may lead to
> problems if array sizes are large.
Looks like most FORTRANs allow the size of integer to be set by a
But hooking it up to work with f2py and C looks like a significant problem
involving the build infrastructure among other things. I think for the time
being we should just avoid using npy_intp as a type passed to FORTRAN
subroutines. This will limit the size of one dimensional arrays that can be
passed to the subroutines to 2GB but I don't see any easy way around it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-Dev