[SciPy-dev] f2py + f90 file

Pearu Peterson pearu at cens.ioc.ee
Tue Feb 26 06:07:10 EST 2008


On Tue, February 26, 2008 12:43 pm, dmitrey wrote:
> So I have tried the pyf-file attached but unfortunately it yields text
> output
> using bvls.f
> Type: float32 ;
> and then nothing (for all finite-box bounded as well)

You can use --debug-capi to see where the processing stops.
May be you should skip float32 and try float64 case first.

> Fortunately, all-finite box-bounds now work correctly, but only for
> f77-version (with f2py -c -m bvls bvls.f) and numpy.float64 type:
>
> using bvls.f
> Type: float32 ;
> xf= [ 0.  0.] ; type(xf[0])= <type 'numpy.float32'>
> Type: float64 ;
> xf= [ 15.  15.] ; type(xf[0])= <type 'numpy.float64'>
> Type: float128 ;
> xf= [0.0 0.0] ; type(xf[0])= <type 'numpy.float128'>

> But is it possible to make somehow bvls.f working correctly with other
> types then numpy.float64, i.e. with float32 and float128?

The above results are expected. Note that by default all array arguments
are intent(in) and when using f2py as you do, the float64 result
is correct by accident (in the meaning that only in this case numpy
array can be passed directly to Fortran, in other cases a copy
is made and you cannot expect f2py to copy the computed results
back to original arrays if the intent(in) is specified).

Sure it is possible to make bvls.f work correctly with other
precision types but note that this involves making copies to float64
that the fortran function expects. To make it work, you have to
use the .pyf file and design it to be robust to all types.
I am afraid, you should use the .pyf file anyway in order to
make the results unaccidental.

Regards,
Pearu




More information about the SciPy-Dev mailing list