[Numpy-discussion] numpy.distutils/f2py: forcing 8-bit reals
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Tue Mar 30 05:01:43 EDT 2010
David Warde-Farley wrote:
> In my setup.py, I have
> from numpy.distutils.misc_util import Configuration
> fflags= '-fdefault-real-8 -ffixed-form'
> config = Configuration(
> f2py_options='--f77flags=\'%s\' --f90flags=\'%s\'' % (fflags,
> However I am still getting stuff returned in 'real' variables as
> dtype=float32. Am I doing something wrong?
Unless f2py is (too) smart, it probably just pass along --f77flags and
--f90flags to the Fortran compiler, but don't use them when creating the
wrapping C Python extension. So, Fortran uses real(8) and the type in C
is "float" -- and what NumPy ends up seeing is float32.
Unless you're dealing with arrays, you are likely blowing your stack here...
I wouldn't think there's a way around this except fixing the original
source. f2py is very much based on assumptions about type sizes which
you then violate when passing -fdefault-real-8.
More information about the NumPy-Discussion