File size: 2,090 Bytes
c011401 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
!%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/
|