# NAG CL Interfaced02qwc (ivp_​adams_​setup)

Settings help

CL Name Style:

## 1Purpose

d02qwc is a setup function which must be called prior to the first call of the integration function d02qfc and may be called prior to any subsequent continuation call of the integrator.

## 2Specification

 #include
 void d02qwc (Nag_Start *state, Integer neqf, Nag_Boolean vectol, const double atol[], const double rtol[], Nag_Boolean one_step, Nag_Boolean crit, double tcrit, double hmax, Integer max_step, Integer neqg, Nag_Boolean *alter_g, Nag_Boolean sophist, Nag_ODE_Adams *opt, NagError *fail)
The function may be called by the names: d02qwc or nag_ode_ivp_adams_setup.

## 3Description

d02qwc permits initialization of the integration method and setting of integration inputs prior to any call of d02qfc.
It must be called before the first call of the function d02qfc and it may be called before any continuation call of d02qfc.

None.

## 5Arguments

1: $\mathbf{state}$Nag_Start * Input/Output
On entry: specifies whether the integration function d02qfc is to start a new system of ordinary differential equations, restart a system or continue with a system.
${\mathbf{state}}=\mathrm{Nag_NewStart}$
Start integration with a new differential system.
${\mathbf{state}}=\mathrm{Nag_ReStart}$
Restart integration with the current differential system.
${\mathbf{state}}=\mathrm{Nag_Continue}$
Continue integration with the current differential system.
Constraint: ${\mathbf{state}}=\mathrm{Nag_NewStart}$, $\mathrm{Nag_ReStart}$ or $\mathrm{Nag_Continue}$.
On exit: state is set to $\mathrm{Nag_Continue}$, except that if an error is detected, state is unchanged.
2: $\mathbf{neqf}$Integer Input
On entry: the number of ordinary differential equations to be solved by the integration function. neqf must remain unchanged on subsequent calls to d02qwc with ${\mathbf{state}}=\mathrm{Nag_Continue}$ or $\mathrm{Nag_ReStart}$.
Constraint: ${\mathbf{neqf}}\ge 1$.
3: $\mathbf{vectol}$Nag_Boolean Input
On entry: specifies whether vector or scalar error control is to be employed for the local error test in the integration. If ${\mathbf{vectol}}=\mathrm{Nag_TRUE}$, then vector error control will be used and you must specify values of ${\mathbf{rtol}}\left[\mathit{i}\right]$ and ${\mathbf{atol}}\left[\mathit{i}\right]$, for $\mathit{i}=0,1,\dots ,{\mathbf{neqf}}-1$. Otherwise scalar error control will be used and you must specify values of just ${\mathbf{rtol}}\left[0\right]$ and ${\mathbf{atol}}\left[0\right]$.
The error test to be satisfied is of the form
 $∑ i=1 neqf ( e i w i ) 2 ≤ 1.0 ,$
where ${w}_{i}$ is defined as follows:
vectol ${\mathbit{w}}_{\mathbit{i}}$
Nag_TRUE ${\mathbf{rtol}}\left[i-1\right]×|{y}_{i}|+{\mathbf{atol}}\left[i-1\right]$
Nag_FALSE ${\mathbf{rtol}}\left[0\right]×|{y}_{i}|+{\mathbf{atol}}\left[0\right]$
and ${e}_{i}$ is an estimate of the local error in ${y}_{i}$, computed internally. vectol must remain unchanged on subsequent calls to d02qwc with ${\mathbf{state}}=\mathrm{Nag_Continue}$ or $\mathrm{Nag_ReStart}$.
4: $\mathbf{atol}\left[{\mathbf{neqf}}\right]$const double Input
On entry: the absolute local error tolerance (see vectol).
Constraint: ${\mathbf{atol}}\left[i\right]\ge 0.0$.
5: $\mathbf{rtol}\left[{\mathbf{neqf}}\right]$const double Input
On entry: the relative local error tolerance (see vectol).
Constraints:
• ${\mathbf{rtol}}\left[i\right]\ge 0.0$;
• if ${\mathbf{atol}}\left[i\right]=0.0$, .
6: $\mathbf{one_step}$Nag_Boolean Input
On entry: the mode of operation of the integration function. If ${\mathbf{one_step}}=\mathrm{Nag_TRUE}$, the integration function will operate in one-step mode, that is it will return after each successful step. Otherwise the integration function will operate in interval mode, that is it will return at the end of the integration interval.
7: $\mathbf{crit}$Nag_Boolean Input
On entry: specifies whether or not there is a value for the independent variable beyond which integration is not to be attempted. Setting ${\mathbf{crit}}=\mathrm{Nag_TRUE}$ indicates that there is such a point, whereas ${\mathbf{crit}}=\mathrm{Nag_FALSE}$ indicates that there is no such restriction.
8: $\mathbf{tcrit}$double Input
On entry: with ${\mathbf{crit}}=\mathrm{Nag_TRUE}$, tcrit must be set to a value of the independent variable beyond which integration is not to be attempted. Otherwise tcrit is not referenced.
9: $\mathbf{hmax}$double Input
On entry:
${\mathbf{hmax}}\ne 0.0$
A bound on the absolute step size during the integration is taken to be $|{\mathbf{hmax}}|$.
${\mathbf{hmax}}=0.0$
No bound is assumed on the step size during the integration.
A bound may be required if there are features of the solution on very short ranges of integration which may be missed. You should try ${\mathbf{hmax}}=0.0$ first.
Note: this argument only affects the step size if the option ${\mathbf{crit}}=\mathrm{Nag_TRUE}$ is being used.
10: $\mathbf{max_step}$Integer Input
On entry: a bound on the number of attempted steps in any one call to the integration function.
If ${\mathbf{max_step}}\le 0$ on entry, a value of 1000 is used.
11: $\mathbf{neqg}$Integer Input
On entry: specifies whether or not root-finding is required in d02qfc.
${\mathbf{neqg}}\le 0$
No root-finding is attempted.
${\mathbf{neqg}}>0$
Root-finding is required and neqg event functions will be specified for the integration function.
12: $\mathbf{alter_g}$Nag_Boolean * Input/Output
On entry: specifies whether or not the event functions have been redefined. alter_g need not be set if ${\mathbf{state}}=\mathrm{Nag_NewStart}$. On subsequent calls to d02qwc, if neqg has been set positive, then ${\mathbf{alter_g}}=\mathrm{Nag_FALSE}$ specifies that the event functions remain unchanged, whereas ${\mathbf{alter_g}}=\mathrm{Nag_TRUE}$ specifies that the event functions have changed. Because of the expense in reinitializing the root searching procedure, alter_g should be set to Nag_TRUE only if the event functions really have been altered. alter_g need not be set if the root-finding option is not used.
On exit: alter_g is set to Nag_FALSE, except that if an error is detected, alter_g is unchanged.
13: $\mathbf{sophist}$Nag_Boolean Input
On entry: the type of search technique to be used in the root-finding.
${\mathbf{sophist}}=\mathrm{Nag_TRUE}$
A sophisticated and reliable but expensive technique will be used, whereas for ${\mathbf{sophist}}=\mathrm{Nag_FALSE}$ a simple but less reliable technique will be used.
${\mathbf{neqg}}\le 0$
sophist is not referenced.
14: $\mathbf{opt}$Nag_ODE_Adams * Output
On exit: the structure of type Nag_ODE_Adams will have been initialized to appropriate values for entry to the integration function d02qfc. opt must be passed unchanged to the integration function.
Memory will have been allocated by d02qwc to several pointers within opt, this memory is used by the integration function d02qfc and the interpolation function d02qzc. The library function d02qyc is provided so that this memory can be freed when all calls to d02qfc and d02qzc have been completed. A call to d02qyc may also be made prior to reentering d02qwc with ${\mathbf{state}}=\mathrm{Nag_NewStart}$.
15: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument state had an illegal value.
NE_BOOL_NOT_SET
The Boolean argument crit has not been set to Nag_TRUE or Nag_FALSE.
NE_INT_ARG_LT
On entry, ${\mathbf{neqf}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{neqf}}\ge 1$.
NE_NEQF_CHANGED
${\mathbf{state}}=⟨\mathit{string}⟩$ but neqf has been changed. neqf was $⟨\mathit{\text{value}}⟩$ but is now $⟨\mathit{\text{value}}⟩$.
NE_NEQG_CHANGED
${\mathbf{alter_g}}=\mathrm{Nag_FALSE}$ but neqg has been changed. neqg was $⟨\mathit{\text{value}}⟩$ but is now $⟨\mathit{\text{value}}⟩$.
NE_REAL_ARG_LT
On entry, ${\mathbf{atol}}\left[⟨\mathit{\text{value}}⟩\right]$ must not be less than 0.0: ${\mathbf{atol}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{rtol}}\left[⟨\mathit{\text{value}}⟩\right]$ must not be less than 0.0: ${\mathbf{rtol}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
NE_REAL_LT_COND
When ${\mathbf{atol}}\left[⟨\mathit{\text{value}}⟩\right]=0.0$, ${\mathbf{rtol}}\left[⟨\mathit{\text{value}}⟩\right]$ must not be less than $4×\epsilon$. ${\mathbf{rtol}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$, $4×\epsilon =⟨\mathit{\text{value}}⟩$.
NE_STATE
${\mathbf{state}}\ne \mathrm{Nag_NewStart}$ on first call.
NE_VECTOL_CHANGED
${\mathbf{state}}=⟨\mathit{string}⟩$ but vectol has been changed. vectol was $⟨\mathit{string}⟩$ but is now $⟨\mathit{string}⟩$.

Not applicable.

## 8Parallelism and Performance

d02qwc is not threaded in any implementation.

Prior to a continuation call of the integration function, you may reset some of the arguments by calling d02qwc with ${\mathbf{state}}=\mathrm{Nag_Continue}$. You may reset:
If the behaviour of the system of differential equations has altered and you wish to restart the integration method from the value of t output from the integration function, then set ${\mathbf{state}}=\mathrm{Nag_ReStart}$ and some of the integration arguments may be reset also. If you want to redefine the system of differential equations or start a new integration problem, then set ${\mathbf{state}}=\mathrm{Nag_NewStart}$. Resetting ${\mathbf{state}}=\mathrm{Nag_ReStart}$ or $\mathrm{Nag_NewStart}$ on normal continuation calls causes a restart in the integration process, which is very inefficient when not needed.