[SciPy-dev] f2py + f90 file
dmitrey
dmitrey.kroshko@scipy....
Tue Feb 26 04:43:54 CST 2008
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)
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'>
using bvls.f90
Type: float32 ;
xf= [ 0. -0.] ; type(xf[0])= <type 'numpy.float32'>
Type: float64 ;
xf= [ 0. -0.] ; type(xf[0])= <type 'numpy.float32'>
Type: float128 ;
xf= [ 0. -0.] ; type(xf[0])= <type 'numpy.float32'>
Ok, let's not use f90 version anymore.
But is it possible to make somehow bvls.f working correctly with other
types then numpy.float64, i.e. with float32 and float128?
Regards, D.
Pearu Peterson wrote:
> On Tue, February 26, 2008 12:01 pm, dmitrey wrote:
>
>> I have seen the pyf-files appearing from time to time, but now they are
>> absent (in the directory where I have used f2py), and do not appear
>> after f2py using.
>>
>> As for commands, I have used
>> f2py -c -m bvls bvls.f
>> and
>> f2py -c -m bvls bvls.f90 --fcompiler=gnu95
>>
>
> Ok, thanks for the info. In general, it is recommended to use
> a modified .pyf when wrapping Fortran functions with longish
> argument list that may contain output-type arguments.
> See f2py users guide for more information.
>
> Below follows the content of a .pyf file that I have modified to
> meet the docs of bvls.f (there are some room for improvements).
> Then I used the following command line
>
> f2py -c bvls.pyf bvls.f
>
> to build the bvls extension module. In test_bvls.py file I changed
> the bvls.bvls call to
>
> xf,w,istate,loopa = bvls.bvls(a,b,bl,bu)
>
> And, most importantly, set inf=100. Now I get the correct results:
>
> using bvls.f
> Type: float32 ;
> xf= [ 15. 15.] ; type(xf[0])= <type 'numpy.float64'>
> Type: float64 ;
> xf= [ 15. 15.] ; type(xf[0])= <type 'numpy.float64'>
> Type: float128 ;
> xf= [ 15. 15.] ; type(xf[0])= <type 'numpy.float64'>
>
> Btw, I believe that your approach of not using .pyf file
> would also worked when not using inf as an bound parameter
> - obviosly the underlying Fortran code is not designed
> to handle float infinities.
>
> HTH,
> Pearu
>
>
> ! -*- f90 -*-
> ! Note: the context of this file is case sensitive.
> !FILE: bvls.pyf
>
> python module bvls ! in
> interface ! in :bvls
> subroutine bvls(key,m,n,a,b,bl,bu,x,w,act,zz,istate,loopa) ! in
> :bvls:bvls.f
> integer :: key = 0
> integer optional,check(shape(a,0)==m),depend(a) :: m=shape(a,0)
> integer optional,check(shape(a,1)==n),depend(a) :: n=shape(a,1)
> double precision dimension(m,n) :: a
> double precision dimension(m),depend(m) :: b
> double precision dimension(n),depend(n) :: bl
> double precision dimension(n),depend(n) :: bu
> double precision dimension(n),depend(n),intent(out) :: x
> double precision dimension(n),depend(n),intent(out) :: w
> double precision dimension(m,m + 2),depend(m), intent(cache),
> optional :: act
> double precision dimension(m),depend(m), intent(cache),
> optional :: zz
> integer dimension(n + 1),depend(n),intent(out) :: istate
> integer intent(out) :: loopa
> end subroutine bvls
> end interface
> end python module bvls
>
> ! This file was auto-generated with f2py (version:2_3744).
> ! See http://cens.ioc.ee/projects/f2py2e/
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
>
>
More information about the Scipy-dev
mailing list