# NAG Library Routine Document

## 1Purpose

d02ptf provides details about an integration performed by either d02pef, d02pff or d02pgf.

## 2Specification

Fortran Interface
 Subroutine d02ptf (
 Integer, Intent (Inout) :: iwsav(130), ifail Integer, Intent (Out) :: fevals, stepcost, stepsok Real (Kind=nag_wp), Intent (In) :: rwsav(350) Real (Kind=nag_wp), Intent (Out) :: waste, hnext
#include nagmk26.h
 void d02ptf_ (Integer *fevals, Integer *stepcost, double *waste, Integer *stepsok, double *hnext, Integer iwsav[], const double rwsav[], Integer *ifail)

## 3Description

d02ptf and its associated routines (d02pef, d02pff, d02pgf, d02phf, d02pjf, d02pqf, d02prf, d02psf and d02puf) solve the initial value problem for a first-order system of ordinary differential equations. The routines, based on Runge–Kutta methods and derived from RKSUITE (see Brankin et al. (1991)), integrate
 $y′ = ft,y given yt0=y0$
where $y$ is the vector of $n$ solution components and $t$ is the independent variable.
After a call to d02pef, d02pff or d02pgf, d02ptf can be called to obtain information about the cost of the integration and the size of the next step.

## 4References

Brankin R W, Gladwell I and Shampine L F (1991) RKSUITE: A suite of Runge–Kutta codes for the initial value problems for ODEs SoftReport 91-S1 Southern Methodist University

## 5Arguments

1:     $\mathbf{fevals}$ – IntegerOutput
On exit: the total number of evaluations of $f$ used in the integration so far; this includes evaluations of $f$ required for the secondary integration necessary if d02pqf had previously been called with ${\mathbf{method}}>0$.
2:     $\mathbf{stepcost}$ – IntegerOutput
On exit: the cost in terms of number of evaluations of $f$ of a typical step with the method being used for the integration. The method is specified by the argument method in a prior call to d02pqf.
3:     $\mathbf{waste}$ – Real (Kind=nag_wp)Output
On exit: the number of attempted steps that failed to meet the local error requirement divided by the total number of steps attempted so far in the integration. A ‘large’ fraction indicates that the integrator is having trouble with the problem being solved. This can happen when the problem is ‘stiff’ and also when the solution has discontinuities in a low-order derivative.
4:     $\mathbf{stepsok}$ – IntegerOutput
On exit: the number of accepted steps.
5:     $\mathbf{hnext}$ – Real (Kind=nag_wp)Output
On exit: the step size the integrator will attempt to use for the next step.
6:     $\mathbf{iwsav}\left(130\right)$ – Integer arrayCommunication Array
7:     $\mathbf{rwsav}\left(350\right)$ – Real (Kind=nag_wp) arrayCommunication Array
Note: the communication rwsav used by the other routines in the suite must be used here however, only the first $350$ elements will be referenced.
On entry: these must be the same arrays supplied in a previous call to d02pef, d02pff or d02pgf. They must remain unchanged between calls.
On exit: information about the integration for use on subsequent calls to d02pef, d02pff or d02pgf or other associated routines.
8:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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).

## 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$
On entry, a previous call to the setup routine has not been made or the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere.
You cannot continue integrating the problem.
You cannot call this routine before you have called the integrator.
You have already made one call to this routine after the integrator could not achieve specified accuracy.
You cannot call this routine again.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8Parallelism and Performance

d02ptf is not threaded in any implementation.

When a secondary integration has taken place, that is when global error assessment has been specified using ${\mathbf{method}}>0$ in a prior call to d02pqf, then the approximate number of evaluations of $f$ used in this secondary integration is given by $2×{\mathbf{stepsok}}×{\mathbf{stepcost}}$ for ${\mathbf{method}}=2$ or $3$ and $3×{\mathbf{stepsok}}×{\mathbf{stepcost}}$ for ${\mathbf{method}}=1$.