Technical data
108
Chapter 6: Compiling and Debugging Parallel Fortran
Using the –static Flag
A few words of caution about the –static flag: 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 flag, 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 files 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 file 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 flag signals the linker to use the Fortran multiprocessing
library. The file bellman.o need not have been compiled with the –mp flag
(although it could have been).










