Logo Search packages:      
Sourcecode: octave3.2 version File versions

slsode.f

*DECK SLSODE
      SUBROUTINE SLSODE (F, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL, ITASK,
     1                  ISTATE, IOPT, RWORK, LRW, IWORK, LIW, JAC, MF)
      EXTERNAL F, JAC
      INTEGER NEQ, ITOL, ITASK, ISTATE, IOPT, LRW, IWORK, LIW, MF
      REAL Y, T, TOUT, RTOL, ATOL, RWORK
      DIMENSION NEQ(*), Y(*), RTOL(*), ATOL(*), RWORK(LRW), IWORK(LIW)
C***BEGIN PROLOGUE  SLSODE
C***PURPOSE  Livermore Solver for Ordinary Differential Equations.
C            SLSODE solves the initial-value problem for stiff or
C            nonstiff systems of first-order ODE



































































's,C               dy/dt = f(t,y),   or, in component form,C               dy(i)/dt = f(i) = f(i,t,y(1),y(2),...,y(N)),  i=1,...,N.C***CATEGORY  I1AC***TYPE      SINGLE PRECISION (SLSODE-S, DLSODE-D)C***KEYWORDS  ORDINARY DIFFERENTIAL EQUATIONS, INITIAL VALUE PROBLEM,C             STIFF, NONSTIFFC***AUTHOR  Hindmarsh, Alan C., (LLNL)C             Center for Applied Scientific Computing, L-561C             Lawrence Livermore National LaboratoryC             Livermore, CA 94551.C***DESCRIPTIONCC     NOTE: The "Usage" and "Arguments" sections treat only a subset ofC           available options, in condensed fashion.  The optionsC           covered and the information supplied will support mostC           standard uses of SLSODE.CC           For more sophisticated uses, full details on all options areC           given in the concluding section, headed "Long Description."C           A synopsis of the SLSODE Long Description is provided at theC           beginning of that section; general topics covered are:C           - Elements of the call sequence; optional input and outputC           - Optional supplemental routines in the SLSODE packageC           - internal COMMON blockCC *Usage:C     Communication between the user and the SLSODE package, for normalC     situations, is summarized here.  This summary describes a subsetC     of the available options.  See "Long Description" for completeC     details, including optional communication, nonstandard options,C     and instructions for special situations.CC     A sample program is given in the "Examples" section.CC     Refer to the argument descriptions for the definitions of theC     quantities that appear in the following sample declarations.CC     For MF = 10,C        PARAMETER  (LRW = 20 + 16*NEQ,           LIW = 20)C     For MF = 21 or 22,C        PARAMETER  (LRW = 22 +  9*NEQ + NEQ**2,  LIW = 20 + NEQ)C     For MF = 24 or 25,C        PARAMETER  (LRW = 22 + 10*NEQ + (2*ML+MU)*NEQ,C       *                                         LIW = 20 + NEQ)CC        EXTERNAL F, JACC        INTEGER  NEQ, ITOL, ITASK, ISTATE, IOPT, LRW, IWORK(LIW),C       *         LIW, MFC        REAL Y(NEQ), T, TOUT, RTOL, ATOL(ntol), RWORK(LRW)CC        CALL SLSODE (F, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL, ITASK,C       *            ISTATE, IOPT, RWORK, LRW, IWORK, LIW, JAC, MF)CC *Arguments:C     F     :EXT    Name of subroutine for right-hand-side vector f.C                   This name must be declared EXTERNAL in callingC                   program.  The form of F must be:CC                   SUBROUTINE  F (NEQ, T, Y, YDOT)C                   INTEGER  NEQC                   REAL T, Y(*), YDOT(*)CC                   The inputs are NEQ, T, Y.  F is to setCC                   YDOT(i) = f(i,T,Y(1),Y(2),...,Y(NEQ)),C                                                     i = 1, ..., NEQ .CC     NEQ   :IN     Number of first-order ODE's.
C
C     Y     :INOUT  Array of values of the y(t) vector, of length NEQ.
C                   Input:  For the first call, Y should contain the
C                           values of y(t) at t = T. (Y is an input
C                           variable only if ISTATE = 1.)
C                   Output: On return, Y will contain the values at the
C                           new t-value.
C
C     T     :INOUT  Value of the independent variable.  On return it
C                   will be the current value of t (normally TOUT).
C
C     TOUT  :IN     Next point where output is desired (.NE. T).
C
C     ITOL  :IN     1 or 2 according as ATOL (below) is a scalar or
C                   an array.
C
C     RTOL  :IN     Relative tolerance parameter (scalar).
C
C     ATOL  :IN     Absolute tolerance parameter (scalar or array).
C                   If ITOL = 1, ATOL need not be dimensioned.
C                   If ITOL = 2, ATOL must be dimensioned at least NEQ.
C
C                   The estimated local error in Y(i) will be controlled
C                   so as to be roughly less (in magnitude) than
C
C                   EWT(i) = RTOL*ABS(Y(i)) + ATOL     if ITOL = 1, or
C                   EWT(i) = RTOL*ABS(Y(i)) + ATOL(i)  if ITOL = 2.
C
C                   Thus the local error test passes if, in each
C                   component, either the absolute error is less than
C                   ATOL (or ATOL(i)), or the relative error is less
C                   than RTOL.
C
C                   Use RTOL = 0.0 for pure absolute error control, and
C                   use ATOL = 0.0 (or ATOL(i) = 0.0) for pure relative
C                   error control.  Caution:  Actual (global) errors may
C                   exceed these local tolerances, so choose them
C                   conservatively.
C
C     ITASK :IN     Flag indicating the task SLSODE is to perform.
C                   Use ITASK = 1 for normal computation of output
C                   values of y at t = TOUT.
C
C     ISTATE:INOUT  Index used for input and output to specify the state
C                   of the calculation.
C                   Input:
C                    1   This is the first call for a problem.
C                    2   This is a subsequent call.
C                   Output:
C                    1   Nothing was done, as TOUT was equal to T.
C                    2   SLSODE was successful (otherwise, negative).
C                        Note that ISTATE need not be modified after a
C                        successful return.
C                   -1   Excess work done on this call (perhaps wrong
C                        MF).
C                   -2   Excess accuracy requested (tolerances too
C                        small).
C                   -3   Illegal input detected (see printed message).
C                   -4   Repeated error test failures (check all
C                        inputs).
C                   -5   Repeated convergence failures (perhaps bad
C                        Jacobian supplied or wrong choice of MF or
C                        tolerances).
C                   -6   Error weight became zero during problem
C                        (solution component i vanished, and ATOL or
C                        ATOL(i) = 0.).
C
C     IOPT  :IN     Flag indicating whether optional inputs are used:
C                   0   No.
C                   1   Yes.  (See "Optional inputs" under 
"LongC                       Description," Part 1.)
C
C     RWORK :WORK   Real work array of length at least:
C                   20 + 16*NEQ                    for MF = 10,
C                   22 +  9*NEQ + NEQ**2           for MF = 21 or 22,
C                   22 + 10*NEQ + (2*ML + MU)*NEQ  for MF = 24 or 25.
C
C     LRW   :IN     Declared length of RWORK (in user































's DIMENSIONC                   statement).CC     IWORK :WORK   Integer work array of length at least:C                   20        for MF = 10,C                   20 + NEQ  for MF = 21, 22, 24, or 25.CC                   If MF = 24 or 25, input in IWORK(1),IWORK(2) theC                   lower and upper Jacobian half-bandwidths ML,MU.CC                   On return, IWORK contains information that may beC                   of interest to the user:CC            Name   Location   MeaningC            -----  ---------  -----------------------------------------C            NST    IWORK(11)  Number of steps taken for the problem soC                              far.C            NFE    IWORK(12)  Number of f evaluations for the problemC                              so far.C            NJE    IWORK(13)  Number of Jacobian evaluations (and ofC                              matrix LU decompositions) for the problemC                              so far.C            NQU    IWORK(14)  Method order last used (successfully).C            LENRW  IWORK(17)  Length of RWORK actually required.  ThisC                              is defined on normal returns and on anC                              illegal input return for insufficientC                              storage.C            LENIW  IWORK(18)  Length of IWORK actually required.  ThisC                              is defined on normal returns and on anC                              illegal input return for insufficientC                              storage.CC     LIW   :IN     Declared length of IWORK (in user's DIMENSION
C                   statement).
C
C     JAC   :EXT    Name of subroutine for Jacobian matrix (MF =
C                   21 or 24).  If used, this name must be declared
C                   EXTERNAL in calling program.  If not used, pass a
C                   dummy name.  The form of JAC must be:
C
C                   SUBROUTINE JAC (NEQ, T, Y, ML, MU, PD, NROWPD)
C                   INTEGER NEQ, ML, MU, NROWPD
C                   REAL T, Y(*), PD(NROWPD,*)
C
C                   See item c, under "Description" below for more
C                   information about JAC.
C
C     MF    :IN     Method flag.  Standard values are:
C                   10  Nonstiff (Adams) method, no Jacobian used.
C                   21  Stiff (BDF) method, user-supplied full Jacobian.
C                   22  Stiff method, internally generated full
C                       Jacobian.
C                   24  Stiff method, user-supplied banded Jacobian.
C                   25  Stiff method, internally generated banded
C                       Jacobian.
C
C *Description:
C     SLSODE solves the initial value problem for stiff or nonstiff
C     systems of first-order ODE

















































































































's,CC        dy/dt = f(t,y) ,CC     or, in component form,CC        dy(i)/dt = f(i) = f(i,t,y(1),y(2),...,y(NEQ))C                                                  (i = 1, ..., NEQ) .CC     SLSODE is a package based on the GEAR and GEARB packages, and onC     the October 23, 1978, version of the tentative ODEPACK userC     interface standard, with minor modifications.CC     The steps in solving such a problem are as follows.CC     a. First write a subroutine of the formCC           SUBROUTINE  F (NEQ, T, Y, YDOT)C           INTEGER  NEQC           REAL T, Y(*), YDOT(*)CC        which supplies the vector function f by loading YDOT(i) withC        f(i).CC     b. Next determine (or guess) whether or not the problem is stiff.C        Stiffness occurs when the Jacobian matrix df/dy has anC        eigenvalue whose real part is negative and large in magnitudeC        compared to the reciprocal of the t span of interest.  If theC        problem is nonstiff, use method flag MF = 10.  If it is stiff,C        there are four standard choices for MF, and SLSODE requires theC        Jacobian matrix in some form.  This matrix is regarded eitherC        as full (MF = 21 or 22), or banded (MF = 24 or 25).  In theC        banded case, SLSODE requires two half-bandwidth parameters MLC        and MU. These are, respectively, the widths of the lower andC        upper parts of the band, excluding the main diagonal.  Thus theC        band consists of the locations (i,j) withCC           i - ML <= j <= i + MU ,CC        and the full bandwidth is ML + MU + 1 .CC     c. If the problem is stiff, you are encouraged to supply theC        Jacobian directly (MF = 21 or 24), but if this is not feasible,C        SLSODE will compute it internally by difference quotients (MF =C        22 or 25).  If you are supplying the Jacobian, write aC        subroutine of the formCC           SUBROUTINE  JAC (NEQ, T, Y, ML, MU, PD, NROWPD)C           INTEGER  NEQ, ML, MU, NRWOPDC           REAL T, Y(*), PD(NROWPD,*)CC        which provides df/dy by loading PD as follows:C        - For a full Jacobian (MF = 21), load PD(i,j) with df(i)/dy(j),C          the partial derivative of f(i) with respect to y(j).  (IgnoreC          the ML and MU arguments in this case.)C        - For a banded Jacobian (MF = 24), load PD(i-j+MU+1,j) withC          df(i)/dy(j); i.e., load the diagonal lines of df/dy into theC          rows of PD from the top down.C        - In either case, only nonzero elements need be loaded.CC     d. Write a main program that calls subroutine SLSODE once for eachC        point at which answers are desired.  This should also provideC        for possible use of logical unit 6 for output of error messagesC        by SLSODE.CC        Before the first call to SLSODE, set ISTATE = 1, set Y and T toC        the initial values, and set TOUT to the first output point.  ToC        continue the integration after a successful return, simplyC        reset TOUT and call SLSODE again.  No other parameters need beC        reset.CC *Examples:C     The following is a simple example problem, with the coding neededC     for its solution by SLSODE. The problem is from chemical kinetics,C     and consists of the following three rate equations:CC        dy1/dt = -.04*y1 + 1.E4*y2*y3C        dy2/dt = .04*y1 - 1.E4*y2*y3 - 3.E7*y2**2C        dy3/dt = 3.E7*y2**2CC     on the interval from t = 0.0 to t = 4.E10, with initial conditionsC     y1 = 1.0, y2 = y3 = 0. The problem is stiff.CC     The following coding solves this problem with SLSODE, using C     MF = 21 and printing results at t = .4, 4., ..., 4.E10.  It uses C     ITOL = 2 and ATOL much smaller for y2 than for y1 or y3 because y2 C     has much smaller values.  At the end of the run, statistical C     quantities of interest are printed.CC        EXTERNAL  FEX, JEXC        INTEGER  IOPT, IOUT, ISTATE, ITASK, ITOL, IWORK(23), LIW, LRW,C       *         MF, NEQC        REAL  ATOL(3), RTOL, RWORK(58), T, TOUT, Y(3)C        NEQ = 3C        Y(1) = 1.C        Y(2) = 0.C        Y(3) = 0.C        T = 0.C        TOUT = .4C        ITOL = 2C        RTOL = 1.E-4C        ATOL(1) = 1.E-6C        ATOL(2) = 1.E-10C        ATOL(3) = 1.E-6C        ITASK = 1C        ISTATE = 1C        IOPT = 0C        LRW = 58C        LIW = 23C        MF = 21C        DO 40 IOUT = 1,12C          CALL SLSODE (FEX, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL, ITASK,C       *               ISTATE, IOPT, RWORK, LRW, IWORK, LIW, JEX, MF)C          WRITE(6,20)  T, Y(1), Y(2), Y(3)C    20    FORMAT(' At t =',E12.4,'   y =



',3E14.6)C          IF (ISTATE .LT. 0)  GO TO 80C    40    TOUT = TOUT*10.C        WRITE(6,60)  IWORK(11), IWORK(12), IWORK(13)C    60  FORMAT(/' No. steps =',i4,',  No. f-s =',i4,',  No. J-s =


',i4)C        STOPC    80  WRITE(6,90)  ISTATEC    90  FORMAT(///' Error halt.. ISTATE =











































































































',I3)C        STOPC        ENDCC        SUBROUTINE  FEX (NEQ, T, Y, YDOT)C        INTEGER  NEQC        REAL  T, Y(3), YDOT(3)C        YDOT(1) = -.04*Y(1) + 1.E4*Y(2)*Y(3)C        YDOT(3) = 3.E7*Y(2)*Y(2)C        YDOT(2) = -YDOT(1) - YDOT(3)C        RETURNC        ENDCC        SUBROUTINE  JEX (NEQ, T, Y, ML, MU, PD, NRPD)C        INTEGER  NEQ, ML, MU, NRPDC        REAL  T, Y(3), PD(NRPD,3)C        PD(1,1) = -.04C        PD(1,2) = 1.E4*Y(3)C        PD(1,3) = 1.E4*Y(2)C        PD(2,1) = .04C        PD(2,3) = -PD(1,3)C        PD(3,2) = 6.E7*Y(2)C        PD(2,2) = -PD(1,2) - PD(3,2)C        RETURNC        ENDCC     The output from this program (on a Cray-1 in single precision)C     is as follows.CC     At t =  4.0000e-01   y =  9.851726e-01  3.386406e-05  1.479357e-02C     At t =  4.0000e+00   y =  9.055142e-01  2.240418e-05  9.446344e-02C     At t =  4.0000e+01   y =  7.158050e-01  9.184616e-06  2.841858e-01C     At t =  4.0000e+02   y =  4.504846e-01  3.222434e-06  5.495122e-01C     At t =  4.0000e+03   y =  1.831701e-01  8.940379e-07  8.168290e-01C     At t =  4.0000e+04   y =  3.897016e-02  1.621193e-07  9.610297e-01C     At t =  4.0000e+05   y =  4.935213e-03  1.983756e-08  9.950648e-01C     At t =  4.0000e+06   y =  5.159269e-04  2.064759e-09  9.994841e-01C     At t =  4.0000e+07   y =  5.306413e-05  2.122677e-10  9.999469e-01C     At t =  4.0000e+08   y =  5.494530e-06  2.197825e-11  9.999945e-01C     At t =  4.0000e+09   y =  5.129458e-07  2.051784e-12  9.999995e-01C     At t =  4.0000e+10   y = -7.170603e-08 -2.868241e-13  1.000000e+00CC     No. steps = 330,  No. f-s = 405,  No. J-s = 69CC *Accuracy:C     The accuracy of the solution depends on the choice of tolerancesC     RTOL and ATOL.  Actual (global) errors may exceed these localC     tolerances, so choose them conservatively.CC *Cautions:C     The work arrays should not be altered between calls to SLSODE forC     the same problem, except possibly for the conditional and optionalC     inputs.CC *Portability:C     Since NEQ is dimensioned inside SLSODE, some compilers may objectC     to a call to SLSODE with NEQ a scalar variable.  In this event, C     use DIMENSION NEQ(1).  Similar remarks apply to RTOL and ATOL.CC     Note to Cray users:C     For maximum efficiency, use the CFT77 compiler.  AppropriateC     compiler optimization directives have been inserted for CFT77.CC *Reference:C     Alan C. Hindmarsh, "ODEPACK, A Systematized Collection of ODEC     Solvers," in Scientific Computing, R. S. Stepleman, et al., Eds.C     (North-Holland, Amsterdam, 1983), pp. 55-64.CC *Long Description:C     The following complete description of the user interface toC     SLSODE consists of four parts:CC     1.  The call sequence to subroutine SLSODE, which is a driverC         routine for the solver.  This includes descriptions of bothC         the call sequence arguments and user-supplied routines.C         Following these descriptions is a description of optionalC         inputs available through the call sequence, and then aC         description of optional outputs in the work arrays.CC     2.  Descriptions of other routines in the SLSODE package that mayC         be (optionally) called by the user.  These provide the abilityC         to alter error message handling, save and restore the internalC         COMMON, and obtain specified derivatives of the solution y(t).CC     3.  Descriptions of COMMON block to be declared in overlay orC         similar environments, or to be saved when doing an interruptC         of the problem and continued solution later.CC     4.  Description of two routines in the SLSODE package, either ofC         which the user may replace with his own version, if desired.C         These relate to the measurement of errors.CCC                         Part 1.  Call SequenceC                         ----------------------CC     ArgumentsC     ---------C     The call sequence parameters used for input only areCC        F, NEQ, TOUT, ITOL, RTOL, ATOL, ITASK, IOPT, LRW, LIW, JAC, MF,CC     and those used for both input and output areCC        Y, T, ISTATE.CC     The work arrays RWORK and IWORK are also used for conditional andC     optional inputs and optional outputs.  (The term output hereC     refers to the return from subroutine SLSODE to the user's calling
C     program.)
C
C     The legality of input parameters will be thoroughly checked on the
C     initial call for the problem, but not checked thereafter unless a
C     change in input parameters is flagged by ISTATE = 3 on input.
C
C     The descriptions of the call arguments are as follows.
C
C     F        The name of the user-supplied subroutine defining the ODE
C              system.  The system must be put in the first-order form
C              dy/dt = f(t,y), where f is a vector-valued function of
C              the scalar t and the vector y. Subroutine F is to compute
C              the function f. It is to have the form
C
C                 SUBROUTINE F (NEQ, T, Y, YDOT)
C                 REAL T, Y(*), YDOT(*)
C
C              where NEQ, T, and Y are input, and the array YDOT =
C              f(T,Y) is output.  Y and YDOT are arrays of length NEQ.
C              Subroutine F should not alter Y(1),...,Y(NEQ).  F must be
C              declared EXTERNAL in the calling program.
C
C              Subroutine F may access user-defined quantities in
C              NEQ(2),... and/or in Y(NEQ(1)+1),..., if NEQ is an array
C              (dimensioned in F) and/or Y has length exceeding NEQ(1).
C              See the descriptions of NEQ and Y below.
C
C              If quantities computed in the F routine are needed
C              externally to SLSODE, an extra call to F should be made
C              for this purpose, for consistent and accurate results.
C              If only the derivative dy/dt is needed, use SINTDY
C              instead.
C
C     NEQ      The size of the ODE system (number of first-order
C              ordinary differential equations).  Used only for input.
C              NEQ may be decreased, but not increased, during the
C              problem.  If NEQ is decreased (with ISTATE = 3 on input),
C              the remaining components of Y should be left undisturbed,
C              if these are to be accessed in F and/or JAC.
C
C              Normally, NEQ is a scalar, and it is generally referred
C              to as a scalar in this user interface description.
C              However, NEQ may be an array, with NEQ(1) set to the
C              system size.  (The SLSODE package accesses only NEQ(1).)
C              In either case, this parameter is passed as the NEQ
C              argument in all calls to F and JAC.  Hence, if it is an
C              array, locations NEQ(2),... may be used to store other
C              integer data and pass it to F and/or JAC.  Subroutines
C              F and/or JAC must include NEQ in a DIMENSION statement
C              in that case.
C
C     Y        A real array for the vector of dependent variables, of
C              length NEQ or more.  Used for both input and output on
C              the first call (ISTATE = 1), and only for output on
C              other calls.  On the first call, Y must contain the
C              vector of initial values.  On output, Y contains the
C              computed solution vector, evaluated at T. If desired,
C              the Y array may be used for other purposes between
C              calls to the solver.
C
C              This array is passed as the Y argument in all calls to F
C              and JAC.  Hence its length may exceed NEQ, and locations
C              Y(NEQ+1),... may be used to store other real data and
C              pass it to F and/or JAC.  (The SLSODE package accesses
C              only Y(1),...,Y(NEQ).)
C
C     T        The independent variable.  On input, T is used only on
C              the first call, as the initial point of the integration.
C              On output, after each call, T is the value at which a
C              computed solution Y is evaluated (usually the same as
C              TOUT).  On an error return, T is the farthest point
C              reached.
C
C     TOUT     The next value of T at which a computed solution is
C              desired.  Used only for input.
C
C              When starting the problem (ISTATE = 1), TOUT may be equal
C              to T for one call, then should not equal T for the next
C              call.  For the initial T, an input value of TOUT .NE. T
C              is used in order to determine the direction of the
C              integration (i.e., the algebraic sign of the step sizes)
C              and the rough scale of the problem.  Integration in
C              either direction (forward or backward in T) is permitted.
C
C              If ITASK = 2 or 5 (one-step modes), TOUT is ignored
C              after the first call (i.e., the first call with
C              TOUT .NE. T).  Otherwise, TOUT is required on every call.
C
C              If ITASK = 1, 3, or 4, the values of TOUT need not be
C              monotone, but a value of TOUT which backs up is limited
C              to the current internal T interval, whose endpoints are
C              TCUR - HU and TCUR.  (See "Optional Outputs" below for
C              TCUR and HU.)
C
C
C     ITOL     An indicator for the type of error control.  See
C              description below under ATOL.  Used only for input.
C
C     RTOL     A relative error tolerance parameter, either a scalar or
C              an array of length NEQ.  See description below under
C              ATOL.  Input only.
C
C     ATOL     An absolute error tolerance parameter, either a scalar or
C              an array of length NEQ.  Input only.
C
C              The input parameters ITOL, RTOL, and ATOL determine the
C              error control performed by the solver.  The solver will
C              control the vector e = (e(i)) of estimated local errors
C              in Y, according to an inequality of the form
C
C                 rms-norm of ( e(i)/EWT(i) ) <= 1,
C
C              where
C
C                 EWT(i) = RTOL(i)*ABS(Y(i)) + ATOL(i),
C
C              and the rms-norm (root-mean-square norm) here is
C
C                 rms-norm(v) = SQRT(sum v(i)**2 / NEQ).
C
C              Here EWT = (EWT(i)) is a vector of weights which must
C              always be positive, and the values of RTOL and ATOL
C              should all be nonnegative.  The following table gives the
C              types (scalar/array) of RTOL and ATOL, and the
C              corresponding form of EWT(i).
C
C              ITOL    RTOL      ATOL      EWT(i)
C              ----    ------    ------    -----------------------------
C              1       scalar    scalar    RTOL*ABS(Y(i)) + ATOL
C              2       scalar    array     RTOL*ABS(Y(i)) + ATOL(i)
C              3       array     scalar    RTOL(i)*ABS(Y(i)) + ATOL
C              4       array     array     RTOL(i)*ABS(Y(i)) + ATOL(i)
C
C              When either of these parameters is a scalar, it need not
C              be dimensioned in the user












































































































































































































































's calling program.CC              If none of the above choices (with ITOL, RTOL, and ATOLC              fixed throughout the problem) is suitable, more generalC              error controls can be obtained by substitutingC              user-supplied routines for the setting of EWT and/or forC              the norm calculation.  See Part 4 below.CC              If global errors are to be estimated by making a repeatedC              run on the same problem with smaller tolerances, then allC              components of RTOL and ATOL (i.e., of EWT) should beC              scaled down uniformly.CC     ITASK    An index specifying the task to be performed.  InputC              only.  ITASK has the following values and meanings:C              1   Normal computation of output values of y(t) atC                  t = TOUT (by overshooting and interpolating).C              2   Take one step only and return.C              3   Stop at the first internal mesh point at or beyondC                  t = TOUT and return.C              4   Normal computation of output values of y(t) atC                  t = TOUT but without overshooting t = TCRIT.  TCRITC                  must be input as RWORK(1).  TCRIT may be equal to orC                  beyond TOUT, but not behind it in the direction ofC                  integration.  This option is useful if the problemC                  has a singularity at or beyond t = TCRIT.C              5   Take one step, without passing TCRIT, and return.C                  TCRIT must be input as RWORK(1).CC              Note:  If ITASK = 4 or 5 and the solver reaches TCRITC              (within roundoff), it will return T = TCRIT (exactly) toC              indicate this (unless ITASK = 4 and TOUT comes beforeC              TCRIT, in which case answers at T = TOUT are returnedC              first).CC     ISTATE   An index used for input and output to specify the stateC              of the calculation.CC              On input, the values of ISTATE are as follows:C              1   This is the first call for the problemC                  (initializations will be done).  See "Note" below.C              2   This is not the first call, and the calculation is toC                  continue normally, with no change in any inputC                  parameters except possibly TOUT and ITASK.  (If ITOL,C                  RTOL, and/or ATOL are changed between calls withC                  ISTATE = 2, the new values will be used but notC                  tested for legality.)C              3   This is not the first call, and the calculation is toC                  continue normally, but with a change in inputC                  parameters other than TOUT and ITASK.  Changes areC                  allowed in NEQ, ITOL, RTOL, ATOL, IOPT, LRW, LIW, MF,C                  ML, MU, and any of the optional inputs except H0.C                  (See IWORK description for ML and MU.)CC              Note:  A preliminary call with TOUT = T is not counted asC              a first call here, as no initialization or checking ofC              input is done.  (Such a call is sometimes useful for theC              purpose of outputting the initial conditions.)  Thus theC              first call for which TOUT .NE. T requires ISTATE = 1 onC              input.CC              On output, ISTATE has the following values and meanings:C               1  Nothing was done, as TOUT was equal to T withC                  ISTATE = 1 on input.C               2  The integration was performed successfully.C              -1  An excessive amount of work (more than MXSTEP steps)C                  was done on this call, before completing theC                  requested task, but the integration was otherwiseC                  successful as far as T. (MXSTEP is an optional inputC                  and is normally 500.)  To continue, the user mayC                  simply reset ISTATE to a value >1 and call again (theC                  excess work step counter will be reset to 0).  InC                  addition, the user may increase MXSTEP to avoid thisC                  error return; see "Optional Inputs" below.C              -2  Too much accuracy was requested for the precision ofC                  the machine being used.  This was detected beforeC                  completing the requested task, but the integrationC                  was successful as far as T. To continue, theC                  tolerance parameters must be reset, and ISTATE mustC                  be set to 3. The optional output TOLSF may be usedC                  for this purpose.  (Note:  If this condition isC                  detected before taking any steps, then an illegalC                  input return (ISTATE = -3) occurs instead.)C              -3  Illegal input was detected, before taking anyC                  integration steps.  See written message for details.C                  (Note:  If the solver detects an infinite loop ofC                  calls to the solver with illegal input, it will causeC                  the run to stop.)C              -4  There were repeated error-test failures on oneC                  attempted step, before completing the requested task,C                  but the integration was successful as far as T.  TheC                  problem may have a singularity, or the input may beC                  inappropriate.C              -5  There were repeated convergence-test failures on oneC                  attempted step, before completing the requested task,C                  but the integration was successful as far as T. ThisC                  may be caused by an inaccurate Jacobian matrix, ifC                  one is being used.C              -6  EWT(i) became zero for some i during the integration.C                  Pure relative error control (ATOL(i)=0.0) wasC                  requested on a variable which has now vanished.  TheC                  integration was successful as far as T.CC              Note:  Since the normal output value of ISTATE is 2, itC              does not need to be reset for normal continuation.  Also,C              since a negative input value of ISTATE will be regardedC              as illegal, a negative output value requires the user toC              change it, and possibly other inputs, before calling theC              solver again.CC     IOPT     An integer flag to specify whether any optional inputsC              are being used on this call.  Input only.  The optionalC              inputs are listed under a separate heading below.C              0   No optional inputs are being used.  Default valuesC                  will be used in all cases.C              1   One or more optional inputs are being used.CC     RWORK    A real working array (single precision).  The length ofC              RWORK must be at leastCC                 20 + NYH*(MAXORD + 1) + 3*NEQ + LWMCC              whereC                 NYH = the initial value of NEQ,C              MAXORD = 12 (if METH = 1) or 5 (if METH = 2) (unless aC                       smaller value is given as an optional input),C                 LWM = 0           if MITER = 0,C                 LWM = NEQ**2 + 2  if MITER = 1 or 2,C                 LWM = NEQ + 2     if MITER = 3, andC                 LWM = (2*ML + MU + 1)*NEQ + 2C                                   if MITER = 4 or 5.C              (See the MF description below for METH and MITER.)CC              Thus if MAXORD has its default value and NEQ is constant,C              this length is:C              20 + 16*NEQ                    for MF = 10,C              22 + 16*NEQ + NEQ**2           for MF = 11 or 12,C              22 + 17*NEQ                    for MF = 13,C              22 + 17*NEQ + (2*ML + MU)*NEQ  for MF = 14 or 15,C              20 +  9*NEQ                    for MF = 20,C              22 +  9*NEQ + NEQ**2           for MF = 21 or 22,C              22 + 10*NEQ                    for MF = 23,C              22 + 10*NEQ + (2*ML + MU)*NEQ  for MF = 24 or 25.CC              The first 20 words of RWORK are reserved for conditionalC              and optional inputs and optional outputs.CC              The following word in RWORK is a conditional input:C              RWORK(1) = TCRIT, the critical value of t which theC                         solver is not to overshoot.  Required if ITASKC                         is 4 or 5, and ignored otherwise.  See ITASK.CC     LRW      The length of the array RWORK, as declared by the user.C              (This will be checked by the solver.)CC     IWORK    An integer work array.  Its length must be at leastC              20       if MITER = 0 or 3 (MF = 10, 13, 20, 23), orC              20 + NEQ otherwise (MF = 11, 12, 14, 15, 21, 22, 24, 25).C              (See the MF description below for MITER.)  The first fewC              words of IWORK are used for conditional and optionalC              inputs and optional outputs.CC              The following two words in IWORK are conditional inputs:C              IWORK(1) = ML   These are the lower and upper half-C              IWORK(2) = MU   bandwidths, respectively, of the bandedC                              Jacobian, excluding the main diagonal.C                         The band is defined by the matrix locationsC                         (i,j) with i - ML <= j <= i + MU. ML and MUC                         must satisfy 0 <= ML,MU <= NEQ - 1. These areC                         required if MITER is 4 or 5, and ignoredC                         otherwise.  ML and MU may in fact be the bandC                         parameters for a matrix to which df/dy is onlyC                         approximately equal.CC     LIW      The length of the array IWORK, as declared by the user.C              (This will be checked by the solver.)CC     Note:  The work arrays must not be altered between calls to SLSODEC     for the same problem, except possibly for the conditional andC     optional inputs, and except for the last 3*NEQ words of RWORK.C     The latter space is used for internal scratch space, and so isC     available for use by the user outside SLSODE between calls, ifC     desired (but not for use by F or JAC).CC     JAC      The name of the user-supplied routine (MITER = 1 or 4) toC              compute the Jacobian matrix, df/dy, as a function of theC              scalar t and the vector y.  (See the MF description belowC              for MITER.)  It is to have the formCC                 SUBROUTINE JAC (NEQ, T, Y, ML, MU, PD, NROWPD)C                 REAL T, Y(*), PD(NROWPD,*)CC              where NEQ, T, Y, ML, MU, and NROWPD are input and theC              array PD is to be loaded with partial derivativesC              (elements of the Jacobian matrix) on output.  PD must beC              given a first dimension of NROWPD.  T and Y have the sameC              meaning as in subroutine F.CC              In the full matrix case (MITER = 1), ML and MU areC              ignored, and the Jacobian is to be loaded into PD inC              columnwise manner, with df(i)/dy(j) loaded into PD(i,j).CC              In the band matrix case (MITER = 4), the elements withinC              the band are to be loaded into PD in columnwise manner,C              with diagonal lines of df/dy loaded into the rows of PD.C              Thus df(i)/dy(j) is to be loaded into PD(i-j+MU+1,j).  MLC              and MU are the half-bandwidth parameters (see IWORK).C              The locations in PD in the two triangular areas whichC              correspond to nonexistent matrix elements can be ignoredC              or loaded arbitrarily, as they are overwritten by SLSODE.CC              JAC need not provide df/dy exactly. A crude approximationC              (possibly with a smaller bandwidth) will do.CC              In either case, PD is preset to zero by the solver, soC              that only the nonzero elements need be loaded by JAC.C              Each call to JAC is preceded by a call to F with the sameC              arguments NEQ, T, and Y. Thus to gain some efficiency,C              intermediate quantities shared by both calculations mayC              be saved in a user COMMON block by F and not recomputedC              by JAC, if desired.  Also, JAC may alter the Y array, ifC              desired.  JAC must be declared EXTERNAL in the callingC              program.CC              Subroutine JAC may access user-defined quantities inC              NEQ(2),... and/or in Y(NEQ(1)+1),... if NEQ is an arrayC              (dimensioned in JAC) and/or Y has length exceedingC              NEQ(1).  See the descriptions of NEQ and Y above.CC     MF       The method flag.  Used only for input.  The legal valuesC              of MF are 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24,C              and 25.  MF has decimal digits METH and MITER:C                 MF = 10*METH + MITER .CC              METH indicates the basic linear multistep method:C              1   Implicit Adams method.C              2   Method based on backward differentiation formulasC                  (BDF's).
C
C              MITER indicates the corrector iteration method:
C              0   Functional iteration (no Jacobian matrix is
C                  involved).
C              1   Chord iteration with a user-supplied full (NEQ by
C                  NEQ) Jacobian.
C              2   Chord iteration with an internally generated
C                  (difference quotient) full Jacobian (using NEQ
C                  extra calls to F per df/dy value).
C              3   Chord iteration with an internally generated
C                  diagonal Jacobian approximation (using one extra call
C                  to F per df/dy evaluation).
C              4   Chord iteration with a user-supplied banded Jacobian.
C              5   Chord iteration with an internally generated banded
C                  Jacobian (using ML + MU + 1 extra calls to F per
C                  df/dy evaluation).
C
C              If MITER = 1 or 4, the user must supply a subroutine JAC
C              (the name is arbitrary) as described above under JAC.
C              For other values of MITER, a dummy argument can be used.
C
C     Optional Inputs
C     ---------------
C     The following is a list of the optional inputs provided for in the
C     call sequence.  (See also Part 2.)  For each such input variable,
C     this table lists its name as used in this documentation, its
C     location in the call sequence, its meaning, and the default value.
C     The use of any of these inputs requires IOPT = 1, and in that case
C     all of these inputs are examined.  A value of zero for any of
C     these optional inputs will cause the default value to be used.
C     Thus to use a subset of the optional inputs, simply preload
C     locations 5 to 10 in RWORK and IWORK to 0.0 and 0 respectively,
C     and then set those of interest to nonzero values.
C
C     Name    Location   Meaning and default value
C     ------  ---------  -----------------------------------------------
C     H0      RWORK(5)   Step size to be attempted on the first step.
C                        The default value is determined by the solver.
C     HMAX    RWORK(6)   Maximum absolute step size allowed.  The
C                        default value is infinite.
C     HMIN    RWORK(7)   Minimum absolute step size allowed.  The
C                        default value is 0.  (This lower bound is not
C                        enforced on the final step before reaching
C                        TCRIT when ITASK = 4 or 5.)
C     MAXORD  IWORK(5)   Maximum order to be allowed.  The default value
C                        is 12 if METH = 1, and 5 if METH = 2. (See the
C                        MF description above for METH.)  If MAXORD
C                        exceeds the default value, it will be reduced
C                        to the default value.  If MAXORD is changed
C                        during the problem, it may cause the current
C                        order to be reduced.
C     MXSTEP  IWORK(6)   Maximum number of (internally defined) steps
C                        allowed during one call to the solver.  The
C                        default value is 500.
C     MXHNIL  IWORK(7)   Maximum number of messages printed (per
C                        problem) warning that T + H = T on a step
C                        (H = step size).  This must be positive to
C                        result in a nondefault value.  The default
C                        value is 10.
C
C     Optional Outputs
C     ----------------
C     As optional additional output from SLSODE, the variables listed
C     below are quantities related to the performance of SLSODE which 
C     are available to the user.  These are communicated by way of the
C     work arrays, but also have internal mnemonic names as shown. 
C     Except where stated otherwise, all of these outputs are defined on
C     any successful return from SLSODE, and on any return with ISTATE =
C     -1, -2, -4, -5, or -6.  On an illegal input return (ISTATE = -3),
C     they will be unchanged from their existing values (if any), except
C     possibly for TOLSF, LENRW, and LENIW.  On any error return,
C     outputs relevant to the error will be defined, as noted below.
C
C     Name   Location   Meaning
C     -----  ---------  ------------------------------------------------
C     HU     RWORK(11)  Step size in t last used (successfully).
C     HCUR   RWORK(12)  Step size to be attempted on the next step.
C     TCUR   RWORK(13)  Current value of the independent variable which
C                       the solver has actually reached, i.e., the
C                       current internal mesh point in t. On output,
C                       TCUR will always be at least as far as the
C                       argument T, but may be farther (if interpolation
C                       was done).
C     TOLSF  RWORK(14)  Tolerance scale factor, greater than 1.0,
C                       computed when a request for too much accuracy
C                       was detected (ISTATE = -3 if detected at the
C                       start of the problem, ISTATE = -2 otherwise).
C                       If ITOL is left unaltered but RTOL and ATOL are
C                       uniformly scaled up by a factor of TOLSF for the
C                       next call, then the solver is deemed likely to
C                       succeed.  (The user may also ignore TOLSF and
C                       alter the tolerance parameters in any other way
C                       appropriate.)
C     NST    IWORK(11)  Number of steps taken for the problem so far.
C     NFE    IWORK(12)  Number of F evaluations for the problem so far.
C     NJE    IWORK(13)  Number of Jacobian evaluations (and of matrix LU
C                       decompositions) for the problem so far.
C     NQU    IWORK(14)  Method order last used (successfully).
C     NQCUR  IWORK(15)  Order to be attempted on the next step.
C     IMXER  IWORK(16)  Index of the component of largest magnitude in
C                       the weighted local error vector ( e(i)/EWT(i) ),
C                       on an error return with ISTATE = -4 or -5.
C     LENRW  IWORK(17)  Length of RWORK actually required.  This is
C                       defined on normal returns and on an illegal
C                       input return for insufficient storage.
C     LENIW  IWORK(18)  Length of IWORK actually required.  This is
C                       defined on normal returns and on an illegal
C                       input return for insufficient storage.
C
C     The following two arrays are segments of the RWORK array which may
C     also be of interest to the user as optional outputs.  For each
C     array, the table below gives its internal name, its base address
C     in RWORK, and its description.
C
C     Name  Base address  Description
C     ----  ------------  ----------------------------------------------
C     YH    21            The Nordsieck history array, of size NYH by
C                         (NQCUR + 1), where NYH is the initial value of
C                         NEQ.  For j = 0,1,...,NQCUR, column j + 1 of
C                         YH contains HCUR**j/factorial(j) times the jth
C                         derivative of the interpolating polynomial
C                         currently representing the solution, evaluated
C                         at t = TCUR.
C     ACOR  LENRW-NEQ+1   Array of size NEQ used for the accumulated
C                         corrections on each step, scaled on output to
C                         represent the estimated local error in Y on
C                         the last step.  This is the vector e in the
C                         description of the error control.  It is
C                         defined only on successful return from SLSODE.
C
C
C                    Part 2.  Other Callable Routines
C                    --------------------------------
C
C     The following are optional calls which the user may make to gain
C     additional capabilities in conjunction with SLSODE.
C
C     Form of call              Function
C     ------------------------  ----------------------------------------
C     CALL XSETUN(LUN)          Set the logical unit number, LUN, for
C                               output of messages from SLSODE, if the
C                               default is not desired.  The default
C                               value of LUN is 6. This call may be made
C                               at any time and will take effect
C                               immediately.
C     CALL XSETF(MFLAG)         Set a flag to control the printing of
C                               messages by SLSODE.  MFLAG = 0 means do
C                               not print.  (Danger:  this risks losing
C                               valuable information.)  MFLAG = 1 means
C                               print (the default).  This call may be
C                               made at any time and will take effect
C                               immediately.
C     CALL SSRCOM(RSAV,ISAV,JOB)  Saves and restores the contents of the
C                               internal COMMON blocks used by SLSODE
C                               (see Part 3 below).  RSAV must be a
C                               real array of length 218 or more, and
C                               ISAV must be an integer array of length
C                               37 or more.  JOB = 1 means save COMMON
C                               into RSAV/ISAV.  JOB = 2 means restore
C                               COMMON from same.  SSRCOM is useful if
C                               one is interrupting a run and restarting
C                               later, or alternating between two or
C                               more problems solved with SLSODE.
C     CALL SINTDY(,,,,,)        Provide derivatives of y, of various
C     (see below)               orders, at a specified point t, if
C                               desired.  It may be called only after a
C                               successful return from SLSODE.  Detailed
C                               instructions follow.
C
C     Detailed instructions for using SINTDY
C     --------------------------------------
C     The form of the CALL is:
C
C           CALL SINTDY (T, K, RWORK(21), NYH, DKY, IFLAG)
C
C     The input parameters are:
C
C     T          Value of independent variable where answers are
C                desired (normally the same as the T last returned by
C                SLSODE).  For valid results, T must lie between
C                TCUR - HU and TCUR.  (See "Optional Outputs" above
C                for TCUR and HU.)
C     K          Integer order of the derivative desired.  K must
C                satisfy 0 <= K <= NQCUR, where NQCUR is the current
C                order (see "Optional Outputs").  The capability
C                corresponding to K = 0, i.e., computing y(t), is
C                already provided by SLSODE directly.  Since
C                NQCUR >= 1, the first derivative dy/dt is always
C                available with SINTDY.
C     RWORK(21)  The base address of the history array YH.
C     NYH        Column length of YH, equal to the initial value of NEQ.
C
C     The output parameters are:
C
C     DKY        Real array of length NEQ containing the computed value
C                of the Kth derivative of y(t).
C     IFLAG      Integer flag, returned as 0 if K and T were legal,
C                -1 if K was illegal, and -2 if T was illegal.
C                On an error return, a message is also written.
C
C
C                          Part 3.  Common Blocks
C                          ----------------------
C
C     If SLSODE is to be used in an overlay situation, the user must
C     declare, in the primary overlay, the variables in:
C     (1) the call sequence to SLSODE,
C     (2) the internal COMMON block /SLS001/, of length 255 
C         (218 single precision words followed by 37 integer words).
C
C     If SLSODE is used on a system in which the contents of internal
C     COMMON blocks are not preserved between calls, the user should
C     declare the above COMMON block in his main program to insure that
C     its contents are preserved.
C
C     If the solution of a given problem by SLSODE is to be interrupted
C     and then later continued, as when restarting an interrupted run or
C     alternating between two or more problems, the user should save,
C     following the return from the last SLSODE call prior to the
C     interruption, the contents of the call sequence variables and the
C     internal COMMON block, and later restore these values before the
C     next SLSODE call for that problem.   In addition, if XSETUN and/or
C     XSETF was called for non-default handling of error messages, then
C     these calls must be repeated.  To save and restore the COMMON
C     block, use subroutine SSRCOM (see Part 2 above).
C
C
C              Part 4.  Optionally Replaceable Solver Routines
C              -----------------------------------------------
C
C     Below are descriptions of two routines in the SLSODE package which
C     relate to the measurement of errors.  Either routine can be
C     replaced by a user-supplied version, if desired.  However, since
C     such a replacement may have a major impact on performance, it
C     should be done only when absolutely necessary, and only with great
C     caution.  (Note:  The means by which the package version of a
C     routine is superseded by the user

















































































































's version may be system-C     dependent.)CC     SEWSETC     ------C     The following subroutine is called just before each internalC     integration step, and sets the array of error weights, EWT, asC     described under ITOL/RTOL/ATOL above:CC           SUBROUTINE SEWSET (NEQ, ITOL, RTOL, ATOL, YCUR, EWT)CC     where NEQ, ITOL, RTOL, and ATOL are as in the SLSODE callC     sequence, YCUR contains the current dependent variable vector,C     and EWT is the array of weights set by SEWSET.CC     If the user supplies this subroutine, it must return in EWT(i)C     (i = 1,...,NEQ) a positive quantity suitable for comparing errorsC     in Y(i) to.  The EWT array returned by SEWSET is passed to theC     SVNORM routine (see below), and also used by SLSODE in theC     computation of the optional output IMXER, the diagonal JacobianC     approximation, and the increments for difference quotientC     Jacobians.CC     In the user-supplied version of SEWSET, it may be desirable to useC     the current values of derivatives of y. Derivatives up to order NQC     are available from the history array YH, described above underC     optional outputs.  In SEWSET, YH is identical to the YCUR array,C     extended to NQ + 1 columns with a column length of NYH and scaleC     factors of H**j/factorial(j).  On the first call for the problem,C     given by NST = 0, NQ is 1 and H is temporarily set to 1.0.C     NYH is the initial value of NEQ.  The quantities NQ, H, and NSTC     can be obtained by including in SEWSET the statements:C           REAL RLSC           COMMON /SLS001/ RLS(218),ILS(37)C           NQ = ILS(33)C           NST = ILS(34)C           H = RLS(212)C     Thus, for example, the current value of dy/dt can be obtained asC     YCUR(NYH+i)/H (i=1,...,NEQ) (and the division by H is unnecessaryC     when NST = 0).CC     SVNORMC     ------C     SVNORM is a real function routine which computes the weightedC     root-mean-square norm of a vector v:CC        d = SVNORM (n, v, w)CC     where:C     n = the length of the vector,C     v = real array of length n containing the vector,C     w = real array of length n containing weights,C     d = SQRT( (1/n) * sum(v(i)*w(i))**2 ).CC     SVNORM is called with n = NEQ and with w(i) = 1.0/EWT(i), whereC     EWT is as set by subroutine SEWSET.CC     If the user supplies this function, it should return a nonnegativeC     value of SVNORM suitable for use in the error control in SLSODE.C     None of the arguments should be altered by SVNORM.  For example, aC     user-supplied SVNORM routine might:C     - Substitute a max-norm of (v(i)*w(i)) for the rms-norm, orC     - Ignore some components of v in the norm, with the effect ofC       suppressing the error control on those components of Y.C  ---------------------------------------------------------------------C***ROUTINES CALLED  SEWSET, SINTDY, D1MACH, SSTODE, SVNORM, XERRWDC***COMMON BLOCKS    SLS001C***REVISION HISTORY  (YYYYMMDD)C 19791129  DATE WRITTENC 19791213  Minor changes to declarations; DELP init. in STODE.C 19800118  Treat NEQ as array; integer declarations added throughout;C           minor changes to prologue.C 19800306  Corrected TESCO(1,NQP1) setting in CFODE.C 19800519  Corrected access of YH on forced order reduction;C           numerous corrections to prologues and other comments.C 19800617  In main driver, added loading of SQRT(UROUND) in RWORK;C           minor corrections to main prologue.C 19800923  Added zero initialization of HU and NQU.C 19801218  Revised XERRWV routine; minor corrections to main prologue.C 19810401  Minor changes to comments and an error message.C 19810814  Numerous revisions: replaced EWT by 1/EWT; used flagsC           JCUR, ICF, IERPJ, IERSL between STODE and subordinates;C           added tuning parameters CCMAX, MAXCOR, MSBP, MXNCF;C           reorganized returns from STODE; reorganized type decls.;C           fixed message length in XERRWV; changed default LUNIT to 6;C           changed Common lengths; changed comments throughout.C 19870330  Major update by ACH: corrected comments throughout;C           removed TRET from Common; rewrote EWSET with 4 loops;C           fixed t test in INTDY; added Cray directives in STODE;C           in STODE, fixed DELP init. and logic around PJAC call;C           combined routines to save/restore Common;C           passed LEVEL = 0 in error message calls (except run abort).C 19890426  Modified prologue to SLATEC/LDOC format.  (FNF)C 19890501  Many improvements to prologue.  (FNF)C 19890503  A few final corrections to prologue.  (FNF)C 19890504  Minor cosmetic changes.  (FNF)C 19890510  Corrected description of Y in Arguments section.  (FNF)C 19890517  Minor corrections to prologue.  (FNF)C 19920514  Updated with prologue edited 891025 by G. Shaw for manual.C 19920515  Converted source lines to upper case.  (FNF)C 19920603  Revised XERRWV calls using mixed upper-lower case.  (ACH)C 19920616  Revised prologue comment regarding CFT.  (ACH)C 19921116  Revised prologue comments regarding Common.  (ACH).C 19930326  Added comment about non-reentrancy.  (FNF)C 19930723  Changed R1MACH to RUMACH. (FNF)C 19930801  Removed ILLIN and NTREP from Common (affects driver logic);C           minor changes to prologue and internal comments;C           changed Hollerith strings to quoted strings; C           changed internal comments to mixed case;C           replaced XERRWV with new version using character type;C           changed dummy dimensions from 1 to *. (ACH)C 19930809  Changed to generic intrinsic names; changed names ofC           subprograms and Common blocks to SLSODE etc. (ACH)C 19930929  Eliminated use of REAL intrinsic; other minor changes. (ACH)C 20010412  Removed all 'own


' variables from Common block /SLS001/C           (affects declarations in 6 routines). (ACH)C 20010509  Minor corrections to prologue. (ACH)C 20031105  Restored 'own
















































































































































































































































































































































' variables to Common block /SLS001/, toC           enable interrupt/restart feature. (ACH)C 20031112  Added SAVE statements for data-loaded constants.CC***  END PROLOGUE  SLSODECC*Internal Notes:CC Other Routines in the SLSODE Package.CC In addition to Subroutine SLSODE, the SLSODE package includes theC following subroutines and function routines:C  SINTDY   computes an interpolated value of the y vector at t = TOUT.C  SSTODE   is the core integrator, which does one step of theC           integration and the associated error control.C  SCFODE   sets all method coefficients and test constants.C  SPREPJ   computes and preprocesses the Jacobian matrix J = df/dyC           and the Newton iteration matrix P = I - h*l0*J.C  SSOLSY   manages solution of linear system in chord iteration.C  SEWSET   sets the error weight vector EWT before each step.C  SVNORM   computes the weighted R.M.S. norm of a vector.C  SSRCOM   is a user-callable routine to save and restoreC           the contents of the internal Common block.C  DGETRF AND DGETRS   ARE ROUTINES FROM LAPACK FOR SOLVING FULLC           SYSTEMS OF LINEAR ALGEBRAIC EQUATIONS.C  DGBTRF AND DGBTRS   ARE ROUTINES FROM LAPACK FOR SOLVING BANDEDC           LINEAR SYSTEMS.C  D1MACH   computes the unit roundoff in a machine-independent manner.C  XERRWD, XSETUN, XSETF, IXSAV, IUMACH   handle the printing of allC           error messages and warnings.  XERRWD is machine-dependent.C Note: SVNORM, D1MACH, IXSAV, and IUMACH are function routines.C All the others are subroutines.CC**EndCC  Declare externals.      EXTERNAL SPREPJ, SSOLSY      REAL D1MACH, SVNORMCC  Declare all other variables.      INTEGER INIT, MXSTEP, MXHNIL, NHNIL, NSLAST, NYH, IOWNS,     1   ICF, IERPJ, IERSL, JCUR, JSTART, KFLAG, L,     2   LYH, LEWT, LACOR, LSAVF, LWM, LIWM, METH, MITER,     3   MAXORD, MAXCOR, MSBP, MXNCF, N, NQ, NST, NFE, NJE, NQU      INTEGER I, I1, I2, IFLAG, IMXER, KGO, LF0,     1   LENIW, LENRW, LENWM, ML, MORD, MU, MXHNL0, MXSTP0      REAL ROWNS,     1   CCMAX, EL0, H, HMIN, HMXI, HU, RC, TN, UROUND      REAL ATOLI, AYI, BIG, EWTI, H0, HMAX, HMX, RH, RTOLI,     1   TCRIT, TDIST, TNEXT, TOL, TOLSF, TP, SIZE, SUM, W0      DIMENSION MORD(2)      LOGICAL IHIT      CHARACTER*80 MSG      SAVE MORD, MXSTP0, MXHNL0C-----------------------------------------------------------------------C The following internal Common block containsC (a) variables which are local to any subroutine but whose values mustC     be preserved between calls to the routine ("own" variables), andC (b) variables which are communicated between subroutines.C The block SLS001 is declared in subroutines SLSODE, SINTDY, SSTODE,C SPREPJ, and SSOLSY.C Groups of variables are replaced by dummy arrays in the CommonC declarations in routines where those variables are not used.C-----------------------------------------------------------------------      COMMON /SLS001/ ROWNS(209),     1   CCMAX, EL0, H, HMIN, HMXI, HU, RC, TN, UROUND,     2   INIT, MXSTEP, MXHNIL, NHNIL, NSLAST, NYH, IOWNS(6),     3   ICF, IERPJ, IERSL, JCUR, JSTART, KFLAG, L,     4   LYH, LEWT, LACOR, LSAVF, LWM, LIWM, METH, MITER,     5   MAXORD, MAXCOR, MSBP, MXNCF, N, NQ, NST, NFE, NJE, NQUC      DATA  MORD(1),MORD(2)/12,5/, MXSTP0/500/, MXHNL0/10/C-----------------------------------------------------------------------C Block A.C This code block is executed on every call.C It tests ISTATE and ITASK for legality and branches appropriately.C If ISTATE .GT. 1 but the flag INIT shows that initialization hasC not yet been done, an error return occurs.C If ISTATE = 1 and TOUT = T, return immediately.C-----------------------------------------------------------------------CC***FIRST EXECUTABLE STATEMENT  SLSODE      IF (ISTATE .LT. 1 .OR. ISTATE .GT. 3) GO TO 601      IF (ITASK .LT. 1 .OR. ITASK .GT. 5) GO TO 602      IF (ISTATE .EQ. 1) GO TO 10      IF (INIT .EQ. 0) GO TO 603      IF (ISTATE .EQ. 2) GO TO 200      GO TO 20 10   INIT = 0      IF (TOUT .EQ. T) RETURNC-----------------------------------------------------------------------C Block B.C The next code block is executed for the initial call (ISTATE = 1),C or for a continuation call with parameter changes (ISTATE = 3).C It contains checking of all inputs and various initializations.CC First check legality of the non-optional inputs NEQ, ITOL, IOPT,C MF, ML, and MU.C----------------------------------------------------------------------- 20   IF (NEQ(1) .LE. 0) GO TO 604      IF (ISTATE .EQ. 1) GO TO 25      IF (NEQ(1) .GT. N) GO TO 605 25   N = NEQ(1)      IF (ITOL .LT. 1 .OR. ITOL .GT. 4) GO TO 606      IF (IOPT .LT. 0 .OR. IOPT .GT. 1) GO TO 607      METH = MF/10      MITER = MF - 10*METH      IF (METH .LT. 1 .OR. METH .GT. 2) GO TO 608      IF (MITER .LT. 0 .OR. MITER .GT. 5) GO TO 608      IF (MITER .LE. 3) GO TO 30      ML = IWORK(1)      MU = IWORK(2)      IF (ML .LT. 0 .OR. ML .GE. N) GO TO 609      IF (MU .LT. 0 .OR. MU .GE. N) GO TO 610 30   CONTINUEC Next process and check the optional inputs. --------------------------      IF (IOPT .EQ. 1) GO TO 40      MAXORD = MORD(METH)      MXSTEP = MXSTP0      MXHNIL = MXHNL0      IF (ISTATE .EQ. 1) H0 = 0.0E0      HMXI = 0.0E0      HMIN = 0.0E0      GO TO 60 40   MAXORD = IWORK(5)      IF (MAXORD .LT. 0) GO TO 611      IF (MAXORD .EQ. 0) MAXORD = 100      MAXORD = MIN(MAXORD,MORD(METH))      MXSTEP = IWORK(6)      IF (MXSTEP .LT. 0) GO TO 612      IF (MXSTEP .EQ. 0) MXSTEP = MXSTP0      MXHNIL = IWORK(7)      IF (MXHNIL .LT. 0) GO TO 613      IF (MXHNIL .EQ. 0) MXHNIL = MXHNL0      IF (ISTATE .NE. 1) GO TO 50      H0 = RWORK(5)      IF ((TOUT - T)*H0 .LT. 0.0E0) GO TO 614 50   HMAX = RWORK(6)      IF (HMAX .LT. 0.0E0) GO TO 615      HMXI = 0.0E0      IF (HMAX .GT. 0.0E0) HMXI = 1.0E0/HMAX      HMIN = RWORK(7)      IF (HMIN .LT. 0.0E0) GO TO 616C-----------------------------------------------------------------------C Set work array pointers and check lengths LRW and LIW.C Pointers to segments of RWORK and IWORK are named by prefixing L toC the name of the segment.  E.g., the segment YH starts at RWORK(LYH).C Segments of RWORK (in order) are denoted  YH, WM, EWT, SAVF, ACOR.C----------------------------------------------------------------------- 60   LYH = 21      IF (ISTATE .EQ. 1) NYH = N      LWM = LYH + (MAXORD + 1)*NYH      IF (MITER .EQ. 0) LENWM = 0      IF (MITER .EQ. 1 .OR. MITER .EQ. 2) LENWM = N*N + 2      IF (MITER .EQ. 3) LENWM = N + 2      IF (MITER .GE. 4) LENWM = (2*ML + MU + 1)*N + 2      LEWT = LWM + LENWM      LSAVF = LEWT + N      LACOR = LSAVF + N      LENRW = LACOR + N - 1      IWORK(17) = LENRW      LIWM = 1      LENIW = 20 + N      IF (MITER .EQ. 0 .OR. MITER .EQ. 3) LENIW = 20      IWORK(18) = LENIW      IF (LENRW .GT. LRW) GO TO 617      IF (LENIW .GT. LIW) GO TO 618C Check RTOL and ATOL for legality. ------------------------------------      RTOLI = RTOL(1)      ATOLI = ATOL(1)      DO 70 I = 1,N        IF (ITOL .GE. 3) RTOLI = RTOL(I)        IF (ITOL .EQ. 2 .OR. ITOL .EQ. 4) ATOLI = ATOL(I)        IF (RTOLI .LT. 0.0E0) GO TO 619        IF (ATOLI .LT. 0.0E0) GO TO 620 70     CONTINUE      IF (ISTATE .EQ. 1) GO TO 100C If ISTATE = 3, set flag to signal parameter changes to SSTODE. -------      JSTART = -1      IF (NQ .LE. MAXORD) GO TO 90C MAXORD was reduced below NQ.  Copy YH(*,MAXORD+2) into SAVF. ---------      DO 80 I = 1,N 80     RWORK(I+LSAVF-1) = RWORK(I+LWM-1)C Reload WM(1) = RWORK(LWM), since LWM may have changed. --------------- 90   IF (MITER .GT. 0) RWORK(LWM) = SQRT(UROUND)      IF (N .EQ. NYH) GO TO 200C NEQ was reduced.  Zero part of YH to avoid undefined references. -----      I1 = LYH + L*NYH      I2 = LYH + (MAXORD + 1)*NYH - 1      IF (I1 .GT. I2) GO TO 200      DO 95 I = I1,I2 95     RWORK(I) = 0.0E0      GO TO 200C-----------------------------------------------------------------------C Block C.C The next block is for the initial call only (ISTATE = 1).C It contains all remaining initializations, the initial call to F,C and the calculation of the initial step size.C The error weights in EWT are inverted after being loaded.C----------------------------------------------------------------------- 100  UROUND = D1MACH(4)      TN = T      IF (ITASK .NE. 4 .AND. ITASK .NE. 5) GO TO 110      TCRIT = RWORK(1)      IF ((TCRIT - TOUT)*(TOUT - T) .LT. 0.0E0) GO TO 625      IF (H0 .NE. 0.0E0 .AND. (T + H0 - TCRIT)*H0 .GT. 0.0E0)     1   H0 = TCRIT - T 110  JSTART = 0      IF (MITER .GT. 0) RWORK(LWM) = SQRT(UROUND)      NHNIL = 0      NST = 0      NJE = 0      NSLAST = 0      HU = 0.0E0      NQU = 0      CCMAX = 0.3E0      MAXCOR = 3      MSBP = 20      MXNCF = 10C Initial call to F.  (LF0 points to YH(*,2).) -------------------------      LF0 = LYH + NYH      CALL F (NEQ, T, Y, RWORK(LF0))      NFE = 1C Load the initial value vector in YH. ---------------------------------      DO 115 I = 1,N 115    RWORK(I+LYH-1) = Y(I)C Load and invert the EWT array.  (H is temporarily set to 1.0.) -------      NQ = 1      H = 1.0E0      CALL SEWSET (N, ITOL, RTOL, ATOL, RWORK(LYH), RWORK(LEWT))      DO 120 I = 1,N        IF (RWORK(I+LEWT-1) .LE. 0.0E0) GO TO 621 120    RWORK(I+LEWT-1) = 1.0E0/RWORK(I+LEWT-1)C-----------------------------------------------------------------------C The coding below computes the step size, H0, to be attempted on theC first step, unless the user has supplied a value for this.C First check that TOUT - T differs significantly from zero.C A scalar tolerance quantity TOL is computed, as MAX(RTOL(I))C if this is positive, or MAX(ATOL(I)/ABS(Y(I))) otherwise, adjustedC so as to be between 100*UROUND and 1.0E-3.C Then the computed value H0 is given by..C                                      NEQC   H0**2 = TOL / ( w0**-2 + (1/NEQ) * SUM ( f(i)/ywt(i) )**2  )C                                       1C where   w0     = MAX ( ABS(T), ABS(TOUT) ),C         f(i)   = i-th component of initial value of f,C         ywt(i) = EWT(i)/TOL  (a weight for y(i)).C The sign of H0 is inferred from the initial values of TOUT and T.C-----------------------------------------------------------------------      IF (H0 .NE. 0.0E0) GO TO 180      TDIST = ABS(TOUT - T)      W0 = MAX(ABS(T),ABS(TOUT))      IF (TDIST .LT. 2.0E0*UROUND*W0) GO TO 622      TOL = RTOL(1)      IF (ITOL .LE. 2) GO TO 140      DO 130 I = 1,N 130    TOL = MAX(TOL,RTOL(I)) 140  IF (TOL .GT. 0.0E0) GO TO 160      ATOLI = ATOL(1)      DO 150 I = 1,N        IF (ITOL .EQ. 2 .OR. ITOL .EQ. 4) ATOLI = ATOL(I)        AYI = ABS(Y(I))        IF (AYI .NE. 0.0E0) TOL = MAX(TOL,ATOLI/AYI) 150    CONTINUE 160  TOL = MAX(TOL,100.0E0*UROUND)      TOL = MIN(TOL,0.001E0)      SUM = SVNORM (N, RWORK(LF0), RWORK(LEWT))      SUM = 1.0E0/(TOL*W0*W0) + TOL*SUM**2      H0 = 1.0E0/SQRT(SUM)      H0 = MIN(H0,TDIST)      H0 = SIGN(H0,TOUT-T)C Adjust H0 if necessary to meet HMAX bound. --------------------------- 180  RH = ABS(H0)*HMXI      IF (RH .GT. 1.0E0) H0 = H0/RHC Load H with H0 and scale YH(*,2) by H0. ------------------------------      H = H0      DO 190 I = 1,N 190    RWORK(I+LF0-1) = H0*RWORK(I+LF0-1)      GO TO 270C-----------------------------------------------------------------------C Block D.C The next code block is for continuation calls only (ISTATE = 2 or 3)C and is to check stop conditions before taking a step.C----------------------------------------------------------------------- 200  NSLAST = NST      GO TO (210, 250, 220, 230, 240), ITASK 210  IF ((TN - TOUT)*H .LT. 0.0E0) GO TO 250      CALL SINTDY (TOUT, 0, RWORK(LYH), NYH, Y, IFLAG)      IF (IFLAG .NE. 0) GO TO 627      T = TOUT      GO TO 420 220  TP = TN - HU*(1.0E0 + 100.0E0*UROUND)      IF ((TP - TOUT)*H .GT. 0.0E0) GO TO 623      IF ((TN - TOUT)*H .LT. 0.0E0) GO TO 250      GO TO 400 230  TCRIT = RWORK(1)      IF ((TN - TCRIT)*H .GT. 0.0E0) GO TO 624      IF ((TCRIT - TOUT)*H .LT. 0.0E0) GO TO 625      IF ((TN - TOUT)*H .LT. 0.0E0) GO TO 245      CALL SINTDY (TOUT, 0, RWORK(LYH), NYH, Y, IFLAG)      IF (IFLAG .NE. 0) GO TO 627      T = TOUT      GO TO 420 240  TCRIT = RWORK(1)      IF ((TN - TCRIT)*H .GT. 0.0E0) GO TO 624 245  HMX = ABS(TN) + ABS(H)      IHIT = ABS(TN - TCRIT) .LE. 100.0E0*UROUND*HMX      IF (IHIT) GO TO 400      TNEXT = TN + H*(1.0E0 + 4.0E0*UROUND)      IF ((TNEXT - TCRIT)*H .LE. 0.0E0) GO TO 250      H = (TCRIT - TN)*(1.0E0 - 4.0E0*UROUND)      IF (ISTATE .EQ. 2) JSTART = -2C-----------------------------------------------------------------------C Block E.C The next block is normally executed for all calls and containsC the call to the one-step core integrator SSTODE.CC This is a looping point for the integration steps.CC First check for too many steps being taken, update EWT (if not atC start of problem), check for too much accuracy being requested, andC check for H below the roundoff level in T.C----------------------------------------------------------------------- 250  CONTINUE      IF ((NST-NSLAST) .GE. MXSTEP) GO TO 500      CALL SEWSET (N, ITOL, RTOL, ATOL, RWORK(LYH), RWORK(LEWT))      DO 260 I = 1,N        IF (RWORK(I+LEWT-1) .LE. 0.0E0) GO TO 510 260    RWORK(I+LEWT-1) = 1.0E0/RWORK(I+LEWT-1) 270  TOLSF = UROUND*SVNORM (N, RWORK(LYH), RWORK(LEWT))      IF (TOLSF .LE. 1.0E0) GO TO 280      TOLSF = TOLSF*2.0E0      IF (NST .EQ. 0) GO TO 626      GO TO 520 280  IF ((TN + H) .NE. TN) GO TO 290      NHNIL = NHNIL + 1      IF (NHNIL .GT. MXHNIL) GO TO 290      CALL XERRWD('SLSODE-  Warning..internal T (=R1) and H (=R2) are


',      1     50, 101, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD(     1  '      such that in the machine, T + H = T on the next step  

',      1     60, 101, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      (H = step size). Solver will continue anyway


',      1     50, 101, 0, 0, 0, 0, 2, TN, H)      IF (NHNIL .LT. MXHNIL) GO TO 290      CALL XERRWD('SLSODE-  Above warning has been issued I1 times.  

',      1     50, 102, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      It will not be issued again for this problem








































































',      1     50, 102, 0, 1, MXHNIL, 0, 0, 0.0E0, 0.0E0) 290  CONTINUEC-----------------------------------------------------------------------C  CALL SSTODE(NEQ,Y,YH,NYH,YH,EWT,SAVF,ACOR,WM,IWM,F,JAC,SPREPJ,SSOLSY)C-----------------------------------------------------------------------      CALL SSTODE (NEQ, Y, RWORK(LYH), NYH, RWORK(LYH), RWORK(LEWT),     1   RWORK(LSAVF), RWORK(LACOR), RWORK(LWM), IWORK(LIWM),     2   F, JAC, SPREPJ, SSOLSY)      KGO = 1 - KFLAG      GO TO (300, 530, 540), KGOC-----------------------------------------------------------------------C Block F.C The following block handles the case of a successful return from theC core integrator (KFLAG = 0).  Test for stop conditions.C----------------------------------------------------------------------- 300  INIT = 1      GO TO (310, 400, 330, 340, 350), ITASKC ITASK = 1.  If TOUT has been reached, interpolate. ------------------- 310  IF ((TN - TOUT)*H .LT. 0.0E0) GO TO 250      CALL SINTDY (TOUT, 0, RWORK(LYH), NYH, Y, IFLAG)      T = TOUT      GO TO 420C ITASK = 3.  Jump to exit if TOUT was reached. ------------------------ 330  IF ((TN - TOUT)*H .GE. 0.0E0) GO TO 400      GO TO 250C ITASK = 4.  See if TOUT or TCRIT was reached.  Adjust H if necessary. 340  IF ((TN - TOUT)*H .LT. 0.0E0) GO TO 345      CALL SINTDY (TOUT, 0, RWORK(LYH), NYH, Y, IFLAG)      T = TOUT      GO TO 420 345  HMX = ABS(TN) + ABS(H)      IHIT = ABS(TN - TCRIT) .LE. 100.0E0*UROUND*HMX      IF (IHIT) GO TO 400      TNEXT = TN + H*(1.0E0 + 4.0E0*UROUND)      IF ((TNEXT - TCRIT)*H .LE. 0.0E0) GO TO 250      H = (TCRIT - TN)*(1.0E0 - 4.0E0*UROUND)      JSTART = -2      GO TO 250C ITASK = 5.  See if TCRIT was reached and jump to exit. --------------- 350  HMX = ABS(TN) + ABS(H)      IHIT = ABS(TN - TCRIT) .LE. 100.0E0*UROUND*HMXC-----------------------------------------------------------------------C Block G.C The following block handles all successful returns from SLSODE.C If ITASK .NE. 1, Y is loaded from YH and T is set accordingly.C ISTATE is set to 2, and the optional outputs are loaded into theC work arrays before returning.C----------------------------------------------------------------------- 400  DO 410 I = 1,N 410    Y(I) = RWORK(I+LYH-1)      T = TN      IF (ITASK .NE. 4 .AND. ITASK .NE. 5) GO TO 420      IF (IHIT) T = TCRIT 420  ISTATE = 2      RWORK(11) = HU      RWORK(12) = H      RWORK(13) = TN      IWORK(11) = NST      IWORK(12) = NFE      IWORK(13) = NJE      IWORK(14) = NQU      IWORK(15) = NQ      RETURNC-----------------------------------------------------------------------C Block H.C The following block handles all unsuccessful returns other thanC those for illegal input.  First the error message routine is called.C If there was an error test or convergence test failure, IMXER is set.C Then Y is loaded from YH and T is set to TN.  The optional outputsC are loaded into the work arrays before returning.C-----------------------------------------------------------------------C The maximum number of steps was taken before reaching TOUT. ---------- 500  CALL XERRWD('SLSODE-  At current T (=R1), MXSTEP (=I1) steps   

',      1 50, 201, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      taken on this call before reaching TOUT     





',      1     50, 201, 0, 1, MXSTEP, 0, 1, TN, 0.0E0)      ISTATE = -1      GO TO 580C EWT(I) .LE. 0.0 for some I (not at start of problem). ---------------- 510  EWTI = RWORK(LEWT+I-1)      CALL XERRWD('SLSODE-  At T (=R1), EWT(I1) has become R2 .LE. 0.




',      1 50, 202, 0, 1, I, 0, 2, TN, EWTI)      ISTATE = -6      GO TO 580C Too much accuracy requested for machine precision. ------------------- 520  CALL XERRWD('SLSODE-  At T (=R1), too much accuracy requested  

',      1     50, 203, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      for precision of machine..  see TOLSF (=R2) 





',      1     50, 203, 0, 0, 0, 0, 2, TN, TOLSF)      RWORK(14) = TOLSF      ISTATE = -2      GO TO 580C KFLAG = -1.  Error test failed repeatedly or with ABS(H) = HMIN. ----- 530  CALL XERRWD('SLSODE-  At T(=R1) and step size H(=R2), the error

',      1     50, 204, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      test failed repeatedly or with ABS(H) = HMIN




',      1     50, 204, 0, 0, 0, 0, 2, TN, H)      ISTATE = -4      GO TO 560C KFLAG = -2.  Convergence failed repeatedly or with ABS(H) = HMIN. ---- 540  CALL XERRWD('SLSODE-  At T (=R1) and step size H (=R2), the    

',     1     50, 205, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      corrector convergence failed repeatedly     

',      1     50, 205, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD('      or with ABS(H) = HMIN   
































',      1     30, 205, 0, 0, 0, 0, 2, TN, H)      ISTATE = -5C Compute IMXER if relevant. ------------------------------------------- 560  BIG = 0.0E0      IMXER = 1      DO 570 I = 1,N        SIZE = ABS(RWORK(I+LACOR-1)*RWORK(I+LEWT-1))        IF (BIG .GE. SIZE) GO TO 570        BIG = SIZE        IMXER = I 570    CONTINUE      IWORK(16) = IMXERC Set Y vector, T, and optional outputs. ------------------------------- 580  DO 590 I = 1,N 590    Y(I) = RWORK(I+LYH-1)      T = TN      RWORK(11) = HU      RWORK(12) = H      RWORK(13) = TN      IWORK(11) = NST      IWORK(12) = NFE      IWORK(13) = NJE      IWORK(14) = NQU      IWORK(15) = NQ      RETURNC-----------------------------------------------------------------------C Block I.C The following block handles all error returns due to illegal inputC (ISTATE = -3), as detected before calling the core integrator.C First the error message routine is called.  If the illegal input C is a negative ISTATE, the run is aborted (apparent infinite loop).C----------------------------------------------------------------------- 601  CALL XERRWD('SLSODE-  ISTATE (=I1) illegal 



',     1     30, 1, 0, 1, ISTATE, 0, 0, 0.0E0, 0.0E0)      IF (ISTATE .LT. 0) GO TO 800      GO TO 700 602  CALL XERRWD('SLSODE-  ITASK (=I1) illegal  


',      1     30, 2, 0, 1, ITASK, 0, 0, 0.0E0, 0.0E0)      GO TO 700 603  CALL XERRWD('SLSODE-  ISTATE .GT. 1 but SLSODE not initialized 


',      1     50, 3, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      GO TO 700 604  CALL XERRWD('SLSODE-  NEQ (=I1) .LT. 1     


',      1     30, 4, 0, 1, NEQ(1), 0, 0, 0.0E0, 0.0E0)      GO TO 700 605  CALL XERRWD('SLSODE-  ISTATE = 3 and NEQ increased (I1 to I2)  


',      1     50, 5, 0, 2, N, NEQ(1), 0, 0.0E0, 0.0E0)      GO TO 700 606  CALL XERRWD('SLSODE-  ITOL (=I1) illegal   


',     1     30, 6, 0, 1, ITOL, 0, 0, 0.0E0, 0.0E0)      GO TO 700 607  CALL XERRWD('SLSODE-  IOPT (=I1) illegal   


',      1     30, 7, 0, 1, IOPT, 0, 0, 0.0E0, 0.0E0)      GO TO 700 608  CALL XERRWD('SLSODE-  MF (=I1) illegal     


',      1     30, 8, 0, 1, MF, 0, 0, 0.0E0, 0.0E0)      GO TO 700 609  CALL XERRWD('SLSODE-  ML (=I1) illegal.. .LT.0 or .GE.NEQ (=I2)


',      1     50, 9, 0, 2, ML, NEQ(1), 0, 0.0E0, 0.0E0)      GO TO 700 610  CALL XERRWD('SLSODE-  MU (=I1) illegal.. .LT.0 or .GE.NEQ (=I2)


',      1     50, 10, 0, 2, MU, NEQ(1), 0, 0.0E0, 0.0E0)      GO TO 700 611  CALL XERRWD('SLSODE-  MAXORD (=I1) .LT. 0  


',      1     30, 11, 0, 1, MAXORD, 0, 0, 0.0E0, 0.0E0)      GO TO 700 612  CALL XERRWD('SLSODE-  MXSTEP (=I1) .LT. 0  


',      1 30, 12, 0, 1, MXSTEP, 0, 0, 0.0E0, 0.0E0)      GO TO 700 613  CALL XERRWD('SLSODE-  MXHNIL (=I1) .LT. 0  


',      1     30, 13, 0, 1, MXHNIL, 0, 0, 0.0E0, 0.0E0)      GO TO 700 614  CALL XERRWD('SLSODE-  TOUT (=R1) behind T (=R2)      

',      1     40, 14, 0, 0, 0, 0, 2, TOUT, T)      CALL XERRWD('      Integration direction is given by H0 (=R1)  


',      1     50, 14, 0, 0, 0, 0, 1, H0, 0.0E0)      GO TO 700 615  CALL XERRWD('SLSODE-  HMAX (=R1) .LT. 0.0  


',      1     30, 15, 0, 0, 0, 0, 1, HMAX, 0.0E0)      GO TO 700 616  CALL XERRWD('SLSODE-  HMIN (=R1) .LT. 0.0  



',      1     30, 16, 0, 0, 0, 0, 1, HMIN, 0.0E0)      GO TO 700 617  CALL XERRWD(     1  'SLSODE-  RWORK length needed, LENRW (=I1), exceeds LRW (=I2)



',      1   60, 17, 0, 2, LENRW, LRW, 0, 0.0E0, 0.0E0)      GO TO 700 618  CALL XERRWD(     1   'SLSODE-  IWORK length needed, LENIW (=I1), exceeds LIW (=I2)


',     1    60, 18, 0, 2, LENIW, LIW, 0, 0.0E0, 0.0E0)      GO TO 700 619  CALL XERRWD('SLSODE-  RTOL(I1) is R1 .LT. 0.0        


',      1     40, 19, 0, 1, I, 0, 1, RTOLI, 0.0E0)      GO TO 700 620  CALL XERRWD('SLSODE-  ATOL(I1) is R1 .LT. 0.0        



',      1     40, 20, 0, 1, I, 0, 1, ATOLI, 0.0E0)      GO TO 700 621  EWTI = RWORK(LEWT+I-1)      CALL XERRWD('SLSODE-  EWT(I1) is R1 .LE. 0.0         



',      1     40, 21, 0, 1, I, 0, 1, EWTI, 0.0E0)      GO TO 700 622  CALL XERRWD(     1   'SLSODE-  TOUT (=R1) too close to T(=R2) to start integration



',     1     60, 22, 0, 0, 0, 0, 2, TOUT, T)      GO TO 700 623  CALL XERRWD(     1 'SLSODE-  ITASK = I1 and TOUT (=R1) behind TCUR - HU (= R2)  



',      1     60, 23, 0, 1, ITASK, 0, 2, TOUT, TP)      GO TO 700 624  CALL XERRWD(     1   'SLSODE-  ITASK = 4 OR 5 and TCRIT (=R1) behind TCUR (=R2)   



',     1    60, 24, 0, 0, 0, 0, 2, TCRIT, TN)      GO TO 700 625  CALL XERRWD(     1  'SLSODE-  ITASK = 4 or 5 and TCRIT (=R1) behind TOUT (=R2)   


',     1   60, 25, 0, 0, 0, 0, 2, TCRIT, TOUT)      GO TO 700 626  CALL XERRWD('SLSODE-  At start of problem, too much accuracy   


',     1     50, 26, 0, 0, 0, 0, 0, 0.0E0, 0.0E0)      CALL XERRWD(     1   '      requested for precision of machine..  See TOLSF (=R1) 



',     1    60, 26, 0, 0, 0, 0, 1, TOLSF, 0.0E0)      RWORK(14) = TOLSF      GO TO 700 627  CALL XERRWD('SLSODE-  Trouble in SINTDY.  ITASK = I1, TOUT = R1





',      1     50, 27, 0, 1, ITASK, 0, 1, TOUT, 0.0E0)C 700  ISTATE = -3      RETURNC 800  CALL XERRWD('SLSODE-  Run aborted.. apparent infinite loop     





Generated by  Doxygen 1.6.0   Back to index