CFPRIME LSHMON                                                          LSHMON      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 LSHMON(IDISW,H)                                        LSHMON      3
CD                                                                      LSHMON      4
CD    TO CHECK UFVD LOAD SHEDDING AND LOAD RESTORATION SCHEME DURING    LSHMON      5
CD    THE TIME SIMULATION.                                              LSHMON      6
CD                                                                      LSHMON      7
CD    INPUT OF THE ROUTINE ARE:                                         LSHMON      8
CD                                                                      LSHMON      9
CD    1. IDISW : A LOGICAL DISCONTINUNITY INDICATOR                     LSHMON     10
CD    2. H     : SIZE OF INTEGRATION STEP                               LSHMON     11
CD                                                                      LSHMON     12
CD                                                                      LSHMON     13
CD     LUFVDB           Starting position of IDATPT array for UFVD      LSHMON     14
CD                      relay scheme LUFVDB is in the common            LSHMON     15
CD                      labelled pt of include file CNPT.               LSHMON     16
CD                                                                      LSHMON     17
CD     NUFVDB           Finishing position of IDATPT array for UFVD     LSHMON     18
CD                      relay scheme LUFVDB is in the common            LSHMON     19
CD                      labelled pt of include file CNPT.               LSHMON     20
CD                                                                      LSHMON     21
CD     let k = k-th UFVD RELAY                                          LSHMON     22
CD                                                                      LSHMON     23
CD     N = IDATPT(k)    IDATPT is the array that stores the start       LSHMON     24
CD                      position of the K-TH UFVD relay scheme data     LSHMON     25
CD                                                                      LSHMON     26
CD                                                                      LSHMON     27
CD     IADATA(N+1)      No. of load shedding scheme the relay has       LSHMON     28
CD                                                                      LSHMON     29
CD     IADATA(N+2)      Bus number where the I_th load shed spec.       LSHMON     30
CD                      applies.                                        LSHMON     31
CD                                                                      LSHMON     32
CD      ADATA(N+3)      Magnitude of initial voltage                    LSHMON     33
CD                                                                      LSHMON     34
CD      ADATA(N+4)      Magnitude of previous voltage                   LSHMON     35
CD                                                                      LSHMON     36
CD      ADATA(N+5)      Angle of previous voltage                       LSHMON     37
CD                                                                      LSHMON     38
CD      ADATA(N+6)      Frequency deviation of previous step            LSHMON     39
CD                                                                      LSHMON     40
CD     IADATA(N+7)      Relay trip flag  = 0  local and remote          LSHMON     41
CD                                       = 1  remote only               LSHMON     42
CD                                                                      LSHMON     43
CD     IADATA(N+8)      Remote relay trip flag.                         LSHMON     44
CD                        -1 : all remote relay tripped.                LSHMON     45
CD                                                                      LSHMON     46
CD     IADATA(N+9)      No.of relays controlled by the local relay.     LSHMON     47
CD                                                                      LSHMON     48
CD RS* ADATA(NS+1)      =1 for under voltage shedding                   LSHMON     49
CD                      =2 for voltage deviation                        LSHMON     50
CD                      =3 for under frequency,in the I-th load shed    LSHMON     51
CD                         spec.                                        LSHMON     52
CD                                                                      LSHMON     53
CD RS  ADATA(NS+2)      = Number of shedding levels in the I-th load    LSHMON     54
CD                        shed spec.                                    LSHMON     55
CD                                                                      LSHMON     56
CD RS  ADATA(NS+3)      =0 no shunt load is to be dropped               LSHMON     57
CD                      =1 shunt load is to be dropped in the I-th      LSHMON     58
CD                         load spec.                                   LSHMON     59
CD                                                                      LSHMON     60
CD RS  ADATA(NS+4)      Amount of PU shunt reactive load to be          LSHMON     61
CD                      dropped for the I-th load spec                  LSHMON     62
CD                                                                      LSHMON     63
CD                                                                      LSHMON     64
CD RL* ADATA(NL+1)      PU voltage deviation for load tripping or       LSHMON     65
CD                      PU voltage for load tripping or                 LSHMON     66
CD                      PU frequency for load tripping thresholds       LSHMON     67
CD                      (expressed in rads/cyc below base freq)         LSHMON     68
CD                      in the I-th shedding level for the J-th         LSHMON     69
CD                      load spec.                                      LSHMON     70
CD                                                                      LSHMON     71
CD RL  ADATA(NL+2)      Relay timer setting in cycles, the length of    LSHMON     72
CD                      time that frequency or voltage must remain      LSHMON     73
CD                      below the threshold before a trip signal is     LSHMON     74
CD                      sent to the PCB, in the I-th shedding level     LSHMON     75
CD                      for the J-th load spec.                         LSHMON     76
CD                                                                      LSHMON     77
CD RL  ADATA(NL+3)      Circuit breaker trip time (cycles) in the I-th  LSHMON     78
CD                      shedding level for the J-th load spec.          LSHMON     79
CD                                                                      LSHMON     80
CD                                                                      LSHMON     81
CD RL  ADATA(NL+4)      Fraction of load to be shed in the I_th         LSHMON     82
CD                      shedding level for the J_th load spec.          LSHMON     83
CD                                                                      LSHMON     84
CD RL  IADATA(NL+5)     Switching status of the I-th shedding level     LSHMON     85
CD                      for the J-th load spec:                         LSHMON     86
CD                      =0 If threshold not reached                     LSHMON     87
CD                      =1 IF threshold relay timer running but not     LSHMON     88
CD                         timed out                                    LSHMON     89
CD                      =2 If relay timed out but PCB delay not         LSHMON     90
CD                         complete. Remote relay timer started(based   LSHMON     91
CD                         on level 1 trip signal)                      LSHMON     92
CD                      =3 If PCB tripped and load dropped, remote      LSHMON     93
CD                         relay not tripped yet                        LSHMON     94
CD                      =4 load shedded ,all remote relay tripped.      LSHMON     95
CD                                                                      LSHMON     96
CD RL  IADATA(NL+6)     =1 If time remaining before threshold relay     LSHMON     97
CD                         or breaker delay complete for I-th shedding  LSHMON     98
CD                         level of J-th load spec.                     LSHMON     99
CD                                                                      LSHMON    100
CD                                                                      LSHMON    101
CD NOTE:                                                                LSHMON    102
CD                                                                      LSHMON    103
CD      1. RS - REPEAT FOR EACH SCHEME                                  LSHMON    104
CD      2. RL - REPEAT FOR EACH LEVEL                                   LSHMON    105
CD                                                                      LSHMON    106
CD                                                                      LSHMON    107
C                                                                       LSHMON    108
      INCLUDE 'PARX.INS'                                                LSHMON    109
      INCLUDE 'CNPT.INS'                                                LSHMON    110
      INCLUDE 'CNNNEW.INS'                                              LSHMON    111
      INCLUDE 'CNAUTO.INS'                                              LSHMON    112
      INCLUDE 'CNVOLT.INS'                                              LSHMON    113
      INCLUDE 'CNB4.INS'                                                LSHMON    114
      INCLUDE 'CNB19.INS'                                               LSHMON    115
      INCLUDE 'CNFLAG.INS'                                              LSHMON    116
      INCLUDE 'CNUNIT.INS'                                              LSHMON    117
      INCLUDE 'CNNBLD.INS'                                              LSHMON    118
C                                                                       LSHMON    119
      COMPLEX VOLTK                                                     LSHMON    120
C                                                                       LSHMON    121
      DIMENSION VOLTM(2)                                                LSHMON    122
      EQUIVALENCE (VOLTK,VOLTM(1))                                      LSHMON    123
      EQUIVALENCE (IVREAL,VREAL,VOLTM(1)),(IVIMAG,VIMAG,VOLTM(2))       LSHMON    124
C                                                                       LSHMON    125
      LOGICAL IDISW                                                     LSHMON    126
      CHARACTER*1 JTYPE(6)                                              LSHMON    127
      DATA JTYPE/'F','V','D','1','2','3' /                              LSHMON    128
C                                                                       LSHMON    129
      LDEB=.FALSE.                                                      LSHMON    130
C                                                                       LSHMON    131
      DO 1200 I=LUFVDB,NUFVDB                                           LSHMON    132
      KBUS=IDATPT(I)-1                                                  LSHMON    133
      IF(IADATA(KBUS+8).GT.9)GOTO 1200                                  LSHMON    134
      NSCHEM=IADATA(KBUS+1)                                             LSHMON    135
      NPROG=IADATA(KBUS+2)                                              LSHMON    136
C                                                                       LSHMON    137
      IFLAG=IADATA(KBUS+7)                                              LSHMON    138
      IDRRR=IADATA(KBUS+9)                                              LSHMON    139
C                                                                       LSHMON    140
      VOLTK=VOLT(NPROG)                                                 LSHMON    141
      VMGNEW=CABS(VOLTK)                                                LSHMON    142
      IF(VREAL.EQ.0.0)VREAL=0.00001                                     LSHMON    143
      ANGNEW=ATAN2(VIMAG,VREAL)                                         LSHMON    144
C                                                                       LSHMON    145
C   BYPASS BUS FREQ CALCULATIONS WHEN COMING OUT OF DISCONTINUITY       LSHMON    146
C                                                                       LSHMON    147
      IF(IDISW)THEN                                                     LSHMON    148
      ADATA(KBUS+5)=ANGNEW                                              LSHMON    149
      GOTO 1200                                                         LSHMON    150
      ENDIF                                                             LSHMON    151
C                                                                       LSHMON    152
      DELAN=ANGNEW-ADATA(KBUS+5)                                        LSHMON    153
      ADATA(KBUS+5)=ANGNEW                                              LSHMON    154
      IF(DELAN.LT.-3.14159)DELAN=DELAN+6.28318                          LSHMON    155
      IF(DELAN.GT.3.14159)DELAN=DELAN-6.28318                           LSHMON    156
C                                                                       LSHMON    157
      K=KBUS+9                                                          LSHMON    158
      DO 1100 J=1,NSCHEM                                                LSHMON    159
      ITYPE=IADATA(K+1)                                                 LSHMON    160
      LEVELS=IADATA(K+2)                                                LSHMON    161
      KP=K                                                              LSHMON    162
      K=K+4                                                             LSHMON    163
C                                                                       LSHMON    164
C   POINTER LEVEL 1 RELAY STATUS                                        LSHMON    165
C   USE TO DETERMINE TRIP REMOTE RELAY                                  LSHMON    166
C                                                                       LSHMON    167
      LEVEL1=K+5                                                        LSHMON    168
C                                                                       LSHMON    169
      DO 1000 L=1,LEVELS                                                LSHMON    170
C                                                                       LSHMON    171
      K=K+6                                                             LSHMON    172
C                                                                       LSHMON    173
      ISHDCD=IADATA(K-1)                                                LSHMON    174
C                                                                       LSHMON    175
      IF(ISHDCD.GE.4)GOTO 1000                                          LSHMON    176
      IF(ISHDCD.EQ.3.OR.ISHDCD.EQ.2)THEN                                LSHMON    177
        IF(ITYPE.LE.3)THEN                                              LSHMON    178
         GOTO 480                                                       LSHMON    179
        ELSE                                                            LSHMON    180
         GOTO 500                                                       LSHMON    181
        ENDIF                                                           LSHMON    182
      ENDIF                                                             LSHMON    183
C                                                                       LSHMON    184
      GOTO(440,400,420,440,440,440),ITYPE                               LSHMON    185
C                                                                       LSHMON    186
C  UNDER VOLTAGE LOAD SHEDDING LOGIC                                    LSHMON    187
C                                                                       LSHMON    188
  400 CONTINUE                                                          LSHMON    189
C                                                                       LSHMON    190
      VOLTX=ADATA(K-5)                                                  LSHMON    191
C                                                                       LSHMON    192
C        CHECK IF VOLTAGE ABOVE THRESHOLD                               LSHMON    193
C                                                                       LSHMON    194
         IF(VMGNEW.GE.VOLTX)THEN                                        LSHMON    195
         IADATA(K-1)=0                                                  LSHMON    196
         IADATA(K)=0                                                    LSHMON    197
         GOTO 1000                                                      LSHMON    198
         ENDIF                                                          LSHMON    199
C                                                                       LSHMON    200
C   VOLTAGE DIFFERENCE BELOW THRESHOLD                                  LSHMON    201
C        CHECK IF BELOW THRESHOLD FIRST TIME                            LSHMON    202
C                                                                       LSHMON    203
         IF(IADATA(K-1).EQ.0)THEN                                       LSHMON    204
         ADATA(K)=TS+ADATA(K-4)                                         LSHMON    205
         IADATA(K-1)=1                                                  LSHMON    206
         ENDIF                                                          LSHMON    207
C                                                                       LSHMON    208
C        ELSE BELOW THRESHOLD                                           LSHMON    209
C                                                                       LSHMON    210
         IF(IADATA(K-1).EQ.1)THEN                                       LSHMON    211
C                                                                       LSHMON    212
C           CHECK IF THRESHOLD TIMED OUT START PCB TIMER                LSHMON    213
C                                                                       LSHMON    214
            IF(ADATA(K).LE.TS)THEN                                      LSHMON    215
            IADATA(K-1)=2                                               LSHMON    216
            ADATA(K)=TS+ADATA(K-3)                                      LSHMON    217
            GOTO 480                                                    LSHMON    218
            ENDIF                                                       LSHMON    219
C                                                                       LSHMON    220
C           THRESHOLD NOT TIMED OUT                                     LSHMON    221
C                                                                       LSHMON    222
            GOTO 1000                                                   LSHMON    223
C                                                                       LSHMON    224
         ENDIF                                                          LSHMON    225
C                                                                       LSHMON    226
C     VOLTAGE DEVIATION SCHEME                                          LSHMON    227
C                                                                       LSHMON    228
  420 CONTINUE                                                          LSHMON    229
C                                                                       LSHMON    230
      DELVLT=ADATA(K-5)                                                 LSHMON    231
      DBVLT=ADATA(KBUS+3)-VMGNEW                                        LSHMON    232
C                                                                       LSHMON    233
C     CHECK IF VOLTAGE DIFFERENCE ABOVE THRESHOLD                       LSHMON    234
C                                                                       LSHMON    235
      IF(DBVLT.LT.DELVLT)THEN                                           LSHMON    236
      IADATA(K-1)=0                                                     LSHMON    237
      IADATA(K)=0                                                       LSHMON    238
      GOTO 1000                                                         LSHMON    239
      ENDIF                                                             LSHMON    240
C                                                                       LSHMON    241
C     ELSE VOLTAGE DIFFERENCE BELOW THRESHOLD                           LSHMON    242
C                                                                       LSHMON    243
      IF(IADATA(K-1).EQ.0)THEN                                          LSHMON    244
C                                                                       LSHMON    245
C     BELOW THRESHOLD THE FIRST TIME                                    LSHMON    246
C                                                                       LSHMON    247
      ADATA(K)=TS+ADATA(K-4)                                            LSHMON    248
      IADATA(K-1)=1                                                     LSHMON    249
      ENDIF                                                             LSHMON    250
C                                                                       LSHMON    251
      IF(IADATA(K-1).EQ.1)THEN                                          LSHMON    252
C                                                                       LSHMON    253
C        THRESHOLD TIMED OUT START PCB TIMER                            LSHMON    254
C                                                                       LSHMON    255
         IF(ADATA(K).LE.TS)THEN                                         LSHMON    256
         IADATA(K-1)=2                                                  LSHMON    257
         ADATA(K)=TS+ADATA(K-3)                                         LSHMON    258
         GOTO 480                                                       LSHMON    259
         ENDIF                                                          LSHMON    260
C                                                                       LSHMON    261
C        THRESHOLD NOT TIMED OUT                                        LSHMON    262
C                                                                       LSHMON    263
         GOTO 1000                                                      LSHMON    264
C                                                                       LSHMON    265
       ENDIF                                                            LSHMON    266
C                                                                       LSHMON    267
C  UNDERFREQUENCY LOAD SHED LOGIC                                       LSHMON    268
C                                                                       LSHMON    269
 440  CONTINUE                                                          LSHMON    270
C                                                                       LSHMON    271
C                                                                       LSHMON    272
      IF(ITYPE .GT. 3)GOTO 500                                          LSHMON    273
C                                                                       LSHMON    274
C   UNDER FREQUENCY LOAD SHEDDING LOGIC                                 LSHMON    275
C                                                                       LSHMON    276
C                                                                       LSHMON    277
C    DELTA FREQUENCY IN HZ.                                             LSHMON    278
C                                                                       LSHMON    279
      DFREQ=FQBASE-ADATA(K-5)                                           LSHMON    280
      DEFNEW=-DELAN/(H*6.2831853)                                       LSHMON    281
      ADATA(KBUS+6)=DEFNEW                                              LSHMON    282
C                                                                       LSHMON    283
C  FREQUENCY ABOVE THRESHOLD                                            LSHMON    284
C                                                                       LSHMON    285
         IF(DEFNEW.LT.DFREQ)THEN                                        LSHMON    286
         IADATA(K-1)=0                                                  LSHMON    287
         IADATA(K)=0                                                    LSHMON    288
         GOTO 1000                                                      LSHMON    289
         ENDIF                                                          LSHMON    290
C                                                                       LSHMON    291
C     CHECK IF FREQUENCY HAS BEEN BELOW THRESHOLD                       LSHMON    292
C                                                                       LSHMON    293
         IF(IADATA(K-1).EQ.0)THEN                                       LSHMON    294
C                                                                       LSHMON    295
C        BELOW THRESHOLD THE FIRST TIME                                 LSHMON    296
C                                                                       LSHMON    297
         ADATA(K)=TS+ADATA(K-4)                                         LSHMON    298
         IADATA(K-1)=1                                                  LSHMON    299
         ENDIF                                                          LSHMON    300
C                                                                       LSHMON    301
      IF(ADATA(K-1).EQ.1)THEN                                           LSHMON    302
C                                                                       LSHMON    303
            IF(ADATA(K).LE.TS)THEN                                      LSHMON    304
C                                                                       LSHMON    305
C           THRESHOLD TIMED OUT START PCB TIMER                         LSHMON    306
C                                                                       LSHMON    307
            IADATA(K-1)=2                                               LSHMON    308
            ADATA(K)=TS+ADATA(K-3)                                      LSHMON    309
            GOTO 480                                                    LSHMON    310
            ENDIF                                                       LSHMON    311
C                                                                       LSHMON    312
C          THRESHOLD NOT TIMED OUT                                      LSHMON    313
C                                                                       LSHMON    314
           GOTO 1000                                                    LSHMON    315
C                                                                       LSHMON    316
      ENDIF                                                             LSHMON    317
C                                                                       LSHMON    318
  480 CONTINUE                                                          LSHMON    319
C                                                                       LSHMON    320
C   IFLAG =0 TRIP BOTH LOCAL AND REMOTE RELAYS                          LSHMON    321
C         =1 TRIP REMOTE RELAY ONLY                                     LSHMON    322
C                                                                       LSHMON    323
       IF(IFLAG .EQ. 1)GOTO 1000                                        LSHMON    324
C                                                                       LSHMON    325
C                                                                       LSHMON    326
      IF(ADATA(K).GT.TS)GOTO 1000                                       LSHMON    327
C                                                                       LSHMON    328
C      SHED LOAD                                                        LSHMON    329
C                                                                       LSHMON    330
       IADATA(K-1)=4                                                    LSHMON    331
       PUSHED=ADATA(K-2)                                                LSHMON    332
       QUSHED=PUSHED                                                    LSHMON    333
       ISOPT=IADATA(KP+3)                                               LSHMON    334
C                                                                       LSHMON    335
C                                                                       LSHMON    336
C    UPDATE THE LOAD SHEDDING STATUS                                    LSHMON    337
C                                                                       LSHMON    338
        KL=JBLD(NPROG)                                                  LSHMON    339
       IF(ITYPE.EQ.1)THEN                                               LSHMON    340
        ISUM(KL)=1                                                      LSHMON    341
       ENDIF                                                            LSHMON    342
C                                                                       LSHMON    343
C                                                                       LSHMON    344
        KKL=KL*12                                                       LSHMON    345
        PMX=BLD(KKL-9)                                                  LSHMON    346
        QMX=BLD(KKL-8)                                                  LSHMON    347
        PREST=PMX*PUSHED/100.                                           LSHMON    348
        QREST=QMX*QUSHED/100.                                           LSHMON    349
        REMP=PMX-BLD(KKL-5)                                             LSHMON    350
C                                                                       LSHMON    351
C    CHECK  THE LOAD SHED TABLE BEFORE RESTORE LOAD                     LSHMON    352
C                                                                       LSHMON    353
        IF(PREST.GT.REMP)THEN                                           LSHMON    354
         PUSHED=(100.*REMP )/PMX                                        LSHMON    355
         QUSHED=PUSHED                                                  LSHMON    356
        ENDIF                                                           LSHMON    357
C                                                                       LSHMON    358
C      WRITE LOAD SHEDDING DATA TO ISWFA FILE                           LSHMON    359
C                                                                       LSHMON    360
       IF(IASWX.EQ.0)THEN                                               LSHMON    361
       WRITE(ISWFA,2010) TS                                             LSHMON    362
       NAWR=NAWR+1                                                      LSHMON    363
       IASWX=1                                                          LSHMON    364
       ENDIF                                                            LSHMON    365
       WRITE(ISWFA,2020) JTYPE(ITYPE),NPROG,ISOPT,PUSHED,QUSHED         LSHMON    366
       NAWR=NAWR+1                                                      LSHMON    367
C                                                                       LSHMON    368
       GOTO 1000                                                        LSHMON    369
C                                                                       LSHMON    370
C  IF THIS IS UNDER FREQ LOAD SHEDDING, CALL SUMUFL TO UPDATE           LSHMON    371
C  UNDERFREQ LOAD SHEDDING SUMMARY TABLES.                              LSHMON    372
C                                                                       LSHMON    373
C      IF(ITYPE.EQ.3)THEN                                               LSHMON    374
C         FRQ=FQBASE-ADATA(K-5)                                         LSHMON    375
C         PDRP=PDROP                                                    LSHMON    376
C         CALL SUMUFL(KBUS,PDRP,FRQ,TS)                                 LSHMON    377
C      ENDIF                                                            LSHMON    378
C                                                                       LSHMON    379
 500   CONTINUE                                                         LSHMON    380
C                                                                       LSHMON    381
C   LOAD RESTORATION LOGIC                                              LSHMON    382
C                                                                       LSHMON    383
        KL=JBLD(NPROG)                                                  LSHMON    384
C                                                                       LSHMON    385
C   CHECK IF THE LOAD AT THIS BUS HAS BEEN SHEDDED PREVIOUSLY           LSHMON    386
C                                                                       LSHMON    387
        IF(ISUM(KL).EQ.0)GOTO 1000                                      LSHMON    388
C                                                                       LSHMON    389
C    DELTA FREQUENCY IN HZ.                                             LSHMON    390
C                                                                       LSHMON    391
      FREQ=ADATA(K-5)                                                   LSHMON    392
      FNEW=DELAN/(H*6.2831853)+FQBASE                                   LSHMON    393
      ADATA(KBUS+6)=FNEW                                                LSHMON    394
C                                                                       LSHMON    395
      IF(ISHDCD.EQ.2)GO TO 580                                          LSHMON    396
C                                                                       LSHMON    397
C  FREQUENCY BELOW THRESHOLD                                            LSHMON    398
C                                                                       LSHMON    399
         IF(FNEW.LE.FREQ)THEN                                           LSHMON    400
         IADATA(K-1)=0                                                  LSHMON    401
         IADATA(K)=0                                                    LSHMON    402
         GOTO 1000                                                      LSHMON    403
         ENDIF                                                          LSHMON    404
C                                                                       LSHMON    405
      IOPT=ITYPE-3                                                      LSHMON    406
      IF(IOPT.LT.1)GOTO 1000                                            LSHMON    407
C                                                                       LSHMON    408
C      FOR OPTION 1                                                     LSHMON    409
C                                                                       LSHMON    410
      IF(IOPT.EQ.1)THEN                                                 LSHMON    411
       IF(IADATA(K).EQ.0)THEN                                           LSHMON    412
        IADATA(K-1)=2                                                   LSHMON    413
        ADATA(K)=TS+ADATA(K-3)                                          LSHMON    414
       ELSE                                                             LSHMON    415
        GOTO 580                                                        LSHMON    416
       ENDIF                                                            LSHMON    417
      ENDIF                                                             LSHMON    418
C                                                                       LSHMON    419
C      FOR OPTION 3                                                     LSHMON    420
C                                                                       LSHMON    421
      IF(IOPT.EQ.3)THEN                                                 LSHMON    422
       ADATA(K)=ADATA(K)+H                                              LSHMON    423
       IF(ADATA(K).GT.ADATA(K-4))THEN                                   LSHMON    424
        IADATA(K-1)=1                                                   LSHMON    425
        GOTO 510                                                        LSHMON    426
       ELSE                                                             LSHMON    427
        GOTO 1000                                                       LSHMON    428
       ENDIF                                                            LSHMON    429
      ENDIF                                                             LSHMON    430
C                                                                       LSHMON    431
C     CHECK IF FREQUENCY HAS BEEN ABOVE THRESHOLD                       LSHMON    432
C                                                                       LSHMON    433
         IF(IADATA(K-1).EQ.0)THEN                                       LSHMON    434
C                                                                       LSHMON    435
C        ABOVE THRESHOLD THE FIRST TIME                                 LSHMON    436
C                                                                       LSHMON    437
         ADATA(K)=TS+ADATA(K-4)                                         LSHMON    438
         IADATA(K-1)=1                                                  LSHMON    439
         ENDIF                                                          LSHMON    440
C                                                                       LSHMON    441
 510    IF(IADATA(K-1).EQ.1)THEN                                        LSHMON    442
C                                                                       LSHMON    443
            IF(ADATA(K).LE.TS)THEN                                      LSHMON    444
C                                                                       LSHMON    445
C           THRESHOLD TIMED OUT START PCB TIMER                         LSHMON    446
C                                                                       LSHMON    447
            IADATA(K-1)=2                                               LSHMON    448
            ADATA(K)=TS+ADATA(K-3)                                      LSHMON    449
            GOTO 580                                                    LSHMON    450
            ENDIF                                                       LSHMON    451
C                                                                       LSHMON    452
C          THRESHOLD NOT TIMED OUT                                      LSHMON    453
C                                                                       LSHMON    454
           GOTO 1000                                                    LSHMON    455
C                                                                       LSHMON    456
      ENDIF                                                             LSHMON    457
C                                                                       LSHMON    458
  580 CONTINUE                                                          LSHMON    459
C                                                                       LSHMON    460
      IF(ADATA(K).GT.TS)GOTO 1000                                       LSHMON    461
C                                                                       LSHMON    462
C      LOAD RESTORATION                                                 LSHMON    463
C                                                                       LSHMON    464
       IADATA(K-1)=4                                                    LSHMON    465
       PUSHED=ADATA(K-2)                                                LSHMON    466
       QUSHED=PUSHED                                                    LSHMON    467
C                                                                       LSHMON    468
        KKL=KL*12                                                       LSHMON    469
        PMX=BLD(KKL-9)                                                  LSHMON    470
        QMX=BLD(KKL-8)                                                  LSHMON    471
        PREST=PMX*PUSHED/100.                                           LSHMON    472
        QREST=QMX*QUSHED/100.                                           LSHMON    473
C                                                                       LSHMON    474
C    CHECK  THE LOAD SHED TABLE BEFORE RESTORE LOAD                     LSHMON    475
C                                                                       LSHMON    476
        IF(PREST.GT.BLD(KKL-5))THEN                                     LSHMON    477
         PUSHED=(100.*BLD(KKL-5) )/PMX                                  LSHMON    478
         QUSHED=(100.*BLD(KKL-4) )/QMX                                  LSHMON    479
        ENDIF                                                           LSHMON    480
C                                                                       LSHMON    481
       ISOPT=IADATA(KP+3)                                               LSHMON    482
C                                                                       LSHMON    483
C      WRITE LOAD RESTORATION DATA TO ISWFA FILE                        LSHMON    484
C                                                                       LSHMON    485
       IF(IASWX.EQ.0)THEN                                               LSHMON    486
       WRITE(ISWFA,2010) TS                                             LSHMON    487
       NAWR=NAWR+1                                                      LSHMON    488
       IASWX=1                                                          LSHMON    489
       ENDIF                                                            LSHMON    490
       WRITE(ISWFA,2030)NPROG,ISOPT,PUSHED,QUSHED                       LSHMON    491
       NAWR=NAWR+1                                                      LSHMON    492
C                                                                       LSHMON    493
C                                                                       LSHMON    494
 1000  CONTINUE                                                         LSHMON    495
C                                                                       LSHMON    496
      IF(ITYPE.LE.3)THEN                                                LSHMON    497
C                                                                       LSHMON    498
      KOLD=K                                                            LSHMON    499
C                                                                       LSHMON    500
C            REMOTE RELAY ACTIVIATED, NOT ALL TRIPPED                   LSHMON    501
C                                                                       LSHMON    502
      IF(IDRRR.NE.0)THEN                                                LSHMON    503
          IF(IADATA(LEVEL1).EQ.2)THEN                                   LSHMON    504
           CALL RTIMER(K,IDRRR)                                         LSHMON    505
           IADATA(LEVEL1)=3                                             LSHMON    506
           IF(IFLAG.EQ.1)IADATA(LEVEL1)=4                               LSHMON    507
          ENDIF                                                         LSHMON    508
C                                                                       LSHMON    509
        IF(IADATA(LEVEL1).EQ.3 .OR. IADATA(LEVEL1).EQ.4)THEN            LSHMON    510
         K=KOLD                                                         LSHMON    511
         IPOINT=8                                                       LSHMON    512
         CALL RETRIP(K,KBUS,IDRRR,IPOINT)                               LSHMON    513
         IF(IADATA(KBUS+IPOINT).EQ.-1)IADATA(LEVEL1)=5                  LSHMON    514
        ENDIF                                                           LSHMON    515
C                                                                       LSHMON    516
       ENDIF                                                            LSHMON    517
C                                                                       LSHMON    518
      ENDIF                                                             LSHMON    519
C                                                                       LSHMON    520
 1100  CONTINUE                                                         LSHMON    521
C                                                                       LSHMON    522
 1200  CONTINUE                                                         LSHMON    523
C                                                                       LSHMON    524
      RETURN                                                            LSHMON    525
C                                                                       LSHMON    526
 2010 FORMAT(F10.5)                                                     LSHMON    527
 2020 FORMAT('SLD',A1,2I5,2F10.4)                                       LSHMON    528
 2030 FORMAT('RLDA',2I5,2F10.4)                                         LSHMON    529
C                                                                       LSHMON    530
      END                                                               LSHMON    531
