Technical data
Writing Parallel Fortran
71
For multiprocessing to work correctly, the iterations of the loop must not
depend on each other; each iteration must stand alone and produce the same
answer regardless of whether any other iteration of the loop is executed. Not
all DO loops have this property, and loops without it cannot be correctly
executed in parallel. However, any of the loops encountered in practice fit
this model. Further, many loops that cannot be run in parallel in their
original form can be rewritten to run wholly or partially in parallel.
To provide compatibility for existing parallel programs, Silicon Graphics has
chosen to adopt the syntax for parallelism used by Sequent Computer
Corporation. This syntax takes the form of compiler directives embedded in
comments. These fairly high level directives provide a convenient method
for you to describe a parallel loop, while leaving the details to the Fortran
compiler. For advanced users, there are a number of special routines that
permit more direct control over the parallel execution. (Refer to “Advanced
Features” on page 97 for more information.)
Writing Parallel Fortran
The Fortran compiler accepts directives that cause it to generate code that
can be run in parallel. The compiler directives look like Fortran comments:
they begin with a C in column one. If multiprocessing is not turned on, these
statements are treated as comments. This allows the identical source to be
compiled with a single-processing compiler or by Fortran without the
multiprocessing option. The directives are distinguished by having a $ as the
second character. There are six directives that are supported:
C$DOACROSS, C$&, C$, C$MP_SCHEDTYPE, C$CHUNK, and
C$COPYIN. The C$COPYIN directive is described in “Local COMMON
Blocks” on page 102. This section describes the others.
C$DOACROSS
The essential compiler directive is C$DOACROSS. This directs the compiler
to generate special code to run iterations of the DO loop in parallel. The
C$DOACROSS statement applies only to the next statement (which must
be a DO loop).










