NAG AD Library
d02bj_a1w_f (ivp_rk_zero_simple_a1w)

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. Additionally, the p0w (passive interface, as alternative to the FL interface) mode is available and can be inferred by replacing of active types by the corresponding passive types. The method of codifying AD implementations in the routine name and corresponding argument types is described in the NAG AD Library Introduction.
Settings help

AD Name Style:


AD Specification Language:

1 Purpose

d02bj_a1w_f is the adjoint version of the primal routine d02bjf.

2 Specification

Fortran Interface
Subroutine d02bj_a1w_f ( ad_handle, x, xend, n, y, fcn, tol, relabs, output, g, w, ifail)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: ifail
External :: g, fcn, output
Type (nagad_a1w_w_rtype), Intent (In) :: xend, tol
Type (nagad_a1w_w_rtype), Intent (Inout) :: x, y(n)
Type (nagad_a1w_w_rtype), Intent (Out) :: w(20*n)
Character (1), Intent (In) :: relabs
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void d02bj_a1w_f_ ( void *&ad_handle, nagad_a1w_w_rtype &x, const nagad_a1w_w_rtype &xend, const Integer &n, nagad_a1w_w_rtype y[],
void (NAG_CALL fcn)(void *&ad_handle, const nagad_a1w_w_rtype &x, const nagad_a1w_w_rtype y[], nagad_a1w_w_rtype f[]),
const nagad_a1w_w_rtype &tol, const char *relabs,
void (NAG_CALL output)(void *&ad_handle, nagad_a1w_w_rtype &xsol, const nagad_a1w_w_rtype y[]),
void (NAG_CALL g)(void *&ad_handle, const nagad_a1w_w_rtype &x, const nagad_a1w_w_rtype y[], nagad_a1w_w_rtype &retval),
nagad_a1w_w_rtype w[], Integer &ifail, const Charlen length_relabs)
The routine may be called by the names d02bj_a1w_f or nagf_ode_ivp_rk_zero_simple_a1w. The corresponding t1w and p0w variants of this routine are also available.

3 Description

d02bj_a1w_f is the adjoint version of the primal routine d02bjf.
d02bjf integrates a system of first-order ordinary differential equations over an interval with suitable initial conditions, using a fixed order Runge–Kutta method, until a user-specified function, if supplied, of the solution is zero, and returns the solution at points specified by you, if desired. For further information see Section 3 in the documentation for d02bjf.

4 References

Shampine L F (1994) Numerical solution of ordinary differential equations Chapman and Hall

5 Arguments

In addition to the arguments present in the interface of the primal routine, d02bj_a1w_f includes some arguments specific to AD.
A brief summary of the AD specific arguments is given below. For the remainder, links are provided to the corresponding argument from the primal routine. A tooltip popup for all arguments can be found by hovering over the argument name in Section 2 and in this section.
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object, as created by x10aa_a1w_f.
2: xType (nagad_a1w_w_rtype) Input/Output
3: xendType (nagad_a1w_w_rtype) Input
4: n – Integer Input
5: y(n) – Type (nagad_a1w_w_rtype) array Input/Output
6: fcn – Subroutine External Procedure
The specification of fcn is:
Fortran Interface
Subroutine fcn ( ad_handle, x, y, f)
Type (nagad_a1w_w_rtype), Intent (In) :: x, y(*)
Type (nagad_a1w_w_rtype), Intent (Inout) :: f(*)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void fcn ( void *&ad_handle, const nagad_a1w_w_rtype &x, const nagad_a1w_w_rtype y[], nagad_a1w_w_rtype f[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: xType (nagad_a1w_w_rtype) Input
3: yType (nagad_a1w_w_rtype) array Input
4: fType (nagad_a1w_w_rtype) array Output
7: tolType (nagad_a1w_w_rtype) Input
8: relabs – character Input
9: output – Subroutine External Procedure
The specification of output is:
Fortran Interface
Subroutine output ( ad_handle, xsol, y)
Type (nagad_a1w_w_rtype), Intent (In) :: y(*)
Type (nagad_a1w_w_rtype), Intent (Inout) :: xsol
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void output ( void *&ad_handle, nagad_a1w_w_rtype &xsol, const nagad_a1w_w_rtype y[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: xsolType (nagad_a1w_w_rtype) Input/Output
3: yType (nagad_a1w_w_rtype) array Input
10: g – Subroutine External Procedure
Note that g is a subroutine in this interface, returning the function value via the additional output parameter retval.
The specification of g is:
Fortran Interface
Subroutine g ( ad_handle, x, y, retval)
Type (nagad_a1w_w_rtype), Intent (In) :: x, y(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: retval
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void g ( void *&ad_handle, const nagad_a1w_w_rtype &x, const nagad_a1w_w_rtype y[], nagad_a1w_w_rtype &retval)
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: xType (nagad_a1w_w_rtype) Input
3: yType (nagad_a1w_w_rtype) array Input
4: retvalType (nagad_a1w_w_rtype) Output
On exit: the value of g(x,y) at the specified point.
11: w(20×n) – Type (nagad_a1w_w_rtype) array Workspace
12: ifail – Integer Input/Output

6 Error Indicators and Warnings

d02bj_a1w_f preserves all error codes from d02bjf and in addition can return:
ifail=-89
An unexpected AD error has been triggered by this routine. Please contact NAG.
See Section 4.8.2 in the NAG AD Library Introduction for further information.
ifail=-899
Dynamic memory allocation failed for AD.
See Section 4.8.1 in the NAG AD Library Introduction for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

d02bj_a1w_f is not threaded in any implementation.

9 Further Comments

None.

10 Example

The following examples are variants of the example for d02bjf, modified to demonstrate calling the NAG AD Library.

10.1 Adjoint mode (a1w)

LanguageSource FileDataResults
Fortrand02bj_a1w_fe.f90d02bj_a1w_fe.dd02bj_a1w_fe.r
C++d02bj_a1w_hcppe.cppNoned02bj_a1w_hcppe.r

10.2 Tangent mode (t1w)

LanguageSource FileDataResults
Fortrand02bj_t1w_fe.f90d02bj_t1w_fe.dd02bj_t1w_fe.r
C++d02bj_t1w_hcppe.cppNoned02bj_t1w_hcppe.r

10.3 Passive mode (p0w)

LanguageSource FileDataResults
Fortrand02bj_p0w_fe.f90d02bj_p0w_fe.dd02bj_p0w_fe.r
C++d02bj_p0w_hcppe.cppNoned02bj_p0w_hcppe.r