Technical data

108
Chapter 6: Compiling and Debugging Parallel Fortran
Using the static Flag
A few words of caution about the static ag: The multiprocessing
implementation demands some use of the stack to allow multiple threads of
execution to execute the same code simultaneously. Therefore, the parallel
DO loops themselves are compiled with the automatic ag, even if the
routine enclosing them is compiled with static.
This means that SHARE variables in a parallel loop behave correctly
according to the static semantics but that LOCAL variables in a parallel
loop will not (see Debugging Parallel Fortran on page 110 for a description
of SHARE and LOCAL variables).
Finally, if the parallel loop calls an external routine, that external routine
cannot be compiled with static. You can mix static and multiprocessed
object les in the same executable; the restriction is that a static routine
cannot be called from within a parallel loop.
Examples of Compiling
This section steps you through a few examples of compiling code using mp.
The following command line
% f77 mp foo.f
compiles and links the Fortran program foo.f into a multiprocessor
executable.
In this example
% f77 c mp O2 snark.f
the Fortran routines in the le snark.f are compiled with multiprocess code
generation enabled. The optimizer is also used. A standard snark.o binary is
produced, which must be linked:
% f77 mp o boojum snark.o bellman.o
Here, the mp ag signals the linker to use the Fortran multiprocessing
library. The le bellman.o need not have been compiled with the mp ag
(although it could have been).