CFPRIME DUDB26                                                          DUDB26      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE DUDB26(LORD)                                           DUDB26      3
CD                                                                      DUDB26      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF USER DEFINED BLOCK  DUDB26      5
CD    TYPE 26 (A/D BLOCK) IN ANY USER DEFINED MODEL, USED BY BOTH       DUDB26      6
CD    RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                               DUDB26      7
CD                                                                      DUDB26      8
      INCLUDE 'PARX.INS'                                                DUDB26      9
      INCLUDE 'CNMDAT.INS'                                              DUDB26     10
      INCLUDE 'CNMSTA.INS'                                              DUDB26     11
      INCLUDE 'CNXSTA.INS'                                              DUDB26     12
      INCLUDE 'CNSTN.INS'                                               DUDB26     13
      INCLUDE 'CNYVAR.INS'                                              DUDB26     14
      INCLUDE 'CNUNIT.INS'                                              DUDB26     15
      INCLUDE 'CNFLAG.INS'                                              DUDB26     16
      INCLUDE 'CNUDM.INS'                                               DUDB26     17
C                                                                       DUDB26     18
      DIMENSION XX(11)                                                  DUDB26     19
C                                                                       DUDB26     20
      LDEB=(JDEB(264).NE.0)                                             DUDB26     21
C                                                                       DUDB26     22
      VALI=0.0                                                          DUDB26     23
      IORD=IDDAT(JE4+LORD)                                              DUDB26     24
      JEI=JEB+2                                                         DUDB26     25
      NX=IDDAT(JEI+1)                                                   DUDB26     26
      DO 100 I=1,NX                                                     DUDB26     27
      XX(I)=DDAT(JEI+I+1)                                               DUDB26     28
  100 CONTINUE                                                          DUDB26     29
C                                                                       DUDB26     30
      KINT=KINPU                                                        DUDB26     31
      KINPU=KINPU+IDDAT(JEI+13)                                         DUDB26     32
      IF(KINT.LT.KINPU) THEN                                            DUDB26     33
         DO 110 J=KINT+1,KINPU                                          DUDB26     34
         XDAT=GAINS(J)                                                  DUDB26     35
         IOUT=INPUTS(J)                                                 DUDB26     36
         VALI=VALI+VALOUT(IOUT)*XDAT                                    DUDB26     37
  110    CONTINUE                                                       DUDB26     38
      ENDIF                                                             DUDB26     39
      KINP=KINPU                                                        DUDB26     40
      KINPU=KINPU+IDDAT(JEI+14)                                         DUDB26     41
      IF(KINP.LT.KINPU) THEN                                            DUDB26     42
         DO 120 J=KINP+1,KINPU                                          DUDB26     43
         XDAT=GAINS(J)                                                  DUDB26     44
         IIN=INPUTS(J)                                                  DUDB26     45
         VALI=VALI+VALIN(IIN)*XDAT                                      DUDB26     46
  120    CONTINUE                                                       DUDB26     47
      ENDIF                                                             DUDB26     48
C                                                                       DUDB26     49
      DO 130 I=2,NX                                                     DUDB26     50
      IF(VALI.LT.XX(I))THEN                                             DUDB26     51
         VALO=XX(I-1)                                                   DUDB26     52
         GO TO 140                                                      DUDB26     53
      ENDIF                                                             DUDB26     54
  130 CONTINUE                                                          DUDB26     55
      VALO=XX(NX)                                                       DUDB26     56
  140 VALOUT(IORD)=VALO                                                 DUDB26     57
      IF(LDEB) WRITE(IUD6,1000) LORD,IORD,VALOUT(IORD)                  DUDB26     58
C                                                                       DUDB26     59
      RETURN                                                            DUDB26     60
 1000 FORMAT(1X,'LORD,IORD,VALOUT(IORD): ',2I5,F10.3)                   DUDB26     61
      END                                                               DUDB26     62
