[Numpy-discussion] f2py with allocatable arrays
Casey W. Stark
Tue Jul 3 13:38:36 CDT 2012
Thanks for the speedy responses! I'll try to respond to all...
The first idea is to split up the routine into two -- one to compute the
final size of the arrays, and the second to fill them in. I might end up
doing this, because it is simplest, but it means creating the initial
conditions twice, throwing them away the first time. Not a huge deal
because this setup is not that big (a few minutes), but it will take twice
Sturla, this is valid Fortran, but I agree it might just be a bad idea. The
Fortran 90/95 Explained book mentions this in the allocatable dummy
arguments section and has an example using an array with allocatable,
intent(out) in a subrountine. You can also see this in the PDF linked from
http://fortranwiki.org/fortran/show/Allocatable+enhancements. I have never
used array pointers in Fortran, but I might give this a shot. Are there any
problems returning pointers to arrays back to python though?
As for storing the arrays in the module data block, I would like to avoid
that approach if possible. It doesn't make sense for these to be module
level components when the size and values depend on the input to a
subroutine in the module.
On Tue, Jul 3, 2012 at 10:24 AM, Pearu Peterson <email@example.com>wrote:
> On Tue, Jul 3, 2012 at 5:20 PM, Sturla Molden <firstname.lastname@example.org> wrote:
>> As for f2py: Allocatable arrays are local variables for internal use,
>> and they are not a part of the subroutine's calling interface. f2py only
>> needs to know about the interface, not the local variables.
> One can have allocatable arrays in module data block, for instance, where
> they a global. f2py supports wrapping these allocatable arrays to python.
> See, for example,
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion