CFPRIME AUDB31                                                          AUDB31      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 AUDB31(LORD)                                           AUDB31      3
CD                                                                      AUDB31      4
CD    TO FORMULATE THE ELEMENTARY LINEARIZED EQUATIONS OF USER DEFINED  AUDB31      5
CD    BLOCK TYPES 31 AND 32 (TYPES E1 AND E2 EXCITER END BLOCKS) IN A   AUDB31      6
CD    USER DEFINED EXCITER MODEL FOR USE IN CONSTRUCTING THE JACOBIAN   AUDB31      7
CD    MATRICES.                                                         AUDB31      8
CD                                                                      AUDB31      9
CD    EACH ENTRY POINT IN THIS SUBROUTINE HAS SIMILAR FUNCTION AND IS   AUDB31     10
CD    FOR A DIFFERENT TYPE OF EXCITER END BLOCK APPLICABLE TO A USER    AUDB31     11
CD    DEFINED EXCITER MODEL.                                            AUDB31     12
CD                                                                      AUDB31     13
      INCLUDE 'PARX.INS'                                                AUDB31     14
      INCLUDE 'CNUNIT.INS'                                              AUDB31     15
      INCLUDE 'CNFLAG.INS'                                              AUDB31     16
      INCLUDE 'CNEXC.INS'                                               AUDB31     17
      INCLUDE 'CNUDM.INS'                                               AUDB31     18
      INCLUDE 'CNUDMA.INS'                                              AUDB31     19
C                                                                       AUDB31     20
      LDEB=(JDEB(264).NE.0)                                             AUDB31     21
C                                                                       AUDB31     22
      IUB=IUB+1                                                         AUDB31     23
      IORD=IUDAT(JE4+LORD)                                              AUDB31     24
      JEI=JEB+2                                                         AUDB31     25
      KINT=KINPU                                                        AUDB31     26
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31     27
      IF(KINT.LT.KINPU) THEN                                            AUDB31     28
         J=KINT+1                                                       AUDB31     29
         XDAT=GAINS(J)                                                  AUDB31     30
         IOUT=INPUTS(J)                                                 AUDB31     31
         CYB(IUB,IOUT)=XDAT                                             AUDB31     32
         XUY(19,IOUT)=XDAT                                              AUDB31     33
         GO TO 100                                                      AUDB31     34
      ENDIF                                                             AUDB31     35
      KINP=KINPU                                                        AUDB31     36
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31     37
      IF(KINP.LT.KINPU) THEN                                            AUDB31     38
         J=KINP+1                                                       AUDB31     39
         XDAT=GAINS(J)                                                  AUDB31     40
         IIN=INPUTS(J)                                                  AUDB31     41
         DU0(IUB,IIN)=XDAT                                              AUDB31     42
         XUREF(19)=XDAT                                                 AUDB31     43
      ENDIF                                                             AUDB31     44
  100 CONTINUE                                                          AUDB31     45
C                                                                       AUDB31     46
      KORD=KORD+1                                                       AUDB31     47
C                                                                       AUDB31     48
      EFDN=VALIN(15)                                                    AUDB31     49
      SEKX=UDAT(JEI+1)                                                  AUDB31     50
      SEKX=SEKX+UDAT(JEI+3)*UDAT(JEI+4)*EXP(UDAT(JEI+4)*EFDN)           AUDB31     51
      AXB(KORD,KORD)=-SEKX/UDAT(JEI+2)                                  AUDB31     52
      BUB(KORD,IUB)=1.0/UDAT(JEI+2)                                     AUDB31     53
      CXB(IORD,KORD)=1.0                                                AUDB31     54
      IF(LDEB) WRITE(IUD6,1000) KORD,LORD,IORD                          AUDB31     55
C                                                                       AUDB31     56
      RETURN                                                            AUDB31     57
 1000 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB31     58
C                                                                       AUDB31     59
C-----------------------------------------------------------------------AUDB31     60
C                                                                       AUDB31     61
      ENTRY AUDB33(LORD)                                                AUDB31     62
CD                                                                      AUDB31     63
CD    FOR BLOCK TYPE 33 (TYPE E3 EXCITER END BLOCK)                     AUDB31     64
CD                                                                      AUDB31     65
      LDEB=(JDEB(264).NE.0)                                             AUDB31     66
C                                                                       AUDB31     67
      IUB=IUB+1                                                         AUDB31     68
      IORD=IUDAT(JE4+LORD)                                              AUDB31     69
      JEI=JEB+2                                                         AUDB31     70
      KINT=KINPU                                                        AUDB31     71
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31     72
      IF(KINT.LT.KINPU) THEN                                            AUDB31     73
         J=KINT+1                                                       AUDB31     74
         XDAT=GAINS(J)                                                  AUDB31     75
         IOUT=INPUTS(J)                                                 AUDB31     76
         CYB(IUB,IOUT)=XDAT                                             AUDB31     77
         XUY(19,IOUT)=XDAT                                              AUDB31     78
         GO TO 110                                                      AUDB31     79
      ENDIF                                                             AUDB31     80
      KINP=KINPU                                                        AUDB31     81
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31     82
      IF(KINP.LT.KINPU) THEN                                            AUDB31     83
         J=KINP+1                                                       AUDB31     84
         XDAT=GAINS(J)                                                  AUDB31     85
         IIN=INPUTS(J)                                                  AUDB31     86
         DU0(IUB,IIN)=XDAT                                              AUDB31     87
         XUREF(19)=XDAT                                                 AUDB31     88
      ENDIF                                                             AUDB31     89
  110 CONTINUE                                                          AUDB31     90
C                                                                       AUDB31     91
      KORD=KORD+1                                                       AUDB31     92
C                                                                       AUDB31     93
      EFDN=VALIN(15)                                                    AUDB31     94
      CFDN=VALIN(16)                                                    AUDB31     95
      FACT=UDAT(JEI+6)*CFDN                                             AUDB31     96
      VEM1=EFDN+0.577*FACT                                              AUDB31     97
      FACT2=FACT*FACT                                                   AUDB31     98
      VEM2=(SQRT(EFDN**2+FACT2))/0.866                                  AUDB31     99
      VEM3=EFDN/1.732+FACT                                              AUDB31    100
      RAT=EFDN/VEM1                                                     AUDB31    101
      IF(RAT.GT.0.75) GO TO 130                                         AUDB31    102
      RAT=EFDN/VEM2                                                     AUDB31    103
      IF(RAT.GT.0.433) GO TO 120                                        AUDB31    104
      VE=VEM3+UDAT(JEI+8)*CFDN                                          AUDB31    105
      G5=1.732                                                          AUDB31    106
      G6=-1.732*(UDAT(JEI+6)+UDAT(JEI+8))                               AUDB31    107
      GO TO 140                                                         AUDB31    108
  120 VE=VEM2+UDAT(JEI+8)*CFDN                                          AUDB31    109
      SQVE=SQRT(0.75-FACT2/VEM2/VEM2)                                   AUDB31    110
      G5=.75/SQVE                                                       AUDB31    111
      G6=-(UDAT(JEI+6)*FACT/VEM2/VEM2+.75*UDAT(JEI+8))/SQVE             AUDB31    112
      GO TO 140                                                         AUDB31    113
  130 VE=VEM1+UDAT(JEI+8)*CFDN                                          AUDB31    114
      G5=1.                                                             AUDB31    115
      G6=-(0.577*UDAT(JEI+6)+UDAT(JEI+8))                               AUDB31    116
  140 G7=UDAT(JEI+8)-UDAT(JEI+7)                                        AUDB31    117
      SKE=UDAT(JEI+1)                                                   AUDB31    118
      SEPKE=SKE+UDAT(JEI+3)*UDAT(JEI+4)*EXP(UDAT(JEI+4)*VE)             AUDB31    119
      AXB(KORD,KORD)=-SEPKE/UDAT(JEI+2)                                 AUDB31    120
      BUB(KORD,IUB)=1./UDAT(JEI+2)                                      AUDB31    121
      CXB(IORD,KORD)=G5                                                 AUDB31    122
      IUB=IUB+1                                                         AUDB31    123
      DU0(IUB,16)=1.0                                                   AUDB31    124
      BUB(KORD,IUB)=G7                                                  AUDB31    125
      DUB(IORD,IUB)=G6                                                  AUDB31    126
      IF(LDEB) WRITE(IUD6,1010) KORD,LORD,IORD                          AUDB31    127
C                                                                       AUDB31    128
      RETURN                                                            AUDB31    129
 1010 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB31    130
C                                                                       AUDB31    131
C-----------------------------------------------------------------------AUDB31    132
C                                                                       AUDB31    133
      ENTRY AUDB34(LORD)                                                AUDB31    134
CD                                                                      AUDB31    135
CD    FOR BLOCK TYPE 34 (TYPE E4 EXCITER END BLOCK)                     AUDB31    136
CD                                                                      AUDB31    137
      LDEB=(JDEB(264).NE.0)                                             AUDB31    138
C                                                                       AUDB31    139
      IUB=IUB+1                                                         AUDB31    140
      IORD=IUDAT(JE4+LORD)                                              AUDB31    141
      JEI=JEB+2                                                         AUDB31    142
      KINT=KINPU                                                        AUDB31    143
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    144
      IF(KINT.LT.KINPU) THEN                                            AUDB31    145
         J=KINT+1                                                       AUDB31    146
         XDAT=GAINS(J)                                                  AUDB31    147
         IOUT=INPUTS(J)                                                 AUDB31    148
         CYB(IUB,IOUT)=XDAT                                             AUDB31    149
         XUY(19,IOUT)=XDAT                                              AUDB31    150
         GO TO 150                                                      AUDB31    151
      ENDIF                                                             AUDB31    152
      KINP=KINPU                                                        AUDB31    153
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    154
      IF(KINP.LT.KINPU) THEN                                            AUDB31    155
         J=KINP+1                                                       AUDB31    156
         XDAT=GAINS(J)                                                  AUDB31    157
         IIN=INPUTS(J)                                                  AUDB31    158
         DU0(IUB,IIN)=XDAT                                              AUDB31    159
         XUREF(19)=XDAT                                                 AUDB31    160
      ENDIF                                                             AUDB31    161
  150 CONTINUE                                                          AUDB31    162
C                                                                       AUDB31    163
      KORD=KORD+1                                                       AUDB31    164
C                                                                       AUDB31    165
      EFDN=VALIN(15)                                                    AUDB31    166
      CFDN=VALIN(16)                                                    AUDB31    167
      FACT=UDAT(JEI+6)*CFDN                                             AUDB31    168
      VEM1=EFDN+0.577*FACT                                              AUDB31    169
      FACT2=FACT*FACT                                                   AUDB31    170
      VEM2=(SQRT(EFDN**2+FACT2))/0.866                                  AUDB31    171
      VEM3=EFDN/1.732+FACT                                              AUDB31    172
      RAT=EFDN/VEM1                                                     AUDB31    173
      IF(RAT.GT.0.75) GO TO 170                                         AUDB31    174
      RAT=EFDN/VEM2                                                     AUDB31    175
      IF(RAT.GT.0.433) GO TO 160                                        AUDB31    176
      VE=VEM3+UDAT(JEI+8)*CFDN                                          AUDB31    177
      G5=1.732                                                          AUDB31    178
      G6=-1.732*(UDAT(JEI+6)+UDAT(JEI+8))                               AUDB31    179
      GO TO 180                                                         AUDB31    180
  160 VE=VEM2+UDAT(JEI+8)*CFDN                                          AUDB31    181
      SQVE=SQRT(0.75-FACT2/VEM2/VEM2)                                   AUDB31    182
      G5=.75/SQVE                                                       AUDB31    183
      G6=-(UDAT(JEI+6)*FACT/VEM2/VEM2+.75*UDAT(JEI+8))/SQVE             AUDB31    184
      GO TO 180                                                         AUDB31    185
  170 VE=VEM1+UDAT(JEI+8)*CFDN                                          AUDB31    186
      G5=1.                                                             AUDB31    187
      G6=-(0.577*UDAT(JEI+6)+UDAT(JEI+8))                               AUDB31    188
  180 G7=UDAT(JEI+8)-UDAT(JEI+7)                                        AUDB31    189
      SKE=UDAT(JEI+1)                                                   AUDB31    190
      SEPKE=SKE+UDAT(JEI+3)*UDAT(JEI+4)*EXP(UDAT(JEI+4)*VE)             AUDB31    191
      GR=UDAT(JEI+12)*VALIN(19)                                         AUDB31    192
      AXB(KORD,KORD)=(GR*G5-SEPKE)/UDAT(JEI+2)                          AUDB31    193
      BUB(KORD,IUB)=UDAT(JEI+12)*EFDN/UDAT(JEI+2)                       AUDB31    194
      CXB(IORD,KORD)=G5                                                 AUDB31    195
      IUB=IUB+1                                                         AUDB31    196
      DU0(IUB,16)=1.0                                                   AUDB31    197
      BUB(KORD,IUB)=G7+GR*G6                                            AUDB31    198
      DUB(IORD,IUB)=G6                                                  AUDB31    199
      IF(LDEB) WRITE(IUD6,1020) KORD,LORD,IORD                          AUDB31    200
C                                                                       AUDB31    201
      RETURN                                                            AUDB31    202
 1020 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB31    203
C                                                                       AUDB31    204
C-----------------------------------------------------------------------AUDB31    205
C                                                                       AUDB31    206
      ENTRY AUDB35(LORD)                                                AUDB31    207
CD                                                                      AUDB31    208
CD    FOR BLOCK TYPE 35 AND 36 (TYPES E5 AND E6 EXCITER END BLOCKS)     AUDB31    209
CD                                                                      AUDB31    210
      LDEB=(JDEB(264).NE.0)                                             AUDB31    211
C                                                                       AUDB31    212
      IUB=IUB+1                                                         AUDB31    213
      IORD=IUDAT(JE4+LORD)                                              AUDB31    214
      JEI=JEB+2                                                         AUDB31    215
      KINT=KINPU                                                        AUDB31    216
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    217
      IF(KINT.LT.KINPU) THEN                                            AUDB31    218
         J=KINT+1                                                       AUDB31    219
         XDAT=GAINS(J)                                                  AUDB31    220
         IOUT=INPUTS(J)                                                 AUDB31    221
         CYB(IUB,IOUT)=XDAT                                             AUDB31    222
         GO TO 190                                                      AUDB31    223
      ENDIF                                                             AUDB31    224
      KINP=KINPU                                                        AUDB31    225
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    226
      IF(KINP.LT.KINPU) THEN                                            AUDB31    227
         J=KINP+1                                                       AUDB31    228
         XDAT=GAINS(J)                                                  AUDB31    229
         IIN=INPUTS(J)                                                  AUDB31    230
         DU0(IUB,IIN)=XDAT                                              AUDB31    231
      ENDIF                                                             AUDB31    232
  190 CONTINUE                                                          AUDB31    233
C                                                                       AUDB31    234
      KORD=KORD+1                                                       AUDB31    235
C                                                                       AUDB31    236
      EFDN=VALIN(15)                                                    AUDB31    237
      CFDN=VALIN(16)                                                    AUDB31    238
      FACT=UDAT(JEI+6)*CFDN                                             AUDB31    239
      VEM1=EFDN+0.577*FACT                                              AUDB31    240
      FACT2=FACT*FACT                                                   AUDB31    241
      VEM2=(SQRT(EFDN**2+FACT2))/0.866                                  AUDB31    242
      VEM3=EFDN/1.732+FACT                                              AUDB31    243
      RAT=EFDN/VEM1                                                     AUDB31    244
      IF(RAT.GT.0.75) GO TO 210                                         AUDB31    245
      RAT=EFDN/VEM2                                                     AUDB31    246
      IF(RAT.GT.0.433) GO TO 200                                        AUDB31    247
      VE=VEM3+UDAT(JEI+8)*CFDN                                          AUDB31    248
      G5=1.732                                                          AUDB31    249
      G6=-1.732*(UDAT(JEI+6)+UDAT(JEI+8))                               AUDB31    250
      GO TO 220                                                         AUDB31    251
  200 VE=VEM2+UDAT(JEI+8)*CFDN                                          AUDB31    252
      SQVE=SQRT(0.75-FACT2/VEM2/VEM2)                                   AUDB31    253
      G5=.75/SQVE                                                       AUDB31    254
      G6=-(UDAT(JEI+6)*FACT/VEM2/VEM2+.75*UDAT(JEI+8))/SQVE             AUDB31    255
      GO TO 220                                                         AUDB31    256
  210 VE=VEM1+UDAT(JEI+8)*CFDN                                          AUDB31    257
      G5=1.                                                             AUDB31    258
      G6=-(0.577*UDAT(JEI+6)+UDAT(JEI+8))                               AUDB31    259
  220 G7=UDAT(JEI+8)-UDAT(JEI+7)                                        AUDB31    260
      SKE=UDAT(JEI+1)                                                   AUDB31    261
      SEPKE=SKE+UDAT(JEI+3)*UDAT(JEI+4)*EXP(UDAT(JEI+4)*VE)             AUDB31    262
      XUY(19,IORD)=SEPKE/G5                                             AUDB31    263
      XUIF(19)=-(G7+G6*SEPKE/G5)                                        AUDB31    264
      AXB(KORD,KORD)=-SEPKE/UDAT(JEI+2)                                 AUDB31    265
      BUB(KORD,IUB)=1.0/UDAT(JEI+2)                                     AUDB31    266
      CXB(IORD,KORD)=G5                                                 AUDB31    267
      IUB=IUB+1                                                         AUDB31    268
      DU0(IUB,16)=1.0                                                   AUDB31    269
      BUB(KORD,IUB)=G7                                                  AUDB31    270
      DUB(IORD,IUB)=G6                                                  AUDB31    271
      IF(LDEB) WRITE(IUD6,1030) KORD,LORD,IORD                          AUDB31    272
C                                                                       AUDB31    273
      RETURN                                                            AUDB31    274
 1030 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB31    275
C                                                                       AUDB31    276
C-----------------------------------------------------------------------AUDB31    277
C                                                                       AUDB31    278
      ENTRY AUDB37(LORD)                                                AUDB31    279
CD                                                                      AUDB31    280
CD    FOR BLOCK TYPE 37 (TYPE E7 EXCITER END BLOCK)                     AUDB31    281
CD                                                                      AUDB31    282
      LDEB=(JDEB(264).NE.0)                                             AUDB31    283
C                                                                       AUDB31    284
      IUB=IUB+1                                                         AUDB31    285
      IORD=IUDAT(JE4+LORD)                                              AUDB31    286
      JEI=JEB+2                                                         AUDB31    287
      KINT=KINPU                                                        AUDB31    288
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    289
      IF(KINT.LT.KINPU) THEN                                            AUDB31    290
         J=KINT+1                                                       AUDB31    291
         XDAT=GAINS(J)                                                  AUDB31    292
         IOUT=INPUTS(J)                                                 AUDB31    293
         CYB(IUB,IOUT)=XDAT                                             AUDB31    294
         XUY(19,IOUT)=XDAT                                              AUDB31    295
         GO TO 230                                                      AUDB31    296
      ENDIF                                                             AUDB31    297
      KINP=KINPU                                                        AUDB31    298
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    299
      IF(KINP.LT.KINPU) THEN                                            AUDB31    300
         J=KINP+1                                                       AUDB31    301
         XDAT=GAINS(J)                                                  AUDB31    302
         IIN=INPUTS(J)                                                  AUDB31    303
         DU0(IUB,IIN)=XDAT                                              AUDB31    304
         XUREF(19)=XDAT                                                 AUDB31    305
      ENDIF                                                             AUDB31    306
  230 CONTINUE                                                          AUDB31    307
C                                                                       AUDB31    308
      KORD=KORD+1                                                       AUDB31    309
C                                                                       AUDB31    310
      EFDN=VALIN(15)                                                    AUDB31    311
      CFDN=VALIN(16)                                                    AUDB31    312
      IF(NRBUS.EQ.0) THEN                                               AUDB31    313
         VR1=VALIN(6)                                                   AUDB31    314
         VI1=VALIN(7)                                                   AUDB31    315
      ELSE                                                              AUDB31    316
         VR1=VALIN(21)*COS(VALIN(31))                                   AUDB31    317
         VI1=VALIN(21)*SIN(VALIN(31))                                   AUDB31    318
      ENDIF                                                             AUDB31    319
      G5=UDAT(JEI+4)*VR1-UDAT(JEI+5)*VALIN(9)                           AUDB31    320
      G6=UDAT(JEI+4)*VI1+UDAT(JEI+5)*VALIN(8)                           AUDB31    321
      VSC=SQRT(G5**2+G6**2)                                             AUDB31    322
      G7=UDAT(JEI+4)*G5/VSC                                             AUDB31    323
      G8=UDAT(JEI+4)*G6/VSC                                             AUDB31    324
      G9=UDAT(JEI+5)*G6/VSC                                             AUDB31    325
      G10=-UDAT(JEI+5)*G5/VSC                                           AUDB31    326
      CIN=UDAT(JEI+6)*CFDN/VSC                                          AUDB31    327
      IF(CIN.GT.0.433) GO TO 240                                        AUDB31    328
      FIN=1.0-0.577*CIN                                                 AUDB31    329
      G5=-0.577*UDAT(JEI+6)                                             AUDB31    330
      G6=1.                                                             AUDB31    331
      GO TO 260                                                         AUDB31    332
  240 IF(CIN.GE.0.75) GO TO 250                                         AUDB31    333
      FIN=SQRT(.75-CIN**2)                                              AUDB31    334
      G5=-UDAT(JEI+6)*CIN/FIN                                           AUDB31    335
      G6=CIN**2/FIN+FIN                                                 AUDB31    336
      GO TO 260                                                         AUDB31    337
  250 FIN=1.732*(1.-CIN)                                                AUDB31    338
      G5=-1.732*UDAT(JEI+6)                                             AUDB31    339
      G6=1.732                                                          AUDB31    340
  260 CONTINUE                                                          AUDB31    341
CC                                                                      AUDB31    342
CC    CODE FOR OLD TYPE ST2 EXCITER                                     AUDB31    343
CC                                                                      AUDB31    344
CC      VB=1.0                                                          AUDB31    345
CC      VR=1.0                                                          AUDB31    346
CC                                                                      AUDB31    347
      VB=VSC*FIN                                                        AUDB31    348
      VR=EFDN*UDAT(JEI+1)/VB                                            AUDB31    349
      G5=G5*VR                                                          AUDB31    350
      G6=G6*VR                                                          AUDB31    351
      AXB(KORD,KORD)=-UDAT(JEI+1)/UDAT(JEI+2)                           AUDB31    352
      BUB(KORD,IUB)=VB/UDAT(JEI+2)                                      AUDB31    353
      CXB(IORD,KORD)=1.0                                                AUDB31    354
C                                                                       AUDB31    355
      IF(NRBUS.EQ.0) THEN                                               AUDB31    356
         IUB=IUB+1                                                      AUDB31    357
         DU0(IUB,6)=1.0                                                 AUDB31    358
         BUB(KORD,IUB)=G6*G7/UDAT(JEI+2)                                AUDB31    359
         IUB=IUB+1                                                      AUDB31    360
         DU0(IUB,7)=1.0                                                 AUDB31    361
         BUB(KORD,IUB)=G6*G8/UDAT(JEI+2)                                AUDB31    362
      ELSE                                                              AUDB31    363
         IUB=IUB+1                                                      AUDB31    364
         DUR0(IUB,1)=VR1/VALIN(21)                                      AUDB31    365
         DUR0(IUB,11)=-VI1                                              AUDB31    366
         BUB(KORD,IUB)=G6*G7/UDAT(JEI+2)                                AUDB31    367
         IUB=IUB+1                                                      AUDB31    368
         DUR0(IUB,1)=VI1/VALIN(21)                                      AUDB31    369
         DUR0(IUB,11)=VR1                                               AUDB31    370
         BUB(KORD,IUB)=G6*G8/UDAT(JEI+2)                                AUDB31    371
      ENDIF                                                             AUDB31    372
C                                                                       AUDB31    373
      IUB=IUB+1                                                         AUDB31    374
      DU0(IUB,8)=1.0/BASPRN                                             AUDB31    375
      BUB(KORD,IUB)=G6*G9/UDAT(JEI+2)                                   AUDB31    376
      IUB=IUB+1                                                         AUDB31    377
      DU0(IUB,9)=1.0/BASPRN                                             AUDB31    378
      BUB(KORD,IUB)=G6*G10/UDAT(JEI+2)                                  AUDB31    379
      IUB=IUB+1                                                         AUDB31    380
      DU0(IUB,16)=1.0                                                   AUDB31    381
      BUB(KORD,IUB)=G5/UDAT(JEI+2)                                      AUDB31    382
      IF(LDEB) WRITE(IUD6,1040) LORD,IORD                               AUDB31    383
C                                                                       AUDB31    384
      RETURN                                                            AUDB31    385
 1040 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB31    386
C                                                                       AUDB31    387
C-----------------------------------------------------------------------AUDB31    388
C                                                                       AUDB31    389
      ENTRY AUDB38(LORD)                                                AUDB31    390
CD                                                                      AUDB31    391
CD    FOR BLOCK TYPE 38 (TYPE E8 EXCITER END BLOCK)                     AUDB31    392
CD                                                                      AUDB31    393
      LDEB=(JDEB(264).NE.0)                                             AUDB31    394
C                                                                       AUDB31    395
      IUB=IUB+1                                                         AUDB31    396
      IORD=IUDAT(JE4+LORD)                                              AUDB31    397
      JEI=JEB+2                                                         AUDB31    398
      KINT=KINPU                                                        AUDB31    399
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    400
      IF(KINT.LT.KINPU) THEN                                            AUDB31    401
         J=KINT+1                                                       AUDB31    402
         XDAT=GAINS(J)                                                  AUDB31    403
         IOUT=INPUTS(J)                                                 AUDB31    404
         CYB(IUB,IOUT)=XDAT                                             AUDB31    405
         XUY(19,IOUT)=XDAT                                              AUDB31    406
         GO TO 270                                                      AUDB31    407
      ENDIF                                                             AUDB31    408
      KINP=KINPU                                                        AUDB31    409
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    410
      IF(KINP.LT.KINPU) THEN                                            AUDB31    411
         J=KINP+1                                                       AUDB31    412
         XDAT=GAINS(J)                                                  AUDB31    413
         IIN=INPUTS(J)                                                  AUDB31    414
         DU0(IUB,IIN)=XDAT                                              AUDB31    415
         XUREF(19)=XDAT                                                 AUDB31    416
      ENDIF                                                             AUDB31    417
  270 CONTINUE                                                          AUDB31    418
C                                                                       AUDB31    419
      EFDN=VALIN(15)                                                    AUDB31    420
      CFDN=VALIN(16)                                                    AUDB31    421
      IF(NRBUS.EQ.0) THEN                                               AUDB31    422
         VR1=VALIN(6)                                                   AUDB31    423
         VI1=VALIN(7)                                                   AUDB31    424
      ELSE                                                              AUDB31    425
         VR1=VALIN(21)*COS(VALIN(31))                                   AUDB31    426
         VI1=VALIN(21)*SIN(VALIN(31))                                   AUDB31    427
      ENDIF                                                             AUDB31    428
      VA=VR1-UDAT(JEI+2)*VALIN(9)                                       AUDB31    429
      VB=VI1+UDAT(JEI+2)*VALIN(8)                                       AUDB31    430
      AKPC=UDAT(JEI+4)*COS(UDAT(JEI+5))                                 AUDB31    431
      AKPS=UDAT(JEI+4)*SIN(UDAT(JEI+5))                                 AUDB31    432
      V1=VA*AKPC-VB*AKPS-UDAT(JEI+3)*VALIN(9)                           AUDB31    433
      V2=VA*AKPS+VB*AKPC+UDAT(JEI+3)*VALIN(8)                           AUDB31    434
      VSC=SQRT(V1**2+V2**2)                                             AUDB31    435
      G7=(V1*AKPC+V2*AKPS)/VSC                                          AUDB31    436
      G8=(V2*AKPC-V1*AKPS)/VSC                                          AUDB31    437
      G9=UDAT(JEI+2)*G8+UDAT(JEI+3)*V2/VSC                              AUDB31    438
      G10=-UDAT(JEI+2)*G7-UDAT(JEI+3)*V1/VSC                            AUDB31    439
      CIN=UDAT(JEI+6)*CFDN/VSC                                          AUDB31    440
      IF(CIN.GT.0.433) GO TO 280                                        AUDB31    441
      FIN=1.0-0.577*CIN                                                 AUDB31    442
      G5=-0.577*UDAT(JEI+6)                                             AUDB31    443
      G6=1.                                                             AUDB31    444
      GO TO 300                                                         AUDB31    445
  280 IF(CIN.GE.0.75) GO TO 290                                         AUDB31    446
      FIN=SQRT(.75-CIN**2)                                              AUDB31    447
      G5=-UDAT(JEI+6)*CIN/FIN                                           AUDB31    448
      G6=CIN**2/FIN+FIN                                                 AUDB31    449
      GO TO 300                                                         AUDB31    450
  290 FIN=1.732*(1.-CIN)                                                AUDB31    451
      G5=-1.732*UDAT(JEI+6)                                             AUDB31    452
      G6=1.732                                                          AUDB31    453
  300 CONTINUE                                                          AUDB31    454
      D=VSC*FIN                                                         AUDB31    455
      G6=G6*EFDN/D                                                      AUDB31    456
      G5=G5*EFDN/D                                                      AUDB31    457
      DUB(IORD,IUB)=D                                                   AUDB31    458
C                                                                       AUDB31    459
      IF(NRBUS.EQ.0) THEN                                               AUDB31    460
         IUB=IUB+1                                                      AUDB31    461
         DU0(IUB,6)=1.0                                                 AUDB31    462
         DUB(IORD,IUB)=G6*G7                                            AUDB31    463
         IUB=IUB+1                                                      AUDB31    464
         DU0(IUB,7)=1.0                                                 AUDB31    465
         DUB(IORD,IUB)=G6*G8                                            AUDB31    466
      ELSE                                                              AUDB31    467
         IUB=IUB+1                                                      AUDB31    468
         DUR0(IUB,1)=VR1/VALIN(21)                                      AUDB31    469
         DUR0(IUB,11)=-VI1                                              AUDB31    470
         DUB(IORD,IUB)=G6*G7                                            AUDB31    471
         IUB=IUB+1                                                      AUDB31    472
         DUR0(IUB,1)=VI1/VALIN(21)                                      AUDB31    473
         DUR0(IUB,11)=VR1                                               AUDB31    474
         DUB(IORD,IUB)=G6*G8                                            AUDB31    475
      ENDIF                                                             AUDB31    476
C                                                                       AUDB31    477
      IUB=IUB+1                                                         AUDB31    478
      DU0(IUB,8)=1.0/BASPRN                                             AUDB31    479
      DUB(IORD,IUB)=G6*G9                                               AUDB31    480
      IUB=IUB+1                                                         AUDB31    481
      DU0(IUB,9)=1.0/BASPRN                                             AUDB31    482
      DUB(IORD,IUB)=G6*G10                                              AUDB31    483
      IUB=IUB+1                                                         AUDB31    484
      DU0(IUB,16)=1.0                                                   AUDB31    485
      DUB(IORD,IUB)=G5                                                  AUDB31    486
      IF(LDEB) WRITE(IUD6,1050) LORD,IORD                               AUDB31    487
C                                                                       AUDB31    488
      RETURN                                                            AUDB31    489
 1050 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB31    490
C                                                                       AUDB31    491
C-----------------------------------------------------------------------AUDB31    492
C                                                                       AUDB31    493
      ENTRY AUDB39(LORD)                                                AUDB31    494
CD                                                                      AUDB31    495
CD    FOR BLOCK TYPE 39 (TYPE E15 EXCITER END BLOCK)                    AUDB31    496
CD                                                                      AUDB31    497
      LDEB=(JDEB(264).NE.0)                                             AUDB31    498
C                                                                       AUDB31    499
      IUB=IUB+1                                                         AUDB31    500
      IORD=IUDAT(JE4+LORD)                                              AUDB31    501
      JEI=JEB+2                                                         AUDB31    502
      KINT=KINPU                                                        AUDB31    503
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    504
      IF(KINT.LT.KINPU) THEN                                            AUDB31    505
         J=KINT+1                                                       AUDB31    506
         XDAT=GAINS(J)                                                  AUDB31    507
         IOUT=INPUTS(J)                                                 AUDB31    508
         CYB(IUB,IOUT)=XDAT                                             AUDB31    509
         XUY(19,IOUT)=XDAT                                              AUDB31    510
         GO TO 310                                                      AUDB31    511
      ENDIF                                                             AUDB31    512
      KINP=KINPU                                                        AUDB31    513
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    514
      IF(KINP.LT.KINPU) THEN                                            AUDB31    515
         J=KINP+1                                                       AUDB31    516
         XDAT=GAINS(J)                                                  AUDB31    517
         IIN=INPUTS(J)                                                  AUDB31    518
         DU0(IUB,IIN)=XDAT                                              AUDB31    519
         XUREF(19)=XDAT                                                 AUDB31    520
      ENDIF                                                             AUDB31    521
  310 CONTINUE                                                          AUDB31    522
C                                                                       AUDB31    523
      DUB(IORD,IUB)=VALIN(1)                                            AUDB31    524
      IUB=IUB+1                                                         AUDB31    525
      DU0(IUB,1)=1.0                                                    AUDB31    526
      DUB(IORD,IUB)=VALIN(19)                                           AUDB31    527
      IF(LDEB) WRITE(IUD6,1060) LORD,IORD                               AUDB31    528
C                                                                       AUDB31    529
      RETURN                                                            AUDB31    530
 1060 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB31    531
C                                                                       AUDB31    532
C-----------------------------------------------------------------------AUDB31    533
C                                                                       AUDB31    534
      ENTRY AUDB40(LORD)                                                AUDB31    535
CD                                                                      AUDB31    536
CD    FOR BLOCK TYPE 40 (TYPE E30 EXCITER END BLOCK)                    AUDB31    537
CD                                                                      AUDB31    538
      LDEB=(JDEB(264).NE.0)                                             AUDB31    539
C                                                                       AUDB31    540
      IUB=IUB+1                                                         AUDB31    541
      IORD=IUDAT(JE4+LORD)                                              AUDB31    542
      JEI=JEB+2                                                         AUDB31    543
      KINT=KINPU                                                        AUDB31    544
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    545
      IF(KINT.LT.KINPU) THEN                                            AUDB31    546
         J=KINT+1                                                       AUDB31    547
         XDAT=GAINS(J)                                                  AUDB31    548
         IOUT=INPUTS(J)                                                 AUDB31    549
         CYB(IUB,IOUT)=XDAT                                             AUDB31    550
         XUY(19,IOUT)=XDAT                                              AUDB31    551
         GO TO 320                                                      AUDB31    552
      ENDIF                                                             AUDB31    553
      KINP=KINPU                                                        AUDB31    554
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    555
      IF(KINP.LT.KINPU) THEN                                            AUDB31    556
         J=KINP+1                                                       AUDB31    557
         XDAT=GAINS(J)                                                  AUDB31    558
         IIN=INPUTS(J)                                                  AUDB31    559
         DU0(IUB,IIN)=XDAT                                              AUDB31    560
         XUREF(19)=XDAT                                                 AUDB31    561
      ENDIF                                                             AUDB31    562
  320 CONTINUE                                                          AUDB31    563
C                                                                       AUDB31    564
      IF(IUDAT(JEI+2).NE.0)THEN                                         AUDB31    565
         KORD=KORD+1                                                    AUDB31    566
         AXB(KORD,KORD)=-1.0/UDAT(JEI+2)                                AUDB31    567
         BUB(KORD,IUB)=UDAT(JEI+1)/UDAT(JEI+2)                          AUDB31    568
         CXB(IORD,KORD)=1.0                                             AUDB31    569
      ELSE                                                              AUDB31    570
         DUB(IORD,IUB)=UDAT(JEI+1)                                      AUDB31    571
      ENDIF                                                             AUDB31    572
      IF(LDEB) WRITE(IUD6,1070) KORD,LORD,IORD                          AUDB31    573
C                                                                       AUDB31    574
      RETURN                                                            AUDB31    575
 1070 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB31    576
C                                                                       AUDB31    577
C-----------------------------------------------------------------------AUDB31    578
C                                                                       AUDB31    579
      ENTRY AUDB41(LORD)                                                AUDB31    580
CD                                                                      AUDB31    581
CD    FOR BLOCK TYPE 41 (TYPE E31 EXCITER END BLOCK)                    AUDB31    582
CD                                                                      AUDB31    583
      LDEB=(JDEB(264).NE.0)                                             AUDB31    584
C                                                                       AUDB31    585
      IUB=IUB+1                                                         AUDB31    586
      IORD=IUDAT(JE4+LORD)                                              AUDB31    587
      JEI=JEB+2                                                         AUDB31    588
      KINT=KINPU                                                        AUDB31    589
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    590
      IF(KINT.LT.KINPU) THEN                                            AUDB31    591
         J=KINT+1                                                       AUDB31    592
         XDAT=GAINS(J)                                                  AUDB31    593
         IOUT=INPUTS(J)                                                 AUDB31    594
         CYB(IUB,IOUT)=XDAT                                             AUDB31    595
         XUY(19,IOUT)=XDAT                                              AUDB31    596
         GO TO 330                                                      AUDB31    597
      ENDIF                                                             AUDB31    598
      KINP=KINPU                                                        AUDB31    599
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    600
      IF(KINP.LT.KINPU) THEN                                            AUDB31    601
         J=KINP+1                                                       AUDB31    602
         XDAT=GAINS(J)                                                  AUDB31    603
         IIN=INPUTS(J)                                                  AUDB31    604
         DU0(IUB,IIN)=XDAT                                              AUDB31    605
         XUREF(19)=XDAT                                                 AUDB31    606
      ENDIF                                                             AUDB31    607
  330 CONTINUE                                                          AUDB31    608
C                                                                       AUDB31    609
      CFDN=VALIN(16)                                                    AUDB31    610
      GAINN=UDAT(JEI+1)/UDAT(JEI+2)                                     AUDB31    611
      PHI=GAINN*VALIN(19)                                               AUDB31    612
      U2=VALIN(4)*UDAT(JEI+2)-UDAT(JEI+6)*CFDN                          AUDB31    613
      DUB(IORD,IUB)=GAINN*U2*COS(PHI)                                   AUDB31    614
      IUB=IUB+1                                                         AUDB31    615
      DU0(IUB,4)=1.0                                                    AUDB31    616
      DUB(IORD,IUB)=SIN(PHI)*UDAT(JEI+2)                                AUDB31    617
      IUB=IUB+1                                                         AUDB31    618
      DU0(IUB,16)=1.0                                                   AUDB31    619
      DUB(IORD,IUB)=-SIN(PHI)*UDAT(JEI+6)                               AUDB31    620
      IF(LDEB) WRITE(IUD6,1080) LORD,IORD                               AUDB31    621
C                                                                       AUDB31    622
      RETURN                                                            AUDB31    623
 1080 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB31    624
C                                                                       AUDB31    625
C-----------------------------------------------------------------------AUDB31    626
C                                                                       AUDB31    627
      ENTRY AUDB42(LORD)                                                AUDB31    628
CD                                                                      AUDB31    629
CD    FOR BLOCK TYPE 42 (TYPE E34 EXCITER END BLOCK)                    AUDB31    630
CD                                                                      AUDB31    631
      LDEB=(JDEB(264).NE.0)                                             AUDB31    632
C                                                                       AUDB31    633
      IUB=IUB+1                                                         AUDB31    634
      IORD=IUDAT(JE4+LORD)                                              AUDB31    635
      JEI=JEB+2                                                         AUDB31    636
      KINT=KINPU                                                        AUDB31    637
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    638
      IF(KINT.LT.KINPU) THEN                                            AUDB31    639
         J=KINT+1                                                       AUDB31    640
         XDAT=GAINS(J)                                                  AUDB31    641
         IOUT=INPUTS(J)                                                 AUDB31    642
         CYB(IUB,IOUT)=XDAT                                             AUDB31    643
         XUY(19,IOUT)=XDAT                                              AUDB31    644
         GO TO 340                                                      AUDB31    645
      ENDIF                                                             AUDB31    646
      KINP=KINPU                                                        AUDB31    647
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    648
      IF(KINP.LT.KINPU) THEN                                            AUDB31    649
         J=KINP+1                                                       AUDB31    650
         XDAT=GAINS(J)                                                  AUDB31    651
         IIN=INPUTS(J)                                                  AUDB31    652
         DU0(IUB,IIN)=XDAT                                              AUDB31    653
         XUREF(19)=XDAT                                                 AUDB31    654
      ENDIF                                                             AUDB31    655
  340 CONTINUE                                                          AUDB31    656
C                                                                       AUDB31    657
      DUB(IORD,IUB)=1.0                                                 AUDB31    658
      IF(LDEB) WRITE(IUD6,1090) LORD,IORD                               AUDB31    659
C                                                                       AUDB31    660
      RETURN                                                            AUDB31    661
 1090 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB31    662
C                                                                       AUDB31    663
C-----------------------------------------------------------------------AUDB31    664
C                                                                       AUDB31    665
      ENTRY AUDB43(LORD)                                                AUDB31    666
CD                                                                      AUDB31    667
CD    FOR BLOCK TYPE 43 (TYPE RHL EXCITER END BLOCK)                    AUDB31    668
CD                                                                      AUDB31    669
      LDEB=(JDEB(264).NE.0)                                             AUDB31    670
C                                                                       AUDB31    671
      IUB=IUB+1                                                         AUDB31    672
      IORD=IUDAT(JE4+LORD)                                              AUDB31    673
      JEI=JEB+2                                                         AUDB31    674
      II=0                                                              AUDB31    675
      KINT=KINPU                                                        AUDB31    676
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB31    677
      IF(KINT.LT.KINPU) THEN                                            AUDB31    678
         DO 350 J=KINT+1,KINPU                                          AUDB31    679
         XDAT=GAINS(J)                                                  AUDB31    680
         IOUT=INPUTS(J)                                                 AUDB31    681
         II=II+1                                                        AUDB31    682
         IF(II.EQ.1) THEN                                               AUDB31    683
            CYB(IUB,IOUT)=XDAT                                          AUDB31    684
         ENDIF                                                          AUDB31    685
  350    CONTINUE                                                       AUDB31    686
      ENDIF                                                             AUDB31    687
      KINP=KINPU                                                        AUDB31    688
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB31    689
      IF(KINP.LT.KINPU) THEN                                            AUDB31    690
         DO 360 J=KINP+1,KINPU                                          AUDB31    691
         XDAT=GAINS(J)                                                  AUDB31    692
         IIN=INPUTS(J)                                                  AUDB31    693
         II=II+1                                                        AUDB31    694
         IF(II.EQ.1) THEN                                               AUDB31    695
            IF(IIN.LE.20) THEN                                          AUDB31    696
               DU0(IUB,IIN)=XDAT                                        AUDB31    697
            ELSE                                                        AUDB31    698
               DUR0(IUB,IIN-20)=XDAT                                    AUDB31    699
            ENDIF                                                       AUDB31    700
         ENDIF                                                          AUDB31    701
  360    CONTINUE                                                       AUDB31    702
      ENDIF                                                             AUDB31    703
C                                                                       AUDB31    704
      DUB(IORD,IUB)=1.0                                                 AUDB31    705
      IF(LDEB) WRITE(IUD6,1100) LORD,IORD                               AUDB31    706
C                                                                       AUDB31    707
      RETURN                                                            AUDB31    708
 1100 FORMAT(1X,'LORD,IORD: ',2I5)                                      AUDB31    709
      END                                                               AUDB31    710
