NAG Library Routine Document

d02qwf  (ivp_adams_setup)

 Contents

    1  Purpose
    7  Accuracy
    10  Example

1
Purpose

d02qwf is a setup routine which must be called prior to the first call of either of the integrators d02qff and d02qgf and may be called prior to any continuation call to these routines.

2
Specification

Fortran Interface
Integer, Intent (In):: neqf, latol, lrtol, maxstp, neqg, lrwork, liwork
Integer, Intent (Inout):: iwork(liwork), ifail
Real (Kind=nag_wp), Intent (In):: atol(latol), rtol(lrtol), tcrit, hmax
Real (Kind=nag_wp), Intent (Inout):: rwork(lrwork)
Logical, Intent (In):: vectol, onestp, crit, sophst
Logical, Intent (Inout):: alterg
Character (1), Intent (Inout):: statef
C Header Interface
#include nagmk26.h
void  d02qwf_ ( char *statef, const Integer *neqf, const logical *vectol, const double atol[], const Integer *latol, const double rtol[], const Integer *lrtol, const logical *onestp, const logical *crit, const double *tcrit, const double *hmax, const Integer *maxstp, const Integer *neqg, logical *alterg, const logical *sophst, double rwork[], const Integer *lrwork, Integer iwork[], const Integer *liwork, Integer *ifail, const Charlen length_statef)

3
Description

d02qwf permits initialization of the integration method and setting of optional inputs prior to any call of d02qff or d02qgf. It must be called before the first call of either of the routines d02qff or d02qgf and it may be called before any continuation call of either of the routines d02qff or d02qgf.

4
References

None.

5
Arguments

1:     statef – Character(1)Input/Output
On entry: specifies whether the integration routine (d02qff or d02qgf) is to start a new system of ordinary differential equations, restart a system or continue with a system.
statef='S'
Start integration with a new differential system.
statef='R'
Restart integration with the current differential system.
statef='C'
Continue integration with the current differential system.
Constraint: statef='S', 'R' or 'C'.
On exit: is set to 'C', except that if an error is detected, statef is unchanged.
2:     neqf – IntegerInput
On entry: the number of ordinary differential equations to be solved by the integration routine. neqf must remain unchanged on subsequent calls to d02qwf with statef='C' or 'R'.
Constraint: neqf1.
3:     vectol – LogicalInput
On entry: specifies whether vector or scalar error control is to be employed for the local error test in the integration.
If vectol=.TRUE., vector error control will be used and you must specify values of rtoli and atoli, for i=1,2,,neqf.
Otherwise scalar error control will be used and you must specify values of just rtol1 and atol1.
The error test to be satisfied is of the form
i=1neqf eiwi 21.0.  
where wi is defined as follows:
vectol wi
.TRUE. rtoli×yi+atoli
.FALSE. rtol1×yi+atol1
and ei is an estimate of the local error in yi, computed internally. vectol must remain unchanged on subsequent calls to d02qwf with statef='C' or 'R'.
4:     atollatol – Real (Kind=nag_wp) arrayInput
On entry: the absolute local error tolerance (see vectol).
Constraint: atoli0.0.
5:     latol – IntegerInput
On entry: the dimension of the array atol as declared in the (sub)program from which d02qwf is called.
Constraints:
  • if vectol=.TRUE., latolneqf;
  • if vectol=.FALSE., latol1.
6:     rtollrtol – Real (Kind=nag_wp) arrayInput
On entry: the relative local error tolerance (see vectol).
Constraints:
  • rtoli0.0;
  • if atoli=0.0, rtoli4.0×machine precision.
7:     lrtol – IntegerInput
On entry: the dimension of the array rtol as declared in the (sub)program from which d02qwf is called.
Constraints:
  • if vectol=.TRUE., lrtolneqf;
  • if vectol=.FALSE., lrtol1.
8:     onestp – LogicalInput
On entry: the mode of operation of the integration routine. If onestp=.TRUE., the integration routine will operate in one-step mode, that is it will return after each successful step. Otherwise the integration routine will operate in interval mode, that is it will return at the end of the integration interval.
9:     crit – LogicalInput
On entry: specifies whether or not there is a value for the independent variable beyond which integration is not to be attempted. Setting crit=.TRUE. indicates that there is such a point, whereas crit=.FALSE. indicates that there is no such restriction.
10:   tcrit – Real (Kind=nag_wp)Input
On entry: with crit=.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.
11:   hmax – Real (Kind=nag_wp)Input
On entry: if hmax0.0, a bound on the absolute step size during the integration is taken to be hmax.
If 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 hmax=0.0 first.
Note:  this argument only affects the step size if the option crit=.TRUE. is being used.
12:   maxstp – IntegerInput
On entry: a bound on the number of attempted steps in any one call to the integration routine. If maxstp0 on entry, a value of 1000 is used.
13:   neqg – IntegerInput
On entry: specifies whether or not root-finding is required in d02qff or d02qgf.
neqg0
No root-finding is attempted.
neqg>0
Root-finding is required and neqg event functions will be specified for the integration routine.
14:   alterg – LogicalInput/Output
On entry: specifies whether or not the event functions have been redefined. alterg need not be set if statef='S'. On subsequent calls to d02qwf, if neqg has been set positive, alterg=.FALSE. specifies that the event functions remain unchanged, whereas alterg=.TRUE. specifies that the event functions have changed. Because of the expense in reinitializing the root searching procedure, alterg should be set to .TRUE. only if the event functions really have been altered. alterg need not be set if the root-finding option is not used.
On exit: is set to .FALSE..
15:   sophst – LogicalInput
On entry: the type of search technique to be used in the root-finding. If sophst=.TRUE. then a sophisticated and reliable but expensive technique will be used, whereas for sophst=.FALSE. a simple but less reliable technique will be used. If neqg0, sophst is not referenced.
16:   rworklrwork – Real (Kind=nag_wp) arrayCommunication Array
This must be the same argument rwork supplied to the integration routine. It is used to pass information to the integration routine and therefore the contents of this array must not be changed before calling the integration routine.
17:   lrwork – IntegerInput
On entry: the dimension of the array rwork as declared in the (sub)program from which d02qwf is called.
Constraint: lrwork21×1+neqf+2×J+K×neqg+2, where
J= neqf if ​vectol=.TRUE. 1 if ​vectol=.FALSE.  
and
K= 14 if ​ sophst=.TRUE. 5 if ​ sophst=.FALSE.  
.
18:   iworkliwork – Integer arrayCommunication Array
This must be the same argument iwork supplied to the integration routine. It is used to pass information to the integration routine and therefore the contents of this array must not be changed before calling the integration routine.
19:   liwork – IntegerInput
On entry: the dimension of the array iwork as declared in the (sub)program from which d02qwf is called.
Constraints:
  • if sophst=.TRUE., liwork21+4×neqg;
  • if sophst=.FALSE., liwork21+neqg.
20:   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).

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:
ifail=1
Illegal input detected.
ifail=-99
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.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

d02qwf 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.
d02qwf is not threaded in any implementation.

9
Further Comments

Prior to a continuation call of the integration routine, you may reset any of the optional parameters by calling d02qwf with statef='C'. You may reset:
hmax to alter the maximum step size selection;
rtol, atol to change the error requirements;
maxstp to increase or decrease the number of attempted steps before an error exit is returned;
onestp to change the operation mode of the integration routine;
crit, tcrit to alter the point beyond which integration must not be attempted; and
neqg, alterg, sophst to alter the number and type of event functions, and also the search method.
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 routine (see d02qff and d02qgf), then statef should be set to statef='R' and any of the optional parameters may be reset also. If you want to redefine the system of differential equations or start a new integration problem, then statef should be set to statef='S'. Resetting statef='R' or 'S' on normal continuation calls causes a restart in the integration process, which is very inefficient when not needed.

10
Example

See Section 10 in d02qff and d02qgf.
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017