X06 Chapter Contents
X06 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentX06AGF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

X06AGF enables or disables nested OpenMP parallelism.

## 2  Specification

 SUBROUTINE X06AGF ( NESTING)
 INTEGER NESTING

## 3  Description

X06AGF, for multi-threaded implementations, enables or disables the nesting of OpenMP parallel regions by setting an OpenMP Internal Control Variable (ICV) and any vendor library specific options where that is possible. See the Users' Note for your implementation for details of the scope of X06AGF.
Nesting is disabled by default in OpenMP.
In serial implementations of the NAG Library X06AGF has no effect. See the Chapter X06 for a discussion of the behaviour of these routines when called in serial.

## 4  References

OpenMP Specifications http://openmp.org/wp/OpenMP-Specifications
Chapman B, Jost G and van der Pas R (2008) Using OpenMP Portable Shared Memory Parallel Programming The MIT Press

## 5  Arguments

1:     $\mathrm{NESTING}$ – INTEGERInput
On entry: if ${\mathbf{NESTING}}=0$, nesting of OpenMP parallel regions is disabled, otherwise it is enabled.

None.

Not applicable.

## 8  Parallelism and Performance

X06AGF is not threaded in any implementation.

None.

## 10  Example

In this example we presume a multi-threaded implementation of the NAG Library. We call X06AGF to enable the nesting of OpenMP parallel regions by setting an ICV. Inside a first, or ‘outer’, parallel region we call X06AHF to display the status of nesting, and expect to see it return the value $1$.
Each thread then spawns a second ‘inner’ parallel region. Within this region we have each thread increment the value total. As there are $5$ threads in the outer region and $3$ threads in each inner region we expect the final value of this variable to be $15$.
If you use a serial implementation of the NAG library, regardless of whether the code is compiled with OpenMP or not, X06AGF will have no effect and X06AHF will always return $0$. The total number of threads will be $1$. The appropriate results file will be included with the distribution material for your implementation.

### 10.1  Program Text

Program Text (x06agfe.f90)

None.

### 10.3  Program Results

Program Results (x06agfe.r)