CFPRIME DGENLN                                                          DGENLN      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 DGENLN(IPATH,EPD,EPQ,MD,MQ,IDMSN)                      DGENLN      3
CD                                                                      DGENLN      4
CD    TO FORMULATE JACOBIAN MATRICES OF DETAILED MACHINE FOR USE IN THE DGENLN      5
CD    IMPLICIT INTEGRATION METHOD.                                      DGENLN      6
CD                                                                      DGENLN      7
CD    THERE ARE THREE STEPS IN THE PROCEDURE                            DGENLN      8
CD                                                                      DGENLN      9
CD    1. FORMULATE SEPARATELY THE LINEARIZED EQUATIONS OF SYNCHRONOUS   DGENLN     10
CD       MACHINE, EXCITER, STABILIZER, GOVERNOR AND ANY OTHER CONTROL   DGENLN     11
CD       SYSTEMS (NOTE THAT FOR USER DEFINED CONTROL MODEL, THIS PART   DGENLN     12
CD       IS DONE EARLIER IN SUBROUTINE GXDOT BY CALLING AEXC, ASTAB,    DGENLN     13
CD       AUAL AND AGOV).                                                DGENLN     14
CD                                                                      DGENLN     15
CD    2. INTERCONNECT ALL ABOVE EQUATIONS TO FORM THE OVERALL LINEARIZEDDGENLN     16
CD       EQUATIONS OF THE MACHINE.                                      DGENLN     17
CD                                                                      DGENLN     18
CD    3. COMPUTE THE FINAL JACOBIAN MATRICES IN TERMS OF THE CURRENT    DGENLN     19
CD       STEP SIZE. FACTORIZED MATRIX A AND SOLVE INVERSE(A)*B. STORE   DGENLN     20
CD       ALL MATRICES IN THE PERMANENT ARRAYS.                          DGENLN     21
CD                                                                      DGENLN     22
      INCLUDE 'PARX.INS'                                                DGENLN     23
      INCLUDE 'CNB4.INS'                                                DGENLN     24
      INCLUDE 'CNB8.INS'                                                DGENLN     25
      INCLUDE 'CNB9.INS'                                                DGENLN     26
      INCLUDE 'CNB19.INS'                                               DGENLN     27
      INCLUDE 'CNEXC.INS'                                               DGENLN     28
      INCLUDE 'CNUDM.INS'                                               DGENLN     29
      INCLUDE 'CNUDMA.INS'                                              DGENLN     30
      INCLUDE 'CNUDMB.INS'                                              DGENLN     31
      INCLUDE 'CNUDMK.INS'                                              DGENLN     32
      INCLUDE 'CNGDAT.INS'                                              DGENLN     33
      INCLUDE 'CNVOLT.INS'                                              DGENLN     34
      INCLUDE 'CNPRGV.INS'                                              DGENLN     35
      INCLUDE 'CNSTAB.INS'                                              DGENLN     36
      INCLUDE 'CNUVAR.INS'                                              DGENLN     37
      INCLUDE 'CNYVAR.INS'                                              DGENLN     38
      INCLUDE 'CNMYVA.INS'                                              DGENLN     39
      INCLUDE 'CNMDAT.INS'                                              DGENLN     40
      INCLUDE 'CNMSTA.INS'                                              DGENLN     41
      INCLUDE 'CNFLAG.INS'                                              DGENLN     42
      INCLUDE 'CNPARX.INS'                                              DGENLN     43
      INCLUDE 'CNUNIT.INS'                                              DGENLN     44
      INCLUDE 'CNJCOB.INS'                                              DGENLN     45
      INCLUDE 'CNXSTA.INS'                                              DGENLN     46
      INCLUDE 'CNIMPR.INS'                                              DGENLN     47
      INCLUDE 'CNABAK.INS'                                              DGENLN     48
C                                                                       DGENLN     49
      DIMENSION ALD(3,3),ALQ(3,3),RD(3),RQ(3)                           DGENLN     50
C                                                                       DGENLN     51
      LDEB=.FALSE.                                                      DGENLN     52
C                                                                       DGENLN     53
      VER=0.0                                                           DGENLN     54
      VEI=0.0                                                           DGENLN     55
      ISTATE=0                                                          DGENLN     56
      ICOLBV=1                                                          DGENLN     57
      NBR(1)=ICBUSN                                                     DGENLN     58
C                                                                       DGENLN     59
C     OBTAIN MACHINE DATA FROM DDAT ARRAY                               DGENLN     60
C                                                                       DGENLN     61
      HM=DDAT(JG+1)                                                     DGENLN     62
C                                                                       DGENLN     63
C     HM <= 1.0E-5 IF THE MACHINE IS OUT OF SERVICE                     DGENLN     64
C                                                                       DGENLN     65
      IF (HM.LT.1.0E-5) GOTO 9999                                       DGENLN     66
C                                                                       DGENLN     67
         JSM=MSTATE(1,N)                                                DGENLN     68
       DAMPK=DDAT(JG+2)                                                 DGENLN     69
      WXBASE=DDAT(JG+5)                                                 DGENLN     70
C                                                                       DGENLN     71
        XAD=DDAT(JG+6)                                                  DGENLN     72
        XAQ=DDAT(JG+7)                                                  DGENLN     73
        XAL=DDAT(JG+8)                                                  DGENLN     74
         RA=DDAT(JG+9)                                                  DGENLN     75
      RD(1)=DDAT(JG+11)*WXBASE                                          DGENLN     76
      RD(2)=DDAT(JG+15)                                                 DGENLN     77
      RD(3)=DDAT(JG+19)                                                 DGENLN     78
      RQ(1)=DDAT(JG+13)                                                 DGENLN     79
      RQ(2)=DDAT(JG+17)                                                 DGENLN     80
      RQ(3)=DDAT(JG+21)                                                 DGENLN     81
        AXD=DDAT(JG+22)                                                 DGENLN     82
        AXQ=DDAT(JG+23)                                                 DGENLN     83
C                                                                       DGENLN     84
      ALD(1,1)=DDAT(JG+36)                                              DGENLN     85
      ALD(2,2)=DDAT(JG+37)                                              DGENLN     86
      ALD(3,3)=DDAT(JG+38)                                              DGENLN     87
C                                                                       DGENLN     88
      ALQ(1,1)=1.0/DDAT(JG+12)                                          DGENLN     89
      ALQ(2,2)=1.0/DDAT(JG+16)                                          DGENLN     90
      ALQ(3,3)=1.0/DDAT(JG+20)                                          DGENLN     91
C                                                                       DGENLN     92
C     NOTE THAT CROSS MUTUAL REACTANCE IS NOT CONSIDERED CURRENTLY      DGENLN     93
C                                                                       DGENLN     94
C      XKC1=DDAT(JG+24)                                                 DGENLN     95
C      XKC2=DDAT(JG+25)                                                 DGENLN     96
C                                                                       DGENLN     97
      SD=DDAT(JG+32)                                                    DGENLN     98
      SQ=DDAT(JG+33)                                                    DGENLN     99
      SDI=AJCOB(IAIDEX+1)                                               DGENLN    100
      SQI=AJCOB(IAIDEX+2)                                               DGENLN    101
C                                                                       DGENLN    102
      MD2=MD+2                                                          DGENLN    103
      MT=MD2+MQ                                                         DGENLN    104
C                                                                       DGENLN    105
C     FULL SATURATED REACTANCE                                          DGENLN    106
C                                                                       DGENLN    107
      XADS=XAD*SD                                                       DGENLN    108
      XAQS=XAQ*SQ                                                       DGENLN    109
C                                                                       DGENLN    110
C     INCREMENTAL SATURATED REACTANCE                                   DGENLN    111
C                                                                       DGENLN    112
      XADSI=XAD*SDI                                                     DGENLN    113
      XAQSI=XAQ*SQI                                                     DGENLN    114
C                                                                       DGENLN    115
C     TRANSFORM THE MACHINE VOLTAGE AND CURRENT FROM                    DGENLN    116
C     SYSTEM REFERENCE FRAME TO MACHINE REFERENCE FRAME                 DGENLN    117
C                                                                       DGENLN    118
      SN=SIN(DELOMG)                                                    DGENLN    119
      COSINE=COS(DELOMG)                                                DGENLN    120
C                                                                       DGENLN    121
      EPDM=COSINE*EPD+SN*EPQ                                            DGENLN    122
      EPQM=-SN*EPD+COSINE*EPQ                                           DGENLN    123
      ET=SQRT(EPD*EPD+EPQ*EPQ)                                          DGENLN    124
C                                                                       DGENLN    125
      CPDM=COSINE*CDGN+SN*CQGN                                          DGENLN    126
      CPQM=-SN*CDGN+COSINE*CQGN                                         DGENLN    127
      CT=SQRT(CDGN*CDGN+CQGN*CQGN)                                      DGENLN    128
C                                                                       DGENLN    129
      CCFDN=(EPQM+RA*CPQM+(XAL+XADS)*CPDM)/XADS                         DGENLN    130
C                                                                       DGENLN    131
C     INITIALIZE A, B, BC AND AK ARRAY.                                 DGENLN    132
C                                                                       DGENLN    133
      DO 10 I=1,IDMSN                                                   DGENLN    134
         DO 20 J=1,IDMSN                                                DGENLN    135
            A(I,J)=0.0                                                  DGENLN    136
   20    CONTINUE                                                       DGENLN    137
         DO 30 J=1,40                                                   DGENLN    138
            B(I,J)=0.0                                                  DGENLN    139
            B(I,J)=0.0                                                  DGENLN    140
   30    CONTINUE                                                       DGENLN    141
         BC(I,1)=0.0                                                    DGENLN    142
         BC(I,2)=0.0                                                    DGENLN    143
   10 CONTINUE                                                          DGENLN    144
      DO 40 I=2,MT                                                      DGENLN    145
         AK(1,I)=0.0                                                    DGENLN    146
         AK(2,I)=0.0                                                    DGENLN    147
   40 CONTINUE                                                          DGENLN    148
C                                                                       DGENLN    149
C     CALCULATE A(PSI,PSI) (ELECTRICAL PART)                            DGENLN    150
C                                                                       DGENLN    151
      CFDD=1.0/(1.0/XADSI+AXD)                                          DGENLN    152
      CFQQ=1.0/(1.0/XAQSI+AXQ)                                          DGENLN    153
C                                                                       DGENLN    154
      DO 100 I=1,MD                                                     DGENLN    155
         I2=I+2                                                         DGENLN    156
         DO 110 J=1,MD                                                  DGENLN    157
            A(I2,J+2)=CFDD*RD(I)*ALD(I,I)*ALD(J,J)                      DGENLN    158
  110    CONTINUE                                                       DGENLN    159
         A(I2,I2)=A(I2,I2)-RD(I)*ALD(I,I)                               DGENLN    160
  100 CONTINUE                                                          DGENLN    161
C                                                                       DGENLN    162
      DO 120 I=1,MQ                                                     DGENLN    163
         IMD2=I+MD2                                                     DGENLN    164
         DO 130 J=1,MQ                                                  DGENLN    165
            A(IMD2,J+MD2)=CFQQ*RQ(I)*ALQ(I,I)*ALQ(J,J)                  DGENLN    166
  130    CONTINUE                                                       DGENLN    167
         A(IMD2,IMD2)=A(IMD2,IMD2)-RQ(I)*ALQ(I,I)                       DGENLN    168
  120 CONTINUE                                                          DGENLN    169
C                                                                       DGENLN    170
C     CALCULATE BC(PSI,I) (ELECTRICAL PART)                             DGENLN    171
C     NOTE THAT THE RESULTS ARE TRANSFORMED INTO NETWORK COORDINATE     DGENLN    172
C                                                                       DGENLN    173
      DO 140 I=1,MD                                                     DGENLN    174
         I2=I+2                                                         DGENLN    175
         DO 150 J=1,MD                                                  DGENLN    176
            BC(I2,1)=BC(I2,1)+A(I2,J+2)                                 DGENLN    177
  150    CONTINUE                                                       DGENLN    178
         BC(I2,1)=XADSI*BC(I2,1)                                        DGENLN    179
         BC(I2,2)=BC(I2,1)*SN                                           DGENLN    180
         BC(I2,1)=BC(I2,1)*COSINE                                       DGENLN    181
  140 CONTINUE                                                          DGENLN    182
C                                                                       DGENLN    183
      DO 160 I=1,MQ                                                     DGENLN    184
         IMD2=I+MD2                                                     DGENLN    185
         DO 170 J=1,MQ                                                  DGENLN    186
            BC(IMD2,2)=BC(IMD2,2)+A(IMD2,J+MD2)                         DGENLN    187
  170    CONTINUE                                                       DGENLN    188
         BC(IMD2,2)=XAQSI*BC(IMD2,2)                                    DGENLN    189
         BC(IMD2,1)=-BC(IMD2,2)*SN                                      DGENLN    190
         BC(IMD2,2)=BC(IMD2,2)*COSINE                                   DGENLN    191
  160 CONTINUE                                                          DGENLN    192
C                                                                       DGENLN    193
C     CALCULATE AK(PSI) (ELECTRICAL PART)                               DGENLN    194
C                                                                       DGENLN    195
      WS1=XADSI*(1.0-CFDD*AXD)                                          DGENLN    196
      WSD=0.0                                                           DGENLN    197
      DO 180 I=1,MD                                                     DGENLN    198
         AK(2,I+2)=WS1*ALD(I,I)                                         DGENLN    199
         WSD=WSD+AK(2,I+2)                                              DGENLN    200
  180 CONTINUE                                                          DGENLN    201
      CAF2=AK(2,3)                                                      DGENLN    202
C                                                                       DGENLN    203
      WS1=XAQSI*(CFQQ*AXQ-1.0)                                          DGENLN    204
      WSQ=0.0                                                           DGENLN    205
      DO 190 I=1,MQ                                                     DGENLN    206
         AK(1,I+MD2)=WS1*ALQ(I,I)                                       DGENLN    207
         WSQ=WSQ-AK(1,I+MD2)                                            DGENLN    208
  190 CONTINUE                                                          DGENLN    209
C                                                                       DGENLN    210
C     CALCULATE XDE(=Xdsi'') AND XQE(=Xqsi'')                           DGENLN    211
C                                                                       DGENLN    212
      XDE=XAL+XADSI*(1.0-WSD)                                           DGENLN    213
      XQE=XAL+XAQSI*(1.0-WSQ)                                           DGENLN    214
C                                                                       DGENLN    215
C     CALCULATE OPERATING-POINT-DEPEDENT AND                            DGENLN    216
C     MECHANICAL PART OF A, B AND AK                                    DGENLN    217
C                                                                       DGENLN    218
      FAD=CPDM*(XAL+XADS-XQE)-CCFDN*XADS                                DGENLN    219
      FAQ=CPQM*(XAL+XAQS-XDE)                                           DGENLN    220
C                                                                       DGENLN    221
      DO 200 I=1,MD                                                     DGENLN    222
         I2=I+2                                                         DGENLN    223
         DO 210 J=1,MD                                                  DGENLN    224
            A(I2,2)=A(I2,2)+A(I2,J+2)*XADSI*CPQM                        DGENLN    225
  210    CONTINUE                                                       DGENLN    226
         A(1,I2)=-CPQM*AK(2,I2)*HM                                      DGENLN    227
  200 CONTINUE                                                          DGENLN    228
C                                                                       DGENLN    229
      DO 220 I=1,MQ                                                     DGENLN    230
         IMD2=I+MD2                                                     DGENLN    231
         DO 230 J=1,MQ                                                  DGENLN    232
            A(IMD2,2)=A(IMD2,2)-A(IMD2,J+MD2)*XAQSI*CPDM                DGENLN    233
  230    CONTINUE                                                       DGENLN    234
         A(1,IMD2)=-CPDM*AK(1,IMD2)*HM                                  DGENLN    235
  220 CONTINUE                                                          DGENLN    236
C                                                                       DGENLN    237
      A(1,1)=-DAMPK*HM                                                  DGENLN    238
      A(2,1)=1.0                                                        DGENLN    239
      A(1,2)=-(CPQM*FAQ+CPDM*FAD)*HM                                    DGENLN    240
C                                                                       DGENLN    241
C     ADD UNIFIED DAMPING TERM IF NECESSARY                             DGENLN    242
C                                                                       DGENLN    243
      SDAMP=0.0                                                         DGENLN    244
      IF (LSDAMP) A(1,1)=A(1,1)-SDAMP                                   DGENLN    245
C                                                                       DGENLN    246
      BC(1,1)=-(FAQ*COSINE+FAD*SN)*HM                                   DGENLN    247
      BC(1,2)=-(FAQ*SN-FAD*COSINE)*HM                                   DGENLN    248
C                                                                       DGENLN    249
      DO 240 I=1,MD                                                     DGENLN    250
         I2=I+2                                                         DGENLN    251
         AK(1,I2)=-SN*AK(2,I2)                                          DGENLN    252
         AK(2,I2)=COSINE*AK(2,I2)                                       DGENLN    253
  240 CONTINUE                                                          DGENLN    254
C                                                                       DGENLN    255
      DO 250 I=1,MQ                                                     DGENLN    256
         IMD2=I+MD2                                                     DGENLN    257
         AK(2,IMD2)=SN*AK(1,IMD2)                                       DGENLN    258
         AK(1,IMD2)=COSINE*AK(1,IMD2)                                   DGENLN    259
  250 CONTINUE                                                          DGENLN    260
C                                                                       DGENLN    261
      AK(1,2)=FAD*COSINE-FAQ*SN                                         DGENLN    262
      AK(2,2)=FAD*SN+FAQ*COSINE                                         DGENLN    263
C                                                                       DGENLN    264
C     FORM Z MATRIX AND YD = INVERSE(Z)                                 DGENLN    265
C                                                                       DGENLN    266
      Z11=RA-SN*COSINE*(XDE-XQE)                                        DGENLN    267
      Z12=-0.5*(XQE+XDE-(XDE-XQE)*(COSINE*COSINE-SN*SN))                DGENLN    268
      Z21=0.5*(XQE+XDE+(XDE-XQE)*(COSINE*COSINE-SN*SN))                 DGENLN    269
      Z22=RA+SN*COSINE*(XDE-XQE)                                        DGENLN    270
C                                                                       DGENLN    271
      DET=RA*RA+XDE*XQE                                                 DGENLN    272
      YD(1,1)=Z22/DET                                                   DGENLN    273
      YD(2,2)=Z11/DET                                                   DGENLN    274
      YD(1,2)=-Z12/DET                                                  DGENLN    275
      YD(2,1)=-Z21/DET                                                  DGENLN    276
C                                                                       DGENLN    277
C     FORM THE FINAL AK ARRAY (INCLUSION OF TRANSFORMATION)             DGENLN    278
C                                                                       DGENLN    279
      DO 260 I=2,MT                                                     DGENLN    280
         AK1=AK(1,I)                                                    DGENLN    281
         AK2=AK(2,I)                                                    DGENLN    282
         AK(1,I)=YD(1,1)*AK1+YD(1,2)*AK2                                DGENLN    283
         AK(2,I)=YD(2,1)*AK1+YD(2,2)*AK2                                DGENLN    284
  260 CONTINUE                                                          DGENLN    285
C                                                                       DGENLN    286
      ISTATE=MT                                                         DGENLN    287
C                                                                       DGENLN    288
C----------------------------------------------------------             DGENLN    289
C                                                                       DGENLN    290
C     THE GENERATOR EQUATIONS ARE IN THE FOLLOWING FORM:                DGENLN    291
C                                                                       DGENLN    292
C         dX/dt =  A*X + BC*I                                           DGENLN    293
C             I = AK*X - YD*V                                           DGENLN    294
C                                                                       DGENLN    295
C     WHERE THE VOLTAGE AND CURRENT VECTORS ARE IN THE                  DGENLN    296
C     NETWORK COORDINATES.                                              DGENLN    297
C                                                                       DGENLN    298
C----------------------------------------------------------             DGENLN    299
C                                                                       DGENLN    300
C     ADD THE EXCITER AND OTHER EXCITATION CONTROLS                     DGENLN    301
C                                                                       DGENLN    302
      IF (IEXN.NE.0) THEN                                               DGENLN    303
C                                                                       DGENLN    304
C     EXCITERS                                                          DGENLN    305
C                                                                       DGENLN    306
         JSTATE=MSTATE(2,N)                                             DGENLN    307
         CFEXC=RD(1)/XAD                                                DGENLN    308
         JE=JCONTA(3,N)                                                 DGENLN    309
C                                                                       DGENLN    310
C     USER DEFINED EXCITER                                              DGENLN    311
C                                                                       DGENLN    312
         IF (IEXN.EQ.50) THEN                                           DGENLN    313
C                                                                       DGENLN    314
C     CONNECT USER DEFINED EXCITER EQUATIONS TO GENERATOR               DGENLN    315
C     EQUATIONS                                                         DGENLN    316
C                                                                       DGENLN    317
            CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                DGENLN    318
C                                                                       DGENLN    319
            MSEXC=MSUDM(1,1)                                            DGENLN    320
            NBUSR=MSUDM(2,1)                                            DGENLN    321
            ICOLTM=ICOLBV                                               DGENLN    322
            DO 270 I=1,MSEXC                                            DGENLN    323
               A(ISTATE+I,1)=BXW(I)                                     DGENLN    324
               A(ISTATE+I,2)=XAD*FCTM(1)*BXIF(I)                        DGENLN    325
               DO 280 J=1,MD                                            DGENLN    326
                  A(ISTATE+I,J+2)=XAD*FCTM(J+1)*BXIF(I)                 DGENLN    327
  280          CONTINUE                                                 DGENLN    328
               DO 290 J=1,MSEXC                                         DGENLN    329
                  A(ISTATE+I,ISTATE+J)=AX(I,J)                          DGENLN    330
  290          CONTINUE                                                 DGENLN    331
               B(ISTATE+I,1)=BXV(I,1)                                   DGENLN    332
               B(ISTATE+I,2)=BXV(I,2)                                   DGENLN    333
               IF (NBUSR.EQ.0) GOTO 310                                 DGENLN    334
               DO 300 J=1,NBUSR                                         DGENLN    335
                  ICOLBV=ICOLBV+1                                       DGENLN    336
                  NBR(ICOLBV)=MSUDM(J+2,1)                              DGENLN    337
                  IWS1=2*ICOLBV                                         DGENLN    338
                  IWS2=2*J+2                                            DGENLN    339
                  B(ISTATE+I,IWS1-1)=BXV(I,IWS2-1)                      DGENLN    340
                  B(ISTATE+I,IWS1)=BXV(I,IWS2)                          DGENLN    341
  300          CONTINUE                                                 DGENLN    342
  310          BC(ISTATE+I,1)=BXI(I,1)+XAD*FCTM(5)*BXIF(I)              DGENLN    343
               BC(ISTATE+I,2)=BXI(I,2)+XAD*FCTM(6)*BXIF(I)              DGENLN    344
  270       CONTINUE                                                    DGENLN    345
C                                                                       DGENLN    346
C     OUTPUT EQUATION                                                   DGENLN    347
C                                                                       DGENLN    348
            CF=CFEXC*XAD                                                DGENLN    349
            DO 320 I=1,MSEXC                                            DGENLN    350
               A(3,ISTATE+I)=CFEXC*CX(1,I)                              DGENLN    351
  320       CONTINUE                                                    DGENLN    352
            BC(3,1)=BC(3,1)+CFEXC*ADEV(1,1)+CF*FCTM(5)*CXIF             DGENLN    353
            BC(3,2)=BC(3,2)+CFEXC*ADEV(1,2)+CF*FCTM(6)*CXIF             DGENLN    354
            B(3,1)=B(3,1)+CFEXC*YDEVS(1,1)                              DGENLN    355
            B(3,2)=B(3,2)+CFEXC*YDEVS(1,2)                              DGENLN    356
            IF (NBUSR.EQ.0) GOTO 340                                    DGENLN    357
            DO 330 I=1,NBUSR                                            DGENLN    358
               IWS1=2*(ICOLTM+I)                                        DGENLN    359
               B(3,IWS1-1)=B(3,IWS1-1)+CFEXC*YDEVR(1,2*I-1)             DGENLN    360
               B(3,IWS1)=B(3,IWS1)+CFEXC*YDEVR(1,2*I)                   DGENLN    361
  330       CONTINUE                                                    DGENLN    362
  340       A(3,2)=A(3,2)+CF*FCTM(1)*CXIF                               DGENLN    363
            DO 350 I=1,MD                                               DGENLN    364
               A(3,I+2)=A(3,I+2)+CF*FCTM(I+1)*CXIF                      DGENLN    365
  350       CONTINUE                                                    DGENLN    366
            A(3,1)=A(3,1)+CFEXC*CXW                                     DGENLN    367
            CXTM=CFEXC*CXTM                                             DGENLN    368
            ISTATE=ISTATE+MSEXC                                         DGENLN    369
            GOTO 500                                                    DGENLN    370
C                                                                       DGENLN    371
         END IF                                                         DGENLN    372
C                                                                       DGENLN    373
C     ALL STANDARD EXCITERS                                             DGENLN    374
C                                                                       DGENLN    375
C     OBTAIN SENSING INFORMATION                                        DGENLN    376
C                                                                       DGENLN    377
         KN=IDDAT(JE+1)                                                 DGENLN    378
         IF (KN.EQ.0.OR.KN.EQ.ICBUSN) THEN                              DGENLN    379
            VSR=EPD                                                     DGENLN    380
            VSI=EPQ                                                     DGENLN    381
            VSM=ET                                                      DGENLN    382
         ELSE                                                           DGENLN    383
            VSR=REAL(VOLT(KN))                                          DGENLN    384
            VSI=AIMAG(VOLT(KN))                                         DGENLN    385
            VSM=SQRT(VSR*VSR+VSI*VSI)                                   DGENLN    386
            ICOLBV=ICOLBV+1                                             DGENLN    387
            NBR(ICOLBV)=KN                                              DGENLN    388
         END IF                                                         DGENLN    389
         KN=2*ICOLBV                                                    DGENLN    390
C                                                                       DGENLN    391
C     COMMON FACTORS DUE TO TERMINAL VOLTAGE COMPENSATION               DGENLN    392
C                                                                       DGENLN    393
         IF (IDDAT(JE+19).EQ.0.AND.IDDAT(JE+20).EQ.0) THEN              DGENLN    394
C                                                                       DGENLN    395
C     RC = 0 AND XC = 0                                                 DGENLN    396
C                                                                       DGENLN    397
            ALP1=0.0                                                    DGENLN    398
            ALP2=0.0                                                    DGENLN    399
            IF (ABS(VSM).GT.1.0E-2) THEN                                DGENLN    400
               ALP3=VSR/VSM                                             DGENLN    401
               ALP4=VSI/VSM                                             DGENLN    402
            ELSE                                                        DGENLN    403
               ALP3=0.0                                                 DGENLN    404
               ALP4=0.0                                                 DGENLN    405
            END IF                                                      DGENLN    406
C                                                                       DGENLN    407
         ELSE                                                           DGENLN    408
C                                                                       DGENLN    409
C     RC AND/OR XC ARE NON-ZERO                                         DGENLN    410
C                                                                       DGENLN    411
            RC=DDAT(JE+19)                                              DGENLN    412
            XC=DDAT(JE+20)                                              DGENLN    413
            IF (ABS(VSM).GT.1.0E-2) THEN                                DGENLN    414
               VER=(VSR+RC*CDGN-XC*CQGN)/VSM                            DGENLN    415
               VEI=(VSI+RC*CDGN+XC*CQGN)/VSM                            DGENLN    416
            ELSE                                                        DGENLN    417
               VER=RC*CDGN-XC*CQGN                                      DGENLN    418
               VEI=RC*CDGN+XC*CQGN                                      DGENLN    419
            END IF                                                      DGENLN    420
            ALP1=VER*RC+VEI*XC                                          DGENLN    421
            ALP2=VEI*RC-VER*XC                                          DGENLN    422
            ALP3=VER                                                    DGENLN    423
            ALP4=VEI                                                    DGENLN    424
C                                                                       DGENLN    425
         END IF                                                         DGENLN    426
C                                                                       DGENLN    427
C     TR BLOCK -- COMMON FOR ALL EXCITERS                               DGENLN    428
C                                                                       DGENLN    429
         IF (IDDAT(JE+18).EQ.0) THEN                                    DGENLN    430
            INPUTR=0                                                    DGENLN    431
         ELSE                                                           DGENLN    432
            ISUB1=ISTATE+1                                              DGENLN    433
            TRI=1.0/DDAT(JE+18)                                         DGENLN    434
            A(ISUB1,ISUB1)=-TRI                                         DGENLN    435
            BC(ISUB1,1)=TRI*ALP1                                        DGENLN    436
            BC(ISUB1,2)=TRI*ALP2                                        DGENLN    437
            B(ISUB1,KN-1)=TRI*ALP3                                      DGENLN    438
            B(ISUB1,KN)=TRI*ALP4                                        DGENLN    439
            INPUTR=1                                                    DGENLN    440
         END IF                                                         DGENLN    441
C                                                                       DGENLN    442
C     IUSTi AND GUSTi ARE LOCATIONS AND                                 DGENLN    443
C     GAINS OF THE INPUT FROM UNDER EXCITED CURRENT LIMITER,            DGENLN    444
C     STABILIZER AND TRANSIENT EXCITATION BOOSTER                       DGENLN    445
C                                                                       DGENLN    446
         DO 360 I=1,4                                                   DGENLN    447
 360     IUST(I)=0                                                      DGENLN    448
C                                                                       DGENLN    449
C                           EXCITER TYPE                                DGENLN    450
C                                                                       DGENLN    451
C                1   2   3   4   5   6   7   8   9  10                  DGENLN    452
         GOTO (401,401,403,404,403,406,407,408,409,410,                 DGENLN    453
C                                                                       DGENLN    454
C               11  12  13  14  15  16  17  18  19  20                  DGENLN    455
     *         500,500,500,414,415,500,500,500,500,500,                 DGENLN    456
C                                                                       DGENLN    457
C               21  22  23  24  25  26  27  28  29  30                  DGENLN    458
     *         500,500,500,500,500,500,500,500,500,430,                 DGENLN    459
C                                                                       DGENLN    460
C               31  32  33  34                                          DGENLN    461
     *         431,432,500,434), IEXN                                   DGENLN    462
C                                                                       DGENLN    463
C     TYPE 1 AND 2                                                      DGENLN    464
C                                                                       DGENLN    465
  401    CALL AEXC1(ISTATE)                                             DGENLN    466
         GOTO 500                                                       DGENLN    467
C                                                                       DGENLN    468
C     TYPE 3 AND 5                                                      DGENLN    469
C                                                                       DGENLN    470
  403    XSPU=1.0/(XSTATE(JSM+1)+WXBASE)                                DGENLN    471
         CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    472
         CALL AEXC3(ISTATE,VSR,VSI,MD,XAD)                              DGENLN    473
         GOTO 500                                                       DGENLN    474
C                                                                       DGENLN    475
C     TYPE 4                                                            DGENLN    476
C                                                                       DGENLN    477
  404    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    478
         CALL AEXC4(ISTATE,MD,XAD)                                      DGENLN    479
         GOTO 500                                                       DGENLN    480
C                                                                       DGENLN    481
C     TYPE 6                                                            DGENLN    482
C                                                                       DGENLN    483
  406    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    484
         CALL AEXC6(ISTATE,MD,XAD)                                      DGENLN    485
         GOTO 500                                                       DGENLN    486
C                                                                       DGENLN    487
C     TYPE 7                                                            DGENLN    488
C                                                                       DGENLN    489
  407    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    490
         CALL AEXC7(ISTATE,EPD,EPQ,MD,XAD)                              DGENLN    491
         GOTO 500                                                       DGENLN    492
C                                                                       DGENLN    493
C     TYPE 8                                                            DGENLN    494
C                                                                       DGENLN    495
  408    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    496
         CALL AEXC8(ISTATE,EPD,EPQ,MD,XAD)                              DGENLN    497
         GOTO 500                                                       DGENLN    498
C                                                                       DGENLN    499
C     TYPE 9                                                            DGENLN    500
C                                                                       DGENLN    501
  409    CALL AEXC9(ISTATE)                                             DGENLN    502
         GOTO 500                                                       DGENLN    503
C                                                                       DGENLN    504
C     TYPE 10                                                           DGENLN    505
C                                                                       DGENLN    506
  410    CALL AEXC10(ISTATE)                                            DGENLN    507
         GOTO 500                                                       DGENLN    508
C                                                                       DGENLN    509
C     TYPE 14                                                           DGENLN    510
C                                                                       DGENLN    511
  414    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    512
         CALL AEXC14(ISTATE,MD,XAD)                                     DGENLN    513
         GOTO 500                                                       DGENLN    514
C                                                                       DGENLN    515
C     TYPE 15                                                           DGENLN    516
C                                                                       DGENLN    517
  415    IF (IDDAT(JE+19).EQ.0.AND.IDDAT(JE+20).EQ.0) THEN              DGENLN    518
            VCOMP=VSM                                                   DGENLN    519
         ELSE                                                           DGENLN    520
            VCOMP=SQRT(VER*VER+VEI*VEI)                                 DGENLN    521
         END IF                                                         DGENLN    522
         CALL AEXC15(ISTATE,VCOMP,XAD)                                  DGENLN    523
         GOTO 500                                                       DGENLN    524
C                                                                       DGENLN    525
C     TYPE 30                                                           DGENLN    526
C                                                                       DGENLN    527
  430    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    528
         CALL AEXC30(ISTATE,EPD,EPQ,MD,XAD)                             DGENLN    529
         GOTO 500                                                       DGENLN    530
C                                                                       DGENLN    531
C     TYPE 31                                                           DGENLN    532
C                                                                       DGENLN    533
  431    IF (IDDAT(JE+19).EQ.0.AND.IDDAT(JE+20).EQ.0) THEN              DGENLN    534
            VCOMP=VSM                                                   DGENLN    535
         ELSE                                                           DGENLN    536
            VCOMP=SQRT(VER*VER+VEI*VEI)                                 DGENLN    537
         END IF                                                         DGENLN    538
         CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    539
         CALL AEXC31(ISTATE,EPD,EPQ,VCOMP,MD,XAD)                       DGENLN    540
         GOTO 500                                                       DGENLN    541
C                                                                       DGENLN    542
C     TYPE 32                                                           DGENLN    543
C                                                                       DGENLN    544
  432    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    545
         CALL AEXC32(ISTATE,EPD,EPQ,MD,XAD)                             DGENLN    546
         GOTO 500                                                       DGENLN    547
C                                                                       DGENLN    548
C     TYPE 34                                                           DGENLN    549
C                                                                       DGENLN    550
  434    CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                   DGENLN    551
         CALL AEXC34(ISTATE,MD,XAD)                                     DGENLN    552
C                                                                       DGENLN    553
  500    CONTINUE                                                       DGENLN    554
C                                                                       DGENLN    555
C     END OF EXCITERS                                                   DGENLN    556
C                                                                       DGENLN    557
         IF (ISTABN.LE.0) GOTO 700                                      DGENLN    558
C                                                                       DGENLN    559
C     STABILIZERS                                                       DGENLN    560
C                                                                       DGENLN    561
         JSTATE=MSTATE(3,N)                                             DGENLN    562
         JS=JCONTA(4,N)                                                 DGENLN    563
         IF (IFLTRN.NE.0) JF=JCONTA(5,N)                                DGENLN    564
C                                                                       DGENLN    565
         IF (ISTABN.EQ.50) THEN                                         DGENLN    566
C                                                                       DGENLN    567
C     USER DEFINED STABILIZER                                           DGENLN    568
C                                                                       DGENLN    569
            MSSTA=MSUDM(1,2)                                            DGENLN    570
            NBUSR=MSUDM(3,2)                                            DGENLN    571
            ICOLTM=ICOLBV                                               DGENLN    572
            DO 510 I=1,MSSTA                                            DGENLN    573
               DO 520 J=1,MSSTA                                         DGENLN    574
                  A(ISTATE+I,ISTATE+J)=AXB(I,J)                         DGENLN    575
  520          CONTINUE                                                 DGENLN    576
               BC(ISTATE+I,1)=BUI(I,1)+XAD*FCTM(5)*BUIF(I)              DGENLN    577
               BC(ISTATE+I,2)=BUI(I,2)+XAD*FCTM(6)*BUIF(I)              DGENLN    578
               B(ISTATE+I,1)=BUV(I,1)                                   DGENLN    579
               B(ISTATE+I,2)=BUV(I,2)                                   DGENLN    580
               A(ISTATE+I,1)=BUW(I)                                     DGENLN    581
               A(ISTATE+I,2)=XAD*FCTM(1)*BUIF(I)                        DGENLN    582
               DO 521 J=1,MD                                            DGENLN    583
               A(ISTATE+I,J+2)=XAD*FCTM(J+1)*BUIF(I)                    DGENLN    584
  521          CONTINUE                                                 DGENLN    585
               IF (NBUSR.EQ.0) GOTO 510                                 DGENLN    586
               DO 530 J=1,NBUSR                                         DGENLN    587
                  ICOLBV=ICOLBV+1                                       DGENLN    588
                  NBR(ICOLBV)=MSUDM(J+3,2)                              DGENLN    589
                  IWS1=2*ICOLBV                                         DGENLN    590
                  B(ISTATE+I,IWS1-1)=BUVR(I,2*J-1)                      DGENLN    591
                  B(ISTATE+I,IWS1)=BUVR(I,2*J)                          DGENLN    592
  530          CONTINUE                                                 DGENLN    593
  510       CONTINUE                                                    DGENLN    594
C                                                                       DGENLN    595
            UELCEF=1.0                                                  DGENLN    596
            IF (MSUDM(2,2).EQ.0) UELCEF=0.0                             DGENLN    597
            DO 550 I=1,4                                                DGENLN    598
               IF (IUST(I).EQ.0) GOTO 580                               DGENLN    599
               IWS1=IUST(I)                                             DGENLN    600
               WS1=GUST(I)                                              DGENLN    601
               DO 560 J=1,MSSTA                                         DGENLN    602
                  A(IWS1,ISTATE+J)=WS1*(CYX(1,J)+UELCEF*CYX(2,J))       DGENLN    603
  560          CONTINUE                                                 DGENLN    604
               BC(IWS1,1)=BC(IWS1,1)+WS1*(CYI(1,1)+UELCEF*CYI(2,1)      DGENLN    605
     *            +XAD*FCTM(5)*CYIF(1)+UELCEF*XAD*FCTM(5)*CYIF(2))      DGENLN    606
               BC(IWS1,2)=BC(IWS1,2)+WS1*(CYI(1,2)+UELCEF*CYI(2,2)      DGENLN    607
     *            +XAD*FCTM(6)*CYIF(1)+UELCEF*XAD*FCTM(6)*CYIF(2))      DGENLN    608
               B(IWS1,1)=B(IWS1,1)+WS1*(CYV(1,1)+UELCEF*CYV(2,1))       DGENLN    609
               B(IWS1,2)=B(IWS1,2)+WS1*(CYV(1,2)+UELCEF*CYV(2,2))       DGENLN    610
               A(IWS1,1)=A(IWS1,1)+WS1*(CYW(1)+UELCEF*CYW(2))           DGENLN    611
               A(IWS1,2)=A(IWS1,2)+WS1*XAD*FCTM(1)*                     DGENLN    612
     *                     (CYIF(1)+UELCEF*CYIF(2))                     DGENLN    613
               DO 561 J=1,MD                                            DGENLN    614
               A(IWS1,J+2)=A(IWS1,J+2)+WS1*XAD*FCTM(I+1)*               DGENLN    615
     *                     (CYIF(1)+UELCEF*CYIF(2))                     DGENLN    616
  561          CONTINUE                                                 DGENLN    617
               IF (NBUSR.EQ.0) GOTO 550                                 DGENLN    618
               DO 570 J=1,NBUSR                                         DGENLN    619
                  IWS2=2*(ICOLTM+J)                                     DGENLN    620
                  B(IWS1,IWS2-1)=B(IWS1,IWS2-1)+WS1*(CYVR(1,1)+         DGENLN    621
     *                           UELCEF*CYVR(2,1))                      DGENLN    622
                  B(IWS1,IWS2)=B(IWS1,IWS2)+WS1*(CYVR(1,2)+             DGENLN    623
     *                         UELCEF*CYVR(2,2))                        DGENLN    624
  570          CONTINUE                                                 DGENLN    625
  550       CONTINUE                                                    DGENLN    626
  580       CONTINUE                                                    DGENLN    627
            INSTA(1,1)=0                                                DGENLN    628
            INSTA(1,2)=0                                                DGENLN    629
            ISTATE=ISTATE+MSSTA                                         DGENLN    630
            GOTO 700                                                    DGENLN    631
C                                                                       DGENLN    632
         END IF                                                         DGENLN    633
C                                                                       DGENLN    634
C     ALL STANDARD STABILIZERS                                          DGENLN    635
C                                                                       DGENLN    636
C     INPUT SIGNALS                                                     DGENLN    637
C                                                                       DGENLN    638
         CALL PSGNAL(ISTATE,EPD,EPQ)                                    DGENLN    639
C                                                                       DGENLN    640
C                        STABILIZER TYPE                                DGENLN    641
C                1   2   3   4   5   6   7   8   9  10                  DGENLN    642
         GOTO (601,601,601,604,604,604,700,700,609,610,                 DGENLN    643
C                                                                       DGENLN    644
C               11  12                                                  DGENLN    645
     *         611,612), ISTABN                                         DGENLN    646
C                                                                       DGENLN    647
C      TYPE 1, 2 AND 3                                                  DGENLN    648
C                                                                       DGENLN    649
  601    CALL ASTA1(ISTATE)                                             DGENLN    650
         GOTO 700                                                       DGENLN    651
C                                                                       DGENLN    652
C      TYPE 4, 5 AND 6                                                  DGENLN    653
C                                                                       DGENLN    654
  604    CALL ASTA4(ISTATE)                                             DGENLN    655
         GOTO 700                                                       DGENLN    656
C                                                                       DGENLN    657
C      TYPE 9                                                           DGENLN    658
C                                                                       DGENLN    659
  609    CALL ASTA9(ISTATE)                                             DGENLN    660
         GOTO 700                                                       DGENLN    661
C                                                                       DGENLN    662
C      TYPE 10                                                          DGENLN    663
C                                                                       DGENLN    664
  610    CALL ASTA10(ISTATE)                                            DGENLN    665
         GOTO 700                                                       DGENLN    666
C                                                                       DGENLN    667
C      TYPE 11                                                          DGENLN    668
C                                                                       DGENLN    669
  611    CALL ASTA11(ISTATE)                                            DGENLN    670
         GOTO 700                                                       DGENLN    671
C                                                                       DGENLN    672
C      TYPE 12                                                          DGENLN    673
C                                                                       DGENLN    674
  612    CALL ASTA12(ISTATE)                                            DGENLN    675
C                                                                       DGENLN    676
  700    CONTINUE                                                       DGENLN    677
C                                                                       DGENLN    678
C      END OF STABILIZERS                                               DGENLN    679
C                                                                       DGENLN    680
         IF (IUALN.EQ.0) GOTO 780                                       DGENLN    681
C                                                                       DGENLN    682
C      UNDER EXCITED CURRENT LIMITERS                                   DGENLN    683
C                                                                       DGENLN    684
         IF (IUALN.EQ.50) THEN                                          DGENLN    685
C                                                                       DGENLN    686
C      USER DEFINED UNDER EXCITED CURRENT LIMITER                       DGENLN    687
C                                                                       DGENLN    688
            MSUAL=MSUDM(1,3)                                            DGENLN    689
            NBUSR=MSUDM(3,2)                                            DGENLN    690
            ICOLTM=ICOLBV                                               DGENLN    691
            DO 710 I=1,MSUAL                                            DGENLN    692
               DO 720 J=1,MSUAL                                         DGENLN    693
                  A(ISTATE+I,ISTATE+J)=AXB(I,J)                         DGENLN    694
  720          CONTINUE                                                 DGENLN    695
               BC(ISTATE+I,1)=BUI(I,1)+XAD*FCTM(5)*BUIF(I)              DGENLN    696
               BC(ISTATE+I,2)=BUI(I,2)+XAD*FCTM(6)*BUIF(I)              DGENLN    697
               B(ISTATE+I,1)=BUV(I,1)                                   DGENLN    698
               B(ISTATE+I,2)=BUV(I,2)                                   DGENLN    699
               A(ISTATE+I,1)=BUW(I)                                     DGENLN    700
               A(ISTATE+I,2)=XAD*FCTM(1)*BUIF(I)                        DGENLN    701
               DO 523 J=1,MD                                            DGENLN    702
               A(ISTATE+I,J+2)=XAD*FCTM(J+1)*BUIF(I)                    DGENLN    703
  523          CONTINUE                                                 DGENLN    704
               IF (NBUSR.EQ.0) GOTO 710                                 DGENLN    705
               DO 730 J=1,NBUSR                                         DGENLN    706
                  ICOLBV=ICOLBV+1                                       DGENLN    707
                  NBR(ICOLBV)=MSUDM(J+3,2)                              DGENLN    708
                  IWS1=2*ICOLBV                                         DGENLN    709
                  B(ISTATE+I,IWS1-1)=BUVR(I,2*J-1)                      DGENLN    710
                  B(ISTATE+I,IWS1)=BUVR(I,2*J)                          DGENLN    711
  730          CONTINUE                                                 DGENLN    712
  710       CONTINUE                                                    DGENLN    713
C                                                                       DGENLN    714
            DO 740 I=1,4                                                DGENLN    715
               IF (IUST(I).EQ.0) GOTO 770                               DGENLN    716
               IWS1=IUST(I)                                             DGENLN    717
               WS1=GUST(I)                                              DGENLN    718
               DO 750 J=1,MSUAL                                         DGENLN    719
                  A(IWS1,ISTATE+J)=WS1*CYX(1,J)                         DGENLN    720
  750          CONTINUE                                                 DGENLN    721
               BC(IWS1,1)=BC(IWS1,1)+WS1*(CYI(1,1)+XAD*FCTM(5)*CYIF(1)) DGENLN    722
               BC(IWS1,2)=BC(IWS1,2)+WS1*(CYI(1,2)+XAD*FCTM(6)*CYIF(1)) DGENLN    723
               B(IWS1,1)=B(IWS1,1)+WS1*CYV(1,1)                         DGENLN    724
               B(IWS1,2)=B(IWS1,2)+WS1*CYV(1,2)                         DGENLN    725
               A(IWS1,1)=A(IWS1,1)+WS1*CYW(1)                           DGENLN    726
               A(IWS1,2)=A(IWS1,2)+WS1*XAD*FCTM(1)*CYIF(1)              DGENLN    727
               DO 755 J=1,MD                                            DGENLN    728
               A(IWS1,J+2)=A(IWS1,J+2)+WS1*XAD*FCTM(I+1)*CYIF(1)        DGENLN    729
  755          CONTINUE                                                 DGENLN    730
               IF (NBUSR.EQ.0) GOTO 740                                 DGENLN    731
               DO 760 J=1,NBUSR                                         DGENLN    732
                  IWS2=2*(ICOLTM+J)                                     DGENLN    733
                  B(IWS1,IWS2-1)=B(IWS1,IWS2-1)+WS1*CYVR(1,1)           DGENLN    734
                  B(IWS1,IWS2)=B(IWS1,IWS2)+WS1*CYVR(1,2)               DGENLN    735
  760          CONTINUE                                                 DGENLN    736
  740       CONTINUE                                                    DGENLN    737
  770       CONTINUE                                                    DGENLN    738
            ISTATE=ISTATE+MSUAL                                         DGENLN    739
            GOTO 780                                                    DGENLN    740
         END IF                                                         DGENLN    741
C                                                                       DGENLN    742
         CALL AUALN(ISTATE,EPD,EPQ)                                     DGENLN    743
C                                                                       DGENLN    744
  780    CONTINUE                                                       DGENLN    745
C                                                                       DGENLN    746
      END IF                                                            DGENLN    747
C                                                                       DGENLN    748
C     MAXIMUM EXCITATION CURRENT LIMITERS                               DGENLN    749
C                                                                       DGENLN    750
      IF (IMXLN.NE.0) THEN                                              DGENLN    751
C                                                                       DGENLN    752
         JMX=JCONTA(11,N)                                               DGENLN    753
         JYMX=MYVAR(8,N)                                                DGENLN    754
         IF (IMXLN.EQ.50) THEN                                          DGENLN    755
C                                                                       DGENLN    756
C      USER DEFINED OVER EXCITATION CURRENT LIMITER                     DGENLN    757
C                                                                       DGENLN    758
            MSOEL=MSUDM(1,3)                                            DGENLN    759
            NBUSR=MSUDM(3,2)                                            DGENLN    760
            ICOLTM=ICOLBV                                               DGENLN    761
            DO 711 I=1,MSOEL                                            DGENLN    762
               DO 721 J=1,MSOEL                                         DGENLN    763
                  A(ISTATE+I,ISTATE+J)=AXB(I,J)                         DGENLN    764
  721          CONTINUE                                                 DGENLN    765
               BC(ISTATE+I,1)=BUI(I,1)+XAD*FCTM(5)*BUIF(I)              DGENLN    766
               BC(ISTATE+I,2)=BUI(I,2)+XAD*FCTM(6)*BUIF(I)              DGENLN    767
               B(ISTATE+I,1)=BUV(I,1)                                   DGENLN    768
               B(ISTATE+I,2)=BUV(I,2)                                   DGENLN    769
               A(ISTATE+I,1)=BUW(I)                                     DGENLN    770
               A(ISTATE+I,2)=XAD*FCTM(1)*BUIF(I)                        DGENLN    771
               DO 522 J=1,MD                                            DGENLN    772
               A(ISTATE+I,J+2)=XAD*FCTM(J+1)*BUIF(I)                    DGENLN    773
  522          CONTINUE                                                 DGENLN    774
               IF (NBUSR.EQ.0) GOTO 711                                 DGENLN    775
               DO 731 J=1,NBUSR                                         DGENLN    776
                  ICOLBV=ICOLBV+1                                       DGENLN    777
                  NBR(ICOLBV)=MSUDM(J+3,2)                              DGENLN    778
                  IWS1=2*ICOLBV                                         DGENLN    779
                  B(ISTATE+I,IWS1-1)=BUVR(I,2*J-1)                      DGENLN    780
                  B(ISTATE+I,IWS1)=BUVR(I,2*J)                          DGENLN    781
  731          CONTINUE                                                 DGENLN    782
  711       CONTINUE                                                    DGENLN    783
C                                                                       DGENLN    784
            DO 741 I=1,4                                                DGENLN    785
               IF (IUST(I).EQ.0) GOTO 771                               DGENLN    786
               IWS1=IUST(I)                                             DGENLN    787
               WS1=-GUST(I)                                             DGENLN    788
               DO 751 J=1,MSOEL                                         DGENLN    789
                  A(IWS1,ISTATE+J)=WS1*CYX(1,J)                         DGENLN    790
  751          CONTINUE                                                 DGENLN    791
               BC(IWS1,1)=BC(IWS1,1)+WS1*(CYI(1,1)+XAD*FCTM(5)*CYIF(1)) DGENLN    792
               BC(IWS1,2)=BC(IWS1,2)+WS1*(CYI(1,2)+XAD*FCTM(6)*CYIF(1)) DGENLN    793
               BC(IWS1,1)=BC(IWS1,1)+WS1*CYI(1,1)                       DGENLN    794
               BC(IWS1,2)=BC(IWS1,2)+WS1*CYI(1,2)                       DGENLN    795
               B(IWS1,1)=B(IWS1,1)+WS1*CYV(1,1)                         DGENLN    796
               B(IWS1,2)=B(IWS1,2)+WS1*CYV(1,2)                         DGENLN    797
               A(IWS1,1)=A(IWS1,1)+WS1*CYW(1)                           DGENLN    798
               A(IWS1,2)=A(IWS1,2)+WS1*XAD*FCTM(1)*CYIF(1)              DGENLN    799
               DO 562 J=1,MD                                            DGENLN    800
               A(IWS1,J+2)=A(IWS1,J+2)+WS1*XAD*FCTM(I+1)*CYIF(1)        DGENLN    801
  562          CONTINUE                                                 DGENLN    802
               IF (NBUSR.EQ.0) GOTO 741                                 DGENLN    803
               DO 761 J=1,NBUSR                                         DGENLN    804
                  IWS2=2*(ICOLTM+J)                                     DGENLN    805
                  B(IWS1,IWS2-1)=B(IWS1,IWS2-1)+WS1*CYVR(1,1)           DGENLN    806
                  B(IWS1,IWS2)=B(IWS1,IWS2)+WS1*CYVR(1,2)               DGENLN    807
  761          CONTINUE                                                 DGENLN    808
  741       CONTINUE                                                    DGENLN    809
  771       CONTINUE                                                    DGENLN    810
            ISTATE=ISTATE+MSOEL                                         DGENLN    811
         ELSE                                                           DGENLN    812
            MXLTYP=IMXLN                                                DGENLN    813
            IF (IMXLN.GT.10) MXLTYP=IMXLN-10                            DGENLN    814
            CALL FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                DGENLN    815
            GOTO (785,786,786,786), MXLTYP                              DGENLN    816
  785       CALL AMEL1(ISTATE,MD,XAD)                                   DGENLN    817
  786       CONTINUE                                                    DGENLN    818
         END IF                                                         DGENLN    819
C                                                                       DGENLN    820
      END IF                                                            DGENLN    821
C                                                                       DGENLN    822
C     END OF EXCITATION CONTROL SYSTEMS (EXCITERS, STABILIZERS,         DGENLN    823
C     STABILIZER TORSIONAL FILTERS, UNDER EXCITED CURRENT LIMITERS,     DGENLN    824
C     MAXIMUM EXCITATION CURRENT LIMITERS, TRANSIENT EXCITATION BOOSTERSDGENLN    825
C                                                                       DGENLN    826
      IF (IGVN .EQ. 46) IGVN=0                                          DGENLN    827
      IF (IGVN.NE.0) THEN                                               DGENLN    828
C                                                                       DGENLN    829
C     GOVERNORS                                                         DGENLN    830
C                                                                       DGENLN    831
         JSTATE=MSTATE(5,N)                                             DGENLN    832
         JGG=JCONTA(2,N)                                                DGENLN    833
         JYP=MYVAR(5,N)                                                 DGENLN    834
C                                                                       DGENLN    835
         IF (IGVN.EQ.50) THEN                                           DGENLN    836
C                                                                       DGENLN    837
C     USER DEFINED GOVERNORS                                            DGENLN    838
C                                                                       DGENLN    839
            BASPRN=DDAT(JG+3)/BASPC                                     DGENLN    840
            BASERT=BASER(JYP+3)                                         DGENLN    841
            JEU=JE7-JE1+2                                               DGENLN    842
            DO 790 I=1,JEU                                              DGENLN    843
               UDAT(I)=DDAT(I+JE1-1)                                    DGENLN    844
  790       CONTINUE                                                    DGENLN    845
            IWS1=JGG+2                                                  DGENLN    846
            JE1=JE1-IWS1                                                DGENLN    847
            JE2=JE2-IWS1                                                DGENLN    848
            JE3=JE3-IWS1                                                DGENLN    849
            JE4=JE4-IWS1                                                DGENLN    850
            JE5=JE5-IWS1                                                DGENLN    851
            JE6=JE6-IWS1                                                DGENLN    852
            JE7=JE7-IWS1                                                DGENLN    853
C                                                                       DGENLN    854
            CALL AGOV(ISTATE,HM)                                        DGENLN    855
C                                                                       DGENLN    856
            ISTATE=ISTATE+MSUDM(1,4)                                    DGENLN    857
            GOTO 900                                                    DGENLN    858
         END IF                                                         DGENLN    859
*IF LTSP                                                                DGENLN    860
*ENDIF                                                                  DGENLN    875
C                                                                       DGENLN    876
C                     GOVERNOR TYPES                                    DGENLN    877
C                1   2   3   4   5   6   7   8   9  10                  DGENLN    878
         GOTO (801,801,900,804,900,806,807,808,900,900,                 DGENLN    879
C                                                                       DGENLN    880
C               11  12  13  14  15  16  17  18  19  20                  DGENLN    881
     *         900,900,900,900,900,900,900,900,900,820,                 DGENLN    882
C                                                                       DGENLN    883
C               21  22                                                  DGENLN    884
     *         821,822), IGVN                                           DGENLN    885
C                                                                       DGENLN    886
C     TYPE 1 , 2 31, 32                                                 DGENLN    887
C                                                                       DGENLN    888
  801    CALL AGOV1(ISTATE,HM)                                          DGENLN    889
*IF LTSP                                                                DGENLN    890
*ENDIF                                                                  DGENLN    899
         GOTO 900                                                       DGENLN    900
C                                                                       DGENLN    901
C     TYPE 4                                                            DGENLN    902
C                                                                       DGENLN    903
  804    CALL AGOV4(ISTATE,HM)                                          DGENLN    904
*IF LTSP                                                                DGENLN    905
*ENDIF                                                                  DGENLN    914
         GOTO 900                                                       DGENLN    915
C                                                                       DGENLN    916
C     TYPE 6                                                            DGENLN    917
C                                                                       DGENLN    918
  806    CALL AGOV6(ISTATE,HM)                                          DGENLN    919
         GOTO 900                                                       DGENLN    920
C                                                                       DGENLN    921
C     TYPE 7                                                            DGENLN    922
C                                                                       DGENLN    923
  807    CALL AGOV7(ISTATE,HM)                                          DGENLN    924
         GOTO 900                                                       DGENLN    925
C                                                                       DGENLN    926
C     TYPE 8                                                            DGENLN    927
C                                                                       DGENLN    928
  808    CALL AGOV8(ISTATE,HM)                                          DGENLN    929
         GOTO 900                                                       DGENLN    930
C                                                                       DGENLN    931
C     TYPE 20                                                           DGENLN    932
C                                                                       DGENLN    933
  820    CALL AGOV20(ISTATE,HM)                                         DGENLN    934
         GOTO 900                                                       DGENLN    935
C                                                                       DGENLN    936
C     TYPE 21                                                           DGENLN    937
C                                                                       DGENLN    938
  821    CALL AGOV21(ISTATE,HM)                                         DGENLN    939
         GOTO 900                                                       DGENLN    940
C                                                                       DGENLN    941
C     TYPE 22                                                           DGENLN    942
C                                                                       DGENLN    943
  822    CALL AGOV22(ISTATE,HM)                                         DGENLN    944
C                                                                       DGENLN    945
  900    CONTINUE                                                       DGENLN    946
C                                                                       DGENLN    947
      END IF                                                            DGENLN    948
C                                                                       DGENLN    949
C     END OF GOVERNORS                                                  DGENLN    950
C                                                                       DGENLN    951
C     ADD TORQUE TERMS IF THE STABILIZER INPUT IS ACCELERATING POWER    DGENLN    952
C                                                                       DGENLN    953
      IF (INSTA(1,1).EQ.0.OR.IGVN.EQ.0) GOTO 960                        DGENLN    954
C                                                                       DGENLN    955
      INTYP1=IDDAT(JS+2)                                                DGENLN    956
      JSGOVS=MSTATE(5,N)-JSM+1                                          DGENLN    957
      JSGOVE=MSTATE(6,N)-JSM                                            DGENLN    958
      IF (INTYP1.NE.2) GOTO 930                                         DGENLN    959
      DO 910 I=1,20                                                     DGENLN    960
         IF (INSTA(I,1).EQ.0) GOTO 955                                  DGENLN    961
         IWS1=INSTA(I,1)                                                DGENLN    962
         WS1=RINSTA(I,1)/HM                                             DGENLN    963
         DO 920 J=JSGOVS,JSGOVE                                         DGENLN    964
            A(IWS1,J)=A(IWS1,J)+WS1*A(1,J)                              DGENLN    965
  920    CONTINUE                                                       DGENLN    966
         A(IWS1,1)=A(IWS1,1)+WS1*DWTERM                                 DGENLN    967
  910 CONTINUE                                                          DGENLN    968
      GOTO 955                                                          DGENLN    969
C                                                                       DGENLN    970
  930 DO 940 I=1,20                                                     DGENLN    971
         IF (INSTA(I,1).EQ.0) GOTO 955                                  DGENLN    972
         IWS1=INSTA(I,1)                                                DGENLN    973
         WS1=RINSTA(I,2)/HM                                             DGENLN    974
         DO 950 J=JSGOVS,JSGOVE                                         DGENLN    975
            A(IWS1,J)=A(IWS1,J)+WS1*A(1,J)                              DGENLN    976
  950    CONTINUE                                                       DGENLN    977
         A(IWS1,1)=A(IWS1,1)+WS1*DWTERM                                 DGENLN    978
  940 CONTINUE                                                          DGENLN    979
C                                                                       DGENLN    980
  955 INSTA(1,1)=0                                                      DGENLN    981
  960 CONTINUE                                                          DGENLN    982
C                                                                       DGENLN    983
C----------------------------------------------------------             DGENLN    984
C                                                                       DGENLN    985
C     THE MACHINE EQUATIONS ARE IN THE FOLLOWING FORM:                  DGENLN    986
C                                                                       DGENLN    987
C         dX/dt =  A*X +  B*V + BC*I                                    DGENLN    988
C             I = AK*X - YD*V                                           DGENLN    989
C                                                                       DGENLN    990
C     WHERE THE VOLTAGE AND CURRENT VECTORS ARE IN THE                  DGENLN    991
C     NETWORK COORDINATES.                                              DGENLN    992
C                                                                       DGENLN    993
C----------------------------------------------------------             DGENLN    994
C                                                                       DGENLN    995
C     ELIMINATE CURRENT TERMS IN STATE EQUATION                         DGENLN    996
C                                                                       DGENLN    997
      DO 970 I=1,ISTATE                                                 DGENLN    998
         IF (IBC(I,1).EQ.0.AND.IBC(I,2).EQ.0) GOTO 970                  DGENLN    999
C                                                                       DGENLN   1000
C     ADD BC*AK TO A MATRIX                                             DGENLN   1001
C                                                                       DGENLN   1002
         DO 980 J=2,MT                                                  DGENLN   1003
            SUM=BC(I,1)*AK(1,J)+BC(I,2)*AK(2,J)                         DGENLN   1004
            A(I,J)=A(I,J)+SUM                                           DGENLN   1005
  980    CONTINUE                                                       DGENLN   1006
C                                                                       DGENLN   1007
C     ADD -BC*YD TO B MATRIX                                            DGENLN   1008
C                                                                       DGENLN   1009
         BR1=-BC(I,1)                                                   DGENLN   1010
         BR2=-BC(I,2)                                                   DGENLN   1011
         B(I,1)=B(I,1)+BR1*YD(1,1)+BR2*YD(2,1)                          DGENLN   1012
         B(I,2)=B(I,2)+BR1*YD(1,2)+BR2*YD(2,2)                          DGENLN   1013
  970 CONTINUE                                                          DGENLN   1014
C                                                                       DGENLN   1015
C     FINALLY FORM AG, BG, CG MATRICES (JACOBIAN MATRICES)              DGENLN   1016
C                                                                       DGENLN   1017
CCCCC                                                                   DGENLN   1018
C      IF (N.EQ.233) THEN                                               DGENLN   1019
C         WRITE(61,*)                                                   DGENLN   1020
C         WRITE(61,*) ' JACOBIAN: ISTATE = ', ISTATE                    DGENLN   1021
C         WRITE(61,*) ((A(II,JJ),JJ=1,ISTATE),II=1,ISTATE)              DGENLN   1022
C         WRITE(61,*) ((B(II,JJ),JJ=1,2),II=1,ISTATE)                   DGENLN   1023
C      END IF                                                           DGENLN   1024
CCCCC                                                                   DGENLN   1025
      NAIDEX=IAIDEX+2                                                   DGENLN   1026
      NBIDEX=IBIDEX                                                     DGENLN   1027
      NCIDEX=ICIDEX                                                     DGENLN   1028
C                                                                       DGENLN   1029
      IF (IPATH.EQ.1) THEN                                              DGENLN   1030
C                                                                       DGENLN   1031
C     FOR USE IN THE NORMAL TRAPEZOIDAL INTEGRATION METHOD              DGENLN   1032
C                                                                       DGENLN   1033
      DO 990 I=1,ISTATE                                                 DGENLN   1034
         DO 1000 J=1,ISTATE                                             DGENLN   1035
            IF (IA(I,J).EQ.0) GOTO 1000                                 DGENLN   1036
            A(I,J)=-CEFJM*A(I,J)                                        DGENLN   1037
 1000    CONTINUE                                                       DGENLN   1038
         A(I,I)=A(I,I)+1.0                                              DGENLN   1039
         DO 1010 J=1,ICOLBV*2                                           DGENLN   1040
            IF (IB(I,J).EQ.0) GOTO 1010                                 DGENLN   1041
            B(I,J)=-CEFJM*B(I,J)                                        DGENLN   1042
 1010    CONTINUE                                                       DGENLN   1043
  990 CONTINUE                                                          DGENLN   1044
C                                                                       DGENLN   1045
C     PERFORM ORDERING                                                  DGENLN   1046
C                                                                       DGENLN   1047
C
C  Modification done by NPAC, GRA Alvin Leung.
C
C  Original code is commented out by character CO.
C
      CALL DUMPA(A,ISTATE)

      CALL SYMRED(JSM,ISTATE)                                           DGENLN   1048
      CALL DUMPA(A,ISTATE)
C                                                                       DGENLN   1049
C     PERFORM LU FACTORIZATION FOR A                                    DGENLN   1050
C                                                                       DGENLN   1051
      CALL LUDCM(ISTATE)                                                DGENLN   1052
      CALL DUMPA(A,ISTATE)
C                                                                       DGENLN   1053
C     COMPUTE INVERSE(A)*B                                              DGENLN   1054
C                                                                       DGENLN   1055
      CALL FBSUBB(JSM,ISTATE)                                           DGENLN   1056
C                                                                       DGENLN   1057
C     STORE AK IN CJCOB ARRAY                                           DGENLN   1058
C                                                                       DGENLN   1059
         DO 1030 J=2,MT                                                 DGENLN   1060
         NCIDEX=NCIDEX+1                                                DGENLN   1061
         CJCOB(NCIDEX)=-AK(1,J)                                         DGENLN   1062
         CJCOB(NCIDEX+MT-1)=-AK(2,J)                                    DGENLN   1063
 1030    CONTINUE                                                       DGENLN   1064
C                                                                       DGENLN   1065
C     STORE B IN BJCOB ARRAY                                            DGENLN   1066
C                                                                       DGENLN   1067
      DO 1040 I=1,ICOLBV                                                DGENLN   1068
         NBIDEX=NBIDEX+1                                                DGENLN   1069
         IBJCOB(NBIDEX)=NBR(I)                                          DGENLN   1070
         IWS1=2*I                                                       DGENLN   1071
         DO 1050 J=1,ISTATE                                             DGENLN   1072
            NBIDEX=NBIDEX+2                                             DGENLN   1073
            BJCOB(NBIDEX-1)=B(J,IWS1-1)                                 DGENLN   1074
            BJCOB(NBIDEX)=B(J,IWS1)                                     DGENLN   1075
 1050    CONTINUE                                                       DGENLN   1076
 1040 CONTINUE                                                          DGENLN   1077
      NBIDEX=NBIDEX+1                                                   DGENLN   1078
      IBJCOB(NBIDEX)=0                                                  DGENLN   1079
C                                                                       DGENLN   1080
C     STORE A IN AJCOB, IAJCOB, ALUFT, AND IALUFT ARRAYS                DGENLN   1081
C                                                                       DGENLN   1082
      IAJCOB(1,IAIDEX+1)=NALUFT                                         DGENLN   1083
      DO 1060 I=2,ISTATE                                                DGENLN   1084
         NROW=0                                                         DGENLN   1085
         DO 1070 J=1,I-1                                                DGENLN   1086
            IF (A(I,J).EQ.0.0) GOTO 1070                                DGENLN   1087
            NROW=NROW+1                                                 DGENLN   1088
            NALUFT=NALUFT+1                                             DGENLN   1089
            ALUFT(NALUFT)=A(I,J)                                        DGENLN   1090
            IALUFT(NALUFT)=J                                            DGENLN   1091
 1070    CONTINUE                                                       DGENLN   1092
         IAJCOB(1,NAIDEX+I)=NROW                                        DGENLN   1093
 1060 CONTINUE                                                          DGENLN   1094
C                                                                       DGENLN   1095
      AJCOB(NAIDEX+ISTATE)=1.0/A(ISTATE,ISTATE)                         DGENLN   1096
      DO 1080 I=ISTATE-1,1,-1                                           DGENLN   1097
         AJCOB(NAIDEX+I)=1.0/A(I,I)                                     DGENLN   1098
         NROW=0                                                         DGENLN   1099
         DO 1090 J=I+1,ISTATE                                           DGENLN   1100
            IF (A(I,J).EQ.0.0) GOTO 1090                                DGENLN   1101
            NROW=NROW+1                                                 DGENLN   1102
            NALUFT=NALUFT+1                                             DGENLN   1103
            ALUFT(NALUFT)=A(I,J)                                        DGENLN   1104
            IALUFT(NALUFT)=J                                            DGENLN   1105
 1090    CONTINUE                                                       DGENLN   1106
         IAJCOB(2,NAIDEX+I)=NROW                                        DGENLN   1107
 1080 CONTINUE                                                          DGENLN   1108
C                                                                       DGENLN   1109
C     STORE YD-C*INVERSE(A)*B+YS IN YGJCOB                              DGENLN   1110
C                                                                       DGENLN   1111
      YGJCOB(1,N)=YD(1,1)+BUVAR(1,N)                                    DGENLN   1112
      YGJCOB(2,N)=YD(1,2)+BUVAR(2,N)                                    DGENLN   1113
      YGJCOB(3,N)=YD(2,1)+BUVAR(3,N)                                    DGENLN   1114
      YGJCOB(4,N)=YD(2,2)+BUVAR(4,N)                                    DGENLN   1115
      DO 1100 I=2,MT                                                    DGENLN   1116
         YGJCOB(1,N)=YGJCOB(1,N)+AK(1,I)*B(I,1)                         DGENLN   1117
         YGJCOB(2,N)=YGJCOB(2,N)+AK(1,I)*B(I,2)                         DGENLN   1118
         YGJCOB(3,N)=YGJCOB(3,N)+AK(2,I)*B(I,1)                         DGENLN   1119
         YGJCOB(4,N)=YGJCOB(4,N)+AK(2,I)*B(I,2)                         DGENLN   1120
 1100 CONTINUE                                                          DGENLN   1121
C                                                                       DGENLN   1122
      ELSE                                                              DGENLN   1123
C                                                                       DGENLN   1124
C     FOR USE IN GEAR'S METHOD TO CALCULATE THE SECOND ORDER DERIVATIVESDGENLN   1125
C                                                                       DGENLN   1126
C      DO 860 ILR=1,ISTATE                                              DGENLN   1127
C         DO 870 ILC=1,ISTATE                                           DGENLN   1128
C            ADGEN(ILR,ILC,N)=A(ILR,ILC)                                DGENLN   1129
C 870     CONTINUE                                                      DGENLN   1130
C         DO 880 ILC=1,ICOLBV                                           DGENLN   1131
C            BDGEN(ILR,ILC,N)=B(ILR,ILC)                                DGENLN   1132
C 880     CONTINUE                                                      DGENLN   1133
C         DO 890 ILC=1,IROWAK                                           DGENLN   1134
C            AKDGEN(ILC,ILR,N)=-AK(ILC,ILR)                             DGENLN   1135
C 890     CONTINUE                                                      DGENLN   1136
C 860  CONTINUE                                                         DGENLN   1137
C                                                                       DGENLN   1138
      END IF                                                            DGENLN   1139
C                                                                       DGENLN   1140
 9999 CONTINUE                                                          DGENLN   1141
C                                                                       DGENLN   1142
      RETURN                                                            DGENLN   1143
      END                                                               DGENLN   1144
C                                                                       DGENLN   1145
      SUBROUTINE FCTMCT(MD,CFDD,CAF2,CPQM,SN,COSINE,ALD)                DGENLN   1146
CD                                                                      DGENLN   1147
CD    TO CALCULATE COEFFICIENTS FOR FIELD CURRENT TRANSFORMATION FOR AC DGENLN   1148
CD    TYPE EXCITERS IN FORMULATING JACOBIAN MATRICES.                   DGENLN   1149
CD                                                                      DGENLN   1150
CD    ON RETURN, FCTM ARRAY IS ARRANGED AS FOLLOWS:                     DGENLN   1151
CD                                                                      DGENLN   1152
CD        (DELTA IF) = FCTM(1)*(DELTA DELTA) +                          DGENLN   1153
CD                     FCTM(2:4)*(DELTA PSID) +                         DGENLN   1154
CD                     FCTM(5:6)*(DELTA I)                              DGENLN   1155
CD                                                                      DGENLN   1156
CD    NOTE THAT WHEN ADDING (DELTA IF) TO EXCITER EQUATIONS, ALL        DGENLN   1157
CD    ELEMENTS IN FCTM SHOULD BE MULTIPLIED BY XAD.                     DGENLN   1158
CD                                                                      DGENLN   1159
      INCLUDE 'PARX.INS'                                                DGENLN   1160
      DIMENSION ALD(3,3)                                                DGENLN   1161
C                                                                       DGENLN   1162
      INCLUDE 'CNABAK.INS'                                              DGENLN   1163
C                                                                       DGENLN   1164
      FCTM(1)=CPQM*CAF2                                                 DGENLN   1165
      FCTM(5)=COSINE*CAF2                                               DGENLN   1166
      FCTM(6)=SN*CAF2                                                   DGENLN   1167
      DO 10 I=1,MD                                                      DGENLN   1168
         FCTM(I+1)=-CFDD*(ALD(I,I)**2)                                  DGENLN   1169
  10  CONTINUE                                                          DGENLN   1170
      FCTM(2)=ALD(1,1)+FCTM(2)                                          DGENLN   1171
      RETURN                                                            DGENLN   1172
      END                                                               DGENLN   1173
C                                                                       DGENLN   1174
      SUBROUTINE BCBTEM(ISUB,GAIN)                                      DGENLN   1175
CD                                                                      DGENLN   1176
CD    TO CALCULATE TERMS IN BC AND B ARRAYS FOR EXCITERS DUE TO THE LOADDGENLN   1177
CD    COMPENSATION BLOCK IN FORMULATING JACOBIAN MATRICES.              DGENLN   1178
CD                                                                      DGENLN   1179
      INCLUDE 'PARX.INS'                                                DGENLN   1180
      INCLUDE 'CNEXC.INS'                                               DGENLN   1181
C                                                                       DGENLN   1182
      INCLUDE 'CNABAK.INS'                                              DGENLN   1183
C                                                                       DGENLN   1184
      BC(ISUB,1)=-GAIN*ALP1                                             DGENLN   1185
      BC(ISUB,2)=-GAIN*ALP2                                             DGENLN   1186
      B(ISUB,KN-1)=-GAIN*ALP3                                           DGENLN   1187
      B(ISUB,KN)=-GAIN*ALP4                                             DGENLN   1188
C                                                                       DGENLN   1189
      RETURN                                                            DGENLN   1190
      END                                                               DGENLN   1191
