I have observed Fortran 77 compilers which perform optimisations, for
example register optimsations, which are correct if the "foreign"
routine is Fortran 77, but if the "foreign" routine is C, then problems
arise. In particular I have been either (a) forced to turn
optimisations of, or (b) avoid the register optimisations by storing the
local variables in a common block, in some Fortran programs that call
MPI. The equivalent C programs worked fine.
I believe that this is a question of inter-language inter-operability.
If the Fortran 77 compiler does not know whether a called routine was
written in Fortran (and, presumably we should also throw the effects of
compiler flags in here), is it correct for that compiler to assume that
the called routine is Fortran 77 and therefore cannot do anything which
Fortran 77 code cannot do (e.g., remember the address of a program
variable in the caller, for later use, which really is one of the cases
in point)?
The answer to this question seems to me to both yes and no. Yes from
the point of view of the language (which the compiler is supposed to
compile). No from the point of view of inter-language interoperability
(which is not part of the language and which the compiler is not
necessarily supposed to compile).
I reached conclusions along the lines that Marc suggests. My
conclusions were that (a) C programs are (usually, but I can imagine
there are examples which break) fine since the called function is
allowed to retain in persistent storage (e.g., static) a pointer to
callee program variables (b) Fortran programs have the problem that
somehow all communication buffers used in non-blocking communiciations,
and in absolute derived datatypes must be made VOLATILE in order to be
portable which means in the end that they must be in COMMON blocks which
are persistent (i.e., blank common, or also defined in the main program,
is that right).
This problem has potentially existed with a whole load of message
passing implementations before MPI came onto the scene. I recall being
real concerned about it years back, and posting to comp.parallel on the
subject. No-one seemed interested then, and people around me said "Oh,
err, interesting, but we never had any problem like that", kind of
thing.
Them's the breaks.
Best Wishes
Lyndon
p.s. See you in Chicago!
/-----------------------------------------------------------------------\
|e||)| Lyndon J Clarke Edinburgh Parallel Computing Centre | Cymru |
|c||c| Tel: [+ 44] (0)131 650 5021 Email: lyndon@epcc.ed.ac.uk | am Byth|
\----| URL: http://www.epcc.ed.ac.uk/~lyndon/ |-------------------------/
\----------------------------------------/