Python/Fortran interoperability
nmm1 at cam.ac.uk
nmm1 at cam.ac.uk
Mon Aug 24 15:54:38 EDT 2009
In article <h6upc9$4u$1 at naig.caltech.edu>,
glen herrmannsfeldt <gah at ugcs.caltech.edu> wrote:
>
>< Consider, for example:
>
>< SUBROUTINE Fred (X) BIND(C)
>< CHARACTER*(*) :: X
>< END SUBROUTINE Fred
>
>< CHARACTER(LEN=100) :: string
>< CALL Fred(string(40:60))
>< CALL Fred(string(5:50))
>
>< This is not currently allowed and raises all sorts of 'interesting'
>< implementation and portability questions. For example, I defy anyone
>< to write Fred portably in C :-)
>
>You mean, how does FRED know the length? It seems to me the
>usual question for Fortran assumed size arrays. Assuming that
>FRED can tell from the passed string, it seems fine to me.
>If not, it is a problem.
Precisely. And the whole point of my question is how many people
WANT to do it, from the point of view of extending BIND(C).
>< Even when Fred has an explicit length, there are some problematic
>< cases, which could catch out programmers in one language that don't
>< know the other fairly well. But those are much less of a problem
>< than the common need for assumed length CHARACTER arguments.
>
>Maybe Fortran programmers who started in Fortran 66 will not
>have so much problem with this. The usual way would be to
>pass the length, as with assumed size arrays. I believe terminating
>strings with unusual (likely not null) characters was also done.
Yeah. But there are a decreasing number of us left :-)
Prefix length strings were also used.
Regards,
Nick Maclaren.
More information about the Python-list
mailing list