[Numpy-discussion] Numerical Python and LAPACK on 64-bit machines

Roman Geus geus at inf.ethz.ch
Wed Mar 6 00:51:10 CST 2002

Dear Numerical Python user and developers

I ran into the following problem:

The python application I'm developing uses Numerical Python and other
C modules that call LAPACK. My application runs well on 32bit

When I tried to run the application on a HP-UX 64bit machine the
application produced bus errors. After a long debugging session I
found out that Fortran integers are still 32bit wide on this
machine. Therefore also the HP LAPACK library has to called using
32bit integers. Numerical Python however codes Fortran integers as C
'long int' variables, which are 64bit wide on this machine.

To make my application run on the HP-UX 64bit machine, I had to change
all 'long int' to 'int' variables in Src/lapack_litemodule.c, which
is a rather painful hack (see end of message for an example).

My question is: 

Should Fortran integers not be coded as 'int' instead of 'long int' in
Numerical Python? This way, it would still work on all 32 bit machines
and also on the 64-bit machines I know.

Would this work on all 64-bit machines?

Thanks for your comments/help.

-- Roman Geus

E.g. the lapack_lite_dgetrf() function now looks like this:

static PyObject *lapack_lite_dgetrf(PyObject *self, PyObject *args)
int  lapack_lite_status__;
int m;
int n;
PyObject *a;
int lda;
PyObject *ipiv;
int info;

 int i; 
 int *ipiv_int;
 int ipiv_len;


 ipiv_len = m < n ? m : n;
 ipiv_int = (int *)malloc(ipiv_len * sizeof(int));
 for (i = 0; i < ipiv_len; i ++)
   ipiv_int[i] = LDATA(ipiv)[i];

#if defined(NO_APPEND_FORTRAN)
lapack_lite_status__ = dgetrf(&m,&n,DDATA(a),&lda,ipiv_int,&info);
lapack_lite_status__ = dgetrf_(&m,&n,DDATA(a),&lda,ipiv_int,&info);

 for (i = 0; i < ipiv_len; i ++)
   LDATA(ipiv)[i] = ipiv_int[i];



More information about the Numpy-discussion mailing list