Re: [f2py] incompatible parameter transfer between python and fortran?
Jürgen Wieferink <[email protected]> Tue, 2 Nov 2010 09:21:49 +0100
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Xavier Barthelemy wrote (Tuesday 02 November 2010 07:24:15): > > Please note that this cannot work because of how Python does things > > You are passing an object of type integer to some function. And as > > integers are immutable, the object cannot be changed. Python passes > > by object, not by value. > > hi Juergen > What do you mean exactly? > how is the correct form to pass these values? what kind have they to be? This is a subtle subject. Try a simple pure python example: def f(x): x = 5 a = 7 f(a) print a In f(), the line "x = 5" lets the name x refer to a new object, without changing the original object, which is still refered to by a in the caller. For f2py, you could get the intended behavior by using a = array(7.) f(a) but that is not quite robust. Juergen