The OpenMP specification provides a number of routines that you can use to control and query the parallel execution environment, timing, and lock.
Parallel threads created by the runtime environment through the OpenMP interface are considered independent of the threads you create and control using calls to the Fortran Pthreads library module. References within the following descriptions to "serial portions of the program" refer to portions of the program that are executed by only one of the threads that have been created by the runtime environment. For example, you can create multiple threads by using f_pthread_create. However, if you then call omp_get_num_threads from outside of an OpenMP parallel block, or from within a serialized nested parallel region, the function will return 1, regardless of the number of threads that are currently executing.
OpenMP runtime library calls must not appear in PURE and ELEMENTAL procedures.
The OpenMP runtime library also supports a set of simple and nestable lock routines. You must only lock variables through these routines. Simple locks may not be locked if they are already in a locked state. Simple lock variables are associated with simple locks and may only be passed to simple lock routines. Nestable locks may be locked multiple times by the same thread. Nestable lock variables are associated with nestable locks and may only be passed to nestable lock routines. Note that locks are now associated with task regions, and no longer with threads as such, in accordance with changes in the OMP standard.
For all the routines listed below, the lock variable is an integer whose KIND type parameter is denoted either by the symbolic constant omp_lock_kind, or by omp_nest_lock_kind.
This variable is sized according to the compilation mode. It is set either to '4' for 32-bit applications or '8' for 64-bit.
See the following topics for more information about OpenMP execution environment routines, timing routines, and lock routines: