[SciPy-dev] returning string by f2py

Pearu Peterson pearu@cens.ioc...
Thu Mar 13 08:57:09 CDT 2008


On Thu, March 13, 2008 1:56 pm, dmitrey wrote:
> Hi Pearu,
>
> have you encountered any success with the problem (returning string from
> fortran)?

$ cat foo.f
      subroutine foo(msg)
      character *(10) msg
cf2py intent(out) msg
      msg = "abc"
      end
$ f2py -m m foo.f -c

>>> import m
>>> m.foo()
'abc       '
>>>

Is that what you need?

> (However, I think connecting f77 code is more preferred than f90,
> because some computers can have f77 but have no f90 compiler installed,
> am I right)?

f2py is designed to wrap any F77 code, and only a subset of F90.

> BTW, I had noticed some parameters return incorrect value as well, for
> example loopa (number of iterations elapsed) always has same value that
> I pass to the fortran routine (even w/o any my modifications to code,
> simple f2py -c -m ...).

Somehow it seems to me that you have not been trying to use intent(out)..

HTH,
Pearu



More information about the Scipy-dev mailing list