!%f90 -*- f90 -*- ! Example: ! Using f2py for wrapping multi-dimensional Fortran and C arrays ! [OLD APPROACH, do not use it with f2py higher than 2.8.x] ! $Id: run.pyf,v 1.1 2002/01/14 15:49:46 pearu Exp $ ! Usage (with gcc compiler): ! f2py -c run.pyf foo.f bar.c -DNO_APPEND_FORTRAN python module run ! in interface ! in :run ! >>> from Numeric import * ! >>> import run ! >>> a=array([[1,2,3],[4,5,6]],'i') subroutine foo(a,m,n) fortranname foo_ integer dimension(m,n) :: a integer optional,check(shape(a,1)==m),depend(a) :: m=shape(a,1) integer optional,check(shape(a,0)==n),depend(a) :: n=shape(a,0) end subroutine foo ! >>> print run.foo.__doc__ ! foo - Function signature: ! foo(a,[m,n]) ! Required arguments: ! a : input rank-2 array('i') with bounds (n,m) ! Optional arguments: ! m := shape(a,1) input int ! n := shape(a,0) input int ! >>> run.foo(a) ! F77: ! m= 3, n= 2 ! Row 1: ! a(i= 1,j= 1) = 1 ! a(i= 1,j= 2) = 4 ! Row 2: ! a(i= 2,j= 1) = 2 ! a(i= 2,j= 2) = 5 ! Row 3: ! a(i= 3,j= 1) = 3 ! a(i= 3,j= 2) = 6 ! >>> run.foo(transpose(a)) ! F77: ! m= 2, n= 3 ! Row 1: ! a(i= 1,j= 1) = 1 ! a(i= 1,j= 2) = 2 ! a(i= 1,j= 3) = 3 ! Row 2: ! a(i= 2,j= 1) = 4 ! a(i= 2,j= 2) = 5 ! a(i= 2,j= 3) = 6 subroutine bar(a,m,n) intent(c) integer dimension(m,n) :: a integer optional,check(shape(a,0)==m),depend(a) :: m=shape(a,0) integer optional,check(shape(a,1)==n),depend(a) :: n=shape(a,1) end subroutine bar ! >>> print run.bar.__doc__ ! bar - Function signature: ! bar(a,[m,n]) ! Required arguments: ! a : rank-2 array('i') with bounds (m,n) ! Optional arguments: ! m := shape(a,0) int ! n := shape(a,1) int ! >>> run.bar(a) ! C:m=2, n=3 ! Row 1: ! a(i=0,j=0)=1 ! a(i=0,j=1)=2 ! a(i=0,j=2)=3 ! Row 2: ! a(i=1,j=0)=4 ! a(i=1,j=1)=5 ! a(i=1,j=2)=6 end interface end python module run ! This file was auto-generated with f2py (version:2.8.172). ! See http://cens.ioc.ee/projects/f2py2e/