Python/Fortran interoperability

nmm1 at nmm1 at
Mon Aug 24 20:55:38 CEST 2009

In article <1j4y84p.v5docbtueccmN%nospam at see.signature>,
Richard Maine <nospam at see.signature> wrote:
>Only character strings of length 1 are interoperable, as the term
>"interoperable" is defined in the Fortran standard. However, that does
>not mean that only character strings of length 1 will work with C. The
>distinction might be picky, but it is important.

Precisely.  And the kludge does NOT work under all circumstances,
which is why I said that it doesn't work very well.

Consider, for example:

    CHARACTER*(*) :: X

    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 :-)

It gets really hairy if you have functions that have assumed length
results, but those are obsolescent.

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.

Nick Maclaren.

More information about the Python-list mailing list