NAG Library Routine Document

x10aa_a1w_f (config_handle_create_a1w)

1
Purpose

x10aa_a1w_f initializes a configuration data structure for the NAG AD Library. It must be called prior to the first call to any routine from the NAG AD Library as listed in the NAG AD Library Introduction including any other routine in Chapter X10.

2
Specification

Fortran Interface
Subroutine x10aa_a1w_f ( ad_handle, ifail)
Integer, Intent (Inout):: ifail
Type (c_ptr), Intent (Out):: ad_handle
C++ Header Interface
#include <nagad.h>
extern "C" {
void  x10aa_a1w_f_ (void *&ad_handle, Integer &ifail)
}
VBA (Long integers) Header Interface
Declare PtrSafe Sub X10AAF Lib "libname" ( _
    ad_handle As LongPtr, ifail As Long)

3
Description

x10aa_a1w_f creates and initializes a configuration data object and returns a handle to the data object. This handle may then be passed to any routine in the NAG AD Library as listed in the NAG AD Library Introduction. The object must always be destroyed by a call to x10ab_a1w_f prior to exiting the application in which it was created.
The returned handle can also be passed to x10ac_a1w_f and x10ad_a1w_f to repectively set and get the algorithmic mode (see the X10 Chapter Introduction).

3.1
Life 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.
The handle is then passed to the computational routines of the NAG AD Library.
Note that separate configuration data objects can be initialized to contain different computational modes; for example, one handle for the symbolic computational mode (to be used when symbolic adjoints are possible and required) and one handle to contain the algorithmic computational mode.
When all AD computation is completed, the handle must be destroyed by x10ab_a1w_f.

4
References

None.

5
Arguments

1:     ad_handle – Type (c_ptr)Output
Note: ad_handle does not need to be set on input.
On exit: holds a handle to the internal data structure where the computational AD configuration data, e.g., mode, is defined. You must not change the handle other than via NAG AD Library calls until it is destroyed by x10ab_a1w_f.
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=-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

x10aa_a1w_f is not threaded in any implementation.

9
Further Comments

None.

10
Example

The following examples show the procedure for calling a NAG AD Library routine (s01ba_a1w_f). x10aa_a1w_f is called to initialize the ad_handle; x10ac_a1w_f and x10ad_a1w_f are called to set and get the computational mode from the handle; and x10ab_a1w_f is called to destroy the handle.
Language Source File Data Results
Fortan x10aa_a1w_fe.f90 None x10aa_a1w_fe.r
C++ x10aa_a1w_hcppe.cpp None x10aa_a1w_hcppe.r
C x10aa_a1w_hce.c None x10aa_a1w_hce.r