Sun Studio 12: Fortran User's Guide

2.3.2 Parallelization Directives

Parallelization directives explicitly request the compiler to attempt to parallelize the DO loop or the region of code that follows the directive. The syntax differs from general directives. Parallelization directives are only recognized when compilation options -openmp, -parallel, or -explicitpar are used. Details regarding Fortran parallelization can be found in the OpenMP API User’s Guide and the Fortran Programming Guide.

The Fortran compiler supports the OpenMP 2.5 shared memory parallelization model. Legacy Sun and Cray parallelization directives are now deprecated and should not be used. OpenMP Parallelization Directives

The Fortran 95 compiler recognizes the OpenMP Fortran shared memory multiprocessing API as the preferred parallel programming model. The API is specified by the OpenMP Architecture Review Board (

You must compile with the command-line option -xopenmp, to enable OpenMP directives. (see 3.4.155 –xopenmp[={parallel|noopt|none}].)

For more information about the OpenMP directives accepted by f95, see the OpenMP API User’s Guide. Legacy Sun/Cray Parallelization Directives

Note –

Legacy Sun and Cray style parallelization directives are now deprecated. The compiler still recognizes these directives, but that may change in a later Sun Studio release. The OpenMP parallelization API is preferred. Information on how to migrate from legacy Sun/Cray directives to the OpenMP model appears in the OpenMP API User’s Guide.

Sun style parallelization directives are the default for -parallel and -explicitpar. Sun directives have the directive sentinel $PAR.

Cray style parallelization directives, enabled by the -mp=cray compiler option, have the sentinel MIC$. Interpretations of similar directives differ between Sun and Cray styles. See the chapter on parallelization in the Fortran Programming Guide for details. See also the OpenMP API User’s Guide for guidelines on converting legacy Sun/Cray parallelization directives to OpenMP directives.

Note that only the OpenMP directives are available for parallelization on x86 Solaris and Linux platforms.

Sun/Cray parallelization directives have the following syntax:

Each parallelization directive has its own set of optional qualifiers that follow the keyword.

Example: Specifying a loop with a shared variable:

C$PAR DOALL SHARED(yvalue)    Sun style
CMIC$ DOALL SHARED(yvalue)    Cray style