## 1Purpose

d02qyf is a diagnostic routine which may be called after a call to the integrator routines d02qff or d02qgf.

## 2Specification

Fortran Interface
 Subroutine d02qyf ( neqg,
 Integer, Intent (In) :: neqg, lrwork, iwork(liwork), liwork Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: index, itype, events(neqg) Real (Kind=nag_wp), Intent (In) :: rwork(lrwork) Real (Kind=nag_wp), Intent (Out) :: resids(neqg)
#include <nag.h>
 void d02qyf_ (const Integer *neqg, Integer *index, Integer *itype, Integer events[], double resids[], const double rwork[], const Integer *lrwork, const Integer iwork[], const Integer *liwork, Integer *ifail)
The routine may be called by the names d02qyf or nagf_ode_ivp_adams_rootdiag.

## 3Description

d02qyf should be called only after a call to d02qff or d02qgf results in the output value ${\mathbf{root}}=\mathrm{.TRUE.}$, indicating that a root has been detected. d02qyf permits you to examine information about the root detected, such as the indices of the event equations for which there is a root, the type of root (odd or even) and the residuals of the event equations.

None.

## 5Arguments

1: $\mathbf{neqg}$Integer Input
On entry: the number of event functions defined for the integration routine. It must be the same argument neqg supplied to the setup routine d02qwf and to the integration routine (d02qff or d02qgf).
2: $\mathbf{index}$Integer Output
On exit: the index $k$ of the event equation ${g}_{k}\left(x,y,{y}^{\prime }\right)=0$ for which the root has been detected.
3: $\mathbf{itype}$Integer Output
On exit: information about the root detected for the event equation defined by index. The possible values of itype with their interpretations are as follows:
${\mathbf{itype}}=1$
A simple root, or lack of distinguishing information available.
${\mathbf{itype}}=2$
A root of even multiplicity is believed to have been detected, that is no change in sign of the event function was found.
${\mathbf{itype}}=3$
A high-order root of odd multiplicity.
${\mathbf{itype}}=4$
A possible root, but due to high multiplicity or a clustering of roots accurate evaluation of the event function was prohibited by round-off error and/or cancellation.
In general, the accuracy of the root is less reliable for values of ${\mathbf{itype}}>1$.
4: $\mathbf{events}\left({\mathbf{neqg}}\right)$Integer array Output
On exit: information about the $k$th event function on a very small interval containing the root, t (see d02qff and d02qgf), as output from the integration routine. All roots lying in this interval are considered indistinguishable numerically and therefore should be regarded as defining a root at t. The possible values of ${\mathbf{events}}\left(k\right)$ with their interpretations are as follows:
${\mathbf{events}}\left(k\right)=0$
The $k$th event function did not have a root.
${\mathbf{events}}\left(k\right)=-1$
The $k$th event function changed sign from positive to negative about a root, in the direction of integration.
${\mathbf{events}}\left(k\right)=1$
The $k$th event function changed sign from negative to positive about a root, in the direction of integration.
${\mathbf{events}}\left(k\right)=2$
A root was identified, but no change in sign was observed.
5: $\mathbf{resids}\left({\mathbf{neqg}}\right)$Real (Kind=nag_wp) array Output
On exit: the value of the $k$th event function computed at the root, t (see d02qff and d02qgf).
6: $\mathbf{rwork}\left({\mathbf{lrwork}}\right)$Real (Kind=nag_wp) array Communication Array
On entry: this must be the same argument rwork as supplied to d02qff or d02qgf. It is used to pass information from the integration routine to d02qyf and therefore the contents of this array must not be changed before calling d02qyf.
7: $\mathbf{lrwork}$Integer Input
On entry: the dimension of the array rwork as declared in the (sub)program from which d02qyf is called.
This must be the same argument lrwork as supplied to d02qwf.
8: $\mathbf{iwork}\left({\mathbf{liwork}}\right)$Integer array Communication Array
On entry: this must be the same argument iwork as supplied to d02qff or d02qgf. It is used to pass information from the integration routine to d02qyf and therefore the contents of this array must not be changed before calling d02qyf.
9: $\mathbf{liwork}$Integer Input
On entry: the dimension of the array iwork as declared in the (sub)program from which d02qyf is called.
This must be the same argument liwork as supplied to d02qwf.
10: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value 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:
${\mathbf{ifail}}=1$
Neither of the appropriate two integrator routines has been called.
On entry, ${\mathbf{liwork}}=〈\mathit{\text{value}}〉$ and ${\mathbf{liwork}}=〈\mathit{\text{value}}〉$ in d02qwf.
Constraint: ${\mathbf{liwork}}={\mathbf{liwork}}$ in d02qwf.
On entry, ${\mathbf{lrwork}}=〈\mathit{\text{value}}〉$ and ${\mathbf{lrwork}}=〈\mathit{\text{value}}〉$ in d02qwf.
Constraint: ${\mathbf{lrwork}}={\mathbf{lrwork}}$ in d02qwf.
On entry, ${\mathbf{neqg}}=〈\mathit{\text{value}}〉$ and ${\mathbf{neqg}}=〈\mathit{\text{value}}〉$ in d02qwf.
Constraint: ${\mathbf{neqg}}={\mathbf{neqg}}$ in d02qwf.
The integrator did not end at an event.
${\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.

Not applicable.