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

Audrey Hureau <[email protected]> Tue, 3 Aug 2010 11:59:03 +0200
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
It is because I though dimensions' array are inverted. 
Because if I don't invert it, I get a segmentation fault if dimensions are big. I am wrong?

Audrey 

> Date: Tue, 3 Aug 2010 10:39:35 +0100
> From: [email protected]
> To: f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> Subject: Re: [f2py] FW: Pass a python array on a subroutine
> 
> Hi,
> 
> Here is a simple example that works for me... perhaps if you check
> this works for you you will see if you're f2py is working properly.
> Then you can start to add things from your full code to see where the
> problem is. I think you need to be careful with indexes - one thing is
> that in your EXECUTABLE function it looks like they are the wrong way
> round - val is (b,c) but you are looping (1..c, 1..b).
> 
> I put this in a function called testpass.f95
> !---
> subroutine executable(val, b, c)
>     implicit none
>     integer, intent(in) :: b,c
>     real, dimension(b,c), intent(in) :: val
>     integer :: li,co
> 
>     DO li = 1,b
>         DO co = 1,c
>             WRITE (*,*) val(li, co)
>         END DO
>     END DO
> end subroutine
> !---
> and run f2py -c testpass.f95 -m testpass
> Then from ipython:
> In [2]: import testpass
> In [3]: x = np.random.rand(3,4)
> In [4]: testpass.executable(x)
>   0.4249328
>   0.5246207
>   0.4804753
>   0.5709109
>   0.7447789
>   0.3164150
>   0.6302102
>   0.7069213
>   0.1635373
>   2.3983051E-03
>   0.8255721
>   0.7564080
> 
> I hope this helps
> 
> Robin
> 
> On Tue, Aug 3, 2010 at 10:00 AM, Audrey Hureau <[email protected]> wrote:
> > I forgeet to join file enclosed. I'm sorry. Here it is.
> >
> > Audrey
> >
> >
> >
> >
> > ________________________________
> > From: [email protected]
> > To: f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> > Subject: Pass a python array on a subroutine
> > Date: Tue, 3 Aug 2010 10:58:00 +0200
> >
> > The simpliest example of my problem is in the file enclosed. I joined all
> > files needed to compile.
> > I still get an array full of null values.
> > I've written values in a text file so I can have a look at the values. And
> > we can see that values are not all nulls.
> > Does anyone can have a look to python program "appelProj.py" and tell me
> > what's wrong with it?
> > Thanks for all.
> >
> > Cheers,
> >
> > 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

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users