Purpose
The omp_in_parallel function returns .TRUE. if you call it from the dynamic extent of a region executing in parallel and returns .FALSE. otherwise. If you call omp_in_parallel from a region that is serialized but nested within the dynamic extent of a region executing in parallel, the function will still return .TRUE.. (Nested parallel regions are serialized by default. See omp_set_nested(enable_expr) and the environment variable OMP_NESTED in the XL Fortran User's Guide for more information.)
Class
Function.
Argument Type and Attributes
None.
Result Type and Attributes
Default logical.
Result Value
.TRUE. if called from the dynamic extent of a region executing in parallel. .FALSE. otherwise.
Examples
USE omp_lib INTEGER N, M N = 4 M = 3 PRINT*, omp_in_parallel() !$OMP PARALLEL DO DO I = 1,N !$OMP PARALLEL DO DO J=1, M PRINT *, omp_in_parallel() END DO !$OMP END PARALLEL DO END DO !$OMP END PARALLEL DO
The first call to omp_in_parallel returns
.FALSE. because the call is outside the dynamic
extent of any parallel region. The second call returns
.TRUE., even if the nested PARALLEL DO loop
is serialized, because the call is still inside the dynamic extent of the
outer PARALLEL DO loop.