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 INTEGER Nfun
, Njac
, Nstp
, Nacc
, Nrej
, Ndec
, Nsol
20 PARAMETER (LWORK
=5*NVAR*NVAR
+12*NVAR
+20,LIWORK
=3*NVAR
+20)
21 PARAMETER (LRCONT
=4*NVAR
+4)
23 KPP_REAL WORK
(LWORK
), RPAR
(1)
24 INTEGER IWORK
(LIWORK
), IPAR
(1)
25 COMMON /CONT
/ ICONT
(4),RCONT
(LRCONT
)
26 EXTERNAL FUNC_CHEM
,JAC_CHEM
,SOLOUT
29 ITOL
=1 ! --- VECTOR TOLERANCES
30 IJAC
=1 ! --- COMPUTE THE JACOBIAN ANALYTICALLY
31 IMAS
=0 ! --- DIFFERENTIAL EQUATION IS IN EXPLICIT FORM
32 IOUT
=0 ! --- OUTPUT ROUTINE IS NOT USED DURING INTEGRATION
33 MLJAC
=NVAR
! --- JACOBIAN IS A FULL MATRIX
34 MUJAC
=NVAR
! --- JACOBIAN IS A FULL MATRIX
35 MLMAS
=NVAR
! --- JACOBIAN IS A FULL MATRIX
36 MUMAS
=NVAR
! --- JACOBIAN IS A FULL MATRIX
43 IWORK
(3) = 8 ! Max no
. of Newton iterations
44 IWORK
(4) = 0 ! Starting values
for Newton are interpolated
(0) or zero
(1)
45 IWORK
(8) = 2 ! Gustaffson
(1) or classic
(2) controller
46 WORK
(2) = 0.9 ! Safety factor
48 CALL RADAU5
(NVAR
,FUNC_CHEM
,TIN
,VAR
,TOUT
,H
,
50 & JAC_CHEM
,IJAC
,MLJAC
,MUJAC
,
51 & FUNC_CHEM
,IMAS
,MLMAS
,MUMAS
,
53 & WORK
,LWORK
,IWORK
,LIWORK
,RPAR
,IPAR
,IDID
)
56 Nfun
= Nfun
+ IWORK
(14)
57 Njac
= Njac
+ IWORK
(15)
58 Nstp
= Nstp
+ IWORK
(16)
59 Nacc
= Nacc
+ IWORK
(17)
60 Nrej
= Nrej
+ IWORK
(18)
61 Ndec
= Ndec
+ IWORK
(19)
62 Nsol
= Nsol
+ IWORK
(20)
64 print
("('Nstep=',I5,' Nacc=',I6,' Nrej=',I6)"),Nstp
, Nacc
, Nrej
67 print
*,'RADAU: Unsucessfull exit at T=',
68 & TIN
,' (IDID=',IDID
,')'
75 SUBROUTINE RADAU5
(N
,FCN
,X
,Y
,XEND
,H
,
77 & JAC
,IJAC
,MLJAC
,MUJAC
,
78 & MAS
,IMAS
,MLMAS
,MUMAS
,
80 & WORK
,LWORK
,IWORK
,LIWORK
,RPAR
,IPAR
,IDID
)
81 C ----------------------------------------------------------
82 C NUMERICAL SOLUTION OF A STIFF (OR DIFFERENTIAL ALGEBRAIC)
83 C SYSTEM OF FIRST 0RDER ORDINARY DIFFERENTIAL EQUATIONS
85 C THE SYSTEM CAN BE (LINEARLY) IMPLICIT (MASS-MATRIX M .NE. I)
87 C THE METHOD USED IS AN IMPLICIT RUNGE-KUTTA METHOD (RADAU IIA)
88 C OF ORDER 5 WITH STEP SIZE CONTROL AND CONTINUOUS OUTPUT.
91 C AUTHORS: E. HAIRER AND G. WANNER
92 C UNIVERSITE DE GENEVE, DEPT. DE MATHEMATIQUES
93 C CH-1211 GENEVE 24, SWITZERLAND
94 C E-MAIL: HAIRER@DIVSUN.UNIGE.CH, WANNER@DIVSUN.UNIGE.CH
96 C THIS CODE IS PART OF THE BOOK:
97 C E. HAIRER AND G. WANNER, SOLVING ORDINARY DIFFERENTIAL
98 C EQUATIONS II. STIFF AND DIFFERENTIAL-ALGEBRAIC PROBLEMS.
99 C SPRINGER SERIES IN COMPUTATIONAL MATHEMATICS 14,
100 C SPRINGER-VERLAG (1991)
102 C VERSION OF SEPTEMBER 30, 1995
106 C N DIMENSION OF THE SYSTEM
108 C FCN NAME (EXTERNAL) OF SUBROUTINE COMPUTING THE
110 C SUBROUTINE FCN(N,X,Y,F,RPAR,IPAR)
111 C KPP_REAL X,Y(N),F(N)
113 C RPAR, IPAR (SEE BELOW)
117 C Y(N) INITIAL VALUES FOR Y
119 C XEND FINAL X-VALUE (XEND-X MAY BE POSITIVE OR NEGATIVE)
121 C H INITIAL STEP SIZE GUESS;
122 C FOR STIFF EQUATIONS WITH INITIAL TRANSIENT,
123 C H=1.D0/(NORM OF F'), USUALLY 1.D-3 OR 1.D-5, IS GOOD.
124 C THIS CHOICE IS NOT VERY IMPORTANT, THE STEP SIZE IS
125 C QUICKLY ADAPTED. (IF H=0.D0, THE CODE PUTS H=1.D-6).
127 C RelTol,AbsTol RELATIVE AND ABSOLUTE ERROR TOLERANCES. THEY
128 C CAN BE BOTH SCALARS OR ELSE BOTH VECTORS OF LENGTH N.
130 C ITOL SWITCH FOR RelTol AND AbsTol:
131 C ITOL=0: BOTH RelTol AND AbsTol ARE SCALARS.
132 C THE CODE KEEPS, ROUGHLY, THE LOCAL ERROR OF
133 C Y(I) BELOW RelTol*ABS(Y(I))+AbsTol
134 C ITOL=1: BOTH RelTol AND AbsTol ARE VECTORS.
135 C THE CODE KEEPS THE LOCAL ERROR OF Y(I) BELOW
136 C RelTol(I)*ABS(Y(I))+AbsTol(I).
138 C JAC NAME (EXTERNAL) OF THE SUBROUTINE WHICH COMPUTES
139 C THE PARTIAL DERIVATIVES OF F(X,Y) WITH RESPECT TO Y
140 C (THIS ROUTINE IS ONLY CALLED IF IJAC=1; SUPPLY
141 C A DUMMY SUBROUTINE IN THE CASE IJAC=0).
142 C FOR IJAC=1, THIS SUBROUTINE MUST HAVE THE FORM
143 C SUBROUTINE JAC(N,X,Y,DFY,LDFY,RPAR,IPAR)
144 C KPP_REAL X,Y(N),DFY(LDFY,N)
146 C LDFY, THE COLUMN-LENGTH OF THE ARRAY, IS
147 C FURNISHED BY THE CALLING PROGRAM.
148 C IF (MLJAC.EQ.N) THE JACOBIAN IS SUPPOSED TO
149 C BE FULL AND THE PARTIAL DERIVATIVES ARE
151 C DFY(I,J) = PARTIAL F(I) / PARTIAL Y(J)
152 C ELSE, THE JACOBIAN IS TAKEN AS BANDED AND
153 C THE PARTIAL DERIVATIVES ARE STORED
155 C DFY(I-J+MUJAC+1,J) = PARTIAL F(I) / PARTIAL Y(J).
157 C IJAC SWITCH FOR THE COMPUTATION OF THE JACOBIAN:
158 C IJAC=0: JACOBIAN IS COMPUTED INTERNALLY BY FINITE
159 C DIFFERENCES, SUBROUTINE "JAC" IS NEVER CALLED.
160 C IJAC=1: JACOBIAN IS SUPPLIED BY SUBROUTINE JAC.
162 C MLJAC SWITCH FOR THE BANDED STRUCTURE OF THE JACOBIAN:
163 C MLJAC=N: JACOBIAN IS A FULL MATRIX. THE LINEAR
164 C ALGEBRA IS DONE BY FULL-MATRIX GAUSS-ELIMINATION.
165 C 0<=MLJAC<N: MLJAC IS THE LOWER BANDWITH OF JACOBIAN
166 C MATRIX (>= NUMBER OF NON-ZERO DIAGONALS BELOW
167 C THE MAIN DIAGONAL).
169 C MUJAC UPPER BANDWITH OF JACOBIAN MATRIX (>= NUMBER OF NON-
170 C ZERO DIAGONALS ABOVE THE MAIN DIAGONAL).
171 C NEED NOT BE DEFINED IF MLJAC=N.
173 C ---- MAS,IMAS,MLMAS, AND MUMAS HAVE ANALOG MEANINGS -----
174 C ---- FOR THE "MASS MATRIX" (THE MATRIX "M" OF SECTION IV.8): -
176 C MAS NAME (EXTERNAL) OF SUBROUTINE COMPUTING THE MASS-
178 C IF IMAS=0, THIS MATRIX IS ASSUMED TO BE THE IDENTITY
179 C MATRIX AND NEEDS NOT TO BE DEFINED;
180 C SUPPLY A DUMMY SUBROUTINE IN THIS CASE.
181 C IF IMAS=1, THE SUBROUTINE MAS IS OF THE FORM
182 C SUBROUTINE MAS(N,AM,LMAS,RPAR,IPAR)
183 C KPP_REAL AM(LMAS,N)
185 C IF (MLMAS.EQ.N) THE MASS-MATRIX IS STORED
186 C AS FULL MATRIX LIKE
188 C ELSE, THE MATRIX IS TAKEN AS BANDED AND STORED
190 C AM(I-J+MUMAS+1,J) = M(I,J).
192 C IMAS GIVES INFORMATION ON THE MASS-MATRIX:
193 C IMAS=0: M IS SUPPOSED TO BE THE IDENTITY
194 C MATRIX, MAS IS NEVER CALLED.
195 C IMAS=1: MASS-MATRIX IS SUPPLIED.
197 C MLMAS SWITCH FOR THE BANDED STRUCTURE OF THE MASS-MATRIX:
198 C MLMAS=N: THE FULL MATRIX CASE. THE LINEAR
199 C ALGEBRA IS DONE BY FULL-MATRIX GAUSS-ELIMINATION.
200 C 0<=MLMAS<N: MLMAS IS THE LOWER BANDWITH OF THE
201 C MATRIX (>= NUMBER OF NON-ZERO DIAGONALS BELOW
202 C THE MAIN DIAGONAL).
203 C MLMAS IS SUPPOSED TO BE .LE. MLJAC.
205 C MUMAS UPPER BANDWITH OF MASS-MATRIX (>= NUMBER OF NON-
206 C ZERO DIAGONALS ABOVE THE MAIN DIAGONAL).
207 C NEED NOT BE DEFINED IF MLMAS=N.
208 C MUMAS IS SUPPOSED TO BE .LE. MUJAC.
210 C SOLOUT NAME (EXTERNAL) OF SUBROUTINE PROVIDING THE
211 C NUMERICAL SOLUTION DURING INTEGRATION.
212 C IF IOUT=1, IT IS CALLED AFTER EVERY SUCCESSFUL STEP.
213 C SUPPLY A DUMMY SUBROUTINE IF IOUT=0.
214 C IT MUST HAVE THE FORM
215 C SUBROUTINE SOLOUT (NR,XOLD,X,Y,CONT,LRC,N,
217 C KPP_REAL X,Y(N),CONT(LRC)
219 C SOLOUT FURNISHES THE SOLUTION "Y" AT THE NR-TH
220 C GRID-POINT "X" (THEREBY THE INITIAL VALUE IS
221 C THE FIRST GRID-POINT).
222 C "XOLD" IS THE PRECEEDING GRID-POINT.
223 C "IRTRN" SERVES TO INTERRUPT THE INTEGRATION. IF IRTRN
224 C IS SET <0, RADAU5 RETURNS TO THE CALLING PROGRAM.
226 C ----- CONTINUOUS OUTPUT: -----
227 C DURING CALLS TO "SOLOUT", A CONTINUOUS SOLUTION
228 C FOR THE INTERVAL [XOLD,X] IS AVAILABLE THROUGH
230 C >>> CONTR5(I,S,CONT,LRC) <<<
231 C WHICH PROVIDES AN APPROXIMATION TO THE I-TH
232 C COMPONENT OF THE SOLUTION AT THE POINT S. THE VALUE
233 C S SHOULD LIE IN THE INTERVAL [XOLD,X].
234 C DO NOT CHANGE THE ENTRIES OF CONT(LRC), IF THE
235 C DENSE OUTPUT FUNCTION IS USED.
237 C IOUT SWITCH FOR CALLING THE SUBROUTINE SOLOUT:
238 C IOUT=0: SUBROUTINE IS NEVER CALLED
239 C IOUT=1: SUBROUTINE IS AVAILABLE FOR OUTPUT.
241 C WORK ARRAY OF WORKING SPACE OF LENGTH "LWORK".
242 C WORK(1), WORK(2),.., WORK(20) SERVE AS PARAMETERS
243 C FOR THE CODE. FOR STANDARD USE OF THE CODE
244 C WORK(1),..,WORK(20) MUST BE SET TO ZERO BEFORE
245 C CALLING. SEE BELOW FOR A MORE SOPHISTICATED USE.
246 C WORK(21),..,WORK(LWORK) SERVE AS WORKING SPACE
247 C FOR ALL VECTORS AND MATRICES.
248 C "LWORK" MUST BE AT LEAST
249 C N*(LJAC+LMAS+3*LE+12)+20
251 C LJAC=N IF MLJAC=N (FULL JACOBIAN)
252 C LJAC=MLJAC+MUJAC+1 IF MLJAC<N (BANDED JAC.)
255 C LMAS=N IF IMAS=1 AND MLMAS=N (FULL)
256 C LMAS=MLMAS+MUMAS+1 IF MLMAS<N (BANDED MASS-M.)
258 C LE=N IF MLJAC=N (FULL JACOBIAN)
259 C LE=2*MLJAC+MUJAC+1 IF MLJAC<N (BANDED JAC.)
261 C IN THE USUAL CASE WHERE THE JACOBIAN IS FULL AND THE
262 C MASS-MATRIX IS THE INDENTITY (IMAS=0), THE MINIMUM
263 C STORAGE REQUIREMENT IS
264 C LWORK = 4*N*N+12*N+20.
265 C IF IWORK(9)=M1>0 THEN "LWORK" MUST BE AT LEAST
266 C N*(LJAC+12)+(N-M1)*(LMAS+3*LE)+20
267 C WHERE IN THE DEFINITIONS OF LJAC, LMAS AND LE THE
268 C NUMBER N CAN BE REPLACED BY N-M1.
270 C LWORK DECLARED LENGTH OF ARRAY "WORK".
272 C IWORK INTEGER WORKING SPACE OF LENGTH "LIWORK".
273 C IWORK(1),IWORK(2),...,IWORK(20) SERVE AS PARAMETERS
274 C FOR THE CODE. FOR STANDARD USE, SET IWORK(1),..,
275 C IWORK(20) TO ZERO BEFORE CALLING.
276 C IWORK(21),...,IWORK(LIWORK) SERVE AS WORKING AREA.
277 C "LIWORK" MUST BE AT LEAST 3*N+20.
279 C LIWORK DECLARED LENGTH OF ARRAY "IWORK".
281 C RPAR, IPAR REAL AND INTEGER PARAMETERS (OR PARAMETER ARRAYS) WHICH
282 C CAN BE USED FOR COMMUNICATION BETWEEN YOUR CALLING
283 C PROGRAM AND THE FCN, JAC, MAS, SOLOUT SUBROUTINES.
285 C ----------------------------------------------------------------------
287 C SOPHISTICATED SETTING OF PARAMETERS
288 C -----------------------------------
289 C SEVERAL PARAMETERS OF THE CODE ARE TUNED TO MAKE IT WORK
290 C WELL. THEY MAY BE DEFINED BY SETTING WORK(1),...
291 C AS WELL AS IWORK(1),... DIFFERENT FROM ZERO.
292 C FOR ZERO INPUT, THE CODE CHOOSES DEFAULT VALUES:
294 C IWORK(1) IF IWORK(1).NE.0, THE CODE TRANSFORMS THE JACOBIAN
295 C MATRIX TO HESSENBERG FORM. THIS IS PARTICULARLY
296 C ADVANTAGEOUS FOR LARGE SYSTEMS WITH FULL JACOBIAN.
297 C IT DOES NOT WORK FOR BANDED JACOBIAN (MLJAC<N)
298 C AND NOT FOR IMPLICIT SYSTEMS (IMAS=1).
300 C IWORK(2) THIS IS THE MAXIMAL NUMBER OF ALLOWED STEPS.
301 C THE DEFAULT VALUE (FOR IWORK(2)=0) IS 100000.
303 C IWORK(3) THE MAXIMUM NUMBER OF NEWTON ITERATIONS FOR THE
304 C SOLUTION OF THE IMPLICIT SYSTEM IN EACH STEP.
305 C THE DEFAULT VALUE (FOR IWORK(3)=0) IS 7.
307 C IWORK(4) IF IWORK(4).EQ.0 THE EXTRAPOLATED COLLOCATION SOLUTION
308 C IS TAKEN AS STARTING VALUE FOR NEWTON'S METHOD.
309 C IF IWORK(4).NE.0 ZERO STARTING VALUES ARE USED.
310 C THE LATTER IS RECOMMENDED IF NEWTON'S METHOD HAS
311 C DIFFICULTIES WITH CONVERGENCE (THIS IS THE CASE WHEN
312 C NSTEP IS LARGER THAN NACCPT + NREJCT; SEE OUTPUT PARAM.).
313 C DEFAULT IS IWORK(4)=0.
315 C THE FOLLOWING 3 PARAMETERS ARE IMPORTANT FOR
316 C DIFFERENTIAL-ALGEBRAIC SYSTEMS OF INDEX > 1.
317 C THE FUNCTION-SUBROUTINE SHOULD BE WRITTEN SUCH THAT
318 C THE INDEX 1,2,3 VARIABLES APPEAR IN THIS ORDER.
319 C IN ESTIMATING THE ERROR THE INDEX 2 VARIABLES ARE
320 C MULTIPLIED BY H, THE INDEX 3 VARIABLES BY H**2.
322 C IWORK(5) DIMENSION OF THE INDEX 1 VARIABLES (MUST BE > 0). FOR
323 C ODE'S THIS EQUALS THE DIMENSION OF THE SYSTEM.
324 C DEFAULT IWORK(5)=N.
326 C IWORK(6) DIMENSION OF THE INDEX 2 VARIABLES. DEFAULT IWORK(6)=0.
328 C IWORK(7) DIMENSION OF THE INDEX 3 VARIABLES. DEFAULT IWORK(7)=0.
330 C IWORK(8) SWITCH FOR STEP SIZE STRATEGY
331 C IF IWORK(8).EQ.1 MOD. PREDICTIVE CONTROLLER (GUSTAFSSON)
332 C IF IWORK(8).EQ.2 CLASSICAL STEP SIZE CONTROL
333 C THE DEFAULT VALUE (FOR IWORK(8)=0) IS IWORK(8)=1.
334 C THE CHOICE IWORK(8).EQ.1 SEEMS TO PRODUCE SAFER RESULTS;
335 C FOR SIMPLE PROBLEMS, THE CHOICE IWORK(8).EQ.2 PRODUCES
336 C OFTEN SLIGHTLY FASTER RUNS
338 C IF THE DIFFERENTIAL SYSTEM HAS THE SPECIAL STRUCTURE THAT
339 C Y(I)' = Y(I+M2) FOR I=1,...,M1,
340 C WITH M1 A MULTIPLE OF M2, A SUBSTANTIAL GAIN IN COMPUTERTIME
341 C CAN BE ACHIEVED BY SETTING THE FOLLOWING TWO PARAMETERS. E.G.,
342 C FOR SECOND ORDER SYSTEMS P'=V, V'=G(P,V), WHERE P AND V ARE
343 C VECTORS OF DIMENSION N/2, ONE HAS TO PUT M1=M2=N/2.
344 C FOR M1>0 SOME OF THE INPUT PARAMETERS HAVE DIFFERENT MEANINGS:
345 C - JAC: ONLY THE ELEMENTS OF THE NON-TRIVIAL PART OF THE
346 C JACOBIAN HAVE TO BE STORED
347 C IF (MLJAC.EQ.N-M1) THE JACOBIAN IS SUPPOSED TO BE FULL
348 C DFY(I,J) = PARTIAL F(I+M1) / PARTIAL Y(J)
349 C FOR I=1,N-M1 AND J=1,N.
350 C ELSE, THE JACOBIAN IS BANDED ( M1 = M2 * MM )
351 C DFY(I-J+MUJAC+1,J+K*M2) = PARTIAL F(I+M1) / PARTIAL Y(J+K*M2)
352 C FOR I=1,MLJAC+MUJAC+1 AND J=1,M2 AND K=0,MM.
353 C - MLJAC: MLJAC=N-M1: IF THE NON-TRIVIAL PART OF THE JACOBIAN IS FULL
354 C 0<=MLJAC<N-M1: IF THE (MM+1) SUBMATRICES (FOR K=0,MM)
355 C PARTIAL F(I+M1) / PARTIAL Y(J+K*M2), I,J=1,M2
356 C ARE BANDED, MLJAC IS THE MAXIMAL LOWER BANDWIDTH
357 C OF THESE MM+1 SUBMATRICES
358 C - MUJAC: MAXIMAL UPPER BANDWIDTH OF THESE MM+1 SUBMATRICES
359 C NEED NOT BE DEFINED IF MLJAC=N-M1
360 C - MAS: IF IMAS=0 THIS MATRIX IS ASSUMED TO BE THE IDENTITY AND
361 C NEED NOT BE DEFINED. SUPPLY A DUMMY SUBROUTINE IN THIS CASE.
362 C IT IS ASSUMED THAT ONLY THE ELEMENTS OF RIGHT LOWER BLOCK OF
363 C DIMENSION N-M1 DIFFER FROM THAT OF THE IDENTITY MATRIX.
364 C IF (MLMAS.EQ.N-M1) THIS SUBMATRIX IS SUPPOSED TO BE FULL
365 C AM(I,J) = M(I+M1,J+M1) FOR I=1,N-M1 AND J=1,N-M1.
366 C ELSE, THE MASS MATRIX IS BANDED
367 C AM(I-J+MUMAS+1,J) = M(I+M1,J+M1)
368 C - MLMAS: MLMAS=N-M1: IF THE NON-TRIVIAL PART OF M IS FULL
369 C 0<=MLMAS<N-M1: LOWER BANDWIDTH OF THE MASS MATRIX
370 C - MUMAS: UPPER BANDWIDTH OF THE MASS MATRIX
371 C NEED NOT BE DEFINED IF MLMAS=N-M1
373 C IWORK(9) THE VALUE OF M1. DEFAULT M1=0.
375 C IWORK(10) THE VALUE OF M2. DEFAULT M2=M1.
379 C WORK(1) UROUND, THE ROUNDING UNIT, DEFAULT 1.D-16.
381 C WORK(2) THE SAFETY FACTOR IN STEP SIZE PREDICTION,
384 C WORK(3) DECIDES WHETHER THE JACOBIAN SHOULD BE RECOMPUTED;
385 C INCREASE WORK(3), TO 0.1 SAY, WHEN JACOBIAN EVALUATIONS
386 C ARE COSTLY. FOR SMALL SYSTEMS WORK(3) SHOULD BE SMALLER
387 C (0.001D0, SAY). NEGATIV WORK(3) FORCES THE CODE TO
388 C COMPUTE THE JACOBIAN AFTER EVERY ACCEPTED STEP.
391 C WORK(4) STOPPING CRITERION FOR NEWTON'S METHOD, USUALLY CHOSEN <1.
392 C SMALLER VALUES OF WORK(4) MAKE THE CODE SLOWER, BUT SAFER.
395 C WORK(5) AND WORK(6) : IF WORK(5) < HNEW/HOLD < WORK(6), THEN THE
396 C STEP SIZE IS NOT CHANGED. THIS SAVES, TOGETHER WITH A
397 C LARGE WORK(3), LU-DECOMPOSITIONS AND COMPUTING TIME FOR
398 C LARGE SYSTEMS. FOR SMALL SYSTEMS ONE MAY HAVE
399 C WORK(5)=1.D0, WORK(6)=1.2D0, FOR LARGE FULL SYSTEMS
400 C WORK(5)=0.99D0, WORK(6)=2.D0 MIGHT BE GOOD.
401 C DEFAULTS WORK(5)=1.D0, WORK(6)=1.2D0 .
403 C WORK(7) MAXIMAL STEP SIZE, DEFAULT XEND-X.
405 C WORK(8), WORK(9) PARAMETERS FOR STEP SIZE SELECTION
406 C THE NEW STEP SIZE IS CHOSEN SUBJECT TO THE RESTRICTION
407 C WORK(8) <= HNEW/HOLD <= WORK(9)
408 C DEFAULT VALUES: WORK(8)=0.2D0, WORK(9)=8.D0
410 C-----------------------------------------------------------------------
414 C X X-VALUE FOR WHICH THE SOLUTION HAS BEEN COMPUTED
415 C (AFTER SUCCESSFUL RETURN X=XEND).
417 C Y(N) NUMERICAL SOLUTION AT X
419 C H PREDICTED STEP SIZE OF THE LAST ACCEPTED STEP
421 C IDID REPORTS ON SUCCESSFULNESS UPON RETURN:
422 C IDID= 1 COMPUTATION SUCCESSFUL,
423 C IDID= 2 COMPUT. SUCCESSFUL (INTERRUPTED BY SOLOUT)
424 C IDID=-1 INPUT IS NOT CONSISTENT,
425 C IDID=-2 LARGER NMAX IS NEEDED,
426 C IDID=-3 STEP SIZE BECOMES TOO SMALL,
427 C IDID=-4 MATRIX IS REPEATEDLY SINGULAR.
429 C IWORK(14) NFCN NUMBER OF FUNCTION EVALUATIONS (THOSE FOR NUMERICAL
430 C EVALUATION OF THE JACOBIAN ARE NOT COUNTED)
431 C IWORK(15) NJAC NUMBER OF JACOBIAN EVALUATIONS (EITHER ANALYTICALLY
433 C IWORK(16) NSTEP NUMBER OF COMPUTED STEPS
434 C IWORK(17) NACCPT NUMBER OF ACCEPTED STEPS
435 C IWORK(18) NREJCT NUMBER OF REJECTED STEPS (DUE TO ERROR TEST),
436 C (STEP REJECTIONS IN THE FIRST STEP ARE NOT COUNTED)
437 C IWORK(19) NDEC NUMBER OF LU-DECOMPOSITIONS OF BOTH MATRICES
438 C IWORK(20) NSOL NUMBER OF FORWARD-BACKWARD SUBSTITUTIONS, OF BOTH
439 C SYSTEMS; THE NSTEP FORWARD-BACKWARD SUBSTITUTIONS,
440 C NEEDED FOR STEP SIZE SELECTION, ARE NOT COUNTED
441 C-----------------------------------------------------------------------
442 C *** *** *** *** *** *** *** *** *** *** *** *** ***
444 C *** *** *** *** *** *** *** *** *** *** *** *** ***
445 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
446 DIMENSION Y
(N
),AbsTol
(*),RelTol
(*),WORK
(LWORK
),IWORK
(LIWORK
)
447 DIMENSION RPAR
(*),IPAR
(*)
448 LOGICAL IMPLCT
,JBAND
,ARRET
,STARTN
,PRED
449 EXTERNAL FCN
,JAC
,MAS
,SOLOUT
450 C *** *** *** *** *** *** ***
451 C SETTING THE PARAMETERS
452 C *** *** *** *** *** *** ***
461 C -------- NMAX , THE MAXIMAL NUMBER OF STEPS -----
462 IF (IWORK
(2).EQ
.0) THEN
467 WRITE(6,*)' WRONG INPUT IWORK(2)=',IWORK
(2)
471 C -------- NIT MAXIMAL NUMBER OF NEWTON ITERATIONS
472 IF (IWORK
(3).EQ
.0) THEN
477 WRITE(6,*)' CURIOUS INPUT IWORK(3)=',IWORK
(3)
481 C -------- STARTN SWITCH FOR STARTING VALUES OF NEWTON ITERATIONS
482 IF(IWORK
(4).EQ
.0)THEN
487 C -------- PARAMETER FOR DIFFERENTIAL-ALGEBRAIC COMPONENTS
491 IF (NIND1
.EQ
.0) NIND1
=N
492 IF (NIND1
+NIND2
+NIND3
.NE
.N
) THEN
493 WRITE(6,*)' CURIOUS INPUT FOR IWORK(5,6,7)=',NIND1
,NIND2
,NIND3
496 C -------- PRED STEP SIZE CONTROL
497 IF(IWORK
(8).LE
.1)THEN
502 C -------- PARAMETER FOR SECOND ORDER EQUATIONS
508 IF (M1
.LT
.0.OR
.M2
.LT
.0.OR
.M1
+M2
.GT
.N
) THEN
509 WRITE(6,*)' CURIOUS INPUT FOR IWORK(9,10)=',M1
,M2
512 C -------- UROUND SMALLEST NUMBER SATISFYING 1.0D0+UROUND>1.0D0
513 IF (WORK
(1).EQ
.0.0D0
) THEN
517 IF (UROUND
.LE
.1.0D
-19.OR
.UROUND
.GE
.1.0D0
) THEN
518 WRITE(6,*)' COEFFICIENTS HAVE 20 DIGITS, UROUND=',WORK
(1)
522 C --------- SAFE SAFETY FACTOR IN STEP SIZE PREDICTION
523 IF (WORK
(2).EQ
.0.0D0
) THEN
527 IF (SAFE
.LE
.0.001D0
.OR
.SAFE
.GE
.1.0D0
) THEN
528 WRITE(6,*)' CURIOUS INPUT FOR WORK(2)=',WORK
(2)
532 C ------ THET DECIDES WHETHER THE JACOBIAN SHOULD BE RECOMPUTED;
533 IF (WORK
(3).EQ
.0.D0
) THEN
537 IF (THET
.LE
.0.0D0
.OR
.THET
.GE
.1.0D0
) THEN
538 WRITE(6,*)' CURIOUS INPUT FOR WORK(3)=',WORK
(3)
542 C --- FNEWT STOPPING CRIERION FOR NEWTON'S METHOD, USUALLY CHOSEN <1.
543 IF (WORK
(4).EQ
.0.D0
) THEN
547 IF (FNEWT
.LE
.UROUND
) THEN
548 WRITE(6,*)' CURIOUS INPUT FOR WORK(4)=',WORK
(4)
552 C --- QUOT1 AND QUOT2: IF QUOT1 < HNEW/HOLD < QUOT2, STEP SIZE = CONST.
553 IF (WORK
(5).EQ
.0.D0
) THEN
558 IF (WORK
(6).EQ
.0.D0
) THEN
563 IF (QUOT1
.GT
.1.0D0
.OR
.QUOT2
.LT
.1.0D0
) THEN
564 WRITE(6,*)' CURIOUS INPUT FOR WORK(5,6)=',QUOT1
,QUOT2
567 C -------- MAXIMAL STEP SIZE
568 IF (WORK
(7).EQ
.0.D0
) THEN
573 C ------- FACL,FACR PARAMETERS FOR STEP SIZE SELECTION
574 IF(WORK
(8).EQ
.0.D0
)THEN
579 IF(WORK
(9).EQ
.0.D0
)THEN
584 IF (FACL
.LT
.1.0D0
.OR
.FACR
.GT
.1.0D0
) THEN
585 WRITE(6,*)' CURIOUS INPUT WORK(8,9)=',WORK
(8),WORK
(9)
588 C --------- CHECK IF TOLERANCES ARE O.K.
590 IF (AbsTol
(1).LE
.0.D0
.OR
.RelTol
(1).LE
.10.D0*UROUND
) THEN
591 WRITE (6,*) ' TOLERANCES ARE TOO SMALL'
596 IF (AbsTol
(I
).LE
.0.D0
.OR
.RelTol
(I
).LE
.10.D0*UROUND
) THEN
597 WRITE (6,*) ' TOLERANCES(',I
,') ARE TOO SMALL'
602 C *** *** *** *** *** *** *** *** *** *** *** *** ***
603 C COMPUTATION OF ARRAY ENTRIES
604 C *** *** *** *** *** *** *** *** *** *** *** *** ***
605 C ---- IMPLICIT, BANDED OR NOT ?
608 C -------- COMPUTATION OF THE ROW-DIMENSIONS OF THE 2-ARRAYS ---
609 C -- JACOBIAN AND MATRICES E1, E2
621 IF (MLMAS
.NE
.NM1
) THEN
632 C ------ BANDWITH OF "MAS" NOT SMALLER THAN BANDWITH OF "JAC"
633 IF (MLMAS
.GT
.MLJAC
.OR
.MUMAS
.GT
.MUJAC
) THEN
634 WRITE (6,*) 'BANDWITH OF "MAS" NOT SMALLER THAN BANDWITH OF
644 IF (N
.GT
.2.AND
.IWORK
(1).NE
.0) IJOB
=7
648 C ------ HESSENBERG OPTION ONLY FOR EXPLICIT EQU. WITH FULL JACOBIAN
649 IF ((IMPLCT
.OR
.JBAND
).AND
.IJOB
.EQ
.7) THEN
650 WRITE(6,*)' HESSENBERG OPTION ONLY FOR EXPLICIT EQUATIONS WITH
654 C ------- PREPARE THE ENTRY-POINTS FOR THE ARRAYS IN WORK -----
669 C ------ TOTAL STORAGE REQUIREMENT -----------
670 ISTORE
=IEE2I
+NM1*LDE1
-1
671 IF(ISTORE
.GT
.LWORK
)THEN
672 WRITE(6,*)' INSUFFICIENT STORAGE FOR WORK, MIN. LWORK=',ISTORE
675 C ------- ENTRY POINTS FOR INTEGER WORKSPACE -----
679 C --------- TOTAL REQUIREMENT ---------------
681 IF (ISTORE
.GT
.LIWORK
) THEN
682 WRITE(6,*)' INSUFF. STORAGE FOR IWORK, MIN. LIWORK=',ISTORE
685 C ------ WHEN A FAIL HAS OCCURED, WE RETURN WITH IDID=-1
690 C -------- CALL TO CORE INTEGRATOR ------------
691 CALL RADCOR
(N
,FCN
,X
,Y
,XEND
,HMAX
,H
,RelTol
,AbsTol
,ITOL
,
692 & JAC
,IJAC
,MLJAC
,MUJAC
,MAS
,MLMAS
,MUMAS
,SOLOUT
,IOUT
,IDID
,
693 & NMAX
,UROUND
,SAFE
,THET
,FNEWT
,QUOT1
,QUOT2
,NIT
,IJOB
,STARTN
,
694 & NIND1
,NIND2
,NIND3
,PRED
,FACL
,FACR
,M1
,M2
,NM1
,
695 & IMPLCT
,JBAND
,LDJAC
,LDE1
,LDMAS2
,WORK
(IEZ1
),WORK
(IEZ2
),
696 & WORK
(IEZ3
),WORK
(IEY0
),WORK
(IESCAL
),WORK
(IEF1
),WORK
(IEF2
),
697 & WORK
(IEF3
),WORK
(IEJAC
),WORK
(IEE1
),WORK
(IEE2R
),WORK
(IEE2I
),
698 & WORK
(IEMAS
),IWORK
(IEIP1
),IWORK
(IEIP2
),IWORK
(IEIPH
),
699 & WORK
(IECON
),NFCN
,NJAC
,NSTEP
,NACCPT
,NREJCT
,NDEC
,NSOL
,RPAR
,IPAR
)
707 C ----------- RETURN -----------
711 C END OF SUBROUTINE RADAU5
713 C ***********************************************************
715 SUBROUTINE RADCOR
(N
,FCN
,X
,Y
,XEND
,HMAX
,H
,RelTol
,AbsTol
,ITOL
,
716 & JAC
,IJAC
,MLJAC
,MUJAC
,MAS
,MLMAS
,MUMAS
,SOLOUT
,IOUT
,IDID
,
717 & NMAX
,UROUND
,SAFE
,THET
,FNEWT
,QUOT1
,QUOT2
,NIT
,IJOB
,STARTN
,
718 & NIND1
,NIND2
,NIND3
,PRED
,FACL
,FACR
,M1
,M2
,NM1
,
719 & IMPLCT
,BANDED
,LDJAC
,LDE1
,LDMAS
,Z1
,Z2
,Z3
,
720 & Y0
,SCAL
,F1
,F2
,F3
,FJAC
,E1
,E2R
,E2I
,FMAS
,IP1
,IP2
,IPHES
,
721 & CONT
,NFCN
,NJAC
,NSTEP
,NACCPT
,NREJCT
,NDEC
,NSOL
,RPAR
,IPAR
)
722 C ----------------------------------------------------------
723 C CORE INTEGRATOR FOR RADAU5
724 C PARAMETERS SAME AS IN RADAU5 WITH WORKSPACE ADDED
725 C ----------------------------------------------------------
727 C ----------------------------------------------------------
728 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
729 DIMENSION Y
(N
),Z1
(N
),Z2
(N
),Z3
(N
),Y0
(N
),SCAL
(N
),F1
(N
),F2
(N
),F3
(N
)
730 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),CONT
(4*N
)
731 DIMENSION E1
(LDE1
,NM1
),E2R
(LDE1
,NM1
),E2I
(LDE1
,NM1
)
732 DIMENSION AbsTol
(*),RelTol
(*),RPAR
(*),IPAR
(*)
733 INTEGER IP1
(NM1
),IP2
(NM1
),IPHES
(NM1
)
734 COMMON /CONRA5
/NN
,NN2
,NN3
,NN4
,XSOL
,HSOL
,C2M1
,C1M1
735 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
736 LOGICAL REJECT
,FIRST
,IMPLCT
,BANDED
,CALJAC
,STARTN
,CALHES
737 LOGICAL INDEX1
,INDEX2
,INDEX3
,LAST
,PRED
738 EXTERNAL FCN
, JAC
, MAS
, SOLOUT
739 C *** *** *** *** *** *** ***
741 C *** *** *** *** *** *** ***
742 C --------- DUPLIFY N FOR COMMON BLOCK CONT -----
747 C -------- CHECK THE INDEX OF THE PROBLEM -----
751 C ------- COMPUTE MASS MATRIX FOR IMPLICIT CASE ----------
752 IF (IMPLCT
) CALL MAS
(NM1
,FMAS
,LDMAS
,RPAR
,IPAR
)
753 C ---------- CONSTANTS ---------
760 DD1
=-(13.D0
+7.D0*SQ6
)/3.D0
761 DD2
=(-13.D0
+7.D0*SQ6
)/3.D0
763 U1
=(6.D0
+81.D0**
(1.D0
/3.D0
)-9.D0**
(1.D0
/3.D0
))/30.D0
764 ALPH
=(12.D0
-81.D0**
(1.D0
/3.D0
)+9.D0**
(1.D0
/3.D0
))/60.D0
765 BETA
=(81.D0**
(1.D0
/3.D0
)+9.D0**
(1.D0
/3.D0
))*DSQRT
(3.D0
)/60.D0
770 T11
=9.1232394870892942792D
-02
771 T12
=-0.14125529502095420843D0
772 T13
=-3.0029194105147424492D
-02
773 T21
=0.24171793270710701896D0
774 T22
=0.20412935229379993199D0
775 T23
=0.38294211275726193779D0
776 T31
=0.96604818261509293619D0
777 TI11
=4.3255798900631553510D0
778 TI12
=0.33919925181580986954D0
779 TI13
=0.54177053993587487119D0
780 TI21
=-4.1787185915519047273D0
781 TI22
=-0.32768282076106238708D0
782 TI23
=0.47662355450055045196D0
783 TI31
=-0.50287263494578687595D0
784 TI32
=2.5719269498556054292D0
785 TI33
=-0.59603920482822492497D0
786 IF (M1
.GT
.0) IJOB
=IJOB
+10
787 POSNEG
=SIGN
(1.D0
,XEND
-X
)
788 HMAXN
=MIN
(ABS
(HMAX
),ABS
(XEND
-X
))
789 IF (ABS
(H
).LE
.10.D0*UROUND
) H
=1.0D
-6
796 IF ((X
+H*1
.0001D0
-XEND
)*POSNEG
.GE
.0.D0
) THEN
814 CALL SOLOUT
(NRSOL
,XOSOL
,XSOL
,Y
,CONT
,LRC
,NSOLU
,
816 IF (IRTRN
.LT
.0) GOTO 179
829 SCAL
(I
)=AbsTol
(1)+RelTol
(1)*ABS
(Y
(I
))
833 SCAL
(I
)=AbsTol
(I
)+RelTol
(I
)*ABS
(Y
(I
))
837 CALL FCN
(N
,X
,Y
,Y0
,RPAR
,IPAR
)
839 C --- BASIC INTEGRATION STEP
841 C *** *** *** *** *** *** ***
842 C COMPUTATION OF THE JACOBIAN
843 C *** *** *** *** *** *** ***
846 C --- COMPUTE JACOBIAN MATRIX NUMERICALLY
848 C --- JACOBIAN IS BANDED
855 F2
(J
)=DSQRT
(UROUND*MAX
(1.D
-5,ABS
(Y
(J
))))
858 IF (J
.LE
.MM*M2
) GOTO 12
859 CALL FCN
(N
,X
,Y
,CONT
,RPAR
,IPAR
)
862 LBEG
=MAX
(1,J1
-MUJAC
)+M1
863 14 LEND
=MIN
(M2
,J1
+MLJAC
)+M1
867 FJAC
(L
+MUJACJ
,J
)=(CONT
(L
)-Y0
(L
))/F2
(J
)
872 IF (J
.LE
.MM*M2
) GOTO 14
876 C --- JACOBIAN IS FULL
879 DELT
=DSQRT
(UROUND*MAX
(1.D
-5,ABS
(YSAFE
)))
881 CALL FCN
(N
,X
,Y
,CONT
,RPAR
,IPAR
)
883 FJAC
(J
-M1
,I
)=(CONT
(J
)-Y0
(J
))/DELT
889 C --- COMPUTE JACOBIAN MATRIX ANALYTICALLY
890 CALL JAC_CHEM
(N
,X
,Y
,FJAC
,LDJAC
,RPAR
,IPAR
)
895 C --- COMPUTE THE MATRICES E1 AND E2 AND THEIR DECOMPOSITIONS
899 CALL DECOMR
(N
,FJAC
,LDJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
900 & M1
,M2
,NM1
,FAC1
,E1
,LDE1
,IP1
,IER
,IJOB
,CALHES
,IPHES
)
901 IF (IER
.NE
.0) GOTO 78
902 CALL DECOMC
(N
,FJAC
,LDJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
903 & M1
,M2
,NM1
,ALPHN
,BETAN
,E2R
,E2I
,LDE1
,IP2
,IER
,IJOB
)
904 IF (IER
.NE
.0) GOTO 78
908 IF (NSTEP
.GT
.NMAX
) GOTO 178
909 IF (0.1D0*ABS
(H
).LE
.ABS
(X
)*UROUND
) GOTO 177
911 DO I
=NIND1
+1,NIND1
+NIND2
912 SCAL
(I
)=SCAL
(I
)/HHFAC
916 DO I
=NIND1
+NIND2
+1,NIND1
+NIND2
+NIND3
917 SCAL
(I
)=SCAL
(I
)/(HHFAC*HHFAC
)
921 C *** *** *** *** *** *** ***
922 C STARTING VALUES FOR NEWTON ITERATION
923 C *** *** *** *** *** *** ***
924 IF (FIRST
.OR
.STARTN
) THEN
941 Z1I
=C1Q*
(AK1
+(C1Q
-C2M1
)*(AK2
+(C1Q
-C1M1
)*AK3
))
942 Z2I
=C2Q*
(AK1
+(C2Q
-C2M1
)*(AK2
+(C2Q
-C1M1
)*AK3
))
943 Z3I
=C3Q*
(AK1
+(C3Q
-C2M1
)*(AK2
+(C3Q
-C1M1
)*AK3
))
947 F1
(I
)=TI11*Z1I
+TI12*Z2I
+TI13*Z3I
948 F2
(I
)=TI21*Z1I
+TI22*Z2I
+TI23*Z3I
949 F3
(I
)=TI31*Z1I
+TI32*Z2I
+TI33*Z3I
952 C *** *** *** *** *** *** ***
953 C LOOP FOR THE SIMPLIFIED NEWTON ITERATION
954 C *** *** *** *** *** *** ***
956 FACCON
=MAX
(FACCON
,UROUND
)**0.8D0
959 IF (NEWT
.GE
.NIT
) GOTO 78
960 C --- COMPUTE THE RIGHT-HAND SIDE
964 CALL FCN
(N
,X
+C1*H
,CONT
,Z1
,RPAR
,IPAR
)
968 CALL FCN
(N
,X
+C2*H
,CONT
,Z2
,RPAR
,IPAR
)
972 CALL FCN
(N
,XPH
,CONT
,Z3
,RPAR
,IPAR
)
974 C --- KppSolve THE LINEAR SYSTEMS
979 Z1
(I
)=TI11*A1
+TI12*A2
+TI13*A3
980 Z2
(I
)=TI21*A1
+TI22*A2
+TI23*A3
981 Z3
(I
)=TI31*A1
+TI32*A2
+TI33*A3
983 CALL SLVRAD
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
984 & M1
,M2
,NM1
,FAC1
,ALPHN
,BETAN
,E1
,E2R
,E2I
,LDE1
,Z1
,Z2
,Z3
,
985 & F1
,F2
,F3
,CONT
,IP1
,IP2
,IPHES
,IER
,IJOB
)
991 DYNO
=DYNO
+(Z1
(I
)/DENOM
)**2+(Z2
(I
)/DENOM
)**2
995 C --- BAD CONVERGENCE OR NUMBER OF ITERATIONS TO LARGE
996 IF (NEWT
.GT
.1.AND
.NEWT
.LT
.NIT
) THEN
1001 THETA
=SQRT
(THQ*THQOLD
)
1004 IF (THETA
.LT
.0.99D0
) THEN
1005 FACCON
=THETA
/(1.0D0
-THETA
)
1006 DYTH
=FACCON*DYNO*THETA**
(NIT
-1-NEWT
)/FNEWT
1007 IF (DYTH
.GE
.1.0D0
) THEN
1008 QNEWT
=DMAX1
(1.0D
-4,DMIN1
(20.0D0
,DYTH
))
1009 HHFAC
=.8D0*QNEWT**
(-1.0D0
/(4.0D0
+NIT
-1-NEWT
))
1020 DYNOLD
=MAX
(DYNO
,UROUND
)
1028 Z1
(I
)=T11*F1I
+T12*F2I
+T13*F3I
1029 Z2
(I
)=T21*F1I
+T22*F2I
+T23*F3I
1032 IF (FACCON*DYNO
.GT
.FNEWT
) GOTO 40
1033 C --- ERROR ESTIMATION
1034 CALL ESTRAD
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
1035 & H
,DD1
,DD2
,DD3
,FCN
,NFCN
,Y0
,Y
,IJOB
,X
,M1
,M2
,NM1
,
1036 & E1
,LDE1
,Z1
,Z2
,Z3
,CONT
,F1
,F2
,IP1
,IPHES
,SCAL
,ERR
,
1037 & FIRST
,REJECT
,FAC1
,RPAR
,IPAR
)
1038 C --- COMPUTATION OF HNEW
1039 C --- WE REQUIRE .2<=HNEW/H<=8.
1040 FAC
=MIN
(SAFE
,CFAC
/(NEWT
+2*NIT
))
1041 QUOT
=MAX
(FACR
,MIN
(FACL
,ERR**
.25D0
/FAC
))
1043 C *** *** *** *** *** *** ***
1044 C IS THE ERROR SMALL ENOUGH ?
1045 C *** *** *** *** *** *** ***
1046 IF (ERR
.LT
.1.D0
) THEN
1047 C --- STEP IS ACCEPTED
1051 C --- PREDICTIVE CONTROLLER OF GUSTAFSSON
1052 IF (NACCPT
.GT
.1) THEN
1053 FACGUS
=(HACC
/H
)*(ERR**2
/ERRACC
)**0.25D0
/SAFE
1054 FACGUS
=MAX
(FACR
,MIN
(FACL
,FACGUS
))
1055 QUOT
=MAX
(QUOT
,FACGUS
)
1059 ERRACC
=MAX
(1.0D
-2,ERR
)
1068 CONT
(I
+N
)=(Z2I
-Z3
(I
))/C2M1
1071 ACONT3
=(AK
-ACONT3
)/C2
1072 CONT
(I
+N2
)=(AK
-CONT
(I
+N
))/C1M1
1073 CONT
(I
+N3
)=CONT
(I
+N2
)-ACONT3
1077 SCAL
(I
)=AbsTol
(1)+RelTol
(1)*ABS
(Y
(I
))
1081 SCAL
(I
)=AbsTol
(I
)+RelTol
(I
)*ABS
(Y
(I
))
1093 CALL SOLOUT
(NRSOL
,XOSOL
,XSOL
,Y
,CONT
,LRC
,NSOLU
,
1095 IF (IRTRN
.LT
.0) GOTO 179
1103 CALL FCN
(N
,X
,Y
,Y0
,RPAR
,IPAR
)
1105 HNEW
=POSNEG*MIN
(ABS
(HNEW
),HMAXN
)
1108 IF (REJECT
) HNEW
=POSNEG*MIN
(ABS
(HNEW
),ABS
(H
))
1110 IF ((X
+HNEW
/QUOT1
-XEND
)*POSNEG
.GE
.0.D0
) THEN
1116 IF (THETA
.LE
.THET
.AND
.QT
.GE
.QUOT1
.AND
.QT
.LE
.QUOT2
) GOTO 30
1120 IF (THETA
.LE
.THET
) GOTO 20
1123 C --- STEP IS REJECTED
1133 IF (NACCPT
.GE
.1) NREJCT
=NREJCT
+1
1137 C --- UNEXPECTED STEP-REJECTION
1141 IF (NSING
.GE
.5) GOTO 176
1152 WRITE(6,*) ' MATRIX IS REPEATEDLY SINGULAR, IER=',IER
1157 WRITE(6,*) ' STEP SIZE T0O SMALL, H=',H
1162 WRITE(6,*) ' MORE THAN NMAX =',NMAX
,'STEPS ARE NEEDED'
1165 C --- EXIT CAUSED BY SOLOUT
1168 979 FORMAT(' EXIT OF RADAU5 AT X=',E18
.4
)
1173 C END OF SUBROUTINE RADCOR
1175 C ***********************************************************
1177 KPP_REAL
FUNCTION CONTR5
(I
,X
,CONT
,LRC
)
1178 C ----------------------------------------------------------
1179 C THIS FUNCTION CAN BE USED FOR CONINUOUS OUTPUT. IT PROVIDES AN
1180 C APPROXIMATION TO THE I-TH COMPONENT OF THE SOLUTION AT X.
1181 C IT GIVES THE VALUE OF THE COLLOCATION POLYNOMIAL, DEFINED FOR
1182 C THE LAST SUCCESSFULLY COMPUTED STEP (BY RADAU5).
1183 C ----------------------------------------------------------
1184 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
1186 COMMON /CONRA5
/NN
,NN2
,NN3
,NN4
,XSOL
,HSOL
,C2M1
,C1M1
1188 CONTR5
=CONT
(I
)+S*
(CONT
(I
+NN
)+(S
-C2M1
)*(CONT
(I
+NN2
)
1189 & +(S
-C1M1
)*CONT
(I
+NN3
)))
1193 C END OF FUNCTION CONTR5
1195 C ***********************************************************
1196 C ******************************************
1197 C VERSION OF SEPTEMBER 18, 1995
1198 C ******************************************
1200 SUBROUTINE DECOMR
(N
,FJAC
,LDJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
1201 & M1
,M2
,NM1
,FAC1
,E1
,LDE1
,IP1
,IER
,IJOB
,CALHES
,IPHES
)
1202 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
1203 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E1
(LDE1
,NM1
),
1206 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
1208 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,14,15), IJOB
1210 C -----------------------------------------------------------
1213 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
1218 E1
(J
,J
)=E1
(J
,J
)+FAC1
1220 CALL DEC
(N
,LDE1
,E1
,IP1
,IER
)
1223 C -----------------------------------------------------------
1226 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
1230 E1
(I
,J
)=-FJAC
(I
,JM1
)
1232 E1
(J
,J
)=E1
(J
,J
)+FAC1
1239 SUM
=(SUM
+FJAC
(I
,J
+K*M2
))/FAC1
1244 CALL DEC
(NM1
,LDE1
,E1
,IP1
,IER
)
1247 C -----------------------------------------------------------
1250 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
1253 E1
(I
+MLE
,J
)=-FJAC
(I
,J
)
1255 E1
(MDIAG
,J
)=E1
(MDIAG
,J
)+FAC1
1257 CALL DECB
(N
,LDE1
,E1
,MLE
,MUE
,IP1
,IER
)
1260 C -----------------------------------------------------------
1263 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
1267 E1
(I
+MLE
,J
)=-FJAC
(I
,JM1
)
1269 E1
(MDIAG
,J
)=E1
(MDIAG
,J
)+FAC1
1276 SUM
=(SUM
+FJAC
(I
,J
+K*M2
))/FAC1
1278 E1
(I
+MLE
,J
)=E1
(I
+MLE
,J
)-SUM
1281 CALL DECB
(NM1
,LDE1
,E1
,MLE
,MUE
,IP1
,IER
)
1284 C -----------------------------------------------------------
1287 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
1292 DO I
=MAX
(1,J
-MUMAS
),MIN
(N
,J
+MLMAS
)
1293 E1
(I
,J
)=E1
(I
,J
)+FAC1*FMAS
(I
-J
+MBDIAG
,J
)
1296 CALL DEC
(N
,LDE1
,E1
,IP1
,IER
)
1299 C -----------------------------------------------------------
1302 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1306 E1
(I
,J
)=-FJAC
(I
,JM1
)
1308 DO I
=MAX
(1,J
-MUMAS
),MIN
(NM1
,J
+MLMAS
)
1309 E1
(I
,J
)=E1
(I
,J
)+FAC1*FMAS
(I
-J
+MBDIAG
,J
)
1314 C -----------------------------------------------------------
1317 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
1320 E1
(I
+MLE
,J
)=-FJAC
(I
,J
)
1324 E1
(IB
,J
)=E1
(IB
,J
)+FAC1*FMAS
(I
,J
)
1327 CALL DECB
(N
,LDE1
,E1
,MLE
,MUE
,IP1
,IER
)
1330 C -----------------------------------------------------------
1333 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX, SECOND ORDER
1337 E1
(I
+MLE
,J
)=-FJAC
(I
,JM1
)
1341 E1
(IB
,J
)=E1
(IB
,J
)+FAC1*FMAS
(I
,J
)
1346 C -----------------------------------------------------------
1349 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
1352 E1
(I
,J
)=FMAS
(I
,J
)*FAC1
-FJAC
(I
,J
)
1355 CALL DEC
(N
,LDE1
,E1
,IP1
,IER
)
1358 C -----------------------------------------------------------
1361 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1365 E1
(I
,J
)=FMAS
(I
,J
)*FAC1
-FJAC
(I
,JM1
)
1370 C -----------------------------------------------------------
1373 C --- B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
1374 C --- THIS OPTION IS NOT PROVIDED
1377 C -----------------------------------------------------------
1380 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
1381 IF (CALHES
) CALL Elmhes
(LDJAC
,N
,1,N
,FJAC
,IPHES
)
1385 E1
(J1
,J
)=-FJAC
(J1
,J
)
1391 E1
(J
,J
)=E1
(J
,J
)+FAC1
1393 CALL DECH
(N
,LDE1
,E1
,1,IP1
,IER
)
1396 C -----------------------------------------------------------
1402 C END OF SUBROUTINE DECOMR
1404 C ***********************************************************
1406 SUBROUTINE DECOMC
(N
,FJAC
,LDJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
1407 & M1
,M2
,NM1
,ALPHN
,BETAN
,E2R
,E2I
,LDE1
,IP2
,IER
,IJOB
)
1408 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
1409 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),
1410 & E2R
(LDE1
,NM1
),E2I
(LDE1
,NM1
),IP2
(NM1
)
1411 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
1413 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,14,15), IJOB
1415 C -----------------------------------------------------------
1418 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
1424 E2R
(J
,J
)=E2R
(J
,J
)+ALPHN
1427 CALL DECC
(N
,LDE1
,E2R
,E2I
,IP2
,IER
)
1430 C -----------------------------------------------------------
1433 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
1437 E2R
(I
,J
)=-FJAC
(I
,JM1
)
1440 E2R
(J
,J
)=E2R
(J
,J
)+ALPHN
1444 ABNO
=ALPHN**2
+BETAN**2
1452 SUMS
=SUMR
+FJAC
(I
,J
+K*M2
)
1453 SUMR
=SUMS*ALP
+SUMI*BET
1454 SUMI
=SUMI*ALP
-SUMS*BET
1456 E2R
(I
,J
)=E2R
(I
,J
)-SUMR
1457 E2I
(I
,J
)=E2I
(I
,J
)-SUMI
1460 CALL DECC
(NM1
,LDE1
,E2R
,E2I
,IP2
,IER
)
1463 C -----------------------------------------------------------
1466 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
1470 E2R
(IMLE
,J
)=-FJAC
(I
,J
)
1473 E2R
(MDIAG
,J
)=E2R
(MDIAG
,J
)+ALPHN
1476 CALL DECBC
(N
,LDE1
,E2R
,E2I
,MLE
,MUE
,IP2
,IER
)
1479 C -----------------------------------------------------------
1482 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
1486 E2R
(I
+MLE
,J
)=-FJAC
(I
,JM1
)
1489 E2R
(MDIAG
,J
)=E2R
(MDIAG
,J
)+ALPHN
1490 E2I
(MDIAG
,J
)=E2I
(MDIAG
,J
)+BETAN
1493 ABNO
=ALPHN**2
+BETAN**2
1501 SUMS
=SUMR
+FJAC
(I
,J
+K*M2
)
1502 SUMR
=SUMS*ALP
+SUMI*BET
1503 SUMI
=SUMI*ALP
-SUMS*BET
1506 E2R
(IMLE
,J
)=E2R
(IMLE
,J
)-SUMR
1507 E2I
(IMLE
,J
)=E2I
(IMLE
,J
)-SUMI
1510 CALL DECBC
(NM1
,LDE1
,E2R
,E2I
,MLE
,MUE
,IP2
,IER
)
1513 C -----------------------------------------------------------
1516 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
1524 DO I
=MAX
(1,J
-MUMAS
),MIN
(N
,J
+MLMAS
)
1525 BB
=FMAS
(I
-J
+MBDIAG
,J
)
1526 E2R
(I
,J
)=E2R
(I
,J
)+ALPHN*BB
1530 CALL DECC
(N
,LDE1
,E2R
,E2I
,IP2
,IER
)
1533 C -----------------------------------------------------------
1536 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1540 E2R
(I
,J
)=-FJAC
(I
,JM1
)
1543 DO I
=MAX
(1,J
-MUMAS
),MIN
(NM1
,J
+MLMAS
)
1544 FFMA
=FMAS
(I
-J
+MBDIAG
,J
)
1545 E2R
(I
,J
)=E2R
(I
,J
)+ALPHN*FFMA
1546 E2I
(I
,J
)=E2I
(I
,J
)+BETAN*FFMA
1551 C -----------------------------------------------------------
1554 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
1558 E2R
(IMLE
,J
)=-FJAC
(I
,J
)
1561 DO I
=MAX
(1,MUMAS
+2-J
),MIN
(MBB
,MUMAS
+1-J
+N
)
1564 E2R
(IB
,J
)=E2R
(IB
,J
)+ALPHN*BB
1568 CALL DECBC
(N
,LDE1
,E2R
,E2I
,MLE
,MUE
,IP2
,IER
)
1571 C -----------------------------------------------------------
1574 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX, SECOND ORDER
1578 E2R
(I
+MLE
,J
)=-FJAC
(I
,JM1
)
1584 E2R
(IB
,J
)=E2R
(IB
,J
)+ALPHN*FFMA
1585 E2I
(IB
,J
)=E2I
(IB
,J
)+BETAN*FFMA
1590 C -----------------------------------------------------------
1593 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
1597 E2R
(I
,J
)=BB*ALPHN
-FJAC
(I
,J
)
1601 CALL DECC
(N
,LDE1
,E2R
,E2I
,IP2
,IER
)
1604 C -----------------------------------------------------------
1607 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1611 E2R
(I
,J
)=ALPHN*FMAS
(I
,J
)-FJAC
(I
,JM1
)
1612 E2I
(I
,J
)=BETAN*FMAS
(I
,J
)
1617 C -----------------------------------------------------------
1620 C --- B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
1621 C --- THIS OPTION IS NOT PROVIDED
1624 C -----------------------------------------------------------
1627 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
1630 E2R
(J1
,J
)=-FJAC
(J1
,J
)
1638 E2R
(J
,J
)=E2R
(J
,J
)+ALPHN
1641 CALL DECHC
(N
,LDE1
,E2R
,E2I
,1,IP2
,IER
)
1644 C -----------------------------------------------------------
1650 C END OF SUBROUTINE DECOMC
1652 C ***********************************************************
1654 SUBROUTINE SLVRAR
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
1655 & M1
,M2
,NM1
,FAC1
,E1
,LDE1
,Z1
,F1
,IP1
,IPHES
,IER
,IJOB
)
1656 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
1657 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E1
(LDE1
,NM1
),
1658 & IP1
(NM1
),IPHES
(N
),Z1
(N
),F1
(N
)
1659 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
1661 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,13,15), IJOB
1663 C -----------------------------------------------------------
1666 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
1668 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1670 CALL SOL
(N
,LDE1
,E1
,Z1
,IP1
)
1673 C -----------------------------------------------------------
1676 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
1678 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1686 SUM1
=(Z1
(JKM
)+SUM1
)/FAC1
1689 Z1
(IM1
)=Z1
(IM1
)+FJAC
(I
,JKM
)*SUM1
1693 CALL SOL
(NM1
,LDE1
,E1
,Z1
(M1
+1),IP1
)
1696 Z1
(I
)=(Z1
(I
)+Z1
(M2
+I
))/FAC1
1700 C -----------------------------------------------------------
1703 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
1705 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1707 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,Z1
,IP1
)
1710 C -----------------------------------------------------------
1713 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
1715 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1723 SUM1
=(Z1
(JKM
)+SUM1
)/FAC1
1724 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
1726 Z1
(IM1
)=Z1
(IM1
)+FJAC
(I
+MUJAC
+1-J
,JKM
)*SUM1
1730 CALL SOLB
(NM1
,LDE1
,E1
,MLE
,MUE
,Z1
(M1
+1),IP1
)
1733 C -----------------------------------------------------------
1736 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
1739 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
1740 S1
=S1
-FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
)
1744 CALL SOL
(N
,LDE1
,E1
,Z1
,IP1
)
1747 C -----------------------------------------------------------
1750 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1752 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1757 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
1758 S1
=S1
-FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
+M1
)
1760 Z1
(IM1
)=Z1
(IM1
)+S1*FAC1
1762 IF (IJOB
.EQ
.14) GOTO 45
1765 C -----------------------------------------------------------
1768 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
1771 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
1772 S1
=S1
-FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
)
1776 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,Z1
,IP1
)
1779 C -----------------------------------------------------------
1782 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
1786 S1
=S1
-FMAS
(I
,J
)*F1
(J
)
1790 CALL SOL
(N
,LDE1
,E1
,Z1
,IP1
)
1793 C -----------------------------------------------------------
1796 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1798 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1804 S1
=S1
-FMAS
(I
,J
)*F1
(J
+M1
)
1806 Z1
(IM1
)=Z1
(IM1
)+S1*FAC1
1810 C -----------------------------------------------------------
1813 C --- B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
1814 C --- THIS OPTION IS NOT PROVIDED
1817 C -----------------------------------------------------------
1820 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
1822 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
1828 IF (I
.EQ
.MP
) GOTO 746
1834 Z1
(I
)=Z1
(I
)-FJAC
(I
,MP1
)*Z1
(MP
)
1837 CALL SOLH
(N
,LDE1
,E1
,1,Z1
,IP1
)
1842 Z1
(I
)=Z1
(I
)+FJAC
(I
,MP1
)*Z1
(MP
)
1845 IF (I
.EQ
.MP
) GOTO 750
1853 C -----------------------------------------------------------
1859 C END OF SUBROUTINE SLVRAR
1861 C ***********************************************************
1863 SUBROUTINE SLVRAI
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
1864 & M1
,M2
,NM1
,ALPHN
,BETAN
,E2R
,E2I
,LDE1
,Z2
,Z3
,
1865 & F2
,F3
,CONT
,IP2
,IPHES
,IER
,IJOB
)
1866 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
1867 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),
1868 & IP2
(NM1
),IPHES
(N
),Z2
(N
),Z3
(N
),F2
(N
),F3
(N
)
1869 DIMENSION E2R
(LDE1
,NM1
),E2I
(LDE1
,NM1
)
1870 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
1872 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,13,15), IJOB
1874 C -----------------------------------------------------------
1877 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
1881 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
1882 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
1884 CALL SOLC
(N
,LDE1
,E2R
,E2I
,Z2
,Z3
,IP2
)
1887 C -----------------------------------------------------------
1890 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
1894 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
1895 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
1897 48 ABNO
=ALPHN**2
+BETAN**2
1904 SUMH
=(Z2
(JKM
)+SUM2
)/ABNO
1905 SUM3
=(Z3
(JKM
)+SUM3
)/ABNO
1906 SUM2
=SUMH*ALPHN
+SUM3*BETAN
1907 SUM3
=SUM3*ALPHN
-SUMH*BETAN
1910 Z2
(IM1
)=Z2
(IM1
)+FJAC
(I
,JKM
)*SUM2
1911 Z3
(IM1
)=Z3
(IM1
)+FJAC
(I
,JKM
)*SUM3
1915 CALL SOLC
(NM1
,LDE1
,E2R
,E2I
,Z2
(M1
+1),Z3
(M1
+1),IP2
)
1921 Z3
(I
)=(Z3I*ALPHN
-Z2I*BETAN
)/ABNO
1922 Z2
(I
)=(Z2I*ALPHN
+Z3I*BETAN
)/ABNO
1926 C -----------------------------------------------------------
1929 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
1933 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
1934 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
1936 CALL SOLBC
(N
,LDE1
,E2R
,E2I
,MLE
,MUE
,Z2
,Z3
,IP2
)
1939 C -----------------------------------------------------------
1942 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
1946 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
1947 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
1949 45 ABNO
=ALPHN**2
+BETAN**2
1956 SUMH
=(Z2
(JKM
)+SUM2
)/ABNO
1957 SUM3
=(Z3
(JKM
)+SUM3
)/ABNO
1958 SUM2
=SUMH*ALPHN
+SUM3*BETAN
1959 SUM3
=SUM3*ALPHN
-SUMH*BETAN
1960 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
1963 Z2
(IM1
)=Z2
(IM1
)+FJAC
(IIMU
,JKM
)*SUM2
1964 Z3
(IM1
)=Z3
(IM1
)+FJAC
(IIMU
,JKM
)*SUM3
1968 CALL SOLBC
(NM1
,LDE1
,E2R
,E2I
,MLE
,MUE
,Z2
(M1
+1),Z3
(M1
+1),IP2
)
1971 C -----------------------------------------------------------
1974 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
1978 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
1979 BB
=FMAS
(I
-J
+MBDIAG
,J
)
1983 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
1984 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
1986 CALL SOLC
(N
,LDE1
,E2R
,E2I
,Z2
,Z3
,IP2
)
1989 C -----------------------------------------------------------
1992 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
1996 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
1997 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2003 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
2005 BB
=FMAS
(I
-J
+MBDIAG
,J
)
2009 Z2
(IM1
)=Z2
(IM1
)+S2*ALPHN
-S3*BETAN
2010 Z3
(IM1
)=Z3
(IM1
)+S3*ALPHN
+S2*BETAN
2012 IF (IJOB
.EQ
.14) GOTO 45
2015 C -----------------------------------------------------------
2018 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
2022 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2023 BB
=FMAS
(I
-J
+MBDIAG
,J
)
2027 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2028 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2030 CALL SOLBC
(N
,LDE1
,E2R
,E2I
,MLE
,MUE
,Z2
,Z3
,IP2
)
2033 C -----------------------------------------------------------
2036 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
2045 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2046 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2048 CALL SOLC
(N
,LDE1
,E2R
,E2I
,Z2
,Z3
,IP2
)
2051 C -----------------------------------------------------------
2054 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
2058 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2059 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2071 Z2
(IM1
)=Z2
(IM1
)+S2*ALPHN
-S3*BETAN
2072 Z3
(IM1
)=Z3
(IM1
)+S3*ALPHN
+S2*BETAN
2076 C -----------------------------------------------------------
2079 C --- B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
2080 C --- THIS OPTION IS NOT PROVIDED
2083 C -----------------------------------------------------------
2086 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
2090 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2091 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2097 IF (I
.EQ
.MP
) GOTO 746
2107 Z2
(I
)=Z2
(I
)-E1IMP*Z2
(MP
)
2108 Z3
(I
)=Z3
(I
)-E1IMP*Z3
(MP
)
2111 CALL SOLHC
(N
,LDE1
,E2R
,E2I
,1,Z2
,Z3
,IP2
)
2117 Z2
(I
)=Z2
(I
)+E1IMP*Z2
(MP
)
2118 Z3
(I
)=Z3
(I
)+E1IMP*Z3
(MP
)
2121 IF (I
.EQ
.MP
) GOTO 750
2132 C -----------------------------------------------------------
2138 C END OF SUBROUTINE SLVRAI
2140 C ***********************************************************
2142 SUBROUTINE SLVRAD
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
2143 & M1
,M2
,NM1
,FAC1
,ALPHN
,BETAN
,E1
,E2R
,E2I
,LDE1
,Z1
,Z2
,Z3
,
2144 & F1
,F2
,F3
,CONT
,IP1
,IP2
,IPHES
,IER
,IJOB
)
2145 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
2146 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E1
(LDE1
,NM1
),
2147 & E2R
(LDE1
,NM1
),E2I
(LDE1
,NM1
),IP1
(NM1
),IP2
(NM1
),
2148 & IPHES
(N
),Z1
(N
),Z2
(N
),Z3
(N
),F1
(N
),F2
(N
),F3
(N
)
2149 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
2151 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,13,15), IJOB
2153 C -----------------------------------------------------------
2156 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
2160 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2161 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2162 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2164 CALL SOL
(N
,LDE1
,E1
,Z1
,IP1
)
2165 CALL SOLC
(N
,LDE1
,E2R
,E2I
,Z2
,Z3
,IP2
)
2168 C -----------------------------------------------------------
2171 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
2175 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2176 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2177 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2179 48 ABNO
=ALPHN**2
+BETAN**2
2187 SUM1
=(Z1
(JKM
)+SUM1
)/FAC1
2188 SUMH
=(Z2
(JKM
)+SUM2
)/ABNO
2189 SUM3
=(Z3
(JKM
)+SUM3
)/ABNO
2190 SUM2
=SUMH*ALPHN
+SUM3*BETAN
2191 SUM3
=SUM3*ALPHN
-SUMH*BETAN
2194 Z1
(IM1
)=Z1
(IM1
)+FJAC
(I
,JKM
)*SUM1
2195 Z2
(IM1
)=Z2
(IM1
)+FJAC
(I
,JKM
)*SUM2
2196 Z3
(IM1
)=Z3
(IM1
)+FJAC
(I
,JKM
)*SUM3
2200 CALL SOL
(NM1
,LDE1
,E1
,Z1
(M1
+1),IP1
)
2201 CALL SOLC
(NM1
,LDE1
,E2R
,E2I
,Z2
(M1
+1),Z3
(M1
+1),IP2
)
2205 Z1
(I
)=(Z1
(I
)+Z1
(MPI
))/FAC1
2208 Z3
(I
)=(Z3I*ALPHN
-Z2I*BETAN
)/ABNO
2209 Z2
(I
)=(Z2I*ALPHN
+Z3I*BETAN
)/ABNO
2213 C -----------------------------------------------------------
2216 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
2220 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2221 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2222 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2224 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,Z1
,IP1
)
2225 CALL SOLBC
(N
,LDE1
,E2R
,E2I
,MLE
,MUE
,Z2
,Z3
,IP2
)
2228 C -----------------------------------------------------------
2231 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
2235 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2236 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2237 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2239 45 ABNO
=ALPHN**2
+BETAN**2
2247 SUM1
=(Z1
(JKM
)+SUM1
)/FAC1
2248 SUMH
=(Z2
(JKM
)+SUM2
)/ABNO
2249 SUM3
=(Z3
(JKM
)+SUM3
)/ABNO
2250 SUM2
=SUMH*ALPHN
+SUM3*BETAN
2251 SUM3
=SUM3*ALPHN
-SUMH*BETAN
2252 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
2254 FFJA
=FJAC
(I
+MUJAC
+1-J
,JKM
)
2255 Z1
(IM1
)=Z1
(IM1
)+FFJA*SUM1
2256 Z2
(IM1
)=Z2
(IM1
)+FFJA*SUM2
2257 Z3
(IM1
)=Z3
(IM1
)+FFJA*SUM3
2261 CALL SOLB
(NM1
,LDE1
,E1
,MLE
,MUE
,Z1
(M1
+1),IP1
)
2262 CALL SOLBC
(NM1
,LDE1
,E2R
,E2I
,MLE
,MUE
,Z2
(M1
+1),Z3
(M1
+1),IP2
)
2265 C -----------------------------------------------------------
2268 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
2273 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2274 BB
=FMAS
(I
-J
+MBDIAG
,J
)
2280 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2281 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2283 CALL SOL
(N
,LDE1
,E1
,Z1
,IP1
)
2284 CALL SOLC
(N
,LDE1
,E2R
,E2I
,Z2
,Z3
,IP2
)
2287 C -----------------------------------------------------------
2290 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
2294 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2295 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2296 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2304 J2B
=MIN
(NM1
,I
+MUMAS
)
2307 BB
=FMAS
(I
-J
+MBDIAG
,J
)
2312 Z1
(IM1
)=Z1
(IM1
)+S1*FAC1
2313 Z2
(IM1
)=Z2
(IM1
)+S2*ALPHN
-S3*BETAN
2314 Z3
(IM1
)=Z3
(IM1
)+S3*ALPHN
+S2*BETAN
2316 IF (IJOB
.EQ
.14) GOTO 45
2319 C -----------------------------------------------------------
2322 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
2327 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2328 BB
=FMAS
(I
-J
+MBDIAG
,J
)
2334 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2335 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2337 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,Z1
,IP1
)
2338 CALL SOLBC
(N
,LDE1
,E2R
,E2I
,MLE
,MUE
,Z2
,Z3
,IP2
)
2341 C -----------------------------------------------------------
2344 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
2356 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2357 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2359 CALL SOL
(N
,LDE1
,E1
,Z1
,IP1
)
2360 CALL SOLC
(N
,LDE1
,E2R
,E2I
,Z2
,Z3
,IP2
)
2363 C -----------------------------------------------------------
2366 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
2370 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2371 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2372 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2386 Z1
(IM1
)=Z1
(IM1
)+S1*FAC1
2387 Z2
(IM1
)=Z2
(IM1
)+S2*ALPHN
-S3*BETAN
2388 Z3
(IM1
)=Z3
(IM1
)+S3*ALPHN
+S2*BETAN
2392 C -----------------------------------------------------------
2395 C --- B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
2396 C --- THIS OPTION IS NOT PROVIDED
2399 C -----------------------------------------------------------
2402 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
2406 Z1
(I
)=Z1
(I
)-F1
(I
)*FAC1
2407 Z2
(I
)=Z2
(I
)+S2*ALPHN
-S3*BETAN
2408 Z3
(I
)=Z3
(I
)+S3*ALPHN
+S2*BETAN
2414 IF (I
.EQ
.MP
) GOTO 746
2427 Z1
(I
)=Z1
(I
)-E1IMP*Z1
(MP
)
2428 Z2
(I
)=Z2
(I
)-E1IMP*Z2
(MP
)
2429 Z3
(I
)=Z3
(I
)-E1IMP*Z3
(MP
)
2432 CALL SOLH
(N
,LDE1
,E1
,1,Z1
,IP1
)
2433 CALL SOLHC
(N
,LDE1
,E2R
,E2I
,1,Z2
,Z3
,IP2
)
2439 Z1
(I
)=Z1
(I
)+E1IMP*Z1
(MP
)
2440 Z2
(I
)=Z2
(I
)+E1IMP*Z2
(MP
)
2441 Z3
(I
)=Z3
(I
)+E1IMP*Z3
(MP
)
2444 IF (I
.EQ
.MP
) GOTO 750
2458 C -----------------------------------------------------------
2464 C END OF SUBROUTINE SLVRAD
2466 C ***********************************************************
2468 SUBROUTINE ESTRAD
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
2469 & H
,DD1
,DD2
,DD3
,FCN
,NFCN
,Y0
,Y
,IJOB
,X
,M1
,M2
,NM1
,
2470 & E1
,LDE1
,Z1
,Z2
,Z3
,CONT
,F1
,F2
,IP1
,IPHES
,SCAL
,ERR
,
2471 & FIRST
,REJECT
,FAC1
,RPAR
,IPAR
)
2472 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
2473 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E1
(LDE1
,NM1
),IP1
(NM1
),
2474 & SCAL
(N
),IPHES
(N
),Z1
(N
),Z2
(N
),Z3
(N
),F1
(N
),F2
(N
),Y0
(N
),Y
(N
)
2475 DIMENSION CONT
(N
),RPAR
(1),IPAR
(1)
2476 LOGICAL FIRST
,REJECT
2477 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
2482 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,14,15), IJOB
2485 C ------ B=IDENTITY, JACOBIAN A FULL MATRIX
2487 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2490 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
2494 C ------ B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
2496 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2503 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
2506 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
,J
+K*M2
)*SUM1
2510 CALL SOL
(NM1
,LDE1
,E1
,CONT
(M1
+1),IP1
)
2512 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
2517 C ------ B=IDENTITY, JACOBIAN A BANDED MATRIX
2519 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2522 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,CONT
,IP1
)
2526 C ------ B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
2528 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2535 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
2536 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
2538 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
+MUJAC
+1-J
,J
+K*M2
)*SUM1
2542 CALL SOLB
(NM1
,LDE1
,E1
,MLE
,MUE
,CONT
(M1
+1),IP1
)
2544 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
2549 C ------ B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
2551 F1
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2555 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2556 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
)
2561 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
2565 C ------ B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
2567 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2571 F1
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2575 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
2576 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
+M1
)
2580 CONT
(IM1
)=SUM
+Y0
(IM1
)
2585 C ------ B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
2587 F1
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2591 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2592 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
)
2597 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,CONT
,IP1
)
2601 C ------ B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX, SECOND ORDER
2603 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2607 F1
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2611 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
2612 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*F1
(J
+M1
)
2616 CONT
(IM1
)=SUM
+Y0
(IM1
)
2621 C ------ B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
2623 F1
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2628 SUM
=SUM
+FMAS
(I
,J
)*F1
(J
)
2633 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
2637 C ------ B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
2639 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2643 F1
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2648 SUM
=SUM
+FMAS
(I
,J
)*F1
(J
+M1
)
2652 CONT
(IM1
)=SUM
+Y0
(IM1
)
2657 C ------ B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
2658 C ------ THIS OPTION IS NOT PROVIDED
2662 C ------ B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
2664 F2
(I
)=HEE1*Z1
(I
)+HEE2*Z2
(I
)+HEE3*Z3
(I
)
2670 IF (I
.EQ
.MP
) GOTO 310
2676 CONT
(I
)=CONT
(I
)-FJAC
(I
,MP
-1)*CONT
(MP
)
2679 CALL SOLH
(N
,LDE1
,E1
,1,CONT
,IP1
)
2683 CONT
(I
)=CONT
(I
)+FJAC
(I
,MP
-1)*CONT
(MP
)
2686 IF (I
.EQ
.MP
) GOTO 440
2693 C --------------------------------------
2698 ERR
=ERR
+(CONT
(I
)/SCAL
(I
))**2
2700 ERR
=MAX
(SQRT
(ERR
/N
),1.D
-10)
2702 IF (ERR
.LT
.1.D0
) RETURN
2703 IF (FIRST
.OR
.REJECT
) THEN
2705 CONT
(I
)=Y
(I
)+CONT
(I
)
2707 CALL FCN
(N
,X
,CONT
,F1
,RPAR
,IPAR
)
2712 GOTO (31,32,31,32,31,32,33,55,55,55,41,42,41,42,41), IJOB
2713 C ------ FULL MATRIX OPTION
2715 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
2717 C ------ FULL MATRIX OPTION, SECOND ORDER
2722 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
2725 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
,J
+K*M2
)*SUM1
2729 CALL SOL
(NM1
,LDE1
,E1
,CONT
(M1
+1),IP1
)
2731 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
2734 C ------ BANDED MATRIX OPTION
2736 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,CONT
,IP1
)
2738 C ------ BANDED MATRIX OPTION, SECOND ORDER
2743 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
2744 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
2746 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
+MUJAC
+1-J
,J
+K*M2
)*SUM1
2750 CALL SOLB
(NM1
,LDE1
,E1
,MLE
,MUE
,CONT
(M1
+1),IP1
)
2752 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
2755 C ------ HESSENBERG MATRIX OPTION
2760 IF (I
.EQ
.MP
) GOTO 510
2766 CONT
(I
)=CONT
(I
)-FJAC
(I
,MP
-1)*CONT
(MP
)
2769 CALL SOLH
(N
,LDE1
,E1
,1,CONT
,IP1
)
2773 CONT
(I
)=CONT
(I
)+FJAC
(I
,MP
-1)*CONT
(MP
)
2776 IF (I
.EQ
.MP
) GOTO 640
2782 C -----------------------------------
2786 ERR
=ERR
+(CONT
(I
)/SCAL
(I
))**2
2788 ERR
=MAX
(SQRT
(ERR
/N
),1.D
-10)
2791 C -----------------------------------------------------------
2796 C END OF SUBROUTINE ESTRAD
2798 C ***********************************************************
2800 SUBROUTINE ESTRAV
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
2801 & H
,DD
,FCN
,NFCN
,Y0
,Y
,IJOB
,X
,M1
,M2
,NM1
,NS
,NNS
,
2802 & E1
,LDE1
,ZZ
,CONT
,FF
,IP1
,IPHES
,SCAL
,ERR
,
2803 & FIRST
,REJECT
,FAC1
,RPAR
,IPAR
)
2804 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
2805 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E1
(LDE1
,NM1
),IP1
(NM1
),
2806 & SCAL
(N
),IPHES
(N
),ZZ
(NNS
),FF
(NNS
),Y0
(N
),Y
(N
)
2807 DIMENSION DD
(NS
),CONT
(N
),RPAR
(1),IPAR
(1)
2808 LOGICAL FIRST
,REJECT
2809 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
2812 GOTO (1,2,3,4,5,6,7,55,55,55,11,12,13,14,15), IJOB
2815 C ------ B=IDENTITY, JACOBIAN A FULL MATRIX
2819 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2822 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
2824 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
2828 C ------ B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
2832 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2835 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
2841 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
2844 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
,J
+K*M2
)*SUM1
2848 CALL SOL
(NM1
,LDE1
,E1
,CONT
(M1
+1),IP1
)
2850 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
2855 C ------ B=IDENTITY, JACOBIAN A BANDED MATRIX
2859 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2862 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
2864 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,CONT
,IP1
)
2868 C ------ B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
2872 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2875 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
2881 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
2882 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
2884 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
+MUJAC
+1-J
,J
+K*M2
)*SUM1
2888 CALL SOLB
(NM1
,LDE1
,E1
,MLE
,MUE
,CONT
(M1
+1),IP1
)
2890 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
2895 C ------ B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
2899 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2905 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2906 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*FF
(J
)
2911 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
2915 C ------ B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
2919 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2922 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
2927 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2933 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
2934 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*FF
(J
+M1
)
2938 CONT
(IM1
)=SUM
+Y0
(IM1
)
2943 C ------ B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
2947 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2953 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
2954 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*FF
(J
)
2959 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,CONT
,IP1
)
2963 C ------ B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX, SECOND ORDER
2967 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2970 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
2975 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
2981 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
2982 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*FF
(J
+M1
)
2986 CONT
(IM1
)=SUM
+Y0
(IM1
)
2991 C ------ B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
2995 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
3002 SUM
=SUM
+FMAS
(I
,J
)*FF
(J
)
3007 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
3011 C ------ B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
3015 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
3018 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
3023 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
3030 SUM
=SUM
+FMAS
(I
,J
)*FF
(J
+M1
)
3034 CONT
(IM1
)=SUM
+Y0
(IM1
)
3039 C ------ B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
3040 C ------ THIS OPTION IS NOT PROVIDED
3044 C ------ B=IDENTITY, JACOBIAN A FULL MATRIX, HESSENBERG-OPTION
3048 SUM
=SUM
+DD
(K
)*ZZ
(I
+(K
-1)*N
)
3051 CONT
(I
)=FF
(I
+N
)+Y0
(I
)
3056 IF (I
.EQ
.MP
) GOTO 310
3062 CONT
(I
)=CONT
(I
)-FJAC
(I
,MP
-1)*CONT
(MP
)
3065 CALL SOLH
(N
,LDE1
,E1
,1,CONT
,IP1
)
3069 CONT
(I
)=CONT
(I
)+FJAC
(I
,MP
-1)*CONT
(MP
)
3072 IF (I
.EQ
.MP
) GOTO 440
3079 C --------------------------------------
3084 ERR
=ERR
+(CONT
(I
)/SCAL
(I
))**2
3086 ERR
=MAX
(SQRT
(ERR
/N
),1.D
-10)
3088 IF (ERR
.LT
.1.D0
) RETURN
3089 IF (FIRST
.OR
.REJECT
) THEN
3091 CONT
(I
)=Y
(I
)+CONT
(I
)
3093 CALL FCN
(N
,X
,CONT
,FF
,RPAR
,IPAR
)
3096 CONT
(I
)=FF
(I
)+FF
(I
+N
)
3098 GOTO (31,32,31,32,31,32,33,55,55,55,41,42,41,42,41), IJOB
3099 C ------ FULL MATRIX OPTION
3101 CALL SOL
(N
,LDE1
,E1
,CONT
,IP1
)
3103 C ------ FULL MATRIX OPTION, SECOND ORDER
3108 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
3111 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
,J
+K*M2
)*SUM1
3115 CALL SOL
(NM1
,LDE1
,E1
,CONT
(M1
+1),IP1
)
3117 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
3120 C ------ BANDED MATRIX OPTION
3122 CALL SOLB
(N
,LDE1
,E1
,MLE
,MUE
,CONT
,IP1
)
3124 C ------ BANDED MATRIX OPTION, SECOND ORDER
3129 SUM1
=(CONT
(J
+K*M2
)+SUM1
)/FAC1
3130 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
3132 CONT
(IM1
)=CONT
(IM1
)+FJAC
(I
+MUJAC
+1-J
,J
+K*M2
)*SUM1
3136 CALL SOLB
(NM1
,LDE1
,E1
,MLE
,MUE
,CONT
(M1
+1),IP1
)
3138 CONT
(I
)=(CONT
(I
)+CONT
(M2
+I
))/FAC1
3141 C ------ HESSENBERG MATRIX OPTION
3146 IF (I
.EQ
.MP
) GOTO 510
3152 CONT
(I
)=CONT
(I
)-FJAC
(I
,MP
-1)*CONT
(MP
)
3155 CALL SOLH
(N
,LDE1
,E1
,1,CONT
,IP1
)
3159 CONT
(I
)=CONT
(I
)+FJAC
(I
,MP
-1)*CONT
(MP
)
3162 IF (I
.EQ
.MP
) GOTO 640
3168 C -----------------------------------
3172 ERR
=ERR
+(CONT
(I
)/SCAL
(I
))**2
3174 ERR
=MAX
(SQRT
(ERR
/N
),1.D
-10)
3178 C -----------------------------------------------------------
3184 C END OF SUBROUTINE ESTRAV
3186 C ***********************************************************
3188 SUBROUTINE SLVROD
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
3189 & M1
,M2
,NM1
,FAC1
,E
,LDE
,IP
,DY
,AK
,FX
,YNEW
,HD
,IJOB
,STAGE1
)
3190 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
3191 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E
(LDE
,NM1
),
3192 & IP
(NM1
),DY
(N
),AK
(N
),FX
(N
),YNEW
(N
)
3194 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
3196 IF (HD
.EQ
.0.D0
) THEN
3202 AK
(I
)=DY
(I
)+HD*FX
(I
)
3206 GOTO (1,2,3,4,5,6,55,55,55,55,11,12,13,13,15), IJOB
3208 C -----------------------------------------------------------
3211 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
3217 CALL SOL
(N
,LDE
,E
,AK
,IP
)
3220 C -----------------------------------------------------------
3223 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
3234 SUM
=(AK
(JKM
)+SUM
)/FAC1
3237 AK
(IM1
)=AK
(IM1
)+FJAC
(I
,JKM
)*SUM
3241 CALL SOL
(NM1
,LDE
,E
,AK
(M1
+1),IP
)
3243 AK
(I
)=(AK
(I
)+AK
(M2
+I
))/FAC1
3247 C -----------------------------------------------------------
3250 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
3256 CALL SOLB
(N
,LDE
,E
,MLE
,MUE
,AK
,IP
)
3259 C -----------------------------------------------------------
3262 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
3273 SUM
=(AK
(JKM
)+SUM
)/FAC1
3274 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
3276 AK
(IM1
)=AK
(IM1
)+FJAC
(I
+MUJAC
+1-J
,JKM
)*SUM
3280 CALL SOLB
(NM1
,LDE
,E
,MLE
,MUE
,AK
(M1
+1),IP
)
3282 AK
(I
)=(AK
(I
)+AK
(M2
+I
))/FAC1
3286 C -----------------------------------------------------------
3289 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX
3293 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
3294 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*YNEW
(J
)
3299 CALL SOL
(N
,LDE
,E
,AK
,IP
)
3302 C -----------------------------------------------------------
3305 C --- B IS A BANDED MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
3312 DO J
=MAX
(1,I
-MLMAS
),MIN
(NM1
,I
+MUMAS
)
3313 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*YNEW
(J
+M1
)
3319 IF (IJOB
.EQ
.14) GOTO 45
3322 C -----------------------------------------------------------
3325 C --- B IS A BANDED MATRIX, JACOBIAN A BANDED MATRIX
3329 DO J
=MAX
(1,I
-MLMAS
),MIN
(N
,I
+MUMAS
)
3330 SUM
=SUM
+FMAS
(I
-J
+MBDIAG
,J
)*YNEW
(J
)
3335 CALL SOLB
(N
,LDE
,E
,MLE
,MUE
,AK
,IP
)
3338 C -----------------------------------------------------------
3341 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX
3346 SUM
=SUM
+FMAS
(I
,J
)*YNEW
(J
)
3351 CALL SOL
(N
,LDE
,E
,AK
,IP
)
3354 C -----------------------------------------------------------
3357 C --- B IS A FULL MATRIX, JACOBIAN A FULL MATRIX, SECOND ORDER
3365 SUM
=SUM
+FMAS
(I
,J
)*YNEW
(J
+M1
)
3373 C -----------------------------------------------------------
3376 C --- B IS A FULL MATRIX, JACOBIAN A BANDED MATRIX
3377 C --- THIS OPTION IS NOT PROVIDED
3382 623 SUM
=SUM
+FMAS
(I
,J
)*YNEW
(J
)
3384 CALL SOLB
(N
,LDE
,E
,MLE
,MUE
,AK
,IP
)
3388 C -----------------------------------------------------------
3394 C END OF SUBROUTINE SLVROD
3397 C ***********************************************************
3399 SUBROUTINE SLVSEU
(N
,FJAC
,LDJAC
,MLJAC
,MUJAC
,FMAS
,LDMAS
,MLMAS
,MUMAS
,
3400 & M1
,M2
,NM1
,FAC1
,E
,LDE
,IP
,IPHES
,DEL
,IJOB
)
3401 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
3402 DIMENSION FJAC
(LDJAC
,N
),FMAS
(LDMAS
,NM1
),E
(LDE
,NM1
),DEL
(N
)
3403 DIMENSION IP
(NM1
),IPHES
(N
)
3404 COMMON/LINAL
/MLE
,MUE
,MBJAC
,MBB
,MDIAG
,MDIFF
,MBDIAG
3406 GOTO (1,2,1,2,1,55,7,55,55,55,11,12,11,12,11), IJOB
3408 C -----------------------------------------------------------
3411 C --- B=IDENTITY, JACOBIAN A FULL MATRIX
3412 CALL SOL
(N
,LDE
,E
,DEL
,IP
)
3415 C -----------------------------------------------------------
3418 C --- B=IDENTITY, JACOBIAN A FULL MATRIX, SECOND ORDER
3424 SUM
=(DEL
(JKM
)+SUM
)/FAC1
3427 DEL
(IM1
)=DEL
(IM1
)+FJAC
(I
,JKM
)*SUM
3431 CALL SOL
(NM1
,LDE
,E
,DEL
(M1
+1),IP
)
3433 DEL
(I
)=(DEL
(I
)+DEL
(M2
+I
))/FAC1
3437 C -----------------------------------------------------------
3440 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX
3441 CALL SOLB
(N
,LDE
,E
,MLE
,MUE
,DEL
,IP
)
3444 C -----------------------------------------------------------
3447 C --- B=IDENTITY, JACOBIAN A BANDED MATRIX, SECOND ORDER
3453 SUM
=(DEL
(JKM
)+SUM
)/FAC1
3454 DO I
=MAX
(1,J
-MUJAC
),MIN
(NM1
,J
+MLJAC
)
3456 DEL
(IM1
)=DEL
(IM1
)+FJAC
(I
+MUJAC
+1-J
,JKM
)*SUM
3460 CALL SOLB
(NM1
,LDE
,E
,MLE
,MUE
,DEL
(M1
+1),IP
)
3462 DEL
(I
)=(DEL
(I
)+DEL
(M2
+I
))/FAC1
3466 C -----------------------------------------------------------
3469 C --- HESSENBERG OPTION
3474 IF (I
.EQ
.MP
) GOTO 110
3480 DEL
(I
)=DEL
(I
)-FJAC
(I
,MP1
)*DEL
(MP
)
3483 CALL SOLH
(N
,LDE
,E
,1,DEL
,IP
)
3488 DEL
(I
)=DEL
(I
)+FJAC
(I
,MP1
)*DEL
(MP
)
3491 IF (I
.EQ
.MP
) GOTO 240
3499 C -----------------------------------------------------------
3505 C END OF SUBROUTINE SLVSEU
3507 SUBROUTINE DEC
(N
, NDIM
, A
, IP
, IER
)
3508 C VERSION REAL KPP_REAL
3509 INTEGER N
,NDIM
,IP
,IER
,NM1
,K
,KP1
,M
,I
,J
3511 DIMENSION A
(NDIM
,N
), IP
(N
)
3512 C-----------------------------------------------------------------------
3513 C MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION.
3515 C N = ORDER OF MATRIX.
3516 C NDIM = DECLARED DIMENSION OF ARRAY A .
3517 C A = MATRIX TO BE TRIANGULARIZED.
3519 C A(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U .
3520 C A(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR FACTOR, I - L.
3521 C IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.
3522 C IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR O .
3523 C IER = 0 IF MATRIX A IS NONSINGULAR, OR K IF FOUND TO BE
3524 C SINGULAR AT STAGE K.
3525 C USE SOL TO OBTAIN SOLUTION OF LINEAR SYSTEM.
3526 C DETERM(A) = IP(N)*A(1,1)*A(2,2)*...*A(N,N).
3527 C IF IP(N)=O, A IS SINGULAR, SOL WILL DIVIDE BY ZERO.
3530 C C. B. MOLER, ALGORITHM 423, LINEAR EQUATION KppSolveR,
3531 C C.A.C.M. 15 (1972), P. 274.
3532 C-----------------------------------------------------------------------
3535 IF (N
.EQ
. 1) GO TO 70
3541 IF (DABS
(A
(I
,K
)) .GT
. DABS
(A
(M
,K
))) M
= I
3545 IF (M
.EQ
. K
) GO TO 20
3550 IF (T
.EQ
. 0.D0
) GO TO 80
3553 30 A
(I
,K
) = -A
(I
,K
)*T
3558 IF (T
.EQ
. 0.D0
) GO TO 45
3560 40 A
(I
,J
) = A
(I
,J
) + A
(I
,K
)*T
3565 IF (A
(N
,N
) .EQ
. 0.D0
) GO TO 80
3570 C----------------------- END OF SUBROUTINE DEC -------------------------
3574 SUBROUTINE SOL
(N
, NDIM
, A
, B
, IP
)
3575 C VERSION REAL KPP_REAL
3576 INTEGER N
,NDIM
,IP
,NM1
,K
,KP1
,M
,I
,KB
,KM1
3578 DIMENSION A
(NDIM
,N
), B
(N
), IP
(N
)
3579 C-----------------------------------------------------------------------
3580 C SOLUTION OF LINEAR SYSTEM, A*X = B .
3582 C N = ORDER OF MATRIX.
3583 C NDIM = DECLARED DIMENSION OF ARRAY A .
3584 C A = TRIANGULARIZED MATRIX OBTAINED FROM DEC.
3585 C B = RIGHT HAND SIDE VECTOR.
3586 C IP = PIVOT VECTOR OBTAINED FROM DEC.
3587 C DO NOT USE IF DEC HAS SET IER .NE. 0.
3589 C B = SOLUTION VECTOR, X .
3590 C-----------------------------------------------------------------------
3591 IF (N
.EQ
. 1) GO TO 50
3600 10 B
(I
) = B
(I
) + A
(I
,K
)*T
3608 30 B
(I
) = B
(I
) + A
(I
,K
)*T
3610 50 B
(1) = B
(1)/A
(1,1)
3612 C----------------------- END OF SUBROUTINE SOL -------------------------
3616 SUBROUTINE DECH
(N
, NDIM
, A
, LB
, IP
, IER
)
3617 C VERSION REAL KPP_REAL
3618 INTEGER N
,NDIM
,IP
,IER
,NM1
,K
,KP1
,M
,I
,J
,LB
,NA
3620 DIMENSION A
(NDIM
,N
), IP
(N
)
3621 C-----------------------------------------------------------------------
3622 C MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION OF A HESSENBERG
3623 C MATRIX WITH LOWER BANDWIDTH LB
3625 C N = ORDER OF MATRIX A.
3626 C NDIM = DECLARED DIMENSION OF ARRAY A .
3627 C A = MATRIX TO BE TRIANGULARIZED.
3628 C LB = LOWER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED, LB.GE.1).
3630 C A(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U .
3631 C A(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR FACTOR, I - L.
3632 C IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.
3633 C IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR O .
3634 C IER = 0 IF MATRIX A IS NONSINGULAR, OR K IF FOUND TO BE
3635 C SINGULAR AT STAGE K.
3636 C USE SOLH TO OBTAIN SOLUTION OF LINEAR SYSTEM.
3637 C DETERM(A) = IP(N)*A(1,1)*A(2,2)*...*A(N,N).
3638 C IF IP(N)=O, A IS SINGULAR, SOL WILL DIVIDE BY ZERO.
3641 C THIS IS A SLIGHT MODIFICATION OF
3642 C C. B. MOLER, ALGORITHM 423, LINEAR EQUATION KppSolveR,
3643 C C.A.C.M. 15 (1972), P. 274.
3644 C-----------------------------------------------------------------------
3647 IF (N
.EQ
. 1) GO TO 70
3654 IF (DABS
(A
(I
,K
)) .GT
. DABS
(A
(M
,K
))) M
= I
3658 IF (M
.EQ
. K
) GO TO 20
3663 IF (T
.EQ
. 0.D0
) GO TO 80
3666 30 A
(I
,K
) = -A
(I
,K
)*T
3671 IF (T
.EQ
. 0.D0
) GO TO 45
3673 40 A
(I
,J
) = A
(I
,J
) + A
(I
,K
)*T
3678 IF (A
(N
,N
) .EQ
. 0.D0
) GO TO 80
3683 C----------------------- END OF SUBROUTINE DECH ------------------------
3687 SUBROUTINE SOLH
(N
, NDIM
, A
, LB
, B
, IP
)
3688 C VERSION REAL KPP_REAL
3689 INTEGER N
,NDIM
,IP
,NM1
,K
,KP1
,M
,I
,KB
,KM1
,LB
,NA
3691 DIMENSION A
(NDIM
,N
), B
(N
), IP
(N
)
3692 C-----------------------------------------------------------------------
3693 C SOLUTION OF LINEAR SYSTEM, A*X = B .
3695 C N = ORDER OF MATRIX A.
3696 C NDIM = DECLARED DIMENSION OF ARRAY A .
3697 C A = TRIANGULARIZED MATRIX OBTAINED FROM DECH.
3698 C LB = LOWER BANDWIDTH OF A.
3699 C B = RIGHT HAND SIDE VECTOR.
3700 C IP = PIVOT VECTOR OBTAINED FROM DEC.
3701 C DO NOT USE IF DECH HAS SET IER .NE. 0.
3703 C B = SOLUTION VECTOR, X .
3704 C-----------------------------------------------------------------------
3705 IF (N
.EQ
. 1) GO TO 50
3715 10 B
(I
) = B
(I
) + A
(I
,K
)*T
3723 30 B
(I
) = B
(I
) + A
(I
,K
)*T
3725 50 B
(1) = B
(1)/A
(1,1)
3727 C----------------------- END OF SUBROUTINE SOLH ------------------------
3730 SUBROUTINE DECC
(N
, NDIM
, AR
, AI
, IP
, IER
)
3731 C VERSION COMPLEX KPP_REAL
3732 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
3733 INTEGER N
,NDIM
,IP
,IER
,NM1
,K
,KP1
,M
,I
,J
3734 DIMENSION AR
(NDIM
,N
), AI
(NDIM
,N
), IP
(N
)
3735 C-----------------------------------------------------------------------
3736 C MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION
3737 C ------ MODIFICATION FOR COMPLEX MATRICES --------
3739 C N = ORDER OF MATRIX.
3740 C NDIM = DECLARED DIMENSION OF ARRAYS AR AND AI .
3741 C (AR, AI) = MATRIX TO BE TRIANGULARIZED.
3743 C AR(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U ; REAL PART.
3744 C AI(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U ; IMAGINARY PART.
3745 C AR(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR FACTOR, I - L.
3747 C AI(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR FACTOR, I - L.
3749 C IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.
3750 C IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR O .
3751 C IER = 0 IF MATRIX A IS NONSINGULAR, OR K IF FOUND TO BE
3752 C SINGULAR AT STAGE K.
3753 C USE SOL TO OBTAIN SOLUTION OF LINEAR SYSTEM.
3754 C IF IP(N)=O, A IS SINGULAR, SOL WILL DIVIDE BY ZERO.
3757 C C. B. MOLER, ALGORITHM 423, LINEAR EQUATION KppSolveR,
3758 C C.A.C.M. 15 (1972), P. 274.
3759 C-----------------------------------------------------------------------
3762 IF (N
.EQ
. 1) GO TO 70
3768 IF (DABS
(AR
(I
,K
))+DABS
(AI
(I
,K
)) .GT
.
3769 & DABS
(AR
(M
,K
))+DABS
(AI
(M
,K
))) M
= I
3774 IF (M
.EQ
. K
) GO TO 20
3781 IF (DABS
(TR
)+DABS
(TI
) .EQ
. 0.D0
) GO TO 80
3786 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
3787 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
3798 IF (DABS
(TR
)+DABS
(TI
) .EQ
. 0.D0
) GO TO 48
3799 IF (TI
.EQ
. 0.D0
) THEN
3803 AR
(I
,J
) = AR
(I
,J
) + PRODR
3804 AI
(I
,J
) = AI
(I
,J
) + PRODI
3808 IF (TR
.EQ
. 0.D0
) THEN
3812 AR
(I
,J
) = AR
(I
,J
) + PRODR
3813 AI
(I
,J
) = AI
(I
,J
) + PRODI
3818 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
3819 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
3820 AR
(I
,J
) = AR
(I
,J
) + PRODR
3821 AI
(I
,J
) = AI
(I
,J
) + PRODI
3827 IF (DABS
(AR
(N
,N
))+DABS
(AI
(N
,N
)) .EQ
. 0.D0
) GO TO 80
3832 C----------------------- END OF SUBROUTINE DECC ------------------------
3836 SUBROUTINE SOLC
(N
, NDIM
, AR
, AI
, BR
, BI
, IP
)
3837 C VERSION COMPLEX KPP_REAL
3838 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
3839 INTEGER N
,NDIM
,IP
,NM1
,K
,KP1
,M
,I
,KB
,KM1
3840 DIMENSION AR
(NDIM
,N
), AI
(NDIM
,N
), BR
(N
), BI
(N
), IP
(N
)
3841 C-----------------------------------------------------------------------
3842 C SOLUTION OF LINEAR SYSTEM, A*X = B .
3844 C N = ORDER OF MATRIX.
3845 C NDIM = DECLARED DIMENSION OF ARRAYS AR AND AI.
3846 C (AR,AI) = TRIANGULARIZED MATRIX OBTAINED FROM DEC.
3847 C (BR,BI) = RIGHT HAND SIDE VECTOR.
3848 C IP = PIVOT VECTOR OBTAINED FROM DEC.
3849 C DO NOT USE IF DEC HAS SET IER .NE. 0.
3851 C (BR,BI) = SOLUTION VECTOR, X .
3852 C-----------------------------------------------------------------------
3853 IF (N
.EQ
. 1) GO TO 50
3865 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
3866 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
3867 BR
(I
) = BR
(I
) + PRODR
3868 BI
(I
) = BI
(I
) + PRODI
3874 DEN
=AR
(K
,K
)*AR
(K
,K
)+AI
(K
,K
)*AI
(K
,K
)
3875 PRODR
=BR
(K
)*AR
(K
,K
)+BI
(K
)*AI
(K
,K
)
3876 PRODI
=BI
(K
)*AR
(K
,K
)-BR
(K
)*AI
(K
,K
)
3882 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
3883 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
3884 BR
(I
) = BR
(I
) + PRODR
3885 BI
(I
) = BI
(I
) + PRODI
3889 DEN
=AR
(1,1)*AR
(1,1)+AI
(1,1)*AI
(1,1)
3890 PRODR
=BR
(1)*AR
(1,1)+BI
(1)*AI
(1,1)
3891 PRODI
=BI
(1)*AR
(1,1)-BR
(1)*AI
(1,1)
3895 C----------------------- END OF SUBROUTINE SOLC ------------------------
3899 SUBROUTINE DECHC
(N
, NDIM
, AR
, AI
, LB
, IP
, IER
)
3900 C VERSION COMPLEX KPP_REAL
3901 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
3902 INTEGER N
,NDIM
,IP
,IER
,NM1
,K
,KP1
,M
,I
,J
3903 DIMENSION AR
(NDIM
,N
), AI
(NDIM
,N
), IP
(N
)
3904 C-----------------------------------------------------------------------
3905 C MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION
3906 C ------ MODIFICATION FOR COMPLEX MATRICES --------
3908 C N = ORDER OF MATRIX.
3909 C NDIM = DECLARED DIMENSION OF ARRAYS AR AND AI .
3910 C (AR, AI) = MATRIX TO BE TRIANGULARIZED.
3912 C AR(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U ; REAL PART.
3913 C AI(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U ; IMAGINARY PART.
3914 C AR(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR FACTOR, I - L.
3916 C AI(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR FACTOR, I - L.
3918 C LB = LOWER BANDWIDTH OF A (DIAGONAL NOT COUNTED), LB.GE.1.
3919 C IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.
3920 C IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR O .
3921 C IER = 0 IF MATRIX A IS NONSINGULAR, OR K IF FOUND TO BE
3922 C SINGULAR AT STAGE K.
3923 C USE SOL TO OBTAIN SOLUTION OF LINEAR SYSTEM.
3924 C IF IP(N)=O, A IS SINGULAR, SOL WILL DIVIDE BY ZERO.
3927 C C. B. MOLER, ALGORITHM 423, LINEAR EQUATION KppSolveR,
3928 C C.A.C.M. 15 (1972), P. 274.
3929 C-----------------------------------------------------------------------
3932 IF (LB
.EQ
. 0) GO TO 70
3933 IF (N
.EQ
. 1) GO TO 70
3940 IF (DABS
(AR
(I
,K
))+DABS
(AI
(I
,K
)) .GT
.
3941 & DABS
(AR
(M
,K
))+DABS
(AI
(M
,K
))) M
= I
3946 IF (M
.EQ
. K
) GO TO 20
3953 IF (DABS
(TR
)+DABS
(TI
) .EQ
. 0.D0
) GO TO 80
3958 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
3959 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
3970 IF (DABS
(TR
)+DABS
(TI
) .EQ
. 0.D0
) GO TO 48
3971 IF (TI
.EQ
. 0.D0
) THEN
3975 AR
(I
,J
) = AR
(I
,J
) + PRODR
3976 AI
(I
,J
) = AI
(I
,J
) + PRODI
3980 IF (TR
.EQ
. 0.D0
) THEN
3984 AR
(I
,J
) = AR
(I
,J
) + PRODR
3985 AI
(I
,J
) = AI
(I
,J
) + PRODI
3990 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
3991 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
3992 AR
(I
,J
) = AR
(I
,J
) + PRODR
3993 AI
(I
,J
) = AI
(I
,J
) + PRODI
3999 IF (DABS
(AR
(N
,N
))+DABS
(AI
(N
,N
)) .EQ
. 0.D0
) GO TO 80
4004 C----------------------- END OF SUBROUTINE DECHC -----------------------
4008 SUBROUTINE SOLHC
(N
, NDIM
, AR
, AI
, LB
, BR
, BI
, IP
)
4009 C VERSION COMPLEX KPP_REAL
4010 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
4011 INTEGER N
,NDIM
,IP
,NM1
,K
,KP1
,M
,I
,KB
,KM1
4012 DIMENSION AR
(NDIM
,N
), AI
(NDIM
,N
), BR
(N
), BI
(N
), IP
(N
)
4013 C-----------------------------------------------------------------------
4014 C SOLUTION OF LINEAR SYSTEM, A*X = B .
4016 C N = ORDER OF MATRIX.
4017 C NDIM = DECLARED DIMENSION OF ARRAYS AR AND AI.
4018 C (AR,AI) = TRIANGULARIZED MATRIX OBTAINED FROM DEC.
4019 C (BR,BI) = RIGHT HAND SIDE VECTOR.
4020 C LB = LOWER BANDWIDTH OF A.
4021 C IP = PIVOT VECTOR OBTAINED FROM DEC.
4022 C DO NOT USE IF DEC HAS SET IER .NE. 0.
4024 C (BR,BI) = SOLUTION VECTOR, X .
4025 C-----------------------------------------------------------------------
4026 IF (N
.EQ
. 1) GO TO 50
4028 IF (LB
.EQ
. 0) GO TO 25
4038 DO 10 I
= KP1
,MIN0
(N
,LB
+K
)
4039 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
4040 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
4041 BR
(I
) = BR
(I
) + PRODR
4042 BI
(I
) = BI
(I
) + PRODI
4049 DEN
=AR
(K
,K
)*AR
(K
,K
)+AI
(K
,K
)*AI
(K
,K
)
4050 PRODR
=BR
(K
)*AR
(K
,K
)+BI
(K
)*AI
(K
,K
)
4051 PRODI
=BI
(K
)*AR
(K
,K
)-BR
(K
)*AI
(K
,K
)
4057 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
4058 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
4059 BR
(I
) = BR
(I
) + PRODR
4060 BI
(I
) = BI
(I
) + PRODI
4064 DEN
=AR
(1,1)*AR
(1,1)+AI
(1,1)*AI
(1,1)
4065 PRODR
=BR
(1)*AR
(1,1)+BI
(1)*AI
(1,1)
4066 PRODI
=BI
(1)*AR
(1,1)-BR
(1)*AI
(1,1)
4070 C----------------------- END OF SUBROUTINE SOLHC -----------------------
4073 SUBROUTINE DECB
(N
, NDIM
, A
, ML
, MU
, IP
, IER
)
4075 DIMENSION A
(NDIM
,N
), IP
(N
)
4076 C-----------------------------------------------------------------------
4077 C MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION OF A BANDED
4078 C MATRIX WITH LOWER BANDWIDTH ML AND UPPER BANDWIDTH MU
4080 C N ORDER OF THE ORIGINAL MATRIX A.
4081 C NDIM DECLARED DIMENSION OF ARRAY A.
4082 C A CONTAINS THE MATRIX IN BAND STORAGE. THE COLUMNS
4083 C OF THE MATRIX ARE STORED IN THE COLUMNS OF A AND
4084 C THE DIAGONALS OF THE MATRIX ARE STORED IN ROWS
4085 C ML+1 THROUGH 2*ML+MU+1 OF A.
4086 C ML LOWER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4087 C MU UPPER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4089 C A AN UPPER TRIANGULAR MATRIX IN BAND STORAGE AND
4090 C THE MULTIPLIERS WHICH WERE USED TO OBTAIN IT.
4091 C IP INDEX VECTOR OF PIVOT INDICES.
4092 C IP(N) (-1)**(NUMBER OF INTERCHANGES) OR O .
4093 C IER = 0 IF MATRIX A IS NONSINGULAR, OR = K IF FOUND TO BE
4094 C SINGULAR AT STAGE K.
4095 C USE SOLB TO OBTAIN SOLUTION OF LINEAR SYSTEM.
4096 C DETERM(A) = IP(N)*A(MD,1)*A(MD,2)*...*A(MD,N) WITH MD=ML+MU+1.
4097 C IF IP(N)=O, A IS SINGULAR, SOLB WILL DIVIDE BY ZERO.
4100 C THIS IS A MODIFICATION OF
4101 C C. B. MOLER, ALGORITHM 423, LINEAR EQUATION KppSolveR,
4102 C C.A.C.M. 15 (1972), P. 274.
4103 C-----------------------------------------------------------------------
4109 IF (ML
.EQ
. 0) GO TO 70
4110 IF (N
.EQ
. 1) GO TO 70
4111 IF (N
.LT
. MU
+2) GO TO 7
4119 MDL
= MIN
(ML
,N
-K
) + MD
4121 IF (DABS
(A
(I
,K
)) .GT
. DABS
(A
(M
,K
))) M
= I
4125 IF (M
.EQ
. MD
) GO TO 20
4130 IF (T
.EQ
. 0.D0
) GO TO 80
4133 30 A
(I
,K
) = -A
(I
,K
)*T
4134 JU
= MIN0
(MAX0
(JU
,MU
+IP
(K
)),N
)
4136 IF (JU
.LT
. KP1
) GO TO 55
4141 IF (M
.EQ
. MM
) GO TO 35
4145 IF (T
.EQ
. 0.D0
) GO TO 45
4149 40 A
(IJK
,J
) = A
(IJK
,J
) + A
(I
,K
)*T
4155 IF (A
(MD
,N
) .EQ
. 0.D0
) GO TO 80
4160 C----------------------- END OF SUBROUTINE DECB ------------------------
4164 SUBROUTINE SOLB
(N
, NDIM
, A
, ML
, MU
, B
, IP
)
4166 DIMENSION A
(NDIM
,N
), B
(N
), IP
(N
)
4167 C-----------------------------------------------------------------------
4168 C SOLUTION OF LINEAR SYSTEM, A*X = B .
4170 C N ORDER OF MATRIX A.
4171 C NDIM DECLARED DIMENSION OF ARRAY A .
4172 C A TRIANGULARIZED MATRIX OBTAINED FROM DECB.
4173 C ML LOWER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4174 C MU UPPER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4175 C B RIGHT HAND SIDE VECTOR.
4176 C IP PIVOT VECTOR OBTAINED FROM DECB.
4177 C DO NOT USE IF DECB HAS SET IER .NE. 0.
4179 C B SOLUTION VECTOR, X .
4180 C-----------------------------------------------------------------------
4185 IF (ML
.EQ
. 0) GO TO 25
4186 IF (N
.EQ
. 1) GO TO 50
4192 MDL
= MIN
(ML
,N
-K
) + MD
4195 10 B
(IMD
) = B
(IMD
) + A
(I
,K
)*T
4206 30 B
(IMD
) = B
(IMD
) + A
(I
,K
)*T
4208 50 B
(1) = B
(1)/A
(MD
,1)
4210 C----------------------- END OF SUBROUTINE SOLB ------------------------
4213 SUBROUTINE DECBC
(N
, NDIM
, AR
, AI
, ML
, MU
, IP
, IER
)
4214 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
4215 DIMENSION AR
(NDIM
,N
), AI
(NDIM
,N
), IP
(N
)
4216 C-----------------------------------------------------------------------
4217 C MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION OF A BANDED COMPLEX
4218 C MATRIX WITH LOWER BANDWIDTH ML AND UPPER BANDWIDTH MU
4220 C N ORDER OF THE ORIGINAL MATRIX A.
4221 C NDIM DECLARED DIMENSION OF ARRAY A.
4222 C AR, AI CONTAINS THE MATRIX IN BAND STORAGE. THE COLUMNS
4223 C OF THE MATRIX ARE STORED IN THE COLUMNS OF AR (REAL
4224 C PART) AND AI (IMAGINARY PART) AND
4225 C THE DIAGONALS OF THE MATRIX ARE STORED IN ROWS
4226 C ML+1 THROUGH 2*ML+MU+1 OF AR AND AI.
4227 C ML LOWER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4228 C MU UPPER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4230 C AR, AI AN UPPER TRIANGULAR MATRIX IN BAND STORAGE AND
4231 C THE MULTIPLIERS WHICH WERE USED TO OBTAIN IT.
4232 C IP INDEX VECTOR OF PIVOT INDICES.
4233 C IP(N) (-1)**(NUMBER OF INTERCHANGES) OR O .
4234 C IER = 0 IF MATRIX A IS NONSINGULAR, OR = K IF FOUND TO BE
4235 C SINGULAR AT STAGE K.
4236 C USE SOLBC TO OBTAIN SOLUTION OF LINEAR SYSTEM.
4237 C DETERM(A) = IP(N)*A(MD,1)*A(MD,2)*...*A(MD,N) WITH MD=ML+MU+1.
4238 C IF IP(N)=O, A IS SINGULAR, SOLBC WILL DIVIDE BY ZERO.
4241 C THIS IS A MODIFICATION OF
4242 C C. B. MOLER, ALGORITHM 423, LINEAR EQUATION KppSolveR,
4243 C C.A.C.M. 15 (1972), P. 274.
4244 C-----------------------------------------------------------------------
4250 IF (ML
.EQ
. 0) GO TO 70
4251 IF (N
.EQ
. 1) GO TO 70
4252 IF (N
.LT
. MU
+2) GO TO 7
4262 MDL
= MIN
(ML
,N
-K
) + MD
4264 IF (DABS
(AR
(I
,K
))+DABS
(AI
(I
,K
)) .GT
.
4265 & DABS
(AR
(M
,K
))+DABS
(AI
(M
,K
))) M
= I
4270 IF (M
.EQ
. MD
) GO TO 20
4276 20 IF (DABS
(TR
)+DABS
(TI
) .EQ
. 0.D0
) GO TO 80
4281 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
4282 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
4286 JU
= MIN0
(MAX0
(JU
,MU
+IP
(K
)),N
)
4288 IF (JU
.LT
. KP1
) GO TO 55
4294 IF (M
.EQ
. MM
) GO TO 35
4300 IF (DABS
(TR
)+DABS
(TI
) .EQ
. 0.D0
) GO TO 48
4302 IF (TI
.EQ
. 0.D0
) THEN
4307 AR
(IJK
,J
) = AR
(IJK
,J
) + PRODR
4308 AI
(IJK
,J
) = AI
(IJK
,J
) + PRODI
4312 IF (TR
.EQ
. 0.D0
) THEN
4317 AR
(IJK
,J
) = AR
(IJK
,J
) + PRODR
4318 AI
(IJK
,J
) = AI
(IJK
,J
) + PRODI
4324 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
4325 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
4326 AR
(IJK
,J
) = AR
(IJK
,J
) + PRODR
4327 AI
(IJK
,J
) = AI
(IJK
,J
) + PRODI
4334 IF (DABS
(AR
(MD
,N
))+DABS
(AI
(MD
,N
)) .EQ
. 0.D0
) GO TO 80
4339 C----------------------- END OF SUBROUTINE DECBC ------------------------
4343 SUBROUTINE SOLBC
(N
, NDIM
, AR
, AI
, ML
, MU
, BR
, BI
, IP
)
4344 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
4345 DIMENSION AR
(NDIM
,N
), AI
(NDIM
,N
), BR
(N
), BI
(N
), IP
(N
)
4346 C-----------------------------------------------------------------------
4347 C SOLUTION OF LINEAR SYSTEM, A*X = B ,
4348 C VERSION BANDED AND COMPLEX-KPP_REAL.
4350 C N ORDER OF MATRIX A.
4351 C NDIM DECLARED DIMENSION OF ARRAY A .
4352 C AR, AI TRIANGULARIZED MATRIX OBTAINED FROM DECB (REAL AND IMAG. PART).
4353 C ML LOWER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4354 C MU UPPER BANDWIDTH OF A (DIAGONAL IS NOT COUNTED).
4355 C BR, BI RIGHT HAND SIDE VECTOR (REAL AND IMAG. PART).
4356 C IP PIVOT VECTOR OBTAINED FROM DECBC.
4357 C DO NOT USE IF DECB HAS SET IER .NE. 0.
4359 C BR, BI SOLUTION VECTOR, X (REAL AND IMAG. PART).
4360 C-----------------------------------------------------------------------
4365 IF (ML
.EQ
. 0) GO TO 25
4366 IF (N
.EQ
. 1) GO TO 50
4375 MDL
= MIN
(ML
,N
-K
) + MD
4378 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
4379 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
4380 BR
(IMD
) = BR
(IMD
) + PRODR
4381 BI
(IMD
) = BI
(IMD
) + PRODI
4387 DEN
=AR
(MD
,K
)*AR
(MD
,K
)+AI
(MD
,K
)*AI
(MD
,K
)
4388 PRODR
=BR
(K
)*AR
(MD
,K
)+BI
(K
)*AI
(MD
,K
)
4389 PRODI
=BI
(K
)*AR
(MD
,K
)-BR
(K
)*AI
(MD
,K
)
4398 PRODR
=AR
(I
,K
)*TR
-AI
(I
,K
)*TI
4399 PRODI
=AI
(I
,K
)*TR
+AR
(I
,K
)*TI
4400 BR
(IMD
) = BR
(IMD
) + PRODR
4401 BI
(IMD
) = BI
(IMD
) + PRODI
4404 DEN
=AR
(MD
,1)*AR
(MD
,1)+AI
(MD
,1)*AI
(MD
,1)
4405 PRODR
=BR
(1)*AR
(MD
,1)+BI
(1)*AI
(MD
,1)
4406 PRODI
=BI
(1)*AR
(MD
,1)-BR
(1)*AI
(MD
,1)
4411 C----------------------- END OF SUBROUTINE SOLBC ------------------------
4415 subroutine Elmhes
(nm
,n
,low
,igh
,a
,int
)
4417 integer i
,j
,m
,n
,la
,nm
,igh
,kp1
,low
,mm1
,mp1
4423 C this subroutine is a translation of the algol procedure elmhes,
4424 C num. math. 12, 349-368(1968) by martin and wilkinson.
4425 C handbook for auto. comp., vol.ii-linear algebra, 339-358(1971).
4427 C given a real general matrix, this subroutine
4428 C reduces a submatrix situated in rows and columns
4429 C low through igh to upper hessenberg form by
4430 C stabilized elementary similarity transformations.
4434 C nm must be set to the row dimension of two-dimensional
4435 C array parameters as declared in the calling program
4436 C dimension statement;
4438 C n is the order of the matrix;
4440 C low and igh are integers determined by the balancing
4441 C subroutine balanc. if balanc has not been used,
4444 C a contains the input matrix.
4448 C a contains the hessenberg matrix. the multipliers
4449 C which were used in the reduction are stored in the
4450 C remaining triangle under the hessenberg matrix;
4452 C int contains information on the rows and columns
4453 C interchanged in the reduction.
4454 C only elements low through igh are used.
4456 C questions and comments should be directed to b. s. garbow,
4457 C applied mathematics division, argonne national laboratory
4459 C ------------------------------------------------------------------
4463 if (la
.lt
. kp1
) go to 200
4471 if (dabs
(a
(j
,mm1
)) .le
. dabs
(x
)) go to 100
4477 if (i
.eq
. m
) go to 130
4478 C :::::::::: interchange rows and columns of a ::::::::::
4490 C :::::::::: end interchange ::::::::::
4491 130 if (x
.eq
. 0.0d0
) go to 180
4496 if (y
.eq
. 0.0d0
) go to 160
4501 140 a
(i
,j
) = a
(i
,j
) - y
* a
(m
,j
)
4504 150 a
(j
,m
) = a
(j
,m
) + y
* a
(j
,i
)
4511 C :::::::::: last card of elmhes ::::::::::
4514 SUBROUTINE SOLOUT
(NR
,XOLD
,X
,Y
,CONT
,LRC
,N
,RPAR
,IPAR
,IRTRN
)
4515 C --- PRINTS SOLUTION AT EQUIDISTANT OUTPUT-POINTS BY USING "CONTR5"
4516 IMPLICIT KPP_REAL
(A
-H
,O
-Z
)
4517 DIMENSION Y
(N
),CONT
(LRC
)
4520 WRITE (6,99) X
,Y
(1),Y
(2),NR
-1
4525 C --- CONTINUOUS OUTPUT FOR RADAU5
4526 WRITE (6,99) XOUT
,CONTR5
(1,XOUT
,CONT
,LRC
),
4527 & CONTR5
(2,XOUT
,CONT
,LRC
),NR
-1
4532 99 FORMAT(1X
,'X =',F5
.2
,' Y =',2E18
.10
,' NSTEP =',I4
)
4536 SUBROUTINE FUNC_CHEM
(N
, T
, V
, FCT
, RPAR
, IPAR
)
4538 INCLUDE
'KPP_ROOT_Parameters.h'
4539 INCLUDE
'KPP_ROOT_Global.h'
4540 KPP_REAL V
(NVAR
), FCT
(NVAR
)
4541 KPP_REAL T
, TOLD
, RPAR
(1)
4546 CALL Update_RCONST
()
4548 CALL Fun
(V
, FIX
, RCONST
, FCT
)
4552 SUBROUTINE JAC_CHEM
(N
, T
, V
, JV
, NROWPD
, RPAR
, IPAR
)
4554 INCLUDE
'KPP_ROOT_Parameters.h'
4555 INCLUDE
'KPP_ROOT_Global.h'
4556 KPP_REAL V
(NVAR
), JV
(NVAR
,NVAR
)
4557 KPP_REAL T
, TOLD
, RPAR
(1)
4558 INTEGER N
, IPAR
(1), NROWPD
, i
, j
4562 CALL Update_RCONST
()
4569 CALL Jac
(V
, FIX
, RCONST
, JV
)