# NAG FL Interfacex06adf (get_​thread_​num)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

x06adf returns the OpenMP thread number of the calling thread.

## 2Specification

Fortran Interface
 Function x06adf ( )
 Integer :: x06adf
C Header Interface
#include <nag.h>
 Integer x06adf_ ()
The routine may be called by the names x06adf or nagf_omp_get_thread_num.

## 3Description

x06adf, for multithreaded implementations, returns the calling OpenMP thread's unique thread number within the current team. The master thread will always return $0$. The remaining threads will return a value between $1$ and the value returned by x06abf less $1$.
If this routine is called from a sequential part of a multithreaded program then it will return the value $0$.
In serial implementations of the NAG Library this routine will always return $0$. See the X06 Chapter Introduction for a discussion of the behaviour of these routines when called in serial.

## 4References

The OpenMP API Specification for Parallel Programming
Chapman B, Jost G and van der Pas R (2008) Using OpenMP Portable Shared Memory Parallel Programming The MIT Press

None.

None.

Not applicable.

## 8Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
x06adf is not threaded in any implementation.

None.

## 10Example

In this example we presume a multithreaded implementation of the NAG Library. We call x06adf both outside and inside an OpenMP active parallel region. Outside we expect a single thread to display the value $0$. Inside the region we use the value to have only the master thread display the result.
We also call x06aff inside and outside of the region. Outside we expect it to return $0$, as we are not in an active parallel region, and inside we expect to see the value $1$, indicating that the parallel region is an active one.
If you use a serial implementation of the NAG Library, regardless of whether the code is compiled with OpenMP or not, x06abf will always return $1$ and x06adf and x06aff will always return $0$. The appropriate results file will be included with the distribution material for your implementation.

### 10.1Program Text

Program Text (x06adfe.f90)

None.

### 10.3Program Results

Program Results (x06adfe.r)