Re: [f2py] f2py Arrays and Fortran functions

Kevin Mitchell <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
I'm confused about exactly what you're doing. You shouldn't have any
problem passing python arrays to a Fortran subroutine that's exactly
what f2py is designed to do.

For example

>>> A1=rand(9,8)
>>> A2=rand(9)
>>> A2=rand(9,7)
>>> f2pymodule.fn(A1,A2,A3)

Where in your fortran source file, you have
subroutine fn(n,m,l,A1,A2,A3)
!intent(inout) A1,A2,A3
integer n,m,l
real*8  A1(n,m),A2(n),A3(n,l)
<do stuff with A1,A2,A3>
return
end subroutine fn


On Sat, May 9, 2009 at 1:22 AM, Leon Adams <[email protected]> wrote:
> Hi all,
>
> I am new to f2py and am having some difficulties with array operation. Here
> is my design difficulties:
>
> Using python as a glue, I initialize my problem. This involves generating a
> series of arrays and matrices. I pass an array and two matrices to FORTRAN
> and return an augmented matrix like so:
>
>
> Python
>
> A1[x],   A2[x,y]   A2[x,z]
>
> pass to FORTRAN        fn(A1,A2,A3)  with intent inout A3
>
> in FORTRAN I have a series of subroutines and functions to preform my
> numeric calculations
>
> FORTRAN
>
> subroutine sub(A1,A2,A3,x,y,z)
>
> calculations using A1,A2,A3,x,y,z
>
> call function using data passed from python as in:
>
> function fun(A1,...x,y)
>
> And here is where my problems start.  FORTRAN does not like passing of
> Arrays. Solutions I thought of was to make the input data from python GLOBAL
> in scope in FORTRAN, but I haven't found any documentation on how to acheive
> this either with COMMON or MODULES viz a viz F2PY. Any suggestion would be
> appreciated.
>
> Thanks in advance
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.