# NAG Library Routine Document

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine d02nsf ( neq,
 Integer, Intent (In) :: neq, neqmax, nwkjac Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (Inout) :: rwork(50+4*neqmax) Character (1), Intent (In) :: jceval
#include nagmk26.h
 void d02nsf_ (const Integer *neq, const Integer *neqmax, const char *jceval, const Integer *nwkjac, double rwork[], Integer *ifail, const Charlen length_jceval)

## 3Description

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

## 4References

See the D02M–N Sub-chapter Introduction.

## 5Arguments

1:     $\mathbf{neq}$ – IntegerInput
On entry: the number of differential equations.
Constraint: $1\le {\mathbf{neq}}\le {\mathbf{neqmax}}$.
2:     $\mathbf{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:     $\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. If this option is used, the actual argument corresponding to jac in the call to d02nbf or d02ngf must be either d02nbz or d02ngz respectively.
${\mathbf{jceval}}=\text{'A'}$
You must supply a (sub)program to evaluate the Jacobian on a call to the integrator.
${\mathbf{jceval}}=\text{'D'}$
The default choice is to be made. In this case 'D' is interpreted as 'N'.
Only the first character of the actual argument jceval is passed to d02nsf; hence it is permissible for the actual argument to be more descriptive ‘Numerical’, ‘Analytical’ or ‘Default’ on a call to d02nsf.
Constraint: ${\mathbf{jceval}}=\text{'N'}$, $\text{'A'}$ or $\text{'D'}$.
4:     $\mathbf{nwkjac}$ – IntegerInput
On entry: the size of the workspace array wkjac, which you are supplying to the integrator, as declared in the (sub)program from which d02nsf is called.
Constraint: ${\mathbf{nwkjac}}\ge {\mathbf{neqmax}}×\left({\mathbf{neqmax}}+1\right)$.
5:     $\mathbf{rwork}\left(50+4×{\mathbf{neqmax}}\right)$ – 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.
6:     $\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, ${\mathbf{neq}}<1$, or ${\mathbf{neq}}>{\mathbf{neqmax}}$, or ${\mathbf{nwkjac}}<{\mathbf{neqmax}}×\left({\mathbf{neqmax}}+1\right)$, or ${\mathbf{jceval}}\ne \text{'N'}$, $\text{'A'}$ or $\text{'D'}$.
${\mathbf{ifail}}=-99$
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.

Not applicable.

## 8Parallelism and Performance

d02nsf is not thread safe and should not be called from a multithreaded user program. Please see Section 3.12.1 in How to Use the NAG Library and its Documentation for more information on thread safety.
d02nsf is not threaded in any implementation.