NAG Library Routine Document

d02mwf (dae_dassl_setup)


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.


Fortran Interface
Subroutine d02mwf ( neq, maxord, jceval, hmax, h0, itol, icom, licom, com, lcom, ifail)
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
C Header Interface
#include <nagmk26.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)


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.




1:     neq – IntegerInput
On entry: the number of differential-algebraic equations to be solved.
Constraint: neq1.
2:     maxord – IntegerInput
On entry: the maximum order to be used for the BDF method. Orders up to 5th order are available; setting maxord>5 means that the maximum order used will be 5.
Constraint: 1maxord.
3:     jceval – Character(1)Input
On entry: specifies the technique to be used to compute the Jacobian.
The Jacobian is to be evaluated numerically by the integrator.
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: jceval='N' or 'A'.
4:     hmax – Real (Kind=nag_wp)Input
On entry: the maximum absolute step size to be allowed. Set hmax=0.0 if this option is not required.
Constraint: hmax0.0.
5:     h0 – Real (Kind=nag_wp)Input
On entry: the step size to be attempted on the first step. Set h0=0.0 if the initial step size is calculated internally.
6:     itol – IntegerInput
On entry: a value to indicate the form of the local error test.
rtol and atol are single element vectors.
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: itol=0 or 1.
7:     icomlicom – Integer arrayCommunication Array
On exit: used to communicate details of the task to be carried out to the integration routine d02nef.
8:     licom – IntegerInput
On entry: the dimension of the array icom as declared in the (sub)program from which d02mwf is called.
Constraint: licomneq+50.
9:     comlcom – Real (Kind=nag_wp) arrayCommunication 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:   lcom – IntegerInput
On entry: the dimension of the array com as declared in the (sub)program from which d02mwf is called.
the array com must be large enough for the requirements of d02nef. That is:
  • if the system Jacobian is dense, lcom 40 + maxord+4 × neq + neq2 ;
  • if the system Jacobian is banded, lcom 40 + maxord+4 × neq + 2×ml+mu+1 × neq + 2 × neq / ml + mu + 1 + 1 .
Here ml and mu are the lower and upper bandwidths respectively that are to be specified in a subsequent call to d02npf.
11:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 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 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 -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry 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:
On entry, neq=value.
Constraint: neq1.
On entry, maxord=value.
Constraint: maxord1.
On entry, jceval has an illegal value: jceval=value.
Constraint: jceval='N' or 'A'.
On entry, hmax=value.
Constraint: hmax0.0.
On entry, itol=value.
Constraint: itol=0 or 1.
On entry, licom=value and neq=value.
Constraint: licom50+neq.
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.
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.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


Not applicable.

Parallelism and Performance

d02mwf is not threaded in any implementation.

Further Comments



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, y, u, v and using x2+y2-1=0, the corresponding DAE system includes the differential equations and the algebraic equation in λ:
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
y10 = 1 , ​ y20 = 0 , ​ y30 = 0 , ​ y40 = 1 ​ and ​ y50 = 1  
at t=0.

Program Text

Program Text (d02mwfe.f90)

Program Data

Program Data (d02mwfe.d)

Program Results

Program Results (d02mwfe.r)