[Numpy-discussion] f2py-users list not working

George Nurser gnurser at googlemail.com
Wed Nov 4 09:38:40 EST 2009


Fortran can accept preprocessor directives, but f2py cannot.
You first need to preprocess a .F (or .F90) file to create a .f (or
.f90) file which you then pass to f2py
The way I preprocess the .F file is to have statements like
int int*INTSIZE :: i,j,k

So preprocess file.F e.g. in gfortran with
gfortran -E -DINTSIZE=8 file.F  -o outdir/file.f

The outdir is necessary in a case-insensitive file system (like
default mac OSX) to prevent the .f files overwriting the .F file.
Alternatively, it may be possible to use some other suffix than .f,
but I've not tried that.

Then f2py file.f

George Nurser.

> ----- Original message -----
> Subject: writing module for 32/64 bit
> From: Robin <robince at gmail.com>
> To: f2py-users at cens.ioc.ee
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> Hi,
>
> I would like to write some subroutines in fortran involving integers
> and distribute them in a small package.  Users might be on 32 bit or
> 64 bit.
>
> Is there an easy or recommended way to approach this? Ideally I would
> like to work with the native integer type - but if I use 'integer' in
> fortran it is always 32 bit and f2py converts input aways when numpy
> is 64 bit. If I use integer*8 in the code then its fine for 64 bit,
> but on 32 bit platforms, both f2py has to convert and its not the
> native integer size.
>
> What I (think) I'd like to do is be able to use the native platform
> integer type, like numpy does, and then not worry about. I found there
> are options like -fdefault-int-8 for gfortran, but when I add that
> stuff breaks (bus error) since I guess f2py doesn't know about it and
> is converting and passing 32 bits anyway.
>
> Is there any way around this, or do I need to maintain 2 different
> versions with different fortran code for 32bit/64bit? Or is it
> possible to acheive something like this with preprossor #ifdefs? (not
> sure how this works with fortran, or if f2py would be aware of it).
>
> Cheers
>
> Robin
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list