CFPRIME AUDB23                                                          AUDB23      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 AUDB23(LORD)                                           AUDB23      3
CD                                                                      AUDB23      4
CD    TO FORMULATE THE ELEMENTARY LINEARIZED EQUATIONS OF USER DEFINED  AUDB23      5
CD    BLOCK TYPE 23 (NONLINEAR FUNCTION BLOCK) IN ANY USER DEFINED MODELAUDB23      6
CD    FOR USE IN CONSTRUCTING THE JACOBIAN MATRICES.                    AUDB23      7
CD                                                                      AUDB23      8
C                                                                       AUDB23      9
C     BLOCK 23 EQUATIONS                                                AUDB23     10
C                                                                       AUDB23     11
      INCLUDE 'PARX.INS'                                                AUDB23     12
      INCLUDE 'CNUNIT.INS'                                              AUDB23     13
      INCLUDE 'CNFLAG.INS'                                              AUDB23     14
      INCLUDE 'CNUDM.INS'                                               AUDB23     15
      INCLUDE 'CNUDMA.INS'                                              AUDB23     16
      INCLUDE 'CNMDAT.INS'                                              AUDB23     17
      INCLUDE 'CNMSTA.INS'                                              AUDB23     18
      INCLUDE 'CNXSTA.INS'                                              AUDB23     19
      INCLUDE 'CNSTN.INS'                                               AUDB23     20
      INCLUDE 'CNYVAR.INS'                                              AUDB23     21
C                                                                       AUDB23     22
      DIMENSION XX(6),YY(6)                                             AUDB23     23
C                                                                       AUDB23     24
      LDEB=(JDEB(264).NE.0)                                             AUDB23     25
C                                                                       AUDB23     26
      VALI=0.0                                                          AUDB23     27
      IUB=IUB+1                                                         AUDB23     28
      IORD=IUDAT(JE4+LORD)                                              AUDB23     29
      JEI=JEB+2                                                         AUDB23     30
      IF (IUDAT(JEI+12).EQ.-10000) THEN                                 AUDB23     31
        NN=IUDAT(JEI+11)                                                AUDB23     32
      ELSE                                                              AUDB23     33
        NN=6                                                            AUDB23     34
      END IF                                                            AUDB23     35
      DO 100 I=1,NN                                                     AUDB23     36
         XX(I)=UDAT(JEI+2*I-1)                                          AUDB23     37
         YY(I)=UDAT(JEI+2*I)                                            AUDB23     38
  100 CONTINUE                                                          AUDB23     39
C                                                                       AUDB23     40
      KINT=KINPU                                                        AUDB23     41
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB23     42
      IF(KINT.LT.KINPU) THEN                                            AUDB23     43
         DO 110 J=KINT+1,KINPU                                          AUDB23     44
         XDAT=GAINS(J)                                                  AUDB23     45
         IOUT=INPUTS(J)                                                 AUDB23     46
         VALI=VALI+VALOUT(IOUT)*XDAT                                    AUDB23     47
         CYB(IUB,IOUT)=CYB(IUB,IOUT)+XDAT                               AUDB23     48
  110    CONTINUE                                                       AUDB23     49
      ENDIF                                                             AUDB23     50
      KINP=KINPU                                                        AUDB23     51
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB23     52
      IF(KINP.LT.KINPU) THEN                                            AUDB23     53
         DO 120 J=KINP+1,KINPU                                          AUDB23     54
         XDAT=GAINS(J)                                                  AUDB23     55
         IIN=INPUTS(J)                                                  AUDB23     56
         VALI=VALI+VALIN(IIN)*XDAT                                      AUDB23     57
         IF(IIN.LE.20) THEN                                             AUDB23     58
            DU0(IUB,IIN)=DU0(IUB,IIN)+XDAT                              AUDB23     59
         ELSE                                                           AUDB23     60
            DUR0(IUB,IIN-20)=DUR0(IUB,IIN-20)+XDAT                      AUDB23     61
         ENDIF                                                          AUDB23     62
  120    CONTINUE                                                       AUDB23     63
      ENDIF                                                             AUDB23     64
C                                                                       AUDB23     65
      DO 130 I=2,NN                                                     AUDB23     66
         IF (VALI.LE.XX(I).OR.I.EQ.NN) THEN                             AUDB23     67
            SLOPE=(YY(I)-YY(I-1))/(XX(I)-XX(I-1))                       AUDB23     68
         END IF                                                         AUDB23     69
  130 CONTINUE                                                          AUDB23     70
      DUB(IORD,IUB)=SLOPE                                               AUDB23     71
      IF(LDEB) WRITE(IUD6,1000) LORD,IORD                               AUDB23     72
C                                                                       AUDB23     73
      RETURN                                                            AUDB23     74
 1000 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB23     75
      END                                                               AUDB23     76
