CFPRIME AUDB48                                                          AUDB48      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 AUDB48(LORD,LTYP)                                      AUDB48      3
CD                                                                      AUDB48      4
CD    TO FORMULATE THE ELEMENTARY LINEARIZED EQUATIONS OF USER DEFINED  AUDB48      5
CD    BLOCK TYPES 48, 49 AND 50 (TYPES OF2, OF1, AND LF SVC OR RANI     AUDB48      6
CD    SPECIAL BLOCKS) IN A USER DEFINED SVC OR RANI MODEL FOR USE IN    AUDB48      7
CD    CONSTRUCTING THE JACOBIAN MATRICES.                               AUDB48      8
CD                                                                      AUDB48      9
CD    EACH ENTRY POINT IN THIS SUBROUTINE HAS SIMILAR FUNCTION AND IS   AUDB48     10
CD    FOR A DIFFERENT TYPE OF SVC OR RANI SPECIAL BLOCK APPLICABLE TO   AUDB48     11
CD    A USER DEFINED SVC OR RANI MODEL.                                 AUDB48     12
CD                                                                      AUDB48     13
      INCLUDE 'PARX.INS'                                                AUDB48     14
      INCLUDE 'CNUNIT.INS'                                              AUDB48     15
      INCLUDE 'CNFLAG.INS'                                              AUDB48     16
      INCLUDE 'CNUDM.INS'                                               AUDB48     17
      INCLUDE 'CNUDMA.INS'                                              AUDB48     18
C                                                                       AUDB48     19
      LDEB=(JDEB(264).NE.0)                                             AUDB48     20
C                                                                       AUDB48     21
      IUB=IUB+1                                                         AUDB48     22
      IORD=IUDAT(JE4+LORD)                                              AUDB48     23
      JEI=JEB+2                                                         AUDB48     24
      II=0                                                              AUDB48     25
      KINT=KINPU                                                        AUDB48     26
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48     27
      IF(KINT.LT.KINPU) THEN                                            AUDB48     28
         DO 110 J=KINT+1,KINPU                                          AUDB48     29
         XDAT=GAINS(J)                                                  AUDB48     30
         IOUT=INPUTS(J)                                                 AUDB48     31
         II=II+1                                                        AUDB48     32
         IF(II.EQ.1) THEN                                               AUDB48     33
            CYB(IUB,IOUT)=XDAT                                          AUDB48     34
         ENDIF                                                          AUDB48     35
  110    CONTINUE                                                       AUDB48     36
      ENDIF                                                             AUDB48     37
      KINP=KINPU                                                        AUDB48     38
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48     39
      IF(KINP.LT.KINPU) THEN                                            AUDB48     40
         DO 120 J=KINP+1,KINPU                                          AUDB48     41
         XDAT=GAINS(J)                                                  AUDB48     42
         IIN=INPUTS(J)                                                  AUDB48     43
         II=II+1                                                        AUDB48     44
         IF(II.EQ.1) THEN                                               AUDB48     45
            IF(IIN.LE.20) THEN                                          AUDB48     46
               DU0(IUB,IIN)=XDAT                                        AUDB48     47
            ELSE                                                        AUDB48     48
               DUR0(IUB,IIN-20)=XDAT                                    AUDB48     49
            ENDIF                                                       AUDB48     50
         ENDIF                                                          AUDB48     51
  120    CONTINUE                                                       AUDB48     52
      ENDIF                                                             AUDB48     53
C                                                                       AUDB48     54
      DUB(IORD,IUB)=UDAT(JEI+8)                                         AUDB48     55
      IF (LTYP.EQ.48) KORD=KORD+1                                       AUDB48     56
      IF (LDEB) WRITE(IUD6,1000) KORD,LORD,IORD                         AUDB48     57
C                                                                       AUDB48     58
      RETURN                                                            AUDB48     59
 1000 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB48     60
C                                                                       AUDB48     61
C-----------------------------------------------------------------------AUDB48     62
C                                                                       AUDB48     63
      ENTRY AUDB51(LORD)                                                AUDB48     64
CD                                                                      AUDB48     65
CD    FOR BLOCK TYPE 51 (TYPE SD1 SVC OR RANI END BLOCK)                AUDB48     66
CD                                                                      AUDB48     67
      LDEB=(JDEB(264).NE.0)                                             AUDB48     68
C                                                                       AUDB48     69
      IUB=IUB+1                                                         AUDB48     70
      IORD=IUDAT(JE4+LORD)                                              AUDB48     71
      JEI=JEB+2                                                         AUDB48     72
      KINT=KINPU                                                        AUDB48     73
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48     74
      IF(KINT.LT.KINPU) THEN                                            AUDB48     75
         J=KINT+1                                                       AUDB48     76
         XDAT=GAINS(J)                                                  AUDB48     77
         IOUT=INPUTS(J)                                                 AUDB48     78
         CYB(IUB,IOUT)=XDAT                                             AUDB48     79
         XUY(11,IOUT)=XDAT                                              AUDB48     80
         GO TO 130                                                      AUDB48     81
      ENDIF                                                             AUDB48     82
      KINP=KINPU                                                        AUDB48     83
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48     84
      IF(KINP.LT.KINPU) THEN                                            AUDB48     85
         J=KINP+1                                                       AUDB48     86
         XDAT=GAINS(J)                                                  AUDB48     87
         IIN=INPUTS(J)                                                  AUDB48     88
         DU0(IUB,IIN)=XDAT                                              AUDB48     89
         XUREF(11)=XDAT                                                 AUDB48     90
      ENDIF                                                             AUDB48     91
  130 CONTINUE                                                          AUDB48     92
C                                                                       AUDB48     93
      DUB(IORD,IUB)=1.0                                                 AUDB48     94
      IF(LDEB) WRITE(IUD6,1010) LORD,IORD                               AUDB48     95
C                                                                       AUDB48     96
      RETURN                                                            AUDB48     97
 1010 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB48     98
C                                                                       AUDB48     99
C-----------------------------------------------------------------------AUDB48    100
C                                                                       AUDB48    101
      ENTRY AUDB52(LORD)                                                AUDB48    102
CD                                                                      AUDB48    103
CD    FOR BLOCK TYPE 52 (TYPE SD2 SVC OR RANI END BLOCK)                AUDB48    104
CD                                                                      AUDB48    105
      LDEB=(JDEB(264).NE.0)                                             AUDB48    106
C                                                                       AUDB48    107
      IUB=IUB+1                                                         AUDB48    108
      IORD=IUDAT(JE4+LORD)                                              AUDB48    109
      JEI=JEB+2                                                         AUDB48    110
      TTR=UDAT(JEI+3)                                                   AUDB48    111
      KINT=KINPU                                                        AUDB48    112
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48    113
      IF(KINT.LT.KINPU) THEN                                            AUDB48    114
         J=KINT+1                                                       AUDB48    115
         XDAT=GAINS(J)                                                  AUDB48    116
         IOUT=INPUTS(J)                                                 AUDB48    117
         CYB(IUB,IOUT)=XDAT                                             AUDB48    118
         XUY(11,IOUT)=XDAT                                              AUDB48    119
         GO TO 140                                                      AUDB48    120
      ENDIF                                                             AUDB48    121
      KINP=KINPU                                                        AUDB48    122
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48    123
      IF(KINP.LT.KINPU) THEN                                            AUDB48    124
         J=KINP+1                                                       AUDB48    125
         XDAT=GAINS(J)                                                  AUDB48    126
         IIN=INPUTS(J)                                                  AUDB48    127
         DU0(IUB,IIN)=XDAT                                              AUDB48    128
         XUREF(11)=XDAT                                                 AUDB48    129
      ENDIF                                                             AUDB48    130
  140 CONTINUE                                                          AUDB48    131
C                                                                       AUDB48    132
      KORD=KORD+1                                                       AUDB48    133
      IF (TTR.GT.0.0) THEN                                              AUDB48    134
         AXB(KORD,KORD)=-1.0/TTR                                        AUDB48    135
         BUB(KORD,IUB)=1.0/TTR                                          AUDB48    136
         CXB(IORD,KORD)=UDAT(JEI+5)                                     AUDB48    137
      ELSE                                                              AUDB48    138
         DUB(IORD,IUB)=UDAT(JEI+5)                                      AUDB48    139
      END IF                                                            AUDB48    140
      IF(LDEB) WRITE(IUD6,1020) KORD,LORD,IORD                          AUDB48    141
C                                                                       AUDB48    142
      RETURN                                                            AUDB48    143
 1020 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB48    144
C                                                                       AUDB48    145
C-----------------------------------------------------------------------AUDB48    146
C                                                                       AUDB48    147
      ENTRY AUDB53(LORD)                                                AUDB48    148
CD                                                                      AUDB48    149
CD    FOR BLOCK TYPE 53 (TYPE SD3 SVC OR RANI END BLOCK)                AUDB48    150
CD                                                                      AUDB48    151
      LDEB=(JDEB(264).NE.0)                                             AUDB48    152
C                                                                       AUDB48    153
      IUB=IUB+1                                                         AUDB48    154
      IORD=IUDAT(JE4+LORD)                                              AUDB48    155
      JEI=JEB+2                                                         AUDB48    156
      TTR=UDAT(JEI+3)                                                   AUDB48    157
      II=0                                                              AUDB48    158
      KINT=KINPU                                                        AUDB48    159
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48    160
      IF(KINT.LT.KINPU) THEN                                            AUDB48    161
         DO 150 J=KINT+1,KINPU                                          AUDB48    162
         XDAT=GAINS(J)                                                  AUDB48    163
         IOUT=INPUTS(J)                                                 AUDB48    164
         II=II+1                                                        AUDB48    165
         IF(II.EQ.1) THEN                                               AUDB48    166
            CYB(IUB,IOUT)=XDAT                                          AUDB48    167
            XUY(11,IOUT)=XDAT                                           AUDB48    168
         ENDIF                                                          AUDB48    169
  150    CONTINUE                                                       AUDB48    170
      ENDIF                                                             AUDB48    171
      KINP=KINPU                                                        AUDB48    172
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48    173
      IF(KINP.LT.KINPU) THEN                                            AUDB48    174
         DO 160 J=KINP+1,KINPU                                          AUDB48    175
         XDAT=GAINS(J)                                                  AUDB48    176
         IIN=INPUTS(J)                                                  AUDB48    177
         II=II+1                                                        AUDB48    178
         IF(II.EQ.1) THEN                                               AUDB48    179
            DU0(IUB,IIN)=XDAT                                           AUDB48    180
            XUREF(11)=XDAT                                              AUDB48    181
         ENDIF                                                          AUDB48    182
  160    CONTINUE                                                       AUDB48    183
      ENDIF                                                             AUDB48    184
C                                                                       AUDB48    185
      KORD=KORD+1                                                       AUDB48    186
      IF (TTR.GT.0.0) THEN                                              AUDB48    187
         AXB(KORD,KORD)=-1.0/TTR                                        AUDB48    188
         BUB(KORD,IUB)=1.0/TTR                                          AUDB48    189
         CXB(IORD,KORD)=UDAT(JEI+1)*UDAT(JEI+11)                        AUDB48    190
      ELSE                                                              AUDB48    191
         DUB(IORD,IUB)=UDAT(JEI+1)*UDAT(JEI+11)                         AUDB48    192
      END IF                                                            AUDB48    193
      KORD=KORD+1                                                       AUDB48    194
      IF(LDEB) WRITE(IUD6,1030) KORD,LORD,IORD                          AUDB48    195
C                                                                       AUDB48    196
      RETURN                                                            AUDB48    197
 1030 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB48    198
C                                                                       AUDB48    199
C-----------------------------------------------------------------------AUDB48    200
C                                                                       AUDB48    201
      ENTRY AUDB54(LORD)                                                AUDB48    202
CD                                                                      AUDB48    203
CD    FOR BLOCK TYPE 54 (TYPE SD4 STC OR SPS END BLOCK)                 AUDB48    204
CD                                                                      AUDB48    205
      LDEB=(JDEB(264).NE.0)                                             AUDB48    206
C                                                                       AUDB48    207
      IUB=IUB+1                                                         AUDB48    208
      IORD=IUDAT(JE4+LORD)                                              AUDB48    209
      JEI=JEB+2                                                         AUDB48    210
      KINT=KINPU                                                        AUDB48    211
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48    212
      IF(KINT.LT.KINPU) THEN                                            AUDB48    213
         J=KINT+1                                                       AUDB48    214
         XDAT=GAINS(J)                                                  AUDB48    215
         IOUT=INPUTS(J)                                                 AUDB48    216
         CYB(IUB,IOUT)=XDAT                                             AUDB48    217
         XUY(11,IOUT)=XDAT                                              AUDB48    218
         XUY(12,IOUT)=XDAT                                              AUDB48    219
         GO TO 170                                                      AUDB48    220
      ENDIF                                                             AUDB48    221
      KINP=KINPU                                                        AUDB48    222
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48    223
      IF(KINP.LT.KINPU) THEN                                            AUDB48    224
         J=KINP+1                                                       AUDB48    225
         XDAT=GAINS(J)                                                  AUDB48    226
         IIN=INPUTS(J)                                                  AUDB48    227
         DU0(IUB,IIN)=XDAT                                              AUDB48    228
         XUREF(11)=XDAT                                                 AUDB48    229
         XUREF(12)=XDAT                                                 AUDB48    230
      ENDIF                                                             AUDB48    231
  170 CONTINUE                                                          AUDB48    232
C                                                                       AUDB48    233
      TT=UDAT(JEI+1)                                                    AUDB48    234
      KORD=KORD+1                                                       AUDB48    235
      IF (TT.GT.0.0) THEN                                               AUDB48    236
         AXB(KORD,KORD)=-1.0/TT                                         AUDB48    237
         BUB(KORD,IUB)=1.0/TT                                           AUDB48    238
         CXB(IORD,KORD)=1.0                                             AUDB48    239
      ELSE                                                              AUDB48    240
         DUB(IORD,IUB)=1.0                                              AUDB48    241
      END IF                                                            AUDB48    242
      IF (LDEB) WRITE(IUD6,1040) KORD,LORD,IORD                         AUDB48    243
C                                                                       AUDB48    244
      RETURN                                                            AUDB48    245
 1040 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB48    246
C                                                                       AUDB48    247
C-----------------------------------------------------------------------AUDB48    248
C                                                                       AUDB48    249
      ENTRY AUDB56(LORD)                                                AUDB48    250
CD                                                                      AUDB48    251
CD    FOR BLOCK TYPES 55, 56, 58, AND 59 (TYPES SD5 SDB, SD6 RANI,      AUDB48    252
CD    SD8 SVC, AND SD9 RANI END BLOCKS)                                 AUDB48    253
CD                                                                      AUDB48    254
      LDEB=(JDEB(264).NE.0)                                             AUDB48    255
C                                                                       AUDB48    256
      IUB=IUB+1                                                         AUDB48    257
      IORD=IUDAT(JE4+LORD)                                              AUDB48    258
      JEI=JEB+2                                                         AUDB48    259
      KINT=KINPU                                                        AUDB48    260
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48    261
      IF(KINT.LT.KINPU) THEN                                            AUDB48    262
         J=KINT+1                                                       AUDB48    263
         XDAT=GAINS(J)                                                  AUDB48    264
         IOUT=INPUTS(J)                                                 AUDB48    265
         CYB(IUB,IOUT)=XDAT                                             AUDB48    266
         XUY(12,IOUT)=XDAT                                              AUDB48    267
         GO TO 180                                                      AUDB48    268
      ENDIF                                                             AUDB48    269
      KINP=KINPU                                                        AUDB48    270
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48    271
      IF(KINP.LT.KINPU) THEN                                            AUDB48    272
         J=KINP+1                                                       AUDB48    273
         XDAT=GAINS(J)                                                  AUDB48    274
         IIN=INPUTS(J)                                                  AUDB48    275
         DU0(IUB,IIN)=XDAT                                              AUDB48    276
         XUREF(12)=XDAT                                                 AUDB48    277
      ENDIF                                                             AUDB48    278
  180 CONTINUE                                                          AUDB48    279
C                                                                       AUDB48    280
      TTG=UDAT(JEI+2)                                                   AUDB48    281
      KORD=KORD+1                                                       AUDB48    282
      IF (TTG.GT.0.0) THEN                                              AUDB48    283
         AXB(KORD,KORD)=-1.0/TTG                                        AUDB48    284
         BUB(KORD,IUB)=1.0/TTG                                          AUDB48    285
         CXB(IORD,KORD)=1.0                                             AUDB48    286
      ELSE                                                              AUDB48    287
         DUB(IORD,IUB)=1.0                                              AUDB48    288
      END IF                                                            AUDB48    289
      IF (LDEB) WRITE(IUD6,1050) KORD,LORD,IORD                         AUDB48    290
C                                                                       AUDB48    291
      RETURN                                                            AUDB48    292
 1050 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB48    293
C                                                                       AUDB48    294
C-----------------------------------------------------------------------AUDB48    295
C                                                                       AUDB48    296
      ENTRY AUDB57(LORD)                                                AUDB48    297
CD                                                                      AUDB48    298
CD    FOR BLOCK TYPE 57 (TYPE SD7 SVC AND RANI END BLOCK)               AUDB48    299
CD                                                                      AUDB48    300
      LDEB=(JDEB(264).NE.0)                                             AUDB48    301
C                                                                       AUDB48    302
      IUB=IUB+1                                                         AUDB48    303
      IORD=IUDAT(JE4+LORD)                                              AUDB48    304
      JEI=JEB+2                                                         AUDB48    305
      KINT=KINPU                                                        AUDB48    306
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB48    307
      IF(KINT.LT.KINPU) THEN                                            AUDB48    308
         J=KINT+1                                                       AUDB48    309
         XDAT=GAINS(J)                                                  AUDB48    310
         IOUT=INPUTS(J)                                                 AUDB48    311
         CYB(IUB,IOUT)=XDAT                                             AUDB48    312
         XUY(12,IOUT)=XDAT                                              AUDB48    313
         GO TO 190                                                      AUDB48    314
      ENDIF                                                             AUDB48    315
      KINP=KINPU                                                        AUDB48    316
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB48    317
      IF(KINP.LT.KINPU) THEN                                            AUDB48    318
         J=KINP+1                                                       AUDB48    319
         XDAT=GAINS(J)                                                  AUDB48    320
         IIN=INPUTS(J)                                                  AUDB48    321
         DU0(IUB,IIN)=XDAT                                              AUDB48    322
         XUREF(12)=XDAT                                                 AUDB48    323
      ENDIF                                                             AUDB48    324
  190 CONTINUE                                                          AUDB48    325
C                                                                       AUDB48    326
      AX=UDAT(JEI+3)                                                    AUDB48    327
      BX=UDAT(JEI+4)                                                    AUDB48    328
      KORD=KORD+1                                                       AUDB48    329
      IF(AX.GT.0.0) THEN                                                AUDB48    330
         AXB(KORD,KORD)=-BX/AX                                          AUDB48    331
         BUB(KORD,IUB)=1.0/AX                                           AUDB48    332
         CXB(IORD,KORD)=1.0                                             AUDB48    333
      ELSE                                                              AUDB48    334
         DUB(IORD,IUB)=1.0/BX                                           AUDB48    335
      END IF                                                            AUDB48    336
      IF (LDEB) WRITE(IUD6,1050) KORD,LORD,IORD                         AUDB48    337
C                                                                       AUDB48    338
      RETURN                                                            AUDB48    339
C                                                                       AUDB48    340
C-----------------------------------------------------------------------AUDB48    341
C                                                                       AUDB48    342
      END                                                               AUDB48    343
