# NAG Library Routine Document

## 1Purpose

d02pjf evaluates the interpolant calculated by d02phf, following an integration step performed by d02pgf to solve an initial value problem.

## 2Specification

Fortran Interface
 Subroutine d02pjf ( n, t, sol,
 Integer, Intent (In) :: icheck, n, nwant, ideriv, lwcomm Integer, Intent (Inout) :: iwsav(130), ifail Real (Kind=nag_wp), Intent (In) :: t Real (Kind=nag_wp), Intent (Inout) :: wcomm(lwcomm), rwsav(32*n+350) Real (Kind=nag_wp), Intent (Out) :: sol(nwant)
C Header Interface
#include nagmk26.h
 void d02pjf_ (const Integer *icheck, const Integer *n, const Integer *nwant, const double *t, const Integer *ideriv, double sol[], double wcomm[], const Integer *lwcomm, Integer iwsav[], double rwsav[], Integer *ifail)

## 3Description

When integrating using the reverse communication Runge–Kutta integrator d02pgf, the solution or its derivatives can be obtained inexpensively between steps by interpolation. d02phf is called after a step by d02pgf from a previous value of $t$ ($={t}_{k-1}$) to its current value, $t={t}_{k}$ (i.e., a $k$th successful time-step has been taken). d02pjf can then be called to evaluate interpolated approximations of the function or its derivatives at any value of $t$ in the interval $\left({t}_{k-1},{t}_{k}\right)$.
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{icheck}$ – IntegerInput
On entry: indicates whether consistency checks on input arguments should be performed
${\mathbf{icheck}}\ne 1$
Don't perform checks on input arguments.
${\mathbf{icheck}}=1$
Perform consistency checks on input arguments.
It is recommended to use ${\mathbf{icheck}}=1$ on the first call following a call to d02phf and to set ${\mathbf{icheck}}\ne 1$ on subsequent calls within the last step to avoid the overhead of argument checking.
2:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the dimension of the system of ODEs being integrated.
Constraint: this must be the same value as supplied in a previous call to d02pqf.
3:     $\mathbf{nwant}$ – IntegerInput
On entry: only the first nwant system components to be computed. This should be the same value as passed to d02phf when computing the interpolant.
Constraint: ${\mathbf{nwant}}={\mathbf{nwant}}$ passed to d02phf.
4:     $\mathbf{t}$ – Real (Kind=nag_wp)Input
On entry: $t$, the value of the independent variable where a solution is desired. Although any value of $t$ can be supplied, accurate solutions can only be obtained for values in the range of the last time-step taken by d02pgf.
5:     $\mathbf{ideriv}$ – IntegerInput
On entry:
${\mathbf{ideriv}}=0$
Compute approximations to the first nwant components of the solution $y\left(t\right)$.
${\mathbf{ideriv}}=1$
Compute approximations to the first nwant components of the first derivatives of the solution ${y}^{\prime }\left(t\right)$.
Constraint: ${\mathbf{ideriv}}=0$ or $1$.
6:     $\mathbf{sol}\left({\mathbf{nwant}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit:
${\mathbf{ideriv}}=0$
The first nwant components of the solution $y\left(t\right)$.
${\mathbf{ideriv}}=1$
The first nwant components of the first derivatives of the solution ${y}^{\prime }\left(t\right)$.
7:     $\mathbf{wcomm}\left({\mathbf{lwcomm}}\right)$ – Real (Kind=nag_wp) arrayCommunication Array
On entry: this must be the same array supplied in a previous call to d02phf. It must remain unchanged between calls.
8:     $\mathbf{lwcomm}$ – IntegerInput
On entry: length of wcomm. This should be the same value as supplied in a previous call to d02phf.
If in a previous call to d02pqf:
• ${\mathbf{method}}=1$ or $-1$, lwcomm must be at least $1$.
• ${\mathbf{method}}=2$ or $-2$, lwcomm must be at least ${\mathbf{n}}+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},5×{\mathbf{nwant}}\right)$.
• ${\mathbf{method}}=3$ or $-3$, ${\mathbf{lwcomm}}\ge 8×{\mathbf{nwant}}$.
9:     $\mathbf{iwsav}\left(130\right)$ – Integer arrayCommunication Array
10:   $\mathbf{rwsav}\left(32×{\mathbf{n}}+350\right)$ – Real (Kind=nag_wp) arrayCommunication Array
On entry: these must be the same arrays supplied in a previous call d02pgf. They must remain unchanged between calls.
On exit: information about the integration for use on subsequent calls to d02pgf, d02phf or other associated routines.
11:   $\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.
On entry, ${\mathbf{ideriv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ideriv}}=0$ or $1$.
On entry, ${\mathbf{lwcomm}}=〈\mathit{\text{value}}〉$, ${\mathbf{n}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nwant}}=〈\mathit{\text{value}}〉$.
Constraint: for ${\mathbf{method}}=-2$ or $2$, ${\mathbf{lwcomm}}\ge {\mathbf{n}}+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},5×{\mathbf{nwant}}\right)$.
On entry, ${\mathbf{lwcomm}}=〈\mathit{\text{value}}〉$.
Constraint: for ${\mathbf{method}}=-1$ or $1$, ${\mathbf{lwcomm}}\ge 1$.
On entry, ${\mathbf{lwcomm}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nwant}}=〈\mathit{\text{value}}〉$.
Constraint: for ${\mathbf{method}}=-3$ or $3$, ${\mathbf{lwcomm}}\ge 8×{\mathbf{nwant}}$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$, but the value passed to the setup routine was ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{nwant}}=〈\mathit{\text{value}}〉$, but on interpolation setup ${\mathbf{nwant}}=〈\mathit{\text{value}}〉$.
Constraint: nwant must be unchanged from setup.
The previous call to the interpolation setup routine returned an error.
You cannot call this routine before you have called the interpolation setup.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
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.

## 7Accuracy

The computed values will be of a similar accuracy to that computed by d02pgf.

## 8Parallelism and Performance

d02pjf is not threaded in any implementation.

None.

## 10Example

See Section 10 in d02pgf.
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017