ode 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,114 @@
1
+ subroutine xerrwv (msg, nmes, nerr, level, ni, i1, i2, nr, r1, r2)
2
+ integer msg, nmes, nerr, level, ni, i1, i2, nr,
3
+ 1 i, lun, lunit, mesflg, ncpw, nch, nwds
4
+ double precision r1, r2
5
+ dimension msg(nmes)
6
+ c-----------------------------------------------------------------------
7
+ c subroutines xerrwv, xsetf, and xsetun, as given here, constitute
8
+ c a simplified version of the slatec error handling package.
9
+ c written by a. c. hindmarsh at llnl. version of march 30, 1987.
10
+ c this version is in double precision.
11
+ c
12
+ c all arguments are input arguments.
13
+ c
14
+ c msg = the message (hollerith literal or integer array).
15
+ c nmes = the length of msg (number of characters).
16
+ c nerr = the error number (not used).
17
+ c level = the error level..
18
+ c 0 or 1 means recoverable (control returns to caller).
19
+ c 2 means fatal (run is aborted--see note below).
20
+ c ni = number of integers (0, 1, or 2) to be printed with message.
21
+ c i1,i2 = integers to be printed, depending on ni.
22
+ c nr = number of reals (0, 1, or 2) to be printed with message.
23
+ c r1,r2 = reals to be printed, depending on nr.
24
+ c
25
+ c note.. this routine is machine-dependent and specialized for use
26
+ c in limited context, in the following ways..
27
+ c 1. the number of hollerith characters stored per word, denoted
28
+ c by ncpw below, is a data-loaded constant.
29
+ c 2. the value of nmes is assumed to be at most 60.
30
+ c (multi-line messages are generated by repeated calls.)
31
+ c 3. if level = 2, control passes to the statement stop
32
+ c to abort the run. this statement may be machine-dependent.
33
+ c 4. r1 and r2 are assumed to be in double precision and are printed
34
+ c in d21.13 format.
35
+ c 5. the common block /eh0001/ below is data-loaded (a machine-
36
+ c dependent feature) with default values.
37
+ c this block is needed for proper retention of parameters used by
38
+ c this routine which the user can reset by calling xsetf or xsetun.
39
+ c the variables in this block are as follows..
40
+ c mesflg = print control flag..
41
+ c 1 means print all messages (the default).
42
+ c 0 means no printing.
43
+ c lunit = logical unit number for messages.
44
+ c the default is 6 (machine-dependent).
45
+ c-----------------------------------------------------------------------
46
+ c the following are instructions for installing this routine
47
+ c in different machine environments.
48
+ c
49
+ c to change the default output unit, change the data statement
50
+ c in the block data subprogram below.
51
+ c
52
+ c for a different number of characters per word, change the
53
+ c data statement setting ncpw below, and format 10. alternatives for
54
+ c various computers are shown in comment cards.
55
+ c
56
+ c for a different run-abort command, change the statement following
57
+ c statement 100 at the end.
58
+ c-----------------------------------------------------------------------
59
+ common /eh0001/ mesflg, lunit
60
+ c-----------------------------------------------------------------------
61
+ c the following data-loaded value of ncpw is valid for the cdc-6600
62
+ c and cdc-7600 computers.
63
+ c data ncpw/10/
64
+ c the following is valid for the cray-1 computer.
65
+ c data ncpw/8/
66
+ c the following is valid for the burroughs 6700 and 7800 computers.
67
+ c data ncpw/6/
68
+ c the following is valid for the pdp-10 computer.
69
+ c data ncpw/5/
70
+ c the following is valid for the vax computer with 4 bytes per integer,
71
+ c and for the ibm-360, ibm-370, ibm-303x, and ibm-43xx computers.
72
+ data ncpw/4/
73
+ c the following is valid for the pdp-11, or vax with 2-byte integers.
74
+ c data ncpw/2/
75
+ c-----------------------------------------------------------------------
76
+ if (mesflg .eq. 0) go to 100
77
+ c get logical unit number. ---------------------------------------------
78
+ lun = lunit
79
+ c get number of words in message. --------------------------------------
80
+ nch = min0(nmes,60)
81
+ nwds = nch/ncpw
82
+ if (nch .ne. nwds*ncpw) nwds = nwds + 1
83
+ c write the message. ---------------------------------------------------
84
+ write (lun, 10) (msg(i),i=1,nwds)
85
+ c-----------------------------------------------------------------------
86
+ c the following format statement is to have the form
87
+ c 10 format(1x,mmann)
88
+ c where nn = ncpw and mm is the smallest integer .ge. 60/ncpw.
89
+ c the following is valid for ncpw = 10.
90
+ c 10 format(1x,6a10)
91
+ c the following is valid for ncpw = 8.
92
+ c 10 format(1x,8a8)
93
+ c the following is valid for ncpw = 6.
94
+ c 10 format(1x,10a6)
95
+ c the following is valid for ncpw = 5.
96
+ c 10 format(1x,12a5)
97
+ c the following is valid for ncpw = 4.
98
+ 10 format(1x,15a4)
99
+ c the following is valid for ncpw = 2.
100
+ c 10 format(1x,30a2)
101
+ c-----------------------------------------------------------------------
102
+ if (ni .eq. 1) write (lun, 20) i1
103
+ 20 format(6x,'in above message, i1 =',i10)
104
+ if (ni .eq. 2) write (lun, 30) i1,i2
105
+ 30 format(6x,'in above message, i1 =',i10,3x,'i2 =',i10)
106
+ if (nr .eq. 1) write (lun, 40) r1
107
+ 40 format(6x,'in above message, r1 =',d21.13)
108
+ if (nr .eq. 2) write (lun, 50) r1,r2
109
+ 50 format(6x,'in above, r1 =',d21.13,3x,'r2 =',d21.13)
110
+ c abort the run if level = 2. ------------------------------------------
111
+ 100 if (level .ne. 2) return
112
+ stop
113
+ c----------------------- end of subroutine xerrwv ----------------------
114
+ end
@@ -0,0 +1,3658 @@
1
+ *DECK ZVODE
2
+ SUBROUTINE ZVODE (F, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL, ITASK,
3
+ 1 ISTATE, IOPT, ZWORK, LZW, RWORK, LRW, IWORK, LIW,
4
+ 2 JAC, MF, RPAR, IPAR)
5
+ EXTERNAL F, JAC
6
+ DOUBLE COMPLEX Y, ZWORK
7
+ DOUBLE PRECISION T, TOUT, RTOL, ATOL, RWORK
8
+ INTEGER NEQ, ITOL, ITASK, ISTATE, IOPT, LZW, LRW, IWORK, LIW,
9
+ 1 MF, IPAR
10
+ DIMENSION Y(*), RTOL(*), ATOL(*), ZWORK(LZW), RWORK(LRW),
11
+ 1 IWORK(LIW), RPAR(*), IPAR(*)
12
+ C-----------------------------------------------------------------------
13
+ C ZVODE: Variable-coefficient Ordinary Differential Equation solver,
14
+ C with fixed-leading-coefficient implementation.
15
+ C This version is in complex double precision.
16
+ C
17
+ C ZVODE solves the initial value problem for stiff or nonstiff
18
+ C systems of first order ODEs,
19
+ C dy/dt = f(t,y) , or, in component form,
20
+ C dy(i)/dt = f(i) = f(i,t,y(1),y(2),...,y(NEQ)) (i = 1,...,NEQ).
21
+ C Here the y vector is treated as complex.
22
+ C ZVODE is a package based on the EPISODE and EPISODEB packages, and
23
+ C on the ODEPACK user interface standard, with minor modifications.
24
+ C
25
+ C NOTE: When using ZVODE for a stiff system, it should only be used for
26
+ C the case in which the function f is analytic, that is, when each f(i)
27
+ C is an analytic function of each y(j). Analyticity means that the
28
+ C partial derivative df(i)/dy(j) is a unique complex number, and this
29
+ C fact is critical in the way ZVODE solves the dense or banded linear
30
+ C systems that arise in the stiff case. For a complex stiff ODE system
31
+ C in which f is not analytic, ZVODE is likely to have convergence
32
+ C failures, and for this problem one should instead use DVODE on the
33
+ C equivalent real system (in the real and imaginary parts of y).
34
+ C-----------------------------------------------------------------------
35
+ C Authors:
36
+ C Peter N. Brown and Alan C. Hindmarsh
37
+ C Center for Applied Scientific Computing
38
+ C Lawrence Livermore National Laboratory
39
+ C Livermore, CA 94551
40
+ C and
41
+ C George D. Byrne (Prof. Emeritus)
42
+ C Illinois Institute of Technology
43
+ C Chicago, IL 60616
44
+ C-----------------------------------------------------------------------
45
+ C For references, see DVODE.
46
+ C-----------------------------------------------------------------------
47
+ C Summary of usage.
48
+ C
49
+ C Communication between the user and the ZVODE package, for normal
50
+ C situations, is summarized here. This summary describes only a subset
51
+ C of the full set of options available. See the full description for
52
+ C details, including optional communication, nonstandard options,
53
+ C and instructions for special situations. See also the example
54
+ C problem (with program and output) following this summary.
55
+ C
56
+ C A. First provide a subroutine of the form:
57
+ C SUBROUTINE F (NEQ, T, Y, YDOT, RPAR, IPAR)
58
+ C DOUBLE COMPLEX Y(NEQ), YDOT(NEQ)
59
+ C DOUBLE PRECISION T
60
+ C which supplies the vector function f by loading YDOT(i) with f(i).
61
+ C
62
+ C B. Next determine (or guess) whether or not the problem is stiff.
63
+ C Stiffness occurs when the Jacobian matrix df/dy has an eigenvalue
64
+ C whose real part is negative and large in magnitude, compared to the
65
+ C reciprocal of the t span of interest. If the problem is nonstiff,
66
+ C use a method flag MF = 10. If it is stiff, there are four standard
67
+ C choices for MF (21, 22, 24, 25), and ZVODE requires the Jacobian
68
+ C matrix in some form. In these cases (MF .gt. 0), ZVODE will use a
69
+ C saved copy of the Jacobian matrix. If this is undesirable because of
70
+ C storage limitations, set MF to the corresponding negative value
71
+ C (-21, -22, -24, -25). (See full description of MF below.)
72
+ C The Jacobian matrix is regarded either as full (MF = 21 or 22),
73
+ C or banded (MF = 24 or 25). In the banded case, ZVODE requires two
74
+ C half-bandwidth parameters ML and MU. These are, respectively, the
75
+ C widths of the lower and upper parts of the band, excluding the main
76
+ C diagonal. Thus the band consists of the locations (i,j) with
77
+ C i-ML .le. j .le. i+MU, and the full bandwidth is ML+MU+1.
78
+ C
79
+ C C. If the problem is stiff, you are encouraged to supply the Jacobian
80
+ C directly (MF = 21 or 24), but if this is not feasible, ZVODE will
81
+ C compute it internally by difference quotients (MF = 22 or 25).
82
+ C If you are supplying the Jacobian, provide a subroutine of the form:
83
+ C SUBROUTINE JAC (NEQ, T, Y, ML, MU, PD, NROWPD, RPAR, IPAR)
84
+ C DOUBLE COMPLEX Y(NEQ), PD(NROWPD,NEQ)
85
+ C DOUBLE PRECISION T
86
+ C which supplies df/dy by loading PD as follows:
87
+ C For a full Jacobian (MF = 21), load PD(i,j) with df(i)/dy(j),
88
+ C the partial derivative of f(i) with respect to y(j). (Ignore the
89
+ C ML and MU arguments in this case.)
90
+ C For a banded Jacobian (MF = 24), load PD(i-j+MU+1,j) with
91
+ C df(i)/dy(j), i.e. load the diagonal lines of df/dy into the rows of
92
+ C PD from the top down.
93
+ C In either case, only nonzero elements need be loaded.
94
+ C
95
+ C D. Write a main program which calls subroutine ZVODE once for
96
+ C each point at which answers are desired. This should also provide
97
+ C for possible use of logical unit 6 for output of error messages
98
+ C by ZVODE. On the first call to ZVODE, supply arguments as follows:
99
+ C F = Name of subroutine for right-hand side vector f.
100
+ C This name must be declared external in calling program.
101
+ C NEQ = Number of first order ODEs.
102
+ C Y = Double complex array of initial values, of length NEQ.
103
+ C T = The initial value of the independent variable.
104
+ C TOUT = First point where output is desired (.ne. T).
105
+ C ITOL = 1 or 2 according as ATOL (below) is a scalar or array.
106
+ C RTOL = Relative tolerance parameter (scalar).
107
+ C ATOL = Absolute tolerance parameter (scalar or array).
108
+ C The estimated local error in Y(i) will be controlled so as
109
+ C to be roughly less (in magnitude) than
110
+ C EWT(i) = RTOL*abs(Y(i)) + ATOL if ITOL = 1, or
111
+ C EWT(i) = RTOL*abs(Y(i)) + ATOL(i) if ITOL = 2.
112
+ C Thus the local error test passes if, in each component,
113
+ C either the absolute error is less than ATOL (or ATOL(i)),
114
+ C or the relative error is less than RTOL.
115
+ C Use RTOL = 0.0 for pure absolute error control, and
116
+ C use ATOL = 0.0 (or ATOL(i) = 0.0) for pure relative error
117
+ C control. Caution: Actual (global) errors may exceed these
118
+ C local tolerances, so choose them conservatively.
119
+ C ITASK = 1 for normal computation of output values of Y at t = TOUT.
120
+ C ISTATE = Integer flag (input and output). Set ISTATE = 1.
121
+ C IOPT = 0 to indicate no optional input used.
122
+ C ZWORK = Double precision complex work array of length at least:
123
+ C 15*NEQ for MF = 10,
124
+ C 8*NEQ + 2*NEQ**2 for MF = 21 or 22,
125
+ C 10*NEQ + (3*ML + 2*MU)*NEQ for MF = 24 or 25.
126
+ C LZW = Declared length of ZWORK (in user's DIMENSION statement).
127
+ C RWORK = Real work array of length at least 20 + NEQ.
128
+ C LRW = Declared length of RWORK (in user's DIMENSION statement).
129
+ C IWORK = Integer work array of length at least:
130
+ C 30 for MF = 10,
131
+ C 30 + NEQ for MF = 21, 22, 24, or 25.
132
+ C If MF = 24 or 25, input in IWORK(1),IWORK(2) the lower
133
+ C and upper half-bandwidths ML,MU.
134
+ C LIW = Declared length of IWORK (in user's DIMENSION statement).
135
+ C JAC = Name of subroutine for Jacobian matrix (MF = 21 or 24).
136
+ C If used, this name must be declared external in calling
137
+ C program. If not used, pass a dummy name.
138
+ C MF = Method flag. Standard values are:
139
+ C 10 for nonstiff (Adams) method, no Jacobian used.
140
+ C 21 for stiff (BDF) method, user-supplied full Jacobian.
141
+ C 22 for stiff method, internally generated full Jacobian.
142
+ C 24 for stiff method, user-supplied banded Jacobian.
143
+ C 25 for stiff method, internally generated banded Jacobian.
144
+ C RPAR = user-defined real or complex array passed to F and JAC.
145
+ C IPAR = user-defined integer array passed to F and JAC.
146
+ C Note that the main program must declare arrays Y, ZWORK, RWORK, IWORK,
147
+ C and possibly ATOL, RPAR, and IPAR. RPAR may be declared REAL, DOUBLE,
148
+ C COMPLEX, or DOUBLE COMPLEX, depending on the user's needs.
149
+ C
150
+ C E. The output from the first call (or any call) is:
151
+ C Y = Array of computed values of y(t) vector.
152
+ C T = Corresponding value of independent variable (normally TOUT).
153
+ C ISTATE = 2 if ZVODE was successful, negative otherwise.
154
+ C -1 means excess work done on this call. (Perhaps wrong MF.)
155
+ C -2 means excess accuracy requested. (Tolerances too small.)
156
+ C -3 means illegal input detected. (See printed message.)
157
+ C -4 means repeated error test failures. (Check all input.)
158
+ C -5 means repeated convergence failures. (Perhaps bad
159
+ C Jacobian supplied or wrong choice of MF or tolerances.)
160
+ C -6 means error weight became zero during problem. (Solution
161
+ C component i vanished, and ATOL or ATOL(i) = 0.)
162
+ C
163
+ C F. To continue the integration after a successful return, simply
164
+ C reset TOUT and call ZVODE again. No other parameters need be reset.
165
+ C
166
+ C-----------------------------------------------------------------------
167
+ C EXAMPLE PROBLEM
168
+ C
169
+ C The program below uses ZVODE to solve the following system of 2 ODEs:
170
+ C dw/dt = -i*w*w*z, dz/dt = i*z; w(0) = 1/2.1, z(0) = 1; t = 0 to 2*pi.
171
+ C Solution: w = 1/(z + 1.1), z = exp(it). As z traces the unit circle,
172
+ C w traces a circle of radius 10/2.1 with center at 11/2.1.
173
+ C For convenience, Main passes RPAR = (imaginary unit i) to FEX and JEX.
174
+ C
175
+ C EXTERNAL FEX, JEX
176
+ C DOUBLE COMPLEX Y(2), ZWORK(24), RPAR, WTRU, ERR
177
+ C DOUBLE PRECISION ABERR, AEMAX, ATOL, RTOL, RWORK(22), T, TOUT
178
+ C DIMENSION IWORK(32)
179
+ C NEQ = 2
180
+ C Y(1) = 1.0D0/2.1D0
181
+ C Y(2) = 1.0D0
182
+ C T = 0.0D0
183
+ C DTOUT = 0.1570796326794896D0
184
+ C TOUT = DTOUT
185
+ C ITOL = 1
186
+ C RTOL = 1.D-9
187
+ C ATOL = 1.D-8
188
+ C ITASK = 1
189
+ C ISTATE = 1
190
+ C IOPT = 0
191
+ C LZW = 24
192
+ C LRW = 22
193
+ C LIW = 32
194
+ C MF = 21
195
+ C RPAR = DCMPLX(0.0D0,1.0D0)
196
+ C AEMAX = 0.0D0
197
+ C WRITE(6,10)
198
+ C 10 FORMAT(' t',11X,'w',26X,'z')
199
+ C DO 40 IOUT = 1,40
200
+ C CALL ZVODE(FEX,NEQ,Y,T,TOUT,ITOL,RTOL,ATOL,ITASK,ISTATE,IOPT,
201
+ C 1 ZWORK,LZW,RWORK,LRW,IWORK,LIW,JEX,MF,RPAR,IPAR)
202
+ C WTRU = 1.0D0/DCMPLX(COS(T) + 1.1D0, SIN(T))
203
+ C ERR = Y(1) - WTRU
204
+ C ABERR = ABS(DREAL(ERR)) + ABS(DIMAG(ERR))
205
+ C AEMAX = MAX(AEMAX,ABERR)
206
+ C WRITE(6,20) T, DREAL(Y(1)),DIMAG(Y(1)), DREAL(Y(2)),DIMAG(Y(2))
207
+ C 20 FORMAT(F9.5,2X,2F12.7,3X,2F12.7)
208
+ C IF (ISTATE .LT. 0) THEN
209
+ C WRITE(6,30) ISTATE
210
+ C 30 FORMAT(//'***** Error halt. ISTATE =',I3)
211
+ C STOP
212
+ C ENDIF
213
+ C 40 TOUT = TOUT + DTOUT
214
+ C WRITE(6,50) IWORK(11), IWORK(12), IWORK(13), IWORK(20),
215
+ C 1 IWORK(21), IWORK(22), IWORK(23), AEMAX
216
+ C 50 FORMAT(/' No. steps =',I4,' No. f-s =',I5,
217
+ C 1 ' No. J-s =',I4,' No. LU-s =',I4/
218
+ C 2 ' No. nonlinear iterations =',I4/
219
+ C 3 ' No. nonlinear convergence failures =',I4/
220
+ C 4 ' No. error test failures =',I4/
221
+ C 5 ' Max. abs. error in w =',D10.2)
222
+ C STOP
223
+ C END
224
+ C
225
+ C SUBROUTINE FEX (NEQ, T, Y, YDOT, RPAR, IPAR)
226
+ C DOUBLE COMPLEX Y(NEQ), YDOT(NEQ), RPAR
227
+ C DOUBLE PRECISION T
228
+ C YDOT(1) = -RPAR*Y(1)*Y(1)*Y(2)
229
+ C YDOT(2) = RPAR*Y(2)
230
+ C RETURN
231
+ C END
232
+ C
233
+ C SUBROUTINE JEX (NEQ, T, Y, ML, MU, PD, NRPD, RPAR, IPAR)
234
+ C DOUBLE COMPLEX Y(NEQ), PD(NRPD,NEQ), RPAR
235
+ C DOUBLE PRECISION T
236
+ C PD(1,1) = -2.0D0*RPAR*Y(1)*Y(2)
237
+ C PD(1,2) = -RPAR*Y(1)*Y(1)
238
+ C PD(2,2) = RPAR
239
+ C RETURN
240
+ C END
241
+ C
242
+ C The output of this example program is as follows:
243
+ C
244
+ C t w z
245
+ C 0.15708 0.4763242 -0.0356919 0.9876884 0.1564345
246
+ C 0.31416 0.4767322 -0.0718256 0.9510565 0.3090170
247
+ C 0.47124 0.4774351 -0.1088651 0.8910065 0.4539906
248
+ C 0.62832 0.4784699 -0.1473206 0.8090170 0.5877853
249
+ C 0.78540 0.4798943 -0.1877789 0.7071067 0.7071069
250
+ C 0.94248 0.4817938 -0.2309414 0.5877852 0.8090171
251
+ C 1.09956 0.4842934 -0.2776778 0.4539904 0.8910066
252
+ C 1.25664 0.4875766 -0.3291039 0.3090169 0.9510566
253
+ C 1.41372 0.4919177 -0.3866987 0.1564343 0.9876884
254
+ C 1.57080 0.4977376 -0.4524889 -0.0000001 1.0000000
255
+ C 1.72788 0.5057044 -0.5293524 -0.1564346 0.9876883
256
+ C 1.88496 0.5169274 -0.6215400 -0.3090171 0.9510565
257
+ C 2.04204 0.5333540 -0.7356275 -0.4539906 0.8910065
258
+ C 2.19911 0.5586542 -0.8823669 -0.5877854 0.8090169
259
+ C 2.35619 0.6004188 -1.0806013 -0.7071069 0.7071067
260
+ C 2.51327 0.6764486 -1.3664281 -0.8090171 0.5877851
261
+ C 2.67035 0.8366909 -1.8175245 -0.8910066 0.4539904
262
+ C 2.82743 1.2657121 -2.6260146 -0.9510566 0.3090168
263
+ C 2.98451 3.0284506 -4.2182180 -0.9876884 0.1564343
264
+ C 3.14159 10.0000699 0.0000663 -1.0000000 -0.0000002
265
+ C 3.29867 3.0284170 4.2182053 -0.9876883 -0.1564346
266
+ C 3.45575 1.2657041 2.6260067 -0.9510565 -0.3090172
267
+ C 3.61283 0.8366878 1.8175205 -0.8910064 -0.4539907
268
+ C 3.76991 0.6764469 1.3664259 -0.8090169 -0.5877854
269
+ C 3.92699 0.6004178 1.0806000 -0.7071066 -0.7071069
270
+ C 4.08407 0.5586535 0.8823662 -0.5877851 -0.8090171
271
+ C 4.24115 0.5333535 0.7356271 -0.4539903 -0.8910066
272
+ C 4.39823 0.5169271 0.6215398 -0.3090168 -0.9510566
273
+ C 4.55531 0.5057041 0.5293523 -0.1564343 -0.9876884
274
+ C 4.71239 0.4977374 0.4524890 0.0000002 -1.0000000
275
+ C 4.86947 0.4919176 0.3866988 0.1564347 -0.9876883
276
+ C 5.02655 0.4875765 0.3291040 0.3090172 -0.9510564
277
+ C 5.18363 0.4842934 0.2776780 0.4539907 -0.8910064
278
+ C 5.34071 0.4817939 0.2309415 0.5877854 -0.8090169
279
+ C 5.49779 0.4798944 0.1877791 0.7071069 -0.7071066
280
+ C 5.65487 0.4784700 0.1473208 0.8090171 -0.5877850
281
+ C 5.81195 0.4774352 0.1088652 0.8910066 -0.4539903
282
+ C 5.96903 0.4767324 0.0718257 0.9510566 -0.3090168
283
+ C 6.12611 0.4763244 0.0356920 0.9876884 -0.1564342
284
+ C 6.28319 0.4761907 0.0000000 1.0000000 0.0000003
285
+ C
286
+ C No. steps = 542 No. f-s = 610 No. J-s = 10 No. LU-s = 47
287
+ C No. nonlinear iterations = 607
288
+ C No. nonlinear convergence failures = 0
289
+ C No. error test failures = 13
290
+ C Max. abs. error in w = 0.13E-03
291
+ C
292
+ C-----------------------------------------------------------------------
293
+ C Full description of user interface to ZVODE.
294
+ C
295
+ C The user interface to ZVODE consists of the following parts.
296
+ C
297
+ C i. The call sequence to subroutine ZVODE, which is a driver
298
+ C routine for the solver. This includes descriptions of both
299
+ C the call sequence arguments and of user-supplied routines.
300
+ C Following these descriptions is
301
+ C * a description of optional input available through the
302
+ C call sequence,
303
+ C * a description of optional output (in the work arrays), and
304
+ C * instructions for interrupting and restarting a solution.
305
+ C
306
+ C ii. Descriptions of other routines in the ZVODE package that may be
307
+ C (optionally) called by the user. These provide the ability to
308
+ C alter error message handling, save and restore the internal
309
+ C COMMON, and obtain specified derivatives of the solution y(t).
310
+ C
311
+ C iii. Descriptions of COMMON blocks to be declared in overlay
312
+ C or similar environments.
313
+ C
314
+ C iv. Description of two routines in the ZVODE package, either of
315
+ C which the user may replace with his own version, if desired.
316
+ C these relate to the measurement of errors.
317
+ C
318
+ C-----------------------------------------------------------------------
319
+ C Part i. Call Sequence.
320
+ C
321
+ C The call sequence parameters used for input only are
322
+ C F, NEQ, TOUT, ITOL, RTOL, ATOL, ITASK, IOPT, LRW, LIW, JAC, MF,
323
+ C and those used for both input and output are
324
+ C Y, T, ISTATE.
325
+ C The work arrays ZWORK, RWORK, and IWORK are also used for conditional
326
+ C and optional input and optional output. (The term output here refers
327
+ C to the return from subroutine ZVODE to the user's calling program.)
328
+ C
329
+ C The legality of input parameters will be thoroughly checked on the
330
+ C initial call for the problem, but not checked thereafter unless a
331
+ C change in input parameters is flagged by ISTATE = 3 in the input.
332
+ C
333
+ C The descriptions of the call arguments are as follows.
334
+ C
335
+ C F = The name of the user-supplied subroutine defining the
336
+ C ODE system. The system must be put in the first-order
337
+ C form dy/dt = f(t,y), where f is a vector-valued function
338
+ C of the scalar t and the vector y. Subroutine F is to
339
+ C compute the function f. It is to have the form
340
+ C SUBROUTINE F (NEQ, T, Y, YDOT, RPAR, IPAR)
341
+ C DOUBLE COMPLEX Y(NEQ), YDOT(NEQ)
342
+ C DOUBLE PRECISION T
343
+ C where NEQ, T, and Y are input, and the array YDOT = f(t,y)
344
+ C is output. Y and YDOT are double complex arrays of length
345
+ C NEQ. Subroutine F should not alter Y(1),...,Y(NEQ).
346
+ C F must be declared EXTERNAL in the calling program.
347
+ C
348
+ C Subroutine F may access user-defined real/complex and
349
+ C integer work arrays RPAR and IPAR, which are to be
350
+ C dimensioned in the calling program.
351
+ C
352
+ C If quantities computed in the F routine are needed
353
+ C externally to ZVODE, an extra call to F should be made
354
+ C for this purpose, for consistent and accurate results.
355
+ C If only the derivative dy/dt is needed, use ZVINDY instead.
356
+ C
357
+ C NEQ = The size of the ODE system (number of first order
358
+ C ordinary differential equations). Used only for input.
359
+ C NEQ may not be increased during the problem, but
360
+ C can be decreased (with ISTATE = 3 in the input).
361
+ C
362
+ C Y = A double precision complex array for the vector of dependent
363
+ C variables, of length NEQ or more. Used for both input and
364
+ C output on the first call (ISTATE = 1), and only for output
365
+ C on other calls. On the first call, Y must contain the
366
+ C vector of initial values. In the output, Y contains the
367
+ C computed solution evaluated at T. If desired, the Y array
368
+ C may be used for other purposes between calls to the solver.
369
+ C
370
+ C This array is passed as the Y argument in all calls to
371
+ C F and JAC.
372
+ C
373
+ C T = The independent variable. In the input, T is used only on
374
+ C the first call, as the initial point of the integration.
375
+ C In the output, after each call, T is the value at which a
376
+ C computed solution Y is evaluated (usually the same as TOUT).
377
+ C On an error return, T is the farthest point reached.
378
+ C
379
+ C TOUT = The next value of t at which a computed solution is desired.
380
+ C Used only for input.
381
+ C
382
+ C When starting the problem (ISTATE = 1), TOUT may be equal
383
+ C to T for one call, then should .ne. T for the next call.
384
+ C For the initial T, an input value of TOUT .ne. T is used
385
+ C in order to determine the direction of the integration
386
+ C (i.e. the algebraic sign of the step sizes) and the rough
387
+ C scale of the problem. Integration in either direction
388
+ C (forward or backward in t) is permitted.
389
+ C
390
+ C If ITASK = 2 or 5 (one-step modes), TOUT is ignored after
391
+ C the first call (i.e. the first call with TOUT .ne. T).
392
+ C Otherwise, TOUT is required on every call.
393
+ C
394
+ C If ITASK = 1, 3, or 4, the values of TOUT need not be
395
+ C monotone, but a value of TOUT which backs up is limited
396
+ C to the current internal t interval, whose endpoints are
397
+ C TCUR - HU and TCUR. (See optional output, below, for
398
+ C TCUR and HU.)
399
+ C
400
+ C ITOL = An indicator for the type of error control. See
401
+ C description below under ATOL. Used only for input.
402
+ C
403
+ C RTOL = A relative error tolerance parameter, either a scalar or
404
+ C an array of length NEQ. See description below under ATOL.
405
+ C Input only.
406
+ C
407
+ C ATOL = An absolute error tolerance parameter, either a scalar or
408
+ C an array of length NEQ. Input only.
409
+ C
410
+ C The input parameters ITOL, RTOL, and ATOL determine
411
+ C the error control performed by the solver. The solver will
412
+ C control the vector e = (e(i)) of estimated local errors
413
+ C in Y, according to an inequality of the form
414
+ C rms-norm of ( e(i)/EWT(i) ) .le. 1,
415
+ C where EWT(i) = RTOL(i)*abs(Y(i)) + ATOL(i),
416
+ C and the rms-norm (root-mean-square norm) here is
417
+ C rms-norm(v) = sqrt(sum v(i)**2 / NEQ). Here EWT = (EWT(i))
418
+ C is a vector of weights which must always be positive, and
419
+ C the values of RTOL and ATOL should all be non-negative.
420
+ C The following table gives the types (scalar/array) of
421
+ C RTOL and ATOL, and the corresponding form of EWT(i).
422
+ C
423
+ C ITOL RTOL ATOL EWT(i)
424
+ C 1 scalar scalar RTOL*ABS(Y(i)) + ATOL
425
+ C 2 scalar array RTOL*ABS(Y(i)) + ATOL(i)
426
+ C 3 array scalar RTOL(i)*ABS(Y(i)) + ATOL
427
+ C 4 array array RTOL(i)*ABS(Y(i)) + ATOL(i)
428
+ C
429
+ C When either of these parameters is a scalar, it need not
430
+ C be dimensioned in the user's calling program.
431
+ C
432
+ C If none of the above choices (with ITOL, RTOL, and ATOL
433
+ C fixed throughout the problem) is suitable, more general
434
+ C error controls can be obtained by substituting
435
+ C user-supplied routines for the setting of EWT and/or for
436
+ C the norm calculation. See Part iv below.
437
+ C
438
+ C If global errors are to be estimated by making a repeated
439
+ C run on the same problem with smaller tolerances, then all
440
+ C components of RTOL and ATOL (i.e. of EWT) should be scaled
441
+ C down uniformly.
442
+ C
443
+ C ITASK = An index specifying the task to be performed.
444
+ C Input only. ITASK has the following values and meanings.
445
+ C 1 means normal computation of output values of y(t) at
446
+ C t = TOUT (by overshooting and interpolating).
447
+ C 2 means take one step only and return.
448
+ C 3 means stop at the first internal mesh point at or
449
+ C beyond t = TOUT and return.
450
+ C 4 means normal computation of output values of y(t) at
451
+ C t = TOUT but without overshooting t = TCRIT.
452
+ C TCRIT must be input as RWORK(1). TCRIT may be equal to
453
+ C or beyond TOUT, but not behind it in the direction of
454
+ C integration. This option is useful if the problem
455
+ C has a singularity at or beyond t = TCRIT.
456
+ C 5 means take one step, without passing TCRIT, and return.
457
+ C TCRIT must be input as RWORK(1).
458
+ C
459
+ C Note: If ITASK = 4 or 5 and the solver reaches TCRIT
460
+ C (within roundoff), it will return T = TCRIT (exactly) to
461
+ C indicate this (unless ITASK = 4 and TOUT comes before TCRIT,
462
+ C in which case answers at T = TOUT are returned first).
463
+ C
464
+ C ISTATE = an index used for input and output to specify the
465
+ C the state of the calculation.
466
+ C
467
+ C In the input, the values of ISTATE are as follows.
468
+ C 1 means this is the first call for the problem
469
+ C (initializations will be done). See note below.
470
+ C 2 means this is not the first call, and the calculation
471
+ C is to continue normally, with no change in any input
472
+ C parameters except possibly TOUT and ITASK.
473
+ C (If ITOL, RTOL, and/or ATOL are changed between calls
474
+ C with ISTATE = 2, the new values will be used but not
475
+ C tested for legality.)
476
+ C 3 means this is not the first call, and the
477
+ C calculation is to continue normally, but with
478
+ C a change in input parameters other than
479
+ C TOUT and ITASK. Changes are allowed in
480
+ C NEQ, ITOL, RTOL, ATOL, IOPT, LRW, LIW, MF, ML, MU,
481
+ C and any of the optional input except H0.
482
+ C (See IWORK description for ML and MU.)
483
+ C Note: A preliminary call with TOUT = T is not counted
484
+ C as a first call here, as no initialization or checking of
485
+ C input is done. (Such a call is sometimes useful to include
486
+ C the initial conditions in the output.)
487
+ C Thus the first call for which TOUT .ne. T requires
488
+ C ISTATE = 1 in the input.
489
+ C
490
+ C In the output, ISTATE has the following values and meanings.
491
+ C 1 means nothing was done, as TOUT was equal to T with
492
+ C ISTATE = 1 in the input.
493
+ C 2 means the integration was performed successfully.
494
+ C -1 means an excessive amount of work (more than MXSTEP
495
+ C steps) was done on this call, before completing the
496
+ C requested task, but the integration was otherwise
497
+ C successful as far as T. (MXSTEP is an optional input
498
+ C and is normally 500.) To continue, the user may
499
+ C simply reset ISTATE to a value .gt. 1 and call again.
500
+ C (The excess work step counter will be reset to 0.)
501
+ C In addition, the user may increase MXSTEP to avoid
502
+ C this error return. (See optional input below.)
503
+ C -2 means too much accuracy was requested for the precision
504
+ C of the machine being used. This was detected before
505
+ C completing the requested task, but the integration
506
+ C was successful as far as T. To continue, the tolerance
507
+ C parameters must be reset, and ISTATE must be set
508
+ C to 3. The optional output TOLSF may be used for this
509
+ C purpose. (Note: If this condition is detected before
510
+ C taking any steps, then an illegal input return
511
+ C (ISTATE = -3) occurs instead.)
512
+ C -3 means illegal input was detected, before taking any
513
+ C integration steps. See written message for details.
514
+ C Note: If the solver detects an infinite loop of calls
515
+ C to the solver with illegal input, it will cause
516
+ C the run to stop.
517
+ C -4 means there were repeated error test failures on
518
+ C one attempted step, before completing the requested
519
+ C task, but the integration was successful as far as T.
520
+ C The problem may have a singularity, or the input
521
+ C may be inappropriate.
522
+ C -5 means there were repeated convergence test failures on
523
+ C one attempted step, before completing the requested
524
+ C task, but the integration was successful as far as T.
525
+ C This may be caused by an inaccurate Jacobian matrix,
526
+ C if one is being used.
527
+ C -6 means EWT(i) became zero for some i during the
528
+ C integration. Pure relative error control (ATOL(i)=0.0)
529
+ C was requested on a variable which has now vanished.
530
+ C The integration was successful as far as T.
531
+ C
532
+ C Note: Since the normal output value of ISTATE is 2,
533
+ C it does not need to be reset for normal continuation.
534
+ C Also, since a negative input value of ISTATE will be
535
+ C regarded as illegal, a negative output value requires the
536
+ C user to change it, and possibly other input, before
537
+ C calling the solver again.
538
+ C
539
+ C IOPT = An integer flag to specify whether or not any optional
540
+ C input is being used on this call. Input only.
541
+ C The optional input is listed separately below.
542
+ C IOPT = 0 means no optional input is being used.
543
+ C Default values will be used in all cases.
544
+ C IOPT = 1 means optional input is being used.
545
+ C
546
+ C ZWORK = A double precision complex working array.
547
+ C The length of ZWORK must be at least
548
+ C NYH*(MAXORD + 1) + 2*NEQ + LWM where
549
+ C NYH = the initial value of NEQ,
550
+ C MAXORD = 12 (if METH = 1) or 5 (if METH = 2) (unless a
551
+ C smaller value is given as an optional input),
552
+ C LWM = length of work space for matrix-related data:
553
+ C LWM = 0 if MITER = 0,
554
+ C LWM = 2*NEQ**2 if MITER = 1 or 2, and MF.gt.0,
555
+ C LWM = NEQ**2 if MITER = 1 or 2, and MF.lt.0,
556
+ C LWM = NEQ if MITER = 3,
557
+ C LWM = (3*ML+2*MU+2)*NEQ if MITER = 4 or 5, and MF.gt.0,
558
+ C LWM = (2*ML+MU+1)*NEQ if MITER = 4 or 5, and MF.lt.0.
559
+ C (See the MF description for METH and MITER.)
560
+ C Thus if MAXORD has its default value and NEQ is constant,
561
+ C this length is:
562
+ C 15*NEQ for MF = 10,
563
+ C 15*NEQ + 2*NEQ**2 for MF = 11 or 12,
564
+ C 15*NEQ + NEQ**2 for MF = -11 or -12,
565
+ C 16*NEQ for MF = 13,
566
+ C 17*NEQ + (3*ML+2*MU)*NEQ for MF = 14 or 15,
567
+ C 16*NEQ + (2*ML+MU)*NEQ for MF = -14 or -15,
568
+ C 8*NEQ for MF = 20,
569
+ C 8*NEQ + 2*NEQ**2 for MF = 21 or 22,
570
+ C 8*NEQ + NEQ**2 for MF = -21 or -22,
571
+ C 9*NEQ for MF = 23,
572
+ C 10*NEQ + (3*ML+2*MU)*NEQ for MF = 24 or 25.
573
+ C 9*NEQ + (2*ML+MU)*NEQ for MF = -24 or -25.
574
+ C
575
+ C LZW = The length of the array ZWORK, as declared by the user.
576
+ C (This will be checked by the solver.)
577
+ C
578
+ C RWORK = A real working array (double precision).
579
+ C The length of RWORK must be at least 20 + NEQ.
580
+ C The first 20 words of RWORK are reserved for conditional
581
+ C and optional input and optional output.
582
+ C
583
+ C The following word in RWORK is a conditional input:
584
+ C RWORK(1) = TCRIT = critical value of t which the solver
585
+ C is not to overshoot. Required if ITASK is
586
+ C 4 or 5, and ignored otherwise. (See ITASK.)
587
+ C
588
+ C LRW = The length of the array RWORK, as declared by the user.
589
+ C (This will be checked by the solver.)
590
+ C
591
+ C IWORK = An integer work array. The length of IWORK must be at least
592
+ C 30 if MITER = 0 or 3 (MF = 10, 13, 20, 23), or
593
+ C 30 + NEQ otherwise (abs(MF) = 11,12,14,15,21,22,24,25).
594
+ C The first 30 words of IWORK are reserved for conditional and
595
+ C optional input and optional output.
596
+ C
597
+ C The following 2 words in IWORK are conditional input:
598
+ C IWORK(1) = ML These are the lower and upper
599
+ C IWORK(2) = MU half-bandwidths, respectively, of the
600
+ C banded Jacobian, excluding the main diagonal.
601
+ C The band is defined by the matrix locations
602
+ C (i,j) with i-ML .le. j .le. i+MU. ML and MU
603
+ C must satisfy 0 .le. ML,MU .le. NEQ-1.
604
+ C These are required if MITER is 4 or 5, and
605
+ C ignored otherwise. ML and MU may in fact be
606
+ C the band parameters for a matrix to which
607
+ C df/dy is only approximately equal.
608
+ C
609
+ C LIW = the length of the array IWORK, as declared by the user.
610
+ C (This will be checked by the solver.)
611
+ C
612
+ C Note: The work arrays must not be altered between calls to ZVODE
613
+ C for the same problem, except possibly for the conditional and
614
+ C optional input, and except for the last 2*NEQ words of ZWORK and
615
+ C the last NEQ words of RWORK. The latter space is used for internal
616
+ C scratch space, and so is available for use by the user outside ZVODE
617
+ C between calls, if desired (but not for use by F or JAC).
618
+ C
619
+ C JAC = The name of the user-supplied routine (MITER = 1 or 4) to
620
+ C compute the Jacobian matrix, df/dy, as a function of
621
+ C the scalar t and the vector y. It is to have the form
622
+ C SUBROUTINE JAC (NEQ, T, Y, ML, MU, PD, NROWPD,
623
+ C RPAR, IPAR)
624
+ C DOUBLE COMPLEX Y(NEQ), PD(NROWPD,NEQ)
625
+ C DOUBLE PRECISION T
626
+ C where NEQ, T, Y, ML, MU, and NROWPD are input and the array
627
+ C PD is to be loaded with partial derivatives (elements of the
628
+ C Jacobian matrix) in the output. PD must be given a first
629
+ C dimension of NROWPD. T and Y have the same meaning as in
630
+ C Subroutine F.
631
+ C In the full matrix case (MITER = 1), ML and MU are
632
+ C ignored, and the Jacobian is to be loaded into PD in
633
+ C columnwise manner, with df(i)/dy(j) loaded into PD(i,j).
634
+ C In the band matrix case (MITER = 4), the elements
635
+ C within the band are to be loaded into PD in columnwise
636
+ C manner, with diagonal lines of df/dy loaded into the rows
637
+ C of PD. Thus df(i)/dy(j) is to be loaded into PD(i-j+MU+1,j).
638
+ C ML and MU are the half-bandwidth parameters. (See IWORK).
639
+ C The locations in PD in the two triangular areas which
640
+ C correspond to nonexistent matrix elements can be ignored
641
+ C or loaded arbitrarily, as they are overwritten by ZVODE.
642
+ C JAC need not provide df/dy exactly. A crude
643
+ C approximation (possibly with a smaller bandwidth) will do.
644
+ C In either case, PD is preset to zero by the solver,
645
+ C so that only the nonzero elements need be loaded by JAC.
646
+ C Each call to JAC is preceded by a call to F with the same
647
+ C arguments NEQ, T, and Y. Thus to gain some efficiency,
648
+ C intermediate quantities shared by both calculations may be
649
+ C saved in a user COMMON block by F and not recomputed by JAC,
650
+ C if desired. Also, JAC may alter the Y array, if desired.
651
+ C JAC must be declared external in the calling program.
652
+ C Subroutine JAC may access user-defined real/complex and
653
+ C integer work arrays, RPAR and IPAR, whose dimensions are set
654
+ C by the user in the calling program.
655
+ C
656
+ C MF = The method flag. Used only for input. The legal values of
657
+ C MF are 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25,
658
+ C -11, -12, -14, -15, -21, -22, -24, -25.
659
+ C MF is a signed two-digit integer, MF = JSV*(10*METH + MITER).
660
+ C JSV = SIGN(MF) indicates the Jacobian-saving strategy:
661
+ C JSV = 1 means a copy of the Jacobian is saved for reuse
662
+ C in the corrector iteration algorithm.
663
+ C JSV = -1 means a copy of the Jacobian is not saved
664
+ C (valid only for MITER = 1, 2, 4, or 5).
665
+ C METH indicates the basic linear multistep method:
666
+ C METH = 1 means the implicit Adams method.
667
+ C METH = 2 means the method based on backward
668
+ C differentiation formulas (BDF-s).
669
+ C MITER indicates the corrector iteration method:
670
+ C MITER = 0 means functional iteration (no Jacobian matrix
671
+ C is involved).
672
+ C MITER = 1 means chord iteration with a user-supplied
673
+ C full (NEQ by NEQ) Jacobian.
674
+ C MITER = 2 means chord iteration with an internally
675
+ C generated (difference quotient) full Jacobian
676
+ C (using NEQ extra calls to F per df/dy value).
677
+ C MITER = 3 means chord iteration with an internally
678
+ C generated diagonal Jacobian approximation
679
+ C (using 1 extra call to F per df/dy evaluation).
680
+ C MITER = 4 means chord iteration with a user-supplied
681
+ C banded Jacobian.
682
+ C MITER = 5 means chord iteration with an internally
683
+ C generated banded Jacobian (using ML+MU+1 extra
684
+ C calls to F per df/dy evaluation).
685
+ C If MITER = 1 or 4, the user must supply a subroutine JAC
686
+ C (the name is arbitrary) as described above under JAC.
687
+ C For other values of MITER, a dummy argument can be used.
688
+ C
689
+ C RPAR User-specified array used to communicate real or complex
690
+ C parameters to user-supplied subroutines. If RPAR is an
691
+ C array, it must be dimensioned in the user's calling program;
692
+ C if it is unused or it is a scalar, then it need not be
693
+ C dimensioned. The type of RPAR may be REAL, DOUBLE, COMPLEX,
694
+ C or DOUBLE COMPLEX, depending on the user program's needs.
695
+ C RPAR is not type-declared within ZVODE, but simply passed
696
+ C (by address) to the user's F and JAC routines.
697
+ C
698
+ C IPAR User-specified array used to communicate integer parameter
699
+ C to user-supplied subroutines. If IPAR is an array, it must
700
+ C be dimensioned in the user's calling program.
701
+ C-----------------------------------------------------------------------
702
+ C Optional Input.
703
+ C
704
+ C The following is a list of the optional input provided for in the
705
+ C call sequence. (See also Part ii.) For each such input variable,
706
+ C this table lists its name as used in this documentation, its
707
+ C location in the call sequence, its meaning, and the default value.
708
+ C The use of any of this input requires IOPT = 1, and in that
709
+ C case all of this input is examined. A value of zero for any
710
+ C of these optional input variables will cause the default value to be
711
+ C used. Thus to use a subset of the optional input, simply preload
712
+ C locations 5 to 10 in RWORK and IWORK to 0.0 and 0 respectively, and
713
+ C then set those of interest to nonzero values.
714
+ C
715
+ C NAME LOCATION MEANING AND DEFAULT VALUE
716
+ C
717
+ C H0 RWORK(5) The step size to be attempted on the first step.
718
+ C The default value is determined by the solver.
719
+ C
720
+ C HMAX RWORK(6) The maximum absolute step size allowed.
721
+ C The default value is infinite.
722
+ C
723
+ C HMIN RWORK(7) The minimum absolute step size allowed.
724
+ C The default value is 0. (This lower bound is not
725
+ C enforced on the final step before reaching TCRIT
726
+ C when ITASK = 4 or 5.)
727
+ C
728
+ C MAXORD IWORK(5) The maximum order to be allowed. The default
729
+ C value is 12 if METH = 1, and 5 if METH = 2.
730
+ C If MAXORD exceeds the default value, it will
731
+ C be reduced to the default value.
732
+ C If MAXORD is changed during the problem, it may
733
+ C cause the current order to be reduced.
734
+ C
735
+ C MXSTEP IWORK(6) Maximum number of (internally defined) steps
736
+ C allowed during one call to the solver.
737
+ C The default value is 500.
738
+ C
739
+ C MXHNIL IWORK(7) Maximum number of messages printed (per problem)
740
+ C warning that T + H = T on a step (H = step size).
741
+ C This must be positive to result in a non-default
742
+ C value. The default value is 10.
743
+ C
744
+ C-----------------------------------------------------------------------
745
+ C Optional Output.
746
+ C
747
+ C As optional additional output from ZVODE, the variables listed
748
+ C below are quantities related to the performance of ZVODE
749
+ C which are available to the user. These are communicated by way of
750
+ C the work arrays, but also have internal mnemonic names as shown.
751
+ C Except where stated otherwise, all of this output is defined
752
+ C on any successful return from ZVODE, and on any return with
753
+ C ISTATE = -1, -2, -4, -5, or -6. On an illegal input return
754
+ C (ISTATE = -3), they will be unchanged from their existing values
755
+ C (if any), except possibly for TOLSF, LENZW, LENRW, and LENIW.
756
+ C On any error return, output relevant to the error will be defined,
757
+ C as noted below.
758
+ C
759
+ C NAME LOCATION MEANING
760
+ C
761
+ C HU RWORK(11) The step size in t last used (successfully).
762
+ C
763
+ C HCUR RWORK(12) The step size to be attempted on the next step.
764
+ C
765
+ C TCUR RWORK(13) The current value of the independent variable
766
+ C which the solver has actually reached, i.e. the
767
+ C current internal mesh point in t. In the output,
768
+ C TCUR will always be at least as far from the
769
+ C initial value of t as the current argument T,
770
+ C but may be farther (if interpolation was done).
771
+ C
772
+ C TOLSF RWORK(14) A tolerance scale factor, greater than 1.0,
773
+ C computed when a request for too much accuracy was
774
+ C detected (ISTATE = -3 if detected at the start of
775
+ C the problem, ISTATE = -2 otherwise). If ITOL is
776
+ C left unaltered but RTOL and ATOL are uniformly
777
+ C scaled up by a factor of TOLSF for the next call,
778
+ C then the solver is deemed likely to succeed.
779
+ C (The user may also ignore TOLSF and alter the
780
+ C tolerance parameters in any other way appropriate.)
781
+ C
782
+ C NST IWORK(11) The number of steps taken for the problem so far.
783
+ C
784
+ C NFE IWORK(12) The number of f evaluations for the problem so far.
785
+ C
786
+ C NJE IWORK(13) The number of Jacobian evaluations so far.
787
+ C
788
+ C NQU IWORK(14) The method order last used (successfully).
789
+ C
790
+ C NQCUR IWORK(15) The order to be attempted on the next step.
791
+ C
792
+ C IMXER IWORK(16) The index of the component of largest magnitude in
793
+ C the weighted local error vector ( e(i)/EWT(i) ),
794
+ C on an error return with ISTATE = -4 or -5.
795
+ C
796
+ C LENZW IWORK(17) The length of ZWORK actually required.
797
+ C This is defined on normal returns and on an illegal
798
+ C input return for insufficient storage.
799
+ C
800
+ C LENRW IWORK(18) The length of RWORK actually required.
801
+ C This is defined on normal returns and on an illegal
802
+ C input return for insufficient storage.
803
+ C
804
+ C LENIW IWORK(19) The length of IWORK actually required.
805
+ C This is defined on normal returns and on an illegal
806
+ C input return for insufficient storage.
807
+ C
808
+ C NLU IWORK(20) The number of matrix LU decompositions so far.
809
+ C
810
+ C NNI IWORK(21) The number of nonlinear (Newton) iterations so far.
811
+ C
812
+ C NCFN IWORK(22) The number of convergence failures of the nonlinear
813
+ C solver so far.
814
+ C
815
+ C NETF IWORK(23) The number of error test failures of the integrator
816
+ C so far.
817
+ C
818
+ C The following two arrays are segments of the ZWORK array which
819
+ C may also be of interest to the user as optional output.
820
+ C For each array, the table below gives its internal name,
821
+ C its base address in ZWORK, and its description.
822
+ C
823
+ C NAME BASE ADDRESS DESCRIPTION
824
+ C
825
+ C YH 1 The Nordsieck history array, of size NYH by
826
+ C (NQCUR + 1), where NYH is the initial value
827
+ C of NEQ. For j = 0,1,...,NQCUR, column j+1
828
+ C of YH contains HCUR**j/factorial(j) times
829
+ C the j-th derivative of the interpolating
830
+ C polynomial currently representing the
831
+ C solution, evaluated at t = TCUR.
832
+ C
833
+ C ACOR LENZW-NEQ+1 Array of size NEQ used for the accumulated
834
+ C corrections on each step, scaled in the output
835
+ C to represent the estimated local error in Y
836
+ C on the last step. This is the vector e in
837
+ C the description of the error control. It is
838
+ C defined only on a successful return from ZVODE.
839
+ C
840
+ C-----------------------------------------------------------------------
841
+ C Interrupting and Restarting
842
+ C
843
+ C If the integration of a given problem by ZVODE is to be
844
+ C interrrupted and then later continued, such as when restarting
845
+ C an interrupted run or alternating between two or more ODE problems,
846
+ C the user should save, following the return from the last ZVODE call
847
+ C prior to the interruption, the contents of the call sequence
848
+ C variables and internal COMMON blocks, and later restore these
849
+ C values before the next ZVODE call for that problem. To save
850
+ C and restore the COMMON blocks, use subroutine ZVSRCO, as
851
+ C described below in part ii.
852
+ C
853
+ C In addition, if non-default values for either LUN or MFLAG are
854
+ C desired, an extra call to XSETUN and/or XSETF should be made just
855
+ C before continuing the integration. See Part ii below for details.
856
+ C
857
+ C-----------------------------------------------------------------------
858
+ C Part ii. Other Routines Callable.
859
+ C
860
+ C The following are optional calls which the user may make to
861
+ C gain additional capabilities in conjunction with ZVODE.
862
+ C (The routines XSETUN and XSETF are designed to conform to the
863
+ C SLATEC error handling package.)
864
+ C
865
+ C FORM OF CALL FUNCTION
866
+ C CALL XSETUN(LUN) Set the logical unit number, LUN, for
867
+ C output of messages from ZVODE, if
868
+ C the default is not desired.
869
+ C The default value of LUN is 6.
870
+ C
871
+ C CALL XSETF(MFLAG) Set a flag to control the printing of
872
+ C messages by ZVODE.
873
+ C MFLAG = 0 means do not print. (Danger:
874
+ C This risks losing valuable information.)
875
+ C MFLAG = 1 means print (the default).
876
+ C
877
+ C Either of the above calls may be made at
878
+ C any time and will take effect immediately.
879
+ C
880
+ C CALL ZVSRCO(RSAV,ISAV,JOB) Saves and restores the contents of
881
+ C the internal COMMON blocks used by
882
+ C ZVODE. (See Part iii below.)
883
+ C RSAV must be a real array of length 51
884
+ C or more, and ISAV must be an integer
885
+ C array of length 40 or more.
886
+ C JOB=1 means save COMMON into RSAV/ISAV.
887
+ C JOB=2 means restore COMMON from RSAV/ISAV.
888
+ C ZVSRCO is useful if one is
889
+ C interrupting a run and restarting
890
+ C later, or alternating between two or
891
+ C more problems solved with ZVODE.
892
+ C
893
+ C CALL ZVINDY(,,,,,) Provide derivatives of y, of various
894
+ C (See below.) orders, at a specified point T, if
895
+ C desired. It may be called only after
896
+ C a successful return from ZVODE.
897
+ C
898
+ C The detailed instructions for using ZVINDY are as follows.
899
+ C The form of the call is:
900
+ C
901
+ C CALL ZVINDY (T, K, ZWORK, NYH, DKY, IFLAG)
902
+ C
903
+ C The input parameters are:
904
+ C
905
+ C T = Value of independent variable where answers are desired
906
+ C (normally the same as the T last returned by ZVODE).
907
+ C For valid results, T must lie between TCUR - HU and TCUR.
908
+ C (See optional output for TCUR and HU.)
909
+ C K = Integer order of the derivative desired. K must satisfy
910
+ C 0 .le. K .le. NQCUR, where NQCUR is the current order
911
+ C (see optional output). The capability corresponding
912
+ C to K = 0, i.e. computing y(T), is already provided
913
+ C by ZVODE directly. Since NQCUR .ge. 1, the first
914
+ C derivative dy/dt is always available with ZVINDY.
915
+ C ZWORK = The history array YH.
916
+ C NYH = Column length of YH, equal to the initial value of NEQ.
917
+ C
918
+ C The output parameters are:
919
+ C
920
+ C DKY = A double complex array of length NEQ containing the
921
+ C computed value of the K-th derivative of y(t).
922
+ C IFLAG = Integer flag, returned as 0 if K and T were legal,
923
+ C -1 if K was illegal, and -2 if T was illegal.
924
+ C On an error return, a message is also written.
925
+ C-----------------------------------------------------------------------
926
+ C Part iii. COMMON Blocks.
927
+ C If ZVODE is to be used in an overlay situation, the user
928
+ C must declare, in the primary overlay, the variables in:
929
+ C (1) the call sequence to ZVODE,
930
+ C (2) the two internal COMMON blocks
931
+ C /ZVOD01/ of length 83 (50 double precision words
932
+ C followed by 33 integer words),
933
+ C /ZVOD02/ of length 9 (1 double precision word
934
+ C followed by 8 integer words),
935
+ C
936
+ C If ZVODE is used on a system in which the contents of internal
937
+ C COMMON blocks are not preserved between calls, the user should
938
+ C declare the above two COMMON blocks in his calling program to insure
939
+ C that their contents are preserved.
940
+ C
941
+ C-----------------------------------------------------------------------
942
+ C Part iv. Optionally Replaceable Solver Routines.
943
+ C
944
+ C Below are descriptions of two routines in the ZVODE package which
945
+ C relate to the measurement of errors. Either routine can be
946
+ C replaced by a user-supplied version, if desired. However, since such
947
+ C a replacement may have a major impact on performance, it should be
948
+ C done only when absolutely necessary, and only with great caution.
949
+ C (Note: The means by which the package version of a routine is
950
+ C superseded by the user's version may be system-dependent.)
951
+ C
952
+ C (a) ZEWSET.
953
+ C The following subroutine is called just before each internal
954
+ C integration step, and sets the array of error weights, EWT, as
955
+ C described under ITOL/RTOL/ATOL above:
956
+ C SUBROUTINE ZEWSET (NEQ, ITOL, RTOL, ATOL, YCUR, EWT)
957
+ C where NEQ, ITOL, RTOL, and ATOL are as in the ZVODE call sequence,
958
+ C YCUR contains the current (double complex) dependent variable vector,
959
+ C and EWT is the array of weights set by ZEWSET.
960
+ C
961
+ C If the user supplies this subroutine, it must return in EWT(i)
962
+ C (i = 1,...,NEQ) a positive quantity suitable for comparison with
963
+ C errors in Y(i). The EWT array returned by ZEWSET is passed to the
964
+ C ZVNORM routine (See below.), and also used by ZVODE in the computation
965
+ C of the optional output IMXER, the diagonal Jacobian approximation,
966
+ C and the increments for difference quotient Jacobians.
967
+ C
968
+ C In the user-supplied version of ZEWSET, it may be desirable to use
969
+ C the current values of derivatives of y. Derivatives up to order NQ
970
+ C are available from the history array YH, described above under
971
+ C Optional Output. In ZEWSET, YH is identical to the YCUR array,
972
+ C extended to NQ + 1 columns with a column length of NYH and scale
973
+ C factors of h**j/factorial(j). On the first call for the problem,
974
+ C given by NST = 0, NQ is 1 and H is temporarily set to 1.0.
975
+ C NYH is the initial value of NEQ. The quantities NQ, H, and NST
976
+ C can be obtained by including in ZEWSET the statements:
977
+ C DOUBLE PRECISION RVOD, H, HU
978
+ C COMMON /ZVOD01/ RVOD(50), IVOD(33)
979
+ C COMMON /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
980
+ C NQ = IVOD(28)
981
+ C H = RVOD(21)
982
+ C Thus, for example, the current value of dy/dt can be obtained as
983
+ C YCUR(NYH+i)/H (i=1,...,NEQ) (and the division by H is
984
+ C unnecessary when NST = 0).
985
+ C
986
+ C (b) ZVNORM.
987
+ C The following is a real function routine which computes the weighted
988
+ C root-mean-square norm of a vector v:
989
+ C D = ZVNORM (N, V, W)
990
+ C where:
991
+ C N = the length of the vector,
992
+ C V = double complex array of length N containing the vector,
993
+ C W = real array of length N containing weights,
994
+ C D = sqrt( (1/N) * sum(abs(V(i))*W(i))**2 ).
995
+ C ZVNORM is called with N = NEQ and with W(i) = 1.0/EWT(i), where
996
+ C EWT is as set by subroutine ZEWSET.
997
+ C
998
+ C If the user supplies this function, it should return a non-negative
999
+ C value of ZVNORM suitable for use in the error control in ZVODE.
1000
+ C None of the arguments should be altered by ZVNORM.
1001
+ C For example, a user-supplied ZVNORM routine might:
1002
+ C -substitute a max-norm of (V(i)*W(i)) for the rms-norm, or
1003
+ C -ignore some components of V in the norm, with the effect of
1004
+ C suppressing the error control on those components of Y.
1005
+ C-----------------------------------------------------------------------
1006
+ C REVISION HISTORY (YYYYMMDD)
1007
+ C 20060517 DATE WRITTEN, modified from DVODE of 20020430.
1008
+ C 20061227 Added note on use for analytic f.
1009
+ C-----------------------------------------------------------------------
1010
+ C Other Routines in the ZVODE Package.
1011
+ C
1012
+ C In addition to Subroutine ZVODE, the ZVODE package includes the
1013
+ C following subroutines and function routines:
1014
+ C ZVHIN computes an approximate step size for the initial step.
1015
+ C ZVINDY computes an interpolated value of the y vector at t = TOUT.
1016
+ C ZVSTEP is the core integrator, which does one step of the
1017
+ C integration and the associated error control.
1018
+ C ZVSET sets all method coefficients and test constants.
1019
+ C ZVNLSD solves the underlying nonlinear system -- the corrector.
1020
+ C ZVJAC computes and preprocesses the Jacobian matrix J = df/dy
1021
+ C and the Newton iteration matrix P = I - (h/l1)*J.
1022
+ C ZVSOL manages solution of linear system in chord iteration.
1023
+ C ZVJUST adjusts the history array on a change of order.
1024
+ C ZEWSET sets the error weight vector EWT before each step.
1025
+ C ZVNORM computes the weighted r.m.s. norm of a vector.
1026
+ C ZABSSQ computes the squared absolute value of a double complex z.
1027
+ C ZVSRCO is a user-callable routine to save and restore
1028
+ C the contents of the internal COMMON blocks.
1029
+ C ZACOPY is a routine to copy one two-dimensional array to another.
1030
+ C ZGETRF and ZGETRS are routines from LAPACK for solving full
1031
+ C systems of linear algebraic equations.
1032
+ C ZGBTRF and ZGBTRS are routines from LAPACK for solving banded
1033
+ C linear systems.
1034
+ C DZSCAL scales a double complex array by a double prec. scalar.
1035
+ C DZAXPY adds a D.P. scalar times one complex vector to another.
1036
+ C ZCOPY is a basic linear algebra module from the BLAS.
1037
+ C DUMACH sets the unit roundoff of the machine.
1038
+ C XERRWD, XSETUN, XSETF, IXSAV, and IUMACH handle the printing of all
1039
+ C error messages and warnings. XERRWD is machine-dependent.
1040
+ C Note: ZVNORM, ZABSSQ, DUMACH, IXSAV, and IUMACH are function routines.
1041
+ C All the others are subroutines.
1042
+ C The intrinsic functions called with double precision complex arguments
1043
+ C are: ABS, DREAL, and DIMAG. All of these are expected to return
1044
+ C double precision real values.
1045
+ C
1046
+ C-----------------------------------------------------------------------
1047
+ C
1048
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
1049
+ C
1050
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
1051
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
1052
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
1053
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
1054
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
1055
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
1056
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
1057
+ 4 NSLP, NYH
1058
+ C
1059
+ C Type declarations for labeled COMMON block ZVOD02 --------------------
1060
+ C
1061
+ DOUBLE PRECISION HU
1062
+ INTEGER NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
1063
+ C
1064
+ C Type declarations for local variables --------------------------------
1065
+ C
1066
+ EXTERNAL ZVNLSD
1067
+ LOGICAL IHIT
1068
+ DOUBLE PRECISION ATOLI, BIG, EWTI, FOUR, H0, HMAX, HMX, HUN, ONE,
1069
+ 1 PT2, RH, RTOLI, SIZE, TCRIT, TNEXT, TOLSF, TP, TWO, ZERO
1070
+ INTEGER I, IER, IFLAG, IMXER, JCO, KGO, LENIW, LENJ, LENP, LENZW,
1071
+ 1 LENRW, LENWM, LF0, MBAND, MFA, ML, MORD, MU, MXHNL0, MXSTP0,
1072
+ 2 NITER, NSLAST
1073
+ CHARACTER*80 MSG
1074
+ C
1075
+ C Type declaration for function subroutines called ---------------------
1076
+ C
1077
+ DOUBLE PRECISION DUMACH, ZVNORM
1078
+ C
1079
+ DIMENSION MORD(2)
1080
+ C-----------------------------------------------------------------------
1081
+ C The following Fortran-77 declaration is to cause the values of the
1082
+ C listed (local) variables to be saved between calls to ZVODE.
1083
+ C-----------------------------------------------------------------------
1084
+ SAVE MORD, MXHNL0, MXSTP0
1085
+ SAVE ZERO, ONE, TWO, FOUR, PT2, HUN
1086
+ C-----------------------------------------------------------------------
1087
+ C The following internal COMMON blocks contain variables which are
1088
+ C communicated between subroutines in the ZVODE package, or which are
1089
+ C to be saved between calls to ZVODE.
1090
+ C In each block, real variables precede integers.
1091
+ C The block /ZVOD01/ appears in subroutines ZVODE, ZVINDY, ZVSTEP,
1092
+ C ZVSET, ZVNLSD, ZVJAC, ZVSOL, ZVJUST and ZVSRCO.
1093
+ C The block /ZVOD02/ appears in subroutines ZVODE, ZVINDY, ZVSTEP,
1094
+ C ZVNLSD, ZVJAC, and ZVSRCO.
1095
+ C
1096
+ C The variables stored in the internal COMMON blocks are as follows:
1097
+ C
1098
+ C ACNRM = Weighted r.m.s. norm of accumulated correction vectors.
1099
+ C CCMXJ = Threshhold on DRC for updating the Jacobian. (See DRC.)
1100
+ C CONP = The saved value of TQ(5).
1101
+ C CRATE = Estimated corrector convergence rate constant.
1102
+ C DRC = Relative change in H*RL1 since last ZVJAC call.
1103
+ C EL = Real array of integration coefficients. See ZVSET.
1104
+ C ETA = Saved tentative ratio of new to old H.
1105
+ C ETAMAX = Saved maximum value of ETA to be allowed.
1106
+ C H = The step size.
1107
+ C HMIN = The minimum absolute value of the step size H to be used.
1108
+ C HMXI = Inverse of the maximum absolute value of H to be used.
1109
+ C HMXI = 0.0 is allowed and corresponds to an infinite HMAX.
1110
+ C HNEW = The step size to be attempted on the next step.
1111
+ C HRL1 = Saved value of H*RL1.
1112
+ C HSCAL = Stepsize in scaling of YH array.
1113
+ C PRL1 = The saved value of RL1.
1114
+ C RC = Ratio of current H*RL1 to value on last ZVJAC call.
1115
+ C RL1 = The reciprocal of the coefficient EL(1).
1116
+ C SRUR = Sqrt(UROUND), used in difference quotient algorithms.
1117
+ C TAU = Real vector of past NQ step sizes, length 13.
1118
+ C TQ = A real vector of length 5 in which ZVSET stores constants
1119
+ C used for the convergence test, the error test, and the
1120
+ C selection of H at a new order.
1121
+ C TN = The independent variable, updated on each step taken.
1122
+ C UROUND = The machine unit roundoff. The smallest positive real number
1123
+ C such that 1.0 + UROUND .ne. 1.0
1124
+ C ICF = Integer flag for convergence failure in ZVNLSD:
1125
+ C 0 means no failures.
1126
+ C 1 means convergence failure with out of date Jacobian
1127
+ C (recoverable error).
1128
+ C 2 means convergence failure with current Jacobian or
1129
+ C singular matrix (unrecoverable error).
1130
+ C INIT = Saved integer flag indicating whether initialization of the
1131
+ C problem has been done (INIT = 1) or not.
1132
+ C IPUP = Saved flag to signal updating of Newton matrix.
1133
+ C JCUR = Output flag from ZVJAC showing Jacobian status:
1134
+ C JCUR = 0 means J is not current.
1135
+ C JCUR = 1 means J is current.
1136
+ C JSTART = Integer flag used as input to ZVSTEP:
1137
+ C 0 means perform the first step.
1138
+ C 1 means take a new step continuing from the last.
1139
+ C -1 means take the next step with a new value of MAXORD,
1140
+ C HMIN, HMXI, N, METH, MITER, and/or matrix parameters.
1141
+ C On return, ZVSTEP sets JSTART = 1.
1142
+ C JSV = Integer flag for Jacobian saving, = sign(MF).
1143
+ C KFLAG = A completion code from ZVSTEP with the following meanings:
1144
+ C 0 the step was succesful.
1145
+ C -1 the requested error could not be achieved.
1146
+ C -2 corrector convergence could not be achieved.
1147
+ C -3, -4 fatal error in VNLS (can not occur here).
1148
+ C KUTH = Input flag to ZVSTEP showing whether H was reduced by the
1149
+ C driver. KUTH = 1 if H was reduced, = 0 otherwise.
1150
+ C L = Integer variable, NQ + 1, current order plus one.
1151
+ C LMAX = MAXORD + 1 (used for dimensioning).
1152
+ C LOCJS = A pointer to the saved Jacobian, whose storage starts at
1153
+ C WM(LOCJS), if JSV = 1.
1154
+ C LYH, LEWT, LACOR, LSAVF, LWM, LIWM = Saved integer pointers
1155
+ C to segments of ZWORK, RWORK, and IWORK.
1156
+ C MAXORD = The maximum order of integration method to be allowed.
1157
+ C METH/MITER = The method flags. See MF.
1158
+ C MSBJ = The maximum number of steps between J evaluations, = 50.
1159
+ C MXHNIL = Saved value of optional input MXHNIL.
1160
+ C MXSTEP = Saved value of optional input MXSTEP.
1161
+ C N = The number of first-order ODEs, = NEQ.
1162
+ C NEWH = Saved integer to flag change of H.
1163
+ C NEWQ = The method order to be used on the next step.
1164
+ C NHNIL = Saved counter for occurrences of T + H = T.
1165
+ C NQ = Integer variable, the current integration method order.
1166
+ C NQNYH = Saved value of NQ*NYH.
1167
+ C NQWAIT = A counter controlling the frequency of order changes.
1168
+ C An order change is about to be considered if NQWAIT = 1.
1169
+ C NSLJ = The number of steps taken as of the last Jacobian update.
1170
+ C NSLP = Saved value of NST as of last Newton matrix update.
1171
+ C NYH = Saved value of the initial value of NEQ.
1172
+ C HU = The step size in t last used.
1173
+ C NCFN = Number of nonlinear convergence failures so far.
1174
+ C NETF = The number of error test failures of the integrator so far.
1175
+ C NFE = The number of f evaluations for the problem so far.
1176
+ C NJE = The number of Jacobian evaluations so far.
1177
+ C NLU = The number of matrix LU decompositions so far.
1178
+ C NNI = Number of nonlinear iterations so far.
1179
+ C NQU = The method order last used.
1180
+ C NST = The number of steps taken for the problem so far.
1181
+ C-----------------------------------------------------------------------
1182
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
1183
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
1184
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
1185
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
1186
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
1187
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
1188
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
1189
+ 7 NSLP, NYH
1190
+ COMMON /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
1191
+ C
1192
+ DATA MORD(1) /12/, MORD(2) /5/, MXSTP0 /500/, MXHNL0 /10/
1193
+ DATA ZERO /0.0D0/, ONE /1.0D0/, TWO /2.0D0/, FOUR /4.0D0/,
1194
+ 1 PT2 /0.2D0/, HUN /100.0D0/
1195
+ C-----------------------------------------------------------------------
1196
+ C Block A.
1197
+ C This code block is executed on every call.
1198
+ C It tests ISTATE and ITASK for legality and branches appropriately.
1199
+ C If ISTATE .gt. 1 but the flag INIT shows that initialization has
1200
+ C not yet been done, an error return occurs.
1201
+ C If ISTATE = 1 and TOUT = T, return immediately.
1202
+ C-----------------------------------------------------------------------
1203
+ IF (ISTATE .LT. 1 .OR. ISTATE .GT. 3) GO TO 601
1204
+ IF (ITASK .LT. 1 .OR. ITASK .GT. 5) GO TO 602
1205
+ IF (ISTATE .EQ. 1) GO TO 10
1206
+ IF (INIT .NE. 1) GO TO 603
1207
+ IF (ISTATE .EQ. 2) GO TO 200
1208
+ GO TO 20
1209
+ 10 INIT = 0
1210
+ IF (TOUT .EQ. T) RETURN
1211
+ C-----------------------------------------------------------------------
1212
+ C Block B.
1213
+ C The next code block is executed for the initial call (ISTATE = 1),
1214
+ C or for a continuation call with parameter changes (ISTATE = 3).
1215
+ C It contains checking of all input and various initializations.
1216
+ C
1217
+ C First check legality of the non-optional input NEQ, ITOL, IOPT,
1218
+ C MF, ML, and MU.
1219
+ C-----------------------------------------------------------------------
1220
+ 20 IF (NEQ .LE. 0) GO TO 604
1221
+ IF (ISTATE .EQ. 1) GO TO 25
1222
+ IF (NEQ .GT. N) GO TO 605
1223
+ 25 N = NEQ
1224
+ IF (ITOL .LT. 1 .OR. ITOL .GT. 4) GO TO 606
1225
+ IF (IOPT .LT. 0 .OR. IOPT .GT. 1) GO TO 607
1226
+ JSV = SIGN(1,MF)
1227
+ MFA = ABS(MF)
1228
+ METH = MFA/10
1229
+ MITER = MFA - 10*METH
1230
+ IF (METH .LT. 1 .OR. METH .GT. 2) GO TO 608
1231
+ IF (MITER .LT. 0 .OR. MITER .GT. 5) GO TO 608
1232
+ IF (MITER .LE. 3) GO TO 30
1233
+ ML = IWORK(1)
1234
+ MU = IWORK(2)
1235
+ IF (ML .LT. 0 .OR. ML .GE. N) GO TO 609
1236
+ IF (MU .LT. 0 .OR. MU .GE. N) GO TO 610
1237
+ 30 CONTINUE
1238
+ C Next process and check the optional input. ---------------------------
1239
+ IF (IOPT .EQ. 1) GO TO 40
1240
+ MAXORD = MORD(METH)
1241
+ MXSTEP = MXSTP0
1242
+ MXHNIL = MXHNL0
1243
+ IF (ISTATE .EQ. 1) H0 = ZERO
1244
+ HMXI = ZERO
1245
+ HMIN = ZERO
1246
+ GO TO 60
1247
+ 40 MAXORD = IWORK(5)
1248
+ IF (MAXORD .LT. 0) GO TO 611
1249
+ IF (MAXORD .EQ. 0) MAXORD = 100
1250
+ MAXORD = MIN(MAXORD,MORD(METH))
1251
+ MXSTEP = IWORK(6)
1252
+ IF (MXSTEP .LT. 0) GO TO 612
1253
+ IF (MXSTEP .EQ. 0) MXSTEP = MXSTP0
1254
+ MXHNIL = IWORK(7)
1255
+ IF (MXHNIL .LT. 0) GO TO 613
1256
+ IF (MXHNIL .EQ. 0) MXHNIL = MXHNL0
1257
+ IF (ISTATE .NE. 1) GO TO 50
1258
+ H0 = RWORK(5)
1259
+ IF ((TOUT - T)*H0 .LT. ZERO) GO TO 614
1260
+ 50 HMAX = RWORK(6)
1261
+ IF (HMAX .LT. ZERO) GO TO 615
1262
+ HMXI = ZERO
1263
+ IF (HMAX .GT. ZERO) HMXI = ONE/HMAX
1264
+ HMIN = RWORK(7)
1265
+ IF (HMIN .LT. ZERO) GO TO 616
1266
+ C-----------------------------------------------------------------------
1267
+ C Set work array pointers and check lengths LZW, LRW, and LIW.
1268
+ C Pointers to segments of ZWORK, RWORK, and IWORK are named by prefixing
1269
+ C L to the name of the segment. E.g., segment YH starts at ZWORK(LYH).
1270
+ C Segments of ZWORK (in order) are denoted YH, WM, SAVF, ACOR.
1271
+ C Besides optional inputs/outputs, RWORK has only the segment EWT.
1272
+ C Within WM, LOCJS is the location of the saved Jacobian (JSV .gt. 0).
1273
+ C-----------------------------------------------------------------------
1274
+ 60 LYH = 1
1275
+ IF (ISTATE .EQ. 1) NYH = N
1276
+ LWM = LYH + (MAXORD + 1)*NYH
1277
+ JCO = MAX(0,JSV)
1278
+ IF (MITER .EQ. 0) LENWM = 0
1279
+ IF (MITER .EQ. 1 .OR. MITER .EQ. 2) THEN
1280
+ LENWM = (1 + JCO)*N*N
1281
+ LOCJS = N*N + 1
1282
+ ENDIF
1283
+ IF (MITER .EQ. 3) LENWM = N
1284
+ IF (MITER .EQ. 4 .OR. MITER .EQ. 5) THEN
1285
+ MBAND = ML + MU + 1
1286
+ LENP = (MBAND + ML)*N
1287
+ LENJ = MBAND*N
1288
+ LENWM = LENP + JCO*LENJ
1289
+ LOCJS = LENP + 1
1290
+ ENDIF
1291
+ LSAVF = LWM + LENWM
1292
+ LACOR = LSAVF + N
1293
+ LENZW = LACOR + N - 1
1294
+ IWORK(17) = LENZW
1295
+ LEWT = 21
1296
+ LENRW = 20 + N
1297
+ IWORK(18) = LENRW
1298
+ LIWM = 1
1299
+ LENIW = 30 + N
1300
+ IF (MITER .EQ. 0 .OR. MITER .EQ. 3) LENIW = 30
1301
+ IWORK(19) = LENIW
1302
+ IF (LENZW .GT. LZW) GO TO 628
1303
+ IF (LENRW .GT. LRW) GO TO 617
1304
+ IF (LENIW .GT. LIW) GO TO 618
1305
+ C Check RTOL and ATOL for legality. ------------------------------------
1306
+ RTOLI = RTOL(1)
1307
+ ATOLI = ATOL(1)
1308
+ DO 70 I = 1,N
1309
+ IF (ITOL .GE. 3) RTOLI = RTOL(I)
1310
+ IF (ITOL .EQ. 2 .OR. ITOL .EQ. 4) ATOLI = ATOL(I)
1311
+ IF (RTOLI .LT. ZERO) GO TO 619
1312
+ IF (ATOLI .LT. ZERO) GO TO 620
1313
+ 70 CONTINUE
1314
+ IF (ISTATE .EQ. 1) GO TO 100
1315
+ C If ISTATE = 3, set flag to signal parameter changes to ZVSTEP. -------
1316
+ JSTART = -1
1317
+ IF (NQ .LE. MAXORD) GO TO 200
1318
+ C MAXORD was reduced below NQ. Copy YH(*,MAXORD+2) into SAVF. ---------
1319
+ CALL ZCOPY (N, ZWORK(LWM), 1, ZWORK(LSAVF), 1)
1320
+ GO TO 200
1321
+ C-----------------------------------------------------------------------
1322
+ C Block C.
1323
+ C The next block is for the initial call only (ISTATE = 1).
1324
+ C It contains all remaining initializations, the initial call to F,
1325
+ C and the calculation of the initial step size.
1326
+ C The error weights in EWT are inverted after being loaded.
1327
+ C-----------------------------------------------------------------------
1328
+ 100 UROUND = DUMACH()
1329
+ TN = T
1330
+ IF (ITASK .NE. 4 .AND. ITASK .NE. 5) GO TO 110
1331
+ TCRIT = RWORK(1)
1332
+ IF ((TCRIT - TOUT)*(TOUT - T) .LT. ZERO) GO TO 625
1333
+ IF (H0 .NE. ZERO .AND. (T + H0 - TCRIT)*H0 .GT. ZERO)
1334
+ 1 H0 = TCRIT - T
1335
+ 110 JSTART = 0
1336
+ IF (MITER .GT. 0) SRUR = SQRT(UROUND)
1337
+ CCMXJ = PT2
1338
+ MSBJ = 50
1339
+ NHNIL = 0
1340
+ NST = 0
1341
+ NJE = 0
1342
+ NNI = 0
1343
+ NCFN = 0
1344
+ NETF = 0
1345
+ NLU = 0
1346
+ NSLJ = 0
1347
+ NSLAST = 0
1348
+ HU = ZERO
1349
+ NQU = 0
1350
+ C Initial call to F. (LF0 points to YH(*,2).) -------------------------
1351
+ LF0 = LYH + NYH
1352
+ CALL F (N, T, Y, ZWORK(LF0), RPAR, IPAR)
1353
+ NFE = 1
1354
+ C Load the initial value vector in YH. ---------------------------------
1355
+ CALL ZCOPY (N, Y, 1, ZWORK(LYH), 1)
1356
+ C Load and invert the EWT array. (H is temporarily set to 1.0.) -------
1357
+ NQ = 1
1358
+ H = ONE
1359
+ CALL ZEWSET (N, ITOL, RTOL, ATOL, ZWORK(LYH), RWORK(LEWT))
1360
+ DO 120 I = 1,N
1361
+ IF (RWORK(I+LEWT-1) .LE. ZERO) GO TO 621
1362
+ 120 RWORK(I+LEWT-1) = ONE/RWORK(I+LEWT-1)
1363
+ IF (H0 .NE. ZERO) GO TO 180
1364
+ C Call ZVHIN to set initial step size H0 to be attempted. --------------
1365
+ CALL ZVHIN (N, T, ZWORK(LYH), ZWORK(LF0), F, RPAR, IPAR, TOUT,
1366
+ 1 UROUND, RWORK(LEWT), ITOL, ATOL, Y, ZWORK(LACOR), H0,
1367
+ 2 NITER, IER)
1368
+ NFE = NFE + NITER
1369
+ IF (IER .NE. 0) GO TO 622
1370
+ C Adjust H0 if necessary to meet HMAX bound. ---------------------------
1371
+ 180 RH = ABS(H0)*HMXI
1372
+ IF (RH .GT. ONE) H0 = H0/RH
1373
+ C Load H with H0 and scale YH(*,2) by H0. ------------------------------
1374
+ H = H0
1375
+ CALL DZSCAL (N, H0, ZWORK(LF0), 1)
1376
+ GO TO 270
1377
+ C-----------------------------------------------------------------------
1378
+ C Block D.
1379
+ C The next code block is for continuation calls only (ISTATE = 2 or 3)
1380
+ C and is to check stop conditions before taking a step.
1381
+ C-----------------------------------------------------------------------
1382
+ 200 NSLAST = NST
1383
+ KUTH = 0
1384
+ GO TO (210, 250, 220, 230, 240), ITASK
1385
+ 210 IF ((TN - TOUT)*H .LT. ZERO) GO TO 250
1386
+ CALL ZVINDY (TOUT, 0, ZWORK(LYH), NYH, Y, IFLAG)
1387
+ IF (IFLAG .NE. 0) GO TO 627
1388
+ T = TOUT
1389
+ GO TO 420
1390
+ 220 TP = TN - HU*(ONE + HUN*UROUND)
1391
+ IF ((TP - TOUT)*H .GT. ZERO) GO TO 623
1392
+ IF ((TN - TOUT)*H .LT. ZERO) GO TO 250
1393
+ GO TO 400
1394
+ 230 TCRIT = RWORK(1)
1395
+ IF ((TN - TCRIT)*H .GT. ZERO) GO TO 624
1396
+ IF ((TCRIT - TOUT)*H .LT. ZERO) GO TO 625
1397
+ IF ((TN - TOUT)*H .LT. ZERO) GO TO 245
1398
+ CALL ZVINDY (TOUT, 0, ZWORK(LYH), NYH, Y, IFLAG)
1399
+ IF (IFLAG .NE. 0) GO TO 627
1400
+ T = TOUT
1401
+ GO TO 420
1402
+ 240 TCRIT = RWORK(1)
1403
+ IF ((TN - TCRIT)*H .GT. ZERO) GO TO 624
1404
+ 245 HMX = ABS(TN) + ABS(H)
1405
+ IHIT = ABS(TN - TCRIT) .LE. HUN*UROUND*HMX
1406
+ IF (IHIT) GO TO 400
1407
+ TNEXT = TN + HNEW*(ONE + FOUR*UROUND)
1408
+ IF ((TNEXT - TCRIT)*H .LE. ZERO) GO TO 250
1409
+ H = (TCRIT - TN)*(ONE - FOUR*UROUND)
1410
+ KUTH = 1
1411
+ C-----------------------------------------------------------------------
1412
+ C Block E.
1413
+ C The next block is normally executed for all calls and contains
1414
+ C the call to the one-step core integrator ZVSTEP.
1415
+ C
1416
+ C This is a looping point for the integration steps.
1417
+ C
1418
+ C First check for too many steps being taken, update EWT (if not at
1419
+ C start of problem), check for too much accuracy being requested, and
1420
+ C check for H below the roundoff level in T.
1421
+ C-----------------------------------------------------------------------
1422
+ 250 CONTINUE
1423
+ IF ((NST-NSLAST) .GE. MXSTEP) GO TO 500
1424
+ CALL ZEWSET (N, ITOL, RTOL, ATOL, ZWORK(LYH), RWORK(LEWT))
1425
+ DO 260 I = 1,N
1426
+ IF (RWORK(I+LEWT-1) .LE. ZERO) GO TO 510
1427
+ 260 RWORK(I+LEWT-1) = ONE/RWORK(I+LEWT-1)
1428
+ 270 TOLSF = UROUND*ZVNORM (N, ZWORK(LYH), RWORK(LEWT))
1429
+ IF (TOLSF .LE. ONE) GO TO 280
1430
+ TOLSF = TOLSF*TWO
1431
+ IF (NST .EQ. 0) GO TO 626
1432
+ GO TO 520
1433
+ 280 IF ((TN + H) .NE. TN) GO TO 290
1434
+ NHNIL = NHNIL + 1
1435
+ IF (NHNIL .GT. MXHNIL) GO TO 290
1436
+ MSG = 'ZVODE-- Warning: internal T (=R1) and H (=R2) are'
1437
+ CALL XERRWD (MSG, 50, 101, 1, 0, 0, 0, 0, ZERO, ZERO)
1438
+ MSG=' such that in the machine, T + H = T on the next step '
1439
+ CALL XERRWD (MSG, 60, 101, 1, 0, 0, 0, 0, ZERO, ZERO)
1440
+ MSG = ' (H = step size). solver will continue anyway'
1441
+ CALL XERRWD (MSG, 50, 101, 1, 0, 0, 0, 2, TN, H)
1442
+ IF (NHNIL .LT. MXHNIL) GO TO 290
1443
+ MSG = 'ZVODE-- Above warning has been issued I1 times. '
1444
+ CALL XERRWD (MSG, 50, 102, 1, 0, 0, 0, 0, ZERO, ZERO)
1445
+ MSG = ' it will not be issued again for this problem'
1446
+ CALL XERRWD (MSG, 50, 102, 1, 1, MXHNIL, 0, 0, ZERO, ZERO)
1447
+ 290 CONTINUE
1448
+ C-----------------------------------------------------------------------
1449
+ C CALL ZVSTEP (Y, YH, NYH, YH, EWT, SAVF, VSAV, ACOR,
1450
+ C WM, IWM, F, JAC, F, ZVNLSD, RPAR, IPAR)
1451
+ C-----------------------------------------------------------------------
1452
+ CALL ZVSTEP (Y, ZWORK(LYH), NYH, ZWORK(LYH), RWORK(LEWT),
1453
+ 1 ZWORK(LSAVF), Y, ZWORK(LACOR), ZWORK(LWM), IWORK(LIWM),
1454
+ 2 F, JAC, F, ZVNLSD, RPAR, IPAR)
1455
+ KGO = 1 - KFLAG
1456
+ C Branch on KFLAG. Note: In this version, KFLAG can not be set to -3.
1457
+ C KFLAG .eq. 0, -1, -2
1458
+ GO TO (300, 530, 540), KGO
1459
+ C-----------------------------------------------------------------------
1460
+ C Block F.
1461
+ C The following block handles the case of a successful return from the
1462
+ C core integrator (KFLAG = 0). Test for stop conditions.
1463
+ C-----------------------------------------------------------------------
1464
+ 300 INIT = 1
1465
+ KUTH = 0
1466
+ GO TO (310, 400, 330, 340, 350), ITASK
1467
+ C ITASK = 1. If TOUT has been reached, interpolate. -------------------
1468
+ 310 IF ((TN - TOUT)*H .LT. ZERO) GO TO 250
1469
+ CALL ZVINDY (TOUT, 0, ZWORK(LYH), NYH, Y, IFLAG)
1470
+ T = TOUT
1471
+ GO TO 420
1472
+ C ITASK = 3. Jump to exit if TOUT was reached. ------------------------
1473
+ 330 IF ((TN - TOUT)*H .GE. ZERO) GO TO 400
1474
+ GO TO 250
1475
+ C ITASK = 4. See if TOUT or TCRIT was reached. Adjust H if necessary.
1476
+ 340 IF ((TN - TOUT)*H .LT. ZERO) GO TO 345
1477
+ CALL ZVINDY (TOUT, 0, ZWORK(LYH), NYH, Y, IFLAG)
1478
+ T = TOUT
1479
+ GO TO 420
1480
+ 345 HMX = ABS(TN) + ABS(H)
1481
+ IHIT = ABS(TN - TCRIT) .LE. HUN*UROUND*HMX
1482
+ IF (IHIT) GO TO 400
1483
+ TNEXT = TN + HNEW*(ONE + FOUR*UROUND)
1484
+ IF ((TNEXT - TCRIT)*H .LE. ZERO) GO TO 250
1485
+ H = (TCRIT - TN)*(ONE - FOUR*UROUND)
1486
+ KUTH = 1
1487
+ GO TO 250
1488
+ C ITASK = 5. See if TCRIT was reached and jump to exit. ---------------
1489
+ 350 HMX = ABS(TN) + ABS(H)
1490
+ IHIT = ABS(TN - TCRIT) .LE. HUN*UROUND*HMX
1491
+ C-----------------------------------------------------------------------
1492
+ C Block G.
1493
+ C The following block handles all successful returns from ZVODE.
1494
+ C If ITASK .ne. 1, Y is loaded from YH and T is set accordingly.
1495
+ C ISTATE is set to 2, and the optional output is loaded into the work
1496
+ C arrays before returning.
1497
+ C-----------------------------------------------------------------------
1498
+ 400 CONTINUE
1499
+ CALL ZCOPY (N, ZWORK(LYH), 1, Y, 1)
1500
+ T = TN
1501
+ IF (ITASK .NE. 4 .AND. ITASK .NE. 5) GO TO 420
1502
+ IF (IHIT) T = TCRIT
1503
+ 420 ISTATE = 2
1504
+ RWORK(11) = HU
1505
+ RWORK(12) = HNEW
1506
+ RWORK(13) = TN
1507
+ IWORK(11) = NST
1508
+ IWORK(12) = NFE
1509
+ IWORK(13) = NJE
1510
+ IWORK(14) = NQU
1511
+ IWORK(15) = NEWQ
1512
+ IWORK(20) = NLU
1513
+ IWORK(21) = NNI
1514
+ IWORK(22) = NCFN
1515
+ IWORK(23) = NETF
1516
+ RETURN
1517
+ C-----------------------------------------------------------------------
1518
+ C Block H.
1519
+ C The following block handles all unsuccessful returns other than
1520
+ C those for illegal input. First the error message routine is called.
1521
+ C if there was an error test or convergence test failure, IMXER is set.
1522
+ C Then Y is loaded from YH, and T is set to TN.
1523
+ C The optional output is loaded into the work arrays before returning.
1524
+ C-----------------------------------------------------------------------
1525
+ C The maximum number of steps was taken before reaching TOUT. ----------
1526
+ 500 MSG = 'ZVODE-- At current T (=R1), MXSTEP (=I1) steps '
1527
+ CALL XERRWD (MSG, 50, 201, 1, 0, 0, 0, 0, ZERO, ZERO)
1528
+ MSG = ' taken on this call before reaching TOUT '
1529
+ CALL XERRWD (MSG, 50, 201, 1, 1, MXSTEP, 0, 1, TN, ZERO)
1530
+ ISTATE = -1
1531
+ GO TO 580
1532
+ C EWT(i) .le. 0.0 for some i (not at start of problem). ----------------
1533
+ 510 EWTI = RWORK(LEWT+I-1)
1534
+ MSG = 'ZVODE-- At T (=R1), EWT(I1) has become R2 .le. 0.'
1535
+ CALL XERRWD (MSG, 50, 202, 1, 1, I, 0, 2, TN, EWTI)
1536
+ ISTATE = -6
1537
+ GO TO 580
1538
+ C Too much accuracy requested for machine precision. -------------------
1539
+ 520 MSG = 'ZVODE-- At T (=R1), too much accuracy requested '
1540
+ CALL XERRWD (MSG, 50, 203, 1, 0, 0, 0, 0, ZERO, ZERO)
1541
+ MSG = ' for precision of machine: see TOLSF (=R2) '
1542
+ CALL XERRWD (MSG, 50, 203, 1, 0, 0, 0, 2, TN, TOLSF)
1543
+ RWORK(14) = TOLSF
1544
+ ISTATE = -2
1545
+ GO TO 580
1546
+ C KFLAG = -1. Error test failed repeatedly or with ABS(H) = HMIN. -----
1547
+ 530 MSG = 'ZVODE-- At T(=R1) and step size H(=R2), the error'
1548
+ CALL XERRWD (MSG, 50, 204, 1, 0, 0, 0, 0, ZERO, ZERO)
1549
+ MSG = ' test failed repeatedly or with abs(H) = HMIN'
1550
+ CALL XERRWD (MSG, 50, 204, 1, 0, 0, 0, 2, TN, H)
1551
+ ISTATE = -4
1552
+ GO TO 560
1553
+ C KFLAG = -2. Convergence failed repeatedly or with ABS(H) = HMIN. ----
1554
+ 540 MSG = 'ZVODE-- At T (=R1) and step size H (=R2), the '
1555
+ CALL XERRWD (MSG, 50, 205, 1, 0, 0, 0, 0, ZERO, ZERO)
1556
+ MSG = ' corrector convergence failed repeatedly '
1557
+ CALL XERRWD (MSG, 50, 205, 1, 0, 0, 0, 0, ZERO, ZERO)
1558
+ MSG = ' or with abs(H) = HMIN '
1559
+ CALL XERRWD (MSG, 30, 205, 1, 0, 0, 0, 2, TN, H)
1560
+ ISTATE = -5
1561
+ C Compute IMXER if relevant. -------------------------------------------
1562
+ 560 BIG = ZERO
1563
+ IMXER = 1
1564
+ DO 570 I = 1,N
1565
+ SIZE = ABS(ZWORK(I+LACOR-1))*RWORK(I+LEWT-1)
1566
+ IF (BIG .GE. SIZE) GO TO 570
1567
+ BIG = SIZE
1568
+ IMXER = I
1569
+ 570 CONTINUE
1570
+ IWORK(16) = IMXER
1571
+ C Set Y vector, T, and optional output. --------------------------------
1572
+ 580 CONTINUE
1573
+ CALL ZCOPY (N, ZWORK(LYH), 1, Y, 1)
1574
+ T = TN
1575
+ RWORK(11) = HU
1576
+ RWORK(12) = H
1577
+ RWORK(13) = TN
1578
+ IWORK(11) = NST
1579
+ IWORK(12) = NFE
1580
+ IWORK(13) = NJE
1581
+ IWORK(14) = NQU
1582
+ IWORK(15) = NQ
1583
+ IWORK(20) = NLU
1584
+ IWORK(21) = NNI
1585
+ IWORK(22) = NCFN
1586
+ IWORK(23) = NETF
1587
+ RETURN
1588
+ C-----------------------------------------------------------------------
1589
+ C Block I.
1590
+ C The following block handles all error returns due to illegal input
1591
+ C (ISTATE = -3), as detected before calling the core integrator.
1592
+ C First the error message routine is called. If the illegal input
1593
+ C is a negative ISTATE, the run is aborted (apparent infinite loop).
1594
+ C-----------------------------------------------------------------------
1595
+ 601 MSG = 'ZVODE-- ISTATE (=I1) illegal '
1596
+ CALL XERRWD (MSG, 30, 1, 1, 1, ISTATE, 0, 0, ZERO, ZERO)
1597
+ IF (ISTATE .LT. 0) GO TO 800
1598
+ GO TO 700
1599
+ 602 MSG = 'ZVODE-- ITASK (=I1) illegal '
1600
+ CALL XERRWD (MSG, 30, 2, 1, 1, ITASK, 0, 0, ZERO, ZERO)
1601
+ GO TO 700
1602
+ 603 MSG='ZVODE-- ISTATE (=I1) .gt. 1 but ZVODE not initialized '
1603
+ CALL XERRWD (MSG, 60, 3, 1, 1, ISTATE, 0, 0, ZERO, ZERO)
1604
+ GO TO 700
1605
+ 604 MSG = 'ZVODE-- NEQ (=I1) .lt. 1 '
1606
+ CALL XERRWD (MSG, 30, 4, 1, 1, NEQ, 0, 0, ZERO, ZERO)
1607
+ GO TO 700
1608
+ 605 MSG = 'ZVODE-- ISTATE = 3 and NEQ increased (I1 to I2) '
1609
+ CALL XERRWD (MSG, 50, 5, 1, 2, N, NEQ, 0, ZERO, ZERO)
1610
+ GO TO 700
1611
+ 606 MSG = 'ZVODE-- ITOL (=I1) illegal '
1612
+ CALL XERRWD (MSG, 30, 6, 1, 1, ITOL, 0, 0, ZERO, ZERO)
1613
+ GO TO 700
1614
+ 607 MSG = 'ZVODE-- IOPT (=I1) illegal '
1615
+ CALL XERRWD (MSG, 30, 7, 1, 1, IOPT, 0, 0, ZERO, ZERO)
1616
+ GO TO 700
1617
+ 608 MSG = 'ZVODE-- MF (=I1) illegal '
1618
+ CALL XERRWD (MSG, 30, 8, 1, 1, MF, 0, 0, ZERO, ZERO)
1619
+ GO TO 700
1620
+ 609 MSG = 'ZVODE-- ML (=I1) illegal: .lt.0 or .ge.NEQ (=I2)'
1621
+ CALL XERRWD (MSG, 50, 9, 1, 2, ML, NEQ, 0, ZERO, ZERO)
1622
+ GO TO 700
1623
+ 610 MSG = 'ZVODE-- MU (=I1) illegal: .lt.0 or .ge.NEQ (=I2)'
1624
+ CALL XERRWD (MSG, 50, 10, 1, 2, MU, NEQ, 0, ZERO, ZERO)
1625
+ GO TO 700
1626
+ 611 MSG = 'ZVODE-- MAXORD (=I1) .lt. 0 '
1627
+ CALL XERRWD (MSG, 30, 11, 1, 1, MAXORD, 0, 0, ZERO, ZERO)
1628
+ GO TO 700
1629
+ 612 MSG = 'ZVODE-- MXSTEP (=I1) .lt. 0 '
1630
+ CALL XERRWD (MSG, 30, 12, 1, 1, MXSTEP, 0, 0, ZERO, ZERO)
1631
+ GO TO 700
1632
+ 613 MSG = 'ZVODE-- MXHNIL (=I1) .lt. 0 '
1633
+ CALL XERRWD (MSG, 30, 13, 1, 1, MXHNIL, 0, 0, ZERO, ZERO)
1634
+ GO TO 700
1635
+ 614 MSG = 'ZVODE-- TOUT (=R1) behind T (=R2) '
1636
+ CALL XERRWD (MSG, 40, 14, 1, 0, 0, 0, 2, TOUT, T)
1637
+ MSG = ' integration direction is given by H0 (=R1) '
1638
+ CALL XERRWD (MSG, 50, 14, 1, 0, 0, 0, 1, H0, ZERO)
1639
+ GO TO 700
1640
+ 615 MSG = 'ZVODE-- HMAX (=R1) .lt. 0.0 '
1641
+ CALL XERRWD (MSG, 30, 15, 1, 0, 0, 0, 1, HMAX, ZERO)
1642
+ GO TO 700
1643
+ 616 MSG = 'ZVODE-- HMIN (=R1) .lt. 0.0 '
1644
+ CALL XERRWD (MSG, 30, 16, 1, 0, 0, 0, 1, HMIN, ZERO)
1645
+ GO TO 700
1646
+ 617 CONTINUE
1647
+ MSG='ZVODE-- RWORK length needed, LENRW (=I1), exceeds LRW (=I2)'
1648
+ CALL XERRWD (MSG, 60, 17, 1, 2, LENRW, LRW, 0, ZERO, ZERO)
1649
+ GO TO 700
1650
+ 618 CONTINUE
1651
+ MSG='ZVODE-- IWORK length needed, LENIW (=I1), exceeds LIW (=I2)'
1652
+ CALL XERRWD (MSG, 60, 18, 1, 2, LENIW, LIW, 0, ZERO, ZERO)
1653
+ GO TO 700
1654
+ 619 MSG = 'ZVODE-- RTOL(I1) is R1 .lt. 0.0 '
1655
+ CALL XERRWD (MSG, 40, 19, 1, 1, I, 0, 1, RTOLI, ZERO)
1656
+ GO TO 700
1657
+ 620 MSG = 'ZVODE-- ATOL(I1) is R1 .lt. 0.0 '
1658
+ CALL XERRWD (MSG, 40, 20, 1, 1, I, 0, 1, ATOLI, ZERO)
1659
+ GO TO 700
1660
+ 621 EWTI = RWORK(LEWT+I-1)
1661
+ MSG = 'ZVODE-- EWT(I1) is R1 .le. 0.0 '
1662
+ CALL XERRWD (MSG, 40, 21, 1, 1, I, 0, 1, EWTI, ZERO)
1663
+ GO TO 700
1664
+ 622 CONTINUE
1665
+ MSG='ZVODE-- TOUT (=R1) too close to T(=R2) to start integration'
1666
+ CALL XERRWD (MSG, 60, 22, 1, 0, 0, 0, 2, TOUT, T)
1667
+ GO TO 700
1668
+ 623 CONTINUE
1669
+ MSG='ZVODE-- ITASK = I1 and TOUT (=R1) behind TCUR - HU (= R2) '
1670
+ CALL XERRWD (MSG, 60, 23, 1, 1, ITASK, 0, 2, TOUT, TP)
1671
+ GO TO 700
1672
+ 624 CONTINUE
1673
+ MSG='ZVODE-- ITASK = 4 or 5 and TCRIT (=R1) behind TCUR (=R2) '
1674
+ CALL XERRWD (MSG, 60, 24, 1, 0, 0, 0, 2, TCRIT, TN)
1675
+ GO TO 700
1676
+ 625 CONTINUE
1677
+ MSG='ZVODE-- ITASK = 4 or 5 and TCRIT (=R1) behind TOUT (=R2) '
1678
+ CALL XERRWD (MSG, 60, 25, 1, 0, 0, 0, 2, TCRIT, TOUT)
1679
+ GO TO 700
1680
+ 626 MSG = 'ZVODE-- At start of problem, too much accuracy '
1681
+ CALL XERRWD (MSG, 50, 26, 1, 0, 0, 0, 0, ZERO, ZERO)
1682
+ MSG=' requested for precision of machine: see TOLSF (=R1) '
1683
+ CALL XERRWD (MSG, 60, 26, 1, 0, 0, 0, 1, TOLSF, ZERO)
1684
+ RWORK(14) = TOLSF
1685
+ GO TO 700
1686
+ 627 MSG='ZVODE-- Trouble from ZVINDY. ITASK = I1, TOUT = R1. '
1687
+ CALL XERRWD (MSG, 60, 27, 1, 1, ITASK, 0, 1, TOUT, ZERO)
1688
+ GO TO 700
1689
+ 628 CONTINUE
1690
+ MSG='ZVODE-- ZWORK length needed, LENZW (=I1), exceeds LZW (=I2)'
1691
+ CALL XERRWD (MSG, 60, 17, 1, 2, LENZW, LZW, 0, ZERO, ZERO)
1692
+ C
1693
+ 700 CONTINUE
1694
+ ISTATE = -3
1695
+ RETURN
1696
+ C
1697
+ 800 MSG = 'ZVODE-- Run aborted: apparent infinite loop '
1698
+ CALL XERRWD (MSG, 50, 303, 2, 0, 0, 0, 0, ZERO, ZERO)
1699
+ RETURN
1700
+ C----------------------- End of Subroutine ZVODE -----------------------
1701
+ END
1702
+ *DECK ZVHIN
1703
+ SUBROUTINE ZVHIN (N, T0, Y0, YDOT, F, RPAR, IPAR, TOUT, UROUND,
1704
+ 1 EWT, ITOL, ATOL, Y, TEMP, H0, NITER, IER)
1705
+ EXTERNAL F
1706
+ DOUBLE COMPLEX Y0, YDOT, Y, TEMP
1707
+ DOUBLE PRECISION T0, TOUT, UROUND, EWT, ATOL, H0
1708
+ INTEGER N, IPAR, ITOL, NITER, IER
1709
+ DIMENSION Y0(*), YDOT(*), EWT(*), ATOL(*), Y(*),
1710
+ 1 TEMP(*), RPAR(*), IPAR(*)
1711
+ C-----------------------------------------------------------------------
1712
+ C Call sequence input -- N, T0, Y0, YDOT, F, RPAR, IPAR, TOUT, UROUND,
1713
+ C EWT, ITOL, ATOL, Y, TEMP
1714
+ C Call sequence output -- H0, NITER, IER
1715
+ C COMMON block variables accessed -- None
1716
+ C
1717
+ C Subroutines called by ZVHIN: F
1718
+ C Function routines called by ZVHIN: ZVNORM
1719
+ C-----------------------------------------------------------------------
1720
+ C This routine computes the step size, H0, to be attempted on the
1721
+ C first step, when the user has not supplied a value for this.
1722
+ C
1723
+ C First we check that TOUT - T0 differs significantly from zero. Then
1724
+ C an iteration is done to approximate the initial second derivative
1725
+ C and this is used to define h from w.r.m.s.norm(h**2 * yddot / 2) = 1.
1726
+ C A bias factor of 1/2 is applied to the resulting h.
1727
+ C The sign of H0 is inferred from the initial values of TOUT and T0.
1728
+ C
1729
+ C Communication with ZVHIN is done with the following variables:
1730
+ C
1731
+ C N = Size of ODE system, input.
1732
+ C T0 = Initial value of independent variable, input.
1733
+ C Y0 = Vector of initial conditions, input.
1734
+ C YDOT = Vector of initial first derivatives, input.
1735
+ C F = Name of subroutine for right-hand side f(t,y), input.
1736
+ C RPAR, IPAR = User's real/complex and integer work arrays.
1737
+ C TOUT = First output value of independent variable
1738
+ C UROUND = Machine unit roundoff
1739
+ C EWT, ITOL, ATOL = Error weights and tolerance parameters
1740
+ C as described in the driver routine, input.
1741
+ C Y, TEMP = Work arrays of length N.
1742
+ C H0 = Step size to be attempted, output.
1743
+ C NITER = Number of iterations (and of f evaluations) to compute H0,
1744
+ C output.
1745
+ C IER = The error flag, returned with the value
1746
+ C IER = 0 if no trouble occurred, or
1747
+ C IER = -1 if TOUT and T0 are considered too close to proceed.
1748
+ C-----------------------------------------------------------------------
1749
+ C
1750
+ C Type declarations for local variables --------------------------------
1751
+ C
1752
+ DOUBLE PRECISION AFI, ATOLI, DELYI, H, HALF, HG, HLB, HNEW, HRAT,
1753
+ 1 HUB, HUN, PT1, T1, TDIST, TROUND, TWO, YDDNRM
1754
+ INTEGER I, ITER
1755
+ C
1756
+ C Type declaration for function subroutines called ---------------------
1757
+ C
1758
+ DOUBLE PRECISION ZVNORM
1759
+ C-----------------------------------------------------------------------
1760
+ C The following Fortran-77 declaration is to cause the values of the
1761
+ C listed (local) variables to be saved between calls to this integrator.
1762
+ C-----------------------------------------------------------------------
1763
+ SAVE HALF, HUN, PT1, TWO
1764
+ DATA HALF /0.5D0/, HUN /100.0D0/, PT1 /0.1D0/, TWO /2.0D0/
1765
+ C
1766
+ NITER = 0
1767
+ TDIST = ABS(TOUT - T0)
1768
+ TROUND = UROUND*MAX(ABS(T0),ABS(TOUT))
1769
+ IF (TDIST .LT. TWO*TROUND) GO TO 100
1770
+ C
1771
+ C Set a lower bound on h based on the roundoff level in T0 and TOUT. ---
1772
+ HLB = HUN*TROUND
1773
+ C Set an upper bound on h based on TOUT-T0 and the initial Y and YDOT. -
1774
+ HUB = PT1*TDIST
1775
+ ATOLI = ATOL(1)
1776
+ DO 10 I = 1, N
1777
+ IF (ITOL .EQ. 2 .OR. ITOL .EQ. 4) ATOLI = ATOL(I)
1778
+ DELYI = PT1*ABS(Y0(I)) + ATOLI
1779
+ AFI = ABS(YDOT(I))
1780
+ IF (AFI*HUB .GT. DELYI) HUB = DELYI/AFI
1781
+ 10 CONTINUE
1782
+ C
1783
+ C Set initial guess for h as geometric mean of upper and lower bounds. -
1784
+ ITER = 0
1785
+ HG = SQRT(HLB*HUB)
1786
+ C If the bounds have crossed, exit with the mean value. ----------------
1787
+ IF (HUB .LT. HLB) THEN
1788
+ H0 = HG
1789
+ GO TO 90
1790
+ ENDIF
1791
+ C
1792
+ C Looping point for iteration. -----------------------------------------
1793
+ 50 CONTINUE
1794
+ C Estimate the second derivative as a difference quotient in f. --------
1795
+ H = SIGN (HG, TOUT - T0)
1796
+ T1 = T0 + H
1797
+ DO 60 I = 1, N
1798
+ 60 Y(I) = Y0(I) + H*YDOT(I)
1799
+ CALL F (N, T1, Y, TEMP, RPAR, IPAR)
1800
+ DO 70 I = 1, N
1801
+ 70 TEMP(I) = (TEMP(I) - YDOT(I))/H
1802
+ YDDNRM = ZVNORM (N, TEMP, EWT)
1803
+ C Get the corresponding new value of h. --------------------------------
1804
+ IF (YDDNRM*HUB*HUB .GT. TWO) THEN
1805
+ HNEW = SQRT(TWO/YDDNRM)
1806
+ ELSE
1807
+ HNEW = SQRT(HG*HUB)
1808
+ ENDIF
1809
+ ITER = ITER + 1
1810
+ C-----------------------------------------------------------------------
1811
+ C Test the stopping conditions.
1812
+ C Stop if the new and previous h values differ by a factor of .lt. 2.
1813
+ C Stop if four iterations have been done. Also, stop with previous h
1814
+ C if HNEW/HG .gt. 2 after first iteration, as this probably means that
1815
+ C the second derivative value is bad because of cancellation error.
1816
+ C-----------------------------------------------------------------------
1817
+ IF (ITER .GE. 4) GO TO 80
1818
+ HRAT = HNEW/HG
1819
+ IF ( (HRAT .GT. HALF) .AND. (HRAT .LT. TWO) ) GO TO 80
1820
+ IF ( (ITER .GE. 2) .AND. (HNEW .GT. TWO*HG) ) THEN
1821
+ HNEW = HG
1822
+ GO TO 80
1823
+ ENDIF
1824
+ HG = HNEW
1825
+ GO TO 50
1826
+ C
1827
+ C Iteration done. Apply bounds, bias factor, and sign. Then exit. ----
1828
+ 80 H0 = HNEW*HALF
1829
+ IF (H0 .LT. HLB) H0 = HLB
1830
+ IF (H0 .GT. HUB) H0 = HUB
1831
+ 90 H0 = SIGN(H0, TOUT - T0)
1832
+ NITER = ITER
1833
+ IER = 0
1834
+ RETURN
1835
+ C Error return for TOUT - T0 too small. --------------------------------
1836
+ 100 IER = -1
1837
+ RETURN
1838
+ C----------------------- End of Subroutine ZVHIN -----------------------
1839
+ END
1840
+ *DECK ZVINDY
1841
+ SUBROUTINE ZVINDY (T, K, YH, LDYH, DKY, IFLAG)
1842
+ DOUBLE COMPLEX YH, DKY
1843
+ DOUBLE PRECISION T
1844
+ INTEGER K, LDYH, IFLAG
1845
+ DIMENSION YH(LDYH,*), DKY(*)
1846
+ C-----------------------------------------------------------------------
1847
+ C Call sequence input -- T, K, YH, LDYH
1848
+ C Call sequence output -- DKY, IFLAG
1849
+ C COMMON block variables accessed:
1850
+ C /ZVOD01/ -- H, TN, UROUND, L, N, NQ
1851
+ C /ZVOD02/ -- HU
1852
+ C
1853
+ C Subroutines called by ZVINDY: DZSCAL, XERRWD
1854
+ C Function routines called by ZVINDY: None
1855
+ C-----------------------------------------------------------------------
1856
+ C ZVINDY computes interpolated values of the K-th derivative of the
1857
+ C dependent variable vector y, and stores it in DKY. This routine
1858
+ C is called within the package with K = 0 and T = TOUT, but may
1859
+ C also be called by the user for any K up to the current order.
1860
+ C (See detailed instructions in the usage documentation.)
1861
+ C-----------------------------------------------------------------------
1862
+ C The computed values in DKY are gotten by interpolation using the
1863
+ C Nordsieck history array YH. This array corresponds uniquely to a
1864
+ C vector-valued polynomial of degree NQCUR or less, and DKY is set
1865
+ C to the K-th derivative of this polynomial at T.
1866
+ C The formula for DKY is:
1867
+ C q
1868
+ C DKY(i) = sum c(j,K) * (T - TN)**(j-K) * H**(-j) * YH(i,j+1)
1869
+ C j=K
1870
+ C where c(j,K) = j*(j-1)*...*(j-K+1), q = NQCUR, TN = TCUR, H = HCUR.
1871
+ C The quantities NQ = NQCUR, L = NQ+1, N, TN, and H are
1872
+ C communicated by COMMON. The above sum is done in reverse order.
1873
+ C IFLAG is returned negative if either K or T is out of bounds.
1874
+ C
1875
+ C Discussion above and comments in driver explain all variables.
1876
+ C-----------------------------------------------------------------------
1877
+ C
1878
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
1879
+ C
1880
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
1881
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
1882
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
1883
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
1884
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
1885
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
1886
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
1887
+ 4 NSLP, NYH
1888
+ C
1889
+ C Type declarations for labeled COMMON block ZVOD02 --------------------
1890
+ C
1891
+ DOUBLE PRECISION HU
1892
+ INTEGER NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
1893
+ C
1894
+ C Type declarations for local variables --------------------------------
1895
+ C
1896
+ DOUBLE PRECISION C, HUN, R, S, TFUZZ, TN1, TP, ZERO
1897
+ INTEGER I, IC, J, JB, JB2, JJ, JJ1, JP1
1898
+ CHARACTER*80 MSG
1899
+ C-----------------------------------------------------------------------
1900
+ C The following Fortran-77 declaration is to cause the values of the
1901
+ C listed (local) variables to be saved between calls to this integrator.
1902
+ C-----------------------------------------------------------------------
1903
+ SAVE HUN, ZERO
1904
+ C
1905
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
1906
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
1907
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
1908
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
1909
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
1910
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
1911
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
1912
+ 7 NSLP, NYH
1913
+ COMMON /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
1914
+ C
1915
+ DATA HUN /100.0D0/, ZERO /0.0D0/
1916
+ C
1917
+ IFLAG = 0
1918
+ IF (K .LT. 0 .OR. K .GT. NQ) GO TO 80
1919
+ TFUZZ = HUN*UROUND*SIGN(ABS(TN) + ABS(HU), HU)
1920
+ TP = TN - HU - TFUZZ
1921
+ TN1 = TN + TFUZZ
1922
+ IF ((T-TP)*(T-TN1) .GT. ZERO) GO TO 90
1923
+ C
1924
+ S = (T - TN)/H
1925
+ IC = 1
1926
+ IF (K .EQ. 0) GO TO 15
1927
+ JJ1 = L - K
1928
+ DO 10 JJ = JJ1, NQ
1929
+ 10 IC = IC*JJ
1930
+ 15 C = REAL(IC)
1931
+ DO 20 I = 1, N
1932
+ 20 DKY(I) = C*YH(I,L)
1933
+ IF (K .EQ. NQ) GO TO 55
1934
+ JB2 = NQ - K
1935
+ DO 50 JB = 1, JB2
1936
+ J = NQ - JB
1937
+ JP1 = J + 1
1938
+ IC = 1
1939
+ IF (K .EQ. 0) GO TO 35
1940
+ JJ1 = JP1 - K
1941
+ DO 30 JJ = JJ1, J
1942
+ 30 IC = IC*JJ
1943
+ 35 C = REAL(IC)
1944
+ DO 40 I = 1, N
1945
+ 40 DKY(I) = C*YH(I,JP1) + S*DKY(I)
1946
+ 50 CONTINUE
1947
+ IF (K .EQ. 0) RETURN
1948
+ 55 R = H**(-K)
1949
+ CALL DZSCAL (N, R, DKY, 1)
1950
+ RETURN
1951
+ C
1952
+ 80 MSG = 'ZVINDY-- K (=I1) illegal '
1953
+ CALL XERRWD (MSG, 30, 51, 1, 1, K, 0, 0, ZERO, ZERO)
1954
+ IFLAG = -1
1955
+ RETURN
1956
+ 90 MSG = 'ZVINDY-- T (=R1) illegal '
1957
+ CALL XERRWD (MSG, 30, 52, 1, 0, 0, 0, 1, T, ZERO)
1958
+ MSG=' T not in interval TCUR - HU (= R1) to TCUR (=R2) '
1959
+ CALL XERRWD (MSG, 60, 52, 1, 0, 0, 0, 2, TP, TN)
1960
+ IFLAG = -2
1961
+ RETURN
1962
+ C----------------------- End of Subroutine ZVINDY ----------------------
1963
+ END
1964
+ *DECK ZVSTEP
1965
+ SUBROUTINE ZVSTEP (Y, YH, LDYH, YH1, EWT, SAVF, VSAV, ACOR,
1966
+ 1 WM, IWM, F, JAC, PSOL, VNLS, RPAR, IPAR)
1967
+ EXTERNAL F, JAC, PSOL, VNLS
1968
+ DOUBLE COMPLEX Y, YH, YH1, SAVF, VSAV, ACOR, WM
1969
+ DOUBLE PRECISION EWT
1970
+ INTEGER LDYH, IWM, IPAR
1971
+ DIMENSION Y(*), YH(LDYH,*), YH1(*), EWT(*), SAVF(*), VSAV(*),
1972
+ 1 ACOR(*), WM(*), IWM(*), RPAR(*), IPAR(*)
1973
+ C-----------------------------------------------------------------------
1974
+ C Call sequence input -- Y, YH, LDYH, YH1, EWT, SAVF, VSAV,
1975
+ C ACOR, WM, IWM, F, JAC, PSOL, VNLS, RPAR, IPAR
1976
+ C Call sequence output -- YH, ACOR, WM, IWM
1977
+ C COMMON block variables accessed:
1978
+ C /ZVOD01/ ACNRM, EL(13), H, HMIN, HMXI, HNEW, HSCAL, RC, TAU(13),
1979
+ C TQ(5), TN, JCUR, JSTART, KFLAG, KUTH,
1980
+ C L, LMAX, MAXORD, N, NEWQ, NQ, NQWAIT
1981
+ C /ZVOD02/ HU, NCFN, NETF, NFE, NQU, NST
1982
+ C
1983
+ C Subroutines called by ZVSTEP: F, DZAXPY, ZCOPY, DZSCAL,
1984
+ C ZVJUST, VNLS, ZVSET
1985
+ C Function routines called by ZVSTEP: ZVNORM
1986
+ C-----------------------------------------------------------------------
1987
+ C ZVSTEP performs one step of the integration of an initial value
1988
+ C problem for a system of ordinary differential equations.
1989
+ C ZVSTEP calls subroutine VNLS for the solution of the nonlinear system
1990
+ C arising in the time step. Thus it is independent of the problem
1991
+ C Jacobian structure and the type of nonlinear system solution method.
1992
+ C ZVSTEP returns a completion flag KFLAG (in COMMON).
1993
+ C A return with KFLAG = -1 or -2 means either ABS(H) = HMIN or 10
1994
+ C consecutive failures occurred. On a return with KFLAG negative,
1995
+ C the values of TN and the YH array are as of the beginning of the last
1996
+ C step, and H is the last step size attempted.
1997
+ C
1998
+ C Communication with ZVSTEP is done with the following variables:
1999
+ C
2000
+ C Y = An array of length N used for the dependent variable vector.
2001
+ C YH = An LDYH by LMAX array containing the dependent variables
2002
+ C and their approximate scaled derivatives, where
2003
+ C LMAX = MAXORD + 1. YH(i,j+1) contains the approximate
2004
+ C j-th derivative of y(i), scaled by H**j/factorial(j)
2005
+ C (j = 0,1,...,NQ). On entry for the first step, the first
2006
+ C two columns of YH must be set from the initial values.
2007
+ C LDYH = A constant integer .ge. N, the first dimension of YH.
2008
+ C N is the number of ODEs in the system.
2009
+ C YH1 = A one-dimensional array occupying the same space as YH.
2010
+ C EWT = An array of length N containing multiplicative weights
2011
+ C for local error measurements. Local errors in y(i) are
2012
+ C compared to 1.0/EWT(i) in various error tests.
2013
+ C SAVF = An array of working storage, of length N.
2014
+ C also used for input of YH(*,MAXORD+2) when JSTART = -1
2015
+ C and MAXORD .lt. the current order NQ.
2016
+ C VSAV = A work array of length N passed to subroutine VNLS.
2017
+ C ACOR = A work array of length N, used for the accumulated
2018
+ C corrections. On a successful return, ACOR(i) contains
2019
+ C the estimated one-step local error in y(i).
2020
+ C WM,IWM = Complex and integer work arrays associated with matrix
2021
+ C operations in VNLS.
2022
+ C F = Dummy name for the user-supplied subroutine for f.
2023
+ C JAC = Dummy name for the user-supplied Jacobian subroutine.
2024
+ C PSOL = Dummy name for the subroutine passed to VNLS, for
2025
+ C possible use there.
2026
+ C VNLS = Dummy name for the nonlinear system solving subroutine,
2027
+ C whose real name is dependent on the method used.
2028
+ C RPAR, IPAR = User's real/complex and integer work arrays.
2029
+ C-----------------------------------------------------------------------
2030
+ C
2031
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
2032
+ C
2033
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
2034
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2035
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
2036
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2037
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2038
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2039
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2040
+ 4 NSLP, NYH
2041
+ C
2042
+ C Type declarations for labeled COMMON block ZVOD02 --------------------
2043
+ C
2044
+ DOUBLE PRECISION HU
2045
+ INTEGER NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
2046
+ C
2047
+ C Type declarations for local variables --------------------------------
2048
+ C
2049
+ DOUBLE PRECISION ADDON, BIAS1,BIAS2,BIAS3, CNQUOT, DDN, DSM, DUP,
2050
+ 1 ETACF, ETAMIN, ETAMX1, ETAMX2, ETAMX3, ETAMXF,
2051
+ 2 ETAQ, ETAQM1, ETAQP1, FLOTL, ONE, ONEPSM,
2052
+ 3 R, THRESH, TOLD, ZERO
2053
+ INTEGER I, I1, I2, IBACK, J, JB, KFC, KFH, MXNCF, NCF, NFLAG
2054
+ C
2055
+ C Type declaration for function subroutines called ---------------------
2056
+ C
2057
+ DOUBLE PRECISION ZVNORM
2058
+ C-----------------------------------------------------------------------
2059
+ C The following Fortran-77 declaration is to cause the values of the
2060
+ C listed (local) variables to be saved between calls to this integrator.
2061
+ C-----------------------------------------------------------------------
2062
+ SAVE ADDON, BIAS1, BIAS2, BIAS3,
2063
+ 1 ETACF, ETAMIN, ETAMX1, ETAMX2, ETAMX3, ETAMXF, ETAQ, ETAQM1,
2064
+ 2 KFC, KFH, MXNCF, ONEPSM, THRESH, ONE, ZERO
2065
+ C-----------------------------------------------------------------------
2066
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
2067
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2068
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
2069
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2070
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2071
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2072
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2073
+ 7 NSLP, NYH
2074
+ COMMON /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
2075
+ C
2076
+ DATA KFC/-3/, KFH/-7/, MXNCF/10/
2077
+ DATA ADDON /1.0D-6/, BIAS1 /6.0D0/, BIAS2 /6.0D0/,
2078
+ 1 BIAS3 /10.0D0/, ETACF /0.25D0/, ETAMIN /0.1D0/,
2079
+ 2 ETAMXF /0.2D0/, ETAMX1 /1.0D4/, ETAMX2 /10.0D0/,
2080
+ 3 ETAMX3 /10.0D0/, ONEPSM /1.00001D0/, THRESH /1.5D0/
2081
+ DATA ONE/1.0D0/, ZERO/0.0D0/
2082
+ C
2083
+ KFLAG = 0
2084
+ TOLD = TN
2085
+ NCF = 0
2086
+ JCUR = 0
2087
+ NFLAG = 0
2088
+ IF (JSTART .GT. 0) GO TO 20
2089
+ IF (JSTART .EQ. -1) GO TO 100
2090
+ C-----------------------------------------------------------------------
2091
+ C On the first call, the order is set to 1, and other variables are
2092
+ C initialized. ETAMAX is the maximum ratio by which H can be increased
2093
+ C in a single step. It is normally 10, but is larger during the
2094
+ C first step to compensate for the small initial H. If a failure
2095
+ C occurs (in corrector convergence or error test), ETAMAX is set to 1
2096
+ C for the next increase.
2097
+ C-----------------------------------------------------------------------
2098
+ LMAX = MAXORD + 1
2099
+ NQ = 1
2100
+ L = 2
2101
+ NQNYH = NQ*LDYH
2102
+ TAU(1) = H
2103
+ PRL1 = ONE
2104
+ RC = ZERO
2105
+ ETAMAX = ETAMX1
2106
+ NQWAIT = 2
2107
+ HSCAL = H
2108
+ GO TO 200
2109
+ C-----------------------------------------------------------------------
2110
+ C Take preliminary actions on a normal continuation step (JSTART.GT.0).
2111
+ C If the driver changed H, then ETA must be reset and NEWH set to 1.
2112
+ C If a change of order was dictated on the previous step, then
2113
+ C it is done here and appropriate adjustments in the history are made.
2114
+ C On an order decrease, the history array is adjusted by ZVJUST.
2115
+ C On an order increase, the history array is augmented by a column.
2116
+ C On a change of step size H, the history array YH is rescaled.
2117
+ C-----------------------------------------------------------------------
2118
+ 20 CONTINUE
2119
+ IF (KUTH .EQ. 1) THEN
2120
+ ETA = MIN(ETA,H/HSCAL)
2121
+ NEWH = 1
2122
+ ENDIF
2123
+ 50 IF (NEWH .EQ. 0) GO TO 200
2124
+ IF (NEWQ .EQ. NQ) GO TO 150
2125
+ IF (NEWQ .LT. NQ) THEN
2126
+ CALL ZVJUST (YH, LDYH, -1)
2127
+ NQ = NEWQ
2128
+ L = NQ + 1
2129
+ NQWAIT = L
2130
+ GO TO 150
2131
+ ENDIF
2132
+ IF (NEWQ .GT. NQ) THEN
2133
+ CALL ZVJUST (YH, LDYH, 1)
2134
+ NQ = NEWQ
2135
+ L = NQ + 1
2136
+ NQWAIT = L
2137
+ GO TO 150
2138
+ ENDIF
2139
+ C-----------------------------------------------------------------------
2140
+ C The following block handles preliminaries needed when JSTART = -1.
2141
+ C If N was reduced, zero out part of YH to avoid undefined references.
2142
+ C If MAXORD was reduced to a value less than the tentative order NEWQ,
2143
+ C then NQ is set to MAXORD, and a new H ratio ETA is chosen.
2144
+ C Otherwise, we take the same preliminary actions as for JSTART .gt. 0.
2145
+ C In any case, NQWAIT is reset to L = NQ + 1 to prevent further
2146
+ C changes in order for that many steps.
2147
+ C The new H ratio ETA is limited by the input H if KUTH = 1,
2148
+ C by HMIN if KUTH = 0, and by HMXI in any case.
2149
+ C Finally, the history array YH is rescaled.
2150
+ C-----------------------------------------------------------------------
2151
+ 100 CONTINUE
2152
+ LMAX = MAXORD + 1
2153
+ IF (N .EQ. LDYH) GO TO 120
2154
+ I1 = 1 + (NEWQ + 1)*LDYH
2155
+ I2 = (MAXORD + 1)*LDYH
2156
+ IF (I1 .GT. I2) GO TO 120
2157
+ DO 110 I = I1, I2
2158
+ 110 YH1(I) = ZERO
2159
+ 120 IF (NEWQ .LE. MAXORD) GO TO 140
2160
+ FLOTL = REAL(LMAX)
2161
+ IF (MAXORD .LT. NQ-1) THEN
2162
+ DDN = ZVNORM (N, SAVF, EWT)/TQ(1)
2163
+ ETA = ONE/((BIAS1*DDN)**(ONE/FLOTL) + ADDON)
2164
+ ENDIF
2165
+ IF (MAXORD .EQ. NQ .AND. NEWQ .EQ. NQ+1) ETA = ETAQ
2166
+ IF (MAXORD .EQ. NQ-1 .AND. NEWQ .EQ. NQ+1) THEN
2167
+ ETA = ETAQM1
2168
+ CALL ZVJUST (YH, LDYH, -1)
2169
+ ENDIF
2170
+ IF (MAXORD .EQ. NQ-1 .AND. NEWQ .EQ. NQ) THEN
2171
+ DDN = ZVNORM (N, SAVF, EWT)/TQ(1)
2172
+ ETA = ONE/((BIAS1*DDN)**(ONE/FLOTL) + ADDON)
2173
+ CALL ZVJUST (YH, LDYH, -1)
2174
+ ENDIF
2175
+ ETA = MIN(ETA,ONE)
2176
+ NQ = MAXORD
2177
+ L = LMAX
2178
+ 140 IF (KUTH .EQ. 1) ETA = MIN(ETA,ABS(H/HSCAL))
2179
+ IF (KUTH .EQ. 0) ETA = MAX(ETA,HMIN/ABS(HSCAL))
2180
+ ETA = ETA/MAX(ONE,ABS(HSCAL)*HMXI*ETA)
2181
+ NEWH = 1
2182
+ NQWAIT = L
2183
+ IF (NEWQ .LE. MAXORD) GO TO 50
2184
+ C Rescale the history array for a change in H by a factor of ETA. ------
2185
+ 150 R = ONE
2186
+ DO 180 J = 2, L
2187
+ R = R*ETA
2188
+ CALL DZSCAL (N, R, YH(1,J), 1 )
2189
+ 180 CONTINUE
2190
+ H = HSCAL*ETA
2191
+ HSCAL = H
2192
+ RC = RC*ETA
2193
+ NQNYH = NQ*LDYH
2194
+ C-----------------------------------------------------------------------
2195
+ C This section computes the predicted values by effectively
2196
+ C multiplying the YH array by the Pascal triangle matrix.
2197
+ C ZVSET is called to calculate all integration coefficients.
2198
+ C RC is the ratio of new to old values of the coefficient H/EL(2)=h/l1.
2199
+ C-----------------------------------------------------------------------
2200
+ 200 TN = TN + H
2201
+ I1 = NQNYH + 1
2202
+ DO 220 JB = 1, NQ
2203
+ I1 = I1 - LDYH
2204
+ DO 210 I = I1, NQNYH
2205
+ 210 YH1(I) = YH1(I) + YH1(I+LDYH)
2206
+ 220 CONTINUE
2207
+ CALL ZVSET
2208
+ RL1 = ONE/EL(2)
2209
+ RC = RC*(RL1/PRL1)
2210
+ PRL1 = RL1
2211
+ C
2212
+ C Call the nonlinear system solver. ------------------------------------
2213
+ C
2214
+ CALL VNLS (Y, YH, LDYH, VSAV, SAVF, EWT, ACOR, IWM, WM,
2215
+ 1 F, JAC, PSOL, NFLAG, RPAR, IPAR)
2216
+ C
2217
+ IF (NFLAG .EQ. 0) GO TO 450
2218
+ C-----------------------------------------------------------------------
2219
+ C The VNLS routine failed to achieve convergence (NFLAG .NE. 0).
2220
+ C The YH array is retracted to its values before prediction.
2221
+ C The step size H is reduced and the step is retried, if possible.
2222
+ C Otherwise, an error exit is taken.
2223
+ C-----------------------------------------------------------------------
2224
+ NCF = NCF + 1
2225
+ NCFN = NCFN + 1
2226
+ ETAMAX = ONE
2227
+ TN = TOLD
2228
+ I1 = NQNYH + 1
2229
+ DO 430 JB = 1, NQ
2230
+ I1 = I1 - LDYH
2231
+ DO 420 I = I1, NQNYH
2232
+ 420 YH1(I) = YH1(I) - YH1(I+LDYH)
2233
+ 430 CONTINUE
2234
+ IF (NFLAG .LT. -1) GO TO 680
2235
+ IF (ABS(H) .LE. HMIN*ONEPSM) GO TO 670
2236
+ IF (NCF .EQ. MXNCF) GO TO 670
2237
+ ETA = ETACF
2238
+ ETA = MAX(ETA,HMIN/ABS(H))
2239
+ NFLAG = -1
2240
+ GO TO 150
2241
+ C-----------------------------------------------------------------------
2242
+ C The corrector has converged (NFLAG = 0). The local error test is
2243
+ C made and control passes to statement 500 if it fails.
2244
+ C-----------------------------------------------------------------------
2245
+ 450 CONTINUE
2246
+ DSM = ACNRM/TQ(2)
2247
+ IF (DSM .GT. ONE) GO TO 500
2248
+ C-----------------------------------------------------------------------
2249
+ C After a successful step, update the YH and TAU arrays and decrement
2250
+ C NQWAIT. If NQWAIT is then 1 and NQ .lt. MAXORD, then ACOR is saved
2251
+ C for use in a possible order increase on the next step.
2252
+ C If ETAMAX = 1 (a failure occurred this step), keep NQWAIT .ge. 2.
2253
+ C-----------------------------------------------------------------------
2254
+ KFLAG = 0
2255
+ NST = NST + 1
2256
+ HU = H
2257
+ NQU = NQ
2258
+ DO 470 IBACK = 1, NQ
2259
+ I = L - IBACK
2260
+ 470 TAU(I+1) = TAU(I)
2261
+ TAU(1) = H
2262
+ DO 480 J = 1, L
2263
+ CALL DZAXPY (N, EL(J), ACOR, 1, YH(1,J), 1 )
2264
+ 480 CONTINUE
2265
+ NQWAIT = NQWAIT - 1
2266
+ IF ((L .EQ. LMAX) .OR. (NQWAIT .NE. 1)) GO TO 490
2267
+ CALL ZCOPY (N, ACOR, 1, YH(1,LMAX), 1 )
2268
+ CONP = TQ(5)
2269
+ 490 IF (ETAMAX .NE. ONE) GO TO 560
2270
+ IF (NQWAIT .LT. 2) NQWAIT = 2
2271
+ NEWQ = NQ
2272
+ NEWH = 0
2273
+ ETA = ONE
2274
+ HNEW = H
2275
+ GO TO 690
2276
+ C-----------------------------------------------------------------------
2277
+ C The error test failed. KFLAG keeps track of multiple failures.
2278
+ C Restore TN and the YH array to their previous values, and prepare
2279
+ C to try the step again. Compute the optimum step size for the
2280
+ C same order. After repeated failures, H is forced to decrease
2281
+ C more rapidly.
2282
+ C-----------------------------------------------------------------------
2283
+ 500 KFLAG = KFLAG - 1
2284
+ NETF = NETF + 1
2285
+ NFLAG = -2
2286
+ TN = TOLD
2287
+ I1 = NQNYH + 1
2288
+ DO 520 JB = 1, NQ
2289
+ I1 = I1 - LDYH
2290
+ DO 510 I = I1, NQNYH
2291
+ 510 YH1(I) = YH1(I) - YH1(I+LDYH)
2292
+ 520 CONTINUE
2293
+ IF (ABS(H) .LE. HMIN*ONEPSM) GO TO 660
2294
+ ETAMAX = ONE
2295
+ IF (KFLAG .LE. KFC) GO TO 530
2296
+ C Compute ratio of new H to current H at the current order. ------------
2297
+ FLOTL = REAL(L)
2298
+ ETA = ONE/((BIAS2*DSM)**(ONE/FLOTL) + ADDON)
2299
+ ETA = MAX(ETA,HMIN/ABS(H),ETAMIN)
2300
+ IF ((KFLAG .LE. -2) .AND. (ETA .GT. ETAMXF)) ETA = ETAMXF
2301
+ GO TO 150
2302
+ C-----------------------------------------------------------------------
2303
+ C Control reaches this section if 3 or more consecutive failures
2304
+ C have occurred. It is assumed that the elements of the YH array
2305
+ C have accumulated errors of the wrong order. The order is reduced
2306
+ C by one, if possible. Then H is reduced by a factor of 0.1 and
2307
+ C the step is retried. After a total of 7 consecutive failures,
2308
+ C an exit is taken with KFLAG = -1.
2309
+ C-----------------------------------------------------------------------
2310
+ 530 IF (KFLAG .EQ. KFH) GO TO 660
2311
+ IF (NQ .EQ. 1) GO TO 540
2312
+ ETA = MAX(ETAMIN,HMIN/ABS(H))
2313
+ CALL ZVJUST (YH, LDYH, -1)
2314
+ L = NQ
2315
+ NQ = NQ - 1
2316
+ NQWAIT = L
2317
+ GO TO 150
2318
+ 540 ETA = MAX(ETAMIN,HMIN/ABS(H))
2319
+ H = H*ETA
2320
+ HSCAL = H
2321
+ TAU(1) = H
2322
+ CALL F (N, TN, Y, SAVF, RPAR, IPAR)
2323
+ NFE = NFE + 1
2324
+ DO 550 I = 1, N
2325
+ 550 YH(I,2) = H*SAVF(I)
2326
+ NQWAIT = 10
2327
+ GO TO 200
2328
+ C-----------------------------------------------------------------------
2329
+ C If NQWAIT = 0, an increase or decrease in order by one is considered.
2330
+ C Factors ETAQ, ETAQM1, ETAQP1 are computed by which H could
2331
+ C be multiplied at order q, q-1, or q+1, respectively.
2332
+ C The largest of these is determined, and the new order and
2333
+ C step size set accordingly.
2334
+ C A change of H or NQ is made only if H increases by at least a
2335
+ C factor of THRESH. If an order change is considered and rejected,
2336
+ C then NQWAIT is set to 2 (reconsider it after 2 steps).
2337
+ C-----------------------------------------------------------------------
2338
+ C Compute ratio of new H to current H at the current order. ------------
2339
+ 560 FLOTL = REAL(L)
2340
+ ETAQ = ONE/((BIAS2*DSM)**(ONE/FLOTL) + ADDON)
2341
+ IF (NQWAIT .NE. 0) GO TO 600
2342
+ NQWAIT = 2
2343
+ ETAQM1 = ZERO
2344
+ IF (NQ .EQ. 1) GO TO 570
2345
+ C Compute ratio of new H to current H at the current order less one. ---
2346
+ DDN = ZVNORM (N, YH(1,L), EWT)/TQ(1)
2347
+ ETAQM1 = ONE/((BIAS1*DDN)**(ONE/(FLOTL - ONE)) + ADDON)
2348
+ 570 ETAQP1 = ZERO
2349
+ IF (L .EQ. LMAX) GO TO 580
2350
+ C Compute ratio of new H to current H at current order plus one. -------
2351
+ CNQUOT = (TQ(5)/CONP)*(H/TAU(2))**L
2352
+ DO 575 I = 1, N
2353
+ 575 SAVF(I) = ACOR(I) - CNQUOT*YH(I,LMAX)
2354
+ DUP = ZVNORM (N, SAVF, EWT)/TQ(3)
2355
+ ETAQP1 = ONE/((BIAS3*DUP)**(ONE/(FLOTL + ONE)) + ADDON)
2356
+ 580 IF (ETAQ .GE. ETAQP1) GO TO 590
2357
+ IF (ETAQP1 .GT. ETAQM1) GO TO 620
2358
+ GO TO 610
2359
+ 590 IF (ETAQ .LT. ETAQM1) GO TO 610
2360
+ 600 ETA = ETAQ
2361
+ NEWQ = NQ
2362
+ GO TO 630
2363
+ 610 ETA = ETAQM1
2364
+ NEWQ = NQ - 1
2365
+ GO TO 630
2366
+ 620 ETA = ETAQP1
2367
+ NEWQ = NQ + 1
2368
+ CALL ZCOPY (N, ACOR, 1, YH(1,LMAX), 1)
2369
+ C Test tentative new H against THRESH, ETAMAX, and HMXI, then exit. ----
2370
+ 630 IF (ETA .LT. THRESH .OR. ETAMAX .EQ. ONE) GO TO 640
2371
+ ETA = MIN(ETA,ETAMAX)
2372
+ ETA = ETA/MAX(ONE,ABS(H)*HMXI*ETA)
2373
+ NEWH = 1
2374
+ HNEW = H*ETA
2375
+ GO TO 690
2376
+ 640 NEWQ = NQ
2377
+ NEWH = 0
2378
+ ETA = ONE
2379
+ HNEW = H
2380
+ GO TO 690
2381
+ C-----------------------------------------------------------------------
2382
+ C All returns are made through this section.
2383
+ C On a successful return, ETAMAX is reset and ACOR is scaled.
2384
+ C-----------------------------------------------------------------------
2385
+ 660 KFLAG = -1
2386
+ GO TO 720
2387
+ 670 KFLAG = -2
2388
+ GO TO 720
2389
+ 680 IF (NFLAG .EQ. -2) KFLAG = -3
2390
+ IF (NFLAG .EQ. -3) KFLAG = -4
2391
+ GO TO 720
2392
+ 690 ETAMAX = ETAMX3
2393
+ IF (NST .LE. 10) ETAMAX = ETAMX2
2394
+ 700 R = ONE/TQ(2)
2395
+ CALL DZSCAL (N, R, ACOR, 1)
2396
+ 720 JSTART = 1
2397
+ RETURN
2398
+ C----------------------- End of Subroutine ZVSTEP ----------------------
2399
+ END
2400
+ *DECK ZVSET
2401
+ SUBROUTINE ZVSET
2402
+ C-----------------------------------------------------------------------
2403
+ C Call sequence communication: None
2404
+ C COMMON block variables accessed:
2405
+ C /ZVOD01/ -- EL(13), H, TAU(13), TQ(5), L(= NQ + 1),
2406
+ C METH, NQ, NQWAIT
2407
+ C
2408
+ C Subroutines called by ZVSET: None
2409
+ C Function routines called by ZVSET: None
2410
+ C-----------------------------------------------------------------------
2411
+ C ZVSET is called by ZVSTEP and sets coefficients for use there.
2412
+ C
2413
+ C For each order NQ, the coefficients in EL are calculated by use of
2414
+ C the generating polynomial lambda(x), with coefficients EL(i).
2415
+ C lambda(x) = EL(1) + EL(2)*x + ... + EL(NQ+1)*(x**NQ).
2416
+ C For the backward differentiation formulas,
2417
+ C NQ-1
2418
+ C lambda(x) = (1 + x/xi*(NQ)) * product (1 + x/xi(i) ) .
2419
+ C i = 1
2420
+ C For the Adams formulas,
2421
+ C NQ-1
2422
+ C (d/dx) lambda(x) = c * product (1 + x/xi(i) ) ,
2423
+ C i = 1
2424
+ C lambda(-1) = 0, lambda(0) = 1,
2425
+ C where c is a normalization constant.
2426
+ C In both cases, xi(i) is defined by
2427
+ C H*xi(i) = t sub n - t sub (n-i)
2428
+ C = H + TAU(1) + TAU(2) + ... TAU(i-1).
2429
+ C
2430
+ C
2431
+ C In addition to variables described previously, communication
2432
+ C with ZVSET uses the following:
2433
+ C TAU = A vector of length 13 containing the past NQ values
2434
+ C of H.
2435
+ C EL = A vector of length 13 in which vset stores the
2436
+ C coefficients for the corrector formula.
2437
+ C TQ = A vector of length 5 in which vset stores constants
2438
+ C used for the convergence test, the error test, and the
2439
+ C selection of H at a new order.
2440
+ C METH = The basic method indicator.
2441
+ C NQ = The current order.
2442
+ C L = NQ + 1, the length of the vector stored in EL, and
2443
+ C the number of columns of the YH array being used.
2444
+ C NQWAIT = A counter controlling the frequency of order changes.
2445
+ C An order change is about to be considered if NQWAIT = 1.
2446
+ C-----------------------------------------------------------------------
2447
+ C
2448
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
2449
+ C
2450
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
2451
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2452
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
2453
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2454
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2455
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2456
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2457
+ 4 NSLP, NYH
2458
+ C
2459
+ C Type declarations for local variables --------------------------------
2460
+ C
2461
+ DOUBLE PRECISION AHATN0, ALPH0, CNQM1, CORTES, CSUM, ELP, EM,
2462
+ 1 EM0, FLOTI, FLOTL, FLOTNQ, HSUM, ONE, RXI, RXIS, S, SIX,
2463
+ 2 T1, T2, T3, T4, T5, T6, TWO, XI, ZERO
2464
+ INTEGER I, IBACK, J, JP1, NQM1, NQM2
2465
+ C
2466
+ DIMENSION EM(13)
2467
+ C-----------------------------------------------------------------------
2468
+ C The following Fortran-77 declaration is to cause the values of the
2469
+ C listed (local) variables to be saved between calls to this integrator.
2470
+ C-----------------------------------------------------------------------
2471
+ SAVE CORTES, ONE, SIX, TWO, ZERO
2472
+ C
2473
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
2474
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2475
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
2476
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2477
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2478
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2479
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2480
+ 7 NSLP, NYH
2481
+ C
2482
+ DATA CORTES /0.1D0/
2483
+ DATA ONE /1.0D0/, SIX /6.0D0/, TWO /2.0D0/, ZERO /0.0D0/
2484
+ C
2485
+ FLOTL = REAL(L)
2486
+ NQM1 = NQ - 1
2487
+ NQM2 = NQ - 2
2488
+ GO TO (100, 200), METH
2489
+ C
2490
+ C Set coefficients for Adams methods. ----------------------------------
2491
+ 100 IF (NQ .NE. 1) GO TO 110
2492
+ EL(1) = ONE
2493
+ EL(2) = ONE
2494
+ TQ(1) = ONE
2495
+ TQ(2) = TWO
2496
+ TQ(3) = SIX*TQ(2)
2497
+ TQ(5) = ONE
2498
+ GO TO 300
2499
+ 110 HSUM = H
2500
+ EM(1) = ONE
2501
+ FLOTNQ = FLOTL - ONE
2502
+ DO 115 I = 2, L
2503
+ 115 EM(I) = ZERO
2504
+ DO 150 J = 1, NQM1
2505
+ IF ((J .NE. NQM1) .OR. (NQWAIT .NE. 1)) GO TO 130
2506
+ S = ONE
2507
+ CSUM = ZERO
2508
+ DO 120 I = 1, NQM1
2509
+ CSUM = CSUM + S*EM(I)/REAL(I+1)
2510
+ 120 S = -S
2511
+ TQ(1) = EM(NQM1)/(FLOTNQ*CSUM)
2512
+ 130 RXI = H/HSUM
2513
+ DO 140 IBACK = 1, J
2514
+ I = (J + 2) - IBACK
2515
+ 140 EM(I) = EM(I) + EM(I-1)*RXI
2516
+ HSUM = HSUM + TAU(J)
2517
+ 150 CONTINUE
2518
+ C Compute integral from -1 to 0 of polynomial and of x times it. -------
2519
+ S = ONE
2520
+ EM0 = ZERO
2521
+ CSUM = ZERO
2522
+ DO 160 I = 1, NQ
2523
+ FLOTI = REAL(I)
2524
+ EM0 = EM0 + S*EM(I)/FLOTI
2525
+ CSUM = CSUM + S*EM(I)/(FLOTI+ONE)
2526
+ 160 S = -S
2527
+ C In EL, form coefficients of normalized integrated polynomial. --------
2528
+ S = ONE/EM0
2529
+ EL(1) = ONE
2530
+ DO 170 I = 1, NQ
2531
+ 170 EL(I+1) = S*EM(I)/REAL(I)
2532
+ XI = HSUM/H
2533
+ TQ(2) = XI*EM0/CSUM
2534
+ TQ(5) = XI/EL(L)
2535
+ IF (NQWAIT .NE. 1) GO TO 300
2536
+ C For higher order control constant, multiply polynomial by 1+x/xi(q). -
2537
+ RXI = ONE/XI
2538
+ DO 180 IBACK = 1, NQ
2539
+ I = (L + 1) - IBACK
2540
+ 180 EM(I) = EM(I) + EM(I-1)*RXI
2541
+ C Compute integral of polynomial. --------------------------------------
2542
+ S = ONE
2543
+ CSUM = ZERO
2544
+ DO 190 I = 1, L
2545
+ CSUM = CSUM + S*EM(I)/REAL(I+1)
2546
+ 190 S = -S
2547
+ TQ(3) = FLOTL*EM0/CSUM
2548
+ GO TO 300
2549
+ C
2550
+ C Set coefficients for BDF methods. ------------------------------------
2551
+ 200 DO 210 I = 3, L
2552
+ 210 EL(I) = ZERO
2553
+ EL(1) = ONE
2554
+ EL(2) = ONE
2555
+ ALPH0 = -ONE
2556
+ AHATN0 = -ONE
2557
+ HSUM = H
2558
+ RXI = ONE
2559
+ RXIS = ONE
2560
+ IF (NQ .EQ. 1) GO TO 240
2561
+ DO 230 J = 1, NQM2
2562
+ C In EL, construct coefficients of (1+x/xi(1))*...*(1+x/xi(j+1)). ------
2563
+ HSUM = HSUM + TAU(J)
2564
+ RXI = H/HSUM
2565
+ JP1 = J + 1
2566
+ ALPH0 = ALPH0 - ONE/REAL(JP1)
2567
+ DO 220 IBACK = 1, JP1
2568
+ I = (J + 3) - IBACK
2569
+ 220 EL(I) = EL(I) + EL(I-1)*RXI
2570
+ 230 CONTINUE
2571
+ ALPH0 = ALPH0 - ONE/REAL(NQ)
2572
+ RXIS = -EL(2) - ALPH0
2573
+ HSUM = HSUM + TAU(NQM1)
2574
+ RXI = H/HSUM
2575
+ AHATN0 = -EL(2) - RXI
2576
+ DO 235 IBACK = 1, NQ
2577
+ I = (NQ + 2) - IBACK
2578
+ 235 EL(I) = EL(I) + EL(I-1)*RXIS
2579
+ 240 T1 = ONE - AHATN0 + ALPH0
2580
+ T2 = ONE + REAL(NQ)*T1
2581
+ TQ(2) = ABS(ALPH0*T2/T1)
2582
+ TQ(5) = ABS(T2/(EL(L)*RXI/RXIS))
2583
+ IF (NQWAIT .NE. 1) GO TO 300
2584
+ CNQM1 = RXIS/EL(L)
2585
+ T3 = ALPH0 + ONE/REAL(NQ)
2586
+ T4 = AHATN0 + RXI
2587
+ ELP = T3/(ONE - T4 + T3)
2588
+ TQ(1) = ABS(ELP/CNQM1)
2589
+ HSUM = HSUM + TAU(NQ)
2590
+ RXI = H/HSUM
2591
+ T5 = ALPH0 - ONE/REAL(NQ+1)
2592
+ T6 = AHATN0 - RXI
2593
+ ELP = T2/(ONE - T6 + T5)
2594
+ TQ(3) = ABS(ELP*RXI*(FLOTL + ONE)*T5)
2595
+ 300 TQ(4) = CORTES*TQ(2)
2596
+ RETURN
2597
+ C----------------------- End of Subroutine ZVSET -----------------------
2598
+ END
2599
+ *DECK ZVJUST
2600
+ SUBROUTINE ZVJUST (YH, LDYH, IORD)
2601
+ DOUBLE COMPLEX YH
2602
+ INTEGER LDYH, IORD
2603
+ DIMENSION YH(LDYH,*)
2604
+ C-----------------------------------------------------------------------
2605
+ C Call sequence input -- YH, LDYH, IORD
2606
+ C Call sequence output -- YH
2607
+ C COMMON block input -- NQ, METH, LMAX, HSCAL, TAU(13), N
2608
+ C COMMON block variables accessed:
2609
+ C /ZVOD01/ -- HSCAL, TAU(13), LMAX, METH, N, NQ,
2610
+ C
2611
+ C Subroutines called by ZVJUST: DZAXPY
2612
+ C Function routines called by ZVJUST: None
2613
+ C-----------------------------------------------------------------------
2614
+ C This subroutine adjusts the YH array on reduction of order,
2615
+ C and also when the order is increased for the stiff option (METH = 2).
2616
+ C Communication with ZVJUST uses the following:
2617
+ C IORD = An integer flag used when METH = 2 to indicate an order
2618
+ C increase (IORD = +1) or an order decrease (IORD = -1).
2619
+ C HSCAL = Step size H used in scaling of Nordsieck array YH.
2620
+ C (If IORD = +1, ZVJUST assumes that HSCAL = TAU(1).)
2621
+ C See References 1 and 2 for details.
2622
+ C-----------------------------------------------------------------------
2623
+ C
2624
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
2625
+ C
2626
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
2627
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2628
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
2629
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2630
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2631
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2632
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2633
+ 4 NSLP, NYH
2634
+ C
2635
+ C Type declarations for local variables --------------------------------
2636
+ C
2637
+ DOUBLE PRECISION ALPH0, ALPH1, HSUM, ONE, PROD, T1, XI,XIOLD, ZERO
2638
+ INTEGER I, IBACK, J, JP1, LP1, NQM1, NQM2, NQP1
2639
+ C-----------------------------------------------------------------------
2640
+ C The following Fortran-77 declaration is to cause the values of the
2641
+ C listed (local) variables to be saved between calls to this integrator.
2642
+ C-----------------------------------------------------------------------
2643
+ SAVE ONE, ZERO
2644
+ C
2645
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
2646
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2647
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
2648
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2649
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2650
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2651
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2652
+ 7 NSLP, NYH
2653
+ C
2654
+ DATA ONE /1.0D0/, ZERO /0.0D0/
2655
+ C
2656
+ IF ((NQ .EQ. 2) .AND. (IORD .NE. 1)) RETURN
2657
+ NQM1 = NQ - 1
2658
+ NQM2 = NQ - 2
2659
+ GO TO (100, 200), METH
2660
+ C-----------------------------------------------------------------------
2661
+ C Nonstiff option...
2662
+ C Check to see if the order is being increased or decreased.
2663
+ C-----------------------------------------------------------------------
2664
+ 100 CONTINUE
2665
+ IF (IORD .EQ. 1) GO TO 180
2666
+ C Order decrease. ------------------------------------------------------
2667
+ DO 110 J = 1, LMAX
2668
+ 110 EL(J) = ZERO
2669
+ EL(2) = ONE
2670
+ HSUM = ZERO
2671
+ DO 130 J = 1, NQM2
2672
+ C Construct coefficients of x*(x+xi(1))*...*(x+xi(j)). -----------------
2673
+ HSUM = HSUM + TAU(J)
2674
+ XI = HSUM/HSCAL
2675
+ JP1 = J + 1
2676
+ DO 120 IBACK = 1, JP1
2677
+ I = (J + 3) - IBACK
2678
+ 120 EL(I) = EL(I)*XI + EL(I-1)
2679
+ 130 CONTINUE
2680
+ C Construct coefficients of integrated polynomial. ---------------------
2681
+ DO 140 J = 2, NQM1
2682
+ 140 EL(J+1) = REAL(NQ)*EL(J)/REAL(J)
2683
+ C Subtract correction terms from YH array. -----------------------------
2684
+ DO 170 J = 3, NQ
2685
+ DO 160 I = 1, N
2686
+ 160 YH(I,J) = YH(I,J) - YH(I,L)*EL(J)
2687
+ 170 CONTINUE
2688
+ RETURN
2689
+ C Order increase. ------------------------------------------------------
2690
+ C Zero out next column in YH array. ------------------------------------
2691
+ 180 CONTINUE
2692
+ LP1 = L + 1
2693
+ DO 190 I = 1, N
2694
+ 190 YH(I,LP1) = ZERO
2695
+ RETURN
2696
+ C-----------------------------------------------------------------------
2697
+ C Stiff option...
2698
+ C Check to see if the order is being increased or decreased.
2699
+ C-----------------------------------------------------------------------
2700
+ 200 CONTINUE
2701
+ IF (IORD .EQ. 1) GO TO 300
2702
+ C Order decrease. ------------------------------------------------------
2703
+ DO 210 J = 1, LMAX
2704
+ 210 EL(J) = ZERO
2705
+ EL(3) = ONE
2706
+ HSUM = ZERO
2707
+ DO 230 J = 1,NQM2
2708
+ C Construct coefficients of x*x*(x+xi(1))*...*(x+xi(j)). ---------------
2709
+ HSUM = HSUM + TAU(J)
2710
+ XI = HSUM/HSCAL
2711
+ JP1 = J + 1
2712
+ DO 220 IBACK = 1, JP1
2713
+ I = (J + 4) - IBACK
2714
+ 220 EL(I) = EL(I)*XI + EL(I-1)
2715
+ 230 CONTINUE
2716
+ C Subtract correction terms from YH array. -----------------------------
2717
+ DO 250 J = 3,NQ
2718
+ DO 240 I = 1, N
2719
+ 240 YH(I,J) = YH(I,J) - YH(I,L)*EL(J)
2720
+ 250 CONTINUE
2721
+ RETURN
2722
+ C Order increase. ------------------------------------------------------
2723
+ 300 DO 310 J = 1, LMAX
2724
+ 310 EL(J) = ZERO
2725
+ EL(3) = ONE
2726
+ ALPH0 = -ONE
2727
+ ALPH1 = ONE
2728
+ PROD = ONE
2729
+ XIOLD = ONE
2730
+ HSUM = HSCAL
2731
+ IF (NQ .EQ. 1) GO TO 340
2732
+ DO 330 J = 1, NQM1
2733
+ C Construct coefficients of x*x*(x+xi(1))*...*(x+xi(j)). ---------------
2734
+ JP1 = J + 1
2735
+ HSUM = HSUM + TAU(JP1)
2736
+ XI = HSUM/HSCAL
2737
+ PROD = PROD*XI
2738
+ ALPH0 = ALPH0 - ONE/REAL(JP1)
2739
+ ALPH1 = ALPH1 + ONE/XI
2740
+ DO 320 IBACK = 1, JP1
2741
+ I = (J + 4) - IBACK
2742
+ 320 EL(I) = EL(I)*XIOLD + EL(I-1)
2743
+ XIOLD = XI
2744
+ 330 CONTINUE
2745
+ 340 CONTINUE
2746
+ T1 = (-ALPH0 - ALPH1)/PROD
2747
+ C Load column L + 1 in YH array. ---------------------------------------
2748
+ LP1 = L + 1
2749
+ DO 350 I = 1, N
2750
+ 350 YH(I,LP1) = T1*YH(I,LMAX)
2751
+ C Add correction terms to YH array. ------------------------------------
2752
+ NQP1 = NQ + 1
2753
+ DO 370 J = 3, NQP1
2754
+ CALL DZAXPY (N, EL(J), YH(1,LP1), 1, YH(1,J), 1 )
2755
+ 370 CONTINUE
2756
+ RETURN
2757
+ C----------------------- End of Subroutine ZVJUST ----------------------
2758
+ END
2759
+ *DECK ZVNLSD
2760
+ SUBROUTINE ZVNLSD (Y, YH, LDYH, VSAV, SAVF, EWT, ACOR, IWM, WM,
2761
+ 1 F, JAC, PDUM, NFLAG, RPAR, IPAR)
2762
+ EXTERNAL F, JAC, PDUM
2763
+ DOUBLE COMPLEX Y, YH, VSAV, SAVF, ACOR, WM
2764
+ DOUBLE PRECISION EWT
2765
+ INTEGER LDYH, IWM, NFLAG, IPAR
2766
+ DIMENSION Y(*), YH(LDYH,*), VSAV(*), SAVF(*), EWT(*), ACOR(*),
2767
+ 1 IWM(*), WM(*), RPAR(*), IPAR(*)
2768
+ C-----------------------------------------------------------------------
2769
+ C Call sequence input -- Y, YH, LDYH, SAVF, EWT, ACOR, IWM, WM,
2770
+ C F, JAC, NFLAG, RPAR, IPAR
2771
+ C Call sequence output -- YH, ACOR, WM, IWM, NFLAG
2772
+ C COMMON block variables accessed:
2773
+ C /ZVOD01/ ACNRM, CRATE, DRC, H, RC, RL1, TQ(5), TN, ICF,
2774
+ C JCUR, METH, MITER, N, NSLP
2775
+ C /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
2776
+ C
2777
+ C Subroutines called by ZVNLSD: F, DZAXPY, ZCOPY, DZSCAL, ZVJAC, ZVSOL
2778
+ C Function routines called by ZVNLSD: ZVNORM
2779
+ C-----------------------------------------------------------------------
2780
+ C Subroutine ZVNLSD is a nonlinear system solver, which uses functional
2781
+ C iteration or a chord (modified Newton) method. For the chord method
2782
+ C direct linear algebraic system solvers are used. Subroutine ZVNLSD
2783
+ C then handles the corrector phase of this integration package.
2784
+ C
2785
+ C Communication with ZVNLSD is done with the following variables. (For
2786
+ C more details, please see the comments in the driver subroutine.)
2787
+ C
2788
+ C Y = The dependent variable, a vector of length N, input.
2789
+ C YH = The Nordsieck (Taylor) array, LDYH by LMAX, input
2790
+ C and output. On input, it contains predicted values.
2791
+ C LDYH = A constant .ge. N, the first dimension of YH, input.
2792
+ C VSAV = Unused work array.
2793
+ C SAVF = A work array of length N.
2794
+ C EWT = An error weight vector of length N, input.
2795
+ C ACOR = A work array of length N, used for the accumulated
2796
+ C corrections to the predicted y vector.
2797
+ C WM,IWM = Complex and integer work arrays associated with matrix
2798
+ C operations in chord iteration (MITER .ne. 0).
2799
+ C F = Dummy name for user-supplied routine for f.
2800
+ C JAC = Dummy name for user-supplied Jacobian routine.
2801
+ C PDUM = Unused dummy subroutine name. Included for uniformity
2802
+ C over collection of integrators.
2803
+ C NFLAG = Input/output flag, with values and meanings as follows:
2804
+ C INPUT
2805
+ C 0 first call for this time step.
2806
+ C -1 convergence failure in previous call to ZVNLSD.
2807
+ C -2 error test failure in ZVSTEP.
2808
+ C OUTPUT
2809
+ C 0 successful completion of nonlinear solver.
2810
+ C -1 convergence failure or singular matrix.
2811
+ C -2 unrecoverable error in matrix preprocessing
2812
+ C (cannot occur here).
2813
+ C -3 unrecoverable error in solution (cannot occur
2814
+ C here).
2815
+ C RPAR, IPAR = User's real/complex and integer work arrays.
2816
+ C
2817
+ C IPUP = Own variable flag with values and meanings as follows:
2818
+ C 0, do not update the Newton matrix.
2819
+ C MITER .ne. 0, update Newton matrix, because it is the
2820
+ C initial step, order was changed, the error
2821
+ C test failed, or an update is indicated by
2822
+ C the scalar RC or step counter NST.
2823
+ C
2824
+ C For more details, see comments in driver subroutine.
2825
+ C-----------------------------------------------------------------------
2826
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
2827
+ C
2828
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
2829
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2830
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
2831
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2832
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2833
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2834
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2835
+ 4 NSLP, NYH
2836
+ C
2837
+ C Type declarations for labeled COMMON block ZVOD02 --------------------
2838
+ C
2839
+ DOUBLE PRECISION HU
2840
+ INTEGER NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
2841
+ C
2842
+ C Type declarations for local variables --------------------------------
2843
+ C
2844
+ DOUBLE PRECISION CCMAX, CRDOWN, CSCALE, DCON, DEL, DELP, ONE,
2845
+ 1 RDIV, TWO, ZERO
2846
+ INTEGER I, IERPJ, IERSL, M, MAXCOR, MSBP
2847
+ C
2848
+ C Type declaration for function subroutines called ---------------------
2849
+ C
2850
+ DOUBLE PRECISION ZVNORM
2851
+ C-----------------------------------------------------------------------
2852
+ C The following Fortran-77 declaration is to cause the values of the
2853
+ C listed (local) variables to be saved between calls to this integrator.
2854
+ C-----------------------------------------------------------------------
2855
+ SAVE CCMAX, CRDOWN, MAXCOR, MSBP, RDIV, ONE, TWO, ZERO
2856
+ C
2857
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
2858
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
2859
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
2860
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
2861
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
2862
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
2863
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
2864
+ 7 NSLP, NYH
2865
+ COMMON /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
2866
+ C
2867
+ DATA CCMAX /0.3D0/, CRDOWN /0.3D0/, MAXCOR /3/, MSBP /20/,
2868
+ 1 RDIV /2.0D0/
2869
+ DATA ONE /1.0D0/, TWO /2.0D0/, ZERO /0.0D0/
2870
+ C-----------------------------------------------------------------------
2871
+ C On the first step, on a change of method order, or after a
2872
+ C nonlinear convergence failure with NFLAG = -2, set IPUP = MITER
2873
+ C to force a Jacobian update when MITER .ne. 0.
2874
+ C-----------------------------------------------------------------------
2875
+ IF (JSTART .EQ. 0) NSLP = 0
2876
+ IF (NFLAG .EQ. 0) ICF = 0
2877
+ IF (NFLAG .EQ. -2) IPUP = MITER
2878
+ IF ( (JSTART .EQ. 0) .OR. (JSTART .EQ. -1) ) IPUP = MITER
2879
+ C If this is functional iteration, set CRATE .eq. 1 and drop to 220
2880
+ IF (MITER .EQ. 0) THEN
2881
+ CRATE = ONE
2882
+ GO TO 220
2883
+ ENDIF
2884
+ C-----------------------------------------------------------------------
2885
+ C RC is the ratio of new to old values of the coefficient H/EL(2)=h/l1.
2886
+ C When RC differs from 1 by more than CCMAX, IPUP is set to MITER
2887
+ C to force ZVJAC to be called, if a Jacobian is involved.
2888
+ C In any case, ZVJAC is called at least every MSBP steps.
2889
+ C-----------------------------------------------------------------------
2890
+ DRC = ABS(RC-ONE)
2891
+ IF (DRC .GT. CCMAX .OR. NST .GE. NSLP+MSBP) IPUP = MITER
2892
+ C-----------------------------------------------------------------------
2893
+ C Up to MAXCOR corrector iterations are taken. A convergence test is
2894
+ C made on the r.m.s. norm of each correction, weighted by the error
2895
+ C weight vector EWT. The sum of the corrections is accumulated in the
2896
+ C vector ACOR(i). The YH array is not altered in the corrector loop.
2897
+ C-----------------------------------------------------------------------
2898
+ 220 M = 0
2899
+ DELP = ZERO
2900
+ CALL ZCOPY (N, YH(1,1), 1, Y, 1 )
2901
+ CALL F (N, TN, Y, SAVF, RPAR, IPAR)
2902
+ NFE = NFE + 1
2903
+ IF (IPUP .LE. 0) GO TO 250
2904
+ C-----------------------------------------------------------------------
2905
+ C If indicated, the matrix P = I - h*rl1*J is reevaluated and
2906
+ C preprocessed before starting the corrector iteration. IPUP is set
2907
+ C to 0 as an indicator that this has been done.
2908
+ C-----------------------------------------------------------------------
2909
+ CALL ZVJAC (Y, YH, LDYH, EWT, ACOR, SAVF, WM, IWM, F, JAC, IERPJ,
2910
+ 1 RPAR, IPAR)
2911
+ IPUP = 0
2912
+ RC = ONE
2913
+ DRC = ZERO
2914
+ CRATE = ONE
2915
+ NSLP = NST
2916
+ C If matrix is singular, take error return to force cut in step size. --
2917
+ IF (IERPJ .NE. 0) GO TO 430
2918
+ 250 DO 260 I = 1,N
2919
+ 260 ACOR(I) = ZERO
2920
+ C This is a looping point for the corrector iteration. -----------------
2921
+ 270 IF (MITER .NE. 0) GO TO 350
2922
+ C-----------------------------------------------------------------------
2923
+ C In the case of functional iteration, update Y directly from
2924
+ C the result of the last function evaluation.
2925
+ C-----------------------------------------------------------------------
2926
+ DO 280 I = 1,N
2927
+ 280 SAVF(I) = RL1*(H*SAVF(I) - YH(I,2))
2928
+ DO 290 I = 1,N
2929
+ 290 Y(I) = SAVF(I) - ACOR(I)
2930
+ DEL = ZVNORM (N, Y, EWT)
2931
+ DO 300 I = 1,N
2932
+ 300 Y(I) = YH(I,1) + SAVF(I)
2933
+ CALL ZCOPY (N, SAVF, 1, ACOR, 1)
2934
+ GO TO 400
2935
+ C-----------------------------------------------------------------------
2936
+ C In the case of the chord method, compute the corrector error,
2937
+ C and solve the linear system with that as right-hand side and
2938
+ C P as coefficient matrix. The correction is scaled by the factor
2939
+ C 2/(1+RC) to account for changes in h*rl1 since the last ZVJAC call.
2940
+ C-----------------------------------------------------------------------
2941
+ 350 DO 360 I = 1,N
2942
+ 360 Y(I) = (RL1*H)*SAVF(I) - (RL1*YH(I,2) + ACOR(I))
2943
+ CALL ZVSOL (WM, IWM, Y, IERSL)
2944
+ NNI = NNI + 1
2945
+ IF (IERSL .GT. 0) GO TO 410
2946
+ IF (METH .EQ. 2 .AND. RC .NE. ONE) THEN
2947
+ CSCALE = TWO/(ONE + RC)
2948
+ CALL DZSCAL (N, CSCALE, Y, 1)
2949
+ ENDIF
2950
+ DEL = ZVNORM (N, Y, EWT)
2951
+ CALL DZAXPY (N, ONE, Y, 1, ACOR, 1)
2952
+ DO 380 I = 1,N
2953
+ 380 Y(I) = YH(I,1) + ACOR(I)
2954
+ C-----------------------------------------------------------------------
2955
+ C Test for convergence. If M .gt. 0, an estimate of the convergence
2956
+ C rate constant is stored in CRATE, and this is used in the test.
2957
+ C-----------------------------------------------------------------------
2958
+ 400 IF (M .NE. 0) CRATE = MAX(CRDOWN*CRATE,DEL/DELP)
2959
+ DCON = DEL*MIN(ONE,CRATE)/TQ(4)
2960
+ IF (DCON .LE. ONE) GO TO 450
2961
+ M = M + 1
2962
+ IF (M .EQ. MAXCOR) GO TO 410
2963
+ IF (M .GE. 2 .AND. DEL .GT. RDIV*DELP) GO TO 410
2964
+ DELP = DEL
2965
+ CALL F (N, TN, Y, SAVF, RPAR, IPAR)
2966
+ NFE = NFE + 1
2967
+ GO TO 270
2968
+ C
2969
+ 410 IF (MITER .EQ. 0 .OR. JCUR .EQ. 1) GO TO 430
2970
+ ICF = 1
2971
+ IPUP = MITER
2972
+ GO TO 220
2973
+ C
2974
+ 430 CONTINUE
2975
+ NFLAG = -1
2976
+ ICF = 2
2977
+ IPUP = MITER
2978
+ RETURN
2979
+ C
2980
+ C Return for successful step. ------------------------------------------
2981
+ 450 NFLAG = 0
2982
+ JCUR = 0
2983
+ ICF = 0
2984
+ IF (M .EQ. 0) ACNRM = DEL
2985
+ IF (M .GT. 0) ACNRM = ZVNORM (N, ACOR, EWT)
2986
+ RETURN
2987
+ C----------------------- End of Subroutine ZVNLSD ----------------------
2988
+ END
2989
+ *DECK ZVJAC
2990
+ SUBROUTINE ZVJAC (Y, YH, LDYH, EWT, FTEM, SAVF, WM, IWM, F, JAC,
2991
+ 1 IERPJ, RPAR, IPAR)
2992
+ EXTERNAL F, JAC
2993
+ DOUBLE COMPLEX Y, YH, FTEM, SAVF, WM
2994
+ DOUBLE PRECISION EWT
2995
+ INTEGER LDYH, IWM, IERPJ, IPAR
2996
+ DIMENSION Y(*), YH(LDYH,*), EWT(*), FTEM(*), SAVF(*),
2997
+ 1 WM(*), IWM(*), RPAR(*), IPAR(*)
2998
+ C-----------------------------------------------------------------------
2999
+ C Call sequence input -- Y, YH, LDYH, EWT, FTEM, SAVF, WM, IWM,
3000
+ C F, JAC, RPAR, IPAR
3001
+ C Call sequence output -- WM, IWM, IERPJ
3002
+ C COMMON block variables accessed:
3003
+ C /ZVOD01/ CCMXJ, DRC, H, HRL1, RL1, SRUR, TN, UROUND, ICF, JCUR,
3004
+ C LOCJS, MITER, MSBJ, N, NSLJ
3005
+ C /ZVOD02/ NFE, NST, NJE, NLU
3006
+ C
3007
+ C Subroutines called by ZVJAC: F, JAC, ZACOPY, ZCOPY, ZGBTRF, ZGETRF,
3008
+ C DZSCAL
3009
+ C Function routines called by ZVJAC: ZVNORM
3010
+ C-----------------------------------------------------------------------
3011
+ C ZVJAC is called by ZVNLSD to compute and process the matrix
3012
+ C P = I - h*rl1*J , where J is an approximation to the Jacobian.
3013
+ C Here J is computed by the user-supplied routine JAC if
3014
+ C MITER = 1 or 4, or by finite differencing if MITER = 2, 3, or 5.
3015
+ C If MITER = 3, a diagonal approximation to J is used.
3016
+ C If JSV = -1, J is computed from scratch in all cases.
3017
+ C If JSV = 1 and MITER = 1, 2, 4, or 5, and if the saved value of J is
3018
+ C considered acceptable, then P is constructed from the saved J.
3019
+ C J is stored in wm and replaced by P. If MITER .ne. 3, P is then
3020
+ C subjected to LU decomposition in preparation for later solution
3021
+ C of linear systems with P as coefficient matrix. This is done
3022
+ C by ZGETRF if MITER = 1 or 2, and by ZGBTRF if MITER = 4 or 5.
3023
+ C
3024
+ C Communication with ZVJAC is done with the following variables. (For
3025
+ C more details, please see the comments in the driver subroutine.)
3026
+ C Y = Vector containing predicted values on entry.
3027
+ C YH = The Nordsieck array, an LDYH by LMAX array, input.
3028
+ C LDYH = A constant .ge. N, the first dimension of YH, input.
3029
+ C EWT = An error weight vector of length N.
3030
+ C SAVF = Array containing f evaluated at predicted y, input.
3031
+ C WM = Complex work space for matrices. In the output, it
3032
+ C contains the inverse diagonal matrix if MITER = 3 and
3033
+ C the LU decomposition of P if MITER is 1, 2 , 4, or 5.
3034
+ C Storage of the saved Jacobian starts at WM(LOCJS).
3035
+ C IWM = Integer work space containing pivot information,
3036
+ C starting at IWM(31), if MITER is 1, 2, 4, or 5.
3037
+ C IWM also contains band parameters ML = IWM(1) and
3038
+ C MU = IWM(2) if MITER is 4 or 5.
3039
+ C F = Dummy name for the user-supplied subroutine for f.
3040
+ C JAC = Dummy name for the user-supplied Jacobian subroutine.
3041
+ C RPAR, IPAR = User's real/complex and integer work arrays.
3042
+ C RL1 = 1/EL(2) (input).
3043
+ C IERPJ = Output error flag, = 0 if no trouble, 1 if the P
3044
+ C matrix is found to be singular.
3045
+ C JCUR = Output flag to indicate whether the Jacobian matrix
3046
+ C (or approximation) is now current.
3047
+ C JCUR = 0 means J is not current.
3048
+ C JCUR = 1 means J is current.
3049
+ C-----------------------------------------------------------------------
3050
+ C
3051
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
3052
+ C
3053
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
3054
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
3055
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
3056
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
3057
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
3058
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
3059
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
3060
+ 4 NSLP, NYH
3061
+ C
3062
+ C Type declarations for labeled COMMON block ZVOD02 --------------------
3063
+ C
3064
+ DOUBLE PRECISION HU
3065
+ INTEGER NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
3066
+ C
3067
+ C Type declarations for local variables --------------------------------
3068
+ C
3069
+ DOUBLE COMPLEX DI, R1, YI, YJ, YJJ
3070
+ DOUBLE PRECISION CON, FAC, ONE, PT1, R, R0, THOU, ZERO
3071
+ INTEGER I, I1, I2, IER, II, J, J1, JJ, JOK, LENP, MBA, MBAND,
3072
+ 1 MEB1, MEBAND, ML, ML1, MU, NP1
3073
+ C
3074
+ C Type declaration for function subroutines called ---------------------
3075
+ C
3076
+ DOUBLE PRECISION ZVNORM
3077
+ C-----------------------------------------------------------------------
3078
+ C The following Fortran-77 declaration is to cause the values of the
3079
+ C listed (local) variables to be saved between calls to this subroutine.
3080
+ C-----------------------------------------------------------------------
3081
+ SAVE ONE, PT1, THOU, ZERO
3082
+ C-----------------------------------------------------------------------
3083
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
3084
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
3085
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
3086
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
3087
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
3088
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
3089
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
3090
+ 7 NSLP, NYH
3091
+ COMMON /ZVOD02/ HU, NCFN, NETF, NFE, NJE, NLU, NNI, NQU, NST
3092
+ C
3093
+ DATA ONE /1.0D0/, THOU /1000.0D0/, ZERO /0.0D0/, PT1 /0.1D0/
3094
+ C
3095
+ IERPJ = 0
3096
+ HRL1 = H*RL1
3097
+ C See whether J should be evaluated (JOK = -1) or not (JOK = 1). -------
3098
+ JOK = JSV
3099
+ IF (JSV .EQ. 1) THEN
3100
+ IF (NST .EQ. 0 .OR. NST .GT. NSLJ+MSBJ) JOK = -1
3101
+ IF (ICF .EQ. 1 .AND. DRC .LT. CCMXJ) JOK = -1
3102
+ IF (ICF .EQ. 2) JOK = -1
3103
+ ENDIF
3104
+ C End of setting JOK. --------------------------------------------------
3105
+ C
3106
+ IF (JOK .EQ. -1 .AND. MITER .EQ. 1) THEN
3107
+ C If JOK = -1 and MITER = 1, call JAC to evaluate Jacobian. ------------
3108
+ NJE = NJE + 1
3109
+ NSLJ = NST
3110
+ JCUR = 1
3111
+ LENP = N*N
3112
+ DO 110 I = 1,LENP
3113
+ 110 WM(I) = ZERO
3114
+ CALL JAC (N, TN, Y, 0, 0, WM, N, RPAR, IPAR)
3115
+ IF (JSV .EQ. 1) CALL ZCOPY (LENP, WM, 1, WM(LOCJS), 1)
3116
+ ENDIF
3117
+ C
3118
+ IF (JOK .EQ. -1 .AND. MITER .EQ. 2) THEN
3119
+ C If MITER = 2, make N calls to F to approximate the Jacobian. ---------
3120
+ NJE = NJE + 1
3121
+ NSLJ = NST
3122
+ JCUR = 1
3123
+ FAC = ZVNORM (N, SAVF, EWT)
3124
+ R0 = THOU*ABS(H)*UROUND*REAL(N)*FAC
3125
+ IF (R0 .EQ. ZERO) R0 = ONE
3126
+ J1 = 0
3127
+ DO 230 J = 1,N
3128
+ YJ = Y(J)
3129
+ R = MAX(SRUR*ABS(YJ),R0/EWT(J))
3130
+ Y(J) = Y(J) + R
3131
+ FAC = ONE/R
3132
+ CALL F (N, TN, Y, FTEM, RPAR, IPAR)
3133
+ DO 220 I = 1,N
3134
+ 220 WM(I+J1) = (FTEM(I) - SAVF(I))*FAC
3135
+ Y(J) = YJ
3136
+ J1 = J1 + N
3137
+ 230 CONTINUE
3138
+ NFE = NFE + N
3139
+ LENP = N*N
3140
+ IF (JSV .EQ. 1) CALL ZCOPY (LENP, WM, 1, WM(LOCJS), 1)
3141
+ ENDIF
3142
+ C
3143
+ IF (JOK .EQ. 1 .AND. (MITER .EQ. 1 .OR. MITER .EQ. 2)) THEN
3144
+ JCUR = 0
3145
+ LENP = N*N
3146
+ CALL ZCOPY (LENP, WM(LOCJS), 1, WM, 1)
3147
+ ENDIF
3148
+ C
3149
+ IF (MITER .EQ. 1 .OR. MITER .EQ. 2) THEN
3150
+ C Multiply Jacobian by scalar, add identity, and do LU decomposition. --
3151
+ CON = -HRL1
3152
+ CALL DZSCAL (LENP, CON, WM, 1)
3153
+ J = 1
3154
+ NP1 = N + 1
3155
+ DO 250 I = 1,N
3156
+ WM(J) = WM(J) + ONE
3157
+ 250 J = J + NP1
3158
+ NLU = NLU + 1
3159
+ c Replaced LINPACK zgefa with LAPACK zgetrf
3160
+ c CALL ZGEFA (WM, N, N, IWM(31), IER)
3161
+ CALL ZGETRF (N, N, WM, N, IWM(31), IER)
3162
+ IF (IER .NE. 0) IERPJ = 1
3163
+ RETURN
3164
+ ENDIF
3165
+ C End of code block for MITER = 1 or 2. --------------------------------
3166
+ C
3167
+ IF (MITER .EQ. 3) THEN
3168
+ C If MITER = 3, construct a diagonal approximation to J and P. ---------
3169
+ NJE = NJE + 1
3170
+ JCUR = 1
3171
+ R = RL1*PT1
3172
+ DO 310 I = 1,N
3173
+ 310 Y(I) = Y(I) + R*(H*SAVF(I) - YH(I,2))
3174
+ CALL F (N, TN, Y, WM, RPAR, IPAR)
3175
+ NFE = NFE + 1
3176
+ DO 320 I = 1,N
3177
+ R1 = H*SAVF(I) - YH(I,2)
3178
+ DI = PT1*R1 - H*(WM(I) - SAVF(I))
3179
+ WM(I) = ONE
3180
+ IF (ABS(R1) .LT. UROUND/EWT(I)) GO TO 320
3181
+ IF (ABS(DI) .EQ. ZERO) GO TO 330
3182
+ WM(I) = PT1*R1/DI
3183
+ 320 CONTINUE
3184
+ RETURN
3185
+ 330 IERPJ = 1
3186
+ RETURN
3187
+ ENDIF
3188
+ C End of code block for MITER = 3. -------------------------------------
3189
+ C
3190
+ C Set constants for MITER = 4 or 5. ------------------------------------
3191
+ ML = IWM(1)
3192
+ MU = IWM(2)
3193
+ ML1 = ML + 1
3194
+ MBAND = ML + MU + 1
3195
+ MEBAND = MBAND + ML
3196
+ LENP = MEBAND*N
3197
+ C
3198
+ IF (JOK .EQ. -1 .AND. MITER .EQ. 4) THEN
3199
+ C If JOK = -1 and MITER = 4, call JAC to evaluate Jacobian. ------------
3200
+ NJE = NJE + 1
3201
+ NSLJ = NST
3202
+ JCUR = 1
3203
+ DO 410 I = 1,LENP
3204
+ 410 WM(I) = ZERO
3205
+ CALL JAC (N, TN, Y, ML, MU, WM(ML1), MEBAND, RPAR, IPAR)
3206
+ IF (JSV .EQ. 1)
3207
+ 1 CALL ZACOPY (MBAND, N, WM(ML1), MEBAND, WM(LOCJS), MBAND)
3208
+ ENDIF
3209
+ C
3210
+ IF (JOK .EQ. -1 .AND. MITER .EQ. 5) THEN
3211
+ C If MITER = 5, make ML+MU+1 calls to F to approximate the Jacobian. ---
3212
+ NJE = NJE + 1
3213
+ NSLJ = NST
3214
+ JCUR = 1
3215
+ MBA = MIN(MBAND,N)
3216
+ MEB1 = MEBAND - 1
3217
+ FAC = ZVNORM (N, SAVF, EWT)
3218
+ R0 = THOU*ABS(H)*UROUND*REAL(N)*FAC
3219
+ IF (R0 .EQ. ZERO) R0 = ONE
3220
+ DO 560 J = 1,MBA
3221
+ DO 530 I = J,N,MBAND
3222
+ YI = Y(I)
3223
+ R = MAX(SRUR*ABS(YI),R0/EWT(I))
3224
+ 530 Y(I) = Y(I) + R
3225
+ CALL F (N, TN, Y, FTEM, RPAR, IPAR)
3226
+ DO 550 JJ = J,N,MBAND
3227
+ Y(JJ) = YH(JJ,1)
3228
+ YJJ = Y(JJ)
3229
+ R = MAX(SRUR*ABS(YJJ),R0/EWT(JJ))
3230
+ FAC = ONE/R
3231
+ I1 = MAX(JJ-MU,1)
3232
+ I2 = MIN(JJ+ML,N)
3233
+ II = JJ*MEB1 - ML
3234
+ DO 540 I = I1,I2
3235
+ 540 WM(II+I) = (FTEM(I) - SAVF(I))*FAC
3236
+ 550 CONTINUE
3237
+ 560 CONTINUE
3238
+ NFE = NFE + MBA
3239
+ IF (JSV .EQ. 1)
3240
+ 1 CALL ZACOPY (MBAND, N, WM(ML1), MEBAND, WM(LOCJS), MBAND)
3241
+ ENDIF
3242
+ C
3243
+ IF (JOK .EQ. 1) THEN
3244
+ JCUR = 0
3245
+ CALL ZACOPY (MBAND, N, WM(LOCJS), MBAND, WM(ML1), MEBAND)
3246
+ ENDIF
3247
+ C
3248
+ C Multiply Jacobian by scalar, add identity, and do LU decomposition.
3249
+ CON = -HRL1
3250
+ CALL DZSCAL (LENP, CON, WM, 1 )
3251
+ II = MBAND
3252
+ DO 580 I = 1,N
3253
+ WM(II) = WM(II) + ONE
3254
+ 580 II = II + MEBAND
3255
+ NLU = NLU + 1
3256
+ c Replaced LINPACK zgbfa with LAPACK zgbtrf
3257
+ c CALL ZGBFA (WM, MEBAND, N, ML, MU, IWM(31), IER)
3258
+ CALL ZGBTRF (N, N, ML, MU, WM, MEBAND, IWM(31), IER)
3259
+ IF (IER .NE. 0) IERPJ = 1
3260
+ RETURN
3261
+ C End of code block for MITER = 4 or 5. --------------------------------
3262
+ C
3263
+ C----------------------- End of Subroutine ZVJAC -----------------------
3264
+ END
3265
+ *DECK ZACOPY
3266
+ SUBROUTINE ZACOPY (NROW, NCOL, A, NROWA, B, NROWB)
3267
+ DOUBLE COMPLEX A, B
3268
+ INTEGER NROW, NCOL, NROWA, NROWB
3269
+ DIMENSION A(NROWA,NCOL), B(NROWB,NCOL)
3270
+ C-----------------------------------------------------------------------
3271
+ C Call sequence input -- NROW, NCOL, A, NROWA, NROWB
3272
+ C Call sequence output -- B
3273
+ C COMMON block variables accessed -- None
3274
+ C
3275
+ C Subroutines called by ZACOPY: ZCOPY
3276
+ C Function routines called by ZACOPY: None
3277
+ C-----------------------------------------------------------------------
3278
+ C This routine copies one rectangular array, A, to another, B,
3279
+ C where A and B may have different row dimensions, NROWA and NROWB.
3280
+ C The data copied consists of NROW rows and NCOL columns.
3281
+ C-----------------------------------------------------------------------
3282
+ INTEGER IC
3283
+ C
3284
+ DO 20 IC = 1,NCOL
3285
+ CALL ZCOPY (NROW, A(1,IC), 1, B(1,IC), 1)
3286
+ 20 CONTINUE
3287
+ C
3288
+ RETURN
3289
+ C----------------------- End of Subroutine ZACOPY ----------------------
3290
+ END
3291
+ *DECK ZVSOL
3292
+ SUBROUTINE ZVSOL (WM, IWM, X, IERSL)
3293
+ DOUBLE COMPLEX WM, X
3294
+ INTEGER IWM, IERSL
3295
+ DIMENSION WM(*), IWM(*), X(*)
3296
+ C-----------------------------------------------------------------------
3297
+ C Call sequence input -- WM, IWM, X
3298
+ C Call sequence output -- X, IERSL
3299
+ C COMMON block variables accessed:
3300
+ C /ZVOD01/ -- H, HRL1, RL1, MITER, N
3301
+ C
3302
+ C Subroutines called by ZVSOL: ZGETRS, ZGBTRS
3303
+ C Function routines called by ZVSOL: None
3304
+ C-----------------------------------------------------------------------
3305
+ C This routine manages the solution of the linear system arising from
3306
+ C a chord iteration. It is called if MITER .ne. 0.
3307
+ C If MITER is 1 or 2, it calls ZGETRS to accomplish this.
3308
+ C If MITER = 3 it updates the coefficient H*RL1 in the diagonal
3309
+ C matrix, and then computes the solution.
3310
+ C If MITER is 4 or 5, it calls ZGBTRS.
3311
+ C Communication with ZVSOL uses the following variables:
3312
+ C WM = Real work space containing the inverse diagonal matrix if
3313
+ C MITER = 3 and the LU decomposition of the matrix otherwise.
3314
+ C IWM = Integer work space containing pivot information, starting at
3315
+ C IWM(31), if MITER is 1, 2, 4, or 5. IWM also contains band
3316
+ C parameters ML = IWM(1) and MU = IWM(2) if MITER is 4 or 5.
3317
+ C X = The right-hand side vector on input, and the solution vector
3318
+ C on output, of length N.
3319
+ C IERSL = Output flag. IERSL = 0 if no trouble occurred.
3320
+ C IERSL = 1 if a singular matrix arose with MITER = 3.
3321
+ C-----------------------------------------------------------------------
3322
+ C
3323
+ C Type declarations for labeled COMMON block ZVOD01 --------------------
3324
+ C
3325
+ DOUBLE PRECISION ACNRM, CCMXJ, CONP, CRATE, DRC, EL,
3326
+ 1 ETA, ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
3327
+ 2 RC, RL1, SRUR, TAU, TQ, TN, UROUND
3328
+ INTEGER ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
3329
+ 1 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
3330
+ 2 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
3331
+ 3 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
3332
+ 4 NSLP, NYH
3333
+ C
3334
+ C Type declarations for local variables --------------------------------
3335
+ C
3336
+ DOUBLE COMPLEX DI
3337
+ DOUBLE PRECISION ONE, PHRL1, R, ZERO
3338
+ INTEGER I, MEBAND, ML, MU
3339
+ C-----------------------------------------------------------------------
3340
+ C The following Fortran-77 declaration is to cause the values of the
3341
+ C listed (local) variables to be saved between calls to this integrator.
3342
+ C-----------------------------------------------------------------------
3343
+ SAVE ONE, ZERO
3344
+ C
3345
+ COMMON /ZVOD01/ ACNRM, CCMXJ, CONP, CRATE, DRC, EL(13), ETA,
3346
+ 1 ETAMAX, H, HMIN, HMXI, HNEW, HRL1, HSCAL, PRL1,
3347
+ 2 RC, RL1, SRUR, TAU(13), TQ(5), TN, UROUND,
3348
+ 3 ICF, INIT, IPUP, JCUR, JSTART, JSV, KFLAG, KUTH,
3349
+ 4 L, LMAX, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
3350
+ 5 LOCJS, MAXORD, METH, MITER, MSBJ, MXHNIL, MXSTEP,
3351
+ 6 N, NEWH, NEWQ, NHNIL, NQ, NQNYH, NQWAIT, NSLJ,
3352
+ 7 NSLP, NYH
3353
+ C
3354
+ DATA ONE /1.0D0/, ZERO /0.0D0/
3355
+ C
3356
+ IERSL = 0
3357
+ GO TO (100, 100, 300, 400, 400), MITER
3358
+ c Replaced LINPACK zgesl with LAPACK zgetrs
3359
+ c 100 CALL ZGESL (WM, N, N, IWM(31), X, 0)
3360
+ 100 CALL ZGETRS ('N', N, 1, WM, N, IWM(31), X, N, IER)
3361
+ RETURN
3362
+ C
3363
+ 300 PHRL1 = HRL1
3364
+ HRL1 = H*RL1
3365
+ IF (HRL1 .EQ. PHRL1) GO TO 330
3366
+ R = HRL1/PHRL1
3367
+ DO 320 I = 1,N
3368
+ DI = ONE - R*(ONE - ONE/WM(I))
3369
+ IF (ABS(DI) .EQ. ZERO) GO TO 390
3370
+ 320 WM(I) = ONE/DI
3371
+ C
3372
+ 330 DO 340 I = 1,N
3373
+ 340 X(I) = WM(I)*X(I)
3374
+ RETURN
3375
+ 390 IERSL = 1
3376
+ RETURN
3377
+ C
3378
+ 400 ML = IWM(1)
3379
+ MU = IWM(2)
3380
+ MEBAND = 2*ML + MU + 1
3381
+ c Replaced LINPACK zgbsl with LAPACK zgbtrs
3382
+ c CALL ZGBSL (WM, MEBAND, N, ML, MU, IWM(31), X, 0)
3383
+ CALL ZGBTRS ('N', N, ML, MU, 1, WM, MEBAND, IWM(31), X, N, IER)
3384
+ RETURN
3385
+ C----------------------- End of Subroutine ZVSOL -----------------------
3386
+ END
3387
+ *DECK ZVSRCO
3388
+ SUBROUTINE ZVSRCO (RSAV, ISAV, JOB)
3389
+ DOUBLE PRECISION RSAV
3390
+ INTEGER ISAV, JOB
3391
+ DIMENSION RSAV(*), ISAV(*)
3392
+ C-----------------------------------------------------------------------
3393
+ C Call sequence input -- RSAV, ISAV, JOB
3394
+ C Call sequence output -- RSAV, ISAV
3395
+ C COMMON block variables accessed -- All of /ZVOD01/ and /ZVOD02/
3396
+ C
3397
+ C Subroutines/functions called by ZVSRCO: None
3398
+ C-----------------------------------------------------------------------
3399
+ C This routine saves or restores (depending on JOB) the contents of the
3400
+ C COMMON blocks ZVOD01 and ZVOD02, which are used internally by ZVODE.
3401
+ C
3402
+ C RSAV = real array of length 51 or more.
3403
+ C ISAV = integer array of length 41 or more.
3404
+ C JOB = flag indicating to save or restore the COMMON blocks:
3405
+ C JOB = 1 if COMMON is to be saved (written to RSAV/ISAV).
3406
+ C JOB = 2 if COMMON is to be restored (read from RSAV/ISAV).
3407
+ C A call with JOB = 2 presumes a prior call with JOB = 1.
3408
+ C-----------------------------------------------------------------------
3409
+ DOUBLE PRECISION RVOD1, RVOD2
3410
+ INTEGER IVOD1, IVOD2
3411
+ INTEGER I, LENIV1, LENIV2, LENRV1, LENRV2
3412
+ C-----------------------------------------------------------------------
3413
+ C The following Fortran-77 declaration is to cause the values of the
3414
+ C listed (local) variables to be saved between calls to this integrator.
3415
+ C-----------------------------------------------------------------------
3416
+ SAVE LENRV1, LENIV1, LENRV2, LENIV2
3417
+ C
3418
+ COMMON /ZVOD01/ RVOD1(50), IVOD1(33)
3419
+ COMMON /ZVOD02/ RVOD2(1), IVOD2(8)
3420
+ DATA LENRV1/50/, LENIV1/33/, LENRV2/1/, LENIV2/8/
3421
+ C
3422
+ IF (JOB .EQ. 2) GO TO 100
3423
+ DO 10 I = 1,LENRV1
3424
+ 10 RSAV(I) = RVOD1(I)
3425
+ DO 15 I = 1,LENRV2
3426
+ 15 RSAV(LENRV1+I) = RVOD2(I)
3427
+ C
3428
+ DO 20 I = 1,LENIV1
3429
+ 20 ISAV(I) = IVOD1(I)
3430
+ DO 25 I = 1,LENIV2
3431
+ 25 ISAV(LENIV1+I) = IVOD2(I)
3432
+ C
3433
+ RETURN
3434
+ C
3435
+ 100 CONTINUE
3436
+ DO 110 I = 1,LENRV1
3437
+ 110 RVOD1(I) = RSAV(I)
3438
+ DO 115 I = 1,LENRV2
3439
+ 115 RVOD2(I) = RSAV(LENRV1+I)
3440
+ C
3441
+ DO 120 I = 1,LENIV1
3442
+ 120 IVOD1(I) = ISAV(I)
3443
+ DO 125 I = 1,LENIV2
3444
+ 125 IVOD2(I) = ISAV(LENIV1+I)
3445
+ C
3446
+ RETURN
3447
+ C----------------------- End of Subroutine ZVSRCO ----------------------
3448
+ END
3449
+ *DECK ZEWSET
3450
+ SUBROUTINE ZEWSET (N, ITOL, RTOL, ATOL, YCUR, EWT)
3451
+ C***BEGIN PROLOGUE ZEWSET
3452
+ C***SUBSIDIARY
3453
+ C***PURPOSE Set error weight vector.
3454
+ C***TYPE DOUBLE PRECISION (SEWSET-S, DEWSET-D, ZEWSET-Z)
3455
+ C***AUTHOR Hindmarsh, Alan C., (LLNL)
3456
+ C***DESCRIPTION
3457
+ C
3458
+ C This subroutine sets the error weight vector EWT according to
3459
+ C EWT(i) = RTOL(i)*ABS(YCUR(i)) + ATOL(i), i = 1,...,N,
3460
+ C with the subscript on RTOL and/or ATOL possibly replaced by 1 above,
3461
+ C depending on the value of ITOL.
3462
+ C
3463
+ C***SEE ALSO DLSODE
3464
+ C***ROUTINES CALLED (NONE)
3465
+ C***REVISION HISTORY (YYMMDD)
3466
+ C 060502 DATE WRITTEN, modified from DEWSET of 930809.
3467
+ C***END PROLOGUE ZEWSET
3468
+ DOUBLE COMPLEX YCUR
3469
+ DOUBLE PRECISION RTOL, ATOL, EWT
3470
+ INTEGER N, ITOL
3471
+ INTEGER I
3472
+ DIMENSION RTOL(*), ATOL(*), YCUR(N), EWT(N)
3473
+ C
3474
+ C***FIRST EXECUTABLE STATEMENT ZEWSET
3475
+ GO TO (10, 20, 30, 40), ITOL
3476
+ 10 CONTINUE
3477
+ DO 15 I = 1,N
3478
+ 15 EWT(I) = RTOL(1)*ABS(YCUR(I)) + ATOL(1)
3479
+ RETURN
3480
+ 20 CONTINUE
3481
+ DO 25 I = 1,N
3482
+ 25 EWT(I) = RTOL(1)*ABS(YCUR(I)) + ATOL(I)
3483
+ RETURN
3484
+ 30 CONTINUE
3485
+ DO 35 I = 1,N
3486
+ 35 EWT(I) = RTOL(I)*ABS(YCUR(I)) + ATOL(1)
3487
+ RETURN
3488
+ 40 CONTINUE
3489
+ DO 45 I = 1,N
3490
+ 45 EWT(I) = RTOL(I)*ABS(YCUR(I)) + ATOL(I)
3491
+ RETURN
3492
+ C----------------------- END OF SUBROUTINE ZEWSET ----------------------
3493
+ END
3494
+ *DECK ZVNORM
3495
+ DOUBLE PRECISION FUNCTION ZVNORM (N, V, W)
3496
+ C***BEGIN PROLOGUE ZVNORM
3497
+ C***SUBSIDIARY
3498
+ C***PURPOSE Weighted root-mean-square vector norm.
3499
+ C***TYPE DOUBLE COMPLEX (SVNORM-S, DVNORM-D, ZVNORM-Z)
3500
+ C***AUTHOR Hindmarsh, Alan C., (LLNL)
3501
+ C***DESCRIPTION
3502
+ C
3503
+ C This function routine computes the weighted root-mean-square norm
3504
+ C of the vector of length N contained in the double complex array V,
3505
+ C with weights contained in the array W of length N:
3506
+ C ZVNORM = SQRT( (1/N) * SUM( abs(V(i))**2 * W(i)**2 )
3507
+ C The squared absolute value abs(v)**2 is computed by ZABSSQ.
3508
+ C
3509
+ C***SEE ALSO DLSODE
3510
+ C***ROUTINES CALLED ZABSSQ
3511
+ C***REVISION HISTORY (YYMMDD)
3512
+ C 060502 DATE WRITTEN, modified from DVNORM of 930809.
3513
+ C***END PROLOGUE ZVNORM
3514
+ DOUBLE COMPLEX V
3515
+ DOUBLE PRECISION W, SUM, ZABSSQ
3516
+ INTEGER N, I
3517
+ DIMENSION V(N), W(N)
3518
+ C
3519
+ C***FIRST EXECUTABLE STATEMENT ZVNORM
3520
+ SUM = 0.0D0
3521
+ DO 10 I = 1,N
3522
+ 10 SUM = SUM + ZABSSQ(V(I)) * W(I)**2
3523
+ ZVNORM = SQRT(SUM/N)
3524
+ RETURN
3525
+ C----------------------- END OF FUNCTION ZVNORM ------------------------
3526
+ END
3527
+ *DECK ZABSSQ
3528
+ DOUBLE PRECISION FUNCTION ZABSSQ(Z)
3529
+ C***BEGIN PROLOGUE ZABSSQ
3530
+ C***SUBSIDIARY
3531
+ C***PURPOSE Squared absolute value of a double complex number.
3532
+ C***TYPE DOUBLE PRECISION (ZABSSQ-Z)
3533
+ C***AUTHOR Hindmarsh, Alan C., (LLNL)
3534
+ C***DESCRIPTION
3535
+ C
3536
+ C This function routine computes the square of the absolute value of
3537
+ C a double precision complex number Z,
3538
+ C ZABSSQ = DREAL(Z)**2 * DIMAG(Z)**2
3539
+ C***REVISION HISTORY (YYMMDD)
3540
+ C 060502 DATE WRITTEN.
3541
+ C***END PROLOGUE ZABSSQ
3542
+ DOUBLE COMPLEX Z
3543
+ ZABSSQ = DREAL(Z)**2 + DIMAG(Z)**2
3544
+ RETURN
3545
+ C----------------------- END OF FUNCTION ZABSSQ ------------------------
3546
+ END
3547
+ *DECK DZSCAL
3548
+ SUBROUTINE DZSCAL(N, DA, ZX, INCX)
3549
+ C***BEGIN PROLOGUE DZSCAL
3550
+ C***SUBSIDIARY
3551
+ C***PURPOSE Scale a double complex vector by a double prec. constant.
3552
+ C***TYPE DOUBLE PRECISION (DZSCAL-Z)
3553
+ C***AUTHOR Hindmarsh, Alan C., (LLNL)
3554
+ C***DESCRIPTION
3555
+ C Scales a double complex vector by a double precision constant.
3556
+ C Minor modification of BLAS routine ZSCAL.
3557
+ C***REVISION HISTORY (YYMMDD)
3558
+ C 060530 DATE WRITTEN.
3559
+ C***END PROLOGUE DZSCAL
3560
+ DOUBLE COMPLEX ZX(*)
3561
+ DOUBLE PRECISION DA
3562
+ INTEGER I,INCX,IX,N
3563
+ C
3564
+ IF( N.LE.0 .OR. INCX.LE.0 )RETURN
3565
+ IF(INCX.EQ.1)GO TO 20
3566
+ C Code for increment not equal to 1
3567
+ IX = 1
3568
+ DO 10 I = 1,N
3569
+ ZX(IX) = DA*ZX(IX)
3570
+ IX = IX + INCX
3571
+ 10 CONTINUE
3572
+ RETURN
3573
+ C Code for increment equal to 1
3574
+ 20 DO 30 I = 1,N
3575
+ ZX(I) = DA*ZX(I)
3576
+ 30 CONTINUE
3577
+ RETURN
3578
+ END
3579
+ *DECK DZAXPY
3580
+ SUBROUTINE DZAXPY(N, DA, ZX, INCX, ZY, INCY)
3581
+ C***BEGIN PROLOGUE DZAXPY
3582
+ C***PURPOSE Real constant times a complex vector plus a complex vector.
3583
+ C***TYPE DOUBLE PRECISION (DZAXPY-Z)
3584
+ C***AUTHOR Hindmarsh, Alan C., (LLNL)
3585
+ C***DESCRIPTION
3586
+ C Add a D.P. real constant times a complex vector to a complex vector.
3587
+ C Minor modification of BLAS routine ZAXPY.
3588
+ C***REVISION HISTORY (YYMMDD)
3589
+ C 060530 DATE WRITTEN.
3590
+ C***END PROLOGUE DZAXPY
3591
+ DOUBLE COMPLEX ZX(*),ZY(*)
3592
+ DOUBLE PRECISION DA
3593
+ INTEGER I,INCX,INCY,IX,IY,N
3594
+ IF(N.LE.0)RETURN
3595
+ IF (ABS(DA) .EQ. 0.0D0) RETURN
3596
+ IF (INCX.EQ.1.AND.INCY.EQ.1)GO TO 20
3597
+ C Code for unequal increments or equal increments not equal to 1
3598
+ IX = 1
3599
+ IY = 1
3600
+ IF(INCX.LT.0)IX = (-N+1)*INCX + 1
3601
+ IF(INCY.LT.0)IY = (-N+1)*INCY + 1
3602
+ DO 10 I = 1,N
3603
+ ZY(IY) = ZY(IY) + DA*ZX(IX)
3604
+ IX = IX + INCX
3605
+ IY = IY + INCY
3606
+ 10 CONTINUE
3607
+ RETURN
3608
+ C Code for both increments equal to 1
3609
+ 20 DO 30 I = 1,N
3610
+ ZY(I) = ZY(I) + DA*ZX(I)
3611
+ 30 CONTINUE
3612
+ RETURN
3613
+ END
3614
+ *DECK DUMACH
3615
+ DOUBLE PRECISION FUNCTION DUMACH ()
3616
+ C***BEGIN PROLOGUE DUMACH
3617
+ C***PURPOSE Compute the unit roundoff of the machine.
3618
+ C***CATEGORY R1
3619
+ C***TYPE DOUBLE PRECISION (RUMACH-S, DUMACH-D)
3620
+ C***KEYWORDS MACHINE CONSTANTS
3621
+ C***AUTHOR Hindmarsh, Alan C., (LLNL)
3622
+ C***DESCRIPTION
3623
+ C *Usage:
3624
+ C DOUBLE PRECISION A, DUMACH
3625
+ C A = DUMACH()
3626
+ C
3627
+ C *Function Return Values:
3628
+ C A : the unit roundoff of the machine.
3629
+ C
3630
+ C *Description:
3631
+ C The unit roundoff is defined as the smallest positive machine
3632
+ C number u such that 1.0 + u .ne. 1.0. This is computed by DUMACH
3633
+ C in a machine-independent manner.
3634
+ C
3635
+ C***REFERENCES (NONE)
3636
+ C***ROUTINES CALLED DUMSUM
3637
+ C***REVISION HISTORY (YYYYMMDD)
3638
+ C 19930216 DATE WRITTEN
3639
+ C 19930818 Added SLATEC-format prologue. (FNF)
3640
+ C 20030707 Added DUMSUM to force normal storage of COMP. (ACH)
3641
+ C***END PROLOGUE DUMACH
3642
+ C
3643
+ DOUBLE PRECISION U, COMP
3644
+ C***FIRST EXECUTABLE STATEMENT DUMACH
3645
+ U = 1.0D0
3646
+ 10 U = U*0.5D0
3647
+ CALL DUMSUM(1.0D0, U, COMP)
3648
+ IF (COMP .NE. 1.0D0) GO TO 10
3649
+ DUMACH = U*2.0D0
3650
+ RETURN
3651
+ C----------------------- End of Function DUMACH ------------------------
3652
+ END
3653
+ SUBROUTINE DUMSUM(A,B,C)
3654
+ C Routine to force normal storing of A + B, for DUMACH.
3655
+ DOUBLE PRECISION A, B, C
3656
+ C = A + B
3657
+ RETURN
3658
+ END