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