Note: a1w denotes that first order adjoints are computed in working precision; this has the corresponding argument type nagad_a1w_w_rtype. Also available is the t1w (first order tangent linear) mode, the interface of which is implied by replacing a1w by t1w throughout this document. The method of codifying AD implementations in the routine name and corresponding argument types is described in the NAG AD Library Introduction.

Settings help

## 1Purpose

x10ac_a1w_f sets the computational mode in a configuration data structure for the NAG AD Library as created by a prior call to x10aa_a1w_f. The full set of computational modes currently available are: nagad_algorithmic and nagad_symbolic.

## 2Specification

Fortran Interface
 Subroutine x10ac_a1w_f ( mode,
 Integer, Intent (In) :: mode Integer, Intent (Inout) :: ifail Type (c_ptr), Intent (Inout) :: ad_handle
extern "C" {
 void x10ac_a1w_f_ (void *&ad_handle, const Integer &mode, Integer &ifail)
}
The routine may be called by the names x10ac_a1w_f or nagf_adutils_config_mode_set_a1w. The corresponding t1w variant of this routine is also available.

## 3Description

x10ac_a1w_f sets the computational mode of differentiation in the configuration data object. This handle may then be passed to any computational routine in the NAG AD Library as listed in the Introduction to the NAG AD Library. The computational mode can be changed between calls to computational routines in the NAG AD Library. The computational modes currently available are nagad_algorithmic and nagad_symbolic. See mode. This routine must be called after a call to x10aa_a1w_f (to create a handle to the configuration data object) and prior to the call of the computational NAG AD Library routines for which the mode is set.

### 3.1Life Cycle of the Handle

Each handle should pass four stages in its life: initialization; mode setting; problem solution using the NAG AD Library; and, destruction.
The initialization by x10aa_a1w_f and destruction by x10ab_a1w_f mark the beginning and the end of the life of the handle. During this time the handle must only be modified by NAG AD Library routines. Working with a handle which has not been properly initialized is potentially very dangerous as it may cause unpredictable behaviour.
After the handle has been initialized, two routines are provided to set or get the computational mode to be used in algorithmic differentiation. x10ac_a1w_f sets the computational mode and x10ad_a1w_f gets the computational mode.
The handle is then passed to the computational routines of the NAG AD Library. The computational mode can be changed, where appropriate, between calls to computational routines.
When all AD computation is completed, the handle must be destroyed by x10ab_a1w_f.

None.

## 5Arguments

1: $\mathbf{ad_handle}$Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object, as created by x10aa_a1w_f.
On exit: holds a handle to the internal data structure where the computational mode was changed according to mode. You must not change the handle other than via NAG AD Library calls until it is destroyed by x10ab_a1w_f.
2: $\mathbf{mode}$Integer Input
On entry: the computational mode to be used in subsequent calls to NAG AD Library computational routines.
The mode nag_algorithmic is available to all computational routines; this means that differentiation of the primal algorithm (e.g., calculating adjoints) is performed by code, converted and instrumented from the primal code.
The mode nag_symbolic is only available for the subset of computational routines listed in Section 3.2.2 in the X10 Chapter Introduction; these have been hand-coded using knowledge of the differentials of the primal algorithm.
Constraint: ${\mathbf{mode}}=\mathit{nag_algorithmic}$ or $\mathit{nag_symbolic}$.
3: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry: ad_handle is not a valid handle for the AD computational data object. Either ad_handle has not been initialized or it has become corrupted.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{mode}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mode}}=\mathit{nag_algorithmic}$ or $\mathit{nag_symbolic}$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

x10ac_a1w_f is not threaded in any implementation.