CFPRIME AUDB44                                                          AUDB44      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 AUDB44(LORD)                                           AUDB44      3
CD                                                                      AUDB44      4
CD    TO FORMULATE THE ELEMENTARY LINEARIZED EQUATIONS OF USER DEFINED  AUDB44      5
CD    BLOCK TYPES 44 (TYPE T1 GOVERNOR END BLOCK) IN A USER DEFINED     AUDB44      6
CD    GOVERNOR MODEL FOR USE IN CONSTRUCTING THE JACOBIAN MATRICES.     AUDB44      7
CD                                                                      AUDB44      8
CD    EACH ENTRY POINT IN THIS SUBROUTINE HAS SIMILAR FUNCTION AND IS   AUDB44      9
CD    FOR A DIFFERENT TYPE OF GOVERNOR END BLOCK APPLICABLE TO A USER   AUDB44     10
CD    DEFINED GOVERNOR MODEL.                                           AUDB44     11
CD                                                                      AUDB44     12
      INCLUDE 'PARX.INS'                                                AUDB44     13
      INCLUDE 'CNGDAT.INS'                                              AUDB44     14
      INCLUDE 'CNB19.INS'                                               AUDB44     15
      INCLUDE 'CNUNIT.INS'                                              AUDB44     16
      INCLUDE 'CNFLAG.INS'                                              AUDB44     17
      INCLUDE 'CNUDM.INS'                                               AUDB44     18
      INCLUDE 'CNUDMA.INS'                                              AUDB44     19
C                                                                       AUDB44     20
      LDEB=(JDEB(264).NE.0)                                             AUDB44     21
C                                                                       AUDB44     22
      IUB=IUB+1                                                         AUDB44     23
      IORD=IUDAT(JE4+LORD)                                              AUDB44     24
      JEI=JEB+2                                                         AUDB44     25
      II=0                                                              AUDB44     26
      KINT=KINPU                                                        AUDB44     27
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB44     28
      IF(KINT.LT.KINPU) THEN                                            AUDB44     29
         DO 110 J=KINT+1,KINPU                                          AUDB44     30
         XDAT=GAINS(J)                                                  AUDB44     31
         IOUT=INPUTS(J)                                                 AUDB44     32
         II=II+1                                                        AUDB44     33
         IF(II.EQ.1) THEN                                               AUDB44     34
            CYB(IUB,IOUT)=XDAT                                          AUDB44     35
            XUY(1,IOUT)=XDAT                                            AUDB44     36
         ENDIF                                                          AUDB44     37
  110    CONTINUE                                                       AUDB44     38
      ENDIF                                                             AUDB44     39
      KINP=KINPU                                                        AUDB44     40
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB44     41
      IF(KINP.LT.KINPU) THEN                                            AUDB44     42
         DO 120 J=KINP+1,KINPU                                          AUDB44     43
         XDAT=GAINS(J)                                                  AUDB44     44
         IIN=INPUTS(J)                                                  AUDB44     45
         II=II+1                                                        AUDB44     46
         IF(II.EQ.1) THEN                                               AUDB44     47
            DU0(IUB,IIN)=XDAT                                           AUDB44     48
            XUREF(1)=XDAT                                               AUDB44     49
         ENDIF                                                          AUDB44     50
  120    CONTINUE                                                       AUDB44     51
      ENDIF                                                             AUDB44     52
C                                                                       AUDB44     53
      JLS=IUDAT(JEI+12)                                                 AUDB44     54
      VG=VALIN(1)                                                       AUDB44     55
      GAIN1=(1.0-SSMAT(JLS+6))/(1.0-SSMAT(JLS+5))                       AUDB44     56
      GAIN2=(SSMAT(JLS+6)-SSMAT(JLS+4))/(SSMAT(JLS+5)-SSMAT(JLS+3))     AUDB44     57
      GAIN3=SSMAT(JLS+4)/SSMAT(JLS+3)                                   AUDB44     58
      GAIN=GAIN1                                                        AUDB44     59
      IF(VG.LT.SSMAT(JLS+5)) GAIN=GAIN2                                 AUDB44     60
      IF(VG.LT.SSMAT(JLS+3)) GAIN=GAIN3                                 AUDB44     61
C                                                                       AUDB44     62
C     HP SECTION                                                        AUDB44     63
C                                                                       AUDB44     64
      KORD=KORD+1                                                       AUDB44     65
      AXB(KORD,KORD)=-1.0/UDAT(JEI+1)                                   AUDB44     66
      AXB(KORD,KORD+1)=(1.0-UDAT(JEI+8))/UDAT(JEI+1)                    AUDB44     67
      BUB(KORD,IUB)=GAIN*UDAT(JEI+8)*SSMAT(JLS+11)/UDAT(JEI+1)          AUDB44     68
      CXB(IORD,KORD)=UDAT(JEI+5)*UDAT(JEI+7)                            AUDB44     69
C                                                                       AUDB44     70
C     REHEATER                                                          AUDB44     71
C                                                                       AUDB44     72
      KORD=KORD+1                                                       AUDB44     73
      AXB(KORD,KORD)=-1.0/UDAT(JEI+2)                                   AUDB44     74
      AXB(KORD,KORD-1)=1.0/UDAT(JEI+2)                                  AUDB44     75
C                                                                       AUDB44     76
C     IP SECTION                                                        AUDB44     77
C                                                                       AUDB44     78
      KORD=KORD+1                                                       AUDB44     79
      IF (IUDAT(JEI+3).NE.0) THEN                                       AUDB44     80
         AXB(KORD,KORD)=-1.0/UDAT(JEI+3)                                AUDB44     81
         AXB(KORD,KORD-1)=1.0/UDAT(JEI+3)                               AUDB44     82
         CXB(IYB+1,KORD)=UDAT(JEI+6)*UDAT(JEI+7)                        AUDB44     83
      END IF                                                            AUDB44     84
C                                                                       AUDB44     85
C     LP SECTION                                                        AUDB44     86
C                                                                       AUDB44     87
      KORD=KORD+1                                                       AUDB44     88
      AXB(KORD,KORD)=-1.0/UDAT(JEI+4)                                   AUDB44     89
      IF (IUDAT(JEI+3).NE.0) THEN                                       AUDB44     90
         AXB(KORD,KORD-1)=1.0/UDAT(JEI+4)                               AUDB44     91
      ELSE                                                              AUDB44     92
         AXB(KORD,KORD-2)=1.0/UDAT(JEI+4)                               AUDB44     93
      END IF                                                            AUDB44     94
      CXB(IYB+2,KORD)=(1.0-UDAT(JEI+5)-UDAT(JEI+6))*UDAT(JEI+7)         AUDB44     95
C                                                                       AUDB44     96
      IF(LDEB) WRITE(IUD6,1000) KORD,LORD,IORD                          AUDB44     97
C                                                                       AUDB44     98
      RETURN                                                            AUDB44     99
 1000 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB44    100
C                                                                       AUDB44    101
C-----------------------------------------------------------------------AUDB44    102
C                                                                       AUDB44    103
      ENTRY AUDB45(LORD)                                                AUDB44    104
CD                                                                      AUDB44    105
CD    FOR BLOCK TYPE 45 (TYPE T4 GOVERNOR END BLOCK)                    AUDB44    106
CD                                                                      AUDB44    107
      LDEB=(JDEB(264).NE.0)                                             AUDB44    108
C                                                                       AUDB44    109
      IUB=IUB+1                                                         AUDB44    110
      IORD=IUDAT(JE4+LORD)                                              AUDB44    111
      JEI=JEB+2                                                         AUDB44    112
      KINT=KINPU                                                        AUDB44    113
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB44    114
      IF(KINT.LT.KINPU) THEN                                            AUDB44    115
         J=KINT+1                                                       AUDB44    116
         XDAT=GAINS(J)                                                  AUDB44    117
         IOUT=INPUTS(J)                                                 AUDB44    118
         CYB(IUB,IOUT)=XDAT                                             AUDB44    119
         XUY(1,IOUT)=XDAT                                               AUDB44    120
         GO TO 130                                                      AUDB44    121
      ENDIF                                                             AUDB44    122
      KINP=KINPU                                                        AUDB44    123
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB44    124
      IF(KINP.LT.KINPU) THEN                                            AUDB44    125
         J=KINP+1                                                       AUDB44    126
         XDAT=GAINS(J)                                                  AUDB44    127
         IIN=INPUTS(J)                                                  AUDB44    128
         DU0(IUB,IIN)=XDAT                                              AUDB44    129
         XUREF(1)=XDAT                                                  AUDB44    130
      ENDIF                                                             AUDB44    131
  130 CONTINUE                                                          AUDB44    132
C                                                                       AUDB44    133
      IF(IUDAT(JEI+1).NE.0) THEN                                        AUDB44    134
         KORD=KORD+1                                                    AUDB44    135
         AXB(KORD,KORD)=-1.0/UDAT(JEI+1)                                AUDB44    136
         BUB(KORD,IUB)=1.0/UDAT(JEI+1)                                  AUDB44    137
      ENDIF                                                             AUDB44    138
      CXB(IORD,KORD)=UDAT(JEI+8)*UDAT(JEI+7)                            AUDB44    139
C                                                                       AUDB44    140
      KORD=KORD+1                                                       AUDB44    141
      IF (IUDAT(JEI+2).NE.0) THEN                                       AUDB44    142
         AXB(KORD,KORD)=-1.0/UDAT(JEI+2)                                AUDB44    143
         AXB(KORD,KORD-1)=1.0/UDAT(JEI+2)                               AUDB44    144
         CXB(IYB+1,KORD)=UDAT(JEI+9)*UDAT(JEI+7)                        AUDB44    145
      ELSE                                                              AUDB44    146
         CXB(IYB+1,KORD-1)=UDAT(JEI+9)*UDAT(JEI+7)                      AUDB44    147
      END IF                                                            AUDB44    148
      IHPLP(1)=KORD                                                     AUDB44    149
C                                                                       AUDB44    150
      KORD=KORD+1                                                       AUDB44    151
      IF (IUDAT(JEI+3).NE.0) THEN                                       AUDB44    152
         AXB(KORD,KORD)=-1.0/UDAT(JEI+3)                                AUDB44    153
         IF (IUDAT(JEI+2).NE.0) THEN                                    AUDB44    154
            AXB(KORD,KORD-1)=1.0/UDAT(JEI+3)                            AUDB44    155
         ELSE                                                           AUDB44    156
            AXB(KORD,KORD-2)=1.0/UDAT(JEI+3)                            AUDB44    157
         END IF                                                         AUDB44    158
         CXB(IYB+2,KORD)=UDAT(JEI+10)*UDAT(JEI+7)                       AUDB44    159
      ELSE                                                              AUDB44    160
         IF (IUDAT(JEI+2).NE.0) THEN                                    AUDB44    161
            CXB(IYB+2,KORD-1)=UDAT(JEI+10)*UDAT(JEI+7)                  AUDB44    162
         ELSE                                                           AUDB44    163
            CXB(IYB+2,KORD-2)=UDAT(JEI+10)*UDAT(JEI+7)                  AUDB44    164
         END IF                                                         AUDB44    165
      END IF                                                            AUDB44    166
      IHPLP(2)=KORD                                                     AUDB44    167
C                                                                       AUDB44    168
      IWS1=KORD                                                         AUDB44    169
      IF (IUDAT(JEI+3).NE.0) GOTO 135                                   AUDB44    170
      IWS1=IWS1-1                                                       AUDB44    171
      IF (IUDAT(JEI+2).NE.0) GOTO 135                                   AUDB44    172
      IWS1=IWS1-1                                                       AUDB44    173
  135 CONTINUE                                                          AUDB44    174
C                                                                       AUDB44    175
      KORD=KORD+1                                                       AUDB44    176
      IF (IUDAT(JEI+4).NE.0) THEN                                       AUDB44    177
         AXB(KORD,KORD)=-1.0/UDAT(JEI+4)                                AUDB44    178
         AXB(KORD,IWS1)=1.0/UDAT(JEI+4)                                 AUDB44    179
         CXB(IYB+3,KORD)=UDAT(JEI+11)*UDAT(JEI+7)                       AUDB44    180
      ELSE                                                              AUDB44    181
         CXB(IYB+3,IWS1)=UDAT(JEI+11)*UDAT(JEI+7)                       AUDB44    182
      END IF                                                            AUDB44    183
      IHPLP(3)=KORD                                                     AUDB44    184
C                                                                       AUDB44    185
      IF(LDEB) WRITE(IUD6,1010) KORD,LORD,IORD                          AUDB44    186
C                                                                       AUDB44    187
      RETURN                                                            AUDB44    188
 1010 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB44    189
C                                                                       AUDB44    190
C-----------------------------------------------------------------------AUDB44    191
C                                                                       AUDB44    192
      ENTRY AUDB47(LORD)                                                AUDB44    193
CD                                                                      AUDB44    194
CD    FOR BLOCK TYPE 47 (TYPE T22 GOVERNOR END BLOCK)                   AUDB44    195
CD                                                                      AUDB44    196
      LDEB=(JDEB(264).NE.0)                                             AUDB44    197
C                                                                       AUDB44    198
      IUB=IUB+1                                                         AUDB44    199
      IORD=IUDAT(JE4+LORD)                                              AUDB44    200
      JEI=JEB+2                                                         AUDB44    201
      TTW=UDAT(JEI+1)/2.0                                               AUDB44    202
      KINT=KINPU                                                        AUDB44    203
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB44    204
      IF(KINT.LT.KINPU) THEN                                            AUDB44    205
         J=KINT+1                                                       AUDB44    206
         XDAT=GAINS(J)                                                  AUDB44    207
         IOUT=INPUTS(J)                                                 AUDB44    208
         CYB(IUB,IOUT)=XDAT                                             AUDB44    209
         XUY(1,IOUT)=XDAT                                               AUDB44    210
         GO TO 140                                                      AUDB44    211
      ENDIF                                                             AUDB44    212
      KINP=KINPU                                                        AUDB44    213
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB44    214
      IF(KINP.LT.KINPU) THEN                                            AUDB44    215
         J=KINP+1                                                       AUDB44    216
         XDAT=GAINS(J)                                                  AUDB44    217
         IIN=INPUTS(J)                                                  AUDB44    218
         DU0(IUB,IIN)=XDAT                                              AUDB44    219
         XUREF(1)=XDAT                                                  AUDB44    220
      ENDIF                                                             AUDB44    221
  140 CONTINUE                                                          AUDB44    222
C                                                                       AUDB44    223
      KORD=KORD+1                                                       AUDB44    224
      IF (TTW.GT.0.0) THEN                                              AUDB44    225
         AXB(KORD,KORD)=-1.0/TTW                                        AUDB44    226
         BUB(KORD,IUB)=UDAT(JEI+2)/TTW                                  AUDB44    227
         CXB(IORD,KORD)=UDAT(JEI+7)                                     AUDB44    228
         DUB(IORD,IUB)=UDAT(JEI+3)*UDAT(JEI+7)                          AUDB44    229
      ELSE                                                              AUDB44    230
         DUB(IORD,IUB)=(UDAT(JEI+2)+UDAT(JEI+3))*UDAT(JEI+7)            AUDB44    231
      END IF                                                            AUDB44    232
      IUB=IUB+1                                                         AUDB44    233
      DU0(IUB,12)=UDAT(JEI+4)/WXBASE                                    AUDB44    234
      DUB(IORD,IUB)=-UDAT(JEI+7)                                        AUDB44    235
      IF(LDEB) WRITE(IUD6,1020) KORD,LORD,IORD                          AUDB44    236
C                                                                       AUDB44    237
      RETURN                                                            AUDB44    238
 1020 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB44    239
      END                                                               AUDB44    240
