[SciPy-Dev] f2py, the fortran integer type, and npy_intp

Charles R Harris charlesr.harris@gmail....
Sat Jul 10 12:31:44 CDT 2010


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 fortran
integers? Should we be using npy_intp for array dimensions at all? Is there
any transparent way to have 64 bit support?

Example code

(from scipy/interpolate/src/__fitpack.h)

void
SPLDER(double*,int*,double*,int*,int*,double*,double*,int*,int*,double*,int*);
                                                           ^^^^
void SPLEV(double*,int*,double*,int*,double*,double*,int*,int*,int*);
                                                          ^^^^

static char doc_spl_[] = " [y,ier] = _spl_(x,nu,t,c,k,e)";
static PyObject *fitpack_spl_(PyObject *dummy, PyObject *args)
{
    int n, nu, ier, k, e=0;
    npy_intp m;

    ...

    if (nu) {
        SPLDER(t, &n, c, &k, &nu, x, y, &m, &e, wrk, &ier);
                                        ^^
    }
    else {
        SPLEV(t, &n, c, &k, x, y, &m, &e, &ier);

^^
    }
 ...
}

(from scipy/interpolate/src/fitpack.pyf

     subroutine splev(t,n,c,k,x,y,m,e,ier)
       ! y = splev(t,c,k,x,[e])
       real*8 dimension(n),intent(in) :: t
       integer intent(hide),depend(t) :: n=len(t)
       real*8 dimension(n),depend(n,k),check(len(c)==n),intent(in) :: c
       integer :: k
       real*8 dimension(m),intent(in) :: x
       real*8 dimension(m),depend(m),intent(out) :: y
       integer intent(hide),depend(x) :: m=len(x)
       integer check(0<=e && e<=2) :: e=0
       integer intent(hide) :: ier
     end subroutine splev

(from scipy/interpolate/fitpack/splev.f)

      subroutine splev(t,n,c,k,x,y,m,e,ier)

...

c  ..scalar arguments..
      integer n, k, m, e, ier

...


Note also that the checks generated by f2py -- and they are generated --
don't seem to work.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20100710/fdf0e828/attachment.html 


More information about the SciPy-Dev mailing list