[f2py] help with optional arguments
pearu at cens.ioc.ee
pearu at cens.ioc.ee
Fri Nov 25 13:35:02 EET 2005
On Wed, 23 Nov 2005, Ryan Krauss wrote:
> I am new to f2py and I am having trouble figuring out how to make
> optional argument work as Cf2py statements. I am working on a simple
> example and if I do this:
> C Attempting to learn f2py
> subroutine tf(s,TAU,mytf,k)
> double precision k, TAU
> complex s,mytf
> Cf2py intent(in) s,TAU
> Cf2py intent(optional) k = 5.0
> Cf2py intent(out) mytf
> print*, "k=",k
> mytf = k/(s*(TAU+s))
> END
>
> k is not optional when I import the module into python.
f2py does not understand the statement `intent(optional) k = 5.0` and so
it is ignored. Use
Cf2py double precision k = 5.0
or
Cf2py double precision optional :: k = 5.0
instead. Though it repeats the type declaration for k, it is currently the
only way to initialize `k` within Cf2py comment. Note that `optional` is
default whenever a variable has an initial value.
Pearu
More information about the f2py-users
mailing list