1 SUBROUTINE FODEDS
(S
,Y
,YP
,YPOLD
,A
,QR
,LENQR
,PIVOT
,PP
,WORK
,
2 $ NFE
,N
,IFLAG
,PAR
,IPAR
)
4 C SUBROUTINE FODEDS IS USED BY SUBROUTINE STEPDS TO SPECIFY THE
5 C ORDINARY DIFFERENTIAL EQUATION DY/DS = G(S,Y) , WHOSE SOLUTION
6 C IS THE ZERO CURVE OF THE HOMOTOPY MAP. S = ARC LENGTH,
7 C YP = DY/DS, AND Y(S) = (X(S), LAMBDA(S)) .
9 C PAR(1:*) AND IPAR(1:*) ARE ARRAYS FOR (OPTIONAL) USER PARAMETERS,
10 C WHICH ARE SIMPLY PASSED THROUGH TO THE USER WRITTEN SUBROUTINES
13 DOUBLE PRECISION DDOT
,DNRM2
,LAMBDA
,S
,TEMP
,YPNORM
14 INTEGER IFLAG
,J
,LENQR
,N
,NFE
,NP1
16 C ***** ARRAY DECLARATIONS. *****
18 DOUBLE PRECISION Y
(N
+1),YP
(N
+1),YPOLD
(N
+1),A
(N
),PAR
(1)
21 C ARRAYS FOR COMPUTING THE JACOBIAN MATRIX AND ITS KERNEL.
22 DOUBLE PRECISION QR
(LENQR
),PP
(N
),WORK
(6*(N
+1)+LENQR
)
25 C ***** END OF DIMENSIONAL INFORMATION. *****
30 C NFE CONTAINS THE NUMBER OF JACOBIAN EVALUATIONS.
32 C * * * * * * * * * * * * * * * * *
34 C COMPUTE THE JACOBIAN MATRIX, STORE IT IN [QR | -PP] .
36 IF (IFLAG
.EQ
. -2) THEN
38 C [QR | -PP] = [ D RHO(A,X,LAMBDA)/DX | D RHO(A,X,LAMBDA)/D LAMBDA ] .
40 CALL RHOJS
(A
,LAMBDA
,Y
,QR
,LENQR
,PIVOT
,PP
,PAR
,IPAR
)
41 C PP = - (D RHO(A,X,LAMBDA)/D LAMBDA) .
45 IF (IFLAG
.EQ
. 0) THEN
47 C [QR | -PP] = [ I - LAMBDA*DF(X) | A - F(X) ] .
49 CALL DAXPY
(N
,-1.0D0
,A
,1,PP
,1)
50 CALL FJACS
(Y
,QR
,LENQR
,PIVOT
)
51 CALL DSCAL
(LENQR
,-LAMBDA
,QR
,1)
53 QR
(PIVOT
(J
))=QR
(PIVOT
(J
)) + 1.0
57 C [QR | -PP] = [ LAMBDA*DF(X) + (1 - LAMBDA)*I | F(X) - X + A ] .
59 CALL DSCAL
(N
,-1.0D0
,PP
,1)
60 CALL DAXPY
(N
,1.0D0
,Y
,1,PP
,1)
61 CALL DAXPY
(N
,-1.0D0
,A
,1,PP
,1)
62 CALL FJACS
(Y
,QR
,LENQR
,PIVOT
)
63 CALL DSCAL
(LENQR
,LAMBDA
,QR
,1)
66 QR
(PIVOT
(J
))=QR
(PIVOT
(J
)) + TEMP
71 C * * * * * * * * * * * * * * * * *
72 CALL DCOPY
(NP1
,YPOLD
,1,YP
,1)
73 C COMPUTE KERNEL OF JACOBIAN, WHICH SPECIFIES YP=DY/DS, USING A
74 C PRECONDITIONED CONJUGATE GRADIENT ALGORITHM.
75 CALL PCGDS
(N
,QR
,LENQR
,PIVOT
,PP
,YP
,WORK
,IFLAG
)
76 IF (IFLAG
.GT
. 0) RETURN
78 C NORMALIZE TANGENT VECTOR YP.
79 YPNORM
=DNRM2
(NP1
,YP
,1)
80 CALL DSCAL
(NP1
,1.0/YPNORM
,YP
,1)
82 C CHOOSE UNIT TANGENT VECTOR DIRECTION TO MAINTAIN CONTINUITY.
83 IF (DDOT
(NP1
,YP
,1,YPOLD
,1) .LT
. 0.0)
84 $
CALL DSCAL
(NP1
,-1.0D0
,YP
,1)
86 C SAVE CURRENT DERIVATIVE (= TANGENT VECTOR) IN YPOLD .
87 CALL DCOPY
(NP1
,YP
,1,YPOLD
,1)