f2py Assumed-Size Array Arguments

Pearu Peterson pearu at cens.ioc.ee
Tue Aug 27 03:59:11 EDT 2002


On 26 Aug 2002, Darryl wrote:

> I am new to python and involved in a software modernization project
> that involves accessing fortran modules from python using the f2py
> interface generator.  However, I have problems when trying to generate
> an interface to a program unit which has assumed-length array
> arguments.  Is there a compatibility issue here that I should know
> about and if not, can someone please let me know the procedure for
> this?

One cannot construct assumed-size array in C as the underlying
specification is extremely compiler dependent and compiler vendors do not
publish this information. This is the reason why you got these
errors. However, there are some tricks that f2py could do to
circumvent this issue but they are not implemented yet.

For now, you could write a simple wrapper to the array_sum(a) function,
e.g.

   real function array_sum_wrap(a,n)
     integer :: n
!f2py integer intent(hide),depend(a) :: n = len(a)
     real, intent(in), dimension(n) :: a
     array_sum_wrap = array_sum( a )
   end

and wrap this function with f2py.

Pearu





More information about the Python-list mailing list