[f2py] Basic question? (without typo)
robert.kern at gmail.com
Wed Oct 3 22:22:37 EEST 2007
Andreas Kring wrote:
> (sorry, this version should be correct).
> I'm new to f2py and have a very basic question. Consider the follow
> fortran90 file (called test.f90) and the following few lines of python.
> subroutine add(x,y,z)
> implicit none
> end subroutine add
> $ f2py -c test.f90 -m test
>>>> from test import add
> Why is c not equal to 3?
Python integers are immutable. They cannot be changed (technically not true in C
modules, but a well-behaved C module like those f2py generates won't). Even if
the argument were mutable, like a numpy array, the default intent of arguments
is considered to be intent(in), not intent(inout). However, in this case, `c` is
really an intent(out) argument, and you should declare it so, otherwise f2py
won't know. Then call the function from Python like so:
c = add(a, b)
> Shouldn't this be the case when comparing to
> the example in the Users Guide
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the f2py-users