CFPRIME PREDIC                                                          PREDIC      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 PREDIC                                                 PREDIC      3
CD                                                                      PREDIC      4
CD    TO PREDICT VALUES OF STATES AND VOLTAGES FOR NEXT TIME STEP IN    PREDIC      5
CD    TRAPEZOIDAL METHOD. ALSO PERFORM SOME PREPARASIONS AND SET        PREDIC      6
CD    NECESSARY FLAGS.                                                  PREDIC      7
CD                                                                      PREDIC      8
      INCLUDE 'PARX.INS'                                                PREDIC      9
      INCLUDE 'CNPT.INS'                                                PREDIC     10
      INCLUDE 'CNB3.INS'                                                PREDIC     11
      INCLUDE 'CNB4.INS'                                                PREDIC     12
      INCLUDE 'CNB5.INS'                                                PREDIC     13
      INCLUDE 'CNB6.INS'                                                PREDIC     14
      INCLUDE 'CNB8.INS'                                                PREDIC     15
      INCLUDE 'CNB9.INS'                                                PREDIC     16
      INCLUDE 'CNB19.INS'                                               PREDIC     17
      INCLUDE 'CNSVS.INS'                                               PREDIC     18
      INCLUDE 'CNUDM.INS'                                               PREDIC     19
      INCLUDE 'CNRAN.INS'                                               PREDIC     20
      INCLUDE 'CNSTP.INS'                                               PREDIC     21
      INCLUDE 'CNSDB.INS'                                               PREDIC     22
      INCLUDE 'CNPARX.INS'                                              PREDIC     23
      INCLUDE 'CNIPTR.INS'                                              PREDIC     24
      INCLUDE 'CNXSTA.INS'                                              PREDIC     25
      INCLUDE 'CNVOLT.INS'                                              PREDIC     26
      INCLUDE 'CNMDAT.INS'                                              PREDIC     27
      INCLUDE 'CNMSTA.INS'                                              PREDIC     28
      INCLUDE 'CNMYVA.INS'                                              PREDIC     29
      INCLUDE 'CNYVAR.INS'                                              PREDIC     30
      INCLUDE 'CNPREV.INS'                                              PREDIC     31
      INCLUDE 'CNXDOT.INS'                                              PREDIC     32
      INCLUDE 'CNGEAR.INS'                                              PREDIC     33
      INCLUDE 'CNIMPR.INS'                                              PREDIC     34
      INCLUDE 'CNGOVE.INS'                                              PREDIC     35
      INCLUDE 'CNMPAR.INS'                                              PREDIC     36
      INCLUDE 'CNUVAR.INS'                                              PREDIC     37
C                                                                       PREDIC     38
      REAL EWS1(2)                                                      PREDIC     39
      COMPLEX CWS1                                                      PREDIC     40
      EQUIVALENCE (CWS1,EWS1(1)),(EWS1(1),VREAL),(EWS1(2),VIMAG)        PREDIC     41
C                                                                       PREDIC     42
      DATA HPI/1.570295/                                                PREDIC     43
C                                                                       PREDIC     44
      JGG=0                                                             PREDIC     45
      LASTSV=0                                                          PREDIC     46
CCCCC                                                                   PREDIC     47
C                                                                       PREDIC     48
C-----------------------------------------------------------------------PREDIC     49
C                                                                       PREDIC     50
C     CAUTION : BEFORE ACTIVATING THESE CODES, MAKE SURE ALL THE        PREDIC     51
C               LOGICS THEREAFTER AND ARRAY ARRANGMENTS ARE OK.         PREDIC     52
C                                                                       PREDIC     53
C-----------------------------------------------------------------------PREDIC     54
C                                                                       PREDIC     55
C     PREDICTION FOR GEAR'S METHOD                                      PREDIC     56
C                                                                       PREDIC     57
C      IF (IGEARS) THEN                                                 PREDIC     58
C         HS2=H*H/2.0                                                   PREDIC     59
C         DO 100 I=1,NSTATE                                             PREDIC     60
C            XPREV(2,I)=XSTATE(I)                                       PREDIC     61
C            XSTATE(I)=XSTATE(I)+H*XDOT(I)+HS2*XDDOT(I)                 PREDIC     62
C            XPREV(1,I)=XSTATE(I)                                       PREDIC     63
C            OXDOT(I)=XDOT(I)                                           PREDIC     64
C            XDOTP(I)=XDOT(I)+H*XDDOT(I)                                PREDIC     65
C  100    CONTINUE                                                      PREDIC     66
C      END IF                                                           PREDIC     67
C                                                                       PREDIC     68
C      IF (IPREDM.EQ.1) THEN                                            PREDIC     69
C                                                                       PREDIC     70
C     PARABOLA PREDICTION                                               PREDIC     71
C                                                                       PREDIC     72
C         DO 110 I=1,NSTATE                                             PREDIC     73
C            WS1=XSTATE(I)                                              PREDIC     74
C            XSTATE(I)=3.0*XSTATE(I)-3.0*XPREV(1,I)+XPREV(2,I)          PREDIC     75
C            XPREV(2,I)=XPREV(1,I)                                      PREDIC     76
C            XPREV(1,I)=WS1                                             PREDIC     77
C            OXDOT(I)=XDOT(I)                                           PREDIC     78
C  110    CONTINUE                                                      PREDIC     79
CCCCC                                                                   PREDIC     80
C                                                                       PREDIC     81
C     ALL MACHINES, STATES ONLY WITH EULER PREDICTION                   PREDIC     82
C                                                                       PREDIC     83
      N=0                                                               PREDIC     84
      DO 120 I=1,IPNODE                                                 PREDIC     85
         L=0                                                            PREDIC     86
 135     L=L+1                                                          PREDIC     87
         N=N+1                                                          PREDIC     88
         JG=JCONTA(1,N)                                                 PREDIC     89
         JSM=MSTATE(1,N)+1                                              PREDIC     90
         LASTSV=MSTATE(1,N+1)                                           PREDIC     91
         IGENS=ICONTA(1,N)                                              PREDIC     92
         IGVN=ICONTA(2,N)                                               PREDIC     93
         IF (IGVN.EQ.46) IGVN=0                                         PREDIC     94
C                                                                       PREDIC     95
         HM=DDAT(JG+1)                                                  PREDIC     96
C                                                                       PREDIC     97
         IF (IGENS.EQ.4) THEN                                           PREDIC     98
C                                                                       PREDIC     99
C     CLASSICAL MACHINES                                                PREDIC    100
C                                                                       PREDIC    101
            JSMD=JSM+1                                                  PREDIC    102
            IF (HM.LT.1.0E-5) GOTO 136                                  PREDIC    103
            XPREV(1,JSM)=XSTATE(JSM)                                    PREDIC    104
            XSTATE(JSM)=XSTATE(JSM)+H*XDOT(JSM)                         PREDIC    105
            OXDOT(JSM)=XDOT(JSM)                                        PREDIC    106
C                                                                       PREDIC    107
            XPREV(1,JSMD)=XSTATE(JSMD)                                  PREDIC    108
            XSTATE(JSMD)=XSTATE(JSMD)+CEFJM*(XSTATE(JSM)+XPREV(1,JSM))  PREDIC    109
            OXDOT(JSMD)=XDOT(JSMD)                                      PREDIC    110
C                                                                       PREDIC    111
            IF (IGVN.NE.0) THEN                                         PREDIC    112
               DO 130 K=JSMD+1,LASTSV                                   PREDIC    113
                  XPREV(1,K)=XSTATE(K)                                  PREDIC    114
                  IF (IXDOT(K).NE.0) XSTATE(K)=XSTATE(K)+H*XDOT(K)      PREDIC    115
                  OXDOT(K)=XDOT(K)                                      PREDIC    116
  130          CONTINUE                                                 PREDIC    117
            END IF                                                      PREDIC    118
C                                                                       PREDIC    119
         ELSE                                                           PREDIC    120
C                                                                       PREDIC    121
            IF (HM.LT.1.0E-5) GOTO 136                                  PREDIC    122
C                                                                       PREDIC    123
            XPREV(1,JSM)=XSTATE(JSM)                                    PREDIC    124
            XSTATE(JSM)=XSTATE(JSM)+H*XDOT(JSM)                         PREDIC    125
            OXDOT(JSM)=XDOT(JSM)                                        PREDIC    126
C                                                                       PREDIC    127
            JSMD=JSM+1                                                  PREDIC    128
            XPREV(1,JSMD)=XSTATE(JSMD)                                  PREDIC    129
            XSTATE(JSMD)=XSTATE(JSMD)+CEFJM*(XSTATE(JSM)+XPREV(1,JSM))  PREDIC    130
            OXDOT(JSMD)=XDOT(JSMD)                                      PREDIC    131
C                                                                       PREDIC    132
C     OTHER STATES                                                      PREDIC    133
C                                                                       PREDIC    134
            DO 140 K=JSMD+1,LASTSV                                      PREDIC    135
               XPREV(1,K)=XSTATE(K)                                     PREDIC    136
               IF (IXDOT(K).NE.0) XSTATE(K)=XSTATE(K)+H*XDOT(K)         PREDIC    137
               OXDOT(K)=XDOT(K)                                         PREDIC    138
  140       CONTINUE                                                    PREDIC    139
         END IF                                                         PREDIC    140
C                                                                       PREDIC    141
  136    IF (L.LT.KTHGE(I)) GO TO 135                                   PREDIC    142
  120 CONTINUE                                                          PREDIC    143
C                                                                       PREDIC    144
C     ALL OTHER STATES                                                  PREDIC    145
C                                                                       PREDIC    146
      DO 170 I=LASTSV+1,NSTATE                                          PREDIC    147
         XPREV(1,I)=XSTATE(I)                                           PREDIC    148
         IF (IXDOT(I).NE.0) XSTATE(I)=XSTATE(I)+H*XDOT(I)               PREDIC    149
         OXDOT(I)=XDOT(I)                                               PREDIC    150
  170 CONTINUE                                                          PREDIC    151
C                                                                       PREDIC    152
C     ALL VOLTAGES                                                      PREDIC    153
C                                                                       PREDIC    154
C     NOTE : THE FOLLOWING LASTV2 SHOULD BE REPLACED BY                 PREDIC    155
C            LASTV1 WHEN IT IS AVAILABLE                                PREDIC    156
C                                                                       PREDIC    157
      DO 180 I=1,LASTV2                                                 PREDIC    158
         IF (CABS(VPREV(I)).GT.0.05) THEN                               PREDIC    159
            CWS1=VOLT(I)                                                PREDIC    160
            VOLT(I)=VOLT(I)*VOLT(I)/VPREV(I)                            PREDIC    161
            VPREV(I)=CWS1                                               PREDIC    162
         ELSE                                                           PREDIC    163
            VPREV(I)=VOLT(I)                                            PREDIC    164
         END IF                                                         PREDIC    165
  180 CONTINUE                                                          PREDIC    166
C                                                                       PREDIC    167
C     OTHER AUXILIARY PREDICTIONS/INITIALIZATION                        PREDIC    168
C                                                                       PREDIC    169
      WSYS=0.0                                                          PREDIC    170
      ICHPLP=0                                                          PREDIC    171
      N=0                                                               PREDIC    172
      DO 190 K=1,IPNODE                                                 PREDIC    173
C                                                                       PREDIC    174
         CWS1=VOLT(K)                                                   PREDIC    175
         EPD=VREAL                                                      PREDIC    176
         EPQ=VIMAG                                                      PREDIC    177
C                                                                       PREDIC    178
         L=0                                                            PREDIC    179
 205     L=L+1                                                          PREDIC    180
         N=N+1                                                          PREDIC    181
         JG=JCONTA(1,N)                                                 PREDIC    182
         JYG=MYVAR(1,N)                                                 PREDIC    183
         JSG=MSTATE(1,N)                                                PREDIC    184
         IGENS=ICONTA(1,N)                                              PREDIC    185
C                                                                       PREDIC    186
         HM=DDAT(JG+1)                                                  PREDIC    187
         IF (HM.LT.1.0E-5) GOTO 200                                     PREDIC    188
C                                                                       PREDIC    189
         IF (IGENS.EQ.4) THEN                                           PREDIC    190
C                                                                       PREDIC    191
C     CLASSICAL MACHINE                                                 PREDIC    192
C                                                                       PREDIC    193
            DELTA=XSTATE(JSG+2)                                         PREDIC    194
            CDG(1,N)=EMG(JYG+4)*SIN(DELTA)                              PREDIC    195
            CDG(2,N)=-EMG(JYG+4)*COS(DELTA)                             PREDIC    196
            IF (LSDAMP) WSYS=WSYS+XPREV(1,JSG+1)/DDAT(JG+1)             PREDIC    197
         ELSE                                                           PREDIC    198
C                                                                       PREDIC    199
C     DETAILED MACHINE                                                 PPREDIC    200
C                                                                       PREDIC    201
            CFDN=CFD(JYG+5)                                             PREDIC    202
            IF (LSDAMP) WSYS=WSYS+XPREV(1,JSG+1)/HM                     PREDIC    203
         END IF                                                         PREDIC    204
C                                                                       PREDIC    205
C     LIMITER CHECKING                                                  PREDIC    206
C                                                                       PREDIC    207
C-------------------                                                    PREDIC    208
C                                                                       PREDIC    209
C     EXCITERS                                                          PREDIC    210
C                                                                       PREDIC    211
C-------------------                                                    PREDIC    212
         IEXN=ICONTA(4,N)                                               PREDIC    213
         IF (IEXN.EQ.0) GOTO 900                                        PREDIC    214
         JYE=MYVAR(2,N)                                                 PREDIC    215
         JE=JCONTA(3,N)                                                 PREDIC    216
         JSE=MSTATE(2,N)                                                PREDIC    217
C                                                                       PREDIC    218
         IF (IEXN.EQ.50) GOTO 550                                       PREDIC    219
C                                                                       PREDIC    220
C               1   2   3   4   5   6   7   8   9   10  11              PREDIC    221
         GOTO (210,210,230,240,230,260,270,280,290,300,600,             PREDIC    222
C                                                                       PREDIC    223
C               12  13  14  15  16  17  18  19  20  21  22              PREDIC    224
     *         600,600,340,350,600,600,600,600,600,600,600,             PREDIC    225
C                                                                       PREDIC    226
C               23  24  25  26  27  28  29  30  31  32  33              PREDIC    227
     *         600,600,600,600,600,600,600,500,510,520,600,             PREDIC    228
C                                                                       PREDIC    229
C               34                                                      PREDIC    230
     *         540), IEXN                                               PREDIC    231
C                                                                       PREDIC    232
C     TYPE 1 AND 2                                                      PREDIC    233
C                                                                       PREDIC    234
  210    JSEC=JSE+4                                                     PREDIC    235
         IF (IXDOT(JSEC).EQ.0) GOTO 600                                 PREDIC    236
         IF (IDDAT(JE+16).EQ.0) THEN                                    PREDIC    237
            ETR=1.0                                                     PREDIC    238
         ELSE                                                           PREDIC    239
            CWS1=VOLT(K)                                                PREDIC    240
            ET=SQRT(VREAL*VREAL+VIMAG*VIMAG)                            PREDIC    241
            ETR=ET/DDAT(JE+16)                                          PREDIC    242
         END IF                                                         PREDIC    243
         VRMAX=ETR*DDAT(JE+14)                                          PREDIC    244
         VRMIN=ETR*DDAT(JE+15)                                          PREDIC    245
         IF (XSTATE(JSEC).GE.VRMAX) THEN                                PREDIC    246
            XSTATE(JSEC)=VRMAX                                          PREDIC    247
         ELSE IF (XSTATE(JSEC).LE.VRMIN) THEN                           PREDIC    248
            XSTATE(JSEC)=VRMIN                                          PREDIC    249
         END IF                                                         PREDIC    250
         GOTO 600                                                       PREDIC    251
C                                                                       PREDIC    252
C     TYPE 3 AND 5                                                      PREDIC    253
C                                                                       PREDIC    254
  230       JSEC=JSE+6                                                  PREDIC    255
            IF (IXDOT(JSEC).EQ.0) GOTO 235                              PREDIC    256
            IF (XSTATE(JSEC).GE.DDAT(JE+14)) THEN                       PREDIC    257
               XSTATE(JSEC)=DDAT(JE+14)                                 PREDIC    258
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+15)) THEN                  PREDIC    259
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    260
            END IF                                                      PREDIC    261
  235       JSEC=JSEC+1                                                 PREDIC    262
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    263
            IF (XSTATE(JSEC).LE.DDAT(JE+16)) THEN                       PREDIC    264
               XSTATE(JSEC)=DDAT(JE+16)                                 PREDIC    265
            END IF                                                      PREDIC    266
            GOTO 600                                                    PREDIC    267
C                                                                       PREDIC    268
C     TYPE 4                                                            PREDIC    269
C                                                                       PREDIC    270
  240       JSEC=JSE+4                                                  PREDIC    271
            IF (IXDOT(JSEC).EQ.0) GOTO 245                              PREDIC    272
            IF (XSTATE(JSEC).GE.DDAT(JE+14)) THEN                       PREDIC    273
               XSTATE(JSEC)=DDAT(JE+14)                                 PREDIC    274
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+15)) THEN                  PREDIC    275
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    276
            END IF                                                      PREDIC    277
  245       JSEC=JSEC+1                                                 PREDIC    278
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    279
            XDD=DDAT(JE+21)-DDAT(JE+22)                                 PREDIC    280
            SE=DDAT(JE+4)                                               PREDIC    281
            VE=XPREV(1,JSEC)                                            PREDIC    282
            IF(ABS(VE).GT.0.0) SE=SE+DDAT(JE+6)*EXP(DDAT(JE+7)*VE)/VE   PREDIC    283
            VEMAX=(DDAT(JE+27)-XDD*CFDN)/SE                             PREDIC    284
            IF (XSTATE(JSEC).GE.VEMAX) THEN                             PREDIC    285
               XSTATE(JSEC)=VEMAX                                       PREDIC    286
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+16)) THEN                  PREDIC    287
               XSTATE(JSEC)=DDAT(JE+16)                                 PREDIC    288
            END IF                                                      PREDIC    289
            GOTO 600                                                    PREDIC    290
C                                                                       PREDIC    291
C     TYPE 6                                                            PREDIC    292
C                                                                       PREDIC    293
  260       JSEC=JSE+4                                                  PREDIC    294
            IF (IXDOT(JSEC).EQ.0) GOTO 265                              PREDIC    295
            IF (XSTATE(JSEC).GE.DDAT(JE+14)) THEN                       PREDIC    296
               XSTATE(JSEC)=DDAT(JE+14)                                 PREDIC    297
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+15)) THEN                  PREDIC    298
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    299
            END IF                                                      PREDIC    300
  265       JSEC=JSEC+1                                                 PREDIC    301
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    302
            XDD=DDAT(JE+21)-DDAT(JE+22)                                 PREDIC    303
            SE=DDAT(JE+4)                                               PREDIC    304
            VE=XPREV(1,JSEC)                                            PREDIC    305
            IF(ABS(VE).GT.0.0) SE=SE+DDAT(JE+6)*EXP(DDAT(JE+7)*VE)/VE   PREDIC    306
            VEMAX=(DDAT(JE+27)-XDD*CFDN)/SE                             PREDIC    307
            IF (XSTATE(JSEC).GE.VEMAX) THEN                             PREDIC    308
               XSTATE(JSEC)=VEMAX                                       PREDIC    309
            ELSE IF (XSTATE(JSEC).LE.0.0) THEN                          PREDIC    310
               XSTATE(JSEC)=0.0                                         PREDIC    311
            END IF                                                      PREDIC    312
            GOTO 600                                                    PREDIC    313
C                                                                       PREDIC    314
C     TYPE 7                                                            PREDIC    315
C                                                                       PREDIC    316
  270       JSEC=JSE+4                                                  PREDIC    317
            IF (IXDOT(JSEC).EQ.0) GOTO 275                              PREDIC    318
            IF (XSTATE(JSEC).GE.DDAT(JE+15)) THEN                       PREDIC    319
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    320
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+16)) THEN                  PREDIC    321
               XSTATE(JSEC)=DDAT(JE+16)                                 PREDIC    322
            END IF                                                      PREDIC    323
  275       JSEC=JSEC+1                                                 PREDIC    324
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    325
            IF (XSTATE(JSEC).GE.DDAT(JE+17)) THEN                       PREDIC    326
               XSTATE(JSEC)=DDAT(JE+17)                                 PREDIC    327
            ELSE IF (XSTATE(JSEC).LE.0.0) THEN                          PREDIC    328
               XSTATE(JSEC)=0.0                                         PREDIC    329
            END IF                                                      PREDIC    330
            GOTO 600                                                    PREDIC    331
C                                                                       PREDIC    332
C     TYPE 8                                                            PREDIC    333
C                                                                       PREDIC    334
  280       JSEC=JSE+4                                                  PREDIC    335
            IF (IXDOT(JSEC).EQ.0) GOTO 285                              PREDIC    336
            IF (XSTATE(JSEC).GE.DDAT(JE+25)) THEN                       PREDIC    337
               XSTATE(JSEC)=DDAT(JE+25)                                 PREDIC    338
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+26)) THEN                  PREDIC    339
               XSTATE(JSEC)=DDAT(JE+26)                                 PREDIC    340
            END IF                                                      PREDIC    341
  285       JSEC=JSEC+1                                                 PREDIC    342
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    343
            IF (XSTATE(JSEC).GE.DDAT(JE+15)) THEN                       PREDIC    344
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    345
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+16)) THEN                  PREDIC    346
               XSTATE(JSEC)=DDAT(JE+16)                                 PREDIC    347
            END IF                                                      PREDIC    348
            GOTO 600                                                    PREDIC    349
C                                                                       PREDIC    350
C     TYPE 9                                                            PREDIC    351
C                                                                       PREDIC    352
  290       JSEC=JSE+2                                                  PREDIC    353
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    354
            IF (XSTATE(JSEC).GE.DDAT(JE+14)) THEN                       PREDIC    355
               XSTATE(JSEC)=DDAT(JE+14)                                 PREDIC    356
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+15)) THEN                  PREDIC    357
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    358
            END IF                                                      PREDIC    359
            GOTO 600                                                    PREDIC    360
C                                                                       PREDIC    361
C     TYPE 10                                                           PREDIC    362
C                                                                       PREDIC    363
  300       JSEC=JSE+3                                                  PREDIC    364
            IF (IXDOT(JSEC).EQ.0) GOTO 305                              PREDIC    365
            IF (XSTATE(JSEC).GE.DDAT(JE+16)) THEN                       PREDIC    366
               XSTATE(JSEC)=DDAT(JE+16)                                 PREDIC    367
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+17)) THEN                  PREDIC    368
               XSTATE(JSEC)=DDAT(JE+17)                                 PREDIC    369
            END IF                                                      PREDIC    370
  305       VRFIN(JYE+3)=XSTATE(JSEC)                                   PREDIC    371
            GOTO 600                                                    PREDIC    372
C                                                                       PREDIC    373
C     TYPE 14                                                           PREDIC    374
C                                                                       PREDIC    375
  340       JSEC=JSE+4                                                  PREDIC    376
C                                                                       PREDIC    377
            IF (IDDAT(JE+17).EQ.0) THEN                                 PREDIC    378
C                                                                       PREDIC    379
            IF (IXDOT(JSEC).EQ.0) GOTO 345                              PREDIC    380
            IF (XSTATE(JSEC).GE.DDAT(JE+14)) THEN                       PREDIC    381
               XSTATE(JSEC)=DDAT(JE+14)                                 PREDIC    382
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+15)) THEN                  PREDIC    383
               XSTATE(JSEC)=DDAT(JE+15)                                 PREDIC    384
            END IF                                                      PREDIC    385
C                                                                       PREDIC    386
            END IF                                                      PREDIC    387
C                                                                       PREDIC    388
  345       JSEC=JSEC+1                                                 PREDIC    389
            IF (IXDOT(JSEC).EQ.0) GOTO 347                              PREDIC    390
            IF (XSTATE(JSEC).LE.DDAT(JE+16)) THEN                       PREDIC    391
               XSTATE(JSEC)=DDAT(JE+16)                                 PREDIC    392
            END IF                                                      PREDIC    393
  347       JSEC=JSEC+1                                                 PREDIC    394
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    395
            IF (XSTATE(JSEC).GE.DDAT(JE+31)) THEN                       PREDIC    396
               XSTATE(JSEC)=DDAT(JE+31)                                 PREDIC    397
            ELSE IF (XSTATE(JSEC).LE.0.0) THEN                          PREDIC    398
               XSTATE(JSEC)=0.0                                         PREDIC    399
            END IF                                                      PREDIC    400
            GOTO 600                                                    PREDIC    401
C                                                                       PREDIC    402
C     TYPE 15                                                           PREDIC    403
C                                                                       PREDIC    404
  350       JSEC=JSE+4                                                  PREDIC    405
            IF (IXDOT(JSEC).EQ.0) GOTO 355                              PREDIC    406
            IF (XSTATE(JSEC).GE.DDAT(JE+11)) THEN                       PREDIC    407
               XSTATE(JSEC)=DDAT(JE+11)                                 PREDIC    408
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+12)) THEN                  PREDIC    409
               XSTATE(JSEC)=DDAT(JE+12)                                 PREDIC    410
            END IF                                                      PREDIC    411
  355       VRFIN(JYE+3)=XSTATE(JSEC)                                   PREDIC    412
            GOTO 600                                                    PREDIC    413
C                                                                       PREDIC    414
C     TYPE 30                                                           PREDIC    415
C                                                                       PREDIC    416
  500       JSEC=IDDAT(JE+34)                                           PREDIC    417
            IF (JSEC.NE.0) THEN                                         PREDIC    418
               JSEC=JSEC+JSG                                            PREDIC    419
               IF (IXDOT(JSEC).EQ.0) GOTO 505                           PREDIC    420
               IF (XSTATE(JSEC).GE.DDAT(JE+25)) THEN                    PREDIC    421
                  XSTATE(JSEC)=DDAT(JE+25)                              PREDIC    422
               END IF                                                   PREDIC    423
            END IF                                                      PREDIC    424
C                                                                       PREDIC    425
  505       JSEC=IDDAT(JE+38)                                           PREDIC    426
            IF (IDDAT(JE+3).NE.0) THEN                                  PREDIC    427
               JSEC=JSEC+JSG                                            PREDIC    428
               IF (IXDOT(JSEC).EQ.0) GOTO 600                           PREDIC    429
               IF (IDDAT(JE+12).EQ.0) THEN                              PREDIC    430
                  VEMAX=DDAT(JE+10)-DDAT(JE+13)*CFDN                    PREDIC    431
                  VEMIN=DDAT(JE+11)+DDAT(JE+13)*CFDN                    PREDIC    432
               ELSE                                                     PREDIC    433
                  VT=CABS(VOLT(K))                                      PREDIC    434
                  VT=VT/DDAT(JE+12)                                     PREDIC    435
                  VEMAX=DDAT(JE+10)*VT-DDAT(JE+13)*CFDN                 PREDIC    436
                  VEMIN=DDAT(JE+11)*VT+DDAT(JE+13)*CFDN                 PREDIC    437
               END IF                                                   PREDIC    438
               IF (XSTATE(JSEC).GE.VEMAX) THEN                          PREDIC    439
                  XSTATE(JSEC)=VEMAX                                    PREDIC    440
               ELSE IF (XSTATE(JSEC).LE.VEMIN) THEN                     PREDIC    441
                  XSTATE(JSEC)=VEMIN                                    PREDIC    442
               END IF                                                   PREDIC    443
            END IF                                                      PREDIC    444
            IF (IDDAT(JE+40).EQ.-1) IDDAT(JE+40)=0                      PREDIC    445
            GOTO 600                                                    PREDIC    446
C                                                                       PREDIC    447
C     TYPE 31                                                           PREDIC    448
C                                                                       PREDIC    449
  510       JSEC=IDDAT(JE+26)                                           PREDIC    450
            IF (JSEC.NE.0) THEN                                         PREDIC    451
               JSEC=JSEC+JSG                                            PREDIC    452
               IF (IXDOT(JSEC).EQ.0) GOTO 515                           PREDIC    453
               IF (XSTATE(JSEC).GE.DDAT(JE+25)) THEN                    PREDIC    454
                  XSTATE(JSEC)=DDAT(JE+25)                              PREDIC    455
               END IF                                                   PREDIC    456
            END IF                                                      PREDIC    457
C                                                                       PREDIC    458
  515       JSEC=IDDAT(JE+27)                                           PREDIC    459
            IF (JSEC.NE.0) THEN                                         PREDIC    460
               JSEC=JSEC+JSG                                            PREDIC    461
               IF (IXDOT(JSEC).EQ.0) GOTO 600                           PREDIC    462
               IF (XSTATE(JSEC).GE.DDAT(JE+10)) THEN                    PREDIC    463
                  XSTATE(JSEC)=DDAT(JE+10)                              PREDIC    464
               ELSE IF (XSTATE(JSEC).LE.DDAT(JE+11)) THEN               PREDIC    465
                  XSTATE(JSEC)=DDAT(JE+11)                              PREDIC    466
               END IF                                                   PREDIC    467
            END IF                                                      PREDIC    468
            IF (IDDAT(JE+28).EQ.-1) IDDAT(JE+28)=0                      PREDIC    469
            GOTO 600                                                    PREDIC    470
C                                                                       PREDIC    471
C     TYPE 32                                                           PREDIC    472
C                                                                       PREDIC    473
  520       JSEC=JSE+2                                                  PREDIC    474
            IF (IXDOT(JSEC).EQ.0) GOTO 525                              PREDIC    475
            IF (XSTATE(JSEC).GE.DDAT(JE+30)) THEN                       PREDIC    476
               XSTATE(JSEC)=DDAT(JE+30)                                 PREDIC    477
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+31)) THEN                  PREDIC    478
               XSTATE(JSEC)=DDAT(JE+31)                                 PREDIC    479
            END IF                                                      PREDIC    480
C                                                                       PREDIC    481
  525       JSEC=IDDAT(JE+45)                                           PREDIC    482
            IF (IDDAT(JE+3).NE.0) THEN                                  PREDIC    483
               JSEC=JSEC+JSG                                            PREDIC    484
               IF (IXDOT(JSEC).EQ.0) GOTO 527                           PREDIC    485
               IF (IDDAT(JE+12).EQ.0) THEN                              PREDIC    486
                  VEMAX=DDAT(JE+10)-DDAT(JE+13)*CFDN                    PREDIC    487
                  VEMIN=DDAT(JE+11)+DDAT(JE+13)*CFDN                    PREDIC    488
               ELSE                                                     PREDIC    489
                  VT=CABS(VOLT(K))                                      PREDIC    490
                  VT=VT/DDAT(JE+12)                                     PREDIC    491
                  VEMAX=DDAT(JE+10)*VT-DDAT(JE+13)*CFDN                 PREDIC    492
                  VEMIN=DDAT(JE+11)*VT+DDAT(JE+13)*CFDN                 PREDIC    493
               END IF                                                   PREDIC    494
               IF (XSTATE(JSEC).GE.VEMAX) THEN                          PREDIC    495
                  XSTATE(JSEC)=VEMAX                                    PREDIC    496
               ELSE IF (XSTATE(JSEC).LE.VEMIN) THEN                     PREDIC    497
                  XSTATE(JSEC)=VEMIN                                    PREDIC    498
               END IF                                                   PREDIC    499
            END IF                                                      PREDIC    500
  527       VRFIN(JYE+3)=XSTATE(JSEC)                                   PREDIC    501
            IF (IDDAT(JE+46).EQ.-1) IDDAT(JE+46)=0                      PREDIC    502
            GOTO 600                                                    PREDIC    503
C                                                                       PREDIC    504
C     TYPE 34                                                           PREDIC    505
C                                                                       PREDIC    506
  540       JSEC=JSE+2                                                  PREDIC    507
            IF (IXDOT(JSEC).EQ.0) GOTO 600                              PREDIC    508
            IF (XSTATE(JSEC).GE.DDAT(JE+12)) THEN                       PREDIC    509
               XSTATE(JSEC)=DDAT(JE+12)                                 PREDIC    510
            ELSE IF (XSTATE(JSEC).LE.DDAT(JE+13)) THEN                  PREDIC    511
               XSTATE(JSEC)=DDAT(JE+13)                                 PREDIC    512
            END IF                                                      PREDIC    513
            IF (IDDAT(JE+29).EQ.-1) IDDAT(JE+29)=0                      PREDIC    514
            GOTO 600                                                    PREDIC    515
C                                                                       PREDIC    516
C     TYPE 50 EXCITER -- USER DEFINED MODEL                             PREDIC    517
C                                                                       PREDIC    518
 550        CONTINUE                                                    PREDIC    519
C                                                                       PREDIC    520
C     CHECK NON-WINDUP LIMITERS                                         PREDIC    521
C                                                                       PREDIC    522
            JE1=JE+9                                                    PREDIC    523
            NRBUS=IDDAT(JE1)                                            PREDIC    524
            JE2=JE1+3*NRBUS+1                                           PREDIC    525
            NRLIN=IDDAT(JE2)                                            PREDIC    526
            JE3=JE2+4*NRLIN+1                                           PREDIC    527
            NUDB=IDDAT(JE3)                                             PREDIC    528
            JE4=JE3+17*NUDB+1                                           PREDIC    529
            JE5=JE4+3*NUDB+1                                            PREDIC    530
            INTUD=IDDAT(JE5)                                            PREDIC    531
            JE6=JE5+2*INTUD+1                                           PREDIC    532
            INPUD=IDDAT(JE6)                                            PREDIC    533
            JE7=JE6+3*INPUD                                             PREDIC    534
C                                                                       PREDIC    535
            CALL UDMNWL(1)                                              PREDIC    536
C                                                                       PREDIC    537
  600       CONTINUE                                                    PREDIC    538
C                                                                       PREDIC    539
C-------------------                                                    PREDIC    540
C                                                                       PREDIC    541
C     STABILIZERS                                                       PREDIC    542
C                                                                       PREDIC    543
C-------------------                                                    PREDIC    544
            ISTABN=ICONTA(5,N)                                          PREDIC    545
            IF (ISTABN.LE.0) GOTO 900                                   PREDIC    546
            JS=JCONTA(4,N)                                              PREDIC    547
C                                                                       PREDIC    548
            IF (ISTABN.EQ.50) GOTO 710                                  PREDIC    549
C                                                                       PREDIC    550
C                  1   2   3   4   5   6   7   8   9   10  11           PREDIC    551
            GOTO (900,700,700,900,700,700,900,900,900,900,900,          PREDIC    552
C                                                                       PREDIC    553
C                  12                                                   PREDIC    554
     *            900), ISTABN                                          PREDIC    555
C                                                                       PREDIC    556
C     TYPE 2, 3, 5 AND 6                                                PREDIC    557
C                                                                       PREDIC    558
  700       IF (ISTABN.LT.4) THEN                                       PREDIC    559
               JSEC=IDDAT(JS+26)                                        PREDIC    560
            ELSE                                                        PREDIC    561
               JSEC=IDDAT(JS+27)                                        PREDIC    562
            END IF                                                      PREDIC    563
            JSEC=JSEC+JSG                                               PREDIC    564
            IF (IXDOT(JSEC).EQ.0) GOTO 900                              PREDIC    565
            IF (XSTATE(JSEC).GE.DDAT(JS+21)) THEN                       PREDIC    566
               XSTATE(JSEC)=DDAT(JS+21)                                 PREDIC    567
            END IF                                                      PREDIC    568
            GOTO 900                                                    PREDIC    569
C                                                                       PREDIC    570
C     TYPE 50 STABILIZER -- USER DEFINED MODEL                          PREDIC    571
C                                                                       PREDIC    572
 710        CONTINUE                                                    PREDIC    573
C                                                                       PREDIC    574
C     CHECK NON-WINDUP LIMITERS                                         PREDIC    575
C                                                                       PREDIC    576
            JE1=JS+9                                                    PREDIC    577
            NRBUS=IDDAT(JE1)                                            PREDIC    578
            JE2=JE1+3*NRBUS+1                                           PREDIC    579
            NRLIN=IDDAT(JE2)                                            PREDIC    580
            JE3=JE2+4*NRLIN+1                                           PREDIC    581
            NUDB=IDDAT(JE3)                                             PREDIC    582
            JE4=JE3+17*NUDB+1                                           PREDIC    583
            JE5=JE4+3*NUDB+1                                            PREDIC    584
            INTUD=IDDAT(JE5)                                            PREDIC    585
            JE6=JE5+2*INTUD+1                                           PREDIC    586
            INPUD=IDDAT(JE6)                                            PREDIC    587
            JE7=JE6+3*INPUD                                             PREDIC    588
C                                                                       PREDIC    589
            CALL UDMNWL(0)                                              PREDIC    590
C                                                                       PREDIC    591
  900       CONTINUE                                                    PREDIC    592
C                                                                       PREDIC    593
C     CHECK MAXIMUM EXCITATION CURRENT LIMITER TRIPPING CONDITION       PREDIC    594
C                                                                       PREDIC    595
      IMXLN=ICONTA(12,N)                                                PREDIC    596
      IF (IMXLN.NE.0) THEN                                              PREDIC    597
         JMX=JCONTA(11,N)                                               PREDIC    598
         JYMX=MYVAR(8,N)                                                PREDIC    599
         IF (DDAT(JMX+10).LE.-0.9999) THEN                              PREDIC    600
            IF (CFDN.GE.DDAT(JMX+6)) THEN                               PREDIC    601
               DDAT(JMX+10)=DDAT(JMX+10)+H                              PREDIC    602
               YIFL(JYMX+2)=YIFL(JYMX+2)+CFDN*H                         PREDIC    603
            END IF                                                      PREDIC    604
         ELSE                                                           PREDIC    605
            DDAT(JMX+10)=DDAT(JMX+10)+H                                 PREDIC    606
            YIFL(JYMX+2)=YIFL(JYMX+2)+CFDN*H                            PREDIC    607
         END IF                                                         PREDIC    608
      END IF                                                            PREDIC    609
C                                                                       PREDIC    610
C-------------------                                                    PREDIC    611
C                                                                       PREDIC    612
C     GOVERNORS                                                         PREDIC    613
C                                                                       PREDIC    614
C-------------------                                                    PREDIC    615
            IGVN=ICONTA(2,N)                                            PREDIC    616
            IF(IGVN.EQ.46) IGVN=0                                       PREDIC    617
            IF (IGVN.EQ.0) GOTO 1500                                    PREDIC    618
            JGG=JCONTA(2,N)                                             PREDIC    619
            JSGV=MSTATE(5,N)                                            PREDIC    620
            JYP=MYVAR(5,N)                                              PREDIC    621
C                                                                       PREDIC    622
            IF (IGVN.EQ.50) GOTO 1250                                   PREDIC    623
C                                                                       PREDIC    624
            IF(IGVN.GT.40.AND.IGVN.LT.50)GOTO 1500                      PREDIC    625
C                                                                       PREDIC    626
C                                                                       PREDIC    627
C   IEEE SIMPLIFIED BOILER MODEL TYPE 31,32,34,AND 35                   PREDIC    628
C                                                                       PREDIC    629
          IGVNB=0                                                       PREDIC    630
          IF(IGVN.GE.31.AND.IGVN.LE.35) THEN                            PREDIC    631
             IGVNB=IGVN                                                 PREDIC    632
             IGVN=IGVN-30                                               PREDIC    633
          END IF                                                        PREDIC    634
C                                                                       PREDIC    635
C                                                                       PREDIC    636
C                   1    2    3    4    5    6    7    8                PREDIC    637
            GOTO (1010,1010,1500,1040,1500,1060,1060,1500,              PREDIC    638
C                                                                       PREDIC    639
C                   9   10   11   12   13   14   15   16                PREDIC    640
     *            1500,1500,1500,1500,1500,1500,1500,1500,              PREDIC    641
C                                                                       PREDIC    642
C                  17   18   19   20   21   22                          PREDIC    643
     *            1500,1500,1500,1200,1210,1500), IGVN                  PREDIC    644
C                                                                       PREDIC    645
C     TYPE 1 AND 2 ,31 & 32                                             PREDIC    646
C                                                                       PREDIC    647
 1010       JSGVC=JSGV+5                                                PREDIC    648
            IF (IXDOT(JSGVC).EQ.0) GOTO 1011                            PREDIC    649
            IF (XSTATE(JSGVC).GE.1.0) THEN                              PREDIC    650
               XSTATE(JSGVC)=1.0                                        PREDIC    651
            ELSE IF (XSTATE(JSGVC).LE.0.0) THEN                         PREDIC    652
               XSTATE(JSGVC)=0.0                                        PREDIC    653
            END IF                                                      PREDIC    654
 1011       JSGVC=JSGV+8                                                PREDIC    655
            IF (IXDOT(JSGVC).EQ.0) GOTO 1020                            PREDIC    656
            IF (XSTATE(JSGVC).GE.1.0) THEN                              PREDIC    657
               XSTATE(JSGVC)=1.0                                        PREDIC    658
            ELSE IF (XSTATE(JSGVC).LE.0.0) THEN                         PREDIC    659
               XSTATE(JSGVC)=0.0                                        PREDIC    660
            END IF                                                      PREDIC    661
 1020       IF (IGVNB.NE.0) THEN                                        PREDIC    662
               JGGB=JGG+78                                              PREDIC    663
               JSGVC=JSGV+19                                            PREDIC    664
               IF (IXDOT(JSGVC).EQ.0) THEN                              PREDIC    665
                  IGVN=IGVNB                                            PREDIC    666
                  GOTO 1500                                             PREDIC    667
               END IF                                                   PREDIC    668
               IF (XSTATE(JSGVC).GE.DDAT(JGGB+11)) THEN                 PREDIC    669
                  XSTATE(JSGVC)=DDAT(JGGB+11)                           PREDIC    670
               ELSE IF (XSTATE(JSGVC).LE.DDAT(JGGB+10)) THEN            PREDIC    671
                  XSTATE(JSGVC)=DDAT(JGGB+10)                           PREDIC    672
               END IF                                                   PREDIC    673
               IGVN=IGVNB                                               PREDIC    674
            END IF                                                      PREDIC    675
            GOTO 1500                                                   PREDIC    676
C                                                                       PREDIC    677
C     TYPE 4                                                            PREDIC    678
C                                                                       PREDIC    679
 1040       JSGVC=JSGV+2                                                PREDIC    680
            IF (IXDOT(JSGVC).EQ.0) GOTO 1050                            PREDIC    681
            IF (XSTATE(JSGVC).GE.1.0) THEN                              PREDIC    682
               XSTATE(JSGVC)=1.0                                        PREDIC    683
            ELSE IF (XSTATE(JSGVC).LE.0.0) THEN                         PREDIC    684
               XSTATE(JSGVC)=0.0                                        PREDIC    685
            END IF                                                      PREDIC    686
 1050       IF (IGVNB.NE.0) THEN                                        PREDIC    687
               JGGB=JGG+16                                              PREDIC    688
               JSGVC=JSGV+15                                            PREDIC    689
               IF (IXDOT(JSGVC).EQ.0) THEN                              PREDIC    690
                  IGVN=IGVNB                                            PREDIC    691
                  GOTO 1500                                             PREDIC    692
               END IF                                                   PREDIC    693
               IF (XSTATE(JSGVC).GE.DDAT(JGGB+11)) THEN                 PREDIC    694
                  XSTATE(JSGVC)=DDAT(JGGB+11)                           PREDIC    695
               ELSE IF (XSTATE(JSGVC).LE.DDAT(JGGB+10)) THEN            PREDIC    696
                  XSTATE(JSGVC)=DDAT(JGGB+10)                           PREDIC    697
               END IF                                                   PREDIC    698
               IGVN=IGVNB                                               PREDIC    699
            END IF                                                      PREDIC    700
C                                                                       PREDIC    701
            GOTO 1500                                                   PREDIC    702
C                                                                       PREDIC    703
C     TYPE 6 AND 7                                                      PREDIC    704
C                                                                       PREDIC    705
 1060       JSGVC=JSGV+1                                                PREDIC    706
            IF (IXDOT(JSGVC).EQ.0) GOTO 1500                            PREDIC    707
            IF (XSTATE(JSGVC).GE.1.0) THEN                              PREDIC    708
               XSTATE(JSGVC)=1.0                                        PREDIC    709
            ELSE IF (XSTATE(JSGVC).LE.DDAT(JGG+6)) THEN                 PREDIC    710
               XSTATE(JSGVC)=DDAT(JGG+6)                                PREDIC    711
            END IF                                                      PREDIC    712
            GOTO 1500                                                   PREDIC    713
C                                                                       PREDIC    714
C     TYPE 20                                                           PREDIC    715
C                                                                       PREDIC    716
 1200       JSGVC=JSGV+1                                                PREDIC    717
            IF (IXDOT(JSGVC).EQ.0) GOTO 1500                            PREDIC    718
            IF (XSTATE(JSGVC).GE.1.0) THEN                              PREDIC    719
               XSTATE(JSGVC)=1.0                                        PREDIC    720
            ELSE IF (XSTATE(JSGVC).LE.0.0) THEN                         PREDIC    721
               XSTATE(JSGVC)=0.0                                        PREDIC    722
            END IF                                                      PREDIC    723
            GOTO 1500                                                   PREDIC    724
C                                                                       PREDIC    725
C     TYPE 21                                                           PREDIC    726
C                                                                       PREDIC    727
 1210       JSGVC=JSGV+1                                                PREDIC    728
            IF (IXDOT(JSGVC).EQ.0) GOTO 1215                            PREDIC    729
            IF (XSTATE(JSGVC).GE.DDAT(JGG+10)) THEN                     PREDIC    730
               XSTATE(JSGVC)=DDAT(JGG+10)                               PREDIC    731
            ELSE IF (XSTATE(JSGVC).LE.DDAT(JGG+11)) THEN                PREDIC    732
               XSTATE(JSGVC)=DDAT(JGG+11)                               PREDIC    733
            END IF                                                      PREDIC    734
 1215       JSGVC=JSGV+2                                                PREDIC    735
            IF (IXDOT(JSGVC).EQ.0) GOTO 1500                            PREDIC    736
            IF (XSTATE(JSGVC).GE.DDAT(JGG+7)) THEN                      PREDIC    737
               XSTATE(JSGVC)=DDAT(JGG+7)                                PREDIC    738
            ELSE IF (XSTATE(JSGVC).LE.DDAT(JGG+8)) THEN                 PREDIC    739
               XSTATE(JSGVC)=DDAT(JGG+8)                                PREDIC    740
            END IF                                                      PREDIC    741
            GOTO 1500                                                   PREDIC    742
C                                                                       PREDIC    743
C     TYPE 50 GOVERNOR -- USER DEFINED MODEL                            PREDIC    744
C                                                                       PREDIC    745
 1250       CONTINUE                                                    PREDIC    746
C                                                                       PREDIC    747
C     CHECK NON-WINDUP LIMITERS                                         PREDIC    748
C                                                                       PREDIC    749
            JE1=JGG+3                                                   PREDIC    750
            NRBUS=IDDAT(JE1)                                            PREDIC    751
            JE2=JE1+3*NRBUS+1                                           PREDIC    752
            NRLIN=IDDAT(JE2)                                            PREDIC    753
            JE3=JE2+4*NRLIN+1                                           PREDIC    754
            NUDB=IDDAT(JE3)                                             PREDIC    755
            JE4=JE3+17*NUDB+1                                           PREDIC    756
            JE5=JE4+3*NUDB+1                                            PREDIC    757
            INTUD=IDDAT(JE5)                                            PREDIC    758
            JE6=JE5+2*INTUD+1                                           PREDIC    759
            INPUD=IDDAT(JE6)                                            PREDIC    760
            JE7=JE6+3*INPUD                                             PREDIC    761
C                                                                       PREDIC    762
            CALL UDMNWL(2)                                              PREDIC    763
C                                                                       PREDIC    764
 1500       CONTINUE                                                    PREDIC    765
C                                                                       PREDIC    766
C     CALCULATE COUPLING COEFFICIENTS FOR LP MACHINE                    PREDIC    767
C                                                                       PREDIC    768
            IF (IGVN.EQ.5.OR.IGVN.EQ.35) THEN                           PREDIC    769
               ICHPLP=ICHPLP+3                                          PREDIC    770
               PMAXL=-CEFJM*HM*DDAT(JGG+4)                              PREDIC    771
               CHPLP(ICHPLP-2)=PMAXL*DDAT(JGG+1)                        PREDIC    772
               CHPLP(ICHPLP-1)=PMAXL*DDAT(JGG+2)                        PREDIC    773
               CHPLP(ICHPLP)=PMAXL*DDAT(JGG+3)                          PREDIC    774
            END IF                                                      PREDIC    775
C                                                                       PREDIC    776
            IF (IGENS.EQ.4) GOTO 200                                    PREDIC    777
C                                                                       PREDIC    778
C     CALCULATE DEVICE CURRENT (EXTERNAL) USING                         PREDIC    779
C     PREDICTED XSTATE AND VOLT                                         PREDIC    780
C                                                                       PREDIC    781
            MD=IDDAT(JG+34)                                             PREDIC    782
            MQ=IDDAT(JG+35)                                             PREDIC    783
            CALL UVARB (N,JG,MD,MQ,JSG)                                 PREDIC    784
            CDG(1,N)=UVAR(1,N)*EPD+UVAR(2,N)*EPQ-UVAR(5,N)              PREDIC    785
            CDG(2,N)=UVAR(3,N)*EPD+UVAR(4,N)*EPQ-UVAR(6,N)              PREDIC    786
C                                                                       PREDIC    787
  200    IF (L.LT.KTHGE(K)) GO TO 205                                   PREDIC    788
  190 CONTINUE                                                          PREDIC    789
C                                                                       PREDIC    790
      WSYS=WSYS*SYSTH                                                   PREDIC    791
C                                                                       PREDIC    792
C     INDUCTION MOTOR                                                   PREDIC    793
C                                                                       PREDIC    794
      IF (NMOTL.NE.0) THEN                                              PREDIC    795
         DO 1630 KK=1,NMOTL                                             PREDIC    796
            K=NMOLD(KK)                                                 PREDIC    797
            JM=JMDAT(KK)                                                PREDIC    798
            IF (DDAT(JM+15).LT.0.0) GOTO 1630                           PREDIC    799
            JZT=JXIMO(KK)                                               PREDIC    800
            JY=JVIMO(KK)                                                PREDIC    801
            MOTYPK=IDDAT(JM+1)                                          PREDIC    802
            GLK=GSM(JY+4)                                               PREDIC    803
            BLK=BSM(JY+5)                                               PREDIC    804
            IF (MOTYPK.LT.10) THEN                                      PREDIC    805
               VR=REAL(VOLT(K))                                         PREDIC    806
               VI=AIMAG(VOLT(K))                                        PREDIC    807
            ELSE                                                        PREDIC    808
               VR=DDAT(JM+37)                                           PREDIC    809
               VI=DDAT(JM+38)                                           PREDIC    810
               MOTYPK=MOTYPK-10                                         PREDIC    811
            END IF                                                      PREDIC    812
            IF (MOTYPK.LE.3) THEN                                       PREDIC    813
               XM1=XSTATE(JZT+1)                                        PREDIC    814
               XM2=XSTATE(JZT+2)                                        PREDIC    815
            ELSE                                                        PREDIC    816
               XM1=0.0                                                  PREDIC    817
               XM2=0.0                                                  PREDIC    818
            END IF                                                      PREDIC    819
            CDM(JY+8)=GLK*(VR-XM1)+BLK*(VI-XM2)                         PREDIC    820
            CDM(JY+9)=GLK*(VI-XM2)-BLK*(VR-XM1)                         PREDIC    821
 1630    CONTINUE                                                       PREDIC    822
      END IF                                                            PREDIC    823
C                                                                       PREDIC    824
C     TSC LOAD                                                          PREDIC    825
C                                                                       PREDIC    826
      IF (NTSCL.NE.0) THEN                                              PREDIC    827
         DO 1635 KK=1,NTSCL                                             PREDIC    828
            JTSC=JTCDAT(KK)                                             PREDIC    829
            JSTATE=JXTSC(KK)                                            PREDIC    830
            NLF=IDDAT(JTSC+1)                                           PREDIC    831
            VR=REAL(VOLT(NLF))                                          PREDIC    832
            VI=AIMAG(VOLT(NLF))                                         PREDIC    833
            VMG=SQRT(VR*VR+VI*VI)                                       PREDIC    834
            IF (IXDOT(JSTATE+2).NE.0) THEN                              PREDIC    835
               GMAX=DDAT(JTSC+7)                                        PREDIC    836
               IF (XSTATE(JSTATE+2).GE.GMAX) THEN                       PREDIC    837
                  XSTATE(JSTATE+2)=GMAX                                 PREDIC    838
               ELSE IF (XSTATE(JSTATE+2).LE.0.0) THEN                   PREDIC    839
                  XSTATE(JSTATE+2)=0.0                                  PREDIC    840
               END IF                                                   PREDIC    841
            END IF                                                      PREDIC    842
            IF (IDDAT(JTSC+15).EQ.0) THEN                               PREDIC    843
               IF (VMG.LE.VTHZL) IDDAT(JTSC+15)=1                       PREDIC    844
            ELSE                                                        PREDIC    845
               IF (VMG.GT.VTHZH) IDDAT(JTSC+15)=0                       PREDIC    846
            END IF                                                      PREDIC    847
            GTSC=DDAT(JTSC+11)                                          PREDIC    848
 1635    CONTINUE                                                       PREDIC    849
      END IF                                                            PREDIC    850
C                                                                       PREDIC    851
C     SVC                                                               PREDIC    852
C                                                                       PREDIC    853
      IF (NSVC.EQ.0) GOTO 1640                                          PREDIC    854
C                                                                       PREDIC    855
      DO 1650 I=1,NSVC                                                  PREDIC    856
         JS=JSDAT(I)                                                    PREDIC    857
         JSM=JXSVR(I)                                                   PREDIC    858
         ISTATE=JXSVR(I+1)-JSM                                          PREDIC    859
         NRTYPN=IDDAT(JS+9)                                             PREDIC    860
C                                                                       PREDIC    861
         IF (NRTYPN.EQ.6) GOTO 1650                                     PREDIC    862
         IF (NRTYPN.EQ.50) GOTO 1850                                    PREDIC    863
C                                                                       PREDIC    864
C                1    2                                                 PREDIC    865
         GOTO (1810,1820), NRTYPN                                       PREDIC    866
C                                                                       PREDIC    867
C     TYPE 1                                                            PREDIC    868
C                                                                       PREDIC    869
 1810    IWS1=8                                                         PREDIC    870
         IWS2=3                                                         PREDIC    871
         GOTO 1900                                                      PREDIC    872
C                                                                       PREDIC    873
C     TYPE 2                                                            PREDIC    874
C                                                                       PREDIC    875
 1820    IWS1=18                                                        PREDIC    876
         IWS2=17                                                        PREDIC    877
         GOTO 1900                                                      PREDIC    878
C                                                                       PREDIC    879
 1900    IF (IDDAT(JS+IWS1).NE.0) THEN                                  PREDIC    880
            JSSVC=JSM+ISTATE                                            PREDIC    881
            XMIN=-DDAT(JS+IWS2)                                         PREDIC    882
            XMAX=1.0+XMIN                                               PREDIC    883
            IF (IXDOT(JSSVC).EQ.0) GOTO 1650                            PREDIC    884
            IF (XSTATE(JSSVC).GE.XMAX) THEN                             PREDIC    885
               XSTATE(JSSVC)=XMAX                                       PREDIC    886
            ELSE IF (XSTATE(JSSVC).LE.XMIN) THEN                        PREDIC    887
               XSTATE(JSSVC)=XMIN                                       PREDIC    888
            END IF                                                      PREDIC    889
         END IF                                                         PREDIC    890
         GOTO 1650                                                      PREDIC    891
C                                                                       PREDIC    892
C     TYPE 50 SVC -- USER DEFINED MODEL                                 PREDIC    893
C                                                                       PREDIC    894
 1850    CONTINUE                                                       PREDIC    895
C                                                                       PREDIC    896
C     CHECK NON-WINDUP LIMITERS                                         PREDIC    897
C                                                                       PREDIC    898
         JE1=JS+13                                                      PREDIC    899
         NRBUS=IDDAT(JE1)                                               PREDIC    900
         JE2=JE1+3*NRBUS+1                                              PREDIC    901
         NRLIN=IDDAT(JE2)                                               PREDIC    902
         JE3=JE2+4*NRLIN+1                                              PREDIC    903
         NUDB=IDDAT(JE3)                                                PREDIC    904
         JE4=JE3+17*NUDB+1                                              PREDIC    905
         JE5=JE4+3*NUDB+1                                               PREDIC    906
         INTUD=IDDAT(JE5)                                               PREDIC    907
         JE6=JE5+2*INTUD+1                                              PREDIC    908
         INPUD=IDDAT(JE6)                                               PREDIC    909
         JE7=JE6+3*INPUD                                                PREDIC    910
C                                                                       PREDIC    911
         CALL UDMNWL(3)                                                 PREDIC    912
C                                                                       PREDIC    913
 1650 CONTINUE                                                          PREDIC    914
C                                                                       PREDIC    915
 1640 CONTINUE                                                          PREDIC    916
C                                                                       PREDIC    917
C     RANI                                                              PREDIC    918
C                                                                       PREDIC    919
      IF (NRANI.EQ.0) GOTO 1670                                         PREDIC    920
C                                                                       PREDIC    921
      DO 1660 N=1,NRANI                                                 PREDIC    922
         JR=JRDAT(N)                                                    PREDIC    923
         JSTATE=JXRAN(N)                                                PREDIC    924
         JY=JVRAN(N)                                                    PREDIC    925
         NRTYPN=IDDAT(JR+4)                                             PREDIC    926
         IF (NRTYPN.NE.50) GO TO 1660                                   PREDIC    927
C                                                                       PREDIC    928
         JE1=JR+12                                                      PREDIC    929
         NRBUS=IDDAT(JE1)                                               PREDIC    930
         JE2=JE1+3*NRBUS+1                                              PREDIC    931
         NRLIN=IDDAT(JE2)                                               PREDIC    932
         JE3=JE2+4*NRLIN+1                                              PREDIC    933
         NUDB=IDDAT(JE3)                                                PREDIC    934
         JE4=JE3+17*NUDB+1                                              PREDIC    935
         JE5=JE4+3*NUDB+1                                               PREDIC    936
         INTUD=IDDAT(JE5)                                               PREDIC    937
         JE6=JE5+2*INTUD+1                                              PREDIC    938
         INPUD=IDDAT(JE6)                                               PREDIC    939
         JE7=JE6+3*INPUD                                                PREDIC    940
C                                                                       PREDIC    941
         CALL UDMNWL(3)                                                 PREDIC    942
C                                                                       PREDIC    943
 1660 CONTINUE                                                          PREDIC    944
C                                                                       PREDIC    945
 1670 CONTINUE                                                          PREDIC    946
C                                                                       PREDIC    947
C     STP                                                               PREDIC    948
C                                                                       PREDIC    949
      IF (NTCPS.EQ.0) GOTO 1680                                         PREDIC    950
C                                                                       PREDIC    951
      DO 1690 N=1,NTCPS                                                 PREDIC    952
C                                                                       PREDIC    953
         JTP=JTPDAT(N)                                                  PREDIC    954
         NTTYPN=IDDAT(JTP+4)                                            PREDIC    955
         NPTYPN=IDDAT(JTP+5)                                            PREDIC    956
C                                                                       PREDIC    957
         IF (NTTYPN.EQ.50) THEN                                         PREDIC    958
            JSTATE=JXSTC(N)                                             PREDIC    959
            JYTC=JVSTC(N)                                               PREDIC    960
            JE1=JTDAT(N)+1                                              PREDIC    961
            NRBUS=IDDAT(JE1)                                            PREDIC    962
            JE2=JE1+3*NRBUS+1                                           PREDIC    963
            NRLIN=IDDAT(JE2)                                            PREDIC    964
            JE3=JE2+4*NRLIN+1                                           PREDIC    965
            NUDB=IDDAT(JE3)                                             PREDIC    966
            JE4=JE3+17*NUDB+1                                           PREDIC    967
            JE5=JE4+3*NUDB+1                                            PREDIC    968
            INTUD=IDDAT(JE5)                                            PREDIC    969
            JE6=JE5+2*INTUD+1                                           PREDIC    970
            INPUD=IDDAT(JE6)                                            PREDIC    971
            JE7=JE6+3*INPUD                                             PREDIC    972
            CALL UDMNWL(4)                                              PREDIC    973
         END IF                                                         PREDIC    974
C                                                                       PREDIC    975
         IF (NPTYPN.EQ.50) THEN                                         PREDIC    976
            JSTATE=JXSPS(N)                                             PREDIC    977
            JYPS=JVSPS(N)                                               PREDIC    978
            JE1=JPDAT(N)+1                                              PREDIC    979
            NRBUS=IDDAT(JE1)                                            PREDIC    980
            JE2=JE1+3*NRBUS+1                                           PREDIC    981
            NRLIN=IDDAT(JE2)                                            PREDIC    982
            JE3=JE2+4*NRLIN+1                                           PREDIC    983
            NUDB=IDDAT(JE3)                                             PREDIC    984
            JE4=JE3+17*NUDB+1                                           PREDIC    985
            JE5=JE4+3*NUDB+1                                            PREDIC    986
            INTUD=IDDAT(JE5)                                            PREDIC    987
            JE6=JE5+2*INTUD+1                                           PREDIC    988
            INPUD=IDDAT(JE6)                                            PREDIC    989
            JE7=JE6+3*INPUD                                             PREDIC    990
            CALL UDMNWL(5)                                              PREDIC    991
         END IF                                                         PREDIC    992
C                                                                       PREDIC    993
 1690 CONTINUE                                                          PREDIC    994
C                                                                       PREDIC    995
 1680 CONTINUE                                                          PREDIC    996
C                                                                       PREDIC    997
C     SDB                                                               PREDIC    998
C                                                                       PREDIC    999
      IF (NSDB.EQ.0) GOTO 2000                                          PREDIC   1000
C                                                                       PREDIC   1001
      DO 2010 N=1,NSDB                                                  PREDIC   1002
C                                                                       PREDIC   1003
         JD=JDDAT(N)                                                    PREDIC   1004
         NDTYPN=IDDAT(JD+2)                                             PREDIC   1005
C                                                                       PREDIC   1006
         IF (NDTYPN.EQ.50) THEN                                         PREDIC   1007
            JSTATE=JXSDB(N)                                             PREDIC   1008
            JY=JVSDB(N)                                                 PREDIC   1009
            JE1=JD+6                                                    PREDIC   1010
            NRBUS=IDDAT(JE1)                                            PREDIC   1011
            JE2=JE1+3*NRBUS+1                                           PREDIC   1012
            NRLIN=IDDAT(JE2)                                            PREDIC   1013
            JE3=JE2+4*NRLIN+1                                           PREDIC   1014
            NUDB=IDDAT(JE3)                                             PREDIC   1015
            JE4=JE3+17*NUDB+1                                           PREDIC   1016
            JE5=JE4+3*NUDB+1                                            PREDIC   1017
            INTUD=IDDAT(JE5)                                            PREDIC   1018
            JE6=JE5+2*INTUD+1                                           PREDIC   1019
            INPUD=IDDAT(JE6)                                            PREDIC   1020
            JE7=JE6+3*INPUD                                             PREDIC   1021
            CALL UDMNWL(6)                                              PREDIC   1022
         END IF                                                         PREDIC   1023
C                                                                       PREDIC   1024
 2010 CONTINUE                                                          PREDIC   1025
C                                                                       PREDIC   1026
 2000 CONTINUE                                                          PREDIC   1027
C                                                                       PREDIC   1028
      IF (NLBS.EQ.0) GOTO 1700                                          PREDIC   1029
      IF (LDISC) GOTO 1700                                              PREDIC   1030
C                                                                       PREDIC   1031
C     PREDICT FREQUENCY FOR THE NON-LINEAR LOADS                        PREDIC   1032
C                                                                       PREDIC   1033
      HOLD=TS-TSOLD                                                     PREDIC   1034
      IF (ABS(HOLD).GT.1.E-4) THEN                                      PREDIC   1035
         HOLD=HOLD*WOBASE                                               PREDIC   1036
         HNEW=H*WOBASE                                                  PREDIC   1037
         ISHIFT=0                                                       PREDIC   1038
         DO 1710 I=1,NLOD                                               PREDIC   1039
            NCOMP=NLCOMP(1,I)                                           PREDIC   1040
            DO 1705 J=1,NCOMP                                           PREDIC   1041
            ISHIFT=ISHIFT+1                                             PREDIC   1042
            JTYPE=NLTYPE(ISHIFT)                                        PREDIC   1043
            IF(JTYPE.NE.3)GOTO 1705                                     PREDIC   1044
            K=NLDOLD(I)                                                 PREDIC   1045
            JNL=JDNLL(ISHIFT)                                           PREDIC   1046
            ANGOLD=DDAT(JNL+6)                                          PREDIC   1047
            CWS1=VPREV(K)                                               PREDIC   1048
            IF (ABS(VREAL).GT.1.0E-6.OR.ABS(VIMAG).GT.1.0E-6) THEN      PREDIC   1049
               ANGNEW=ATAN2(VIMAG,VREAL)                                PREDIC   1050
            ELSE                                                        PREDIC   1051
               ANGNEW=0.0                                               PREDIC   1052
            END IF                                                      PREDIC   1053
            DEFNEW=ANGNEW-ANGOLD                                        PREDIC   1054
            IF (ABS(ANGOLD).GT.HPI.OR.ABS(ANGNEW).GT.HPI) THEN          PREDIC   1055
               ANX=ANGNEW*ANGOLD                                        PREDIC   1056
               IF (ANX.LT.0.0) THEN                                     PREDIC   1057
                  IF (ANGOLD.GT.0.0) THEN                               PREDIC   1058
                     DEFNEW=4.0/PI+DEFNEW                               PREDIC   1059
                  ELSE                                                  PREDIC   1060
                     DEFNEW=DEFNEW-4.0/PI                               PREDIC   1061
                  END IF                                                PREDIC   1062
               END IF                                                   PREDIC   1063
            END IF                                                      PREDIC   1064
C                                                                       PREDIC   1065
            DEFNEW=DEFNEW/HOLD                                          PREDIC   1066
C            DEFOLD=DDAT(JNL+7)                                         PREDIC   1067
C            DEFPRE=DEFNEW+(DEFNEW-DEFOLD)*HNEW/HOLD                    PREDIC   1068
            DEFPRE=DEFNEW                                               PREDIC   1069
            DDAT(JNL+7)=DEFNEW                                          PREDIC   1070
            DDAT(JNL+6)=ANGNEW                                          PREDIC   1071
            DDAT(JNL+8)=DEFPRE                                          PREDIC   1072
 1705     CONTINUE                                                      PREDIC   1073
 1710    CONTINUE                                                       PREDIC   1074
         TSOLD=TS                                                       PREDIC   1075
      END IF                                                            PREDIC   1076
C                                                                       PREDIC   1077
 1700 CONTINUE                                                          PREDIC   1078
C                                                                       PREDIC   1079
C    SET FLAG FOR CONST. CURRENT AND CONST. MVA BUSES                   PREDIC   1080
C                                                                       PREDIC   1081
      IF (NKCUR.EQ.0 .AND. NKMVA.EQ.0) GOTO 9999                        PREDIC   1082
      DO 1730 I=1,NLOD                                                  PREDIC   1083
         K=NLDOLD(I)                                                    PREDIC   1084
         CWS1=VOLT(K)                                                   PREDIC   1085
         VMG=SQRT(VREAL*VREAL+VIMAG*VIMAG)                              PREDIC   1086
         IF (VMG.GT.VTHZH) THEN                                         PREDIC   1087
            NLCOMP(2,I)=0                                               PREDIC   1088
         ELSE                                                           PREDIC   1089
            NLCOMP(2,I)=1                                               PREDIC   1090
         END IF                                                         PREDIC   1091
 1730 CONTINUE                                                          PREDIC   1092
C                                                                       PREDIC   1093
 9999 CONTINUE                                                          PREDIC   1094
C                                                                       PREDIC   1095
      RETURN                                                            PREDIC   1096
      END                                                               PREDIC   1097
