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