Re: [f2py] Pass a python array on a subroutine

Robin <[email protected]> Mon, 2 Aug 2010 09:08:22 +0100
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
On Mon, Aug 2, 2010 at 8:51 AM, Audrey Hureau <[email protected]> wrote:
> The problem is pretty simple because I explained my goal :
> I want to pass an array on a subroutine.
> The array is Proj and I pass it on (and its size) with the python line:
> "execute (Proj, dim1, dim2)"
>
> and then the subroutine could be : http://pastebin.com/d846QwZi

What are q and r? If you are passing the size of the array as b and c
then shouldn't your a array be inialised with those sizes.

And perhaps it would help to specify intent(in) which tells f2py that
it is supposed to be an input from python.

Also infact with f2py if you do that correctly then you do not
explicitly have to pass the sizes of the array.

ie with
subroutine executable(a, n, m)
    implicit none
    integer, intent(in) :: n,m
    real, dimension(n,m), intent(in) :: x


then you should just be able to call excutable(Proj) I think and have
the sizes filled in automatically.

Cheers

Robin

> The values which are printed in the subroutine "executable" are all nulls
> and should not be.
>
> Is this better for helping the readers to understand my problem?
>
> Audrey
>
>
>
>
>> From: [email protected]
>> To: f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
>> Date: Mon, 2 Aug 2010 09:30:11 +0200
>> Subject: Re: [f2py] Pass a python array on a subroutine
>>
>> Dear Audrey,
>>
>> it would be very helpful for all the readers of the list to try hard
>> to make examples as short and terse as possible. Chances are higher
>> to get a usable answer if we do not have to struggle through mostly
>> unrelated code.
>>
>> Regards,
>> Juergen
>>
>>
>>
>>
>> Audrey Hureau wrote (Monday 02 August 2010 09:11:40):
>> > Hello everyone,
>> >
>> > I need your help because I try to pass a python array in a subroutine
>> > but
>> > the values I retrieve in my fortran subroutine are all null. I don't
>> > know
>> > why.
>> > Is anobody can tell me more about why I get this?
>> > Here is the python program : http://pastebin.com/MT8mLmaV. The
>> > subroutine
>> > is named "executable". The array's values are calculated with another
>> > python program called "projRot" and stocked in the "Proj" array. Here is
>> > the subroutine : http://pastebin.com/UExTzEhp.
>> >
>> > Audrey
>> >
>>
>> _______________________________________________
>> f2py-users mailing list
>> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
>> http://cens.ioc.ee/mailman/listinfo/f2py-users
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users
>
>