get_thread_num returns the OpenMP thread number of the calling thread.

For full information please refer to the NAG Library document for x06ad


The returned OpenMP thread number of the calling thread.


get_thread_num, for multithreaded implementations, returns the calling OpenMP thread’s unique thread number within the current team. The master thread will always return . The remaining threads will return a value between and the value returned by get_num_threads() less .

If this function is called from a sequential part of a multithreaded program then it will return the value .

In serial implementations of the NAG Library this function will always return . See the X06 Introduction for a discussion of the behaviour of these functions when called in serial.


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