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