CFPRIME GENINT                                                          GENINT      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 GENINT(ILARGE,*,*)                                     GENINT      3
CD                                                                      GENINT      4
CD    THIS SUBROUTINE INITIALIZES DETAILED GENERATOR, ITS ASSOCIATED    GENINT      5
CD    CONTROL DEVICES, AND CLASSICAL GENERATOR.                         GENINT      6
CD                                                                      GENINT      7
CD    THE DATA STRUCTURE OF MACHINES AFTER THE INITIALIZATION IS GIVEN  GENINT      8
CD    BELOW.                                                            GENINT      9
CD                                                                      GENINT     10
CD                                                                      GENINT     11
CD   Generator Data Map                                                 GENINT     12
CD                                                                      GENINT     13
CD   1. Generators and associated controls                              GENINT     14
CD                                                                      GENINT     15
CD     NC                      : machine number                         GENINT     16
CD     CID = NDGC(N)           : generator identity                     GENINT     17
CD                                                                      GENINT     18
CD     Generator and Control device type array                          GENINT     19
CD                                                                      GENINT     20
CD     IGEN   = ICONTA(1,N)    : machine data type                      GENINT     21
CD     IGVN   = ICONTA(2,N)    : governor type                          GENINT     22
CD     ISAT   = ICONTA(3,N)    : machine saturation type                GENINT     23
CD     IEX    = ICONTA(4,N)    : exciter type                           GENINT     24
CD     ISTAB  = ICONTA(5,N)    : stabilizer type                        GENINT     25
CD     IFLTR  = ICONTA(6,N)    : torsional filter type                  GENINT     26
CD     IUAL   = ICONTA(7,N)    : under excitation limiter type          GENINT     27
CD     IMASS  = ICONTA(8,N)    : multi-mass type                        GENINT     28
CD     ICBR   = ICONTA(9,N)    : crowbar type                           GENINT     29
CD     IGSTA  = ICONTA(10,N)   : governor stabilizer type               GENINT     30
CD     ITEB   = ICONTA(11,N)   : transient excitation booster type      GENINT     31
CD     IMXLN  = ICONTA(12,N)   : over excitation current limiter type   GENINT     32
CD     IFDSN  = ICONTA(13,N)   : sign of field current                  GENINT     33
CD     LVUEL  = ICONTA(14,N)   : location of UEL signal in exciter      GENINT     34
CD     LVOEL  = ICONTA(15,N)   : location of OEL signal in exciter      GENINT     35
CD     LVS    = ICONTA(16,N)   : location of VS signal in exciter       GENINT     36
CD                                                                      GENINT     37
CD     Model data offsets                                               GENINT     38
CD                                                                      GENINT     39
CD     JG     = JCONTA(1,N)    : machine data vector offset             GENINT     40
CD     JGG    = JCONTA(2,N)    : governor data vector offset            GENINT     41
CD     JGGP1  = JCONTA(2,N+1)  : governor data vector offset of next    GENINT     42
CD                               generator                              GENINT     43
CD     JE     = JCONTA(3,N)    : exciter data vector offset             GENINT     44
CD     JS     = JCONTA(4,N)    : stabilizer data vector offset          GENINT     45
CD     JF     = JCONTA(5,N)    : torsional filter data vector offset    GENINT     46
CD     JU     = JCONTA(6,N)    : under excitation current limiter data  GENINT     47
CD                               vector offset                          GENINT     48
CD     JM     = JCONTA(7,N)    : multi-mass data vector offset          GENINT     49
CD     JCB    = JCONTA(8,N)    : crowbar  data vector offset            GENINT     50
CD     JGS    = JCONTA(9,N)    : governor stabilizer data vector offset GENINT     51
CD     JTB    = JCONTA(10,N)   : transient excitation booster data vectoGENINT     52
CD                               offset                                 GENINT     53
CD     JMX    = JCONTA(11,N)   : over excitation current limiter data   GENINT     54
CD                               vector offset                          GENINT     55
CD                                                                      GENINT     56
CD     State offsets                                                    GENINT     57
CD                                                                      GENINT     58
CD     JGS    = MSTATE(1,N)    : machine state vector offset            GENINT     59
CD     JES    = MSTATE(2,N)    : exciter state vector offset            GENINT     60
CD     JSS    = MSTATE(3,N)    : stabilizer state vector offset         GENINT     61
CD     JUS    = MSTATE(4,N)    : under excitation current limiter state GENINT     62
CD                               vector offset                          GENINT     63
CD     JPS    = MSTATE(5,N)    : governor state vector offset           GENINT     64
CD     JPSS   = MSTATE(6,N)    : governor stabilizer state vector offsetGENINT     65
CD     JMXS   = MSTATE(7,N)    : over excitation current limiter state  GENINT     66
CD                               vector offset                          GENINT     67
CD                                                                      GENINT     68
CD     Y-variable offsets                                               GENINT     69
CD                                                                      GENINT     70
CD     JYG    = MYVAR(1,N)     : machine Y-variable vector offset       GENINT     71
CD     JYE    = MYVAR(2,N)     : exciter Y-variable vector offset       GENINT     72
CD     JYS    = MYVAR(3,N)     : stabilizer Y-variable vector offset    GENINT     73
CD     JYU    = MYVAR(4,N)     : under excitation current limiter       GENINT     74
CD                               Y-variable vector offset               GENINT     75
CD     JYP    = MYVAR(5,N)     : governor Y-variable vector offset      GENINT     76
CD     JYPS   = MYVAR(6,N)     : governor stabilizer Y-variable vector  GENINT     77
CD                               offset                                 GENINT     78
CD     JYTB   = MYVAR(7,N)     : transient excitation booster Y-variableGENINT     79
CD                               vector offset                          GENINT     80
CD     JYMX   = MYVAR(8,N)     : maximum excitation current limiter     GENINT     81
CD                               Y-variable offset                      GENINT     82
CD                                                                      GENINT     83
CD   Classical Machine data array                                       GENINT     84
CD                                                                      GENINT     85
CD     DDAT(JG+1) = 0.5*WXBASE/HM                                       GENINT     86
CD     DDAT(JG+2) = DAMP                                                GENINT     87
CD     DDAT(JG+3) = BMVA                                                GENINT     88
CD     DDAT(JG+4) = BVR                                                 GENINT     89
CD     DDAT(JG+5) = WXBASE                                              GENINT     90
CD                                                                      GENINT     91
CD     XPD(N) = 1.0/XPD                                                 GENINT     92
CD                                                                      GENINT     93
CD   Detailed machine data array                                        GENINT     94
CD                                                                      GENINT     95
CD     DDAT(JG+ 1) = 0.5*WXBASE/HM                                      GENINT     96
CD     DDAT(JG+ 2) = DAMP                                               GENINT     97
CD     DDAT(JG+ 3) = BVR                                                GENINT     98
CD     DDAT(JG+ 4) = BMVA                                               GENINT     99
CD     DDAT(JG+ 5) = WXBASE                                             GENINT    100
CD     DDAT(JG+ 6) = XAD                                                GENINT    101
CD     DDAT(JG+ 7) = XAQ                                                GENINT    102
CD     DDAT(JG+ 8) = XL                                                 GENINT    103
CD     DDAT(JG+ 9) = RA                                                 GENINT    104
CD     DDAT(JG+10) = XFD                                                GENINT    105
CD     DDAT(JG+11) = RFD                                                GENINT    106
CD     DDAT(JG+12) = XKQ1                                               GENINT    107
CD     DDAT(JG+13) = RKQ1                                               GENINT    108
CD     DDAT(JG+14) = XKD1                                               GENINT    109
CD     DDAT(JG+15) = RKD1                                               GENINT    110
CD     DDAT(JG+16) = XKQ2                                               GENINT    111
CD     DDAT(JG+17) = RKQ2                                               GENINT    112
CD     DDAT(JG+18) = XKD2                                               GENINT    113
CD     DDAT(JG+19) = RKD2                                               GENINT    114
CD     DDAT(JG+20) = XKQ3                                               GENINT    115
CD     DDAT(JG+21) = RKQ3                                               GENINT    116
CD     DDAT(JG+22) = AXD                                                GENINT    117
CD     DDAT(JG+23) = AXQ                                                GENINT    118
CD     DDAT(JG+24) = XFKD1                                              GENINT    119
CD     DDAT(JG+25) = XFKD2                                              GENINT    120
CD     DDAT(JG+26) = ASAT                                               GENINT    121
CD     DDAT(JG+27) = BSAT                                               GENINT    122
CD     DDAT(JG+28) =  L                                                 GENINT    123
CD     DDAT(JG+29) =  M                                                 GENINT    124
CD     DDAT(JG+30) = RS                                                 GENINT    125
CD     DDAT(JG+31) = CMTL                                               GENINT    126
CD     DDAT(JG+32) = SD                                                 GENINT    127
CD     DDAT(JG+33) = SQ                                                 GENINT    128
CD     IDDAT(JG+34) = MD                                                GENINT    129
CD     IDDAT(JG+35) = MQ       : no. of damper windings on q axis + 1   GENINT    130
CD     DDAT(JG+36) = IXKD1     : if XC1 or XC2 are represented,         GENINT    131
CD                               store KDT*XD-1                         GENINT    132
CD     DDAT(JG+37) = IXKD2                                              GENINT    133
CD     DDAT(JG+38) = IXKD3                                              GENINT    134
CD                                                                      GENINT    135
CD     Common data for detailed generator ends here                     GENINT    136
CD                                                                      GENINT    137
CD     DDAT(JG+39) = IX11      : if XC1 or XC2 are represented, store   GENINT    138
CD                               upper triangular part of XD-1          GENINT    139
CD     DDAT(JG+40) = IX12                                               GENINT    140
CD     DDAT(JG+41) = IX13                                               GENINT    141
CD     DDAT(JG+42) = IX22                                               GENINT    142
CD     DDAT(JG+43) = IX23                                               GENINT    143
CD     DDAT(JG+44) = IX33                                               GENINT    144
CD                                                                      GENINT    145
CD     DDAT(JG+45) = ASATQ     : if q axis saturation is represented    GENINT    146
CD                               separately                             GENINT    147
CD     DDAT(JG+46) = BSATQ                                              GENINT    148
CD     DDAT(JG+47) =  LQ                                                GENINT    149
CD     DDAT(JG+48) =  MQ                                                GENINT    150
CD     DDAT(JG+49) = RSQ                                                GENINT    151
CD                                                                      GENINT    152
CD     Classical Machine states                                         GENINT    153
CD                                                                      GENINT    154
CD     XSTATE(JS+1) = speed                                             GENINT    155
CD     XSTATE(JS+2) = rotor angle                                       GENINT    156
CD                                                                      GENINT    157
CD     Detailed Machine states                                          GENINT    158
CD                                                                      GENINT    159
CD     XSTATE(JGS+1)  = SPEED        : actual no. of states = MD+MQ+1   GENINT    160
CD     XSTATE(JGS+2)  = DELTA                                           GENINT    161
CD     XSTATE(JGS+3)  = SIF          : states after this are optional   GENINT    162
CD     XSTATE(JGS+4)  = SIKD                                            GENINT    163
CD     XSTATE(JGS+5)  = SIKD2                                           GENINT    164
CD     XSTATE(JGS+6)  = SIKQ                                            GENINT    165
CD     XSTATE(JGS+7)  = SIKQ1                                           GENINT    166
CD     XSTATE(JGS+8)  = SIKQ2                                           GENINT    167
CD                                                                      GENINT    168
CD     Classical Machine Y-variables                                    GENINT    169
CD                                                                      GENINT    170
CD     YVAR(JYG+1) <=> TIN(JYG+1)  = mechanical torque                  GENINT    171
CD     YVAR(JYG+2) <=> PDG(JYG+2)  = real generation                    GENINT    172
CD     YVAR(JYG+3) <=> PQG(JYG+3)  = reactive generation                GENINT    173
CD     YVAR(JYG+4) <=> EMG(JYG+4)  = magnitude of equivalent norton     GENINT    174
CD                                   current source                     GENINT    175
CD     YVAR(JYG+5) <=> ACCP(JYG+1) = accelerating power                 GENINT    176
CD                                                                      GENINT    177
CD     Detailed Machine Y-variables                                     GENINT    178
CD                                                                      GENINT    179
CD     YVAR(JYG+1) <=> TIN (JYG+1)  =     mechanical torque             GENINT    180
CD     YVAR(JYG+2) <=> PDG (JYG+2)  =     active generation             GENINT    181
CD     YVAR(JYG+3) <=> PQG (JYG+3)  =     reactive generation           GENINT    182
CD     YVAR(JYG+4) <=> EFD (JYG+4)  =     field voltage                 GENINT    183
CD     YVAR(JYG+5) <=> CFD (JYG+5)  =     field current                 GENINT    184
CD     YVAR(JYG+6) <=> ACCP(JYG+6)  =     accelerating power            GENINT    185
CD                                                                      GENINT    186
      INCLUDE 'PARX.INS'                                                GENINT    187
      INCLUDE 'CNPARX.INS'                                              GENINT    188
      INCLUDE 'CNPT.INS'                                                GENINT    189
      INCLUDE 'CNIPTR.INS'                                              GENINT    190
      INCLUDE 'CNSTN.INS'                                               GENINT    191
      INCLUDE 'CNVOLT.INS'                                              GENINT    192
      INCLUDE 'CNB0.INS'                                                GENINT    193
      INCLUDE 'CNMDAT.INS'                                              GENINT    194
      INCLUDE 'CNB1.INS'                                                GENINT    195
      INCLUDE 'CNGDAT.INS'                                              GENINT    196
      INCLUDE 'CNB3.INS'                                                GENINT    197
      INCLUDE 'CNB4.INS'                                                GENINT    198
      INCLUDE 'CNB5.INS'                                                GENINT    199
      INCLUDE 'CNMSTA.INS'                                              GENINT    200
      INCLUDE 'CNXSTA.INS'                                              GENINT    201
      INCLUDE 'CNB8.INS'                                                GENINT    202
      INCLUDE 'CNB10.INS'                                               GENINT    203
      INCLUDE 'CNB19.INS'                                               GENINT    204
      INCLUDE 'CNFLAG.INS'                                              GENINT    205
      INCLUDE 'CNEXC.INS'                                               GENINT    206
      INCLUDE 'CNUDM.INS'                                               GENINT    207
      INCLUDE 'CNPRGV.INS'                                              GENINT    208
      INCLUDE 'CNQSTA.INS'                                              GENINT    209
      INCLUDE 'CNXDOT.INS'                                              GENINT    210
      INCLUDE 'CNMYVA.INS'                                              GENINT    211
      INCLUDE 'CNYVAR.INS'                                              GENINT    212
      INCLUDE 'CNUNIT.INS'                                              GENINT    213
      INCLUDE 'CNIMPR.INS'                                              GENINT    214
C                                                                       GENINT    215
      INCLUDE 'EQQSTA.INS'                                              GENINT    216
      INCLUDE 'CNMSG.INS'                                               GENINT    217
      INCLUDE 'CNENG1.INS'                                              GENINT    218
C                                                                       GENINT    219
      CHARACTER*2 CID,CID1,CID5                                         GENINT    220
      CHARACTER*4 CKID5                                                 GENINT    221
*IF -MI2                                                                GENINT    222
      INTEGER*2 MYVDG                                                   GENINT    223
*ENDIF                                                                  GENINT    224
      DIMENSION  MYVDG(MP*9)                                            GENINT    225
      EQUIVALENCE (MYVAR(1,1),MYVDG(1))                                 GENINT    226
      COMPLEX VOLTG,VOLTC                                               GENINT    227
      DIMENSION EVOLTG(2),EVOLTC(2)                                     GENINT    228
      EQUIVALENCE (VOLTG,EVOLTG(1),GTREAL),(EVOLTG(2),GTIMAG)           GENINT    229
      EQUIVALENCE (VOLTC,EVOLTC(1),CVREAL),(EVOLTC(2),CVIMAG)           GENINT    230
C                                                                       GENINT    231
      LDEB=(JDEB(28).NE.0)                                              GENINT    232
      IEBK=0                                                            GENINT    233
      IERR1=0                                                           GENINT    234
      IERR2=0                                                           GENINT    235
      IERR3=0                                                           GENINT    236
C                                                                       GENINT    237
      CALL HMOVE(0,MYVDG,MYVDG,MP*9)                                    GENINT    238
C                                                                       GENINT    239
      SYSTH=0.0                                                         GENINT    240
      IFC=0                                                             GENINT    241
      N=0                                                               GENINT    242
      KN=0                                                              GENINT    243
      KK=0                                                              GENINT    244
      JSTATE=0                                                          GENINT    245
      ILARGE=1                                                          GENINT    246
      XLARGE=0                                                          GENINT    247
      TOTALP=0.0                                                        GENINT    248
      TOTALK=0.0                                                        GENINT    249
      TKEMIN=0.0                                                        GENINT    250
      XKEMIN=0.0                                                        GENINT    251
      TPEMAX=0.0                                                        GENINT    252
      XPEMAX=0.0                                                        GENINT    253
      SPEEDC=0.0                                                        GENINT    254
      ANGLEC=0.0                                                        GENINT    255
      ILBOIL=0                                                          GENINT    256
C                                                                       GENINT    257
      NSTATE=0                                                          GENINT    258
C                                                                       GENINT    259
      TIN5=0.0                                                          GENINT    260
      JY=0                                                              GENINT    261
      IEEXIN=0                                                          GENINT    262
      IF (NT.EQ.0) GO TO 2550                                           GENINT    263
      DO 2500 K=1,IPNODE                                                GENINT    264
      KK=KK+2                                                           GENINT    265
      KN=KN+3                                                           GENINT    266
      YLARGE=0.0                                                        GENINT    267
      VOLTG=VOLT(K)                                                     GENINT    268
      VANG=ATAN2(GTREAL,GTIMAG)                                         GENINT    269
      VMAG=GTREAL**2+GTIMAG**2                                          GENINT    270
      GTV=SQRT(VMAG)                                                    GENINT    271
      EDEM=GTREAL/VMAG                                                  GENINT    272
      EQEM=GTIMAG/VMAG                                                  GENINT    273
      AT=ATAN2(GTIMAG,GTREAL)                                           GENINT    274
      NLF=NOLD(K)                                                       GENINT    275
      IK=K                                                              GENINT    276
      DO 2450 J=1,KTHGE(K)                                              GENINT    277
      N=N+1                                                             GENINT    278
      FOLD(N)=0.0                                                       GENINT    279
      FUNC(N)=0.0                                                       GENINT    280
      VPE(N)=0.0                                                        GENINT    281
      XSPEED(N)=0.0                                                     GENINT    282
      NGBUS(N)=K                                                        GENINT    283
      CID=NDGC(N)(3:4)                                                  GENINT    284
      MSTATE(1,N)=JSTATE                                                GENINT    285
      IGENS=ICONTA(1,N)                                                 GENINT    286
      IF(IGENS.EQ.3.OR.IGENS.EQ.7.OR.IGENS.EQ.11)THEN                   GENINT    287
C                                                                       GENINT    288
C  CLASSICAL MACHINE                                                    GENINT    289
C                                                                       GENINT    290
         ICONTA(1,N)=4                                                  GENINT    291
         IF(JSTATE+2.GT.NSI) RETURN 1                                   GENINT    292
         IF(JY+5.GT.NSI) RETURN 2                                       GENINT    293
         NBFT=NBFT+1                                                    GENINT    294
         KCGEN(1,NBFT)=K                                                GENINT    295
         KCGEN(2,NBFT)=N                                                GENINT    296
         JG=JCONTA(1,N)                                                 GENINT    297
         MYVAR(1,N)=JY                                                  GENINT    298
         JYG=JY                                                         GENINT    299
         GMWX=PDGT(1,N)*BASPC                                           GENINT    300
         GMXX=PDGT(2,N)*BASPC                                           GENINT    301
         PDGN=PDGT(1,N)                                                 GENINT    302
         IF(GMWX.GT.XLARGE)THEN                                         GENINT    303
            ILARGE=K                                                    GENINT    304
            XLARGE=GMWX                                                 GENINT    305
         ENDIF                                                          GENINT    306
         PDG(JY+2)=PDGT(1,N)                                            GENINT    307
         PQG(JY+3)=PDGT(2,N)                                            GENINT    308
         TIN(JY+1)=PDG(JY+2)                                            GENINT    309
         ACCP(JY+5)=0.0                                                 GENINT    310
         WXBASE=DDAT(JG+5)                                              GENINT    311
C                                                                       GENINT    312
C  INITIALIZE TIN=0.0 FOR FREQUENCY CONVERTORS                          GENINT    313
C                                                                       GENINT    314
         IF (IFC.NE.0) THEN                                             GENINT    315
            IFC=IFC-1                                                   GENINT    316
            TIN(JY+1)=0.0                                               GENINT    317
         ELSEIF(N.LT.NT)THEN                                            GENINT    318
            JGP1=JCONTA(1,N+1)+5                                        GENINT    319
            IF ((IDDAT(JG+5)-IDDAT(JGP1)).NE.0) THEN                    GENINT    320
               IFC=1                                                    GENINT    321
               PSUM=ABS(PDG(JY+2)+PDGT(1,N+1))                          GENINT    322
               IF (PSUM.GT.1.E-3) THEN                                  GENINT    323
                  K3=K*3                                                GENINT    324
                  NLF=NOLD(K)                                           GENINT    325
                  K31=(K+1)*3                                           GENINT    326
                  NLF1=NOLD(K+1)                                        GENINT    327
                  WRITE(MSG(1),3110)                                    GENINT    328
                  WRITE(MSG(2),3125) NLF,INAME(K3-2),INAME(K3-1)        GENINT    329
     *                           ,INAME(K3),NLF1,INAME(K31-2)           GENINT    330
     *                           ,INAME(K31-1),INAME(K31)               GENINT    331
                  WRITE(MSG(3),3130)                                    GENINT    332
                  CALL PRTMSG(3)                                        GENINT    333
                  IERR3=1                                               GENINT    334
                  IEBK=1                                                GENINT    335
               END IF                                                   GENINT    336
               TIN(JY+1)=0.0                                            GENINT    337
            END IF                                                      GENINT    338
         END IF                                                         GENINT    339
C                                                                       GENINT    340
         ET=CABS(VOLTG)                                                 GENINT    341
         DAMPX=DDAT(JG+2)                                               GENINT    342
         HMX=DDAT(JG+1)                                                 GENINT    343
         HMK=WXBASE/(2.0*HMX)                                           GENINT    344
         DAMPK=DAMPX/WXBASE                                             GENINT    345
C                                                                       GENINT    346
         DDAT(JG+1)=0.5*WXBASE/HMX                                      GENINT    347
         DDAT(JG+2)=DAMPX/WXBASE                                        GENINT    348
         IF (IDDAT(JG+3).EQ.0.OR.IDDAT(JG+4).EQ.0) THEN                 GENINT    349
            DDAT(JG+3)=BASPC                                            GENINT    350
            DDAT(JG+4)=1.0                                              GENINT    351
         END IF                                                         GENINT    352
         SYSTH=SYSTH+1.0/DDAT(JG+1)                                     GENINT    353
C                                                                       GENINT    354
         XPDN=1.0/XPD(N)                                                GENINT    355
         CDGN=CDG(1,N)                                                  GENINT    356
         CQGN=CDG(2,N)                                                  GENINT    357
         EPD=GTREAL-XPDN*CQGN                                           GENINT    358
         EPQ=GTIMAG+XPDN*CDGN                                           GENINT    359
         EMG(JY+4)=SQRT(EPD**2+EPQ**2)/XPDN                             GENINT    360
C                                                                       GENINT    361
C  SET THE STATE VARIABLES AND THE STATE POINTERS, I.E. JGSTA(*)...     GENINT    362
C                                                                       GENINT    363
         MSTATE(1,N)=JSTATE                                             GENINT    364
         XSTATE(JSTATE+1)=0.0                                           GENINT    365
         DELTA=ATAN2(EPQ,EPD)                                           GENINT    366
C                                                                       GENINT    367
C-----------------------------------------------------------------------GENINT    368
C                                                                       GENINT    369
C     THESE CODES ARE USED TO OBTAIN CONSISTENT MACHINE ANGLES.         GENINT    370
C     IF PROBLEMS ARE FOUND LATE IN THE PROGRAM, CHANGE THESE CODES     GENINT    371
C     OR DELETE THEM.                                                   GENINT    372
C                                                                       GENINT    373
C         IF (DELTA.GT.3.1415927) THEN                                  GENINT    374
C            DELTA=DELTA-6.2831853                                      GENINT    375
C         ELSE IF (DELTA.LT.-3.1415927) THEN                            GENINT    376
C            DELTA=6.2831853+DELTA                                      GENINT    377
C         END IF                                                        GENINT    378
C                                                                       GENINT    379
C-----------------------------------------------------------------------GENINT    380
C                                                                       GENINT    381
         XSTATE(JSTATE+2)=DELTA                                         GENINT    382
         XANGLO(N)=DELTA                                                GENINT    383
         ANGXC2(N)=DELTA                                                GENINT    384
         XDFACT(JSTATE+1)=DDAT(JG+1)                                    GENINT    385
         JSTATE=JSTATE+2                                                GENINT    386
         JY=JY+5                                                        GENINT    387
         GOTO 560                                                       GENINT    388
      ENDIF                                                             GENINT    389
      IF(JSTATE+50.GT.NSI) RETURN 1                                     GENINT    390
      IF(JY+200.GT.NSI) RETURN 2                                        GENINT    391
      IF (LDEB)                                                         GENINT    392
     *WRITE(IUD6,2750) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID        GENINT    393
      NPGEN=NPGEN+1                                                     GENINT    394
      KPGEN(1,NPGEN)=K                                                  GENINT    395
      KPGEN(2,NPGEN)=N                                                  GENINT    396
      MYVAR(1,N)=JY                                                     GENINT    397
      JYG=JY                                                            GENINT    398
      JG=JCONTA(1,N)                                                    GENINT    399
      ISATN=ICONTA(3,N)                                                 GENINT    400
      MASSN=ICONTA(8,N)                                                 GENINT    401
      PDGN=PDGT(1,N)                                                    GENINT    402
      PQGN=PDGT(2,N)                                                    GENINT    403
      PDG(JYG+2)=PDGN                                                   GENINT    404
      PQG(JYG+3)=PQGN                                                   GENINT    405
      GMWX=PDGN*BASPC                                                   GENINT    406
      GMXX=PQGN*BASPC                                                   GENINT    407
      YLARGE=YLARGE+GMWX                                                GENINT    408
      IPGX=IPFG(N)                                                      GENINT    409
      IQGX=IQFG(N)                                                      GENINT    410
      WXBASE=DDAT(JG+5)                                                 GENINT    411
      FBGN=WXBASE*0.25*PI                                               GENINT    412
      IF (IDDAT(JG+3).EQ.0.OR.IDDAT(JG+4).EQ.0) THEN                    GENINT    413
         BMVA=BASPC                                                     GENINT    414
         DDAT(JG+3)=BASPC                                               GENINT    415
         DDAT(JG+4)=1.0                                                 GENINT    416
         BASVRN=1.0                                                     GENINT    417
         JBASE=0                                                        GENINT    418
      ELSE                                                              GENINT    419
         BMVA=DDAT(JG+3)                                                GENINT    420
         BASVRN=DDAT(JG+4)                                              GENINT    421
         JBASE=1                                                        GENINT    422
      END IF                                                            GENINT    423
      BASPRN=BMVA/BASPC                                                 GENINT    424
      ZBAS=BASVRN*BASVRN/BASPRN                                         GENINT    425
C                                                                       GENINT    426
      HMX=DDAT(JG+1)                                                    GENINT    427
      DAMPX=DDAT(JG+2)                                                  GENINT    428
      CGGN=1.0                                                          GENINT    429
      CSGN=1.0                                                          GENINT    430
      HHMMX=0.0                                                         GENINT    431
      IF (MASSN.NE.0)THEN                                               GENINT    432
      JM=JCONTA(7,N)                                                    GENINT    433
      CSGN=DDAT(JM+6)                                                   GENINT    434
      CGGN=DDAT(JM+7)                                                   GENINT    435
      CSSUM=CSGN                                                        GENINT    436
      CGSUM=CGGN                                                        GENINT    437
C                                                                       GENINT    438
      KM=1                                                              GENINT    439
      DO 100 LI=1,MASSN                                                 GENINT    440
      KM=KM+6                                                           GENINT    441
      CS(LI)=DDAT(JM+KM+5)                                              GENINT    442
      CG(LI)=DDAT(JM+KM+6)                                              GENINT    443
      CSSUM=CSSUM+CS(LI)                                                GENINT    444
      CGSUM=CGSUM+CG(LI)                                                GENINT    445
      HHMMX=DDAT(JM+KM+1)+HHMMX                                         GENINT    446
      XHHM(1,LI)=DDAT(JM+KM+1)                                          GENINT    447
      XHHM(2,LI)=DDAT(JM+KM+2)                                          GENINT    448
      XHHM(3,LI)=DDAT(JM+KM+3)                                          GENINT    449
      XHHM(4,LI)=DDAT(JM+KM+4)                                          GENINT    450
C CODE BELOW NEEDS TO BE CHECKED                                        GENINT    451
      XHHM(1,LI)=WXBASE/(2.0*XHHM(1,LI))                                GENINT    452
      XHHM(2,LI)=XHHM(2,LI)/WXBASE                                      GENINT    453
      XHHM(4,LI)=XHHM(4,LI)/WXBASE                                      GENINT    454
 100   CONTINUE                                                         GENINT    455
C                                                                       GENINT    456
      IF (ABS(CSSUM-1.0).GT.0.001.OR.ABS(CGSUM-1.0).GT.0.001)THEN       GENINT    457
      WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID      GENINT    458
      WRITE(MSG(2),2850) CSSUM,CGSUM                                    GENINT    459
      CALL PRTMSG(2)                                                    GENINT    460
      IEBK=IEBK+1                                                       GENINT    461
      IERR1=1                                                           GENINT    462
      ENDIF                                                             GENINT    463
C                                                                       GENINT    464
C   ENDIF MASSN.NE.0                                                    GENINT    465
C                                                                       GENINT    466
      ENDIF                                                             GENINT    467
C                                                                       GENINT    468
C SUM UP INERTIA CONSTANTS OF MULTIMASS TO GET TOTAL INERTIA CONSTANT   GENINT    469
C OF THE MACHINE.  STORE THIS IN DDAT(JG+1). THUS THE TOTAL INERTIA IS  GENINT    470
C USED. WHEN THE TORSIONAL SHAFT DYNAMICS ARE INCLUDED THEN THIS MIGHT  GENINT    471
C HAVE TO CHANGE                                                        GENINT    472
C                                                                       GENINT    473
      HMX=HMX+HHMMX                                                     GENINT    474
      DDAT(JG+1)=HMX                                                    GENINT    475
C                                                                       GENINT    476
C                                                                       GENINT    477
C   CHECK PARK'S CONSTANTS IF -VE STOP                                  GENINT    478
C                                                                       GENINT    479
      IPARK=0                                                           GENINT    480
      IF(DDAT(JG+6).LT.0..OR.DDAT(JG+7).LT.0..OR.DDAT(JG+8).LT.0.       GENINT    481
     &.OR.DDAT(JG+10).LT.0..OR.DDAT(JG+14).LT.0..OR.DDAT(JG+16).LT.0.   GENINT    482
     &.OR.DDAT(JG+18).LT.0.0.OR.DDAT(JG+20).LT.0.0) IPARK=1             GENINT    483
      IF (ABS(DDAT(JG+24)).GE.1.E-6.AND.DDAT(JG+8).LE.1.E-6) IPARK=1    GENINT    484
C                                                                       GENINT    485
      IF (IPARK.NE.0)THEN                                               GENINT    486
      IERR2 =1                                                          GENINT    487
      IEBK=1                                                            GENINT    488
      WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID      GENINT    489
      MSG(2)='              HAS NEGATIVE PARK''S PARAMETER CHECK        GENINT    490
     * GENERATOR DATA'                                                  GENINT    491
      CALL PRTMSG(2)                                                    GENINT    492
      ENDIF                                                             GENINT    493
C                                                                       GENINT    494
C   CONVERTING DATA TO COMMON MVA BASE                                  GENINT    495
C                                                                       GENINT    496
      IF(JBASE.NE.0)THEN                                                GENINT    497
      DDAT(JG+6)=DDAT(JG+6)*ZBAS                                        GENINT    498
      DDAT(JG+7)=DDAT(JG+7)*ZBAS                                        GENINT    499
      DDAT(JG+8)=DDAT(JG+8)*ZBAS                                        GENINT    500
      DDAT(JG+9)=DDAT(JG+9)*ZBAS                                        GENINT    501
      DDAT(JG+10)=DDAT(JG+10)*ZBAS                                      GENINT    502
      DDAT(JG+11)=DDAT(JG+11)*ZBAS                                      GENINT    503
      DDAT(JG+24)=DDAT(JG+24)*ZBAS                                      GENINT    504
      DDAT(JG+25)=DDAT(JG+25)*ZBAS                                      GENINT    505
      DDAT(JG+1)=0.5*WXBASE/DDAT(JG+1)/BASPRN                           GENINT    506
      DDAT(JG+2)=DDAT(JG+2)*BASPRN/WXBASE                               GENINT    507
      SYSTH=SYSTH+1.0/DDAT(JG+1)                                        GENINT    508
C                                                                       GENINT    509
C        CHECK IF XKD2.EQ.0                                             GENINT    510
C                                                                       GENINT    511
        IF(DDAT(JG+18).LT.99.0)THEN                                     GENINT    512
        DDAT(JG+18)=DDAT(JG+18)*ZBAS                                    GENINT    513
        DDAT(JG+19)=DDAT(JG+19)*ZBAS                                    GENINT    514
        DDAT(JG+14)=DDAT(JG+14)*ZBAS                                    GENINT    515
        DDAT(JG+15)=DDAT(JG+15)*ZBAS                                    GENINT    516
C                                                                       GENINT    517
C        CHECK IF XKD1.EQ.0                                             GENINT    518
C                                                                       GENINT    519
         ELSEIF(DDAT(JG+14).LT.99.0)THEN                                GENINT    520
         DDAT(JG+14)=DDAT(JG+14)*ZBAS                                   GENINT    521
         DDAT(JG+15)=DDAT(JG+15)*ZBAS                                   GENINT    522
         ENDIF                                                          GENINT    523
C                                                                       GENINT    524
C        CHECK IF XKQ3.EQ.0                                             GENINT    525
C                                                                       GENINT    526
         IF(DDAT(JG+20).LT.99.0)THEN                                    GENINT    527
         DDAT(JG+20)=DDAT(JG+20)*ZBAS                                   GENINT    528
         DDAT(JG+21)=DDAT(JG+21)*ZBAS                                   GENINT    529
         DDAT(JG+16)=DDAT(JG+16)*ZBAS                                   GENINT    530
         DDAT(JG+17)=DDAT(JG+17)*ZBAS                                   GENINT    531
         DDAT(JG+12)=DDAT(JG+12)*ZBAS                                   GENINT    532
         DDAT(JG+13)=DDAT(JG+13)*ZBAS                                   GENINT    533
C                                                                       GENINT    534
C        CHECK IF XKQ2.EQ.0                                             GENINT    535
C                                                                       GENINT    536
         ELSEIF(DDAT(JG+16).LT.99.0)THEN                                GENINT    537
         DDAT(JG+16)=DDAT(JG+16)*ZBAS                                   GENINT    538
         DDAT(JG+17)=DDAT(JG+17)*ZBAS                                   GENINT    539
         DDAT(JG+12)=DDAT(JG+12)*ZBAS                                   GENINT    540
         DDAT(JG+13)=DDAT(JG+13)*ZBAS                                   GENINT    541
C                                                                       GENINT    542
C        CHECK IF XKQ1.EQ.0                                             GENINT    543
C                                                                       GENINT    544
         ELSEIF(DDAT(JG+12).LT.99.0)THEN                                GENINT    545
         DDAT(JG+12)=DDAT(JG+12)*ZBAS                                   GENINT    546
         DDAT(JG+13)=DDAT(JG+13)*ZBAS                                   GENINT    547
         ENDIF                                                          GENINT    548
C                                                                       GENINT    549
      IF (MASSN.NE.0)THEN                                               GENINT    550
      DO 150 LI=1,MASSN                                                 GENINT    551
      XHHM(1,LI)=XHHM(1,LI)/BASPRN                                      GENINT    552
      XHHM(2,LI)=XHHM(2,LI)*BASPRN                                      GENINT    553
      XHHM(3,LI)=XHHM(3,LI)*BASPRN                                      GENINT    554
 150  XHHM(4,LI)=XHHM(4,LI)*BASPRN                                      GENINT    555
      ENDIF                                                             GENINT    556
C                                                                       GENINT    557
C                                                                       GENINT    558
      ELSE                                                              GENINT    559
C                                                                       GENINT    560
      DDAT(JG+1)=0.5*WXBASE/DDAT(JG+1)                                  GENINT    561
      DDAT(JG+2)=DDAT(JG+2)/WXBASE                                      GENINT    562
      SYSTH=SYSTH+1.0/DDAT(JG+1)                                        GENINT    563
C                                                                       GENINT    564
C   ENDIF JBASE.NE.0                                                    GENINT    565
C                                                                       GENINT    566
      ENDIF                                                             GENINT    567
C                                                                       GENINT    568
C   COMPUTE AXQ                                                         GENINT    569
C                                                                       GENINT    570
C   CHECK XKQ3.EQ.0.AND/OR.XKQ2.EQ.0.AND/OR.XKQ1.EQ.0                   GENINT    571
C                                                                       GENINT    572
      MQ=1                                                              GENINT    573
      DDAT(JG+23)=0.0                                                   GENINT    574
      IF(DDAT(JG+20).LT.99.0)THEN                                       GENINT    575
      MQ=4                                                              GENINT    576
      DDAT(JG+23)=1.0/DDAT(JG+12)+1.0/DDAT(JG+16)+1.0/DDAT(JG+20)       GENINT    577
      ELSEIF(DDAT(JG+16).LT.99.0)THEN                                   GENINT    578
      MQ=3                                                              GENINT    579
      DDAT(JG+23)=1.0/DDAT(JG+12)+1.0/DDAT(JG+16)                       GENINT    580
      ELSEIF(DDAT(JG+12).LT.99.0)THEN                                   GENINT    581
      MQ=2                                                              GENINT    582
      DDAT(JG+23)=1.0/DDAT(JG+12)                                       GENINT    583
      ENDIF                                                             GENINT    584
      IDDAT(JG+35)=MQ                                                   GENINT    585
C                                                                       GENINT    586
C   COMPUTE AXD                                                         GENINT    587
C                                                                       GENINT    588
      MD=1                                                              GENINT    589
      IF(IGENS.NE.2.OR.IGENS.NE.6.OR.IGENS.NE.10.OR.IGENS.NE.14)THEN    GENINT    590
C                                                                       GENINT    591
         ICONTA(1,N)=1                                                  GENINT    592
         DDAT(JG+22)=1./DDAT(JG+10)                                     GENINT    593
         DDAT(JG+36)=DDAT(JG+22)                                        GENINT    594
C                                                                       GENINT    595
C   CHECK XKD2.EQ.0.AND/OR.XKD1.EQ.0                                    GENINT    596
C                                                                       GENINT    597
         IF(DDAT(JG+18).LT.99.0)THEN                                    GENINT    598
            MD=3                                                        GENINT    599
            DDAT(JG+37)=1.0/DDAT(JG+14)                                 GENINT    600
            DDAT(JG+38)=1.0/DDAT(JG+18)                                 GENINT    601
            DDAT(JG+22)=DDAT(JG+22)+DDAT(JG+37)+DDAT(JG+38)             GENINT    602
         ELSEIF(DDAT(JG+14).LT.99.0)THEN                                GENINT    603
            MD=2                                                        GENINT    604
            DDAT(JG+37)=1.0/DDAT(JG+14)                                 GENINT    605
            DDAT(JG+22)=DDAT(JG+22)+DDAT(JG+37)                         GENINT    606
         ENDIF                                                          GENINT    607
C                                                                       GENINT    608
      ELSE                                                              GENINT    609
C                                                                       GENINT    610
C     CASE WITH CROSS MUTUAL                                            GENINT    611
C                                                                       GENINT    612
         ICONTA(1,N)=2                                                  GENINT    613
         IF(DDAT(JG+18).LT.99.0)THEN                                    GENINT    614
C                                                                       GENINT    615
C     TWO DAMPER WINDING CASE                                           GENINT    616
C                                                                       GENINT    617
            MD=3                                                        GENINT    618
            XKC1=DDAT(JG+24)                                            GENINT    619
            XKC2=DDAT(JG+25)                                            GENINT    620
            AFTR=DDAT(JG+10)+XKC1+XKC2                                  GENINT    621
            BFTR=XKC1                                                   GENINT    622
            CFTR=XKC1+XKC2                                              GENINT    623
            DFTR=XKC1                                                   GENINT    624
            EFTR=DDAT(JG+14)+XKC1                                       GENINT    625
            FFTR=XKC1                                                   GENINT    626
            GFTR=XKC1+XKC2                                              GENINT    627
            HFTR=XKC1                                                   GENINT    628
            XFTR=DDAT(JG+18)+XKC1+XKC2                                  GENINT    629
C                                                                       GENINT    630
C   NOTE: WHEN EVERYTHING WORKS SUB CFTR,HFTR,GFTR,&FFTR TO XKC1        GENINT    631
C                                                                       GENINT    632
            DET=AFTR*(EFTR*XFTR-HFTR*FFTR)-BFTR*(DFTR*XFTR-GFTR*FFTR)   GENINT    633
     &      +CFTR*(DFTR*HFTR-EFTR*GFTR)                                 GENINT    634
C                                                                       GENINT    635
            DDAT(JG+36)=(EFTR*XFTR-HFTR*FFTR)+(FFTR*GFTR-DFTR*XFTR)     GENINT    636
     &      +(DFTR*HFTR-GFTR*EFTR)                                      GENINT    637
            DDAT(JG+36)=DDAT(JG+36)/DET                                 GENINT    638
C                                                                       GENINT    639
            DDAT(JG+37)=(HFTR*CFTR-BFTR*XFTR)+(AFTR*XFTR-GFTR*CFTR)     GENINT    640
     &      +(GFTR*BFTR-AFTR*HFTR)                                      GENINT    641
            DDAT(JG+37)=DDAT(JG+37)/DET                                 GENINT    642
C                                                                       GENINT    643
            DDAT(JG+38)=(BFTR*FFTR-CFTR*EFTR)+(DFTR*CFTR-AFTR*FFTR)     GENINT    644
     &      +(AFTR*EFTR-DFTR*BFTR)                                      GENINT    645
            DDAT(JG+38)=DDAT(JG+38)/DET                                 GENINT    646
C                                                                       GENINT    647
            DDAT(JG+22)=DDAT(JG+36)+DDAT(JG+37)+DDAT(JG+38)             GENINT    648
C                                                                       GENINT    649
C     CALCULATE INVERSE OF XD MATRIX                                    GENINT    650
C                                                                       GENINT    651
            DDAT(JG+39)=(EFTR*XFTR-HFTR*FFTR)/DET                       GENINT    652
            DDAT(JG+40)=(HFTR*CFTR-BFTR*XFTR)/DET                       GENINT    653
            DDAT(JG+41)=(BFTR*FFTR-CFTR*EFTR)/DET                       GENINT    654
            DDAT(JG+42)=(AFTR*XFTR-GFTR*CFTR)/DET                       GENINT    655
            DDAT(JG+43)=(DFTR*CFTR-AFTR*FFTR)/DET                       GENINT    656
            DDAT(JG+44)=(AFTR*EFTR-DFTR*BFTR)/DET                       GENINT    657
C                                                                       GENINT    658
         ELSEIF(DDAT(JG+14).LT.99.0)THEN                                GENINT    659
C                                                                       GENINT    660
C     ONE DAMPER WINDING CASE                                           GENINT    661
C                                                                       GENINT    662
            MD=2                                                        GENINT    663
            DDAT(JG+38)=0.0                                             GENINT    664
C                                                                       GENINT    665
            XKC1=DDAT(JG+24)                                            GENINT    666
            AFTR=DDAT(JG+10)+XKC1                                       GENINT    667
            DFTR=DDAT(JG+14)+XKC1                                       GENINT    668
            DET=AFTR*DFTR-XKC1*XKC1                                     GENINT    669
            DDAT(JG+36)=(DFTR-XKC1)/DET                                 GENINT    670
            DDAT(JG+37)=(AFTR-XKC1)/DET                                 GENINT    671
            DDAT(JG+22)=DDAT(JG+36)+DDAT(JG+37)                         GENINT    672
C                                                                       GENINT    673
C     CALCULATE INVERSE OF XD MATRIX                                    GENINT    674
C                                                                       GENINT    675
            DDAT(JG+39)=DFTR/DET                                        GENINT    676
            DDAT(JG+40)=-XKC1/DET                                       GENINT    677
            DDAT(JG+41)=AFTR/DET                                        GENINT    678
C                                                                       GENINT    679
C     ENDIF DDAT(JG+18).LT.99.0                                         GENINT    680
C                                                                       GENINT    681
         ENDIF                                                          GENINT    682
C                                                                       GENINT    683
C   ENDIF IGENS.NE.2                                                    GENINT    684
C                                                                       GENINT    685
      ENDIF                                                             GENINT    686
C                                                                       GENINT    687
      IDDAT(JG+34)=MD                                                   GENINT    688
C                                                                       GENINT    689
      CDGN=PDGN*EDEM+PQGN*EQEM                                          GENINT    690
      CQGN=PDGN*EQEM-PQGN*EDEM                                          GENINT    691
      CDG(1,N)=CDGN                                                     GENINT    692
      CDG(2,N)=CQGN                                                     GENINT    693
      CT=SQRT(CDGN**2+CQGN**2)                                          GENINT    694
      PHI=0.0                                                           GENINT    695
      IF (ABS(PDGN).GT.1.E-6.OR.ABS(PQGN).GT.1.E-6) PHI=ATAN2(PQGN      GENINT    696
     +,PDGN)                                                            GENINT    697
C----------------------                                                 GENINT    698
C     SANITY CHECK                                                      GENINT    699
C----------------------                                                 GENINT    700
      XQ=DDAT(JG+7)+DDAT(JG+8)                                          GENINT    701
      TTHENX=PDGN*XQ-PQGN*DDAT(JG+9)                                    GENINT    702
      THED=VMAG+(PDGN*DDAT(JG+9)+PQGN*XQ)                               GENINT    703
      THETA=ATAN2(TTHENX,THED)                                          GENINT    704
      DELTA=THETA-VANG                                                  GENINT    705
      ED0=GTV*SIN(THETA)                                                GENINT    706
      EQ0=GTV*COS(THETA)                                                GENINT    707
      CD0=CT*SIN(THETA+PHI)                                             GENINT    708
      CQ0=CT*COS(THETA+PHI)                                             GENINT    709
      XADS=DDAT(JG+6)                                                   GENINT    710
      XD=DDAT(JG+8)+XADS                                                GENINT    711
      EFDN=(EQ0+DDAT(JG+9)*CQ0+XD*CD0)                                  GENINT    712
      IF (ABS(EFDN).GT.5.0) THEN                                        GENINT    713
         WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   GENINT    714
         WRITE(MSG(2),3580)                                             GENINT    715
         WRITE(MSG(3),3590)                                             GENINT    716
         WRITE(MSG(4),3600)                                             GENINT    717
         WRITE(MSG(5),3605)                                             GENINT    718
         CALL PRTMSG(5)                                                 GENINT    719
      END IF                                                            GENINT    720
C                                                                       GENINT    721
C     SATURATION FACTOR                                                 GENINT    722
C                                                                       GENINT    723
C     ISATN=0   NO SATURATION                                           GENINT    724
C     ISATN=1   D AXIS SATURATION ONLY (FOR SALIENT POLE)               GENINT    725
C     ISATN=2   D AND Q AXES HAVE SAME SATURATION CHARACTERISTICS       GENINT    726
C     ISATN=3   D AND Q AXES HAVE SEPARATE SATURATION CHARACTERISTICS   GENINT    727
C                                                                       GENINT    728
      DDAT(JG+32)=1.0                                                   GENINT    729
      DDAT(JG+33)=1.0                                                   GENINT    730
C                                                                       GENINT    731
      IF (ISATN.EQ.0) GOTO 450                                          GENINT    732
C                                                                       GENINT    733
      CTR=CT*COS(PHI)                                                   GENINT    734
      CTI=-CT*SIN(PHI)                                                  GENINT    735
      BAR=GTV+DDAT(JG+9)*CTR-DDAT(JG+8)*CTI                             GENINT    736
      BAI=CTR*DDAT(JG+8)+CTI*DDAT(JG+9)                                 GENINT    737
      BAT=SQRT(BAR*BAR+BAI*BAI)                                         GENINT    738
C                                                                       GENINT    739
C     D AXIS SATURATION                                                 GENINT    740
C                                                                       GENINT    741
      IF (ABS(BAT).LE.DDAT(JG+28)) THEN                                 GENINT    742
C                                                                       GENINT    743
C     REGION 1                                                          GENINT    744
C                                                                       GENINT    745
         CONTINUE                                                       GENINT    746
C                                                                       GENINT    747
      ELSE IF (ABS(BAT).LE.DDAT(JG+29)) THEN                            GENINT    748
C                                                                       GENINT    749
C     REGION 2                                                          GENINT    750
C                                                                       GENINT    751
         XSAT=ABS(BAT)-DDAT(JG+28)                                      GENINT    752
         DBAT=DDAT(JG+26)*EXP(DDAT(JG+27)*XSAT)                         GENINT    753
         DDAT(JG+32)=BAT/(BAT+DBAT)                                     GENINT    754
C                                                                       GENINT    755
      ELSE                                                              GENINT    756
C                                                                       GENINT    757
C     REGION 3                                                          GENINT    758
C                                                                       GENINT    759
         XSAT=DDAT(JG+29)-DDAT(JG+28)                                   GENINT    760
         DBAT=DDAT(JG+26)*EXP(DDAT(JG+27)*XSAT)                         GENINT    761
         DBAT=DBAT+(DDAT(JG+30)*(ABS(BAT)-DDAT(JG+29)))                 GENINT    762
         DDAT(JG+32)=BAT/(DDAT(JG+29)+DBAT)                             GENINT    763
C                                                                       GENINT    764
      END IF                                                            GENINT    765
C                                                                       GENINT    766
C     Q AXIS SATURATION                                                 GENINT    767
C                                                                       GENINT    768
      GOTO (450,460,470) ISATN                                          GENINT    769
C                                                                       GENINT    770
  460 CONTINUE                                                          GENINT    771
      DDAT(JG+33)=DDAT(JG+32)                                           GENINT    772
      GOTO 450                                                          GENINT    773
C                                                                       GENINT    774
  470 CONTINUE                                                          GENINT    775
      IF (ABS(BAT).LE.DDAT(JG+47)) THEN                                 GENINT    776
C                                                                       GENINT    777
C     REGION 1                                                          GENINT    778
C                                                                       GENINT    779
         CONTINUE                                                       GENINT    780
C                                                                       GENINT    781
      ELSE IF (ABS(BAT).LE.DDAT(JG+48)) THEN                            GENINT    782
C                                                                       GENINT    783
C     REGION 2                                                          GENINT    784
C                                                                       GENINT    785
         XSAT=ABS(BAT)-DDAT(JG+47)                                      GENINT    786
         DBAT=DDAT(JG+45)*EXP(DDAT(JG+46)*XSAT)                         GENINT    787
         DDAT(JG+33)=BAT/(BAT+DBAT)                                     GENINT    788
C                                                                       GENINT    789
      ELSE                                                              GENINT    790
C                                                                       GENINT    791
C     REGION 3                                                          GENINT    792
C                                                                       GENINT    793
         XSAT=DDAT(JG+48)-DDAT(JG+47)                                   GENINT    794
         DBAT=DDAT(JG+45)*EXP(DDAT(JG+46)*XSAT)                         GENINT    795
         DBAT=DBAT+(DDAT(JG+49)*(ABS(BAT)-DDAT(JG+48)))                 GENINT    796
         DDAT(JG+33)=BAT/(DDAT(JG+48)+DBAT)                             GENINT    797
C                                                                       GENINT    798
      END IF                                                            GENINT    799
C                                                                       GENINT    800
 450  CONTINUE                                                          GENINT    801
C                                                                       GENINT    802
C     CHECK SATURATION FACTORS                                          GENINT    803
C                                                                       GENINT    804
      IF (DDAT(JG+32).LT.0.5.OR.DDAT(JG+33).LT.0.5) THEN                GENINT    805
         WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   GENINT    806
         IWS1=1                                                         GENINT    807
         IF (DDAT(JG+32).LT.0.5) THEN                                   GENINT    808
            IWS1=IWS1+1                                                 GENINT    809
            WRITE(MSG(IWS1),3610) 'D',DDAT(JG+32)                       GENINT    810
         END IF                                                         GENINT    811
         IF (DDAT(JG+33).LT.0.5) THEN                                   GENINT    812
            IWS1=IWS1+1                                                 GENINT    813
            WRITE(MSG(IWS1),3610) 'Q',DDAT(JG+33)                       GENINT    814
         END IF                                                         GENINT    815
         CALL PRTMSG(IWS1)                                              GENINT    816
      END IF                                                            GENINT    817
C                                                                       GENINT    818
      XQ=DDAT(JG+7)*DDAT(JG+33)+DDAT(JG+8)                              GENINT    819
      TTHENX=PDGN*XQ-PQGN*DDAT(JG+9)                                    GENINT    820
      THED=VMAG+(PDGN*DDAT(JG+9)+PQGN*XQ)                               GENINT    821
      THETA=ATAN2(TTHENX,THED)                                          GENINT    822
      DELTA=THETA-VANG                                                  GENINT    823
C                                                                       GENINT    824
C-----------------------------------------------------------------------GENINT    825
C                                                                       GENINT    826
C     THESE CODES ARE USED TO OBTAIN CONSISTENT MACHINE ANGLES.         GENINT    827
C     IF PROBLEMS ARE FOUND LATE IN THE PROGRAM, CHANGE THESE CODES     GENINT    828
C     OR DELETE THEM.                                                   GENINT    829
C                                                                       GENINT    830
C      IF (DELTA.GT.3.1415927) THEN                                     GENINT    831
C         DELTA=DELTA-6.2831853                                         GENINT    832
C      ELSE IF (DELTA.LT.-3.1415927) THEN                               GENINT    833
C         DELTA=6.2831853+DELTA                                         GENINT    834
C      END IF                                                           GENINT    835
C                                                                       GENINT    836
C-----------------------------------------------------------------------GENINT    837
C                                                                       GENINT    838
      XSTATE(JSTATE+1)=0.0                                              GENINT    839
      XSTATE(JSTATE+2)=DELTA                                            GENINT    840
      XDFACT(JSTATE+1)=DDAT(JG+1)                                       GENINT    841
      ANGXC2(N)=DELTA                                                   GENINT    842
      XANGLO(N)=DELTA                                                   GENINT    843
      ED0=GTV*SIN(THETA)                                                GENINT    844
      EQ0=GTV*COS(THETA)                                                GENINT    845
      CD0=CT*SIN(THETA+PHI)                                             GENINT    846
      CQ0=CT*COS(THETA+PHI)                                             GENINT    847
C                                                                       GENINT    848
      XADS=DDAT(JG+6)*DDAT(JG+32)                                       GENINT    849
      XD=DDAT(JG+8)+XADS                                                GENINT    850
      XFFD=XADS+DDAT(JG+10)+DDAT(JG+24)+DDAT(JG+25)                     GENINT    851
C                                                                       GENINT    852
C  FIELD CURRENT IN RECIPROCAL P.U. SYSTEM                              GENINT    853
C                                                                       GENINT    854
      CFDN=(EQ0+DDAT(JG+9)*CQ0+XD*CD0)/XADS                             GENINT    855
      EFDN=CFDN*DDAT(JG+6)                                              GENINT    856
      EFD(JY+4)=EFDN                                                    GENINT    857
      CFD(JY+5)=EFDN                                                    GENINT    858
      ICONTA(13,N)=1                                                    GENINT    859
C                                                                       GENINT    860
      IF (EFDN.GE.5.0) THEN                                             GENINT    861
         WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   GENINT    862
         WRITE(MSG(2),3550) EFDN                                        GENINT    863
         MSG(3)='     BE SURE TO CHECK THE GENERATOR DATA.'             GENINT    864
         CALL PRTMSG(3)                                                 GENINT    865
      ELSE IF (EFDN.LT.0.0) THEN                                        GENINT    866
         WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   GENINT    867
         WRITE(MSG(2),3640) EFDN                                        GENINT    868
         MSG(3)='     BE SURE TO CHECK THE GENERATOR DATA AND '//       GENINT    869
     1          'INITIAL CONDITION.'                                    GENINT    870
         CALL PRTMSG(3)                                                 GENINT    871
         ICONTA(13,N)=-1                                                GENINT    872
      END IF                                                            GENINT    873
C                                                                       GENINT    874
C     INITIALIZE CROWBAR MODEL DATA                                     GENINT    875
C                                                                       GENINT    876
      ICBRN=ICONTA(9,N)                                                 GENINT    877
      IF (ICBRN.GT.1) THEN                                              GENINT    878
         JCB=JCONTA(8,N)                                                GENINT    879
         CFDOC=DDAT(JCB+1)                                              GENINT    880
         IF (CFDOC.LE.0.0) THEN                                         GENINT    881
            WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1)              GENINT    882
     &                        ,INAME(KN),CID                            GENINT    883
            WRITE(MSG(2),3620) CFDOC                                    GENINT    884
            WRITE(MSG(3),3630)                                          GENINT    885
            CALL PRTMSG(3)                                              GENINT    886
            CALL ASTOP('GENINT: FATAL ERROR',19)                        GENINT    887
         END IF                                                         GENINT    888
         CFBASE=CFDOC*DDAT(JG+6)                                        GENINT    889
         RFDBAS=1.0E6*DDAT(JG+3)/(CFBASE*CFBASE)                        GENINT    890
         IF (ICBRN.EQ.2) THEN                                           GENINT    891
            DDAT(JCB+2)=DDAT(JCB+2)/RFDBAS                              GENINT    892
         ELSE                                                           GENINT    893
            IF (IDDAT(JCB+3).LE.0) IDDAT(JCB+3)=1                       GENINT    894
            AEXP=DDAT(JCB+4)                                            GENINT    895
            DDAT(JCB+2)=DDAT(JCB+2)*(CFBASE**(AEXP-1.0))/               GENINT    896
     &                  ((REAL(IDDAT(JCB+3))**AEXP)*RFDBAS)             GENINT    897
            DDAT(JCB+4)=DDAT(JCB+4)-1.0                                 GENINT    898
         END IF                                                         GENINT    899
      END IF                                                            GENINT    900
C                                                                       GENINT    901
      JSTATE=JSTATE+3                                                   GENINT    902
      XSTATE(JSTATE)=XFFD*CFDN-XADS*CD0                                 GENINT    903
      IF(MD.GT.1)THEN                                                   GENINT    904
      JSTATE=JSTATE+1                                                   GENINT    905
      XSTATE(JSTATE)=XADS*(CFDN-CD0)+DDAT(JG+24)*CFDN                   GENINT    906
      ENDIF                                                             GENINT    907
      IF(MD.GT.2)THEN                                                   GENINT    908
      XSTATE(JSTATE+1)=XSTATE(JSTATE)+DDAT(JG+25)*CFDN                  GENINT    909
      JSTATE=JSTATE+1                                                   GENINT    910
      ENDIF                                                             GENINT    911
C                                                                       GENINT    912
C     CALCULATE INITIAL Q AXIS STATES                                   GENINT    913
C                                                                       GENINT    914
      IF(MQ.GT.1)THEN                                                   GENINT    915
      X3N=-DDAT(JG+7)*CQ0*DDAT(JG+33)                                   GENINT    916
      JSTC=1                                                            GENINT    917
 500  JSTC=JSTC+1                                                       GENINT    918
      JSTATE=JSTATE+1                                                   GENINT    919
      XSTATE(JSTATE)=X3N                                                GENINT    920
      IF(JSTC.LT.MQ)GOTO 500                                            GENINT    921
      ENDIF                                                             GENINT    922
C                                                                       GENINT    923
C     COMPUTE U1 TO U6 FOR USE IN LOADFL                                GENINT    924
C                                                                       GENINT    925
      CALL UVARB (N,JG,MD,MQ,NSTATE)                                    GENINT    926
C                                                                       GENINT    927
C   PRINT GENERATOR DATA                                                GENINT    928
C                                                                       GENINT    929
      APHI=PHI*57.29578                                                 GENINT    930
      ADELTA=DELTA*57.29578                                             GENINT    931
      ANGD=90.0-VANG*57.29578                                           GENINT    932
      ATHETA=THETA*57.29578                                             GENINT    933
C                                                                       GENINT    934
C   AIR GAP FLUX                                                        GENINT    935
C                                                                       GENINT    936
      CFDN=CFD(JY+5)                                                    GENINT    937
      FLXAD=XADS*(CFDN-CD0)+DDAT(JG+24)*CFDN                            GENINT    938
      FLXAQ=-DDAT(JG+7)*DDAT(JG+33)*CQ0                                 GENINT    939
C                                                                       GENINT    940
      IF (LDEB) THEN                                                    GENINT    941
         WRITE(IUD6,2900) GTV,ANGD,CDGN,CQGN,CT,IPGX,GMWX,IQGX,GMXX     GENINT    942
         WRITE(IUD6,2950) APHI,ATHETA,ADELTA                            GENINT    943
C         WRITE(IUD6,3000) EFDN,CFDN,FLXAD,FLXAQ,BAT,DDAT(JG+32)        GENINT    944
C     *        ,DDAT(JG+33)                                             GENINT    945
      ENDIF                                                             GENINT    946
C                                                                       GENINT    947
      MT=MD+MQ                                                          GENINT    948
      IF (LDEB) WRITE(IUD6,3050) MD,MQ,MT                               GENINT    949
C                                                                       GENINT    950
      TINN=PDGN+DDAT(JG+9)*CT**2                                        GENINT    951
      TIN(JY+1)=TINN                                                    GENINT    952
C                                                                       GENINT    953
      VBUS(N)=GTV                                                       GENINT    954
C                                                                       GENINT    955
C  PRE-CALCULATE THE 'TIN' OF NEXT MACHINE IF IT IS ONE OF THE HP-LP COUGENINT    956
C                                                                       GENINT    957
      IGV5=ICONTA(2,N+1)                                                GENINT    958
      IF (IGV5.EQ.5.OR.IGV5.EQ.35) THEN                                 GENINT    959
         PE5=PDGT(1,N+1)                                                GENINT    960
         QE5=PDGT(2,N+1)                                                GENINT    961
         JG5=JCONTA(1,N+1)                                              GENINT    962
         RA5=DDAT(JG5+9)                                                GENINT    963
         IF (IDDAT(JG5+3).NE.0.AND.IDDAT(JG5+4).NE.0) THEN              GENINT    964
            ZBAS5=DDAT(JG5+4)**2*BASPC/DDAT(JG5+3)                      GENINT    965
            RA5=RA5*ZBAS5                                               GENINT    966
         ENDIF                                                          GENINT    967
         CD5=PE5*EDEM+QE5*EQEM                                          GENINT    968
         CQ5=PE5*EQEM-QE5*EDEM                                          GENINT    969
         CT5=CD5*CD5+CQ5*CQ5                                            GENINT    970
         TIN5=PE5+RA5*CT5                                               GENINT    971
C                                                                       GENINT    972
         IF (ABS(TIN5).LT.1.0E-10.AND.ABS(PDGN).LT.1.0E-10) THEN        GENINT    973
            IF (J.LT.KTHGE(K)) THEN                                     GENINT    974
               NLF5=NLF                                                 GENINT    975
               KN5=KN                                                   GENINT    976
            ELSE                                                        GENINT    977
               NLF5=NOLD(K+1)                                           GENINT    978
               KN5=KN+3                                                 GENINT    979
            END IF                                                      GENINT    980
            CKID5=NDGC(N+1)                                             GENINT    981
            CID5=CKID5                                                  GENINT    982
            WRITE(MSG(1),3450) NLF5,INAME(KN5-2),INAME(KN5-1)           GENINT    983
     *                        ,INAME(KN5),CID5                          GENINT    984
            WRITE(MSG(2),3500) IGV5                                     GENINT    985
            CALL PRTMSG(2)                                              GENINT    986
            ICONTA(2,N+1)=0                                             GENINT    987
         END IF                                                         GENINT    988
C                                                                       GENINT    989
      ENDIF                                                             GENINT    990
C                                                                       GENINT    991
C  INITIALIZE TIN=0.0 FOR FREQUENCY CONVERTORS                          GENINT    992
C                                                                       GENINT    993
      IF (IFC.NE.0) THEN                                                GENINT    994
         IFC=IFC-1                                                      GENINT    995
         TIN(JYG+1)=0.0                                                 GENINT    996
         GOTO 550                                                       GENINT    997
      ELSE                                                              GENINT    998
         IF (N.GE.NTT) GOTO 550                                         GENINT    999
         JGP1=JCONTA(1,N+1)+5                                           GENINT   1000
         IF ((IDDAT(JG+5)-IDDAT(JGP1)).NE.0) THEN                       GENINT   1001
            IFC=1                                                       GENINT   1002
            PSUM=ABS(PDG(JYG+2)+PDGT(1,N+1))                            GENINT   1003
            IF (PSUM.GT.1.0E-3) THEN                                    GENINT   1004
               K3=K*3                                                   GENINT   1005
               NLF=NOLD(K)                                              GENINT   1006
               K31=(K+1)*3                                              GENINT   1007
               NLF1=NOLD(K+1)                                           GENINT   1008
               CID1=NDGC(N+1)(3:4)                                      GENINT   1009
               WRITE(MSG(1),3110)                                       GENINT   1010
               WRITE(MSG(2),3120) NLF,INAME(K3-2),INAME(K3-1)           GENINT   1011
     *                           ,INAME(K3),CID,NLF1,INAME(K31-2)       GENINT   1012
     *                           ,INAME(K31-1),INAME(K31),CID1          GENINT   1013
               WRITE(MSG(3),3130)                                       GENINT   1014
               CALL PRTMSG(3)                                           GENINT   1015
               IERR3=1                                                  GENINT   1016
               IEBK=1                                                   GENINT   1017
            END IF                                                      GENINT   1018
            TIN(JYG+1)=0.0                                              GENINT   1019
         END IF                                                         GENINT   1020
      END IF                                                            GENINT   1021
C                                                                       GENINT   1022
 550  CONTINUE                                                          GENINT   1023
C                                                                       GENINT   1024
C                                                                       GENINT   1025
C      MULTIPLY RESISTANCE OF PARK MODEL BY WXBASE                      GENINT   1026
C THIS MODIFICATION IS UNIQUE FOR TIME DOMAIN SIMULATION                GENINT   1027
C                                                                       GENINT   1028
      DDAT(JG+13)=DDAT(JG+13)*WXBASE                                    GENINT   1029
      DDAT(JG+15)=DDAT(JG+15)*WXBASE                                    GENINT   1030
      DDAT(JG+17)=DDAT(JG+17)*WXBASE                                    GENINT   1031
      DDAT(JG+19)=DDAT(JG+19)*WXBASE                                    GENINT   1032
      DDAT(JG+21)=DDAT(JG+21)*WXBASE                                    GENINT   1033
C                                                                       GENINT   1034
      ACCP(JYG+6)=0.0                                                   GENINT   1035
      JY=JY+6                                                           GENINT   1036
C                                                                       GENINT   1037
C   PRINTING EXCITATION CONTROL SYSTEM DATA                             GENINT   1038
C                                                                       GENINT   1039
  560 CONTINUE                                                          GENINT   1040
      MSTATE(2,N)=JSTATE                                                GENINT   1041
      MSTATE(3,N)=JSTATE                                                GENINT   1042
      MSTATE(4,N)=JSTATE                                                GENINT   1043
      MSTATE(7,N)=JSTATE                                                GENINT   1044
      IEXN=ICONTA(4,N)                                                  GENINT   1045
      IF(IEXN.NE.0)THEN                                                 GENINT   1046
         JE=JCONTA(3,N)                                                 GENINT   1047
         MYVAR(2,N)=JY                                                  GENINT   1048
         JYE=JY                                                         GENINT   1049
         IUALN=ICONTA(7,N)                                              GENINT   1050
         ISTABN=ICONTA(5,N)                                             GENINT   1051
         ITEBN=ICONTA(11,N)                                             GENINT   1052
         IMXLN=ICONTA(12,N)                                             GENINT   1053
         IF(IEXN.EQ.50) THEN                                            GENINT   1054
            JE0=JE                                                      GENINT   1055
            DDAT(JE0+1)=DDAT(JE0+1)/BASPRN                              GENINT   1056
            DDAT(JE0+2)=DDAT(JE0+2)/BASPRN                              GENINT   1057
            JE1=JE0+9                                                   GENINT   1058
            NRBUS=IDDAT(JE1)                                            GENINT   1059
            IF(NRBUS.EQ.0) THEN                                         GENINT   1060
               VCR=GTREAL                                               GENINT   1061
               VCI=GTIMAG                                               GENINT   1062
            ELSE                                                        GENINT   1063
               IBUSR=IDDAT(JE1+1)                                       GENINT   1064
               VCR=REAL(VOLT(IBUSR))                                    GENINT   1065
               VCI=AIMAG(VOLT(IBUSR))                                   GENINT   1066
            ENDIF                                                       GENINT   1067
C                                                                       GENINT   1068
C     GET THE KNOWN INPUTS                                              GENINT   1069
C                                                                       GENINT   1070
            CALL FMOVE(0,VALIN,VALIN,80)                                GENINT   1071
            RC=DDAT(JE0+1)                                              GENINT   1072
            XC=DDAT(JE0+2)                                              GENINT   1073
            VCD=VCR+(RC*CDGN-XC*CQGN)                                   GENINT   1074
            VCQ=VCI+(RC*CQGN+XC*CDGN)                                   GENINT   1075
            VCM=SQRT(VCD**2+VCQ**2)                                     GENINT   1076
            VALIN(1)=VCM                                                GENINT   1077
            IF(VCM.GT.0.05)VALIN(2)=ATAN2(VCQ,VCD)                      GENINT   1078
            VALIN(4)=GTV                                                GENINT   1079
            VALIN(5)=AT                                                 GENINT   1080
            VALIN(6)=GTREAL                                             GENINT   1081
            VALIN(7)=GTIMAG                                             GENINT   1082
            VALIN(8)=CDGN/BASPRN                                        GENINT   1083
            VALIN(9)=CQGN/BASPRN                                        GENINT   1084
            VALIN(10)=PDGN/BASPRN                                       GENINT   1085
            VALIN(11)=PQGN/BASPRN                                       GENINT   1086
            VALIN(15)=EFDN                                              GENINT   1087
            VALIN(16)=CFDN                                              GENINT   1088
C                                                                       GENINT   1089
            IDDAT(JE0+4)=0                                              GENINT   1090
            DDAT(JE0+5)=VALIN(2)                                        GENINT   1091
            IDDAT(JE0+6)=0                                              GENINT   1092
            DDAT(JE0+7)=VALIN(5)                                        GENINT   1093
            NUF=1                                                       GENINT   1094
            CALL UDMINT(NUF,GTV,NLF,KN,CID)                             GENINT   1095
C                                                                       GENINT   1096
            IF(LDEB) THEN                                               GENINT   1097
            WRITE(IUD6,3250) (VALIN(JK),JK=1,12),(VALIN(I),I=14,20)     GENINT   1098
            WRITE(IUD6,3200) (I,VALIN(I),I=1,80)                        GENINT   1099
            ENDIF                                                       GENINT   1100
C                                                                       GENINT   1101
C     STORE THE REQUIRED INPUTS AND OUTPUT                              GENINT   1102
C                                                                       GENINT   1103
            VREG(JYE+1)=VALIN(1)                                        GENINT   1104
            VREF(JYE+2)=VALIN(20)                                       GENINT   1105
            VRFIN(JYE+3)=VALIN(19)                                      GENINT   1106
            VTOS(JYE+4)=VALIN(4)                                        GENINT   1107
            JY=JY+4                                                     GENINT   1108
            DO 600 JK=1,NXUDB                                           GENINT   1109
            YVAR(JY+JK)=VALOUT(JK)                                      GENINT   1110
 600        CONTINUE                                                    GENINT   1111
            JY=JY+NXUDB                                                 GENINT   1112
            GO TO 1300                                                  GENINT   1113
         ENDIF                                                          GENINT   1114
         IVTN=IDDAT(JE+1)                                               GENINT   1115
         IF(IVTN.EQ.0)IVTN=K                                            GENINT   1116
         NVTN=NOLD(IVTN)                                                GENINT   1117
         IF (NVTN.EQ.NLF) THEN                                          GENINT   1118
            ET=GTV                                                      GENINT   1119
            CVREAL=GTREAL                                               GENINT   1120
            CVIMAG=GTIMAG                                               GENINT   1121
            IDDAT(JE+1)=0                                               GENINT   1122
         ELSE                                                           GENINT   1123
            VOLTC=VOLT(IVTN)                                            GENINT   1124
            ET=SQRT(CVREAL**2+CVIMAG**2)                                GENINT   1125
         ENDIF                                                          GENINT   1126
C                                                                       GENINT   1127
C                                                                       GENINT   1128
C  COMPENSATOR                                                          GENINT   1129
C                                                                       GENINT   1130
C     SET TR=0.0 IF TR<=0.005 FROM INPUT                                GENINT   1131
C                                                                       GENINT   1132
C      IF (DDAT(JE+18).LT.0.0095.AND.IDDAT(JE+18).NE.0) DDAT(JE+18)=0.0 GENINT   1133
         IF (IDDAT(JE+19).NE.0.OR.IDDAT(JE+20).NE.0)THEN                GENINT   1134
            DDAT(JE+19)=DDAT(JE+19)/BASPRN                              GENINT   1135
            DDAT(JE+20)=DDAT(JE+20)/BASPRN                              GENINT   1136
            VR1=CVREAL+CDGN*DDAT(JE+19)-CQGN*DDAT(JE+20)                GENINT   1137
            VR2=CVIMAG+CDGN*DDAT(JE+20)+CQGN*DDAT(JE+19)                GENINT   1138
            VREG(JY+1)=SQRT(VR1**2+VR2**2)                              GENINT   1139
         ELSE                                                           GENINT   1140
            VREG(JY+1)=ET                                               GENINT   1141
         ENDIF                                                          GENINT   1142
C                                                                       GENINT   1143
C     SENSING CIRCUIT                                                   GENINT   1144
C                                                                       GENINT   1145
         XSTATE(JSTATE+1)=VREG(JY+1)                                    GENINT   1146
         IF (DDAT(JE+18).GE.TMIN) XDFACT(JSTATE+1)=1.0/DDAT(JE+18)      GENINT   1147
C                                                                       GENINT   1148
         V1=XSTATE(JSTATE+1)                                            GENINT   1149
C                                                                       GENINT   1150
C   TYPE # :       1   2   3   4   5   6   7   8   9  10   11   12      GENINT   1151
           GOTO (650,650,700,750,700,800,850,850,900,950,1300,1300,     GENINT   1152
C            13   14   15   16   17   18   19   20   21   22   23       GENINT   1153
     &     1300,1000,1050,1900,1900,1900,1900,1900,1900,1900,1900,      GENINT   1154
C             24  25   26   27   28   29   30   31   32   33   34       GENINT   1155
     &     1900,1900,1900,1900,1900,1900,1100,1150,1200,1900,1250),IEXN GENINT   1156
C                                                                       GENINT   1157
C     SET TA=0.0 IF TA <= 0.005 FROM INPUT                              GENINT   1158
C                                                                       GENINT   1159
C  270    IF (DDAT(JE+3).LE.0.005) DDAT(JE+3)=0.0                       GENINT   1160
 650     CALL INE1N2                                                    GENINT   1161
         GO TO 1300                                                     GENINT   1162
 700     CALL INE3N5                                                    GENINT   1163
         GO TO 1300                                                     GENINT   1164
 750     CALL INE4                                                      GENINT   1165
         GO TO 1300                                                     GENINT   1166
 800     CALL INE6                                                      GENINT   1167
         GO TO 1300                                                     GENINT   1168
 850     CALL INE7N8                                                    GENINT   1169
         GO TO 1300                                                     GENINT   1170
 900     CALL INE9                                                      GENINT   1171
         GO TO 1300                                                     GENINT   1172
 950     CALL INE10                                                     GENINT   1173
         GO TO 1300                                                     GENINT   1174
 1000    CALL INE14                                                     GENINT   1175
         GO TO 1300                                                     GENINT   1176
 1050    CALL INE15                                                     GENINT   1177
         GO TO 1300                                                     GENINT   1178
 1100    CONTINUE                                                       GENINT   1179
         CALL INE30                                                     GENINT   1180
         GO TO 1300                                                     GENINT   1181
 1150    CALL INE31                                                     GENINT   1182
         GO TO 1300                                                     GENINT   1183
 1200    CALL INE32                                                     GENINT   1184
         GO TO 1300                                                     GENINT   1185
 1250    CALL INE34                                                     GENINT   1186
C                                                                       GENINT   1187
 1300 CONTINUE                                                          GENINT   1188
C                                                                       GENINT   1189
         MSTATE(3,N)=JSTATE                                             GENINT   1190
         JS=JCONTA(4,N)                                                 GENINT   1191
         IF(ISTABN.GT.0) THEN                                           GENINT   1192
            MYVAR(3,N)=JY                                               GENINT   1193
            JYS=JY                                                      GENINT   1194
            KSTATE=0                                                    GENINT   1195
            IF(ISTABN.EQ.50) THEN                                       GENINT   1196
               JE0=JS                                                   GENINT   1197
               DDAT(JE0+1)=DDAT(JE0+1)/BASPRN                           GENINT   1198
               DDAT(JE0+2)=DDAT(JE0+2)/BASPRN                           GENINT   1199
               JE1=JE0+9                                                GENINT   1200
               NRBUS=IDDAT(JE1)                                         GENINT   1201
               IF(NRBUS.EQ.0) THEN                                      GENINT   1202
                  VCR=GTREAL                                            GENINT   1203
                  VCI=GTIMAG                                            GENINT   1204
               ELSE                                                     GENINT   1205
                  IBUSR=IDDAT(JE1+1)                                    GENINT   1206
                  VCR=REAL(VOLT(IBUSR))                                 GENINT   1207
                  VCI=AIMAG(VOLT(IBUSR))                                GENINT   1208
               ENDIF                                                    GENINT   1209
C                                                                       GENINT   1210
C     GET THE KNOWN INPUTS                                              GENINT   1211
C                                                                       GENINT   1212
               CALL FMOVE(0,VALIN,VALIN,80)                             GENINT   1213
               RC=DDAT(JE0+1)                                           GENINT   1214
               XC=DDAT(JE0+2)                                           GENINT   1215
               VCD=VCR+(RC*CDGN-XC*CQGN)                                GENINT   1216
               VCQ=VCI+(RC*CQGN+XC*CDGN)                                GENINT   1217
               VCM=SQRT(VCD**2+VCQ**2)                                  GENINT   1218
               VALIN(1)=VCM                                             GENINT   1219
               IF(VCM.GT.0.05)VALIN(2)=ATAN2(VCQ,VCD)                   GENINT   1220
               VALIN(4)=GTV                                             GENINT   1221
               VALIN(5)=AT                                              GENINT   1222
               VALIN(6)=GTREAL                                          GENINT   1223
               VALIN(7)=GTIMAG                                          GENINT   1224
               VALIN(8)=CDGN/BASPRN                                     GENINT   1225
               VALIN(9)=CQGN/BASPRN                                     GENINT   1226
               VALIN(10)=PDGN/BASPRN                                    GENINT   1227
               VALIN(11)=PQGN/BASPRN                                    GENINT   1228
               VALIN(15)=EFDN                                           GENINT   1229
               VALIN(16)=CFDN                                           GENINT   1230
C                                                                       GENINT   1231
               IDDAT(JE0+4)=0                                           GENINT   1232
               DDAT(JE0+5)=VALIN(2)                                     GENINT   1233
               IDDAT(JE0+6)=0                                           GENINT   1234
               DDAT(JE0+7)=VALIN(5)                                     GENINT   1235
               NUF=2                                                    GENINT   1236
               CALL UDMINT(NUF,GTV,NLF,KN,CID)                          GENINT   1237
C                                                                       GENINT   1238
               IF(LDEB) WRITE(IUD6,3350) (VALIN(JK),JK=1,12),           GENINT   1239
     &         VALIN(14),VALIN(17),VALIN(18)                            GENINT   1240
               IF(LDEB) WRITE(IUD6,3200) (I,VALIN(I),I=1,80)            GENINT   1241
C                                                                       GENINT   1242
C     STORE THE REQUIRED INPUTS AND OUTPUTS                             GENINT   1243
C                                                                       GENINT   1244
               IOUT1=IDDAT(JE7+1)                                       GENINT   1245
               IOUT2=IDDAT(JE7+2)                                       GENINT   1246
               VSS(JYS+1)=0.0                                           GENINT   1247
               VALO=VALOUT(IOUT1)                                       GENINT   1248
               VALO=ABS(VALO)                                           GENINT   1249
               IF(VALO.GE.0.001) THEN                                   GENINT   1250
                  WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1251
     *                             ,INAME(KN),CID                       GENINT   1252
                  MSG(2)=                                               GENINT   1253
     *'              PSS OUTPUT IS NOT INITIALLY ZERO.'                 GENINT   1254
                  CALL PRTMSG(2)                                        GENINT   1255
               ENDIF                                                    GENINT   1256
               VTOS(JYS+2)=VALIN(4)                                     GENINT   1257
               VUAL(JYS+3)=0.0                                          GENINT   1258
               IF(IOUT2.NE.0) THEN                                      GENINT   1259
                  VALO=VALOUT(IOUT2)                                    GENINT   1260
                  VALO=ABS(VALO)                                        GENINT   1261
                  IF(VALO.GE.0.001) THEN                                GENINT   1262
                  WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1263
     *                             ,INAME(KN),CID                       GENINT   1264
                  MSG(2)=                                               GENINT   1265
     &'              UEL OUTPUT IS NOT INITIALLY ZERO.'                 GENINT   1266
                  CALL PRTMSG(2)                                        GENINT   1267
                  ENDIF                                                 GENINT   1268
               ENDIF                                                    GENINT   1269
               JY=JY+3                                                  GENINT   1270
               DO 1350 JK=1,NXUDB                                       GENINT   1271
               YVAR(JY+JK)=VALOUT(JK)                                   GENINT   1272
 1350          CONTINUE                                                 GENINT   1273
               JY=JY+NXUDB                                              GENINT   1274
               GO TO 1700                                               GENINT   1275
            ENDIF                                                       GENINT   1276
C                                                                       GENINT   1277
            IF (ISTABN.LE.6) THEN                                       GENINT   1278
               IF (IDDAT(JS+2).EQ.3.AND.DDAT(JS+11).LT.TMIN) THEN       GENINT   1279
                  WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1280
     *                              ,INAME(KN),CID                      GENINT   1281
                  WRITE(MSG(2),3560) ISTABN,'TF',DDAT(JS+11),TMIN       GENINT   1282
                   WRITE(MSG(3),3570) 'TF',TMIN                         GENINT   1283
                   CALL PRTMSG(3)                                       GENINT   1284
                   DDAT(JS+11)=TMIN                                     GENINT   1285
               END IF                                                   GENINT   1286
            ELSE IF (ISTABN.EQ.9) THEN                                  GENINT   1287
               IF ((IDDAT(JS+2).EQ.3.OR.IDDAT(JS+4).EQ.3)               GENINT   1288
     *            .AND.DDAT(JS+26).LT.TMIN) THEN                        GENINT   1289
                  WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1290
     *                              ,INAME(KN),CID                      GENINT   1291
                  WRITE(MSG(2),3560) ISTABN,'TF',DDAT(JS+26),TMIN       GENINT   1292
                   WRITE(MSG(3),3570) 'TF',TMIN                         GENINT   1293
                   CALL PRTMSG(3)                                       GENINT   1294
                   DDAT(JS+26)=TMIN                                     GENINT   1295
               END IF                                                   GENINT   1296
            ELSE IF (ISTABN.EQ.10) THEN                                 GENINT   1297
               IF (IDDAT(JS+2).EQ.3.AND.DDAT(JS+17).LT.TMIN) THEN       GENINT   1298
                  WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1299
     *                              ,INAME(KN),CID                      GENINT   1300
                  WRITE(MSG(2),3560) ISTABN,'TF',DDAT(JS+17),TMIN       GENINT   1301
                   WRITE(MSG(3),3570) 'TF',TMIN                         GENINT   1302
                   CALL PRTMSG(3)                                       GENINT   1303
                   DDAT(JS+17)=TMIN                                     GENINT   1304
               END IF                                                   GENINT   1305
            ELSE IF (ISTABN.EQ.11) THEN                                 GENINT   1306
               IF (IDDAT(JS+2).EQ.3.AND.DDAT(JS+26).LT.TMIN) THEN       GENINT   1307
                  WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1308
     *                              ,INAME(KN),CID                      GENINT   1309
                  WRITE(MSG(2),3560) ISTABN,'TF',DDAT(JS+26),TMIN       GENINT   1310
                   WRITE(MSG(3),3570) 'TF',TMIN                         GENINT   1311
                   CALL PRTMSG(3)                                       GENINT   1312
                   DDAT(JS+26)=TMIN                                     GENINT   1313
               END IF                                                   GENINT   1314
            ELSE IF (ISTABN.EQ.12) THEN                                 GENINT   1315
               IF ((IDDAT(JS+2).EQ.3.OR.IDDAT(JS+4).EQ.3)               GENINT   1316
     *            .AND.DDAT(JS+19).LT.TMIN) THEN                        GENINT   1317
                  WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1318
     *                              ,INAME(KN),CID                      GENINT   1319
                  WRITE(MSG(2),3560) ISTABN,'TF',DDAT(JS+19),TMIN       GENINT   1320
                   WRITE(MSG(3),3570) 'TF',TMIN                         GENINT   1321
                   CALL PRTMSG(3)                                       GENINT   1322
                   DDAT(JS+19)=TMIN                                     GENINT   1323
               END IF                                                   GENINT   1324
            END IF                                                      GENINT   1325
C                                                                       GENINT   1326
            ET=GTV                                                      GENINT   1327
C                                                                       GENINT   1328
            CALL ICSTAB(K)                                              GENINT   1329
C                                                                       GENINT   1330
            IF(ISTABN.NE.7) CALL ISGNAL(K)                              GENINT   1331
C                                                                       GENINT   1332
            KBUSNO=K                                                    GENINT   1333
C                                                                       GENINT   1334
C   ISTABN =         1    2    3    4    5    6    7    8    9          GENINT   1335
C                                                                       GENINT   1336
            GOTO (1400,1400,1400,1450,1450,1450,1450,1650,1500,         GENINT   1337
C                                                                       GENINT   1338
C                   10   11   12                                        GENINT   1339
     *            1550,1550,1600),ISTABN                                GENINT   1340
C                                                                       GENINT   1341
C        TYPE 1,2,3 STABILIZER                                          GENINT   1342
C                                                                       GENINT   1343
 1400       CALL ISTAB1(ISMAX,ISMIN)                                    GENINT   1344
            GOTO 1650                                                   GENINT   1345
C                                                                       GENINT   1346
C          TYPE 4,5,6,7 STABILIZER                                      GENINT   1347
C                                                                       GENINT   1348
 1450       CALL ISTAB4(ISMAX,ISMIN)                                    GENINT   1349
            GOTO 1650                                                   GENINT   1350
C                                                                       GENINT   1351
C         TYPE 9 STABILIZER                                             GENINT   1352
C                                                                       GENINT   1353
 1500       CALL ISTAB9(ISMAX,ISMIN,KBUSNO)                             GENINT   1354
            GOTO 1650                                                   GENINT   1355
C                                                                       GENINT   1356
C         TYPE 10,11 STABILIZER                                         GENINT   1357
C                                                                       GENINT   1358
 1550       CALL ISTA10(ISMAX,ISMIN)                                    GENINT   1359
            GOTO 1650                                                   GENINT   1360
C                                                                       GENINT   1361
C         TYPE 12 STABILIZER                                            GENINT   1362
C                                                                       GENINT   1363
 1600       CALL ISTA12(ISMAX,ISMIN)                                    GENINT   1364
            GO TO 1650                                                  GENINT   1365
C                                                                       GENINT   1366
 1650       IFLTRN=ICONTA(6,N)                                          GENINT   1367
            IF(IFLTRN.NE.0)CALL IFLTER(ISMAX,ISMIN)                     GENINT   1368
C                                                                       GENINT   1369
            VSS(JYS+1)=0.0                                              GENINT   1370
            JY=JY+2                                                     GENINT   1371
         END IF                                                         GENINT   1372
C                                                                       GENINT   1373
C                                                                       GENINT   1374
 1700    IUALN=ICONTA(7,N)                                              GENINT   1375
C                                                                       GENINT   1376
         MSTATE(4,N)=JSTATE                                             GENINT   1377
         IF(IUALN.NE.0)THEN                                             GENINT   1378
            JU=JCONTA(6,N)                                              GENINT   1379
            MYVAR(4,N)=JY                                               GENINT   1380
            JYU=JY                                                      GENINT   1381
            IF(IUALN.EQ.50.AND.ISTABN.NE.50) THEN                       GENINT   1382
               JE0=JU                                                   GENINT   1383
               DDAT(JE0+1)=DDAT(JE0+1)/BASPRN                           GENINT   1384
               DDAT(JE0+2)=DDAT(JE0+2)/BASPRN                           GENINT   1385
               JE1=JE0+9                                                GENINT   1386
               NRBUS=IDDAT(JE1)                                         GENINT   1387
               IF(NRBUS.EQ.0) THEN                                      GENINT   1388
                  VCR=GTREAL                                            GENINT   1389
                  VCI=GTIMAG                                            GENINT   1390
               ELSE                                                     GENINT   1391
                  IBUSR=IDDAT(JE1+1)                                    GENINT   1392
                  VCR=REAL(VOLT(IBUSR))                                 GENINT   1393
                  VCI=AIMAG(VOLT(IBUSR))                                GENINT   1394
               ENDIF                                                    GENINT   1395
C                                                                       GENINT   1396
C     GET THE KNOWN INPUTS                                              GENINT   1397
C                                                                       GENINT   1398
               CALL FMOVE(0,VALIN,VALIN,80)                             GENINT   1399
               RC=DDAT(JE0+1)                                           GENINT   1400
               XC=DDAT(JE0+2)                                           GENINT   1401
               VCD=VCR+(RC*CDGN-XC*CQGN)                                GENINT   1402
               VCQ=VCI+(RC*CQGN+XC*CDGN)                                GENINT   1403
               VCM=SQRT(VCD**2+VCQ**2)                                  GENINT   1404
               VALIN(1)=VCM                                             GENINT   1405
               IF(VCM.GT.0.05)VALIN(2)=ATAN2(VCQ,VCD)                   GENINT   1406
               VALIN(4)=GTV                                             GENINT   1407
               VALIN(5)=AT                                              GENINT   1408
               VALIN(6)=GTREAL                                          GENINT   1409
               VALIN(7)=GTIMAG                                          GENINT   1410
               VALIN(8)=CDGN/BASPRN                                     GENINT   1411
               VALIN(9)=CQGN/BASPRN                                     GENINT   1412
               VALIN(10)=PDGN/BASPRN                                    GENINT   1413
               VALIN(11)=PQGN/BASPRN                                    GENINT   1414
               VALIN(15)=EFDN                                           GENINT   1415
               VALIN(16)=CFDN                                           GENINT   1416
C                                                                       GENINT   1417
               IDDAT(JE0+4)=0                                           GENINT   1418
               DDAT(JE0+5)=VALIN(2)                                     GENINT   1419
               IDDAT(JE0+6)=0                                           GENINT   1420
               DDAT(JE0+7)=VALIN(5)                                     GENINT   1421
               NUF=3                                                    GENINT   1422
               CALL UDMINT(NUF,GTV,NLF,KN,CID)                          GENINT   1423
C                                                                       GENINT   1424
               IF(LDEB) THEN                                            GENINT   1425
               WRITE(IUD6,3400) (VALIN(JK),JK=1,12),VALIN(14),VALIN(18) GENINT   1426
               WRITE(IUD6,3200) (I,VALIN(I),I=1,80)                     GENINT   1427
               ENDIF                                                    GENINT   1428
C                                                                       GENINT   1429
C     STORE THE REQUIRED INPUTS AND OUTPUT                              GENINT   1430
C                                                                       GENINT   1431
               IOUT=IDDAT(JE7+1)                                        GENINT   1432
               VUAL(JYU+1)=0.0                                          GENINT   1433
               VALO=VALOUT(IOUT)                                        GENINT   1434
               VALO=ABS(VALO)                                           GENINT   1435
               IF(VALO.GE.0.001) THEN                                   GENINT   1436
                  WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1437
     *                             ,INAME(KN),CID                       GENINT   1438
                  MSG(2)=                                               GENINT   1439
     &'              UEL OUTPUT IS NOT INITIALLY ZERO.'                 GENINT   1440
                  CALL PRTMSG(2)                                        GENINT   1441
               ENDIF                                                    GENINT   1442
               VTOS(JYU+2)=VALIN(4)                                     GENINT   1443
               JY=JY+2                                                  GENINT   1444
               DO 1750 JK=1,NXUDB                                       GENINT   1445
               YVAR(JY+JK)=VALOUT(JK)                                   GENINT   1446
 1750          CONTINUE                                                 GENINT   1447
               JY=JY+NXUDB                                              GENINT   1448
               GO TO 1755                                               GENINT   1449
            ENDIF                                                       GENINT   1450
            IF(IUALN.EQ.50.AND.ISTABN.EQ.50) THEN                       GENINT   1451
               VUAL(JYU+1)=0.0                                          GENINT   1452
               JY=JY+1                                                  GENINT   1453
               GO TO 1755                                               GENINT   1454
            ENDIF                                                       GENINT   1455
            CALL INUAL                                                  GENINT   1456
         ENDIF                                                          GENINT   1457
C                                                                       GENINT   1458
C   MAXIMUM EXCITATION CURRENT LIMITER                                  GENINT   1459
C                                                                       GENINT   1460
 1755    CONTINUE                                                       GENINT   1461
         MSTATE(7,N)=JSTATE                                             GENINT   1462
         IF (IMXLN.NE.0) THEN                                           GENINT   1463
            JMX=JCONTA(11,N)                                            GENINT   1464
            MYVAR(8,N)=JY                                               GENINT   1465
            JYMX=JY                                                     GENINT   1466
            IF(IMXLN.EQ.50) THEN                                        GENINT   1467
               JE0=JMX                                                  GENINT   1468
               DDAT(JE0+1)=DDAT(JE0+1)/BASPRN                           GENINT   1469
               DDAT(JE0+2)=DDAT(JE0+2)/BASPRN                           GENINT   1470
               JE1=JE0+9                                                GENINT   1471
               NRBUS=IDDAT(JE1)                                         GENINT   1472
               IF(NRBUS.EQ.0) THEN                                      GENINT   1473
                  VCR=GTREAL                                            GENINT   1474
                  VCI=GTIMAG                                            GENINT   1475
               ELSE                                                     GENINT   1476
                  IBUSR=IDDAT(JE1+1)                                    GENINT   1477
                  VCR=REAL(VOLT(IBUSR))                                 GENINT   1478
                  VCI=AIMAG(VOLT(IBUSR))                                GENINT   1479
               ENDIF                                                    GENINT   1480
C                                                                       GENINT   1481
C     GET THE KNOWN INPUTS                                              GENINT   1482
C                                                                       GENINT   1483
               CALL FMOVE(0,VALIN,VALIN,80)                             GENINT   1484
               RC=DDAT(JE0+1)                                           GENINT   1485
               XC=DDAT(JE0+2)                                           GENINT   1486
               VCD=VCR+(RC*CDGN-XC*CQGN)                                GENINT   1487
               VCQ=VCI+(RC*CQGN+XC*CDGN)                                GENINT   1488
               VCM=SQRT(VCD**2+VCQ**2)                                  GENINT   1489
               VALIN(1)=VCM                                             GENINT   1490
               IF(VCM.GT.0.05)VALIN(2)=ATAN2(VCQ,VCD)                   GENINT   1491
               VALIN(4)=GTV                                             GENINT   1492
               VALIN(5)=AT                                              GENINT   1493
               VALIN(6)=GTREAL                                          GENINT   1494
               VALIN(7)=GTIMAG                                          GENINT   1495
               VALIN(8)=CDGN/BASPRN                                     GENINT   1496
               VALIN(9)=CQGN/BASPRN                                     GENINT   1497
               VALIN(10)=PDGN/BASPRN                                    GENINT   1498
               VALIN(11)=PQGN/BASPRN                                    GENINT   1499
               VALIN(15)=EFDN                                           GENINT   1500
               VALIN(16)=CFDN                                           GENINT   1501
C                                                                       GENINT   1502
               IDDAT(JE0+4)=0                                           GENINT   1503
               DDAT(JE0+5)=VALIN(2)                                     GENINT   1504
               IDDAT(JE0+6)=0                                           GENINT   1505
               DDAT(JE0+7)=VALIN(5)                                     GENINT   1506
               NUF=3                                                    GENINT   1507
               CALL UDMINT(NUF,GTV,NLF,KN,CID)                          GENINT   1508
C                                                                       GENINT   1509
               IF(LDEB) THEN                                            GENINT   1510
               WRITE(IUD6,3400) (VALIN(JK),JK=1,12),VALIN(14),VALIN(18) GENINT   1511
               WRITE(IUD6,3200) (I,VALIN(I),I=1,80)                     GENINT   1512
               ENDIF                                                    GENINT   1513
C                                                                       GENINT   1514
C     STORE THE REQUIRED INPUTS AND OUTPUT                              GENINT   1515
C                                                                       GENINT   1516
               IOUT=IDDAT(JE7+1)                                        GENINT   1517
               VMXL(JYMX+1)=0.0                                         GENINT   1518
               VALO=VALOUT(IOUT)                                        GENINT   1519
               VALO=ABS(VALO)                                           GENINT   1520
               IF(VALO.GE.0.001) THEN                                   GENINT   1521
                  WRITE(MSG(1),2800) NLF,INAME(KN-2),INAME(KN-1)        GENINT   1522
     *                             ,INAME(KN),CID                       GENINT   1523
                  MSG(2)=                                               GENINT   1524
     &'              OEL OUTPUT IS NOT INITIALLY ZERO.'                 GENINT   1525
                  CALL PRTMSG(2)                                        GENINT   1526
               ENDIF                                                    GENINT   1527
               VTOS(JYMX+2)=VALIN(4)                                    GENINT   1528
               JY=JY+2                                                  GENINT   1529
               DO 1760 JK=1,NXUDB                                       GENINT   1530
               YVAR(JY+JK)=VALOUT(JK)                                   GENINT   1531
 1760          CONTINUE                                                 GENINT   1532
               JY=JY+NXUDB                                              GENINT   1533
               GO TO 1900                                               GENINT   1534
            ELSE                                                        GENINT   1535
               MXLTYP=IMXLN                                             GENINT   1536
               IF (IMXLN.GT.10) MXLTYP=IMXLN-10                         GENINT   1537
               GOTO (1800,1850,1850,1850) MXLTYP                        GENINT   1538
 1800          CALL INMXL1                                              GENINT   1539
               GOTO 1850                                                GENINT   1540
            ENDIF                                                       GENINT   1541
         ENDIF                                                          GENINT   1542
 1850    CONTINUE                                                       GENINT   1543
C                                                                       GENINT   1544
         IF (ITEBN.NE.0) THEN                                           GENINT   1545
            JTB=JCONTA(10,N)                                            GENINT   1546
            MYVAR(7,N)=JY                                               GENINT   1547
            JYTB=JY                                                     GENINT   1548
            CALL INTEB                                                  GENINT   1549
         ENDIF                                                          GENINT   1550
C                                                                       GENINT   1551
C   ENDIF IEXN.NE.0                                                     GENINT   1552
C                                                                       GENINT   1553
      ENDIF                                                             GENINT   1554
                                                                        GENINT   1555
 1900 IGVN=ICONTA(2,N)                                                  GENINT   1556
      MSTATE(5,N)=JSTATE                                                GENINT   1557
      MSTATE(6,N)=JSTATE                                                GENINT   1558
      IF (PDGN.LE.0.0.AND.IGVN.EQ.20) THEN                              GENINT   1559
         WRITE(MSG(1),3450) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   GENINT   1560
         WRITE(MSG(2),3500) IGVN                                        GENINT   1561
         CALL PRTMSG(2)                                                 GENINT   1562
         IGVN=0                                                         GENINT   1563
         ICONTA(2,N)=0                                                  GENINT   1564
      END IF                                                            GENINT   1565
      IF (IGVN.NE.0) THEN                                               GENINT   1566
C                                                                       GENINT   1567
      JGG=JCONTA(2,N)                                                   GENINT   1568
      MYVAR(5,N)=JY                                                     GENINT   1569
      JYP=JY                                                            GENINT   1570
C                                                                       GENINT   1571
C                                                                       GENINT   1572
C   INITIALIZE GOVERNOR                                                 GENINT   1573
C                                                                       GENINT   1574
      IF(IGVN.EQ.50) THEN                                               GENINT   1575
C                                                                       GENINT   1576
C     GET THE KNOWN INPUTS                                              GENINT   1577
C                                                                       GENINT   1578
         JE0=JGG                                                        GENINT   1579
         CALL FMOVE(0,VALIN,VALIN,80)                                   GENINT   1580
         VALIN(4)=GTV                                                   GENINT   1581
         VALIN(5)=AT                                                    GENINT   1582
         VALIN(6)=GTREAL                                                GENINT   1583
         VALIN(7)=GTIMAG                                                GENINT   1584
         VALIN(8)=CDGN/BASPRN                                           GENINT   1585
         VALIN(9)=CQGN/BASPRN                                           GENINT   1586
         VALIN(10)=PDGN/BASPRN                                          GENINT   1587
         VALIN(11)=PQGN/BASPRN                                          GENINT   1588
         VALIN(15)=EFDN                                                 GENINT   1589
         VALIN(16)=CFDN                                                 GENINT   1590
C                                                                       GENINT   1591
         IDDAT(JE0+1)=0                                                 GENINT   1592
         DDAT(JE0+2)=VALIN(5)                                           GENINT   1593
         JE1=JE0+3                                                      GENINT   1594
         NUF=4                                                          GENINT   1595
         TINX=TIN5                                                      GENINT   1596
         CALL UDMINT(NUF,TINX,NLF,KN,CID)                               GENINT   1597
C                                                                       GENINT   1598
         IF(LDEB) WRITE(IUD6,3300) (VALIN(JK),JK=1,12),VALIN(14)        GENINT   1599
     &   ,VALIN(20)                                                     GENINT   1600
         IF(LDEB) WRITE(IUD6,3200) (I,VALIN(I),I=1,80)                  GENINT   1601
C                                                                       GENINT   1602
C     STORE THE REQUIRED INPUTS AND OUTPUT                              GENINT   1603
C                                                                       GENINT   1604
         VREF(JYP+1)=VALIN(20)                                          GENINT   1605
         VGOV(JYP+2)=VALIN(1)                                           GENINT   1606
         VGOV(JYP+4)=VALIN(2)                                           GENINT   1607
         JY=JY+4                                                        GENINT   1608
         DO 1950 JK=1,NXUDB                                             GENINT   1609
         YVAR(JY+JK)=VALOUT(JK)                                         GENINT   1610
 1950    CONTINUE                                                       GENINT   1611
         JY=JY+NXUDB                                                    GENINT   1612
         GO TO 2400                                                     GENINT   1613
      ENDIF                                                             GENINT   1614
*IF LTSP                                                                GENINT   1615
*ENDIF                                                                  GENINT   1719
C                                                                       GENINT   1720
C TYPE         1    2    3    4    5    6    7    8                     GENINT   1721
      GOTO (2000,2000,2000,2050,2050,2100,2150,2200,2400,2400,2400,     GENINT   1722
C TYPE                                                20   21   22      GENINT   1723
     +      2400,2400,2400,2400,2400,2400,2400,2400,2250,2300,2350)IGVN GENINT   1724
C                                                                       GENINT   1725
C     THERMAL UNITS -DETAILED MODELS                                    GENINT   1726
C                                                                       GENINT   1727
 2000 CONTINUE                                                          GENINT   1728
*IF LTSP                                                                GENINT   1729
*ENDIF                                                                  GENINT   1731
      CALL INGV01                                                       GENINT   1732
      GOTO 2400                                                         GENINT   1733
C                                                                       GENINT   1734
C   TYPE 4 AND 5                                                        GENINT   1735
C                                                                       GENINT   1736
 2050 CONTINUE                                                          GENINT   1737
*IF LTSP                                                                GENINT   1738
*ENDIF                                                                  GENINT   1740
      CALL INGV04(TIN5)                                                 GENINT   1741
      GOTO 2400                                                         GENINT   1742
C                                                                       GENINT   1743
C   TYPE 6, 7 AND 8                                                     GENINT   1744
C                                                                       GENINT   1745
 2100 CALL INGV06                                                       GENINT   1746
      GOTO 2400                                                         GENINT   1747
 2150 CALL INGV07                                                       GENINT   1748
      GOTO 2400                                                         GENINT   1749
 2200 CALL INGV08                                                       GENINT   1750
      GOTO 2400                                                         GENINT   1751
C                                                                       GENINT   1752
C     HYDRO GOVERNOR                                                    GENINT   1753
C                                                                       GENINT   1754
 2250 CALL INGV20                                                       GENINT   1755
      GOTO 2400                                                         GENINT   1756
 2300 CALL INGV21                                                       GENINT   1757
      GOTO 2400                                                         GENINT   1758
 2350 CALL INGV22                                                       GENINT   1759
 2400 CONTINUE                                                          GENINT   1760
C                                                                       GENINT   1761
C   ENDIF IGVN.NE.0                                                     GENINT   1762
C                                                                       GENINT   1763
      ENDIF                                                             GENINT   1764
C                                                                       GENINT   1765
      NSTATE=JSTATE                                                     GENINT   1766
C                                                                       GENINT   1767
 2450 CONTINUE                                                          GENINT   1768
      IF(YLARGE.GT.XLARGE)THEN                                          GENINT   1769
         ILARGE=K                                                       GENINT   1770
         XLARGE=YLARGE                                                  GENINT   1771
      ENDIF                                                             GENINT   1772
C                                                                       GENINT   1773
 2500 CONTINUE                                                          GENINT   1774
C                                                                       GENINT   1775
      MSTATE(1,N+1)=JSTATE                                              GENINT   1776
C                                                                       GENINT   1777
 2550 CONTINUE                                                          GENINT   1778
C                                                                       GENINT   1779
C                                                                       GENINT   1780
C   STORE SYSTH IN RECOPRICAL                                           GENINT   1781
C                                                                       GENINT   1782
      SYSTH=1.0/SYSTH                                                   GENINT   1783
C                                                                       GENINT   1784
      IF (IEBK.EQ.0) RETURN                                             GENINT   1785
C                                                                       GENINT   1786
      IF(IERR1 .NE. 0)THEN                                              GENINT   1787
         MSG(1)=' *** ERROR IN CS FRACTIONS, PROGRAM ABORTED'           GENINT   1788
         MSG(2)=                                                        GENINT   1789
     *    'GENINT: ABORTED DUE TO ERROR IN MULTI MASS FRACTIONS'        GENINT   1790
         LMSG=52                                                        GENINT   1791
      ENDIF                                                             GENINT   1792
      IF(IERR2 .NE. 0)THEN                                              GENINT   1793
         MSG(1)=                                                        GENINT   1794
     *' *** NEGATIVE PARKS PARAMETER ERROR, PROGRAM ABORTED'            GENINT   1795
         MSG(2)=                                                        GENINT   1796
     *    'GENINT: ABORTED DUE TO NEGATIVE PARKS PARAMETER'             GENINT   1797
         LMSG=47                                                        GENINT   1798
      ENDIF                                                             GENINT   1799
      IF(IERR3 .NE. 0)THEN                                              GENINT   1800
         MSG(1)=                                                        GENINT   1801
     *' *** ERROR IN FREQUENCY CONVERTOR, PROGRAM ABORTED.'             GENINT   1802
         MSG(2)='GENINT: FATAL ERROR'                                   GENINT   1803
         LMSG=19                                                        GENINT   1804
      ENDIF                                                             GENINT   1805
C                                                                       GENINT   1806
      CALL PRTMSG(1)                                                    GENINT   1807
      CALL ASTOP(MSG(2),LMSG)                                           GENINT   1808
C                                                                       GENINT   1809
 2750 FORMAT (//,1X,'BUS',I5,1X,'STATION:',1X,3A4,1X,'GID',A4,/,        GENINT   1810
     +1X,38('-'))                                                       GENINT   1811
 2800 FORMAT(' *** ERROR GENERATOR AT BUS: ',I5,' STATION: ',3A4        GENINT   1812
     *,' GID:',A2)                                                      GENINT   1813
 2810 FORMAT(' *** ERROR CLASSICAL GENERATOR AT BUS: ',I5               GENINT   1814
     &,' STATION: ',3A4)                                                GENINT   1815
 2850 FORMAT(5X,'SUM OF CS FRACTIONS =',F8.3                            GENINT   1816
     *,', SUM OF CG FRACTIONS =',F8.3)                                  GENINT   1817
 2900 FORMAT (/,1X,'INITIAL GENERATOR CONDITIONS:',/,1X,29('-'),//,4X,'EGENINT   1818
     +T =',F8.5,2X,'VANG =',F8.2,4X,'CR =',F8.3,4X,'CI =',F8.3,4X,'CT ='GENINT   1819
     &,F8.3,/,2X,' PFA =',I8,3X,'GMW =',F8.2,2X,' QFA =',I8,3X,'GMX ='  GENINT   1820
     &,F8.2)                                                            GENINT   1821
 2950 FORMAT (3X,'PHI =',F8.2,1X,'THETA =',F8.2,1X,'DELTA =',F8.2)      GENINT   1822
 3000 FORMAT (3X,'EFD =',F8.5,3X,'IFD =',F8.5,1X,'FLXAD =',F8.5,1X,'FLXAGENINT   1823
     +Q =',F8.5,1X,'FLXAT =',F8.5,/,4X,'SD =',F8.5,4X,'SQ =',F8.5)      GENINT   1824
 3050 FORMAT(4X,'MD =',I8,4X,'MQ =',I8,4X,'MT =',I8)                    GENINT   1825
 3100 FORMAT(5X,'CHECK MACHINE GENERATION OF CONVERTER #',I3)           GENINT   1826
 3110 FORMAT(' *** ERROR FREQUENCY CONVERTER PAIR AT:')                 GENINT   1827
 3120 FORMAT(5X,I5,' STATION: ',3A4,' GID: ',A2,' AND ',I5,' STATION: ' GENINT   1828
     &,3A4,' GID: ',A2)                                                 GENINT   1829
 3125 FORMAT(5X,I5,' STATION: ',3A4,' AND ',I5,' STATION: ',3A4)        GENINT   1830
 3130 FORMAT('     THE SUM OF GENERATIONS OF THIS CONVERTER PAIR IS'    GENINT   1831
     &,' NOT ZERO.')                                                    GENINT   1832
 3150 FORMAT (1X,I5,3X,3A4,50X,2G12.5)                                  GENINT   1833
 3200 FORMAT(1X,'INPUT VALUES: ',/,I5,F10.3)                            GENINT   1834
 3250 FORMAT(1X,'LOCAL INPUT SIGNALS:',/,' VC=',F6.3,' PU  AC=',F6.3,   GENINT   1835
     &' PU  PACC=',F6.3,' PU  VT=',F6.3,' PU  AT=',F6.3,' RAD  VD=',F6.3GENINT   1836
     &,' PU',/,' VQ=',F6.3,' PU  ID=',F6.3,' PU  IQ=',F6.3,' PU  PT=',  GENINT   1837
     &F6.3,' PU  QT=',F6.3,' PU  DW=',F6.3,' PU',/,' TS=',F6.3,' SEC '  GENINT   1838
     &,' EFD=',F6.3,' PU  IFD=',F6.3,' PU  VS=',F6.3,'  VU=',F6.3,      GENINT   1839
     &'  VF=',F6.3,' PU  VREF=',F6.3,/)                                 GENINT   1840
 3300 FORMAT(1X,'LOCAL INPUT SIGNALS:',/,' VG=',F6.3,' PU  VG2=',F6.3,  GENINT   1841
     &' PU  PACC=',F6.3,' PU  VT=',F6.3,' PU  AT=',F6.3,' RAD  VD=',F6.3GENINT   1842
     &,' PU  VQ=',F6.3,' PU',/,' ID=',F6.3,' PU  IQ=',F6.3,' PU  PT=',  GENINT   1843
     &F6.3,' PU  QT=',F6.3,' PU  DW=',F6.3,' PU  TS=',F6.3,' SEC ',     GENINT   1844
     &' VREF=',F6.3,/)                                                  GENINT   1845
 3350 FORMAT(1X,'LOCAL INPUT SIGNALS:',/,' VC=',F6.3,' PU  AC=',F6.3,   GENINT   1846
     &' PU  PACC=',F6.3,' PU  VT=',F6.3,' PU  AT=',F6.3,' RAD  VD=',F6.3GENINT   1847
     &,' PU',/,' VQ=',F6.3,' PU  ID=',F6.3,' PU  IQ=',F6.3,' PU  PT=',  GENINT   1848
     &F6.3,' PU  QT=',F6.3,' PU  DW=',F6.3,' PU',/,' TS=',F6.3,' SEC '  GENINT   1849
     &,' VS=',F6.3,'  VU=',F6.3,/)                                      GENINT   1850
 3400 FORMAT(1X,'LOCAL INPUT SIGNALS:',/,' VC=',F6.3,' PU  AC=',F6.3,   GENINT   1851
     &' PU  PACC=',F6.3,' PU  VT=',F6.3,' PU  AT=',F6.3,' RAD  VD=',F6.3GENINT   1852
     &,' PU',/,' VQ=',F6.3,' PU  ID=',F6.3,' PU  IQ=',F6.3,' PU  PT=',  GENINT   1853
     &F6.3,' PU  QT=',F6.3,' PU  DW=',F6.3,' PU',/,' TS=',F6.3,' SEC '  GENINT   1854
     &,' VU=',F6.3,/)                                                   GENINT   1855
 3450 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      GENINT   1856
     *,' GID:',A2)                                                      GENINT   1857
 3500 FORMAT(5X,'HAS ZERO POWER OUTPUT AND TYPE ',I2                    GENINT   1858
     *,' GOVERNOR.  THE GOVERNOR IS DISABLED.')                         GENINT   1859
 3550 FORMAT(5X,'INITIAL FIELD VOLTAGE =',F10.5                         GENINT   1860
     *,' HAS EXCEEDED 5.0 P.U..')                                       GENINT   1861
 3560 FORMAT(5X,'TYPE ',I2,' STABILIZER ',A,'=',F8.6                    GENINT   1862
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            GENINT   1863
 3570 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             GENINT   1864
 3580 FORMAT('     THE COMPUTED FIELD VOLTAGE WITHOUT CONSIDERING ',    GENINT   1865
     *'SATURATION IS GREATER')                                          GENINT   1866
 3590 FORMAT('     THAN 5.0. THIS MAY CAUSE COMPUTATION OVERFLOW ',     GENINT   1867
     *'PROBLEM.')                                                       GENINT   1868
 3600 FORMAT('     CHECK MACHINE DATA (IN PARTICULAR MVA BASE) AND ')   GENINT   1869
 3605 FORMAT('     GENERATION FOR CONSISTENCY.')                        GENINT   1870
 3610 FORMAT(5X,1A,'-AXIS SATURATION FACTOR = ',F6.4,' (<0.5). CHECK',  GENINT   1871
     *' THE SATURATION DATA.')                                          GENINT   1872
 3620 FORMAT(5X,'OPEN CIRCUIT FIELD CURRENT =',F9.4,' FOR THE CROWBAR ' GENINT   1873
     *,'MODEL IS INVALID.')                                             GENINT   1874
 3630 FORMAT(5X,'A POSITIVE VALUE IS EXPECTED. CHECK YOUR DATA.')       GENINT   1875
 3640 FORMAT(5X,'FIELD CURRENT IS NEGATIVE AT STEADY STATE: IFD ='      GENINT   1876
     *,F9.4)                                                            GENINT   1877
      END                                                               GENINT   1878
