Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] Problem with mpi_comm_spawn_multiple
From: Noam Bernstein (noam.bernstein_at_[hidden])
Date: 2010-05-07 18:30:12

I haven't been following this whole discussion, but I do know
something about how Fortran allocates and passes string argument
(the joys of Fortran/C/python inter-language calls), for what
it's worth.

By definition in the Fortran language all strings have a predefined
length, which Fortran magically knows. Therefore, it doesn't need
termination (like null termination in C). In practice, we've found
that most compilers, when you pass a string to a routine, also pass
its length, although you don't do so explicitly, so that "character(len=*)
arg" works. In practice (and this is probably part of the standard),
Fortran ' ' pads all strings. As usual, there's no default value
in new strings, so strings declared, string arrays declared, and
string arrays allocated may or may not have any particular value
at initialization. But if you set a string to ' ', or even '',
it'll actually set it all to spaces, because of the padding. There's
no null termination. len(string) returns the overall (allocated
or declared) length, len_trim(string) will return the length ignoring
any trailing spaces. If the underlying routines receiving the
string want to know how long it is, and they're C routines, they
have to have another (integer, by reference) argument. Unfortunately,
compilers don't always agree on where that hidden argument goes.
Most, I think, put it after the explicit arguments, but some might
put it right after the string being passed. If the receiving
routines are Fortran from another compiler, you're just hosed, I

As with every array in Fortran, arrays of strings
are contiguous in memory, and presumably the end of string (1,1)
is right before the beginning of string(2,1), etc.