array of string
pogam opened this issue · comments
pogam commented
I am using f90wrap v0.2.3
I have a problem passing array of string from fortan to python
in the string example f90wrap/examples/string
I changed func_return_string
to
function func_return_string() result(stringout)
CHARACTER(51),dimension(10):: stringout
stringout(1) = 'yy-_-::this is a string with ASCII, / and 123...::-_-'
print*,stringout(1)
stringout(2) = 'eerde'
print*,stringout(2)
end function func_return_string
in the python code when printing the outstring
I got
array([b'y', b'y', b'-', b'_', b'-', b':', b':', b't', b'h', b'i'], dtype='|S1')
each element of the array is getting one letter of the first string.
James Kermode commented
I'm afraid there's nothing simple to be done about this - this is what the Fortran representation of the string looks like. You can convert to a Python string with ''.join(outstring)
or similar.