CFPRIME AUALN                                                           AUALN       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 AUALN(ISTATE,EPD,EPQ)                                  AUALN       3
CD                                                                      AUALN       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPES 1, 2 AND 3            AUALN       5
CD    UNDEREXCITED CURRENT LIMITER.                                     AUALN       6
CD                                                                      AUALN       7
      INCLUDE 'PARX.INS'                                                AUALN       8
      INCLUDE 'CNB8.INS'                                                AUALN       9
      INCLUDE 'CNEXC.INS'                                               AUALN      10
      INCLUDE 'CNSTAB.INS'                                              AUALN      11
      INCLUDE 'CNPARX.INS'                                              AUALN      12
      INCLUDE 'CNMDAT.INS'                                              AUALN      13
      INCLUDE 'CNXSTA.INS'                                              AUALN      14
      INCLUDE 'CNMSTA.INS'                                              AUALN      15
      INCLUDE 'CNUDMB.INS'                                              AUALN      16
      INCLUDE 'CNABAK.INS'                                              AUALN      17
C                                                                       AUALN      18
      DIMENSION ATMP(8,8),BTMP(8,8),CTMP(8,8),DTMP(8,8),BOTMP(8,8)      AUALN      19
      DIMENSION BVTMP(8,2),BITMP(8,2)                                   AUALN      20
      DIMENSION WM1(8,8),WM2(8,8),WM3(8,8),IWV1(8),IWV2(8)              AUALN      21
C                                                                       AUALN      22
      IU=0                                                              AUALN      23
      IY=0                                                              AUALN      24
      PSGN=SQRT(PDGN*PDGN+PQGN*PQGN)                                    AUALN      25
      SINPF=PQGN/PSGN                                                   AUALN      26
      COSPF=PDGN/PSGN                                                   AUALN      27
C                                                                       AUALN      28
      DO 50 I=1,8                                                       AUALN      29
      BVTMP(I,1)=0.0                                                    AUALN      30
      BVTMP(I,2)=0.0                                                    AUALN      31
      BITMP(I,1)=0.0                                                    AUALN      32
      BITMP(I,2)=0.0                                                    AUALN      33
      DO 50 J=1,8                                                       AUALN      34
      ATMP(I,J)=0.0                                                     AUALN      35
      BTMP(I,J)=0.0                                                     AUALN      36
      CTMP(I,J)=0.0                                                     AUALN      37
      DTMP(I,J)=0.0                                                     AUALN      38
      BOTMP(I,J)=0.0                                                    AUALN      39
  50  CONTINUE                                                          AUALN      40
C      CALL FMOVE(0,ATMP,ATMP,64)                                       AUALN      41
C      CALL FMOVE(0,BTMP,BTMP,64)                                       AUALN      42
C      CALL FMOVE(0,CTMP,CTMP,64)                                       AUALN      43
C      CALL FMOVE(0,DTMP,DTMP,64)                                       AUALN      44
C      CALL FMOVE(0,BOTMP,BOTMP,64)                                     AUALN      45
C      CALL FMOVE(0,BVTMP,BVTMP,16)                                     AUALN      46
C      CALL FMOVE(0,BITMP,BITMP,16)                                     AUALN      47
C                                                                       AUALN      48
      KUALN=IUALN                                                       AUALN      49
      IF (KUALN.GT.10) KUALN=KUALN-10                                   AUALN      50
      GOTO (100,200,300), KUALN                                         AUALN      51
C                                                                       AUALN      52
C     TYPE 1                                                            AUALN      53
C                                                                       AUALN      54
  100 CONTINUE                                                          AUALN      55
C                                                                       AUALN      56
C     FORM BLOCK STATE EQUATIONS                                        AUALN      57
C                                                                       AUALN      58
C     T1, T2 BLOCK                                                      AUALN      59
C                                                                       AUALN      60
      IY=IY+1                                                           AUALN      61
      IF (IDDAT(JU+10).NE.0) THEN                                       AUALN      62
         IU=IU+1                                                        AUALN      63
         T2I=1.0/DDAT(JU+10)                                            AUALN      64
         ATMP(IU,IU)=-DDAT(JU+9)*T2I                                    AUALN      65
         ATMP(IU,IU+1)=-T2I                                             AUALN      66
         ATMP(IU+1,IU)=1.0                                              AUALN      67
         BTMP(IU,IY)=DDAT(JU+1)*T2I                                     AUALN      68
         CTMP(IY,IU+1)=DDAT(JU+3)                                       AUALN      69
         IU=IU+1                                                        AUALN      70
      ELSE IF (IDDAT(JU+9).NE.0) THEN                                   AUALN      71
         IU=IU+1                                                        AUALN      72
         T1I=1.0/DDAT(JU+9)                                             AUALN      73
         ATMP(IU,IU)=-T1I                                               AUALN      74
         BTMP(IU,IY)=DDAT(JU+1)*T1I                                     AUALN      75
         CTMP(IY,IU)=DDAT(JU+3)                                         AUALN      76
      ELSE                                                              AUALN      77
         DTMP(IY,IY)=DDAT(JU+1)*DDAT(JU+3)                              AUALN      78
      END IF                                                            AUALN      79
      BVTMP(IY,1)=EPD/ET                                                AUALN      80
      BVTMP(IY,2)=EPQ/ET                                                AUALN      81
C                                                                       AUALN      82
C     T5, T6 BLOCK                                                      AUALN      83
C                                                                       AUALN      84
      IY=IY+1                                                           AUALN      85
      IF (IDDAT(JU+14).NE.0) THEN                                       AUALN      86
         IU=IU+1                                                        AUALN      87
         T6I=1.0/DDAT(JU+14)                                            AUALN      88
         ATMP(IU,IU)=-DDAT(JU+13)*T6I                                   AUALN      89
         ATMP(IU,IU+1)=-T6I                                             AUALN      90
         ATMP(IU+1,IU)=1.0                                              AUALN      91
         BTMP(IU,IY)=SINPF*T6I                                          AUALN      92
         CTMP(IY,IU+1)=DDAT(JU+5)                                       AUALN      93
         IU=IU+1                                                        AUALN      94
      ELSE IF (IDDAT(JU+13).NE.0) THEN                                  AUALN      95
         IU=IU+1                                                        AUALN      96
         T5I=1.0/DDAT(JU+13)                                            AUALN      97
         ATMP(IU,IU)=-T5I                                               AUALN      98
         BTMP(IU,IY)=SINPF*T5I                                          AUALN      99
         CTMP(IY,IU)=DDAT(JU+5)                                         AUALN     100
      ELSE                                                              AUALN     101
         DTMP(IY,IY)=SINPF*DDAT(JU+5)                                   AUALN     102
      END IF                                                            AUALN     103
      BITMP(IY,1)=DDAT(JU+2)*CDGN/CT                                    AUALN     104
      BITMP(IY,2)=DDAT(JU+2)*CQGN/CT                                    AUALN     105
C                                                                       AUALN     106
C     T3, T4 BLOCK                                                      AUALN     107
C                                                                       AUALN     108
      IY=IY+1                                                           AUALN     109
      IF (IDDAT(JU+12).NE.0) THEN                                       AUALN     110
         IU=IU+1                                                        AUALN     111
         T4I=1.0/DDAT(JU+12)                                            AUALN     112
         ATMP(IU,IU)=-DDAT(JU+11)*T4I                                   AUALN     113
         ATMP(IU,IU+1)=-T4I                                             AUALN     114
         ATMP(IU+1,IU)=1.0                                              AUALN     115
         BTMP(IU,IY)=COSPF*T4I                                          AUALN     116
         CTMP(IY,IU+1)=DDAT(JU+4)                                       AUALN     117
         IU=IU+1                                                        AUALN     118
      ELSE IF (IDDAT(JU+11).NE.0) THEN                                  AUALN     119
         IU=IU+1                                                        AUALN     120
         T3I=1.0/DDAT(JU+11)                                            AUALN     121
         ATMP(IU,IU)=-T3I                                               AUALN     122
         BTMP(IU,IY)=COSPF*T3I                                          AUALN     123
         CTMP(IY,IU)=DDAT(JU+4)                                         AUALN     124
      ELSE                                                              AUALN     125
         DTMP(IY,IY)=COSPF*DDAT(JU+4)                                   AUALN     126
      END IF                                                            AUALN     127
      BITMP(IY,1)=DDAT(JU+2)*CDGN/CT                                    AUALN     128
      BITMP(IY,2)=DDAT(JU+2)*CQGN/CT                                    AUALN     129
C                                                                       AUALN     130
C     T7, T8 BLOCK                                                      AUALN     131
C                                                                       AUALN     132
      IY=IY+1                                                           AUALN     133
      IF (IDDAT(JU+16).NE.0) THEN                                       AUALN     134
         IU=IU+1                                                        AUALN     135
         T8I=1.0/DDAT(JU+16)                                            AUALN     136
         ATMP(IU,IU)=-DDAT(JU+15)*T8I                                   AUALN     137
         ATMP(IU,IU+1)=-T8I                                             AUALN     138
         ATMP(IU+1,IU)=1.0                                              AUALN     139
         BTMP(IU,IY)=DDAT(JU+6)*T8I                                     AUALN     140
         CTMP(IY,IU)=DDAT(JU+7)                                         AUALN     141
         CTMP(IY,IU+1)=1.0                                              AUALN     142
         IU=IU+1                                                        AUALN     143
      ELSE IF (IDDAT(JU+15).NE.0) THEN                                  AUALN     144
         IU=IU+1                                                        AUALN     145
         T7I=1.0/DDAT(JU+15)                                            AUALN     146
         ATMP(IU,IU)=-T7I                                               AUALN     147
         BTMP(IU,IY)=DDAT(JU+6)*T7I                                     AUALN     148
         CTMP(IY,IU)=1.0-DDAT(JU+7)*T7I                                 AUALN     149
         DTMP(IY,IY)=DDAT(JU+6)*DDAT(JU+7)*T7I                          AUALN     150
      ELSE                                                              AUALN     151
         DTMP(IY,IY)=DDAT(JU+6)                                         AUALN     152
      END IF                                                            AUALN     153
      BOTMP(IY,1)=-1.0                                                  AUALN     154
      BOTMP(IY,2)=-1.0                                                  AUALN     155
      BOTMP(IY,3)=1.0                                                   AUALN     156
      GOTO 400                                                          AUALN     157
C                                                                       AUALN     158
C     TYPE 2                                                            AUALN     159
C                                                                       AUALN     160
  200 CONTINUE                                                          AUALN     161
C                                                                       AUALN     162
C     T1 BLOCK                                                          AUALN     163
C                                                                       AUALN     164
      IY=IY+1                                                           AUALN     165
      IF (IDDAT(JU+9).NE.0) THEN                                        AUALN     166
         IU=IU+1                                                        AUALN     167
         T1I=1.0/DDAT(JU+9)                                             AUALN     168
         ATMP(IU,IU)=-T1I                                               AUALN     169
         BTMP(IU,IY)=DDAT(JU+1)*T1I                                     AUALN     170
         CTMP(IY,IU)=1.0                                                AUALN     171
      ELSE                                                              AUALN     172
         DTMP(IY,IY)=DDAT(JU+1)                                         AUALN     173
      END IF                                                            AUALN     174
      BVTMP(IY,1)=CDGN                                                  AUALN     175
      BVTMP(IY,2)=CQGN                                                  AUALN     176
      BITMP(IY,1)=EPD                                                   AUALN     177
      BITMP(IY,2)=EPQ                                                   AUALN     178
C                                                                       AUALN     179
C     T2 BLOCK                                                          AUALN     180
C                                                                       AUALN     181
      IY=IY+1                                                           AUALN     182
      IF (IDDAT(JU+10).NE.0) THEN                                       AUALN     183
         IU=IU+1                                                        AUALN     184
         T2I=1.0/DDAT(JU+10)                                            AUALN     185
         ATMP(IU,IU)=-T2I                                               AUALN     186
         BTMP(IU,IY)=DDAT(JU+2)*T2I                                     AUALN     187
         CTMP(IY,IU)=1.0                                                AUALN     188
      ELSE                                                              AUALN     189
         DTMP(IY,IY)=DDAT(JU+2)                                         AUALN     190
      END IF                                                            AUALN     191
      BVTMP(IY,1)=-CQGN                                                 AUALN     192
      BVTMP(IY,2)=CDGN                                                  AUALN     193
      BITMP(IY,1)=EPQ                                                   AUALN     194
      BITMP(IY,2)=-EPD                                                  AUALN     195
C                                                                       AUALN     196
C     T3 BLOCK                                                          AUALN     197
C                                                                       AUALN     198
      IY=IY+1                                                           AUALN     199
      IF (IDDAT(JU+11).NE.0) THEN                                       AUALN     200
         IU=IU+1                                                        AUALN     201
         T3I=1.0/DDAT(JU+11)                                            AUALN     202
         ATMP(IU,IU)=-T3I                                               AUALN     203
         BTMP(IU,IY)=DDAT(JU+4)*T3I                                     AUALN     204
         CTMP(IY,IU)=1.0                                                AUALN     205
      ELSE                                                              AUALN     206
         DTMP(IY,IY)=DDAT(JU+4)                                         AUALN     207
      END IF                                                            AUALN     208
      BVTMP(IY,1)=2.0*EPD*DDAT(JU+3)**2.0                               AUALN     209
      BVTMP(IY,2)=2.0*EPQ*DDAT(JU+3)**2.0                               AUALN     210
C                                                                       AUALN     211
C     T4 BLOCK                                                          AUALN     212
C                                                                       AUALN     213
      IY=IY+1                                                           AUALN     214
      IF (IDDAT(JU+12).NE.0) THEN                                       AUALN     215
         IU=IU+1                                                        AUALN     216
         T4I=1.0/DDAT(JU+12)                                            AUALN     217
         ATMP(IU,IU)=-T4I                                               AUALN     218
         BTMP(IU,IY)=DDAT(JU+5)*T4I                                     AUALN     219
         CTMP(IY,IU)=1.0                                                AUALN     220
      ELSE                                                              AUALN     221
         DTMP(IY,IY)=DDAT(JU+5)                                         AUALN     222
      END IF                                                            AUALN     223
      BOTMP(IY,1)=1.0                                                   AUALN     224
      BOTMP(IY,2)=-1.0                                                  AUALN     225
      BOTMP(IY,3)=-1.0                                                  AUALN     226
C                                                                       AUALN     227
C     T5 BLOCK                                                          AUALN     228
C                                                                       AUALN     229
      IY=IY+1                                                           AUALN     230
      IF (IDDAT(JU+13).NE.0) THEN                                       AUALN     231
         IU=IU+1                                                        AUALN     232
         T5I=1.0/DDAT(JU+13)                                            AUALN     233
         ATMP(IU,IU)=-T5I                                               AUALN     234
         BTMP(IU,IY)=T5I                                                AUALN     235
         CTMP(IY,IU)=1.0                                                AUALN     236
      ELSE                                                              AUALN     237
         DTMP(IY,IY)=1.0                                                AUALN     238
      END IF                                                            AUALN     239
      BOTMP(IY,IY-1)=1.0                                                AUALN     240
C                                                                       AUALN     241
C     T6 BLOCK                                                          AUALN     242
C                                                                       AUALN     243
      IY=IY+1                                                           AUALN     244
      IF (IDDAT(JU+14).NE.0) THEN                                       AUALN     245
         IU=IU+1                                                        AUALN     246
         T6I=1.0/DDAT(JU+14)                                            AUALN     247
         ATMP(IU,IU)=-T6I                                               AUALN     248
         BTMP(IU,IY)=T6I                                                AUALN     249
         CTMP(IY,IU)=1.0                                                AUALN     250
      ELSE                                                              AUALN     251
         DTMP(IY,IY)=1.0                                                AUALN     252
      END IF                                                            AUALN     253
      BOTMP(IY,IY-1)=1.0                                                AUALN     254
C                                                                       AUALN     255
C     T7, T8 BLOCK                                                      AUALN     256
C                                                                       AUALN     257
      IY=IY+1                                                           AUALN     258
      IF (IDDAT(JU+16).NE.0) THEN                                       AUALN     259
         IU=IU+1                                                        AUALN     260
         T8I=1.0/DDAT(JU+16)                                            AUALN     261
         ATMP(IU,IU)=-DDAT(JU+15)*T8I                                   AUALN     262
         ATMP(IU,IU+1)=-T8I                                             AUALN     263
         ATMP(IU+1,IU)=1.0                                              AUALN     264
         BTMP(IU,IY)=T8I                                                AUALN     265
         CTMP(IY,IU)=DDAT(JU+7)                                         AUALN     266
         CTMP(IY,IU+1)=1.0                                              AUALN     267
         IU=IU+1                                                        AUALN     268
      ELSE IF (IDDAT(JU+15).NE.0) THEN                                  AUALN     269
         IU=IU+1                                                        AUALN     270
         T7I=1.0/DDAT(JU+15)                                            AUALN     271
         ATMP(IU,IU)=-T7I                                               AUALN     272
         BTMP(IU,IY)=T7I                                                AUALN     273
         CTMP(IY,IU)=1.0-DDAT(JU+7)*T7I                                 AUALN     274
         DTMP(IY,IY)=DDAT(JU+7)*T7I                                     AUALN     275
      ELSE                                                              AUALN     276
         DTMP(IY,IY)=1.0                                                AUALN     277
      END IF                                                            AUALN     278
      BOTMP(IY,IY-1)=1.0                                                AUALN     279
      GOTO 400                                                          AUALN     280
C                                                                       AUALN     281
C     TYPE 3                                                            AUALN     282
C                                                                       AUALN     283
  300 CONTINUE                                                          AUALN     284
C                                                                       AUALN     285
C     T1 BLOCK                                                          AUALN     286
C                                                                       AUALN     287
      IY=IY+1                                                           AUALN     288
      IF (IDDAT(JU+9).NE.0) THEN                                        AUALN     289
         IU=IU+1                                                        AUALN     290
         T1I=1.0/DDAT(JU+9)                                             AUALN     291
         ATMP(IU,IU)=-T1I                                               AUALN     292
         BTMP(IU,IY)=DDAT(JU+1)*T1I                                     AUALN     293
         CTMP(IY,IU)=1.0                                                AUALN     294
      ELSE                                                              AUALN     295
         DTMP(IY,IY)=DDAT(JU+1)                                         AUALN     296
      END IF                                                            AUALN     297
      BVTMP(IY,1)=CDGN                                                  AUALN     298
      BVTMP(IY,2)=CQGN                                                  AUALN     299
      BITMP(IY,1)=EPD                                                   AUALN     300
      BITMP(IY,2)=EPQ                                                   AUALN     301
C                                                                       AUALN     302
C     T2 BLOCK                                                          AUALN     303
C                                                                       AUALN     304
      IY=IY+1                                                           AUALN     305
      IF (IDDAT(JU+10).NE.0) THEN                                       AUALN     306
         IU=IU+1                                                        AUALN     307
         T2I=1.0/DDAT(JU+10)                                            AUALN     308
         ATMP(IU,IU)=-T2I                                               AUALN     309
         BTMP(IU,IY)=DDAT(JU+2)*T2I                                     AUALN     310
         CTMP(IY,IU)=1.0                                                AUALN     311
      ELSE                                                              AUALN     312
         DTMP(IY,IY)=DDAT(JU+2)                                         AUALN     313
      END IF                                                            AUALN     314
      BVTMP(IY,1)=-CQGN                                                 AUALN     315
      BVTMP(IY,2)=CDGN                                                  AUALN     316
      BITMP(IY,1)=EPQ                                                   AUALN     317
      BITMP(IY,2)=-EPD                                                  AUALN     318
C                                                                       AUALN     319
C     T3 BLOCK                                                          AUALN     320
C                                                                       AUALN     321
      IY=IY+1                                                           AUALN     322
      IF (IDDAT(JU+11).NE.0) THEN                                       AUALN     323
         IU=IU+1                                                        AUALN     324
         T3I=1.0/DDAT(JU+11)                                            AUALN     325
         ATMP(IU,IU)=-T3I                                               AUALN     326
         BTMP(IU,IY)=DDAT(JU+3)*T3I                                     AUALN     327
         CTMP(IY,IU)=1.0                                                AUALN     328
      ELSE                                                              AUALN     329
         DTMP(IY,IY)=DDAT(JU+3)                                         AUALN     330
      END IF                                                            AUALN     331
      BVTMP(IY,1)=EPD/ET                                                AUALN     332
      BVTMP(IY,2)=EPQ/ET                                                AUALN     333
C                                                                       AUALN     334
C     T6 BLOCK                                                          AUALN     335
C                                                                       AUALN     336
      IY=IY+1                                                           AUALN     337
      IF (IDDAT(JU+14).NE.0) THEN                                       AUALN     338
         IU=IU+1                                                        AUALN     339
         T6I=1.0/DDAT(JU+14)                                            AUALN     340
         ATMP(IU,IU)=-T6I                                               AUALN     341
         BTMP(IU,IY)=DDAT(JU+6)*T6I                                     AUALN     342
         CTMP(IY,IU)=1.0                                                AUALN     343
      ELSE                                                              AUALN     344
         DTMP(IY,IY)=DDAT(JU+6)                                         AUALN     345
      END IF                                                            AUALN     346
C                                                                       AUALN     347
C     DEL EFD TERM TO BE ADDED                                          AUALN     348
C                                                                       AUALN     349
                                                                        AUALN     350
C                                                                       AUALN     351
C     T4 BLOCK                                                          AUALN     352
C                                                                       AUALN     353
      IY=IY+1                                                           AUALN     354
      IF (IDDAT(JU+12).NE.0) THEN                                       AUALN     355
         IU=IU+1                                                        AUALN     356
         T4I=1.0/DDAT(JU+12)                                            AUALN     357
         ATMP(IU,IU)=-T4I                                               AUALN     358
         BTMP(IU,IY)=DDAT(JU+4)*T4I                                     AUALN     359
         CTMP(IY,IU)=1.0                                                AUALN     360
      ELSE                                                              AUALN     361
         DTMP(IY,IY)=DDAT(JU+4)                                         AUALN     362
      END IF                                                            AUALN     363
      BOTMP(IY,1)=1.0                                                   AUALN     364
      BOTMP(IY,2)=1.0                                                   AUALN     365
      BOTMP(IY,3)=1.0                                                   AUALN     366
      BOTMP(IY,4)=-1.0                                                  AUALN     367
C                                                                       AUALN     368
C     T5 BLOCK                                                          AUALN     369
C                                                                       AUALN     370
      IY=IY+1                                                           AUALN     371
      IF (IDDAT(JU+13).NE.0) THEN                                       AUALN     372
         IU=IU+1                                                        AUALN     373
         T5I=1.0/DDAT(JU+13)                                            AUALN     374
         ATMP(IU,IU)=-(1.0-DDAT(JU+5))*T5I                              AUALN     375
         BTMP(IU,IY)=T5I                                                AUALN     376
         CTMP(IY,IU)=DDAT(JU+5)                                         AUALN     377
         DTMP(IY,IY)=1.0                                                AUALN     378
      ELSE                                                              AUALN     379
         DTMP(IY,IY)=1.0/(1.0-DDAT(JU+5))                               AUALN     380
      END IF                                                            AUALN     381
      BOTMP(IY,IY-1)=1.0                                                AUALN     382
C                                                                       AUALN     383
  400 CONTINUE                                                          AUALN     384
C                                                                       AUALN     385
C     ELIMINATE AUXILUARY VARIABLES                                     AUALN     386
C                                                                       AUALN     387
C     INVERSE(G)                                                        AUALN     388
C                                                                       AUALN     389
      DO 500 I=1,IY                                                     AUALN     390
         DO 510 J=1,IY                                                  AUALN     391
            SUM=0.0                                                     AUALN     392
            DO 520 L=1,IY                                               AUALN     393
               SUM=SUM+DTMP(I,L)*BOTMP(L,J)                             AUALN     394
  520       CONTINUE                                                    AUALN     395
            WM1(I,J)=-SUM                                               AUALN     396
  510    CONTINUE                                                       AUALN     397
         WM1(I,I)=1.0+WM1(I,I)                                          AUALN     398
  500 CONTINUE                                                          AUALN     399
C                                                                       AUALN     400
      CALL MINVRS(WM1,8,IY,DETA,IER,IWV1,IWV2)                          AUALN     401
C                                                                       AUALN     402
C     INVERSE(G)*CT, INVERSE(G)*DT                                      AUALN     403
C                                                                       AUALN     404
      DO 530 I=1,IY                                                     AUALN     405
         DO 540 J=1,IU                                                  AUALN     406
            SUM=0.0                                                     AUALN     407
            DO 550 L=1,IY                                               AUALN     408
               SUM=SUM+WM1(I,L)*CTMP(L,J)                               AUALN     409
  550       CONTINUE                                                    AUALN     410
            WM2(I,J)=SUM                                                AUALN     411
  540    CONTINUE                                                       AUALN     412
         DO 560 J=1,IY                                                  AUALN     413
            SUM=0.0                                                     AUALN     414
            DO 570 L=1,IY                                               AUALN     415
               SUM=SUM+WM1(I,L)*DTMP(L,J)                               AUALN     416
  570       CONTINUE                                                    AUALN     417
            WM3(I,J)=SUM                                                AUALN     418
  560    CONTINUE                                                       AUALN     419
  530 CONTINUE                                                          AUALN     420
C                                                                       AUALN     421
C     INVERSE(G)*DT*BVT, INVERSE(G)*DT*BIT                              AUALN     422
C                                                                       AUALN     423
      DO 580 I=1,IY                                                     AUALN     424
         DO 590 J=1,2                                                   AUALN     425
            SUM=0.0                                                     AUALN     426
            DO 600 L=1,IY                                               AUALN     427
               SUM=SUM+WM3(I,L)*BVTMP(L,J)                              AUALN     428
  600       CONTINUE                                                    AUALN     429
            DTMP(I,J)=SUM                                               AUALN     430
  590    CONTINUE                                                       AUALN     431
         DO 610 J=1,2                                                   AUALN     432
            SUM=0.0                                                     AUALN     433
            DO 620 L=1,IY                                               AUALN     434
               SUM=SUM+WM3(I,L)*BITMP(L,J)                              AUALN     435
  620       CONTINUE                                                    AUALN     436
            DTMP(I,J+2)=SUM                                             AUALN     437
  610    CONTINUE                                                       AUALN     438
  580 CONTINUE                                                          AUALN     439
C                                                                       AUALN     440
C     BOT*INVERSE(G)*CT                                                 AUALN     441
C                                                                       AUALN     442
      DO 630 I=1,IY                                                     AUALN     443
         DO 640 J=1,IU                                                  AUALN     444
            SUM=0.0                                                     AUALN     445
            DO 650 L=1,IY                                               AUALN     446
               SUM=SUM+BOTMP(I,L)*WM2(L,J)                              AUALN     447
  650       CONTINUE                                                    AUALN     448
            WM1(I,J)=SUM                                                AUALN     449
  640    CONTINUE                                                       AUALN     450
  630 CONTINUE                                                          AUALN     451
C                                                                       AUALN     452
C     A ARRAY                                                           AUALN     453
C                                                                       AUALN     454
      DO 660 I=1,IU                                                     AUALN     455
         DO 670 J=1,IU                                                  AUALN     456
            SUM=0.0                                                     AUALN     457
            DO 680 L=1,IY                                               AUALN     458
               SUM=SUM+BTMP(I,L)*WM1(L,J)                               AUALN     459
  680       CONTINUE                                                    AUALN     460
            A(ISTATE+I,ISTATE+J)=ATMP(I,J)+SUM                          AUALN     461
  670    CONTINUE                                                       AUALN     462
  660 CONTINUE                                                          AUALN     463
C                                                                       AUALN     464
C     BVT+BOT*INVERSE(G)*DT*BVT, BIT+BOT*INVERSE(G)*DT*BIT              AUALN     465
C                                                                       AUALN     466
      DO 690 I=1,IY                                                     AUALN     467
         DO 700 J=1,2                                                   AUALN     468
            SUM1=0.0                                                    AUALN     469
            SUM2=0.0                                                    AUALN     470
            DO 710 L=1,IY                                               AUALN     471
               SUM1=SUM1+BOTMP(I,L)*DTMP(L,J)                           AUALN     472
               SUM2=SUM2+BOTMP(I,L)*DTMP(L,J+2)                         AUALN     473
  710       CONTINUE                                                    AUALN     474
            BVTMP(I,J)=BVTMP(I,J)+SUM1                                  AUALN     475
            BITMP(I,J)=BITMP(I,J)+SUM2                                  AUALN     476
  700    CONTINUE                                                       AUALN     477
  690 CONTINUE                                                          AUALN     478
C                                                                       AUALN     479
C     B AND BC ARRAYS                                                   AUALN     480
C                                                                       AUALN     481
      DO 720 I=1,IU                                                     AUALN     482
         DO 730 J=1,2                                                   AUALN     483
            SUM1=0.0                                                    AUALN     484
            SUM2=0.0                                                    AUALN     485
            DO 740 L=1,IY                                               AUALN     486
               SUM1=SUM1+BTMP(I,L)*BVTMP(L,J)                           AUALN     487
               SUM2=SUM2+BTMP(I,L)*BITMP(L,J)                           AUALN     488
  740       CONTINUE                                                    AUALN     489
            B(ISTATE+I,J)=SUM1                                          AUALN     490
            BC(ISTATE+I,J)=SUM2                                         AUALN     491
  730    CONTINUE                                                       AUALN     492
  720 CONTINUE                                                          AUALN     493
C                                                                       AUALN     494
C     INTERCONNECTION WITH EXCITER (OUTPUT EQUATION)                    AUALN     495
C                                                                       AUALN     496
      IF (IEXN.NE.50) THEN                                              AUALN     497
C                                                                       AUALN     498
      DO 750 I=1,4                                                      AUALN     499
         IF (IUST(I).EQ.0) GOTO 760                                     AUALN     500
         IWS1=IUST(I)                                                   AUALN     501
         WS1=GUST(I)                                                    AUALN     502
         DO 770 J=1,IU                                                  AUALN     503
            A(IWS1,ISTATE+J)=WS1*WM2(IY,J)                              AUALN     504
  770    CONTINUE                                                       AUALN     505
         B(IWS1,1)=B(IWS1,1)+WS1*DTMP(IY,1)                             AUALN     506
         B(IWS1,2)=B(IWS1,2)+WS1*DTMP(IY,2)                             AUALN     507
         BC(IWS1,1)=BC(IWS1,1)+WS1*DTMP(IY,3)                           AUALN     508
         BC(IWS1,2)=BC(IWS1,2)+WS1*DTMP(IY,4)                           AUALN     509
  750 CONTINUE                                                          AUALN     510
C                                                                       AUALN     511
      ELSE                                                              AUALN     512
C                                                                       AUALN     513
C     CONNECTION WITH A USER DEFINED EXCITER                            AUALN     514
C                                                                       AUALN     515
      MSEXC=MSUDM(1,1)                                                  AUALN     516
      IWS1=ISTATE-MSEXC                                                 AUALN     517
      DO 780 I=1,MSEXC+1                                                AUALN     518
         IWS2=IWS1+I                                                    AUALN     519
         IF (I.GT.MSEXC) IWS2=3                                         AUALN     520
         DO 790 J=1,IU                                                  AUALN     521
            A(IWS2,ISTATE+J)=BXVS(I)*WM2(IY,J)                          AUALN     522
  790    CONTINUE                                                       AUALN     523
         B(IWS2,1)=B(IWS2,1)+BXVU(I)*DTMP(IY,1)                         AUALN     524
         B(IWS2,2)=B(IWS2,2)+BXVU(I)*DTMP(IY,2)                         AUALN     525
         BC(IWS2,1)=BC(IWS2,1)+BXVU(I)*DTMP(IY,3)                       AUALN     526
         BC(IWS2,2)=BC(IWS2,2)+BXVU(I)*DTMP(IY,4)                       AUALN     527
  780 CONTINUE                                                          AUALN     528
C                                                                       AUALN     529
      END IF                                                            AUALN     530
C                                                                       AUALN     531
  760 CONTINUE                                                          AUALN     532
C                                                                       AUALN     533
      ISTATE=ISTATE+IU                                                  AUALN     534
C                                                                       AUALN     535
      RETURN                                                            AUALN     536
      END                                                               AUALN     537
