NAG AD Library
d03ra_a1w_f (dim2_gen_order2_rectangle_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

d03ra_a1w_f is the adjoint version of the primal routine d03raf.

2 Specification

Fortran Interface
Integer, Intent (In) :: npde, nx, ny, opti(4), lenrwk, leniwk, lenlwk, itrace
Integer, Intent (Inout) :: iwk(leniwk), ind, iuser(*), iwsav(20), ifail
Type (nagad_a1w_w_rtype), Intent (In) :: tout, xmin, xmax, ymin, ymax, tols, tolt, optr(3,npde)
Type (nagad_a1w_w_rtype), Intent (Inout) :: ts, dt(3), rwk(lenrwk), ruser(*), rwsav(25)
Logical, Intent (Inout) :: lwsav(5)
Logical, Intent (Out) :: lwk(lenlwk)
Type (c_ptr), Intent (Inout) :: ad_handle
External :: pdedef, bndary, pdeiv, monitr
C++ Header Interface
#include <nagad.h>
void d03ra_a1w_f_ ( void *&ad_handle, const Integer &npde, nagad_a1w_w_rtype &ts, const nagad_a1w_w_rtype &tout, nagad_a1w_w_rtype dt[], const nagad_a1w_w_rtype &xmin, const nagad_a1w_w_rtype &xmax, const nagad_a1w_w_rtype &ymin, const nagad_a1w_w_rtype &ymax, const Integer &nx, const Integer &ny, const nagad_a1w_w_rtype &tols, const nagad_a1w_w_rtype &tolt,
void (NAG_CALL pdedef)(void *&ad_handle, const Integer &npts, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype x[], const nagad_a1w_w_rtype y[], const nagad_a1w_w_rtype u[], const nagad_a1w_w_rtype ut[], const nagad_a1w_w_rtype ux[], const nagad_a1w_w_rtype uy[], const nagad_a1w_w_rtype uxx[], const nagad_a1w_w_rtype uxy[], const nagad_a1w_w_rtype uyy[], nagad_a1w_w_rtype res[], Integer iuser[], nagad_a1w_w_rtype ruser[]),
void (NAG_CALL bndary)(void *&ad_handle, const Integer &npts, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype x[], const nagad_a1w_w_rtype y[], const nagad_a1w_w_rtype u[], const nagad_a1w_w_rtype ut[], const nagad_a1w_w_rtype ux[], const nagad_a1w_w_rtype uy[], const Integer &nbpts, const Integer lbnd[], nagad_a1w_w_rtype res[], Integer iuser[], nagad_a1w_w_rtype ruser[]),
void (NAG_CALL pdeiv)(void *&ad_handle, const Integer &npts, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype x[], const nagad_a1w_w_rtype y[], nagad_a1w_w_rtype u[], Integer iuser[], nagad_a1w_w_rtype ruser[]),
void (NAG_CALL monitr)(void *&ad_handle, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype &dt, const nagad_a1w_w_rtype &dtnew, const logical &tlast, const Integer &nlev, const Integer ngpts[], const nagad_a1w_w_rtype xpts[], const nagad_a1w_w_rtype ypts[], const Integer lsol[], const nagad_a1w_w_rtype sol[], Integer &ierr, Integer iuser[], nagad_a1w_w_rtype ruser[]),
const Integer opti[], const nagad_a1w_w_rtype optr[], nagad_a1w_w_rtype rwk[], const Integer &lenrwk, Integer iwk[], const Integer &leniwk, logical lwk[], const Integer &lenlwk, const Integer &itrace, Integer &ind, logical lwsav[], Integer iwsav[], nagad_a1w_w_rtype rwsav[], Integer iuser[], nagad_a1w_w_rtype ruser[], Integer &ifail)
The routine may be called by the names d03ra_a1w_f or nagf_pde_dim2_gen_order2_rectangle_a1w. The corresponding t1w and p0w variants of this routine are also available.

3 Description

d03ra_a1w_f is the adjoint version of the primal routine d03raf.
d03raf integrates a system of linear or nonlinear, time-dependent partial differential equations (PDEs) in two space dimensions on a rectangular domain. The method of lines is employed to reduce the PDEs to a system of ordinary differential equations (ODEs) which are solved using a backward differentiation formula (BDF) method. The resulting system of nonlinear equations is solved using a modified Newton method and a Bi-CGSTAB iterative linear solver with ILU preconditioning. Local uniform grid refinement is used to improve the accuracy of the solution. d03raf originates from the VLUGR2 package (see Blom and Verwer (1993) and Blom et al. (1996)). For further information see Section 3 in the documentation for d03raf.

4 References

Adjerid S and Flaherty J E (1988) A local refinement finite element method for two-dimensional parabolic systems SIAM J. Sci. Statist. Comput. 9 792–811
Blom J G, Trompert R A and Verwer J G (1996) Algorithm 758. VLUGR2: A vectorizable adaptive grid solver for PDEs in 2D Trans. Math. Software 22 302–328
Blom J G and Verwer J G (1993) VLUGR2: A vectorized local uniform grid refinement code for PDEs in 2D Report NM-R9306 CWI, Amsterdam
Brown P N, Hindmarsh A C and Petzold L R (1994) Using Krylov methods in the solution of large scale differential-algebraic systems SIAM J. Sci. Statist. Comput. 15 1467–1488
Trompert R A (1993) Local uniform grid refinement and systems of coupled partial differential equations Appl. Numer. Maths 12 331–355
Trompert R A and Verwer J G (1993) Analysis of the implicit Euler local uniform grid refinement method SIAM J. Sci. Comput. 14 259–278

5 Arguments

In addition to the arguments present in the interface of the primal routine, d03ra_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: npde – Integer Input
3: tsType (nagad_a1w_w_rtype) Input/Output
4: toutType (nagad_a1w_w_rtype) Input
5: dt(3) – Type (nagad_a1w_w_rtype) array Input/Output
6: xminType (nagad_a1w_w_rtype) Input
7: xmaxType (nagad_a1w_w_rtype) Input
8: yminType (nagad_a1w_w_rtype) Input
9: ymaxType (nagad_a1w_w_rtype) Input
10: nx – Integer Input
11: ny – Integer Input
12: tolsType (nagad_a1w_w_rtype) Input
13: toltType (nagad_a1w_w_rtype) Input
14: pdedef – Subroutine External Procedure
The specification of pdedef is:
Fortran Interface
Subroutine pdedef ( ad_handle, npts, npde, t, x, y, u, ut, ux, uy, uxx, uxy, uyy, res, iuser, ruser)
Integer, Intent (In) :: npts, npde
Integer, Intent (Inout) :: iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: t, x(npts), y(npts), u(npts,npde), ut(npts,npde), ux(npts,npde), uy(npts,npde), uxx(npts,npde), uxy(npts,npde), uyy(npts,npde)
Type (nagad_a1w_w_rtype), Intent (Inout) :: ruser(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: res(npts,npde)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void pdedef ( void *&ad_handle, const Integer &npts, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype x[], const nagad_a1w_w_rtype y[], const nagad_a1w_w_rtype u[], const nagad_a1w_w_rtype ut[], const nagad_a1w_w_rtype ux[], const nagad_a1w_w_rtype uy[], const nagad_a1w_w_rtype uxx[], const nagad_a1w_w_rtype uxy[], const nagad_a1w_w_rtype uyy[], nagad_a1w_w_rtype res[], Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: npts – Integer Input
3: npde – Integer Input
4: tType (nagad_a1w_w_rtype) Input
5: xType (nagad_a1w_w_rtype) array Input
6: yType (nagad_a1w_w_rtype) array Input
7: uType (nagad_a1w_w_rtype) array Input
8: utType (nagad_a1w_w_rtype) array Input
9: uxType (nagad_a1w_w_rtype) array Input
10: uyType (nagad_a1w_w_rtype) array Input
11: uxxType (nagad_a1w_w_rtype) array Input
12: uxyType (nagad_a1w_w_rtype) array Input
13: uyyType (nagad_a1w_w_rtype) array Input
14: resType (nagad_a1w_w_rtype) array Output
15: iuser(*) – Integer array User Workspace
16: ruser(*)Type (nagad_a1w_w_rtype) array User Workspace
15: bndary – Subroutine External Procedure
The specification of bndary is:
Fortran Interface
Subroutine bndary ( ad_handle, npts, npde, t, x, y, u, ut, ux, uy, nbpts, lbnd, res, iuser, ruser)
Integer, Intent (In) :: npts, npde, nbpts, lbnd(nbpts)
Integer, Intent (Inout) :: iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: t, x(npts), y(npts), u(npts,npde), ut(npts,npde), ux(npts,npde), uy(npts,npde)
Type (nagad_a1w_w_rtype), Intent (Inout) :: res(npts,npde), ruser(*)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void bndary ( void *&ad_handle, const Integer &npts, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype x[], const nagad_a1w_w_rtype y[], const nagad_a1w_w_rtype u[], const nagad_a1w_w_rtype ut[], const nagad_a1w_w_rtype ux[], const nagad_a1w_w_rtype uy[], const Integer &nbpts, const Integer lbnd[], nagad_a1w_w_rtype res[], Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: npts – Integer Input
3: npde – Integer Input
4: tType (nagad_a1w_w_rtype) Input
5: xType (nagad_a1w_w_rtype) array Input
6: yType (nagad_a1w_w_rtype) array Input
7: uType (nagad_a1w_w_rtype) array Input
8: utType (nagad_a1w_w_rtype) array Input
9: uxType (nagad_a1w_w_rtype) array Input
10: uyType (nagad_a1w_w_rtype) array Input
11: nbpts – Integer Input
12: lbnd – Integer array Input
13: resType (nagad_a1w_w_rtype) array Input/Output
14: iuser(*) – Integer array User Workspace
15: ruser(*)Type (nagad_a1w_w_rtype) array User Workspace
16: pdeiv – Subroutine External Procedure
The specification of pdeiv is:
Fortran Interface
Subroutine pdeiv ( ad_handle, npts, npde, t, x, y, u, iuser, ruser)
Integer, Intent (In) :: npts, npde
Integer, Intent (Inout) :: iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: t, x(npts), y(npts)
Type (nagad_a1w_w_rtype), Intent (Inout) :: ruser(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: u(npts,npde)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void pdeiv ( void *&ad_handle, const Integer &npts, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype x[], const nagad_a1w_w_rtype y[], nagad_a1w_w_rtype u[], Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: npts – Integer Input
3: npde – Integer Input
4: tType (nagad_a1w_w_rtype) Input
5: xType (nagad_a1w_w_rtype) array Input
6: yType (nagad_a1w_w_rtype) array Input
7: uType (nagad_a1w_w_rtype) array Output
8: iuser(*) – Integer array User Workspace
9: ruser(*)Type (nagad_a1w_w_rtype) array User Workspace
17: monitr – Subroutine External Procedure
The specification of monitr is:
Fortran Interface
Subroutine monitr ( ad_handle, npde, t, dt, dtnew, tlast, nlev, ngpts, xpts, ypts, lsol, sol, ierr, iuser, ruser)
Integer, Intent (In) :: npde, nlev, ngpts(nlev), lsol(nlev)
Integer, Intent (Inout) :: ierr, iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: t, dt, dtnew, xpts(*), ypts(*), sol(*)
Type (nagad_a1w_w_rtype), Intent (Inout) :: ruser(*)
Logical, Intent (In) :: tlast
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void monitr ( void *&ad_handle, const Integer &npde, const nagad_a1w_w_rtype &t, const nagad_a1w_w_rtype &dt, const nagad_a1w_w_rtype &dtnew, const logical &tlast, const Integer &nlev, const Integer ngpts[], const nagad_a1w_w_rtype xpts[], const nagad_a1w_w_rtype ypts[], const Integer lsol[], const nagad_a1w_w_rtype sol[], Integer &ierr, Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: npde – Integer Input
3: tType (nagad_a1w_w_rtype) Input
4: dtType (nagad_a1w_w_rtype) Input
5: dtnewType (nagad_a1w_w_rtype) Input
6: tlast – logical Input
7: nlev – Integer Input
8: ngpts – Integer array Input
9: xptsType (nagad_a1w_w_rtype) array Input
10: yptsType (nagad_a1w_w_rtype) array Input
11: lsol – Integer array Input
12: solType (nagad_a1w_w_rtype) array Input
13: ierr – Integer Input/Output
14: iuser(*) – Integer array User Workspace
15: ruser(*)Type (nagad_a1w_w_rtype) array User Workspace
18: opti(4) – Integer array Input
19: optr(3, npde) – Type (nagad_a1w_w_rtype) array Input
20: rwk(lenrwk) – Type (nagad_a1w_w_rtype) array Communication Array
21: lenrwk – Integer Input
22: iwk(leniwk) – Integer array Communication Array
23: leniwk – Integer Input
24: lwk(lenlwk) – logical array Workspace
25: lenlwk – Integer Input
26: itrace – Integer Input
27: ind – Integer Input/Output
28: lwsav(5) – logical array Communication Array
Communication Array.
29: iwsav(20) – Integer array Communication Array
Communication Array.
30: rwsav(25) – Type (nagad_a1w_w_rtype) array Communication Array
Communication Array.
31: iuser(*) – Integer array User Workspace
User workspace.
32: ruser(*) – Type (nagad_a1w_w_rtype) array User Workspace
User workspace.
33: ifail – Integer Input/Output

6 Error Indicators and Warnings

d03ra_a1w_f preserves all error codes from d03raf 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

d03ra_a1w_f is not threaded in any implementation.

9 Further Comments

None.

10 Example

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

10.1 Adjoint mode (a1w)

LanguageSource FileDataResults
Fortrand03ra_a1w_fe.f90d03ra_a1w_fe.dd03ra_a1w_fe.r

10.2 Passive mode (p0w)

LanguageSource FileDataResults
Fortrand03ra_p0w_fe.f90d03ra_p0w_fe.dd03ra_p0w_fe.r