[f2py] FW: Pass a python array on a subroutine
robince at gmail.com
Tue Aug 3 12:39:35 EEST 2010
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)
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)
and run f2py -c testpass.f95 -m testpass
Then from ipython:
In : import testpass
In : x = np.random.rand(3,4)
In : testpass.executable(x)
I hope this helps
On Tue, Aug 3, 2010 at 10:00 AM, Audrey Hureau <audrey.hureau at hotmail.fr> wrote:
> I forgeet to join file enclosed. I'm sorry. Here it is.
> From: audrey.hureau at hotmail.fr
> To: f2py-users at cens.ioc.ee
> 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.
> f2py-users mailing list
> f2py-users at cens.ioc.ee
More information about the f2py-users