1 SUBROUTINE INTEGRATE
( TIN
, TOUT
)
3 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
4 INCLUDE
'KPP_ROOT_Parameters.h'
5 INCLUDE
'KPP_ROOT_Global.h'
13 PARAMETER (KM
=12,KM2
=2+KM*
(KM
+3)/2,NRDENS
=NVAR
)
14 PARAMETER (LWORK
=2*NVAR*NVAR
+(KM
+8)*NVAR
+4*KM
+20+KM2*NRDENS
)
15 PARAMETER (LIWORK
=2*NVAR
+KM
+20+NRDENS
)
19 EXTERNAL FUNC_CHEM
,JAC_CHEM
21 ITOL
=1 ! --- VECTOR TOLERANCES
22 IJAC
=1 ! --- COMPUTE THE JACOBIAN ANALYTICALLY
23 MLJAC
=NVAR
! --- JACOBIAN IS A FULL MATRIX
24 MUJAC
=NVAR
! --- JACOBIAN IS A FULL MATRIX
25 IMAS
=0 ! --- DIFFERENTIAL EQUATION IS IN EXPLICIT FORM
26 IOUT
=0 ! --- OUTPUT ROUTINE IS NOT USED DURING INTEGRATION
27 IDFX
=0 ! --- INTERNAL TIME DERIVATIVE
34 CALL ATMSEULEX
(NVAR
,FUNC_CHEM
,Autonomous
,TIN
,VAR
,TOUT
,
35 & STEPMIN
,RTOL
,ATOL
,ITOL
,
36 & JAC_CHEM
,IJAC
,MLJAC
,MUJAC
,
37 & FUNC_CHEM
,IMAS
,MLJAC
,MUJAC
,
38 & WORK
,LWORK
,IWORK
,LIWORK
,IDID
)
41 print
*,'ATMSEULEX: Unsucessfull exit at T=',
42 & TIN
,' (IDID=',IDID
,')'
49 SUBROUTINE ATMSEULEX
(N
,FCN
,IFCN
,X
,Y
,XEND
,H
,
51 & JAC
,IJAC
,MLJAC
,MUJAC
,
52 & MAS
,IMAS
,MLMAS
,MUMAS
,
53 & WORK
,LWORK
,IWORK
,LIWORK
,IDID
)
54 C ----------------------------------------------------------
55 C NUMERICAL SOLUTION OF A STIFF (OR DIFFERENTIAL ALGEBRAIC)
56 C SYSTEM OF FIRST 0RDER ORDINARY DIFFERENTIAL EQUATIONS MY'=F(X,Y).
57 C THIS IS AN EXTRAPOLATION-ALGORITHM, BASED ON THE
58 C LINEARLY IMPLICIT EULER METHOD (WITH STEP SIZE CONTROL
59 C AND ORDER SELECTION).
61 C AUTHORS: E. HAIRER AND G. WANNER
62 C UNIVERSITE DE GENEVE, DEPT. DE MATHEMATIQUES
63 C CH-1211 GENEVE 24, SWITZERLAND
64 C E-MAIL: HAIRER@DIVSUN.UNIGE.CH, WANNER@DIVSUN.UNIGE.CH
65 C INCLUSION OF DENSE OUTPUT BY E. HAIRER AND A. OSTERMANN
67 C THIS CODE IS PART OF THE BOOK:
68 C E. HAIRER AND G. WANNER, SOLVING ORDINARY DIFFERENTIAL
69 C EQUATIONS II. STIFF AND DIFFERENTIAL-ALGEBRAIC PROBLEMS.
70 C SPRINGER SERIES IN COMPUTATIONAL MATHEMATICS 14,
71 C SPRINGER-VERLAG (1991)
73 C VERSION OF SEPTEMBER 30, 1995
77 C N DIMENSION OF THE SYSTEM
79 C FCN NAME (EXTERNAL) OF SUBROUTINE COMPUTING THE
81 C SUBROUTINE FCN(N,X,Y,F)
82 C KPP_REAL X,Y(N),F(N)
84 C RPAR, IPAR (SEE BELOW)
86 C IFCN GIVES INFORMATION ON FCN:
87 C IFCN=0: F(X,Y) INDEPENDENT OF X (AUTONOMOUS)
88 C IFCN=1: F(X,Y) MAY DEPEND ON X (NON-AUTONOMOUS)
92 C Y(N) INITIAL VALUES FOR Y
94 C XEND FINAL X-VALUE (XEND-X MAY BE POSITIVE OR NEGATIVE)
96 C H INITIAL STEP SIZE GUESS;
97 C FOR STIFF EQUATIONS WITH INITIAL TRANSIENT,
98 C H=1.D0/(NORM OF F'), USUALLY 1.D-2 OR 1.D-3, IS GOOD.
99 C THIS CHOICE IS NOT VERY IMPORTANT, THE CODE QUICKLY
100 C ADAPTS ITS STEP SIZE (IF H=0.D0, THE CODE PUTS H=1.D-6).
102 C RelTol,AbsTol RELATIVE AND ABSOLUTE ERROR TOLERANCES. THEY
103 C CAN BE BOTH SCALARS OR ELSE BOTH VECTORS OF LENGTH N.
105 C ITOL SWITCH FOR RelTol AND AbsTol:
106 C ITOL=0: BOTH RelTol AND AbsTol ARE SCALARS.
107 C THE CODE KEEPS, ROUGHLY, THE LOCAL ERROR OF
108 C Y(I) BELOW RelTol*ABS(Y(I))+AbsTol
109 C ITOL=1: BOTH RelTol AND AbsTol ARE VECTORS.
110 C THE CODE KEEPS THE LOCAL ERROR OF Y(I) BELOW
111 C RelTol(I)*ABS(Y(I))+AbsTol(I).
113 C JAC NAME (EXTERNAL) OF THE SUBROUTINE WHICH COMPUTES
114 C THE PARTIAL DERIVATIVES OF F(X,Y) WITH RESPECT TO Y
115 C (THIS ROUTINE IS ONLY CALLED IF IJAC=1; SUPPLY
116 C A DUMMY SUBROUTINE IN THE CASE IJAC=0).
117 C FOR IJAC=1, THIS SUBROUTINE MUST HAVE THE FORM
118 C SUBROUTINE JAC(N,X,Y,DFY,LDFY)
119 C KPP_REAL X,Y(N),DFY(LDFY,N)
121 C LDFY, THE COLOMN-LENGTH OF THE ARRAY, IS
122 C FURNISHED BY THE CALLING PROGRAM.
123 C IF (MLJAC.EQ.N) THE JACOBIAN IS SUPPOSED TO
124 C BE FULL AND THE PARTIAL DERIVATIVES ARE
126 C DFY(I,J) = PARTIAL F(I) / PARTIAL Y(J)
127 C ELSE, THE JACOBIAN IS TAKEN AS BANDED AND
128 C THE PARTIAL DERIVATIVES ARE STORED
130 C DFY(I-J+MUJAC+1,J) = PARTIAL F(I) / PARTIAL Y(J).
132 C IJAC SWITCH FOR THE COMPUTATION OF THE JACOBIAN:
133 C IJAC=0: JACOBIAN IS COMPUTED INTERNALLY BY FINITE
134 C DIFFERENCES, SUBROUTINE "JAC" IS NEVER CALLED.
135 C IJAC=1: JACOBIAN IS SUPPLIED BY SUBROUTINE JAC.
137 C MLJAC SWITCH FOR THE BANDED STRUCTURE OF THE JACOBIAN:
138 C MLJAC=N: JACOBIAN IS A FULL MATRIX. THE LINEAR
139 C ALGEBRA IS DONE BY FULL-MATRIX GAUSS-ELIMINATION.
140 C 0<=MLJAC<N: MLJAC IS THE LOWER BANDWITH OF JACOBIAN
141 C MATRIX (>= NUMBER OF NON-ZERO DIAGONALS BELOW
142 C THE MAIN DIAGONAL).
144 C MUJAC UPPER BANDWITH OF JACOBIAN MATRIX (>= NUMBER OF NON-
145 C ZERO DIAGONALS ABOVE THE MAIN DIAGONAL).
146 C NEED NOT BE DEFINED IF MLJAC=N.
148 C ---- MAS,IMAS,MLMAS, AND MUMAS HAVE ANALOG MEANINGS -----
149 C ---- FOR THE "MASS MATRIX" (THE MATRIX "M" OF SECTION IV.8): -
151 C MAS NAME (EXTERNAL) OF SUBROUTINE COMPUTING THE MASS-
153 C IF IMAS=0, THIS MATRIX IS ASSUMED TO BE THE IDENTITY
154 C MATRIX AND NEEDS NOT TO BE DEFINED;
155 C SUPPLY A DUMMY SUBROUTINE IN THIS CASE.
156 C IF IMAS=1, THE SUBROUTINE MAS IS OF THE FORM
157 C SUBROUTINE MAS(N,AM,LMAS)
158 C KPP_REAL AM(LMAS,N)
160 C IF (MLMAS.EQ.N) THE MASS-MATRIX IS STORED
161 C AS FULL MATRIX LIKE
163 C ELSE, THE MATRIX IS TAKEN AS BANDED AND STORED
165 C AM(I-J+MUMAS+1,J) = M(I,J).
167 C IMAS GIVES INFORMATION ON THE MASS-MATRIX:
168 C IMAS=0: M IS SUPPOSED TO BE THE IDENTITY
169 C MATRIX, MAS IS NEVER CALLED.
170 C IMAS=1: MASS-MATRIX IS SUPPLIED.
172 C MLMAS SWITCH FOR THE BANDED STRUCTURE OF THE MASS-MATRIX:
173 C MLMAS=N: THE FULL MATRIX CASE. THE LINEAR
174 C ALGEBRA IS DONE BY FULL-MATRIX GAUSS-ELIMINATION.
175 C 0<=MLMAS<N: MLMAS IS THE LOWER BANDWITH OF THE
176 C MATRIX (>= NUMBER OF NON-ZERO DIAGONALS BELOW
177 C THE MAIN DIAGONAL).
178 C MLMAS IS SUPPOSED TO BE .LE. MLJAC.
180 C MUMAS UPPER BANDWITH OF MASS-MATRIX (>= NUMBER OF NON-
181 C ZERO DIAGONALS ABOVE THE MAIN DIAGONAL).
182 C NEED NOT BE DEFINED IF MLMAS=N.
183 C MUMAS IS SUPPOSED TO BE .LE. MUJAC.
185 C SOLOUT NAME (EXTERNAL) OF SUBROUTINE PROVIDING THE
186 C NUMERICAL SOLUTION DURING INTEGRATION.
187 C IF IOUT>=1, IT IS CALLED AFTER EVERY SUCCESSFUL STEP.
188 C SUPPLY A DUMMY SUBROUTINE IF IOUT=0.
189 C IT MUST HAVE THE FORM
190 C SUBROUTINE SOLOUT (NR,XOLD,X,Y,RC,LRC,IC,LIC,N,
192 C KPP_REAL X,Y(N),RC(LRC),IC(LIC)
194 C SOLOUT FURNISHES THE SOLUTION "Y" AT THE NR-TH
195 C GRID-POINT "X" (THEREBY THE INITIAL VALUE IS
196 C THE FIRST GRID-POINT).
197 C "XOLD" IS THE PRECEEDING GRID-POINT.
198 C "IRTRN" SERVES TO INTERRUPT THE INTEGRATION. IF IRTRN
199 C IS SET <0, SEULEX RETURNS TO THE CALLING PROGRAM.
200 C DO NOT CHANGE THE ENTRIES OF RC(LRC),IC(LIC)!
202 C ----- CONTINUOUS OUTPUT (IF IOUT=2): -----
203 C DURING CALLS TO "SOLOUT", A CONTINUOUS SOLUTION
204 C FOR THE INTERVAL [XOLD,X] IS AVAILABLE THROUGH
205 C THE KPP_REAL FUNCTION
206 C >>> CONTEX(I,S,RC,LRC,IC,LIC) <<<
207 C WHICH PROVIDES AN APPROXIMATION TO THE I-TH
208 C COMPONENT OF THE SOLUTION AT THE POINT S. THE VALUE
209 C S SHOULD LIE IN THE INTERVAL [XOLD,X].
211 C IOUT GIVES INFORMATION ON THE SUBROUTINE SOLOUT:
212 C IOUT=0: SUBROUTINE IS NEVER CALLED
213 C IOUT=1: SUBROUTINE IS USED FOR OUTPUT
214 C IOUT=2: DENSE OUTPUT IS PERFORMED IN SOLOUT
216 C WORK ARRAY OF WORKING SPACE OF LENGTH "LWORK".
217 C SERVES AS WORKING SPACE FOR ALL VECTORS AND MATRICES.
218 C "LWORK" MUST BE AT LEAST
219 C N*(LJAC+LMAS+LE1+KM+8)+4*KM+20+KM2*NRDENS
221 C KM2=2+KM*(KM+3)/2 AND NRDENS=IWORK(6) (SEE BELOW)
223 C LJAC=N IF MLJAC=N (FULL JACOBIAN)
224 C LJAC=MLJAC+MUJAC+1 IF MLJAC<N (BANDED JAC.)
227 C LMAS=N IF IMAS=1 AND MLMAS=N (FULL)
228 C LMAS=MLMAS+MUMAS+1 IF MLMAS<N (BANDED MASS-M.)
230 C LE1=N IF MLJAC=N (FULL JACOBIAN)
231 C LE1=2*MLJAC+MUJAC+1 IF MLJAC<N (BANDED JAC.).
233 C KM=12 IF IWORK(3)=0
234 C KM=IWORK(3) IF IWORK(3).GT.0
236 C IN THE USUAL CASE WHERE THE JACOBIAN IS FULL AND THE
237 C MASS-MATRIX IS THE INDENTITY (IMAS=0), THE MINIMUM
238 C STORAGE REQUIREMENT IS
239 C LWORK = 2*N*N+(KM+8)*N+4*KM+13+KM2*NRDENS.
240 C IF IWORK(9)=M1>0 THEN "LWORK" MUST BE AT LEAST
241 C N*(LJAC+KM+8)+(N-M1)*(LMAS+LE1)+4*KM+20+KM2*NRDENS
242 C WHERE IN THE DEFINITIONS OF LJAC, LMAS AND LE1 THE
243 C NUMBER N CAN BE REPLACED BY N-M1.
245 C LWORK DECLARED LENGTH OF ARRAY "WORK".
247 C IWORK INTEGER WORKING SPACE OF LENGTH "LIWORK".
248 C "LIWORK" MUST BE AT LEAST 2*N+KM+20+NRDENS.
250 C LIWORK DECLARED LENGTH OF ARRAY "IWORK".
252 C RPAR, IPAR REAL AND INTEGER PARAMETERS (OR PARAMETER ARRAYS) WHICH
253 C CAN BE USED FOR COMMUNICATION BETWEEN YOUR CALLING
254 C PROGRAM AND THE FCN, JAC, MAS, SOLOUT SUBROUTINES.
256 C ----------------------------------------------------------------------
258 C SOPHISTICATED SETTING OF PARAMETERS
259 C -----------------------------------
260 C SEVERAL PARAMETERS OF THE CODE ARE TUNED TO MAKE IT WORK
261 C WELL. THEY MAY BE DEFINED BY SETTING WORK(1),..,WORK(13)
262 C AS WELL AS IWORK(1),..,IWORK(4) DIFFERENT FROM ZERO.
263 C FOR ZERO INPUT, THE CODE CHOOSES DEFAULT VALUES:
265 C IWORK(1) IF IWORK(1).NE.0, THE CODE TRANSFORMS THE JACOBIAN
266 C MATRIX TO HESSENBERG FORM. THIS IS PARTICULARLY
267 C ADVANTAGEOUS FOR LARGE SYSTEMS WITH FULL JACOBIAN.
268 C IT DOES NOT WORK FOR BANDED JACOBIAN (MLJAC<N)
269 C AND NOT FOR IMPLICIT SYSTEMS (IMAS=1).
271 C IWORK(2) THIS IS THE MAXIMAL NUMBER OF ALLOWED STEPS.
272 C THE DEFAULT VALUE (FOR IWORK(2)=0) IS 100000.
274 C IWORK(3) THE MAXIMUM NUMBER OF COLUMNS IN THE EXTRAPOLATION
275 C TABLE. THE DEFAULT VALUE (FOR IWORK(3)=0) IS 12.
276 C IF IWORK(3).NE.0 THEN IWORK(3) SHOULD BE .GE.3.
278 C IWORK(4) SWITCH FOR THE STEP SIZE SEQUENCE
279 C IF IWORK(4).EQ.1 THEN 1,2,3,4,6,8,12,16,24,32,48,...
280 C IF IWORK(4).EQ.2 THEN 2,3,4,6,8,12,16,24,32,48,64,...
281 C IF IWORK(4).EQ.3 THEN 1,2,3,4,5,6,7,8,9,10,...
282 C IF IWORK(4).EQ.4 THEN 2,3,4,5,6,7,8,9,10,11,...
283 C THE DEFAULT VALUE (FOR IWORK(4)=0) IS IWORK(4)=2.
285 C IWORK(5) PARAMETER "LAMBDA" OF DENSE OUTPUT; POSSIBLE VALUES
286 C ARE 0 AND 1; DEFAULT IWORK(5)=0.
288 C IWORK(6) = NRDENS = NUMBER OF COMPONENTS, FOR WHICH DENSE OUTPUT
291 C IWORK(21),...,IWORK(NRDENS+20) INDICATE THE COMPONENTS, FOR WHICH
292 C DENSE OUTPUT IS REQUIRED
294 C IF THE DIFFERENTIAL SYSTEM HAS THE SPECIAL STRUCTURE THAT
295 C Y(I)' = Y(I+M2) FOR I=1,...,M1,
296 C WITH M1 A MULTIPLE OF M2, A SUBSTANTIAL GAIN IN COMPUTERTIME
297 C CAN BE ACHIEVED BY SETTING THE FOLLOWING TWO PARAMETERS. E.G.,
298 C FOR SECOND ORDER SYSTEMS P'=V, V'=G(P,V), WHERE P AND V ARE
299 C VECTORS OF DIMENSION N/2, ONE HAS TO PUT M1=M2=N/2.
300 C FOR M1>0 SOME OF THE INPUT PARAMETERS HAVE DIFFERENT MEANINGS:
301 C - JAC: ONLY THE ELEMENTS OF THE NON-TRIVIAL PART OF THE
302 C JACOBIAN HAVE TO BE STORED
303 C IF (MLJAC.EQ.N-M1) THE JACOBIAN IS SUPPOSED TO BE FULL
304 C DFY(I,J) = PARTIAL F(I+M1) / PARTIAL Y(J)
305 C FOR I=1,N-M1 AND J=1,N.
306 C ELSE, THE JACOBIAN IS BANDED ( M1 = M2 * MM )
307 C DFY(I-J+MUJAC+1,J+K*M2) = PARTIAL F(I+M1) / PARTIAL Y(J+K*M2)
308 C FOR I=1,MLJAC+MUJAC+1 AND J=1,M2 AND K=0,MM.
309 C - MLJAC: MLJAC=N-M1: IF THE NON-TRIVIAL PART OF THE JACOBIAN IS FULL
310 C 0<=MLJAC<N-M1: IF THE (MM+1) SUBMATRICES (FOR K=0,MM)
311 C PARTIAL F(I+M1) / PARTIAL Y(J+K*M2), I,J=1,M2
312 C ARE BANDED, MLJAC IS THE MAXIMAL LOWER BANDWIDTH
313 C OF THESE MM+1 SUBMATRICES
314 C - MUJAC: MAXIMAL UPPER BANDWIDTH OF THESE MM+1 SUBMATRICES
315 C NEED NOT BE DEFINED IF MLJAC=N-M1
316 C - MAS: IF IMAS=0 THIS MATRIX IS ASSUMED TO BE THE IDENTITY AND
317 C NEED NOT BE DEFINED. SUPPLY A DUMMY SUBROUTINE IN THIS CASE.
318 C IT IS ASSUMED THAT ONLY THE ELEMENTS OF RIGHT LOWER BLOCK OF
319 C DIMENSION N-M1 DIFFER FROM THAT OF THE IDENTITY MATRIX.
320 C IF (MLMAS.EQ.N-M1) THIS SUBMATRIX IS SUPPOSED TO BE FULL
321 C AM(I,J) = M(I+M1,J+M1) FOR I=1,N-M1 AND J=1,N-M1.
322 C ELSE, THE MASS MATRIX IS BANDED
323 C AM(I-J+MUMAS+1,J) = M(I+M1,J+M1)
324 C - MLMAS: MLMAS=N-M1: IF THE NON-TRIVIAL PART OF M IS FULL
325 C 0<=MLMAS<N-M1: LOWER BANDWIDTH OF THE MASS MATRIX
326 C - MUMAS: UPPER BANDWIDTH OF THE MASS MATRIX
327 C NEED NOT BE DEFINED IF MLMAS=N-M1
329 C IWORK(9) THE VALUE OF M1. DEFAULT M1=0.
331 C IWORK(10) THE VALUE OF M2. DEFAULT M2=M1.
333 C WORK(1) UROUND, THE ROUNDING UNIT, DEFAULT 1.D-16.
335 C WORK(2) MAXIMAL STEP SIZE, DEFAULT XEND-X.
337 C WORK(3) DECIDES WHETHER THE JACOBIAN SHOULD BE RECOMPUTED;
338 C INCREASE WORK(3), TO 0.01 SAY, WHEN JACOBIAN EVALUATIONS
339 C ARE COSTLY. FOR SMALL SYSTEMS WORK(3) SHOULD BE SMALLER.
340 C DEFAULT MIN(1.0D-4,RelTol(1))
342 C WORK(4), WORK(5) PARAMETERS FOR STEP SIZE SELECTION
343 C THE NEW STEP SIZE FOR THE J-TH DIAGONAL ENTRY IS
344 C CHOSEN SUBJECT TO THE RESTRICTION
345 C FACMIN/WORK(5) <= HNEW(J)/HOLD <= 1/FACMIN
346 C WHERE FACMIN=WORK(4)**(1/(J-1))
347 C DEFAULT VALUES: WORK(4)=0.1D0, WORK(5)=4.D0
349 C WORK(6), WORK(7) PARAMETERS FOR THE ORDER SELECTION
350 C ORDER IS DECREASED IF W(K-1) <= W(K)*WORK(6)
351 C ORDER IS INCREASED IF W(K) <= W(K-1)*WORK(7)
352 C DEFAULT VALUES: WORK(6)=0.7D0, WORK(7)=0.9D0
354 C WORK(8), WORK(9) SAFETY FACTORS FOR STEP CONTROL ALGORITHM
355 C HNEW=H*WORK(9)*(WORK(8)*TOL/ERR)**(1/(J-1))
356 C DEFAULT VALUES: WORK(8)=0.8D0, WORK(9)=0.93D0
358 C WORK(10), WORK(11), WORK(12), WORK(13) ESTIMATED WORKS FOR
359 C A CALL TO FCN, JAC, DEC, SOL, RESPECTIVELY.
360 C DEFAULT VALUES ARE: WORK(10)=1.D0, WORK(11)=5.D0,
361 C WORK(12)=1.D0, WORK(13)=1.D0.
363 C-----------------------------------------------------------------------
367 C X X-VALUE WHERE THE SOLUTION IS COMPUTED
368 C (AFTER SUCCESSFUL RETURN X=XEND)
372 C H PREDICTED STEP SIZE OF THE LAST ACCEPTED STEP
374 C IDID REPORTS ON SUCCESSFULNESS UPON RETURN:
375 C IDID=1 COMPUTATION SUCCESSFUL,
376 C IDID=-1 COMPUTATION UNSUCCESSFUL.
378 C IWORK(14) NFCN NUMBER OF FUNCTION EVALUATIONS (THOSE FOR NUMERICAL
379 C EVALUATION OF THE JACOBIAN ARE NOT COUNTED)
380 C IWORK(15) NJAC NUMBER OF JACOBIAN EVALUATIONS (EITHER ANALYTICALLY
382 C IWORK(16) NSTEP NUMBER OF COMPUTED STEPS
383 C IWORK(17) NACCPT NUMBER OF ACCEPTED STEPS
384 C IWORK(18) NREJCT NUMBER OF REJECTED STEPS (AFTER AT LEAST ONE STEP
386 C IWORK(19) NDEC NUMBER OF LU-DECOMPOSITIONS (N-DIMENSIONAL MATRIX)
387 C IWORK(20) NSOL NUMBER OF FORWARD-BACKWARD SUBSTITUTIONS
388 C-----------------------------------------------------------------------
389 C *** *** *** *** *** *** *** *** *** *** *** *** ***
391 C *** *** *** *** *** *** *** *** *** *** *** *** ***
392 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
393 DIMENSION Y
(N
),AbsTol
(*),RelTol
(*),WORK
(LWORK
),IWORK
(LIWORK
)
394 LOGICAL AUTNMS
,IMPLCT
,ARRET
,JBAND
396 C *** *** *** *** *** *** ***
397 C SETTING THE PARAMETERS
398 C *** *** *** *** *** *** ***
408 C -------- NMAX , THE MAXIMAL NUMBER OF STEPS -----
409 IF(IWORK
(2).EQ
.0)THEN
414 WRITE(6,*)' WRONG INPUT IWORK(2)=',IWORK
(2)
418 C -------- KM MAXIMUM NUMBER OF COLUMNS IN THE EXTRAPOLATION
419 IF(IWORK
(3).EQ
.0)THEN
424 WRITE(6,*)' CURIOUS INPUT IWORK(3)=',IWORK
(3)
428 C -------- NSEQU CHOICE OF STEP SIZE SEQUENCE
430 IF(IWORK
(4).EQ
.0) NSEQU
=2
431 IF(NSEQU
.LE
.0.OR
.NSEQU
.GE
.5)THEN
432 WRITE(6,*)' CURIOUS INPUT IWORK(4)=',IWORK
(4)
435 C -------- LAMBDA PARAMETER FOR DENSE OUTPUT
437 IF(LAMBDA
.LT
.0.OR
.LAMBDA
.GE
.2)THEN
438 WRITE(6,*)' CURIOUS INPUT IWORK(5)=',IWORK
(5)
441 C -------- NRDENS NUMBER OF DENSE OUTPUT COMPONENTS
443 IF(NRDENS
.LT
.0.OR
.NRDENS
.GT
.N
)THEN
444 WRITE(6,*)' CURIOUS INPUT IWORK(6)=',IWORK
(6)
447 C -------- PARAMETER FOR SECOND ORDER EQUATIONS
453 IF (M1
.LT
.0.OR
.M2
.LT
.0.OR
.M1
+M2
.GT
.N
) THEN
454 WRITE(6,*)' CURIOUS INPUT FOR IWORK(9,10)=',M1
,M2
457 C -------- UROUND SMALLEST NUMBER SATISFYING 1.D0+UROUND>1.D0
458 IF(WORK
(1).EQ
.0.D0
)THEN
462 IF(UROUND
.LE
.0.D0
.OR
.UROUND
.GE
.1.D0
)THEN
463 WRITE(6,*)' UROUND=',WORK
(1)
467 C -------- MAXIMAL STEP SIZE
468 IF(WORK
(2).EQ
.0.D0
)THEN
473 C ------ THET DECIDES WHETHER THE JACOBIAN SHOULD BE RECOMPUTED;
474 IF(WORK
(3).EQ
.0.D0
)THEN
475 THET
=MIN
(1.0D
-4,RelTol
(1))
479 C ------- FAC1,FAC2 PARAMETERS FOR STEP SIZE SELECTION
480 IF(WORK
(4).EQ
.0.D0
)THEN
485 IF(WORK
(5).EQ
.0.D0
)THEN
490 C ------- FAC3, FAC4 PARAMETERS FOR THE ORDER SELECTION
491 IF(WORK
(6).EQ
.0.D0
)THEN
496 IF(WORK
(7).EQ
.0.D0
)THEN
501 C ------- SAFE1, SAFE2 SAFETY FACTORS FOR STEP SIZE PREDICTION
502 IF(WORK
(8).EQ
.0.D0
)THEN
507 IF(WORK
(9).EQ
.0.D0
)THEN
512 C ------- WKFCN,WKJAC,WKDEC,WKSOL ESTIMATED WORK FOR FCN,JAC,DEC,SOL
513 IF(WORK
(10).EQ
.0.D0
)THEN
518 IF(WORK
(11).EQ
.0.D0
)THEN
523 IF(WORK
(12).EQ
.0.D0
)THEN
528 IF(WORK
(13).EQ
.0.D0
)THEN
534 C --------- CHECK IF TOLERANCES ARE O.K.
536 IF (AbsTol
(1).LE
.0.D0
.OR
.RelTol
(1).LE
.10.D0*UROUND
) THEN
537 WRITE (6,*) ' TOLERANCES ARE TOO SMALL'
542 IF (AbsTol
(I
).LE
.0.D0
.OR
.RelTol
(I
).LE
.10.D0*UROUND
) THEN
543 WRITE (6,*) ' TOLERANCES(',I
,') ARE TOO SMALL'
548 C *** *** *** *** *** *** *** *** *** *** *** *** ***
549 C COMPUTATION OF ARRAY ENTRIES
550 C *** *** *** *** *** *** *** *** *** *** *** *** ***
551 C ---- AUTONOMOUS, IMPLICIT, BANDED OR NOT ?
555 C -------- COMPUTATION OF THE ROW-DIMENSIONS OF THE 2-ARRAYS ---
556 C -- JACOBIAN AND MATRIX E
568 IF (MLMAS
.NE
.NM1
) THEN
579 C ------ BANDWITH OF "MAS" NOT LARGER THAN BANDWITH OF "JAC"
580 IF (MLMAS
.GT
.MLJAC
.OR
.MUMAS
.GT
.MUJAC
) THEN
581 WRITE (6,*) 'BANDWITH OF "MAS" NOT LARGER THAN BANDWITH OF
591 IF (N
.GT
.2.AND
.IWORK
(1).NE
.0) IJOB
=7
595 C ------ HESSENBERG OPTION ONLY FOR EXPLICIT EQU. WITH FULL JACOBIAN
596 IF ((IMPLCT
.OR
.JBAND
).AND
.IJOB
.EQ
.7) THEN
597 WRITE(6,*)' HESSENBERG OPTION ONLY FOR EXPLICIT EQUATIONS WITH
601 C ------- PREPARE THE ENTRY-POINTS FOR THE ARRAYS IN WORK -----
620 IFSAFE
=IEDE
+(KM
+2)*NRDENS
621 C ------ TOTAL STORAGE REQUIREMENT -----------
622 ISTORE
=IFSAFE
+KM2*NRDENS
-1
623 IF(ISTORE
.GT
.LWORK
)THEN
624 WRITE(6,*)' INSUFFICIENT STORAGE FOR WORK, MIN. LWORK=',ISTORE
627 C ------- ENTRY POINTS FOR INTEGER WORKSPACE -----
632 C --------- TOTAL REQUIREMENT ---------------
634 IF(ISTORE
.GT
.LIWORK
)THEN
635 WRITE(6,*)' INSUFF. STORAGE FOR IWORK, MIN. LIWORK=',ISTORE
638 C ------ WHEN A FAIL HAS OCCURED, WE RETURN WITH IDID=-1
644 C -------- CALL TO CORE INTEGRATOR ------------
645 CALL SEUCOR
(N
,FCN
,X
,Y
,XEND
,HMAX
,H
,KM
,RelTol
,AbsTol
,ITOL
,JAC
,IJAC
,
646 & MLJAC
,MUJAC
,MLMAS
,MUMAS
,IOUT
,IDID
,IJOB
,M1
,M2
,NM1
,
647 & NMAX
,UROUND
,NSEQU
,AUTNMS
,IMPLCT
,JBAND
,LDJAC
,LDE
,LDMAS2
,
648 & WORK
(IEYH
),WORK
(IEDY
),WORK
(IEFX
),WORK
(IEYHH
),WORK
(IEDYH
),
649 & WORK
(IEDEL
),WORK
(IEWH
),WORK
(IESCAL
),WORK
(IEHH
),
650 & WORK
(IEW
),WORK
(IEA
),WORK
(IEJAC
),WORK
(IEE
),WORK
(IEMAS
),
651 & WORK
(IET
),IWORK
(IEIP
),IWORK
(IENJ
),IWORK
(IEIPH
),FAC1
,FAC2
,FAC3
,
652 & FAC4
,THET
,SAFE1
,SAFE2
,WKJAC
,WKDEC
,WKROW
,KM2
,NRD
,WORK
(IFAC
),
653 & WORK
(IFSAFE
),LAMBDA
,NFCN
,NJAC
,NSTEP
,NACCPT
,NREJCT
,NDEC
,NSOL
,
654 & WORK
(IEDE
),IWORK
(IECO
))
662 C ----------- RETURN -----------
667 C ----- ... AND HERE IS THE CORE INTEGRATOR ----------
669 SUBROUTINE SEUCOR
(N
,FCN
,X
,Y
,XEND
,HMAX
,H
,KM
,RelTol
,AbsTol
,ITOL
,
670 & JAC
,IJAC
,MLJAC
,MUJAC
,MLB
,MUB
,IOUT
,IDID
,IJOB
,M1
,M2
,
671 & NM1
,NMAX
,UROUND
,NSEQU
,AUTNMS
,IMPLCT
,BANDED
,LFJAC
,LE
,
672 & LDMAS
,YH
,DY
,FX
,YHH
,DYH
,DEL
,WH
,SCAL
,HH
,W
,A
,FJAC
,E
,FMAS
,T
,IP
,
673 & NJ
,IPHES
,FAC1
,FAC2
,FAC3
,FAC4
,THET
,SAFE1
,SAFE2
,WKJAC
,WKDEC
,WKROW
,
674 & KM2
,NRD
,FACUL
,FSAFE
,LAMBDA
,NFCN
,NJAC
,NSTEP
,NACCPT
,NREJCT
,
675 & NDEC
,NSOL
,DENS
,ICOMP
)
676 C ----------------------------------------------------------
677 C CORE INTEGRATOR FOR SEULEX
678 C PARAMETERS SAME AS IN SEULEX WITH WORKSPACE ADDED
679 C ----------------------------------------------------------
681 C ----------------------------------------------------------
682 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
683 INCLUDE
'KPP_ROOT_Parameters.h'
684 INCLUDE
'KPP_ROOT_Sparse.h'
685 INTEGER KM
, KM2
, K
, KC
, KRIGHT
, KLR
, KK
, KRN
, KOPT
686 DIMENSION Y
(N
),YH
(N
),DY
(N
),FX
(N
),YHH
(N
),DYH
(N
),DEL
(N
)
687 DIMENSION WH
(N
),SCAL
(N
),HH
(KM
),W
(KM
),A
(KM
),FJAC
(LU_NONZERO
)
688 DIMENSION FMAS
(LDMAS
,NM1
),T
(KM
,N
),IP
(NM1
),NJ
(KM
)
689 DIMENSION RelTol
(*),AbsTol
(*)
690 DIMENSION IPHES
(N
),FSAFE
(KM2
,NRD
),FACUL
(KM
),E
(LE
,NM1
)
691 DIMENSION DENS
((KM
+2)*NRD
),ICOMP
(NRD
)
692 LOGICAL REJECT
,LAST
,ATOV
,CALJAC
,CALHES
,AUTNMS
,IMPLCT
,BANDED
694 COMMON /COSEU
/XOLDD
,HHH
,NNRD
,KRIGHT
695 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
696 C --- COMPUTE COEFFICIENTS FOR DENSE OUTPUT
699 C --- COMPUTE THE FACTORIALS --------
702 FACUL
(I
+1)=I*FACUL
(I
)
706 C *** *** *** *** *** *** ***
708 C *** *** *** *** *** *** ***
717 IF (M1
.GT
.0) IJOB
=IJOB
+10
718 C --- DEFINE THE STEP SIZE SEQUENCE
735 IF (NSEQU
.EQ
.3) NJ
(I
)=I
736 IF (NSEQU
.EQ
.4) NJ
(I
)=I
+1
738 A
(1)=WKJAC
+NJ
(1)*WKROW
+WKDEC
740 A
(I
)=A
(I
-1)+(NJ
(I
)-1)*WKROW
+WKDEC
742 K
=MAX0
(3,MIN0
(KM
-2,INT
(-DLOG10
(RelTol
(1)+AbsTol
(1))*.6D0
+1.5D0
)))
743 HMAXN
=MIN
(ABS
(HMAX
),ABS
(XEND
-X
))
744 IF (ABS
(H
).LE
.10.D0*UROUND
) H
=1.0D
-6
751 SCAL
(I
)=AbsTol
(1)+RelTol
(1)*DABS
(Y
(I
))
753 SCAL
(I
)=AbsTol
(I
)+RelTol
(I
)*DABS
(Y
(I
))
760 IF (REJECT
) THETA
=2*ABS
(THET
)
762 C *** *** *** *** *** *** ***
763 C --- IS XEND REACHED IN THE NEXT STEP?
764 C *** *** *** *** *** *** ***
766 IF (H1
.LE
.UROUND
) GO TO 110
769 IF (H
.GE
.H1
-UROUND
) LAST
=.TRUE
.
774 IF (THETA
.GT
.THET
.AND
..NOT
.CALJAC
) THEN
775 C *** *** *** *** *** *** ***
776 C COMPUTATION OF THE JACOBIAN
777 C *** *** *** *** *** *** ***
779 C --- COMPUTE JACOBIAN MATRIX ANALYTICALLY
784 C *** *** *** *** *** *** ***
785 C --- THE FIRST AND LAST STEP
786 C *** *** *** *** *** *** ***
787 IF (NSTEP
.EQ
.0.OR
.LAST
) THEN
792 CALL SEUL
(J
,N
,FCN
,X
,Y
,DY
,FX
,FJAC
,LFJAC
,FMAS
,LDMAS
,E
,LE
,IP
,H
,KM
,
793 & HMAXN
,T
,SCAL
,NJ
,HH
,W
,A
,YHH
,DYH
,DEL
,WH
,ERR
,SAFE1
,FAC
,
794 & FAC1
,FAC2
,SAFE2
,THETA
,MLJAC
,MUJAC
,NFCN
,NDEC
,NSOL
,MLB
,
795 & MUB
,ERROLD
,IPHES
,ICOMP
,AUTNMS
,IMPLCT
,BANDED
,REJECT
,
796 & ATOV
,FSAFE
,KM2
,NRD
,IOUT
,IPT
,M1
,M2
,NM1
,IJOB
,CALHES
)
798 IF (J
.GT
.1.AND
.ERR
.LE
.1.D0
) GO TO 60
802 C --- BASIC INTEGRATION STEP
806 IF (NSTEP
.GE
.NMAX
) GO TO 120
809 CALL SEUL
(J
,N
,FCN
,X
,Y
,DY
,FX
,FJAC
,LFJAC
,FMAS
,LDMAS
,E
,LE
,IP
,H
,KM
,
810 & HMAXN
,T
,SCAL
,NJ
,HH
,W
,A
,YHH
,DYH
,DEL
,WH
,ERR
,SAFE1
,
811 & FAC
,FAC1
,FAC2
,SAFE2
,THETA
,MLJAC
,MUJAC
,NFCN
,NDEC
,NSOL
,
812 & MLB
,MUB
,ERROLD
,IPHES
,ICOMP
,AUTNMS
,IMPLCT
,BANDED
,REJECT
,
813 & ATOV
,FSAFE
,KM2
,NRD
,IOUT
,IPT
,M1
,M2
,NM1
,IJOB
,CALHES
)
816 C *** *** *** *** *** *** ***
817 C --- CONVERGENCE MONITOR
818 C *** *** *** *** *** *** ***
819 IF (K
.EQ
.2.OR
.REJECT
) GO TO 50
820 IF (ERR
.LE
.1.D0
) GO TO 60
821 IF (ERR
.GT
.DBLE
(NJ
(K
+1)*NJ
(K
))*4.D0
) GO TO 100
822 50 CALL SEUL
(K
,N
,FCN
,X
,Y
,DY
,FX
,FJAC
,LFJAC
,FMAS
,LDMAS
,E
,LE
,IP
,H
,KM
,
823 & HMAXN
,T
,SCAL
,NJ
,HH
,W
,A
,YHH
,DYH
,DEL
,WH
,ERR
,SAFE1
,
824 & FAC
,FAC1
,FAC2
,SAFE2
,THETA
,MLJAC
,MUJAC
,NFCN
,NDEC
,NSOL
,
825 & MLB
,MUB
,ERROLD
,IPHES
,ICOMP
,AUTNMS
,IMPLCT
,BANDED
,REJECT
,
826 & ATOV
,FSAFE
,KM2
,NRD
,IOUT
,IPT
,M1
,M2
,NM1
,IJOB
,CALHES
)
829 IF (ERR
.LE
.1.D0
) GO TO 60
830 C --- HOPE FOR CONVERGENCE IN LINE K+1
831 55 IF (ERR
.GT
.DBLE
(NJ
(K
+1))*2.D0
) GO TO 100
833 CALL SEUL
(KC
,N
,FCN
,X
,Y
,DY
,FX
,FJAC
,LFJAC
,FMAS
,LDMAS
,E
,LE
,IP
,H
,KM
,
834 & HMAXN
,T
,SCAL
,NJ
,HH
,W
,A
,YHH
,DYH
,DEL
,WH
,ERR
,SAFE1
,
835 & FAC
,FAC1
,FAC2
,SAFE2
,THETA
,MLJAC
,MUJAC
,NFCN
,NDEC
,NSOL
,
836 & MLB
,MUB
,ERROLD
,IPHES
,ICOMP
,AUTNMS
,IMPLCT
,BANDED
,REJECT
,
837 & ATOV
,FSAFE
,KM2
,NRD
,IOUT
,IPT
,M1
,M2
,NM1
,IJOB
,CALHES
)
839 CAdi IF (ERR.GT.1.D0) GO TO 100
840 IF ((ERR
.GT
.1.D0
).and
.(H
.gt
.STEPMIN
)) GO TO 100 ! Adi
841 C *** *** *** *** *** *** ***
842 C --- STEP IS ACCEPTED
843 C *** *** *** *** *** *** ***
855 SCAL
(I
)=AbsTol
(1)+RelTol
(1)*DABS
(T1I
)
857 SCAL
(I
)=AbsTol
(I
)+RelTol
(I
)*DABS
(T1I
)
867 DENS
(NRD
+I
)=Y
(ICOMP
(I
))
870 C --- COMPUTE DIFFERENCES
877 FSAFE
(L
,I
)=FSAFE
(L
,I
)-FSAFE
(L
-1,I
)
882 C --- COMPUTE DERIVATIVES AT RIGHT END ----
885 FACNJ
=FACNJ**KLR
/FACUL
(KLR
+1)
888 KRN
=(KK
-LAMBDA
+1)*NRD
889 DENS
(KRN
+I
)=FSAFE
(IPT
,I
)*FACNJ
894 DO L
=J
,KLR
+LAMBDA
+1,-1
895 FACTOR
=DBLENJ
/NJ
(L
-1)-1.D0
897 KRN
=(L
-LAMBDA
+1)*NRD
+I
898 DENS
(KRN
-NRD
)=DENS
(KRN
)
899 & +(DENS
(KRN
)-DENS
(KRN
-NRD
))/FACTOR
904 C --- COMPUTE THE COEFFICIENTS OF THE INTERPOLATION POLYNOMIAL
908 DENS
(II
)=DENS
(II
)-DENS
(II
-NRD
)
912 C --- COMPUTE OPTIMAL ORDER
920 IF (W
(KC
-1).LT
.W
(KC
)*FAC3
) KOPT
=KC
-1
921 IF (W
(KC
).LT
.W
(KC
-1)*FAC4
) KOPT
=MIN0
(KC
+1,KM
-1)
924 IF (KC
.GT
.3.AND
.W
(KC
-2).LT
.W
(KC
-1)*FAC3
) KOPT
=KC
-2
925 IF (W
(KC
).LT
.W
(KOPT
)*FAC4
) KOPT
=MIN0
(KC
,KM
-1)
927 C --- AFTER A REJECTED STEP
934 C --- COMPUTE STEP SIZE FOR NEXT STEP
938 IF (KC
.LT
.K
.AND
.W
(KC
).LT
.W
(KC
-1)*FAC4
) THEN
939 H
=HH
(KC
)*A
(KOPT
+1)/A
(KC
)
941 H
=HH
(KC
)*A
(KOPT
)/A
(KC
)
945 H
= DMAX1
(H
, STEPMIN
) ! Adi
947 C *** *** *** *** *** *** ***
948 C --- STEP IS REJECTED
949 C *** *** *** *** *** *** ***
951 IF (K
.GT
.2.AND
.W
(K
-1).LT
.W
(K
)*FAC3
) K
=K
-1
964 120 WRITE (6,979) X
,H
965 979 FORMAT(' EXIT OF SEULEX AT X=',D14
.7
,' H=',D14
.7
)
971 C *** *** *** *** *** *** ***
972 C S U B R O U T I N E S E U L
973 C *** *** *** *** *** *** ***
975 SUBROUTINE SEUL
(JJ
,N
,FCN
,X
,Y
,DY
,FX
,FJAC
,LFJAC
,FMAS
,LDMAS
,E
,LE
,IP
,
976 & H
,KM
,HMAXN
,T
,SCAL
,NJ
,HH
,W
,A
,YH
,DYH
,DEL
,WH
,ERR
,SAFE1
,
977 & FAC
,FAC1
,FAC2
,SAFE2
,THETA
,MLJAC
,MUJAC
,NFCN
,NDEC
,NSOL
,
978 & MLB
,MUB
,ERROLD
,IPHES
,ICOMP
,
979 & AUTNMS
,IMPLCT
,BANDED
,REJECT
,ATOV
,FSAFE
,KM2
,NRD
,IOUT
,
980 & IPT
,M1
,M2
,NM1
,IJOB
,CALHES
)
981 C --- THIS SUBROUTINE COMPUTES THE J-TH LINE OF THE
982 C --- EXTRAPOLATION TABLE AND PROVIDES AN ESTIMATE
983 C --- OF THE OPTIMAL STEP SIZE
984 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
985 INCLUDE
'KPP_ROOT_Parameters.h'
986 INCLUDE
'KPP_ROOT_Sparse.h'
988 DIMENSION Y
(N
),YH
(N
),DY
(N
),FX
(N
),DYH
(N
),DEL
(N
)
989 DIMENSION WH
(N
),SCAL
(N
),HH
(KM
),W
(KM
),A
(KM
)
990 DIMENSION FJAC
(LU_NONZERO
),E
(LU_NONZERO
)
991 DIMENSION FMAS
(LDMAS
,N
),T
(KM
,N
),IP
(N
),NJ
(KM
),IPHES
(N
)
992 DIMENSION FSAFE
(KM2
,NRD
),ICOMP
(NRD
)
993 LOGICAL ATOV
,REJECT
,AUTNMS
,IMPLCT
,BANDED
,CALHES
994 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
996 C *** *** *** *** *** *** ***
997 C COMPUTE THE MATRIX E AND ITS DECOMPOSITION
998 C *** *** *** *** *** *** ***
1005 E
(LU_DIAG
(J
))=E
(LU_DIAG
(J
))+HJI
1007 CALL KppDecomp
(E
,IER
)
1008 IF (IER
.NE
.0) GOTO 79
1010 C *** *** *** *** *** *** ***
1011 C --- STARTING PROCEDURE
1012 C *** *** *** *** *** *** ***
1013 IF (.NOT
.AUTNMS
) THEN
1014 CALL FCN
(N
,X
+HJ
,Y
,DY
)
1021 CALL KppSolve
(E
,DEL
)
1024 IF (IOUT
.EQ
.2.AND
.M
.EQ
.JJ
) THEN
1027 FSAFE
(IPT
,I
)=DEL
(ICOMP
(I
))
1030 C *** *** *** *** *** *** ***
1031 C --- SEMI-IMPLICIT EULER METHOD
1032 C *** *** *** *** *** *** ***
1039 CALL FCN
(N
,X
+HJ*MM
,YH
,DYH
)
1041 CALL FCN
(N
,X
+HJ*
(MM
+1),YH
,DYH
)
1044 IF (MM
.EQ
.1.AND
.JJ
.LE
.2) THEN
1045 C --- STABILITY CHECK
1048 DEL1
=DEL1
+(DEL
(I
)/SCAL
(I
))**2
1055 IF (MLB
.EQ
.NM1
) THEN
1059 SUM
=SUM
+FMAS
(I
,J
)*WH
(J
)
1066 DO J
=MAX
(1,I
-MLB
),MIN
(NM1
,I
+MUB
)
1067 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*WH
(J
)
1073 IF (.NOT
.AUTNMS
) THEN
1074 CALL FCN
(N
,X
+HJ
,YH
,WH
)
1077 DEL
(I
)=WH
(I
)-DEL
(I
)*HJI
1081 DEL
(I
)=DYH
(I
)-DEL
(I
)*HJI
1084 CALL KppSolve
(E
,DEL
)
1088 DEL2
=DEL2
+(DEL
(I
)/SCAL
(I
))**2
1091 THETA
=DEL2
/MAX
(1.D0
,DEL1
)
1092 IF (THETA
.GT
.1.D0
) GOTO 79
1094 CALL KppSolve
(E
,DYH
)
1099 IF (IOUT
.EQ
.2.AND
.MM
.GE
.M
-JJ
) THEN
1102 FSAFE
(IPT
,I
)=DEL
(ICOMP
(I
))
1108 T
(JJ
,I
)=YH
(I
)+DEL
(I
)
1110 C *** *** *** *** *** *** ***
1111 C --- POLYNOMIAL EXTRAPOLATION
1112 C *** *** *** *** *** *** ***
1115 FAC
=(DBLE
(NJ
(JJ
))/DBLE
(NJ
(L
-1)))-1.D0
1117 T
(L
-1,I
)=T
(L
,I
)+(T
(L
,I
)-T
(L
-1,I
))/FAC
1122 ERR
=ERR
+MIN
(ABS
((T
(1,I
)-T
(2,I
)))/SCAL
(I
),1.D15
)**2
1124 IF (ERR
.GE
.1.D30
) GOTO 79
1125 ERR
=DSQRT
(ERR
/DBLE
(N
))
1126 IF (JJ
.GT
.2.AND
.ERR
.GE
.ERROLD
) GOTO 79
1127 ERROLD
=DMAX1
(4*ERR
,1.D0
)
1128 C --- COMPUTE OPTIMAL STEP SIZES
1131 FAC
=DMIN1
(FAC2
/FACMIN
,DMAX1
(FACMIN
,(ERR
/SAFE1
)**EXPO
/SAFE2
))
1133 HH
(JJ
)=DMIN1
(H*FAC
,HMAXN
)
1144 SUBROUTINE FUNC_CHEM
(N
, T
, Y
, P
)
1145 INCLUDE
'KPP_ROOT_Parameters.h'
1146 INCLUDE
'KPP_ROOT_Global.h'
1149 KPP_REAL Y
(NVAR
), P
(NVAR
)
1153 CALL Update_RCONST
()
1154 CALL Fun
( Y
, FIX
, RCONST
, P
)
1160 SUBROUTINE JAC_CHEM
(N
, T
, Y
, J
)
1161 INCLUDE
'KPP_ROOT_Parameters.h'
1162 INCLUDE
'KPP_ROOT_Global.h'
1165 KPP_REAL Y
(NVAR
), J
(LU_NONZERO
)
1169 CALL Update_RCONST
()
1170 CALL Jac_SP
( Y
, FIX
, RCONST
, J
)