# NAG FL Interfaced02nvf (ivp_​stiff_​bdf)

## 1Purpose

d02nvf is a setup routine which must be called prior to linear algebra setup routines and integrators from the SPRINT suite of routines, if Backward Differentiation Formulae (BDF) are to be used.

## 2Specification

Fortran Interface
 Subroutine d02nvf ( con, hmin, hmax, h0, norm,
 Integer, Intent (In) :: neqmax, sdysav, maxord, maxstp, mxhnil Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: tcrit, hmin, hmax, h0 Real (Kind=nag_wp), Intent (Inout) :: con(6), rwork(50+4*neqmax) Logical, Intent (In) :: petzld Character (1), Intent (In) :: method, norm
#include <nag.h>
 void d02nvf_ (const Integer *neqmax, const Integer *sdysav, const Integer *maxord, const char *method, const logical *petzld, double con[], const double *tcrit, const double *hmin, const double *hmax, const double *h0, const Integer *maxstp, const Integer *mxhnil, const char *norm, double rwork[], Integer *ifail, const Charlen length_method, const Charlen length_norm)
The routine may be called by the names d02nvf or nagf_ode_ivp_stiff_bdf.

## 3Description

An integrator setup routine must be called before the call to any linear algebra setup routine or integrator from the SPRINT suite of routines in this sub-chapter. This setup routine, d02nvf, makes the choice of the BDF integrator and permits you to define options appropriate to this choice. Alternative choices of integrator from this suite are the BLEND method and the DASSL implementation of the BDF method which can be chosen by initial calls to d02nwf or d02mvf respectively.

## 4References

See the D02MN Sub-chapter Introduction.

## 5Arguments

1: $\mathbf{neqmax}$Integer Input
On entry: a bound on the maximum number of differential equations to be solved.
Constraint: ${\mathbf{neqmax}}\ge 1$.
2: $\mathbf{sdysav}$Integer Input
On entry: the second dimension of the array ysav that will be supplied to the integrator, as declared in the (sub)program from which the integrator is called.
Constraint: ${\mathbf{sdysav}}\ge {\mathbf{maxord}}+1$.
3: $\mathbf{maxord}$Integer Input
On entry: the maximum order to be used for the BDF method.
Constraint: $0<{\mathbf{maxord}}\le 5$.
4: $\mathbf{method}$Character(1) Input
On entry: specifies the method to be used to solve the system of nonlinear equations arising on each step of the BDF code.
${\mathbf{method}}=\text{'N'}$
A modified Newton iteration is used.
${\mathbf{method}}=\text{'F'}$
Functional iteration is used.
${\mathbf{method}}=\text{'D'}$
A modified Newton iteration is used.
Note:  a linear algebra setup routine must be called even when using functional iteration, since if difficulty is encountered a switch is made to a modified Newton method.
Only the first character of the actual argument method is passed to d02nvf; hence it is permissible for the actual argument to be more descriptive e.g., ‘Newton’, ‘Functional iteration’ or ‘Default’ in a call to d02nvf.
Constraint: ${\mathbf{method}}=\text{'N'}$, $\text{'F'}$ or $\text{'D'}$.
5: $\mathbf{petzld}$Logical Input
On entry: specifies whether the Petzold local error test is to be used. If petzld is set to .TRUE. on entry, the Petzold local error test is used, otherwise a conventional test is used. The Petzold test results in extra overhead cost but is more stable and reliable for differential/algebraic equations.
6: $\mathbf{con}\left(6\right)$Real (Kind=nag_wp) array Input/Output
On entry: values to be used to control step size choice during integration. If any ${\mathbf{con}}\left(i\right)=0.0$ on entry, it is replaced by its default value described below. In most cases this is the recommended setting.
${\mathbf{con}}\left(1\right)$, ${\mathbf{con}}\left(2\right)$, and ${\mathbf{con}}\left(3\right)$ are factors used to bound step size changes. If the current step size $h$ fails, the modulus of the next step size is bounded by ${\mathbf{con}}\left(1\right)×\left|h\right|$. The default value of ${\mathbf{con}}\left(1\right)$ is $2.0$. Note that the new step size may be used with a method of different order to the failed step. If the initial step size is $h$, the modulus of the step size on the second step is bounded by ${\mathbf{con}}\left(3\right)×\left|h\right|$. At any other stage in the integration, if the current step size is $h$, the modulus of the next step size is bounded by ${\mathbf{con}}\left(2\right)×\left|h\right|$. The default values are $10.0$ for ${\mathbf{con}}\left(2\right)$ and $1000.0$ for ${\mathbf{con}}\left(3\right)$.
${\mathbf{con}}\left(4\right)$, ${\mathbf{con}}\left(5\right)$ and ${\mathbf{con}}\left(6\right)$ are ‘tuning’ constants used in determining the next order and step size. They are used to scale the error estimates used in determining whether to keep the same order of the BDF method, decrease the order or increase the order respectively. The larger the value of ${\mathbf{con}}\left(\mathit{i}\right)$, for $\mathit{i}=4,5,6$, the less likely the choice of the corresponding order. The default values are: ${\mathbf{con}}\left(4\right)=1.2$, ${\mathbf{con}}\left(5\right)=1.3$, ${\mathbf{con}}\left(6\right)=1.4$.
Constraints:
These constraints must be satisfied after any zero values have been replaced by their default values.
• $0.0<{\mathbf{con}}\left(1\right)\le {\mathbf{con}}\left(2\right)\le {\mathbf{con}}\left(3\right)$;
• ${\mathbf{con}}\left(\mathit{i}\right)\ge 1.0$, for $\mathit{i}=2,3,\dots ,6$.
On exit: the values actually used by d02nvf.
7: $\mathbf{tcrit}$Real (Kind=nag_wp) Input
On entry: a point beyond which integration must not be attempted. The use of tcrit is described under the argument itask in the specification for the integrator (e.g., see d02nbf). A value, $0.0$ say, must be specified even if itask subsequently specifies that tcrit will not be used.
8: $\mathbf{hmin}$Real (Kind=nag_wp) Input
On entry: the minimum absolute step size to be allowed. Set ${\mathbf{hmin}}=0.0$ if this option is not required.
9: $\mathbf{hmax}$Real (Kind=nag_wp) Input
On entry: the maximum absolute step size to be allowed. Set ${\mathbf{hmax}}=0.0$ if this option is not required.
10: $\mathbf{h0}$Real (Kind=nag_wp) Input
On entry: the step size to be attempted on the first step. Set ${\mathbf{h0}}=0.0$ if the initial step size is calculated internally.
11: $\mathbf{maxstp}$Integer Input
On entry: the maximum number of steps to be attempted during one call to the integrator after which it will return with ${\mathbf{ifail}}={\mathbf{2}}$. Set ${\mathbf{maxstp}}=0$ if no limit is to be imposed.
12: $\mathbf{mxhnil}$Integer Input
On entry: the maximum number of warnings printed (if ${\mathbf{itrace}}\ge 0$) per problem when $t+h=t$ on a step ($h=$ current step size). If ${\mathbf{mxhnil}}\le 0$, a default value of $10$ is assumed.
13: $\mathbf{norm}$Character(1) Input
On entry: indicates the type of norm to be used.
${\mathbf{norm}}=\text{'M'}$
Maximum norm.
${\mathbf{norm}}=\text{'A'}$
Averaged L2 norm.
${\mathbf{norm}}=\text{'D'}$
Is the same as ${\mathbf{norm}}=\text{'A'}$.
If $\mathit{vnorm}$ denotes the norm of the vector $v$ of length $n$, for the averaged L2 norm
 $vnorm=1n∑i=1nvi/wi2,$
while for the maximum norm
 $vnorm=maxivi/wi.$
If you wish to weight the maximum norm or the L2 norm, rtol and atol should be scaled appropriately on input to the integrator (see under itol in the specification of the integrator for the formulation of the weight vector ${w}_{i}$ from rtol and atol, e.g., see d02nbf).
Only the first character to the actual argument norm is passed to d02nvf; hence it is permissible for the actual argument to be more descriptive e.g., ‘Maximum’, ‘Average L2’ or ‘Default’ in a call to d02nvf.
Constraint: ${\mathbf{norm}}=\text{'M'}$, $\text{'A'}$ or $\text{'D'}$.
14: $\mathbf{rwork}\left(50+4×{\mathbf{neqmax}}\right)$Real (Kind=nag_wp) array Communication Array
This must be the same workspace array as the array rwork supplied to the integrator. It is used to pass information from the setup routine to the integrator and therefore the contents of this array must not be changed before calling the integrator.
15: $\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$
On entry, ${\mathbf{con}}\left(〈\mathit{\text{value}}〉\right)=〈\mathit{\text{value}}〉$ was less than $0.0$.
On entry, ${\mathbf{con}}\left(〈\mathit{\text{value}}〉\right)=〈\mathit{\text{value}}〉$ was less than $1.0$.
On entry, ${\mathbf{con}}\left(1\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{con}}\left(2\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{con}}\left(1\right)\le {\mathbf{con}}\left(2\right)$.
On entry, ${\mathbf{con}}\left(2\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{con}}\left(3\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{con}}\left(2\right)\le {\mathbf{con}}\left(3\right)$.
On entry, ${\mathbf{maxord}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{maxord}}\ge 1$.
On entry, ${\mathbf{method}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{method}}=\text{'N'}$, $\text{'F'}$ or $\text{'D'}$.
On entry, ${\mathbf{method}}=〈\mathit{\text{value}}〉$ and ${\mathbf{maxord}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{maxord}}\le 〈\mathit{\text{value}}〉$, the maximum allowed order for the method define by method.
On entry, ${\mathbf{neqmax}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{neqmax}}\ge 1$.
On entry, ${\mathbf{norm}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{norm}}=\text{'M'}$, $\text{'A'}$ or $\text{'D'}$.
On entry, ${\mathbf{sdysav}}=〈\mathit{\text{value}}〉$ and ${\mathbf{maxord}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{sdysav}}>{\mathbf{maxord}}$.
${\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.

## 8Parallelism and Performance

d02nvf is not threaded in any implementation.