[Numpy-discussion] numpy.distutils/f2py: forcing 8-bit reals
Dag Sverre Seljebotn
dagss@student.matnat.uio...
Tue Mar 30 04:02:21 CDT 2010
Dag Sverre Seljebotn wrote:
> David Warde-Farley wrote:
>> Hi,
>>
>> In my setup.py, I have
>> from numpy.distutils.misc_util import Configuration
>>
>> fflags= '-fdefault-real-8 -ffixed-form'
>> config = Configuration(
>> 'foo',
>> parent_package=None,
>> top_path=None,
>> f2py_options='--f77flags=\'%s\' --f90flags=\'%s\'' % (fflags,
>> 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.
Well, you can pass -fdefault-real-8 and then write .pyf headers where
real(8) is always given explicitly.
Dag Sverre
More information about the NumPy-Discussion
mailing list