dmatd.f

Go to the documentation of this file.
00001 C Work performed under the auspices of the U.S. Department of Energy
00002 C by Lawrence Livermore National Laboratory under contract number 
00003 C W-7405-Eng-48.
00004 C
00005       SUBROUTINE DMATD(NEQ,X,Y,YPRIME,DELTA,CJ,H,IER,EWT,E,
00006      *                 WM,IWM,RES,IRES,UROUND,JACD,RPAR,IPAR)
00007 C
00008 C***BEGIN PROLOGUE  DMATD
00009 C***REFER TO  DDASPK
00010 C***DATE WRITTEN   890101   (YYMMDD)
00011 C***REVISION DATE  900926   (YYMMDD)
00012 C***REVISION DATE  940701   (YYMMDD) (new LIPVT)
00013 C
00014 C-----------------------------------------------------------------------
00015 C***DESCRIPTION
00016 C
00017 C     This routine computes the iteration matrix
00018 C     J = dG/dY+CJ*dG/dYPRIME (where G(X,Y,YPRIME)=0).
00019 C     Here J is computed by:
00020 C       the user-supplied routine JACD if IWM(MTYPE) is 1 or 4, or
00021 C       by numerical difference quotients if IWM(MTYPE) is 2 or 5.
00022 C
00023 C     The parameters have the following meanings.
00024 C     X        = Independent variable.
00025 C     Y        = Array containing predicted values.
00026 C     YPRIME   = Array containing predicted derivatives.
00027 C     DELTA    = Residual evaluated at (X,Y,YPRIME).
00028 C                (Used only if IWM(MTYPE)=2 or 5).
00029 C     CJ       = Scalar parameter defining iteration matrix.
00030 C     H        = Current stepsize in integration.
00031 C     IER      = Variable which is .NE. 0 if iteration matrix
00032 C                is singular, and 0 otherwise.
00033 C     EWT      = Vector of error weights for computing norms.
00034 C     E        = Work space (temporary) of length NEQ.
00035 C     WM       = Real work space for matrices.  On output
00036 C                it contains the LU decomposition
00037 C                of the iteration matrix.
00038 C     IWM      = Integer work space containing
00039 C                matrix information.
00040 C     RES      = External user-supplied subroutine
00041 C                to evaluate the residual.  See RES description
00042 C                in DDASPK prologue.
00043 C     IRES     = Flag which is equal to zero if no illegal values
00044 C                in RES, and less than zero otherwise.  (If IRES
00045 C                is less than zero, the matrix was not completed).
00046 C                In this case (if IRES .LT. 0), then IER = 0.
00047 C     UROUND   = The unit roundoff error of the machine being used.
00048 C     JACD     = Name of the external user-supplied routine
00049 C                to evaluate the iteration matrix.  (This routine
00050 C                is only used if IWM(MTYPE) is 1 or 4)
00051 C                See JAC description for the case INFO(12) = 0
00052 C                in DDASPK prologue.
00053 C     RPAR,IPAR= Real and integer parameter arrays that
00054 C                are used for communication between the
00055 C                calling program and external user routines.
00056 C                They are not altered by DMATD.
00057 C-----------------------------------------------------------------------
00058 C***ROUTINES CALLED
00059 C   JACD, RES, DGETRF, DGBTRF
00060 C
00061 C***END PROLOGUE  DMATD
00062 C
00063 C
00064       IMPLICIT DOUBLE PRECISION(A-H,O-Z)
00065       DIMENSION Y(*),YPRIME(*),DELTA(*),EWT(*),E(*)
00066       DIMENSION WM(*),IWM(*), RPAR(*),IPAR(*)
00067       EXTERNAL  RES, JACD
00068 C
00069       PARAMETER (LML=1, LMU=2, LMTYPE=4, LNRE=12, LNPD=22, LLCIWP=30)
00070 C
00071       LIPVT = IWM(LLCIWP)
00072       IER = 0
00073       MTYPE=IWM(LMTYPE)
00074       GO TO (100,200,300,400,500),MTYPE
00075 C
00076 C
00077 C     Dense user-supplied matrix.
00078 C
00079 100   LENPD=IWM(LNPD)
00080       DO 110 I=1,LENPD
00081 110      WM(I)=0.0D0
00082       CALL JACD(X,Y,YPRIME,WM,CJ,RPAR,IPAR)
00083       GO TO 230
00084 C
00085 C
00086 C     Dense finite-difference-generated matrix.
00087 C
00088 200   IRES=0
00089       NROW=0
00090       SQUR = SQRT(UROUND)
00091       DO 210 I=1,NEQ
00092          DEL=SQUR*MAX(ABS(Y(I)),ABS(H*YPRIME(I)),
00093      *     ABS(1.D0/EWT(I)))
00094          DEL=SIGN(DEL,H*YPRIME(I))
00095          DEL=(Y(I)+DEL)-Y(I)
00096          YSAVE=Y(I)
00097          YPSAVE=YPRIME(I)
00098          Y(I)=Y(I)+DEL
00099          YPRIME(I)=YPRIME(I)+CJ*DEL
00100          IWM(LNRE)=IWM(LNRE)+1
00101          CALL RES(X,Y,YPRIME,CJ,E,IRES,RPAR,IPAR)
00102          IF (IRES .LT. 0) RETURN
00103          DELINV=1.0D0/DEL
00104          DO 220 L=1,NEQ
00105 220        WM(NROW+L)=(E(L)-DELTA(L))*DELINV
00106       NROW=NROW+NEQ
00107       Y(I)=YSAVE
00108       YPRIME(I)=YPSAVE
00109 210   CONTINUE
00110 C
00111 C
00112 C     Do dense-matrix LU decomposition on J.
00113 C
00114 230      CALL DGETRF( NEQ, NEQ, WM, NEQ, IWM(LIPVT), IER)
00115       RETURN
00116 C
00117 C
00118 C     Dummy section for IWM(MTYPE)=3.
00119 C
00120 300   RETURN
00121 C
00122 C
00123 C     Banded user-supplied matrix.
00124 C
00125 400   LENPD=IWM(LNPD)
00126       DO 410 I=1,LENPD
00127 410      WM(I)=0.0D0
00128       CALL JACD(X,Y,YPRIME,WM,CJ,RPAR,IPAR)
00129       MEBAND=2*IWM(LML)+IWM(LMU)+1
00130       GO TO 550
00131 C
00132 C
00133 C     Banded finite-difference-generated matrix.
00134 C
00135 500   MBAND=IWM(LML)+IWM(LMU)+1
00136       MBA=MIN0(MBAND,NEQ)
00137       MEBAND=MBAND+IWM(LML)
00138       MEB1=MEBAND-1
00139       MSAVE=(NEQ/MBAND)+1
00140       ISAVE=IWM(LNPD)
00141       IPSAVE=ISAVE+MSAVE
00142       IRES=0
00143       SQUR=SQRT(UROUND)
00144       DO 540 J=1,MBA
00145         DO 510 N=J,NEQ,MBAND
00146           K= (N-J)/MBAND + 1
00147           WM(ISAVE+K)=Y(N)
00148           WM(IPSAVE+K)=YPRIME(N)
00149           DEL=SQUR*MAX(ABS(Y(N)),ABS(H*YPRIME(N)),
00150      *      ABS(1.D0/EWT(N)))
00151           DEL=SIGN(DEL,H*YPRIME(N))
00152           DEL=(Y(N)+DEL)-Y(N)
00153           Y(N)=Y(N)+DEL
00154 510       YPRIME(N)=YPRIME(N)+CJ*DEL
00155         IWM(LNRE)=IWM(LNRE)+1
00156         CALL RES(X,Y,YPRIME,CJ,E,IRES,RPAR,IPAR)
00157         IF (IRES .LT. 0) RETURN
00158         DO 530 N=J,NEQ,MBAND
00159           K= (N-J)/MBAND + 1
00160           Y(N)=WM(ISAVE+K)
00161           YPRIME(N)=WM(IPSAVE+K)
00162           DEL=SQUR*MAX(ABS(Y(N)),ABS(H*YPRIME(N)),
00163      *      ABS(1.D0/EWT(N)))
00164           DEL=SIGN(DEL,H*YPRIME(N))
00165           DEL=(Y(N)+DEL)-Y(N)
00166           DELINV=1.0D0/DEL
00167           I1=MAX0(1,(N-IWM(LMU)))
00168           I2=MIN0(NEQ,(N+IWM(LML)))
00169           II=N*MEB1-IWM(LML)
00170           DO 520 I=I1,I2
00171 520         WM(II+I)=(E(I)-DELTA(I))*DELINV
00172 530     CONTINUE
00173 540   CONTINUE
00174 C
00175 C
00176 C     Do LU decomposition of banded J.
00177 C
00178 550   CALL DGBTRF(NEQ, NEQ, IWM(LML), IWM(LMU), WM, MEBAND,
00179      *     IWM(LIPVT), IER)
00180       RETURN
00181 C
00182 C------END OF SUBROUTINE DMATD------------------------------------------
00183       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines