f2py Assumed-Size Array Arguments

Darryl darryl.genovesi at lmco.com
Mon Aug 26 18:57:55 EDT 2002


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?

Thanks in advance
Darryl

P.S. You want the details?  Please read on...



For example, if I try to wrap a file containing:

-------------------------------------------------------
module mod0

  implicit none

contains

  real function array_sum( a )
    real, intent(in), dimension(:) :: a
    array_sum = sum( a )
  return
  end function

end module
--------------------------------------------------------

f2py will generate the error message:

15 Lines Compiled
ifc  -KPIC  -FI -w90 -w95   -O3  -xM 
-I/usr/local/Python-2.2.1/lib/python2.2/site-packages/f2py2e/src  -c
/usr/tmp/@20794.0/array_sum-f2pywrappers.f -o
/usr/tmp/@20794.0/array_sum-f2pywrappers.o
   external subroutine F2PYWRAP_MOD0_ARRAY_SUM
      array_sumf2pywrap = array_sum(a)
                          ^
Error 259 at (8:/usr/tmp/@20794.0/array_sum-f2pywrappers.f) : This
function has the wrong number of arguments or arguments with the wrong
name, type or rank
   external subroutine F2PYINITMOD0

1 Error
compilation aborted for /usr/tmp/@20794.0/array_sum-f2pywrappers.f
(code 1)
error: failure during compile



More information about the Python-list mailing list