Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-05 Thread Ondřej Čertík
On Tue, Jul 3, 2012 at 9:51 PM, Paul Anton Letnes wrote: > > On 4. juli 2012, at 02:23, Sturla Molden wrote: > >> Den 03.07.2012 20:38, skrev Casey W. Stark: >>> >>> 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 >>

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-05 Thread Ondřej Čertík
On Tue, Jul 3, 2012 at 5:27 PM, Sturla Molden wrote: > Den 04.07.2012 01:59, skrev Sturla Molden: >> But neither was the case here. The allocatable was a dummy variable in >> a subroutine's interface, declared with intent(out). That is an error >> the compiler should trap, because it is doomed to

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-05 Thread Casey W. Stark
Hi all. Thanks for the help again. I ended up going with running it twice -- once for the final number of particles and second for the positions. Sturla, given that this functionality is so standard dependent, I decided to ditch it. It works with my gfortran, but who knows with other machines and

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Paul Anton Letnes
On 4. juli 2012, at 02:23, Sturla Molden wrote: > Den 03.07.2012 20:38, skrev Casey W. Stark: >> >> 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 a

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Sturla Molden
Den 04.07.2012 01:59, skrev Sturla Molden: > But neither was the case here. The allocatable was a dummy variable in > a subroutine's interface, declared with intent(out). That is an error > the compiler should trap, because it is doomed to segfault. Ok, so the answer here seems to be: In Fortra

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Sturla Molden
Den 03.07.2012 20:38, skrev Casey W. Stark: > > 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

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Sturla Molden
Den 03.07.2012 19:24, skrev Pearu Peterson: > > One can have allocatable arrays in module data block, for instance, where > they a global In Fortran 2003 one can also have allocatable arrays as members in derived types. But neither was the case here. The allocatable was a dummy variable in a su

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Casey W. Stark
Hi all. 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

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Pearu Peterson
On Tue, Jul 3, 2012 at 5:20 PM, Sturla Molden 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 array

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Sturla Molden
Den 03.07.2012 11:54, skrev George Nurser: >> module zp >>implicit none >>contains >>subroutine ics(..., num_particles, particle_mass, positions, velocities) >> use data_types, only : dp >> implicit none >> ... inputs ... >> integer, intent(out) :: num_particles >>

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Jim Vickroy
On 7/2/2012 7:17 PM, Casey W. Stark wrote: Hi numpy. Does anyone know if f2py supports allocatable arrays, allocated inside fortran subroutines? The old f2py docs seem to indicate that the allocatable array must be created with numpy, and dropped in the module. Here's more background to expla

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Andreas Hilboll
> Hi numpy. > > Does anyone know if f2py supports allocatable arrays, allocated inside > fortran subroutines? The old f2py docs seem to indicate that the > allocatable array must be created with numpy, and dropped in the module. > Here's more background to explain... > > I have a fortran subroutine

Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread George Nurser
Can you interface your fortran program twice? First time return the number of particles, dimensions etc to python python then creates work array of right size Second interface pass work array as in/out array, dimension in fortran argument list, to fortran fortran copies allocatable arrays to arg

[Numpy-discussion] f2py with allocatable arrays

2012-07-02 Thread Casey W. Stark
Hi numpy. Does anyone know if f2py supports allocatable arrays, allocated inside fortran subroutines? The old f2py docs seem to indicate that the allocatable array must be created with numpy, and dropped in the module. Here's more background to explain... I have a fortran subroutine that returns