NAG AD Library
x10bc_a1w_f (callback_mode_set_a1w)
1
Purpose
x10bc_a1w_f sets the callback 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 callback computational modes currently available are:
nagad_primal,
nagad_dstate,
nagad_dparam and
nagad_dall.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
mode |
Integer, Intent (Inout) |
:: |
ifail |
Type (c_ptr), Intent (Inout) |
:: |
ad_handle |
|
C++ Header Interface
#include <nagad.h> extern "C" {
}
|
The routine may be called by the names x10bc_a1w_f or nagf_adutils_callback_mode_set_a1w.
3
Description
x10bc_a1w_f sets the callback computational mode within a supplied procedure argument to a NAG AD Library routine. The callback mode is stored in the configuration data object as created by
x10aa_a1w_f via a handle, and that handle is passed as first argument to any procedure argument.
Generally there is no need to set the callback computational mode using
x10bc_a1w_f; rather, the callback computational mode is supplied to a procedure argument via the computational data object (
ad_handle) and this callback mode can be extracted using
x10bd_a1w_f. The mode determines what form of calculation must be performed by the procedure argument.
Please refer to
x10bd_a1w_f for details on how to obtain the callback computational mode for a given procedure argument and what computations to perform in each case.
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.
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.
During a call to a NAG AD Library routine that contains a procedure argument, a call back to that procedure argument will contain the callback computational mode within the computational data object (
ad_handle). This mode can be obtained by a call to
x10bd_a1w_f. The computation to be performed within the supplied procedure argument will be based on the value obtained for this mode.
When all AD computation is completed, the handle must be destroyed by
x10ab_a1w_f.
4
References
None.
5
Arguments
-
1:
– 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 AD configuration data, is defined. You
must not change the handle other than via NAG AD Library calls until it is destroyed by
x10ab_a1w_f.
-
2:
– Integer
Input
-
On entry: the callback computational mode within the current supplied procedure argument.
- The current callback is expected to perform the primal calculation.
- The current callback is expected to return the derivatives of the primal calculation with respect to real-valued input arguments.
- The current callback is expected to return the derivatives of the primal calculation with respect to user-supplied real-valued inputs (e.g., in ruser).
- The current callback is expected to return derivatives of the primal calculation with respect to both active input arguments and active supplied parameters (i.e., combining nagad_dstate and nagad_dparam).
Constraint:
, , or .
-
3:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
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.
-
On entry, .
Constraint: , , or .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
x10bc_a1w_f is not threaded in any implementation.
None.
10
Example
None.