# NAG FL Interfaced02mwf (dae_​dassl_​setup)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d02mwf is a setup routine which must be called prior to the integrator d02nef, if the DASSL implementation of Backward Differentiation Formulae (BDF) is to be used.

## 2Specification

Fortran Interface
 Subroutine d02mwf ( neq, hmax, h0, itol, icom, com, lcom,
 Integer, Intent (In) :: neq, maxord, itol, licom, lcom Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: icom(licom) Real (Kind=nag_wp), Intent (In) :: hmax, h0 Real (Kind=nag_wp), Intent (Out) :: com(lcom) Character (1), Intent (In) :: jceval
#include <nag.h>
 void d02mwf_ (const Integer *neq, const Integer *maxord, const char *jceval, const double *hmax, const double *h0, const Integer *itol, Integer icom[], const Integer *licom, double com[], const Integer *lcom, Integer *ifail, const Charlen length_jceval)
The routine may be called by the names d02mwf or nagf_ode_dae_dassl_setup.

## 3Description

This integrator setup routine must be called before the first call to the integrator d02nef. This setup routine d02mwf permits you to define options for the DASSL integrator, such as: whether the Jacobian is to be provided or is to be approximated numerically by the integrator; the initial and maximum step-sizes for the integration; whether relative and absolute tolerances are system wide or per system equation; and the maximum order of BDF method permitted.

None.

## 5Arguments

1: $\mathbf{neq}$Integer Input
On entry: the number of differential-algebraic equations to be solved.
Constraint: ${\mathbf{neq}}\ge 1$.
2: $\mathbf{maxord}$Integer Input
On entry: the maximum order to be used for the BDF method. Orders up to 5th order are available; setting ${\mathbf{maxord}}>5$ means that the maximum order used will be $5$.
Constraint: $1\le {\mathbf{maxord}}$.
3: $\mathbf{jceval}$Character(1) Input
On entry: specifies the technique to be used to compute the Jacobian.
${\mathbf{jceval}}=\text{'N'}$
The Jacobian is to be evaluated numerically by the integrator.
${\mathbf{jceval}}=\text{'A'}$
You must supply a subroutine to evaluate the Jacobian on a call to the integrator.
Only the first character of the actual paramater jceval is passed to d02mwf; hence it is permissible for the actual argument to be more descriptive, e.g., ‘Numerical’ or ‘Analytical’, on a call to d02mwf.
Constraint: ${\mathbf{jceval}}=\text{'N'}$ or $\text{'A'}$.
4: $\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.
Constraint: ${\mathbf{hmax}}\ge 0.0$.
5: $\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.
6: $\mathbf{itol}$Integer Input
On entry: a value to indicate the form of the local error test.
${\mathbf{itol}}=0$
rtol and atol are single element vectors.
${\mathbf{itol}}=1$
rtol and atol are vectors. This should be chosen if you want to apply different tolerances to each equation in the system.
See d02nef.
Note: the tolerances must either both be single element vectors or both be vectors of length neq.
Constraint: ${\mathbf{itol}}=0$ or $1$.
7: $\mathbf{icom}\left({\mathbf{licom}}\right)$Integer array Communication Array
On exit: used to communicate details of the task to be carried out to the integration routine d02nef.
8: $\mathbf{licom}$Integer Input
On entry: the dimension of the array icom as declared in the (sub)program from which d02mwf is called.
Constraint: ${\mathbf{licom}}\ge {\mathbf{neq}}+50$.
9: $\mathbf{com}\left({\mathbf{lcom}}\right)$Real (Kind=nag_wp) array Communication Array
On exit: used to communicate problem parameters to the integration routine d02nef. This must be the same communication array as the array com supplied to d02nef. In particular, the values of hmax and h0 are contained in com.
10: $\mathbf{lcom}$Integer Input
On entry: the dimension of the array com as declared in the (sub)program from which d02mwf is called.
Constraints:
the array com must be large enough for the requirements of d02nef. That is:
• if the system Jacobian is dense, ${\mathbf{lcom}}\ge 40+\left({\mathbf{maxord}}+4\right)×{\mathbf{neq}}+{{\mathbf{neq}}}^{2}$;
• if the system Jacobian is banded, ${\mathbf{lcom}}\ge 40+\left({\mathbf{maxord}}+4\right)×{\mathbf{neq}}+\left(2×{\mathbf{ml}}+{\mathbf{mu}}+1\right)×{\mathbf{neq}}+2×\phantom{\rule{0ex}{0ex}}\left({\mathbf{neq}}/\left({\mathbf{ml}}+{\mathbf{mu}}+1\right)+1\right)$.
Here ml and mu are the lower and upper bandwidths respectively that are to be specified in a subsequent call to d02npf.
11: $\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 $0$ is recommended. 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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{neq}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{neq}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{maxord}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{maxord}}\ge 1$.
${\mathbf{ifail}}=3$
On entry, jceval has an illegal value: ${\mathbf{jceval}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{jceval}}=\text{'N'}$ or $\text{'A'}$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{hmax}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{hmax}}\ge 0.0$.
${\mathbf{ifail}}=6$
On entry, ${\mathbf{itol}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{itol}}=0$ or $1$.
${\mathbf{ifail}}=8$
On entry, ${\mathbf{licom}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{neq}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{licom}}\ge 50+{\mathbf{neq}}$.
${\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

d02mwf is not threaded in any implementation.

None.

## 10Example

This example solves the plane pendulum problem, defined by the following equations:
 $x′ = u y′ = v u′ = -λx v′ = -λy-1 x2+y2 = 1.$
Differentiating the algebraic constraint once, a new algebraic constraint is obtained
 $xu+yv=0 .$
Differentiating the algebraic constraint one more time, substituting for ${x}^{\prime }$, ${y}^{\prime }$, ${u}^{\prime }$, ${v}^{\prime }$ and using ${x}^{2}+{y}^{2}-1=0$, the corresponding DAE system includes the differential equations and the algebraic equation in $\lambda$:
 $u2 + v2 - λ - y = 0 .$
We solve the reformulated DAE system
 $y1′ = y3 y2′ = y4 y3′ = -y5×y1 y4′ = -y5×y2-1 y32 + y42 - y5 - y2 = 0.$
For our experiments, we take consistent initial values
 $y1(0) = 1 , ​ y2(0) = 0 , ​ y3(0) = 0 , ​ y4(0) = 1 ​ and ​ y5(0) = 1$
at $t=0$.

### 10.1Program Text

Program Text (d02mwfe.f90)

### 10.2Program Data

Program Data (d02mwfe.d)

### 10.3Program Results

Program Results (d02mwfe.r)