Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array of string #138

Open
pogam opened this issue Jan 22, 2021 · 1 comment
Open

array of string #138

pogam opened this issue Jan 22, 2021 · 1 comment

Comments

@pogam
Copy link

pogam commented Jan 22, 2021

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.

@jameskermode
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants