# NAG FL Interfaced02zaf (ivp_​stiff_​errest)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d02zaf calculates the weighted norm of the local error estimate from inside a monitr called from an integrator in Sub-chapter D02M–N (e.g., see d02nbf).

## 2Specification

Fortran Interface
 Function d02zaf ( neq, v, w,
 Real (Kind=nag_wp) :: d02zaf Integer, Intent (In) :: neq Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: v(neq), w(neq)
#include <nag.h>
 double d02zaf_ (const Integer *neq, const double v[], const double w[], Integer *ifail)
The routine may be called by the names d02zaf or nagf_ode_ivp_stiff_errest.

## 3Description

d02zaf is for use with the direct communication integrators d02nbf, d02ncf, d02ndf, d02ngf, d02nhf and d02njf and the reverse communication integrators d02nmf and d02nnf. It must be used only inside monitr (if this option is selected) for the direct communication routines or on the equivalent return for the reverse communication routines. It may be used to evaluate the norm of the scaled local error estimate, $‖v‖$, where the weights used are contained in $w$ and the norm used is as defined by an earlier call to the integrator setup routine (d02mvf, d02nvf or d02nwf). Its use is described under the description of monitr in the specifications for the direct communication integrators mentioned above.

None.

## 5Arguments

1: $\mathbf{neq}$Integer Input
On entry: the number of differential equations, as defined for the integrator being used.
2: $\mathbf{v}\left({\mathbf{neq}}\right)$Real (Kind=nag_wp) array Input
On entry: the vector, the weighted norm of which is to be evaluated by d02zaf. v is calculated internally by the integrator being used.
3: $\mathbf{w}\left({\mathbf{neq}}\right)$Real (Kind=nag_wp) array Input
On entry: the weights, calculated internally by the integrator, to be used in the norm evaluation.
4: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $-1$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
Note: in some cases d02zaf may return useful information.
${\mathbf{ifail}}=1$
The value of the norm would either overflow or is close to overflowing.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

The result is calculated close to machine precision except in the case when the routine exits with ${\mathbf{ifail}}={\mathbf{1}}$.

## 8Parallelism and Performance

d02zaf is not threaded in any implementation.

d02zaf should only be used within monitr associated with the integrators in Sub-chapter D02M–N (e.g., see d02nbf). Its use and only valid calling sequence are fully documented in the description of monitr in the routine documents for the integrators.

## 10Example

This example solves the well-known stiff Robertson problem
 $a′ = -0.04a + 1.0E4bc b′ = 0.04a - 1.0E4bc - 3.0E7⁢b2 c′ = 3.0E7⁢b2$
over the range $\left[0,10\right]$ with initial conditions $a=1.0$ and $b=c=0.0$ using scalar error control (${\mathbf{itol}}=1$) and computation of the solution at ${\mathbf{tout}}=10.0$ with tcrit (e.g., see d02mvf) set to $10.0$ (${\mathbf{itask}}=4$). A BDF integrator (setup routine d02nvf) is used and a modified Newton method is selected. This example illustrates the use of d02zaf within a monitor routine monitr to output intermediate results during the integration. The same problem is solved in the example program for d02nbf where no monitoring was performed and so no intermediate solution information is output.

### 10.1Program Text

Program Text (d02zafe.f90)

### 10.2Program Data

Program Data (d02zafe.d)

### 10.3Program Results

Program Results (d02zafe.r)