[Numpy-discussion] f2py: returning strings?

Peter Williams pwilliams at astro.berkeley.edu
Fri Jul 20 15:24:24 EDT 2007


Hi,

I have some fortran code that I'm trying to wrap with f2py. The f2py
mailing list seems really dead, so I thought I'd try asking here. My
problem is that I can't get a routine to return a string (using the f2py
from numpy 1.0.3). The Fortran looks like this:

        subroutine uvDatGta(object,aval)
        implicit none
        character object*(*),aval*(*)
	...

where object is an input and aval is an output. I've tried passing aval
as a numpy.chararray and using all sorts of intent() flags in the f2py
headers. No matter what I do, though, f2py seems to want to treat aval
as a char *, and it seems that it doesn't have the facilities to map
strings as outputs from routines. Is there a way to get f2py to make
this work? Ideally, I'd like to be able to go

	aval = uvdatgta (object)

and get a plain Python string back, but I can always write a wrapper in
Python around some chararray stuff.

Thanks,

Peter

-- 
Peter Williams / pwilliams at astro.berkeley.edu
Department of Astronomy, UC Berkeley




More information about the NumPy-Discussion mailing list