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 v4.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 Offloading and Multi Processing Runtime Library libgomp in GNU Offloading and Multi Processing Runtime Library.
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:
-Wl,--whole-archive -lpthread -Wl,--no-whole-archive
is added to the command line. However, this is not supported by gcc
and thus not recommended.
Next: OpenACC, Previous: CONVERT specifier, Up: Extensions implemented in GNU Fortran [Contents][Index]
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gfortran/OpenMP.html