D03 Chapter Contents
D03 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD03RAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

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)).

## 2  Specification

 SUBROUTINE D03RAF ( NPDE, TS, TOUT, DT, XMIN, XMAX, YMIN, YMAX, NX, NY, TOLS, TOLT, PDEDEF, BNDARY, PDEIV, MONITR, OPTI, OPTR, RWK, LENRWK, IWK, LENIWK, LWK, LENLWK, ITRACE, IND, IFAIL)
 INTEGER NPDE, NX, NY, OPTI(4), LENRWK, IWK(LENIWK), LENIWK, LENLWK, ITRACE, IND, IFAIL REAL (KIND=nag_wp) TS, TOUT, DT(3), XMIN, XMAX, YMIN, YMAX, TOLS, TOLT, OPTR(3,NPDE), RWK(LENRWK) LOGICAL LWK(LENLWK) EXTERNAL PDEDEF, BNDARY, PDEIV, MONITR

## 3  Description

D03RAF integrates the system of PDEs:
 $Fjt,x,y,u,ut,ux,uy,uxx,uxy,uyy=0, j=1,2,…,NPDE,$ (1)
for $x$ and $y$ in the rectangular domain ${x}_{\mathrm{min}}\le x\le {x}_{\mathrm{max}}$, ${y}_{\mathrm{min}}\le y\le {y}_{\mathrm{max}}$, and time interval ${t}_{0}\le t\le {t}_{\mathrm{out}}$, where the vector $u$ is the set of solution values
 $ux,y,t=u1x,y,t,…,uNPDEx,y,tT,$
and ${u}_{t}$ denotes partial differentiation with respect to $t$, and similarly for ${u}_{x}$ etc.
The functions ${F}_{j}$ must be supplied by you in PDEDEF. Similarly the initial values of the functions $u\left(x,y,t\right)$ must be specified at $t={t}_{0}$ in PDEIV.
Note that whilst complete generality is offered by the master equations (1), D03RAF is not appropriate for all PDEs. In particular, hyperbolic systems should not be solved using this routine. Also, at least one component of ${u}_{t}$ must appear in the system of PDEs.
The boundary conditions must be supplied by you in BNDARY in the form
 $Gj t,x,y,u,ut,ux,uy = 0 ,$ (2)
for all $y$ when ${x}_{\mathrm{min}}$ or ${x}_{\mathrm{max}}$ and for all $x$ when $y={y}_{\mathrm{min}}$ or $y={y}_{\mathrm{max}}$ and $j=1,2,\dots ,{\mathbf{NPDE}}$
The domain is covered by a uniform coarse base grid of size ${n}_{x}×{n}_{y}$ specified by you, and nested finer uniform subgrids are subsequently created in regions with high spatial activity. The refinement is controlled using a space monitor which is computed from the current solution and a user-supplied space tolerance TOLS. A number of optional parameters, e.g., the maximum number of grid levels at any time, and some weighting factors, can be specified in the arrays OPTI and OPTR. Further details of the refinement strategy can be found in Section 8.
The system of PDEs and the boundary conditions are discretized in space on each grid using a standard second-order finite difference scheme (centred on the internal domain and one-sided at the boundaries), and the resulting system of ODEs is integrated in time using a second-order, two-step, implicit BDF method with variable step size. The time integration is controlled using a time monitor computed at each grid level from the current solution and a user-supplied time tolerance TOLT, and some further optional user-specified weighting factors held in OPTR (see Section 8 for details). The time monitor is used to compute a new step size, subject to restrictions on the size of the change between steps, and (optional) user-specified maximum and minimum step sizes held in DT. The step size is adjusted so that the remaining integration interval is an integer number times $\Delta t$. In this way a solution is obtained at $t={t}_{\mathrm{out}}$.
A modified Newton method is used to solve the nonlinear equations arising from the time integration. You may specify (in OPTI) the maximum number of Newton iterations to be attempted. A Jacobian matrix is calculated at the beginning of each time step. If the Newton process diverges or the maximum number of iterations is exceeded, a new Jacobian is calculated using the most recent iterates and the Newton process is restarted. If convergence is not achieved after the (optional) user-specified maximum number of new Jacobian evaluations, the time step is retried with $\Delta t=\Delta t/4$. The linear systems arising from the Newton iteration are solved using a Bi-CGSTAB iterative method, in combination with ILU preconditioning. The maximum number of iterations can be specified by you in OPTI.
The solution at all grid levels is stored in the workspace arrays, along with other information needed for a restart (i.e., a continuation call). It is not intended that you extract the solution from these arrays, indeed the necessary information regarding these arrays is not included. The user-supplied monitor MONITR should be used to obtain the solution at particular levels and times. MONITR is called at the end of every time step, with the last step being identified via the input parameter TLAST.
Within PDEIV, PDEDEF, BNDARY and MONITR the data structure is as follows. Each point on a particular grid is given an index (ranging from $1$ to the total number of points on the grid) and all coordinate or solution information is stored in arrays according to this index, e.g., ${\mathbf{X}}\left(i\right)$ and ${\mathbf{Y}}\left(i\right)$ contain the $x$- and $y$ coordinate of point $i$, and ${\mathbf{U}}\left(i,j\right)$ contains the $j$th solution component ${u}_{j}$ at point $i$.
Further details of the underlying algorithm can be found in Section 8 and in Blom and Verwer (1993) and Blom et al. (1996) and the references therein.

## 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  Parameters

1:     NPDE – INTEGERInput
On entry: the number of PDEs in the system.
Constraint: ${\mathbf{NPDE}}\ge 1$.
2:     TS – REAL (KIND=nag_wp)Input/Output
On entry: the initial value of the independent variable $t$.
On exit: the value of $t$ which has been reached. Normally ${\mathbf{TS}}={\mathbf{TOUT}}$.
Constraint: ${\mathbf{TS}}<{\mathbf{TOUT}}$.
3:     TOUT – REAL (KIND=nag_wp)Input
On entry: the final value of $t$ to which the integration is to be carried out.
4:     DT($3$) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the initial, minimum and maximum time step sizes respectively.
${\mathbf{DT}}\left(1\right)$
Specifies the initial time step size to be used on the first entry, i.e., when ${\mathbf{IND}}=0$. If ${\mathbf{DT}}\left(1\right)=0.0$ then the default value ${\mathbf{DT}}\left(1\right)=0.01×\left({\mathbf{TOUT}}-{\mathbf{TS}}\right)$ is used. On subsequent entries (${\mathbf{IND}}=1$), the value of ${\mathbf{DT}}\left(1\right)$ is not referenced.
${\mathbf{DT}}\left(2\right)$
Specifies the minimum time step size to be attempted by the integrator. If ${\mathbf{DT}}\left(2\right)=0.0$ the default value  is used.
${\mathbf{DT}}\left(3\right)$
Specifies the maximum time step size to be attempted by the integrator. If ${\mathbf{DT}}\left(3\right)=0.0$ the default value ${\mathbf{DT}}\left(3\right)={\mathbf{TOUT}}-{\mathbf{TS}}$ is used.
On exit: ${\mathbf{DT}}\left(1\right)$ contains the time step size for the next time step. ${\mathbf{DT}}\left(2\right)$ and ${\mathbf{DT}}\left(3\right)$ are unchanged or set to their default values if zero on entry.
Constraints:
• if ${\mathbf{IND}}=0$, ${\mathbf{DT}}\left(1\right)\ge 0.0$;
• if ${\mathbf{IND}}=0$ and ${\mathbf{DT}}\left(1\right)>0.0$,  and ${\mathbf{DT}}\left(2\right)\le {\mathbf{DT}}\left(1\right)\le {\mathbf{DT}}\left(3\right)$, where the values of ${\mathbf{DT}}\left(2\right)$ and ${\mathbf{DT}}\left(3\right)$ will have been reset to their default values if zero on entry;
• $0\le {\mathbf{DT}}\left(2\right)\le {\mathbf{DT}}\left(3\right)$.
5:     XMIN – REAL (KIND=nag_wp)Input
6:     XMAX – REAL (KIND=nag_wp)Input
On entry: the extents of the rectangular domain in the $x$-direction, i.e., the $x$ coordinates of the left and right boundaries respectively.
Constraint: ${\mathbf{XMIN}}<{\mathbf{XMAX}}$ and XMAX must be sufficiently distinguishable from XMIN for the precision of the machine being used.
7:     YMIN – REAL (KIND=nag_wp)Input
8:     YMAX – REAL (KIND=nag_wp)Input
On entry: the extents of the rectangular domain in the $y$-direction, i.e., the $y$ coordinates of the lower and upper boundaries respectively.
Constraint: ${\mathbf{YMIN}}<{\mathbf{YMAX}}$ and YMAX must be sufficiently distinguishable from YMIN for the precision of the machine being used.
9:     NX – INTEGERInput
On entry: the number of grid points in the $x$-direction (including the boundary points).
Constraint: ${\mathbf{NX}}\ge 4$.
10:   NY – INTEGERInput
On entry: the number of grid points in the $y$-direction (including the boundary points).
Constraint: ${\mathbf{NY}}\ge 4$.
11:   TOLS – REAL (KIND=nag_wp)Input
On entry: the space tolerance used in the grid refinement strategy ($\sigma$ in equation (4)). See Section 8.2.
Constraint: ${\mathbf{TOLS}}>0.0$.
12:   TOLT – REAL (KIND=nag_wp)Input
On entry: the time tolerance used to determine the time step size ($\tau$ in equation (7)). See Section 8.3.
Constraint: ${\mathbf{TOLT}}>0.0$.
13:   PDEDEF – SUBROUTINE, supplied by the user.External Procedure
PDEDEF must evaluate the functions ${F}_{j}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, in equation (1) which define the system of PDEs (i.e., the residuals of the resulting ODE system) at all interior points of the domain. Values at points on the boundaries of the domain are ignored and will be overwritten by BNDARY. PDEDEF is called for each subgrid in turn.
The specification of PDEDEF is:
 SUBROUTINE PDEDEF ( NPTS, NPDE, T, X, Y, U, UT, UX, UY, UXX, UXY, UYY, RES)
 INTEGER NPTS, NPDE REAL (KIND=nag_wp) 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), RES(NPTS,NPDE)
1:     NPTS – INTEGERInput
On entry: the number of grid points in the current grid.
2:     NPDE – INTEGERInput
On entry: the number of PDEs in the system.
3:     T – REAL (KIND=nag_wp)Input
On entry: the current value of the independent variable $t$.
4:     X(NPTS) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{X}}\left(\mathit{i}\right)$ contains the $x$ coordinate of the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$.
5:     Y(NPTS) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{Y}}\left(\mathit{i}\right)$ contains the $y$ coordinate of the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$.
6:     U(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{U}}\left(\mathit{i},\mathit{j}\right)$ contains the value of the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
7:     UT(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UT}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{\partial u}{\partial t}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
8:     UX(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UX}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{\partial u}{\partial x}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
9:     UY(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UY}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{\partial u}{\partial y}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
10:   UXX(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UXX}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{{\partial }^{2}u}{\partial {x}^{2}}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
11:   UXY(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UXY}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{{\partial }^{2}u}{\partial x\partial y}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
12:   UYY(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UYY}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{{\partial }^{2}u}{\partial {y}^{2}}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
13:   RES(NPTS,NPDE) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{RES}}\left(\mathit{i},\mathit{j}\right)$ must contain the value of ${F}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$, although the residuals at boundary points will be ignored (and overwritten later on) and so they need not be specified here.
PDEDEF must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D03RAF is called. Parameters denoted as Input must not be changed by this procedure.
14:   BNDARY – SUBROUTINE, supplied by the user.External Procedure
BNDARY must evaluate the functions ${G}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, in equation (2) which define the boundary conditions at all boundary points of the domain. Residuals at interior points must not be altered by this subroutine.
The specification of BNDARY is:
 SUBROUTINE BNDARY ( NPTS, NPDE, T, X, Y, U, UT, UX, UY, NBPTS, LBND, RES)
 INTEGER NPTS, NPDE, NBPTS, LBND(NBPTS) REAL (KIND=nag_wp) T, X(NPTS), Y(NPTS), U(NPTS,NPDE), UT(NPTS,NPDE), UX(NPTS,NPDE), UY(NPTS,NPDE), RES(NPTS,NPDE)
1:     NPTS – INTEGERInput
On entry: the number of grid points in the current grid.
2:     NPDE – INTEGERInput
On entry: the number of PDEs in the system.
3:     T – REAL (KIND=nag_wp)Input
On entry: the current value of the independent variable $t$.
4:     X(NPTS) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{X}}\left(\mathit{i}\right)$ contains the $x$ coordinate of the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$.
5:     Y(NPTS) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{Y}}\left(\mathit{i}\right)$ contains the $y$ coordinate of the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$.
6:     U(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{U}}\left(\mathit{i},\mathit{j}\right)$ contains the value of the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
7:     UT(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UT}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{\partial u}{\partial t}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
8:     UX(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UX}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{\partial u}{\partial x}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
9:     UY(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{UY}}\left(\mathit{i},\mathit{j}\right)$ contains the value of $\frac{\partial u}{\partial y}$ for the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
10:   NBPTS – INTEGERInput
On entry: the number of boundary points in the grid.
11:   LBND(NBPTS) – INTEGER arrayInput
On entry: ${\mathbf{LBND}}\left(\mathit{i}\right)$ contains the grid index for the $\mathit{i}$th boundary point, for $\mathit{i}=1,2,\dots ,{\mathbf{NBPTS}}$. Hence the $\mathit{i}$th boundary point has coordinates ${\mathbf{X}}\left({\mathbf{LBND}}\left(\mathit{i}\right)\right)$ and ${\mathbf{Y}}\left({\mathbf{LBND}}\left(\mathit{i}\right)\right)$, and the corresponding solution values are ${\mathbf{U}}\left({\mathbf{LBND}}\left(\mathit{i}\right),{\mathbf{NPDE}}\right)$, etc.
12:   RES(NPTS,NPDE) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{RES}}\left(\mathit{i},\mathit{j}\right)$ contains the value of ${F}_{\mathit{j}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NPDE}}$, at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$, as returned by PDEDEF. The residuals at the boundary points will be overwritten and so need not have been set by PDEDEF.
On exit: ${\mathbf{RES}}\left({\mathbf{LBND}}\left(\mathit{i}\right),\mathit{j}\right)$ must contain the value of ${G}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, at the $\mathit{i}$th boundary point, for $\mathit{i}=1,2,\dots ,{\mathbf{NBPTS}}$.
Note: elements of RES corresponding to interior points must not be altered.
BNDARY must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D03RAF is called. Parameters denoted as Input must not be changed by this procedure.
15:   PDEIV – SUBROUTINE, supplied by the user.External Procedure
PDEIV must specify the initial values of the PDE components $u$ at all points in the grid. PDEIV is not referenced if, on entry, ${\mathbf{IND}}=1$.
The specification of PDEIV is:
 SUBROUTINE PDEIV ( NPTS, NPDE, T, X, Y, U)
 INTEGER NPTS, NPDE REAL (KIND=nag_wp) T, X(NPTS), Y(NPTS), U(NPTS,NPDE)
1:     NPTS – INTEGERInput
On entry: the number of grid points in the grid.
2:     NPDE – INTEGERInput
On entry: the number of PDEs in the system.
3:     T – REAL (KIND=nag_wp)Input
On entry: the (initial) value of the independent variable $t$.
4:     X(NPTS) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{X}}\left(\mathit{i}\right)$ contains the $x$ coordinate of the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$.
5:     Y(NPTS) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{Y}}\left(\mathit{i}\right)$ contains the $y$ coordinate of the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$.
6:     U(NPTS,NPDE) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{U}}\left(\mathit{i},\mathit{j}\right)$ must contain the value of the $\mathit{j}$th PDE component at the $\mathit{i}$th grid point, for $\mathit{i}=1,2,\dots ,{\mathbf{NPTS}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
PDEIV must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D03RAF is called. Parameters denoted as Input must not be changed by this procedure.
16:   MONITR – SUBROUTINE, supplied by the user.External Procedure
MONITR is called by D03RAF at the end of every successful time step, and may be used to examine or print the solution or perform other tasks such as error calculations, particularly at the final time step, indicated by the parameter TLAST. The input arguments contain information about the grid and solution at all grid levels used.
MONITR can also be used to force an immediate tidy termination of the solution process and return to the calling program.
The specification of MONITR is:
 SUBROUTINE MONITR ( NPDE, T, DT, DTNEW, TLAST, NLEV, NGPTS, XPTS, YPTS, LSOL, SOL, IERR)
 INTEGER NPDE, NLEV, NGPTS(NLEV), LSOL(NLEV), IERR REAL (KIND=nag_wp) T, DT, DTNEW, XPTS(*), YPTS(*), SOL(*) LOGICAL TLAST
1:     NPDE – INTEGERInput
On entry: the number of PDEs in the system.
2:     T – REAL (KIND=nag_wp)Input
On entry: the current value of the independent variable $t$, i.e., the time at the end of the integration step just completed.
3:     DT – REAL (KIND=nag_wp)Input
On entry: the current time step size $\Delta t$, i.e., the time step size used for the integration step just completed.
4:     DTNEW – REAL (KIND=nag_wp)Input
On entry: the step size that will be used for the next time step.
5:     TLAST – LOGICALInput
On entry: indicates if intermediate or final time step. ${\mathbf{TLAST}}=\mathrm{.FALSE.}$ for an intermediate step, ${\mathbf{TLAST}}=\mathrm{.TRUE.}$ for the last call to MONITR before returning to your program.
6:     NLEV – INTEGERInput
On entry: the number of grid levels used at time T.
7:     NGPTS(NLEV) – INTEGER arrayInput
On entry: ${\mathbf{NGPTS}}\left(\mathit{l}\right)$ contains the number of grid points at level $\mathit{l}$, for $\mathit{l}=1,2,\dots ,{\mathbf{NLEV}}$.
8:     XPTS($*$) – REAL (KIND=nag_wp) arrayInput
On entry: contains the $x$ coordinates of the grid points in each level in turn, i.e., ${\mathbf{X}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NGPTS}}\left(\mathit{l}\right)$ and $\mathit{l}=1,2,\dots ,{\mathbf{NLEV}}$.
So for level $\mathit{l}$, ${\mathbf{X}}\left(\mathit{i}\right)={\mathbf{XPTS}}\left(\mathit{k}+\mathit{i}\right)$, where $\mathit{k}={\mathbf{NGPTS}}\left(1\right)+{\mathbf{NGPTS}}\left(2\right)+\cdots +{\mathbf{NGPTS}}\left(\mathit{l}-1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NGPTS}}\left(\mathit{l}\right)$ and $\mathit{l}=1,2,\dots ,{\mathbf{NLEV}}$.
9:     YPTS($*$) – REAL (KIND=nag_wp) arrayInput
On entry: contains the $y$ coordinates of the grid points in each level in turn, i.e., ${\mathbf{Y}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NGPTS}}\left(\mathit{l}\right)$ and $\mathit{l}=1,2,\dots ,{\mathbf{NLEV}}$.
So for level $\mathit{l}$, ${\mathbf{Y}}\left(\mathit{i}\right)={\mathbf{YPTS}}\left(\mathit{k}+\mathit{i}\right)$, where $\mathit{k}={\mathbf{NGPTS}}\left(1\right)+{\mathbf{NGPTS}}\left(2\right)+\cdots +{\mathbf{NGPTS}}\left(\mathit{l}-1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NGPTS}}\left(\mathit{l}\right)$ and $\mathit{l}=1,2,\dots ,{\mathbf{NLEV}}$.
10:   LSOL(NLEV) – INTEGER arrayInput
On entry: ${\mathbf{LSOL}}\left(\mathit{l}\right)$ contains the pointer to the solution in SOL at grid level $\mathit{l}$ and time T. (${\mathbf{LSOL}}\left(\mathit{l}\right)$ actually contains the array index immediately preceding the start of the solution in SOL.)
11:   SOL($*$) – REAL (KIND=nag_wp) arrayInput
On entry: contains the solution ${\mathbf{U}}\left({\mathbf{NGPTS}}\left(\mathit{l}\right),{\mathbf{NPDE}}\right)$ at time T for each grid level $\mathit{l}$ in turn, positioned according to LSOL, i.e., for level $\mathit{l}$, ${\mathbf{U}}\left(\mathit{i},\mathit{j}\right)={\mathbf{SOL}}\left({\mathbf{LSOL}}\left(\mathit{l}\right)+\left(\mathit{j}-1\right)×{\mathbf{NGPTS}}\left(\mathit{l}\right)+\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NGPTS}}\left(\mathit{l}\right)$, $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$ and $\mathit{l}=1,2,\dots ,{\mathbf{NLEV}}$.
12:   IERR – INTEGERInput/Output
On entry: will be set to $0$.
On exit: should be set to $1$ to force a tidy termination and an immediate return to the calling program with ${\mathbf{IFAIL}}={\mathbf{4}}$. IERR should remain unchanged otherwise.
MONITR must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D03RAF is called. Parameters denoted as Input must not be changed by this procedure.
17:   OPTI($4$) – INTEGER arrayInput
On entry: may be set to control various options available in the integrator.
${\mathbf{OPTI}}\left(1\right)=0$
All the default options are employed.
${\mathbf{OPTI}}\left(1\right)>0$
The default value of ${\mathbf{OPTI}}\left(\mathit{i}\right)$, for $\mathit{i}=2,3,4$, can be obtained by setting ${\mathbf{OPTI}}\left(\mathit{i}\right)=0$.
${\mathbf{OPTI}}\left(1\right)$
Specifies the maximum number of grid levels allowed (including the base grid). ${\mathbf{OPTI}}\left(1\right)\ge 0$. The default value is ${\mathbf{OPTI}}\left(1\right)=3$.
${\mathbf{OPTI}}\left(2\right)$
Specifies the maximum number of Jacobian evaluations allowed during each nonlinear equations solution. ${\mathbf{OPTI}}\left(2\right)\ge 0$. The default value is ${\mathbf{OPTI}}\left(2\right)=2$.
${\mathbf{OPTI}}\left(3\right)$
Specifies the maximum number of Newton iterations in each nonlinear equations solution. ${\mathbf{OPTI}}\left(3\right)\ge 0$. The default value is ${\mathbf{OPTI}}\left(3\right)=10$.
${\mathbf{OPTI}}\left(4\right)$
Specifies the maximum number of iterations in each linear equations solution. ${\mathbf{OPTI}}\left(4\right)\ge 0$. The default value is ${\mathbf{OPTI}}\left(4\right)=100$.
Constraint: ${\mathbf{OPTI}}\left(1\right)\ge 0$ and if ${\mathbf{OPTI}}\left(1\right)>0$, ${\mathbf{OPTI}}\left(\mathit{i}\right)\ge 0$, for $\mathit{i}=2,3,4$.
18:   OPTR($3$,NPDE) – REAL (KIND=nag_wp) arrayInput
On entry: may be used to specify the optional vectors ${u}^{\mathrm{max}}$, ${w}^{\mathrm{s}}$ and ${w}^{\mathrm{t}}$ in the space and time monitors (see Section 8).
If an optional vector is not required then all its components should be set to $1.0$.
${\mathbf{OPTR}}\left(1,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, specifies ${u}_{\mathit{j}}^{\mathrm{max}}$, the approximate maximum absolute value of the $\mathit{j}$th component of $u$, as used in (4) and (7). ${\mathbf{OPTR}}\left(1,\mathit{j}\right)>0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
${\mathbf{OPTR}}\left(2,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, specifies ${w}_{\mathit{j}}^{\mathrm{s}}$, the weighting factors used in the space monitor (see (4)) to indicate the relative importance of the $\mathit{j}$th component of $u$ on the space monitor. ${\mathbf{OPTR}}\left(2,\mathit{j}\right)\ge 0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
${\mathbf{OPTR}}\left(3,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$, specifies ${w}_{\mathit{j}}^{\mathrm{t}}$, the weighting factors used in the time monitor (see (6)) to indicate the relative importance of the $\mathit{j}$th component of $u$ on the time monitor. ${\mathbf{OPTR}}\left(3,\mathit{j}\right)\ge 0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
Constraints:
• ${\mathbf{OPTR}}\left(1,\mathit{j}\right)>0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$;
• ${\mathbf{OPTR}}\left(\mathit{i},\mathit{j}\right)\ge 0.0$, for $\mathit{i}=2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NPDE}}$.
19:   RWK(LENRWK) – REAL (KIND=nag_wp) arrayCommunication Array
20:   LENRWK – INTEGERInput
On entry: the dimension of the array RWK as declared in the (sub)program from which D03RAF is called.
The required value of LENRWK cannot be determined exactly in advance, but a suggested value is
 $LENRWK=maxpts×NPDE×5×l+18×NPDE+9+2×maxpts,$
where $\mathit{l}={\mathbf{OPTI}}\left(1\right)$ if ${\mathbf{OPTI}}\left(1\right)\ne 0$ and $\mathit{l}=3$ otherwise, and $\mathit{maxpts}$ is the expected maximum number of grid points at any one level. If during the execution the supplied value is found to be too small then the routine returns with ${\mathbf{IFAIL}}={\mathbf{3}}$ and an estimated required size is printed on the current error message unit (see X04AAF).
Constraint: ${\mathbf{LENRWK}}\ge {\mathbf{NX}}×{\mathbf{NY}}×{\mathbf{NPDE}}×\left(14+18×{\mathbf{NPDE}}\right)+2×{\mathbf{NX}}×{\mathbf{NY}}$ (the required size for the initial grid).
21:   IWK(LENIWK) – INTEGER arrayCommunication Array
On entry: if ${\mathbf{IND}}=0$, IWK need not be set. Otherwise IWK must remain unchanged from a previous call to D03RAF.
On exit: the following components of the array IWK concern the efficiency of the integration. Here, $m$ is the maximum number of grid levels allowed ($m={\mathbf{OPTI}}\left(1\right)$ if ${\mathbf{OPTI}}\left(1\right)>1$ and $m=3$ otherwise), and $\mathit{l}$ is a grid level taking the values $\mathit{l}=1,2,\dots ,\mathit{nl}$, where $\mathit{nl}$ is the number of levels used.
${\mathbf{IWK}}\left(1\right)$
Contains the number of steps taken in time.
${\mathbf{IWK}}\left(2\right)$
Contains the number of rejected time steps.
${\mathbf{IWK}}\left(2+\mathit{l}\right)$
Contains the total number of residual evaluations performed (i.e., the number of times PDEDEF was called) at grid level $\mathit{l}$.
${\mathbf{IWK}}\left(2+m+\mathit{l}\right)$
Contains the total number of Jacobian evaluations performed at grid level $\mathit{l}$.
${\mathbf{IWK}}\left(2+2×m+\mathit{l}\right)$
Contains the total number of Newton iterations performed at grid level $\mathit{l}$.
${\mathbf{IWK}}\left(2+3×m+\mathit{l}\right)$
Contains the total number of linear solver iterations performed at grid level $\mathit{l}$.
${\mathbf{IWK}}\left(2+4×m+\mathit{l}\right)$
Contains the maximum number of Newton iterations performed at any one time step at grid level $\mathit{l}$.
${\mathbf{IWK}}\left(2+5×m+\mathit{l}\right)$
Contains the maximum number of linear solver iterations performed at any one time step at grid level $\mathit{l}$.
Note: the total and maximum numbers are cumulative over all calls to D03RAF. If the specified maximum number of Newton or linear solver iterations is exceeded at any stage, then the maximums above are set to the specified maximum plus one.
22:   LENIWK – INTEGERInput
On entry: the dimension of the array IWK as declared in the (sub)program from which D03RAF is called.
The required value of LENIWK cannot be determined exactly in advance, but a suggested value is
 $LENIWK=maxpts×14+5×m+7×m+2,$
where $\mathit{maxpts}$ is the expected maximum number of grid points at any one level and $m={\mathbf{OPTI}}\left(1\right)$ if ${\mathbf{OPTI}}\left(1\right)>0$ and $m=3$ otherwise. If during the execution the supplied value is found to be too small then the routine returns with ${\mathbf{IFAIL}}={\mathbf{3}}$ and an estimated required size is printed on the current error message unit (see X04AAF).
Constraint: ${\mathbf{LENIWK}}\ge 19×{\mathbf{NX}}×{\mathbf{NY}}+9$ (the required size for the initial grid).
23:   LWK(LENLWK) – LOGICAL arrayWorkspace
24:   LENLWK – INTEGERInput
On entry: the dimension of the array LWK as declared in the (sub)program from which D03RAF is called.
The required value of LENLWK cannot be determined exactly in advanced, but a suggested value is
 $LENLWK=maxpts+1,$
where $\mathit{maxpts}$ is the expected maximum number of grid points at any one level. If during the execution the supplied value is found to be too small then the routine returns with ${\mathbf{IFAIL}}={\mathbf{3}}$ and an estimated required size is printed on the current error message unit (see X04AAF).
Constraint: ${\mathbf{LENLWK}}\ge {\mathbf{NX}}×{\mathbf{NY}}+1$ (the required size for the initial grid).
25:   ITRACE – INTEGERInput
On entry: the level of trace information required from D03RAF. ITRACE may take the value $-1$, $0$, $1$, $2$ or $3$.
${\mathbf{ITRACE}}=-1$
No output is generated.
${\mathbf{ITRACE}}=0$
Only warning messages are printed.
${\mathbf{ITRACE}}>0$
Output from the underlying solver is printed on the current advisory message unit (see X04ABF). This output contains details of the time integration, the nonlinear iteration and the linear solver.
If ${\mathbf{ITRACE}}<-1$, then $-1$ is assumed and similarly if ${\mathbf{ITRACE}}>3$, then $3$ is assumed.
The advisory messages are given in greater detail as ITRACE increases. Setting ${\mathbf{ITRACE}}=1$ allows you to monitor the progress of the integration without possibly excessive information.
26:   IND – INTEGERInput/Output
On entry: must be set to $0$ or $1$.
${\mathbf{IND}}=0$
Starts the integration in time.
${\mathbf{IND}}=1$
Continues the integration after an earlier exit from the routine. In this case, only the following parameters may be reset between calls to D03RAF: TOUT, ${\mathbf{DT}}\left(2\right)$, ${\mathbf{DT}}\left(3\right)$, TOLS, TOLT, OPTI, OPTR, ITRACE and IFAIL.
Constraint: $0\le {\mathbf{IND}}\le 1$.
On exit: ${\mathbf{IND}}=1$.
Note:  for users of the NAG Library for SMP & Multicore only, additional values of IND are allowed. See Section 2.2.3 in the Introduction to the NAG Library for SMP & Multicore for further details.
27:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ 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 parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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, ${\mathbf{NPDE}}<1$, or ${\mathbf{TOUT}}\le {\mathbf{TS}}$, or TOUT is too close to TS, or ${\mathbf{IND}}=0$ and ${\mathbf{DT}}\left(1\right)<0.0$, or ${\mathbf{DT}}\left(i\right)<0.0$, for $\mathit{i}=2\text{​ or ​}3$, or ${\mathbf{DT}}\left(2\right)>{\mathbf{DT}}\left(3\right)$, or ${\mathbf{IND}}=0$ and , or ${\mathbf{IND}}=0$ and ${\mathbf{DT}}\left(1\right)>{\mathbf{TOUT}}-{\mathbf{TS}}$, or ${\mathbf{IND}}=0$ and ${\mathbf{DT}}\left(1\right)<{\mathbf{DT}}\left(2\right)$ or ${\mathbf{DT}}\left(1\right)>{\mathbf{DT}}\left(3\right)$, or ${\mathbf{XMIN}}\ge {\mathbf{XMAX}}$, or XMAX too close to XMIN, or ${\mathbf{YMIN}}\ge {\mathbf{YMAX}}$, or YMAX too close to YMIN, or NX or ${\mathbf{NY}}<4$, or TOLS or ${\mathbf{TOLT}}\le 0.0$, or ${\mathbf{OPTI}}\left(1\right)<0$, or ${\mathbf{OPTI}}\left(1\right)>0$ and ${\mathbf{OPTI}}\left(j\right)<0$, for $\mathit{j}=2$, $3$ or $4$, or ${\mathbf{OPTR}}\left(1,j\right)\le 0.0$, for some $j=1,2,\dots ,{\mathbf{NPDE}}$, or ${\mathbf{OPTR}}\left(2,j\right)<0.0$, for some $j=1,2,\dots ,{\mathbf{NPDE}}$, or ${\mathbf{OPTR}}\left(3,j\right)<0.0$, for some $j=1,2,\dots ,{\mathbf{NPDE}}$, or LENRWK, LENIWK or LENLWK too small for initial grid level, or ${\mathbf{IND}}\ne 0$ or $1$, or ${\mathbf{IND}}=1$ on initial entry to D03RAF.
${\mathbf{IFAIL}}=2$
The time step size to be attempted is less than the specified minimum size. This may occur following time step failures and subsequent step size reductions caused by one or more of the following:
• the requested accuracy could not be achieved, i.e., TOLT is too small,
• the maximum number of linear solver iterations, Newton iterations or Jacobian evaluations is too small,
• ILU decomposition of the Jacobian matrix could not be performed, possibly due to singularity of the Jacobian.
Setting ITRACE to a higher value may provide further information.
In the latter two cases you are advised to check their problem formulation in PDEDEF and/or BNDARY, and the initial values in PDEIV if appropriate.
${\mathbf{IFAIL}}=3$
One or more of the workspace arrays is too small for the required number of grid points. An estimate of the required sizes for the current stage is output, but more space may be required at a later stage.
${\mathbf{IFAIL}}=4$
IERR was set to $1$ in MONITR, forcing control to be passed back to calling program. Integration was successful as far as ${\mathbf{T}}={\mathbf{TS}}$.
${\mathbf{IFAIL}}=5$
The integration has been completed but the maximum number of levels specified in ${\mathbf{OPTI}}\left(1\right)$ was insufficient at one or more time steps, meaning that the requested space accuracy could not be achieved. To avoid this warning either increase the value of ${\mathbf{OPTI}}\left(1\right)$ or decrease the value of TOLS.

## 7  Accuracy

There are three sources of error in the algorithm: space and time discretization, and interpolation (linear) between grid levels. The space and time discretization errors are controlled separately using the parameters TOLS and TOLT described in the following section, and you should test the effects of varying these parameters. Interpolation errors are generally implicitly controlled by the refinement criterion since in areas where interpolation errors are potentially large, the space monitor will also be large. It can be shown that the global spatial accuracy is comparable to that which would be obtained on a uniform grid of the finest grid size. A full error analysis can be found in Trompert and Verwer (1993).

### 8.1  Algorithm Outline

The local uniform grid refinement method is summarised as follows:
1. Initialize the course base grid, an initial solution and an initial time step.
2. Solve the system of PDEs on the current grid with the current time step.
3. If the required accuracy in space and the maximum number of grid levels have not yet been reached:
 (a) Determine new finer grid at forward time level. (b) Get solution values at previous time level(s) on new grid. (c) Interpolate internal boundary values from old grid at forward time. (d) Get initial values for the Newton process at forward time. (e) Go to $2$.
4. Update the coarser grid solution using the finer grid values.
5. Estimate error in time integration. If time error is acceptable advance time level.
6. Determine new step size then go to $2$ with coarse base as current grid.

### 8.2  Refinement Strategy

For each grid point $i$ a space monitor ${\mu }_{i}^{\mathrm{s}}$ is determined by
 $μ i s = max j=1,NPDE γ j Δ x 2 ∂ 2 ∂ x 2 u j x i , y i ,t + Δ y 2 ∂ 2 ∂ y 2 u j x i , y i ,t ,$ (3)
where $\Delta x$ and $\Delta y$ are the grid widths in the $x$ and $y$ directions; and ${x}_{i}$, ${y}_{i}$ are the $x$ and $y$ coordinates at grid point $i$. The parameter ${\gamma }_{j}$ is obtained from
 $γj=wjs ujmax σ ,$ (4)
where $\sigma$ is the user-supplied space tolerance; ${w}_{j}^{s}$ is a weighting factor for the relative importance of the $j$th PDE component on the space monitor; and ${u}_{j}^{\mathrm{max}}$ is the approximate maximum absolute value of the $j$th component. A value for $\sigma$ must be supplied by you. Values for ${w}_{j}^{\mathrm{s}}$ and ${u}_{j}^{\mathrm{max}}$ must also be supplied but may be set to the value $1.0$ if little information about the solution is known.
A new level of refinement is created if
 $maxiμis>0.9 or 1.0,$ (5)
depending on the grid level at the previous step in order to avoid fluctuations in the number of grid levels between time steps. If (5) is satisfied then all grid points for which ${\mu }_{i}^{s}>0.25$ are flagged and surrounding cells are quartered in size.
No derefinement takes place as such, since at each time step the solution on the base grid is computed first and new finer grids are then created based on the new solution. Hence derefinement occurs implicitly. See Section 8.1.

### 8.3  Time Integration

The time integration is controlled using a time monitor calculated at each level $\mathit{l}$ up to the maximum level used, given by
 $μlt=1N∑j=1NPDEwjt∑i=1 NGPTSl Δtαij utxi,yi,t 2$ (6)
where ${\mathbf{NGPTS}}\left(\mathit{l}\right)$ is the total number of points on grid level $\mathit{l}$; $N={\mathbf{NGPTS}}\left(\mathit{l}\right)×{\mathbf{NPDE}}$; $\Delta t$ is the current time step; ${u}_{t}$ is the time derivative of $u$ which is approximated by first-order finite differences; ${w}_{j}^{\mathrm{t}}$ is the time equivalent of the space weighting factor ${w}_{j}^{\mathrm{s}}$; and ${\alpha }_{ij}$ is given by
 $αij=τ ujmax100+uxi,yi,t$ (7)
where ${u}_{j}^{\mathrm{max}}$ is as before, and $\tau$ is the user-specified time tolerance.
An integration step is rejected and retried at all levels if
 $maxlμlt>1.0.$ (8)

## 9  Example

Note: a modified example is supplied with the NAG Library for SMP & Multicore and links have been supplied in the following subsections.
For this routine two examples are presented, with a main program and two example problems given in Example 1 (EX1) and Example 2 (EX2).
Example 1 (EX1)
This example stems from combustion theory and is a model for a single, one-step reaction of a mixture of two chemicals (see Adjerid and Flaherty (1988)). The PDE for the temperature of the mixture $u$ is
 $∂u ∂t =d ∂2u ∂x2 + ∂2u ∂y2 +D1+α-u exp-δu$
for $0\le x,y\le 1$ and $t\ge 0$, with initial conditions $u\left(x,y,0\right)=1$ for $0\le x,y\le 1$, and boundary conditions
 $ux 0,y,t = 0, u 1,y,t = 1 for ​ 0≤y≤1,$
 $uy x,0,t = 0, u x,1,t = 1 for ​ 0≤x≤ 1.$
The heat release parameter $\alpha =1$, the Damkohler number $D=R\mathrm{exp}\left(\delta \right)/\left(\alpha \delta \right)$, the activation energy $\delta =20$, the reaction rate $R=5$, and the diffusion parameter $d=0.1$.
For small times the temperature gradually increases in a circular region about the origin, and at about $t=0.24$ ‘ignition’ occurs causing the temperature to suddenly jump from near unity to $1+\alpha$, and a reaction front forms and propagates outwards, becoming steeper. Thus during the solution, just one grid level is used up to the ignition point, then two levels, and then three as the reaction front steepens.
Example 2 (EX2)
This example is taken from a multispecies food web model, in which predator-prey relationships in a spatial domain are simulated (see Brown et al. (1994)). In this example there is just one species each of prey and predator, and the two PDEs for the concentrations ${c}_{1}$ and ${c}_{2}$ of the prey and the predator respectively are
 $∂c1 ∂t =c1b1+a11c1+a12c2+d1 ∂2c1 ∂x2 + ∂2c1 ∂y2 ,$
 $0=c2 b2+a21c1+a22c2+d2 ∂2 c2 ∂x2 + ∂2 c2 ∂y2 ,$
with
 $a11=a22=-1, a12=-0.5×10-6, and a21=104, and b1=1+αxy+βsin4πxsin4πy,$
where $\alpha =50$ and $\beta =300$, and ${b}_{2}=-{b}_{1}$.
The initial conditions are taken to be simple peaked functions which satisfy the boundary conditions and very nearly satisfy the PDEs:
 $c1=10+16x1-xy1-y2,$
 $c2=b2+a21c1,$
and the boundary conditions are of Neumann type, i.e., zero normal derivatives everywhere.
During the solution a number of peaks and troughs develop across the domain, and so the number of levels required increases with time. Since the solution varies rapidly in space across the whole of the domain, refinement at intermediate levels tends to occur at all points of the domain.

### 9.1  Program Text

Program Text (d03rafe.f90)

Program Text (d03rafe_smp.f90)

### 9.2  Program Data

Program Data (d03rafe.d)

Program Data (d03rafe_smp.d)

### 9.3  Program Results

Program Results (d03rafe.r)

Program Results (d03rafe_smp.r)