Next: , Previous: CONVERT specifier, Up: Extensions implemented in GNU Fortran


6.1.15 OpenMP

OpenMP (Open Multi-Processing) is an application programming interface (API) that supports multi-platform shared memory multiprocessing programming in C/C++ and Fortran on many architectures, including Unix and Microsoft Windows platforms. It consists of a set of compiler directives, library routines, and environment variables that influence run-time behavior.

GNU Fortran strives to be compatible to the OpenMP Application Program Interface v2.5.

To enable the processing of the OpenMP directive !$omp in free-form source code; the c$omp, *$omp and !$omp directives in fixed form; the !$ conditional compilation sentinels in free form; and the c$, *$ and !$ sentinels in fixed form, gfortran needs to be invoked with the -fopenmp. This also arranges for automatic linking of the GNU OpenMP runtime library libgomp.

The OpenMP Fortran runtime library routines are provided both in a form of a Fortran 90 module named omp_lib and in a form of a Fortran include file named omp_lib.h.

An example of a parallelized loop taken from Appendix A.1 of the OpenMP Application Program Interface v2.5:

     SUBROUTINE A1(N, A, B)
       INTEGER I, N
       REAL B(N), A(N)
     !$OMP PARALLEL DO !I is private by default
       DO I=2,N
         B(I) = (A(I) + A(I-1)) / 2.0
       ENDDO
     !$OMP END PARALLEL DO
     END SUBROUTINE A1

Please note: