Re: [f2py] How to pass string to F90 module data
Pearu Peterson <[email protected]> Tue, 23 Nov 2010 09:31:26 +0200
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Joe,
Here's a possible solution:
module foo
character*(50) str
contains
subroutine bar()
print*, "str=",str
end subroutine bar
end module foo
#eof foo.f90
f2py -c -m foo foo.f90
>>> import foo
>>> foo.foo.bar()
str=
>>> s = '1234567890ab'
>>> foo.foo.str[:len(s)] = s
>>> foo.foo.bar()
str=1234567890ab
HTH,
Pearu
On 11/23/2010 06:15 AM, Jing wrote:
> Hello:
>
> I have difficulty to pass python strings to F90 module data
> variables with different length. I have declared at module level
> variables as fixed length character, say 50. I want to pass a python
> string variable of length 12 to it.
>
> The problem is I can't predict in advance the length of python
> string, and F90 won't let me declare variable length character. Any
> suggestion? Thanks,
>
>
> Joe S
>
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users