[f2py] problems with generated signature file

Paulo Teotonio Sobrinho teotonio@fma.if.usp.br
Thu, 14 Feb 2002 18:58:21 -0200 (BRST)


Dear Pearu,

Thanks for your answer!!! I'm looking forward to see the new
documentation. In the mean time, I think I have enough information to play
with simple examples.

Cheers, Paulo

On Thu, 14 Feb 2002, Pearu Peterson wrote:

> 
> Tere,
> 
> Sorry, Paulo, that the f2py documentation is out-dated and it has been too
> long in that way. The good news is that f2py is now quite stable and soon
> I will rewrite the whole documendation as quite a few things have been
> improved lately.
> 
> On Thu, 14 Feb 2002, Paulo Teotonio Sobrinho wrote:
> 
> > 
> > I'm new to f2py, so I'm trying to follow the example in the
> > documentation. I have a file with the usual
> > 
> > ! Fortran file foo.f:
> >       subroutine foo(a)
> >       integer a
> >       a = a + 5
> >       end		  
> > 
> > After 
> > f2py foo.f  -m foobar -h foobar.pyf
> > 
> > the generated foobar.pyf *is not* the same as in the tutorial. Here is
> > what I get
> > 
> > !%f90 -*- f90 -*-
> > python module foobar ! in 
> >     interface  ! in :foobar
> >         subroutine foo(a) ! in :foobar:foo.f
> >             integer :: a
> >         end subroutine foo
> > 
> > According to the documentation I was expecting 
> > 
> > integer intent(inout) :: a
> 
> Indeed, the default intent is now intent(in). In fact, intent(inout) will
> be depreciated due its nasty side-effects. Usage of intent(in,out) is
> the recommended way to get data in to and out from Fortran routine.
> 
> The f2py documentations will be changed to the following example:
> ---------------------------------------------
> 1) Fortran file:
> ! Fortran file foo.f:   
>        subroutine foo(a)
>        integer a
> cf2py  intent(in,out) a
>        a = a + 5
>        end
> 
> (cf2py  is special directive recognized by f2py so that one needs not to
> generate these intermediate signature files anymore, though, some times
> they can be handy.)
> 
> 2) Building a wrapper:
> 
>    f2py -c foo.f -m foobar -lfoobar
>                            ^------^- (you may not need this)
> This will create foobar.so into the current directory.
> 
> 3) Python session
> >>> import foobar
> >>> print foobar.foo(3)
> 8
> 
> That's it!
> -----------------------------------
> 
> > Finally, when I use the function foo in python it does nothing
> > 
> > >>from Numeric import *
> > >>a = array(3)
> > >>print a,foobar.foo(a),a
> > >>3 None 3
> >
> > I have no idea why the interface file is not corrected generated. If I edit
> > foobar.pyf then foobar.foo(a) works.
> 
> The reason is that default intent is changed, see above. So, everything is
> correct except the documentation.
> 
> And thanks for reminding me about outdated documentation. Only users
> requests and complaints can trigger me to update documentations and fix
> bugs, in general.
> 
> Regards,
> 	Pearu
> 
> 
>