# NAG Library Routine Document

## 1Purpose

x04aaf returns the value of the current error message unit number, or sets the current error message unit number to a new value.

## 2Specification

Fortran Interface
 Subroutine x04aaf ( nerr)
 Integer, Intent (In) :: iflag Integer, Intent (Inout) :: nerr
#include nagmk26.h
 void x04aaf_ ( const Integer *iflag, Integer *nerr)

## 3Description

x04aaf enables those library routines which output error messages, to determine the number of the output unit to which the error messages are to be sent; in this case x04aaf is called with ${\mathbf{iflag}}=0$. x04aaf may also be called with ${\mathbf{iflag}}=1$ to set the unit number to a specified value. Otherwise a default value (stated in the Users' Note for your implementation) is returned.
Records written to this output unit by other library routines are at most $80$ characters long (including a line-printer carriage control character).
Note that if the unit number is set $\text{}<0$, no messages will be output.

None.

## 5Arguments

1:     $\mathbf{iflag}$ – IntegerInput
On entry: the action to be taken (see nerr).
Constraint: ${\mathbf{iflag}}=0$ or $1$.
2:     $\mathbf{nerr}$ – IntegerInput/Output
On entry: if ${\mathbf{iflag}}=0$, nerr need not be set.
If ${\mathbf{iflag}}=1$, nerr must specify the new error message unit number.
On exit: if ${\mathbf{iflag}}=0$, nerr is set to the current error message unit number.
If ${\mathbf{iflag}}=1$, nerr is unchanged.
Note that Fortran unit numbers must be positive or zero. If nerr is set $\text{}<0$, output of error messages is totally suppressed. It is important to note that if you supply an illegal value for nerr (such as a unit number associated with a file opened for reading instead of writing) then x04aaf cannot detect that fact, but any output sent to the unit by later calls of NAG routines may have undesirable consequences, such as program crashes.

None.

Not applicable.

## 8Parallelism and Performance

x04aaf is not thread safe and should not be called from a multithreaded user program. Please see Section 3.12.1 in How to Use the NAG Library and its Documentation for more information on thread safety.
x04aaf is not threaded in any implementation.

The time taken by x04aaf is negligible.

## 10Example

In this example x04aaf is called by your main program to make the error message from the routine DUMMY appear on the same unit as the rest of the output (unit $6$). Normally a NAG Library routine with an IFAIL argument (see Section 3.4.2 in How to Use the NAG Library and its Documentation) would take the place of DUMMY.

### 10.1Program Text

Program Text (x04aafe.f90)

None.

### 10.3Program Results

Program Results (x04aafe.r)

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