D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02NUF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D02NUF is a setup routine which must be called prior to an integrator in sub-chapter D02M–N, if sparse matrix linear algebra is required.

## 2  Specification

 SUBROUTINE D02NUF ( NEQ, NEQMAX, JCEVAL, NWKJAC, IA, NIA, JA, NJA, JACPVT, NJCPVT, SENS, U, ETA, LBLOCK, ISPLIT, RWORK, IFAIL)
 INTEGER NEQ, NEQMAX, NWKJAC, IA(NIA), NIA, JA(NJA), NJA, JACPVT(NJCPVT), NJCPVT, ISPLIT, IFAIL REAL (KIND=nag_wp) SENS, U, ETA, RWORK(50+4*NEQMAX) LOGICAL LBLOCK CHARACTER(1) JCEVAL

## 3  Description

D02NUF defines the linear algebra to be used as sparse matrix linear algebra, permits you to specify the method for calculating the Jacobian and its structure, and checks the validity of certain input values.

## 4  References

See the D02M–N sub-chapter Introduction.

## 5  Parameters

1:     NEQ – INTEGERInput
On entry: the number of differential equations.
Constraint: $1\le {\mathbf{NEQ}}\le {\mathbf{NEQMAX}}$.
2:     NEQMAX – INTEGERInput
On entry: a bound on the maximum number of differential equations to be solved during the integration.
Constraint: ${\mathbf{NEQMAX}}\ge {\mathbf{NEQ}}$.
3:     JCEVAL – CHARACTER(1)Input
On entry: specifies the technique to be used to compute the Jacobian.
${\mathbf{JCEVAL}}=\text{'N'}$
The sparsity structure and the value of the Jacobian are to be determined numerically by the integrator.
${\mathbf{JCEVAL}}=\text{'S'}$
The sparsity structure of the Jacobian is supplied in the arrays IA and JA but its value is to be determined numerically. This is the recommended mode of operation unless it is a simple matter to supply the Jacobian.
${\mathbf{JCEVAL}}=\text{'A'}$
The Jacobian will be evaluated by calls to JAC. The sparsity structure will be estimated by calls to JAC; that is, no explicit sparsity structure need be supplied in the arrays IA and JA.
${\mathbf{JCEVAL}}=\text{'F'}$
The sparsity structure of the Jacobian is supplied in IA and JA, and its value will be determined by calls to JAC. This is the recommended mode of operation if the JAC is simple to form.
${\mathbf{JCEVAL}}=\text{'D'}$
The default choice is to be made. In this case 'D' is interpreted as 'S'.
If the sparsity structure is supplied in arrays IA and JA, then any evidence from the numerical or analytical formation of the Jacobian that this structure is not correct, is ignored.
Only the first character of the actual parameter JCEVAL is passed to D02NUF; hence it is permissible for the actual argument to be more descriptive, e.g., ‘Numerical’, ‘Structural’, ‘Analytical’, ‘Full information’ or ‘Default’ in a call to D02NUF.
If the option ${\mathbf{JCEVAL}}=\text{'N'}$, $\text{'S'}$ or $\text{'D'}$ is used then the actual argument corresponding to JAC in the call to D02NDF or D02NJF must be either D02NDZ or D02NJZ respectively.
If integration is to be performed by reverse communication (D02NMF or D02NNF) then JCEVAL should be set to either 'N' or 'A'. In this case IA and JA are not used and their lengths may be set to $1$.
Constraint: ${\mathbf{JCEVAL}}=\text{'N'}$, $\text{'S'}$, $\text{'A'}$, $\text{'F'}$ or $\text{'D'}$.
4:     NWKJAC – INTEGERInput
On entry: the size of the array WKJAC, which you are supplying to the integrator, as declared in the (sub)program from which D02NUF is called.
Suggested value: ${\mathbf{NWKJAC}}=4×{\mathbf{NEQMAX}}$ if ${\mathbf{JCEVAL}}=\text{'N'}$ or $\text{'A'}$. If NWKJAC is less than this estimate, then a message is printed on the current advisory message unit (see X04ABF), and execution continues.
Constraint: if ${\mathbf{JCEVAL}}=\text{'S'}$, $\text{'F'}$ or $\text{'D'}$, ${\mathbf{NWKJAC}}\ge \mathit{nelement}+2×{\mathbf{NEQ}}$, where $\mathit{nelement}$ is the total number of nonzeros.
5:     IA(NIA) – INTEGER arrayInput
On entry: if ${\mathbf{JCEVAL}}=\text{'S'}$, $\text{'F'}$ or $\text{'D'}$, IA must contain details of the sparsity pattern to be used for the Jacobian. See JA.
IA is not used if ${\mathbf{JCEVAL}}=\text{'N'}$ or $\text{'A'}$.
6:     NIA – INTEGERInput
On entry: the dimension of the array IA as declared in the (sub)program from which D02NUF is called.
Constraints:
• if ${\mathbf{JCEVAL}}=\text{'S'}$, $\text{'F'}$ or $\text{'D'}$, ${\mathbf{NIA}}\ge {\mathbf{NEQ}}+1$;
• otherwise ${\mathbf{NIA}}\ge 1$.
7:     JA(NJA) – INTEGER arrayInput
On entry: if ${\mathbf{JCEVAL}}=\text{'S'}$, $\text{'F'}$ or $\text{'D'}$, JA must contain details of the sparsity pattern to be used for the Jacobian. JA contains the row indices where nonzero elements occur, reading in column-wise order, and IA contains the starting locations in JA of the descriptions of columns $1,2,\dots ,{\mathbf{NEQ}}$ in that order, with ${\mathbf{IA}}\left(1\right)=1$. Thus for each column index $j=1,2,\dots ,{\mathbf{NEQ}}$, the values of the row index $i$ in column $j$ where a nonzero element may occur are given by
 $i=JAk$
where ${\mathbf{IA}}\left(j\right)\le k<{\mathbf{IA}}\left(j+1\right)$.
Thus the total number of nonzeros, $\mathit{nelement}$, must be ${\mathbf{IA}}\left({\mathbf{NEQ}}+1\right)-1$. For example, for the following matrix
 $x 0 x 0 0 0 x x x 0 x x x 0 0 x 0 0 x x 0 0 0 x x$
where $x$ represents nonzero elements (13 in all) the arrays IA and JA should be
 $IAk 1 4 6 9 12 14 JAk 1 3 4 2 03 01 2 3 2 4 5 4 5$
JA is not used if ${\mathbf{JCEVAL}}=\text{'N'}$ or $\text{'A'}$.
8:     NJA – INTEGERInput
On entry: the dimension of the array JA as declared in the (sub)program from which D02NUF is called.
Constraints:
• if ${\mathbf{JCEVAL}}=\text{'S'}$, $\text{'F'}$ or $\text{'D'}$, ${\mathbf{NJA}}\ge {\mathbf{IA}}\left({\mathbf{NEQ}}+1\right)-1$;
• otherwise ${\mathbf{NJA}}\ge 1$.
9:     JACPVT(NJCPVT) – INTEGER arrayCommunication Array
On exit: data relating to the Jacobian sparsity structure.
10:   NJCPVT – INTEGERInput
On entry: the length of the array JACPVT, which you are supplying to the integrator, as dimensioned in the sub(program) from which D02NUF is called.
Suggested value: ${\mathbf{NJCPVT}}=20×{\mathbf{NEQMAX}}$ if ${\mathbf{JCEVAL}}=\text{'N'}$ or $\text{'A'}$. If NJCPVT is less than this estimate, then a message is printed on the current advisory message unit (see X04ABF), and execution continues.
Constraint: if ${\mathbf{JCEVAL}}=\text{'S'}$, $\text{'F'}$ or $\text{'D'}$, ${\mathbf{NJCPVT}}\ge 3×\mathit{nelement}+14×{\mathbf{NEQ}}$, where $\mathit{nelement}$ is the total number of nonzeros.
11:   SENS – REAL (KIND=nag_wp)Input
On entry: a threshold parameter used to determine whether or not a matrix element is zero; when SENS is set to $0.0$ on entry, the routine will use . Otherwise the absolute value of SENS is used.
12:   U – REAL (KIND=nag_wp)Input
On entry: should have a value between $0.0$ and $0.9999$. Otherwise a default value of $0.1$ is used. When the sparsity pattern has been evaluated, the first Jacobian computed is decomposed with U governing the choice of pivots; subsequent Jacobian decompositions use the same pattern of decomposition until the sparsity pattern is re-evaluated. When searching a row for a pivot, any element is excluded from the search which is less than U times the largest of those elements in the row available as pivots. Thus decreasing U biases the algorithm towards maintaining sparsity at the expense of numerical stability.
13:   ETA – REAL (KIND=nag_wp)Input
On entry: a relative pivot threshold, below which on subsequent decompositions (as described under U), an internal error is provoked.
${\mathbf{ETA}}>1.0$
No check on pivot size is made.
${\mathbf{ETA}}\le 0.0$
The default value ${\mathbf{ETA}}=\text{1.0E−4}$ is used.
14:   LBLOCK – LOGICALInput
On entry: indicates if preordering is used before decomposition.
If ${\mathbf{LBLOCK}}=\mathrm{.TRUE.}$, on entry, the Jacobian matrix is preordered to block lower triangular form before a decomposition is performed (this is the recommended mode). If you know the structure of the Jacobian to be irreducible, that is not permutable to block lower triangular form, then you should set ${\mathbf{LBLOCK}}=\mathrm{.FALSE.}$. For example, a Jacobian arising from using the method of lines for parabolic partial differential equations would normally be irreducible. (See the specification of D02NXF for optional output concerning LBLOCK.)
15:   ISPLIT – INTEGERInput
On entry: this parameter is used for splitting the integer workspace JACPVT to effect an efficient decomposition. It must satisfy $1\le {\mathbf{ISPLIT}}\le 99$. If ISPLIT lies outside this range on entry, a default value of $73$ is used. An appropriate value for ISPLIT for subsequent runs on similar problems is available via the optional output D02NXF.
Suggested value: ${\mathbf{ISPLIT}}=73$, unless you have information from a previous run of a similar problem.
16:   RWORK($50+4×{\mathbf{NEQMAX}}$) – REAL (KIND=nag_wp) arrayCommunication 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.
17:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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, an illegal input was detected.

Not applicable.