X06AAF (PDF version)
X06 Chapter Contents
X06 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

X06AAF

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.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

X06AAF sets the number of threads requested for subsequent OpenMP parallel regions.

2  Specification

SUBROUTINE X06AAF ( NUM, IFAIL)
INTEGER  NUM, IFAIL

3  Description

X06AAF, for multi-threaded implementations, sets the number of threads to be requested for subsequent parallel regions to NUM. The first element of the list held by the OpenMP Internal Control Variable (ICV) used in determining the number of threads is set. See the Users' Note for your implementation for details of the scope of this routine.
The number of threads used in parallel regions will be equal to, or less than, the value of the ICV. The actual number of threads used is dependent on several factors, such as the presence of a num_threads clause on the parallel directive or the number of threads already in use by the program. Please refer to Section 4 for a full description of how the number of threads is chosen for a particular parallel region.
In serial implementations of the NAG Library this routine has no effect. See the X06 Chapter Introduction 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:     NUM – INTEGERInput
On entry: the number of threads requested for subsequent OpenMP parallel regions.
Constraint: NUM1.
2:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, NUM=value.
Constraint: NUM1.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

X06AAF is not threaded in any implementation.

9  Further Comments

None.

10  Example

In this example we presume a multi-threaded implementation of the NAG Library. We set the OpenMP Internal Control Variable used in determining the number of threads to 5 with a call to X06AAF and retrieve it again with X06ACF.
We then, using X06ABF, display the number of threads in use both outside, and inside, the OpenMP parallel region.
We expect to see X06ABF returning 1 outside of the parallel region, as the current team of threads there will consist of a single thread, and 5 from within it.
If you use a serial implementation of the NAG Library, regardless of whether the code is compiled with OpenMP or not, calling X06AAF has no effect and X06ABF and X06ACF will always return 1. The appropriate results file will be included with the distribution material for your implementation.

10.1  Program Text

Program Text (x06aafe.f90)

10.2  Program Data

None.

10.3  Program Results

Program Results (x06aafe.r)


X06AAF (PDF version)
X06 Chapter Contents
X06 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016