bizarre I get ================= >>> hello.foo(a) Hello from Fortran! a= 1 2 >>> a 1 >>> hello.foo(a) Hello from Fortran! a= 1 2 >>> print a 1 >>> =================================
i.e. The value of 2 gets printed! This is numpy 1.3.0 -Mathew On Tue, Apr 12, 2011 at 11:45 AM, Pearu Peterson <[email protected]> wrote: > > > On Tue, Apr 12, 2011 at 9:06 PM, Mathew Yeates <[email protected]> wrote: >> >> I have >> subroutine foo (a) >> integer a >> print*, "Hello from Fortran!" >> print*, "a=",a >> a=2 >> end >> >> and from python I want to do >> >>> a=1 >> >>> foo(a) >> >> and I want a's value to now be 2. >> How do I do this? > > With > > subroutine foo (a) > integer a > !f2py intent(in, out) a > print*, "Hello from Fortran!" > print*, "a=",a > a=2 > end > > you will have desired effect: > >>>> a=1 >>>> a = foo(a) >>>> print a > 2 > > HTH, > Pearu > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
