CFPRIME AEXC30                                                          AEXC30      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 AEXC30(ISTATE,EPD,EPQ,MD,XAD)                          AEXC30      3
CD                                                                      AEXC30      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 30 EXCITER             AEXC30      5
CD    (IEEE TYPE ST1 AND AC4).                                          AEXC30      6
CD                                                                      AEXC30      7
      INCLUDE 'PARX.INS'                                                AEXC30      8
      INCLUDE 'CNB8.INS'                                                AEXC30      9
      INCLUDE 'CNEXC.INS'                                               AEXC30     10
      INCLUDE 'CNMYVA.INS'                                              AEXC30     11
      INCLUDE 'CNPARX.INS'                                              AEXC30     12
      INCLUDE 'CNMDAT.INS'                                              AEXC30     13
      INCLUDE 'CNXSTA.INS'                                              AEXC30     14
      INCLUDE 'CNMSTA.INS'                                              AEXC30     15
C                                                                       AEXC30     16
      INCLUDE 'CNABAK.INS'                                              AEXC30     17
C                                                                       AEXC30     18
      DIMENSION FIELD(10),IFIELD(10)                                    AEXC30     19
      EQUIVALENCE (FIELD(1),IFIELD(1))                                  AEXC30     20
C                                                                       AEXC30     21
      TBI=0.0                                                           AEXC30     22
      TFI=0.0                                                           AEXC30     23
      TF2I=0.0                                                          AEXC30     24
C                                                                       AEXC30     25
      DO 10 I=2,6                                                       AEXC30     26
         FIELD(I)=0.0                                                   AEXC30     27
  10  CONTINUE                                                          AEXC30     28
C                                                                       AEXC30     29
C     GET STATE SUBSCRIPTS FROM IDDAT                                   AEXC30     30
C                                                                       AEXC30     31
      ISUB1=ISTATE+1                                                    AEXC30     32
      ISUB2=IDDAT(JE+34)                                                AEXC30     33
      ISUB3=IDDAT(JE+35)                                                AEXC30     34
      ISUB4=IDDAT(JE+36)                                                AEXC30     35
      ISUB5=IDDAT(JE+37)                                                AEXC30     36
      ISUB6=IDDAT(JE+38)                                                AEXC30     37
C                                                                       AEXC30     38
C     INPUT FROM TERMINAL VOLTAGE LIMITER                               AEXC30     39
C                                                                       AEXC30     40
      IF (ET.LE.DDAT(JE+24)) THEN                                       AEXC30     41
         CVD=0.0                                                        AEXC30     42
         CVQ=0.0                                                        AEXC30     43
      ELSE                                                              AEXC30     44
         CVD=EPD/ET                                                     AEXC30     45
         CVQ=EPQ/ET                                                     AEXC30     46
      END IF                                                            AEXC30     47
C                                                                       AEXC30     48
C     INPUT FROM FIELD CURRENT LIMITER                                  AEXC30     49
C                                                                       AEXC30     50
      IF (CFDN.LE.DDAT(JE+16)) THEN                                     AEXC30     51
         CIFL=0.0                                                       AEXC30     52
      ELSE                                                              AEXC30     53
         CIFL=DDAT(JE+15)                                               AEXC30     54
      END IF                                                            AEXC30     55
C                                                                       AEXC30     56
C     TL1, TL2 BLOCK (OPTIONAL) -- COMMON FOR BOTH CASES                AEXC30     57
C                                                                       AEXC30     58
      CETL=DDAT(JE+21)                                                  AEXC30     59
      CVD=CVD*CETL                                                      AEXC30     60
      CVQ=CVQ*CETL                                                      AEXC30     61
      IF (ISUB2.EQ.0) THEN                                              AEXC30     62
         TL1TL2=1.0                                                     AEXC30     63
      ELSE                                                              AEXC30     64
         TL2I=1.0/DDAT(JE+23)                                           AEXC30     65
         TL1TL2=DDAT(JE+22)*TL2I                                        AEXC30     66
         A(ISUB2,ISUB2)=-TL2I                                           AEXC30     67
         B(ISUB2,1)=CVD*TL2I                                            AEXC30     68
         B(ISUB2,2)=CVQ*TL2I                                            AEXC30     69
         CVD=CVD*TL1TL2                                                 AEXC30     70
         CVQ=CVQ*TL1TL2                                                 AEXC30     71
      END IF                                                            AEXC30     72
C                                                                       AEXC30     73
      ICASE=IDDAT(JE+33)                                                AEXC30     74
C                                                                       AEXC30     75
      GOTO (100,200), ICASE                                             AEXC30     76
C                                                                       AEXC30     77
C     CASE 1 -- NORMAL CASE WITH TA NON-ZERO                            AEXC30     78
C                                                                       AEXC30     79
 100  CONTINUE                                                          AEXC30     80
C                                                                       AEXC30     81
C     KF, TF  BLOCK (OPTIONAL)                                          AEXC30     82
C                                                                       AEXC30     83
      IF (ISUB3.EQ.0) THEN                                              AEXC30     84
         CFTF=0.0                                                       AEXC30     85
         TF1TF2=0.0                                                     AEXC30     86
      ELSE                                                              AEXC30     87
         TFI=1.0/DDAT(JE+7)                                             AEXC30     88
         CFTF=DDAT(JE+6)*TFI                                            AEXC30     89
         A(ISUB3,ISUB3)=-TFI                                            AEXC30     90
         A(ISUB3,ISUB6)=TFI                                             AEXC30     91
C                                                                       AEXC30     92
C     TF1, TF2 BLOCK (OPTIONAL)                                         AEXC30     93
C                                                                       AEXC30     94
         IF (ISUB4.EQ.0) THEN                                           AEXC30     95
            TF1TF2=1.0                                                  AEXC30     96
         ELSE                                                           AEXC30     97
            TF2I=1.0/DDAT(JE+9)                                         AEXC30     98
            TF1TF2=DDAT(JE+8)*TF2I                                      AEXC30     99
            WS1=CFTF*TF2I                                               AEXC30    100
            A(ISUB4,ISUB3)=-WS1                                         AEXC30    101
            A(ISUB4,ISUB4)=-TF2I                                        AEXC30    102
            A(ISUB4,ISUB6)=WS1                                          AEXC30    103
         END IF                                                         AEXC30    104
C                                                                       AEXC30    105
      END IF                                                            AEXC30    106
C                                                                       AEXC30    107
C     TC, TB BLOCK (OPTIONAL)                                           AEXC30    108
C                                                                       AEXC30    109
      GAIN1=CFTF*TF1TF2                                                 AEXC30    110
      IF (ISUB5.EQ.0) THEN                                              AEXC30    111
         TCTB=1.0                                                       AEXC30    112
      ELSE                                                              AEXC30    113
         TBI=1.0/DDAT(JE+5)                                             AEXC30    114
         TCTB=DDAT(JE+4)*TBI                                            AEXC30    115
         A(ISUB5,ISUB5)=-TBI                                            AEXC30    116
         A(ISUB5,ISUB6)=-TBI*GAIN1                                      AEXC30    117
         IF (ISUB2.NE.0) A(ISUB5,ISUB2)=-TBI*(1.0-TL1TL2)               AEXC30    118
         IF (ISUB3.NE.0) THEN                                           AEXC30    119
            A(ISUB5,ISUB3)=TBI*GAIN1                                    AEXC30    120
            IF (ISUB4.NE.0) A(ISUB5,ISUB4)=-TBI*(1.0-TF1TF2)            AEXC30    121
         END IF                                                         AEXC30    122
C                                                                       AEXC30    123
         FIELD(ISUB5-ISTATE)=-TBI*CIFL                                  AEXC30    124
C                                                                       AEXC30    125
         IF (INPUTR.EQ.0) THEN                                          AEXC30    126
            CALL BCBTEM(ISUB5,TBI)                                      AEXC30    127
         ELSE                                                           AEXC30    128
            A(ISUB5,ISUB1)=-TBI                                         AEXC30    129
         END IF                                                         AEXC30    130
         B(ISUB5,1)=B(ISUB5,1)-CVD*TBI                                  AEXC30    131
         B(ISUB5,2)=B(ISUB5,2)-CVQ*TBI                                  AEXC30    132
C                                                                       AEXC30    133
         IUST(1)=ISUB5                                                  AEXC30    134
         GUST(1)=TBI                                                    AEXC30    135
C                                                                       AEXC30    136
      END IF                                                            AEXC30    137
C                                                                       AEXC30    138
C     TA BLOCK                                                          AEXC30    139
C                                                                       AEXC30    140
      TAI=1.0/DDAT(JE+3)                                                AEXC30    141
      CATA=DDAT(JE+2)*TAI                                               AEXC30    142
      GAIN2=TCTB*CATA                                                   AEXC30    143
      GAIN1=GAIN1*GAIN2                                                 AEXC30    144
      A(ISUB6,ISUB6)=-(TAI+GAIN1)                                       AEXC30    145
      IF (ISUB2.NE.0) A(ISUB6,ISUB2)=-GAIN2*(1.0-TL1TL2)                AEXC30    146
      IF (ISUB3.NE.0) THEN                                              AEXC30    147
         A(ISUB6,ISUB3)=GAIN1                                           AEXC30    148
         IF (ISUB4.NE.0) A(ISUB6,ISUB4)=-GAIN2*(1.0-TF1TF2)             AEXC30    149
      END IF                                                            AEXC30    150
      IF (ISUB5.NE.0) A(ISUB6,ISUB5)=CATA-GAIN2                         AEXC30    151
C                                                                       AEXC30    152
      FIELD(ISUB6-ISTATE)=-CIFL*GAIN2                                   AEXC30    153
C                                                                       AEXC30    154
      IF (INPUTR.EQ.0) THEN                                             AEXC30    155
         CALL BCBTEM(ISUB6,GAIN2)                                       AEXC30    156
      ELSE                                                              AEXC30    157
         A(ISUB6,ISUB1)=-GAIN2                                          AEXC30    158
      END IF                                                            AEXC30    159
      B(ISUB6,1)=B(ISUB6,1)-CVD*GAIN2                                   AEXC30    160
      B(ISUB6,2)=B(ISUB6,2)-CVQ*GAIN2                                   AEXC30    161
C                                                                       AEXC30    162
      IF (IUST(1).EQ.0) THEN                                            AEXC30    163
         IUST(1)=ISUB6                                                  AEXC30    164
         GUST(1)=GAIN2                                                  AEXC30    165
      ELSE                                                              AEXC30    166
         IUST(2)=ISUB6                                                  AEXC30    167
         GUST(2)=GAIN2                                                  AEXC30    168
      END IF                                                            AEXC30    169
C                                                                       AEXC30    170
C     OUTPUT EQUATION                                                   AEXC30    171
C                                                                       AEXC30    172
      A(3,ISUB6)=CFEXC                                                  AEXC30    173
C                                                                       AEXC30    174
C     END OF CASE 1                                                     AEXC30    175
C                                                                       AEXC30    176
      GOTO 300                                                          AEXC30    177
C                                                                       AEXC30    178
C     CASE 2 -- TA EQUAL TO ZERO                                        AEXC30    179
C                                                                       AEXC30    180
 200  CONTINUE                                                          AEXC30    181
      CA=DDAT(JE+2)                                                     AEXC30    182
C                                                                       AEXC30    183
C     CALCULATE ALP6                                                    AEXC30    184
C                                                                       AEXC30    185
      IF (ISUB5.EQ.0) THEN                                              AEXC30    186
         TCTB=1.0                                                       AEXC30    187
      ELSE                                                              AEXC30    188
         TBI=1.0/DDAT(JE+5)                                             AEXC30    189
         TCTB=DDAT(JE+4)*TBI                                            AEXC30    190
      END IF                                                            AEXC30    191
C                                                                       AEXC30    192
      IF (ISUB3.EQ.0) THEN                                              AEXC30    193
         CFTF=0.0                                                       AEXC30    194
         TF1TF2=0.0                                                     AEXC30    195
         GAIN1=0.0                                                      AEXC30    196
         ALP6=1.0                                                       AEXC30    197
      ELSE                                                              AEXC30    198
         TFI=1.0/DDAT(JE+7)                                             AEXC30    199
         CFTF=DDAT(JE+6)*TFI                                            AEXC30    200
         IF (ISUB4.EQ.0) THEN                                           AEXC30    201
            TF1TF2=1.0                                                  AEXC30    202
         ELSE                                                           AEXC30    203
            TF2I=1.0/DDAT(JE+9)                                         AEXC30    204
            TF1TF2=DDAT(JE+8)*TF2I                                      AEXC30    205
         END IF                                                         AEXC30    206
         GAIN1=CA*TCTB*CFTF*TF1TF2                                      AEXC30    207
         ALP6=1.0/(1.0+GAIN1)                                           AEXC30    208
      END IF                                                            AEXC30    209
      GAIN2=ALP6*TCTB*CA                                                AEXC30    210
      GAIN3=1.0-ALP6*GAIN1                                              AEXC30    211
C                                                                       AEXC30    212
C     KF, TF  BLOCK (OPTIONAL)                                          AEXC30    213
C                                                                       AEXC30    214
      IF (ISUB3.NE.0) THEN                                              AEXC30    215
         WS1=GAIN2*TFI                                                  AEXC30    216
         A(ISUB3,ISUB3)=-TFI*GAIN3                                      AEXC30    217
         IF (ISUB2.NE.0) A(ISUB3,ISUB2)=-WS1*(1.0-TL1TL2)               AEXC30    218
         IF (ISUB5.NE.0) A(ISUB3,ISUB5)=CA*TFI*(1.0-TCTB)*GAIN3         AEXC30    219
C                                                                       AEXC30    220
         FIELD(ISUB3-ISTATE)=-CIFL*WS1                                  AEXC30    221
C                                                                       AEXC30    222
         IF (INPUTR.EQ.0) THEN                                          AEXC30    223
            CALL BCBTEM(ISUB3,WS1)                                      AEXC30    224
         ELSE                                                           AEXC30    225
            A(ISUB3,ISUB1)=-WS1                                         AEXC30    226
         END IF                                                         AEXC30    227
         B(ISUB3,1)=B(ISUB3,1)-CVD*WS1                                  AEXC30    228
         B(ISUB3,2)=B(ISUB3,2)-CVQ*WS1                                  AEXC30    229
C                                                                       AEXC30    230
         IUST(1)=ISUB3                                                  AEXC30    231
         GUST(1)=WS1                                                    AEXC30    232
C                                                                       AEXC30    233
C     TF1, TF2 BLOCK (OPTIONAL)                                         AEXC30    234
C                                                                       AEXC30    235
         IF (ISUB4.NE.0) THEN                                           AEXC30    236
            A(ISUB3,ISUB4)=-WS1*(1.0-TF1TF2)                            AEXC30    237
            WS1=GAIN2*CFTF*TF2I                                         AEXC30    238
            A(ISUB4,ISUB3)=-CFTF*TF2I*GAIN3                             AEXC30    239
            A(ISUB4,ISUB4)=-(TF2I+WS1*(1.0-TF1TF2))                     AEXC30    240
            IF (ISUB2.NE.0) A(ISUB4,ISUB2)=-WS1*(1.0-TL1TL2)            AEXC30    241
            IF (ISUB5.NE.0) A(ISUB4,ISUB5)=CA*CFTF*TF2I*(1.0-TCTB)*GAIN3AEXC30    242
C                                                                       AEXC30    243
            FIELD(ISUB4-ISTATE)=-CIFL*WS1                               AEXC30    244
C                                                                       AEXC30    245
            IF (INPUTR.EQ.0) THEN                                       AEXC30    246
               CALL BCBTEM(ISUB4,WS1)                                   AEXC30    247
            ELSE                                                        AEXC30    248
               A(ISUB4,ISUB1)=-WS1                                      AEXC30    249
            END IF                                                      AEXC30    250
            B(ISUB4,1)=B(ISUB4,1)-CVD*WS1                               AEXC30    251
            B(ISUB4,2)=B(ISUB4,2)-CVQ*WS1                               AEXC30    252
C                                                                       AEXC30    253
            IUST(2)=ISUB4                                               AEXC30    254
            GUST(2)=WS1                                                 AEXC30    255
C                                                                       AEXC30    256
         END IF                                                         AEXC30    257
C                                                                       AEXC30    258
      END IF                                                            AEXC30    259
C                                                                       AEXC30    260
C     TC, TB BLOCK (OPTIONAL)                                           AEXC30    261
C                                                                       AEXC30    262
      IF (ISUB5.NE.0) THEN                                              AEXC30    263
         WS1=ALP6*TBI                                                   AEXC30    264
         WS2=WS1*CFTF*TF1TF2                                            AEXC30    265
         A(ISUB5,ISUB5)=-(TBI+CA*WS2*(1.0-TCTB))                        AEXC30    266
         IF (ISUB2.NE.0) A(ISUB5,ISUB2)=-WS1*(1.0-TL1TL2)               AEXC30    267
         IF (ISUB3.NE.0) THEN                                           AEXC30    268
            A(ISUB5,ISUB3)=WS2                                          AEXC30    269
            IF (ISUB4.NE.0) A(ISUB5,ISUB4)=-WS1*(1.0-TF1TF2)            AEXC30    270
         END IF                                                         AEXC30    271
C                                                                       AEXC30    272
         FIELD(ISUB5-ISTATE)=-CIFL*WS1                                  AEXC30    273
C                                                                       AEXC30    274
         IF (INPUTR.EQ.0) THEN                                          AEXC30    275
            CALL BCBTEM(ISUB5,WS1)                                      AEXC30    276
         ELSE                                                           AEXC30    277
            A(ISUB5,ISUB1)=-WS1                                         AEXC30    278
         END IF                                                         AEXC30    279
         B(ISUB5,1)=B(ISUB5,1)-CVD*WS1                                  AEXC30    280
         B(ISUB5,2)=B(ISUB5,2)-CVQ*WS1                                  AEXC30    281
C                                                                       AEXC30    282
         IF (IUST(1).EQ.0) THEN                                         AEXC30    283
            IUST(1)=ISUB5                                               AEXC30    284
            GUST(1)=WS1                                                 AEXC30    285
         ELSE IF (IUST(2).EQ.0) THEN                                    AEXC30    286
            IUST(2)=ISUB5                                               AEXC30    287
            GUST(2)=WS1                                                 AEXC30    288
         ELSE                                                           AEXC30    289
            IUST(3)=ISUB5                                               AEXC30    290
            GUST(3)=WS1                                                 AEXC30    291
         END IF                                                         AEXC30    292
C                                                                       AEXC30    293
      END IF                                                            AEXC30    294
C                                                                       AEXC30    295
C     OUTPUT EQUATION                                                   AEXC30    296
C                                                                       AEXC30    297
C     CALCULATE CURRENT AND VOLTAGE COMPONENTS IN OUTPUT EQUATION       AEXC30    298
C                                                                       AEXC30    299
      GAIN4=CFEXC*GAIN2                                                 AEXC30    300
      CF=CFEXC*XAD                                                      AEXC30    301
      WS1=CF*GAIN2                                                      AEXC30    302
      IF (INPUTR.EQ.0) THEN                                             AEXC30    303
         B(3,1)=B(3,1)-WS1*ALP1                                         AEXC30    304
         B(3,2)=B(3,2)-WS1*ALP2                                         AEXC30    305
         B(3,KN-1)=B(3,KN-1)-WS1*ALP3                                   AEXC30    306
         B(3,KN)=B(3,KN)-WS1*ALP4                                       AEXC30    307
      ELSE                                                              AEXC30    308
         A(3,ISUB1)=-GAIN4                                              AEXC30    309
      END IF                                                            AEXC30    310
      B(3,1)=B(3,1)-WS1*CVD                                             AEXC30    311
      B(3,2)=B(3,2)-WS1*CVQ                                             AEXC30    312
C                                                                       AEXC30    313
C     CALCULATE FIELD CURRENT COMPONENT IN OUTPUT EQUATION              AEXC30    314
C                                                                       AEXC30    315
      FCURR=-CIFL*GAIN2                                                 AEXC30    316
C                                                                       AEXC30    317
C     CALCULATE THE COUPLING ELEMENTS IN STATE EQUATION DUE TO          AEXC30    318
C     THE STATE COMPONENTS IN OUTPUT EQUATION. A(3,ISUB1) IS            AEXC30    319
C     ALREADY CALCULATED ABOVE                                          AEXC30    320
C                                                                       AEXC30    321
      IF (ISUB2.NE.0) A(3,ISUB2)=-GAIN4*(1.0-TL1TL2)                    AEXC30    322
      IF (ISUB3.NE.0) THEN                                              AEXC30    323
         A(3,ISUB3)=CFEXC*ALP6*GAIN1                                    AEXC30    324
         IF (ISUB4.NE.0) A(3,ISUB4)=-GAIN4*(1.0-TF1TF2)                 AEXC30    325
      END IF                                                            AEXC30    326
      IF (ISUB5.NE.0) A(3,ISUB5)=CFEXC*CA*(1.0-TCTB)*GAIN3              AEXC30    327
C                                                                       AEXC30    328
      IF (IUST(1).EQ.0) THEN                                            AEXC30    329
         IUST(1)=3                                                      AEXC30    330
         GUST(1)=GAIN4                                                  AEXC30    331
      ELSE IF (IUST(2).EQ.0) THEN                                       AEXC30    332
         IUST(2)=3                                                      AEXC30    333
         GUST(2)=GAIN4                                                  AEXC30    334
      ELSE IF (IUST(3).EQ.0) THEN                                       AEXC30    335
         IUST(3)=3                                                      AEXC30    336
         GUST(3)=GAIN4                                                  AEXC30    337
      ELSE                                                              AEXC30    338
         IUST(4)=3                                                      AEXC30    339
         GUST(4)=GAIN4                                                  AEXC30    340
      END IF                                                            AEXC30    341
C                                                                       AEXC30    342
C     ELIMINATE FIELD CURRENT COMPONENT IN OUTPUT EQUATION              AEXC30    343
C                                                                       AEXC30    344
      FCURR=CF*FCURR                                                    AEXC30    345
      DO 20 I=1,MD+1                                                    AEXC30    346
         A(3,I+1)=A(3,I+1)+FCURR*FCTM(I)                                AEXC30    347
  20  CONTINUE                                                          AEXC30    348
C                                                                       AEXC30    349
      BC(3,1)=BC(3,1)+FCURR*FCTM(5)                                     AEXC30    350
      BC(3,2)=BC(3,2)+FCURR*FCTM(6)                                     AEXC30    351
C                                                                       AEXC30    352
C     BOTH CASES REACH HERE                                             AEXC30    353
C                                                                       AEXC30    354
 300  CONTINUE                                                          AEXC30    355
C                                                                       AEXC30    356
C     ELIMINATE THE FIELD CURRENT TERM IN STATE EQUATION                AEXC30    357
C                                                                       AEXC30    358
      DO 30 I=2,6                                                       AEXC30    359
         IF (IFIELD(I).EQ.0) GOTO 30                                    AEXC30    360
         II=ISTATE+I                                                    AEXC30    361
         WS1=XAD*FIELD(I)                                               AEXC30    362
C                                                                       AEXC30    363
         DO 40 J=1,MD+1                                                 AEXC30    364
            A(II,J+1)=WS1*FCTM(J)                                       AEXC30    365
  40     CONTINUE                                                       AEXC30    366
C                                                                       AEXC30    367
         BC(II,1)=BC(II,1)+WS1*FCTM(5)                                  AEXC30    368
         BC(II,2)=BC(II,2)+WS1*FCTM(6)                                  AEXC30    369
C                                                                       AEXC30    370
  30  CONTINUE                                                          AEXC30    371
C                                                                       AEXC30    372
      ISTATE=ISUB6                                                      AEXC30    373
C                                                                       AEXC30    374
      RETURN                                                            AEXC30    375
      END                                                               AEXC30    376
