[f2py] status of numpy and character string arrays

ES eli-sava at pacbell.net
Tue Jan 2 19:49:30 EET 2007


Hello,
I have been trying to compile on an Enthought distribution of Python 
2.4 with numpy 0.9.9 and the f2py contained within it. I use Windows 
XP with --fcompiler=intelv. The configuration of f2py works great 
when there are no arrays of character strings.

I get an argument conversion error when there are arrays of character 
strings. See for example the test below off a previous thread and my 
results. There is nothing new -- my error is the same as that 
reported by Fabien Wahl in April 2006. At that time, Robert Kern 
mentioned that the numpy version of f2py was compatible with numpy. 
My question is how far that goes -- is it thought to work with 
character string arrays? If so, could the test be modified to work? The code?

It worked fine before on Numeric with Python 2.3, compaqv compiler 
and no numpy, but using Numeric is not an option for me. If my goal 
is not realistic, I would appreciate pointers on a workaround. It is 
an important, applied project.

Thanks so much.
Eli


C FILE: STRING.F
       SUBROUTINE FOO2(A)
       CHARACTER, dimension(2) ::A*5
Cf2py intent(in) a
       PRINT*, "A(1)=",A(1)
       PRINT*, "A(2)=",A(2)
       END
C END OF FILE STRING.F

compiled with:
f2py -c --fcompiler=intelv  -m mystring_new string.f
where "f2py is actually a python call to the numpy version"

tested with:
import mystring_new
from numpy import array
a=array(('abcde','vwxyz'))
mystring_new.foo2(a)

and the error is:
1-th dimension must be 5 but got 0 (not defined).
Traceback (most recent call last):
   File "test.py", line 5, in ?
     mystring_new.foo2(a)
mystring_new.error: failed in converting 1st argument `a' of 
mystring_new.foo2 to C/Fortran array





More information about the f2py-users mailing list