CFPRIME LSHDAT                                                          LSHDAT      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 LSHDAT(IEBK)                                           LSHDAT      3
CD                                                                      LSHDAT      4
CD    TO READ UFVD LOAD SHEDDING AND LOAD RESTORATION RELAY DATA.       LSHDAT      5
CD                                                                      LSHDAT      6
CD     LUFVDB           Starting position of IDATPT array for UFVD      LSHDAT      7
CD                      relay scheme LUFVDB is in the common            LSHDAT      8
CD                      labelled pt of include file CNPT.               LSHDAT      9
CD                                                                      LSHDAT     10
CD     NUFVDB           Finishing position of IDATPT array for UFVD     LSHDAT     11
CD                      relay scheme LUFVDB is in the common            LSHDAT     12
CD                      labelled pt of include file CNPT.               LSHDAT     13
CD                                                                      LSHDAT     14
CD     let k = k-th UFVD RELAY                                          LSHDAT     15
CD                                                                      LSHDAT     16
CD     N = IDATPT(k)-1  IDATPT is the array that stores the start       LSHDAT     17
CD                      position of the K-TH UFVD relay scheme data     LSHDAT     18
CD                                                                      LSHDAT     19
CD                                                                      LSHDAT     20
CD     IADATA(N+1)      No. of load shedding scheme the relay has       LSHDAT     21
CD                                                                      LSHDAT     22
CD     IADATA(N+2)      Bus number where the I_th load shed spec.       LSHDAT     23
CD                      applies.                                        LSHDAT     24
CD                                                                      LSHDAT     25
CD      ADATA(N+3)      Magnitude of initial voltage                    LSHDAT     26
CD                                                                      LSHDAT     27
CD      ADATA(N+4)      Magnitude of previous voltage                   LSHDAT     28
CD                                                                      LSHDAT     29
CD      ADATA(N+5)      Angle of previous voltage                       LSHDAT     30
CD                                                                      LSHDAT     31
CD      ADATA(N+6)      Frequency deviation of previous step            LSHDAT     32
CD                                                                      LSHDAT     33
CD     IADATA(N+7)      Relay trip flag  = 0  local and remote          LSHDAT     34
CD                                       = 1  remote only               LSHDAT     35
CD                                                                      LSHDAT     36
CD     IADATA(N+8)      Remote relay trip flag.                         LSHDAT     37
CD                        -1 : all remote relay tripped.                LSHDAT     38
CD                                                                      LSHDAT     39
CD     IADATA(N+9)      No.of relays controlled by the local relay.     LSHDAT     40
CD                                                                      LSHDAT     41
CD RS* ADATA(NS+1)      =1 for under frequency,in the I-th load shed    LSHDAT     42
CD                         spec.                                        LSHDAT     43
CD                      =2 for under voltage shedding                   LSHDAT     44
CD                      =3 for voltage deviation                        LSHDAT     45
CD                                                                      LSHDAT     46
CD RS  ADATA(NS+2)      = Number of shedding levels in the I-th load    LSHDAT     47
CD                        shed spec.                                    LSHDAT     48
CD                                                                      LSHDAT     49
CD RS  ADATA(NS+3)      =0 no shunt load is to be dropped               LSHDAT     50
CD                      =1 shunt load is to be dropped in the I-th      LSHDAT     51
CD                         load spec.                                   LSHDAT     52
CD                                                                      LSHDAT     53
CD RS  ADATA(NS+4)      Amount of PU shunt reactive load to be          LSHDAT     54
CD                      dropped for the I-th load spec                  LSHDAT     55
CD                                                                      LSHDAT     56
CD                                                                      LSHDAT     57
CD RL* ADATA(NL+1)      PU voltage deviation for load tripping or       LSHDAT     58
CD                      PU voltage for load tripping or                 LSHDAT     59
CD                      PU frequency for load tripping thresholds       LSHDAT     60
CD                      (expressed in rads/cyc below base freq)         LSHDAT     61
CD                      in the I-th shedding level for the J-th         LSHDAT     62
CD                      load spec.                                      LSHDAT     63
CD                                                                      LSHDAT     64
CD RL  ADATA(NL+2)      Relay timer setting in cycles, the length of    LSHDAT     65
CD                      time that frequency or voltage must remain      LSHDAT     66
CD                      below the threshold before a trip signal is     LSHDAT     67
CD                      sent to the PCB, in the I-th shedding level     LSHDAT     68
CD                      for the J-th load spec.                         LSHDAT     69
CD                                                                      LSHDAT     70
CD RL  ADATA(NL+3)      Circuit breaker trip time (cycles) in the I-th  LSHDAT     71
CD                      shedding level for the J-th load spec.          LSHDAT     72
CD                                                                      LSHDAT     73
CD                                                                      LSHDAT     74
CD RL  ADATA(NL+4)      Fraction of load to be shed in the I_th         LSHDAT     75
CD                      shedding level for the J_th load spec.          LSHDAT     76
CD                                                                      LSHDAT     77
CD RL  IADATA(NL+5)     Switching status of the I-th shedding level     LSHDAT     78
CD                      for the J-th load spec:                         LSHDAT     79
CD                      =0 If threshold not reached                     LSHDAT     80
CD                      =1 IF threshold relay timer running but not     LSHDAT     81
CD                         timed out                                    LSHDAT     82
CD                      =2 If relay timed out but PCB delay not         LSHDAT     83
CD                         complete. Remote relay timer started(based   LSHDAT     84
CD                         on level 1 trip signal)                      LSHDAT     85
CD                      =3 If PCB tripped and load dropped, remote      LSHDAT     86
CD                         relay not tripped yet                        LSHDAT     87
CD                      =4 load shedded ,all remote relay tripped.      LSHDAT     88
CD                                                                      LSHDAT     89
CD RL  IADATA(NL+6)     =1 If time remaining before threshold relay     LSHDAT     90
CD                         or breaker delay complete for I-th shedding  LSHDAT     91
CD                         level of J-th load spec.                     LSHDAT     92
CD                                                                      LSHDAT     93
CD                                                                      LSHDAT     94
CD NOTE:                                                                LSHDAT     95
CD                                                                      LSHDAT     96
CD      1. RS - REPEAT FOR EACH SCHEME                                  LSHDAT     97
CD      2. RL - REPEAT FOR EACH LEVEL                                   LSHDAT     98
CD                                                                      LSHDAT     99
CD                                                                      LSHDAT    100
C                                                                       LSHDAT    101
      INCLUDE 'PARX.INS'                                                LSHDAT    102
      INCLUDE 'CNPT.INS'                                                LSHDAT    103
      INCLUDE 'CNIPTR.INS'                                              LSHDAT    104
      INCLUDE 'CNMNEW.INS'                                              LSHDAT    105
      INCLUDE 'CNAUTO.INS'                                              LSHDAT    106
      INCLUDE 'CNLFDA.INS'                                              LSHDAT    107
      INCLUDE 'CNB19.INS'                                               LSHDAT    108
      INCLUDE 'CNFLAG.INS'                                              LSHDAT    109
      INCLUDE 'CNPARX.INS'                                              LSHDAT    110
      INCLUDE 'CNREN.INS'                                               LSHDAT    111
      INCLUDE 'CNUNIT.INS'                                              LSHDAT    112
      INCLUDE 'CNMSG.INS'                                               LSHDAT    113
C                                                                       LSHDAT    114
*IF -MI2                                                                LSHDAT    115
      INTEGER*2 IFSLSD,INXLSD,ILSREC                                    LSHDAT    116
*ENDIF                                                                  LSHDAT    117
      COMMON/SCRAT4/IFSLSD(NB),INXLSD(MAXSET),ILSREC(MAXSET)            LSHDAT    118
      CHARACTER*32 FILNAM                                               LSHDAT    119
      CHARACTER*80 CARD,CARD1,CARD3                                     LSHDAT    120
      CHARACTER*1 NTYPE,CTYPE(6)                                        LSHDAT    121
      CHARACTER*4 CTDATA(32),CDATA(20),CDATA1(20)                       LSHDAT    122
      CHARACTER*12 BUSNAM,CAREA,CZONE                                   LSHDAT    123
      CHARACTER*5 EDATA                                                 LSHDAT    124
      CHARACTER*3 ESC,MPI                                               LSHDAT    125
      LOGICAL JAUTB                                                     LSHDAT    126
      DIMENSION TDATA(32),ITDATA(32)                                    LSHDAT    127
      EQUIVALENCE (CARD1,CDATA(1)),(CARD3,CDATA1(1))                    LSHDAT    128
      EQUIVALENCE (TDATA(1),ITDATA(1),CTDATA(1))                        LSHDAT    129
      DATA EDATA/'EDATA'/,ESC/'ESC'/,MPI/'MPI'/                         LSHDAT    130
      DATA CTYPE/'F','V','D','1','2','3'/                               LSHDAT    131
C                                                                       LSHDAT    132
      LDEB=(JDEB(12).NE.0)                                              LSHDAT    133
C                                                                       LSHDAT    134
      LASTBU=0                                                          LSHDAT    135
      JREC=0                                                            LSHDAT    136
      NTLSD=0                                                           LSHDAT    137
C                                                                       LSHDAT    138
      JLENG=50                                                          LSHDAT    139
      IKEY=4                                                            LSHDAT    140
      CALL OPENRE(IU31,FILNAM,JLENG,IKEY,ISTAT,0)                       LSHDAT    141
C                                                                       LSHDAT    142
      CALL HMOVE(0,IFSLSD,IFSLSD,NB)                                    LSHDAT    143
      CALL HMOVE(0,INXLSD,INXLSD,MAXSET)                                LSHDAT    144
C                                                                       LSHDAT    145
C  READING LOAD SHEDDING DATA                                           LSHDAT    146
C                                                                       LSHDAT    147
  110 CONTINUE                                                          LSHDAT    148
      CALL GETLIN(IU54,CARD)                                            LSHDAT    149
      IF(CARD(1:5).EQ.EDATA)THEN                                        LSHDAT    150
      GOTO 500                                                          LSHDAT    151
      ELSEIF(CARD(1:12).EQ.'AREA        ')THEN                          LSHDAT    152
      CALL GETLIN(IU54,CARD)                                            LSHDAT    153
      IF(KLFO.EQ.0)THEN                                                 LSHDAT    154
      READ(CARD,3090) NAREA,NTYPE,ISOPT,IFLAG                           LSHDAT    155
      ELSE                                                              LSHDAT    156
      READ(CARD,3110) CAREA,NTYPE,ISOPT,IFLAG                           LSHDAT    157
      CALL CHAREA(CAREA,NAREA)                                          LSHDAT    158
      IF(NAREA.EQ.0)THEN                                                LSHDAT    159
      IEBK=2                                                            LSHDAT    160
      WRITE(MSG(1),3130)                                                LSHDAT    161
      MSG(2)=CARD                                                       LSHDAT    162
      CALL PRTMSG(2)                                                    LSHDAT    163
 125  CONTINUE                                                          LSHDAT    164
      CALL GETLIN(IU54,CARD)                                            LSHDAT    165
      IF(CARD(1:3).NE.ESC)GOTO 125                                      LSHDAT    166
      GOTO 110                                                          LSHDAT    167
      ENDIF                                                             LSHDAT    168
      ENDIF                                                             LSHDAT    169
      GOTO 200                                                          LSHDAT    170
      ELSEIF(CARD(1:12).EQ.'ZONE        ')THEN                          LSHDAT    171
      CALL GETLIN(IU54,CARD)                                            LSHDAT    172
      IF(KLFO.EQ.0)THEN                                                 LSHDAT    173
      READ(CARD,3090) NZONE,NTYPE,ISOPT,IFLAG                           LSHDAT    174
      ELSE                                                              LSHDAT    175
      READ(CARD,3110) CZONE,NTYPE,ISOPT,IFLAG                           LSHDAT    176
      CALL CHZONE(CZONE,NZONE)                                          LSHDAT    177
      IF(NZONE.EQ.0)THEN                                                LSHDAT    178
      IEBK=2                                                            LSHDAT    179
      WRITE(MSG(1),3140)                                                LSHDAT    180
      MSG(2)=CARD                                                       LSHDAT    181
      CALL PRTMSG(2)                                                    LSHDAT    182
 215  CONTINUE                                                          LSHDAT    183
      CALL GETLIN(IU54,CARD)                                            LSHDAT    184
      IF(CARD(1:3).NE.ESC)GOTO 215                                      LSHDAT    185
      GOTO 110                                                          LSHDAT    186
      ENDIF                                                             LSHDAT    187
      ENDIF                                                             LSHDAT    188
      GOTO 300                                                          LSHDAT    189
      ELSEIF(CARD(1:12).EQ.'SYSTEM      ')THEN                          LSHDAT    190
      CALL GETLIN(IU54,CARD)                                            LSHDAT    191
      IF(KLFO.EQ.0)THEN                                                 LSHDAT    192
      READ(CARD,3090) NAREA,NTYPE,ISOPT,IFLAG                           LSHDAT    193
      ELSE                                                              LSHDAT    194
      READ(CARD,3110) CAREA,NTYPE,ISOPT,IFLAG                           LSHDAT    195
      ENDIF                                                             LSHDAT    196
      GOTO 400                                                          LSHDAT    197
      ENDIF                                                             LSHDAT    198
      IF(KLFO.EQ.0)THEN                                                 LSHDAT    199
      READ (CARD,3010) NLF,NTYPE,ISOPT,IFLAG                            LSHDAT    200
           IF(MNEW(NLF).EQ.0)THEN                                       LSHDAT    201
           IEBK=1                                                       LSHDAT    202
           MSG(1)=CARD                                                  LSHDAT    203
           CALL PRTMSG(1)                                               LSHDAT    204
 315  CONTINUE                                                          LSHDAT    205
      CALL GETLIN(IU54,CARD)                                            LSHDAT    206
      IF(CARD(1:3).NE.ESC)GOTO 315                                      LSHDAT    207
           GOTO 110                                                     LSHDAT    208
           ELSE                                                         LSHDAT    209
           NPROG=MNEW(NLF)                                              LSHDAT    210
           ENDIF                                                        LSHDAT    211
      ELSE                                                              LSHDAT    212
      READ (CARD,3040) BUSNAM,NTYPE,ISOPT,IFLAG                         LSHDAT    213
      CALL CHKBUS(BUSNAM,NLF)                                           LSHDAT    214
           IF(NLF.EQ.0)THEN                                             LSHDAT    215
           IEBK=1                                                       LSHDAT    216
           MSG(1)=CARD                                                  LSHDAT    217
           CALL PRTMSG(1)                                               LSHDAT    218
 415       CONTINUE                                                     LSHDAT    219
           CALL GETLIN(IU54,CARD)                                       LSHDAT    220
           IF(CARD(1:3).NE.ESC)GOTO 415                                 LSHDAT    221
           GOTO 110                                                     LSHDAT    222
           ELSE                                                         LSHDAT    223
           NPROG=MNEW(NLF)                                              LSHDAT    224
          ENDIF                                                         LSHDAT    225
      ENDIF                                                             LSHDAT    226
C                                                                       LSHDAT    227
      ASSIGN 150 TO I2000                                               LSHDAT    228
      GOTO 2000                                                         LSHDAT    229
C                                                                       LSHDAT    230
C  TOO MANY LOAD SHEDDING BUSES                                         LSHDAT    231
C                                                                       LSHDAT    232
 115  NAUT=NAUT-1                                                       LSHDAT    233
      IEBK=2                                                            LSHDAT    234
      WRITE(MSG(1),3020)MAXSET                                          LSHDAT    235
      MSG(2)=CARD                                                       LSHDAT    236
      CALL PRTMSG(2)                                                    LSHDAT    237
      GOTO 110                                                          LSHDAT    238
C                                                                       LSHDAT    239
 150  CONTINUE                                                          LSHDAT    240
C                                                                       LSHDAT    241
C   STORE DATA TO DA FILE                                               LSHDAT    242
C                                                                       LSHDAT    243
      IF(NPROG.GT.LASTBU)LASTBU=NPROG                                   LSHDAT    244
      JFLAG=0                                                           LSHDAT    245
      ASSIGN 155 TO I2100                                               LSHDAT    246
      GOTO 2100                                                         LSHDAT    247
C                                                                       LSHDAT    248
 155  CONTINUE                                                          LSHDAT    249
C                                                                       LSHDAT    250
      IPTR=NPROG                                                        LSHDAT    251
      CALL LSHDA1(IPTR,JREC,NTLSD,NAUT,JTYPE,JFLAG,TDATA,IERR)          LSHDAT    252
      IF(IERR.NE.0)GOTO 115                                             LSHDAT    253
C                                                                       LSHDAT    254
 165  JREC=JREC1                                                        LSHDAT    255
      GOTO 110                                                          LSHDAT    256
C                                                                       LSHDAT    257
C      SELECT BUS FOR SPECIFIED AREA                                    LSHDAT    258
C                                                                       LSHDAT    259
  200 CONTINUE                                                          LSHDAT    260
C                                                                       LSHDAT    261
      ASSIGN 205 TO I2000                                               LSHDAT    262
      GOTO 2000                                                         LSHDAT    263
 205  CONTINUE                                                          LSHDAT    264
      JFLAG=-2                                                          LSHDAT    265
      ASSIGN 210 TO I2100                                               LSHDAT    266
      GOTO 2100                                                         LSHDAT    267
C                                                                       LSHDAT    268
  210 CONTINUE                                                          LSHDAT    269
C                                                                       LSHDAT    270
C   FLETCH THE BUS                                                      LSHDAT    271
C                                                                       LSHDAT    272
      K=0                                                               LSHDAT    273
      KK=0                                                              LSHDAT    274
      DO 220 I=1,NLFBUS                                                 LSHDAT    275
        K=K+4                                                           LSHDAT    276
        KK=KK+8                                                         LSHDAT    277
        ILK=IBAR(K-1)                                                   LSHDAT    278
        CALL UPACKI(JJJ,JAREA,ILK)                                      LSHDAT    279
        IF(JAREA.EQ.NAREA)THEN                                          LSHDAT    280
          IF((IBAR(K-2).NE.0.OR.IBAR(K-3).NE.0).OR.                     LSHDAT    281
     +       ((ISOPT.EQ.1).AND.                                         LSHDAT    282
     +        (RYGR(KK-3).NE.0.0.OR.RYGR(KK-4).NE.0.0)))THEN            LSHDAT    283
            IF(I.GT.LASTBU)LASTBU=I                                     LSHDAT    284
C                                                                       LSHDAT    285
            IPTR=I                                                      LSHDAT    286
            CALL LSHDA1(IPTR,JREC,NTLSD,NAUT,JTYPE,JFLAG,TDATA,IERR)    LSHDAT    287
            IF(IERR.NE.0)GOTO 115                                       LSHDAT    288
C                                                                       LSHDAT    289
          ENDIF                                                         LSHDAT    290
        ENDIF                                                           LSHDAT    291
 220  CONTINUE                                                          LSHDAT    292
      JREC=JREC1                                                        LSHDAT    293
      GOTO 110                                                          LSHDAT    294
C                                                                       LSHDAT    295
C      SELECT BUS FOR SPECIFIED ZONE                                    LSHDAT    296
C                                                                       LSHDAT    297
 300  CONTINUE                                                          LSHDAT    298
C                                                                       LSHDAT    299
      ASSIGN 305 TO I2000                                               LSHDAT    300
      GOTO 2000                                                         LSHDAT    301
 305  CONTINUE                                                          LSHDAT    302
      JFLAG=-1                                                          LSHDAT    303
      ASSIGN 310 TO I2100                                               LSHDAT    304
      GOTO 2100                                                         LSHDAT    305
C                                                                       LSHDAT    306
 310  CONTINUE                                                          LSHDAT    307
C                                                                       LSHDAT    308
C   FLETCH THE BUS                                                      LSHDAT    309
C                                                                       LSHDAT    310
      K=0                                                               LSHDAT    311
      KK=0                                                              LSHDAT    312
      DO 320 I=1,NLFBUS                                                 LSHDAT    313
        K=K+4                                                           LSHDAT    314
        KK=KK+8                                                         LSHDAT    315
        ILK=IBAR(K-1)                                                   LSHDAT    316
        CALL UPACKI(JZONE,JJJ,ILK)                                      LSHDAT    317
        IF(JZONE.EQ.NZONE)THEN                                          LSHDAT    318
        IF((IBAR(K-2).NE.0.OR.IBAR(K-3).NE.0).OR.                       LSHDAT    319
     +     ((ISOPT.EQ.1).AND.                                           LSHDAT    320
     +      (RYGR(KK-3).NE.0.0.OR.RYGR(KK-4).NE.0.0)))THEN              LSHDAT    321
          IF(I.GT.LASTBU)LASTBU=I                                       LSHDAT    322
C                                                                       LSHDAT    323
            IPTR=I                                                      LSHDAT    324
            CALL LSHDA1(IPTR,JREC,NTLSD,NAUT,JTYPE,JFLAG,TDATA,IERR)    LSHDAT    325
            IF(IERR.NE.0)GOTO 115                                       LSHDAT    326
C                                                                       LSHDAT    327
          ENDIF                                                         LSHDAT    328
        ENDIF                                                           LSHDAT    329
 320  CONTINUE                                                          LSHDAT    330
      JREC=JREC1                                                        LSHDAT    331
      GOTO 110                                                          LSHDAT    332
C                                                                       LSHDAT    333
C      SELECT BUS FOR THE WHOLE SYSTEM                                  LSHDAT    334
C                                                                       LSHDAT    335
 400  CONTINUE                                                          LSHDAT    336
C                                                                       LSHDAT    337
      ASSIGN 405 TO I2000                                               LSHDAT    338
      GOTO 2000                                                         LSHDAT    339
 405  CONTINUE                                                          LSHDAT    340
      JFLAG=-3                                                          LSHDAT    341
      ASSIGN 410 TO I2100                                               LSHDAT    342
      GOTO 2100                                                         LSHDAT    343
C                                                                       LSHDAT    344
 410  CONTINUE                                                          LSHDAT    345
C                                                                       LSHDAT    346
C                                                                       LSHDAT    347
C   FLETCH THE BUS                                                      LSHDAT    348
C                                                                       LSHDAT    349
      K=0                                                               LSHDAT    350
      KK=0                                                              LSHDAT    351
      DO 420 I=1,NLFBUS                                                 LSHDAT    352
      K=K+4                                                             LSHDAT    353
      KK=KK+8                                                           LSHDAT    354
      IF((IBAR(K-2).NE.0.OR.IBAR(K-3).NE.0).OR.                         LSHDAT    355
     +   ((ISOPT.EQ.1).AND.                                             LSHDAT    356
     +    (RYGR(KK-3).NE.0.0.OR.RYGR(KK-4).NE.0.0)))THEN                LSHDAT    357
        IF(I.GT.LASTBU)LASTBU=I                                         LSHDAT    358
C                                                                       LSHDAT    359
          IPTR=I                                                        LSHDAT    360
          CALL LSHDA1(IPTR,JREC,NTLSD,NAUT,JTYPE,JFLAG,TDATA,IERR)      LSHDAT    361
          IF(IERR.NE.0)GOTO 115                                         LSHDAT    362
C                                                                       LSHDAT    363
        ENDIF                                                           LSHDAT    364
 420  CONTINUE                                                          LSHDAT    365
      JREC=JREC1                                                        LSHDAT    366
      GOTO 110                                                          LSHDAT    367
C                                                                       LSHDAT    368
  500 CONTINUE                                                          LSHDAT    369
C                                                                       LSHDAT    370
C     STORE THE DATA INTO THE PERMANENT ARRAY                           LSHDAT    371
C                                                                       LSHDAT    372
      LUFVDB=LRTEMP                                                     LSHDAT    373
C                                                                       LSHDAT    374
      DO 560 I=1,LASTBU                                                 LSHDAT    375
        IPTR=IFSLSD(I)                                                  LSHDAT    376
        JAUTB=.TRUE.                                                    LSHDAT    377
        NSCHEM=0                                                        LSHDAT    378
  510   IF(IPTR.EQ.0)GOTO 560                                           LSHDAT    379
        JREC=ILSREC(IPTR)                                               LSHDAT    380
C                                                                       LSHDAT    381
C   STORE THE BUS FOR RENUMBERING                                       LSHDAT    382
C                                                                       LSHDAT    383
        READ(IU31,REC=JREC) TDATA                                       LSHDAT    384
        IF(JAUTB)THEN                                                   LSHDAT    385
          NAUTB=NAUTB+1                                                 LSHDAT    386
          NLF=NOLD(I)                                                   LSHDAT    387
          NAUBUS(NAUTB)=NLF                                             LSHDAT    388
          JAUTB=.FALSE.                                                 LSHDAT    389
          LRTEMP=LRTEMP+1                                               LSHDAT    390
          IDATPT(LRTEMP)=JLNA+1                                         LSHDAT    391
          JSCHEM=JLNA                                                   LSHDAT    392
          IADATA(JLNA+2)=NLF                                            LSHDAT    393
          IADATA(JLNA+7)=ITDATA(4)                                      LSHDAT    394
          IRELAY=JLNA+9                                                 LSHDAT    395
          KSWITC=0                                                      LSHDAT    396
          LDSTAT=0                                                      LSHDAT    397
          NPROG=MNEW(NLF)                                               LSHDAT    398
          IF(JBSTAT(NPROG).GT.2)LDSTAT=10                               LSHDAT    399
          IADATA(JLNA+8)=LDSTAT                                         LSHDAT    400
          IADATA(JLNA+9)=0                                              LSHDAT    401
          JLNA=JLNA+9                                                   LSHDAT    402
        ENDIF                                                           LSHDAT    403
C                                                                       LSHDAT    404
        NSCHEM=NSCHEM+1                                                 LSHDAT    405
C                                                                       LSHDAT    406
        IADATA(JLNA+1)=ITDATA(2)                                        LSHDAT    407
        KPOS=JLNA+2                                                     LSHDAT    408
        IADATA(JLNA+3)=ITDATA(3)                                        LSHDAT    409
        ADATA(JLNA+4)=0.0                                               LSHDAT    410
        JLNA=JLNA+4                                                     LSHDAT    411
        LEVELS=0                                                        LSHDAT    412
        K=4                                                             LSHDAT    413
        DO 540 L=1,5                                                    LSHDAT    414
          IF(ITDATA(K+1).NE.0)THEN                                      LSHDAT    415
            LEVELS=LEVELS+1                                             LSHDAT    416
            ADATA(JLNA+1)=TDATA(K+1)                                    LSHDAT    417
            ADATA(JLNA+2)=TDATA(K+2)                                    LSHDAT    418
            ADATA(JLNA+3)=TDATA(K+3)                                    LSHDAT    419
            ADATA(JLNA+4)=TDATA(K+4)                                    LSHDAT    420
            IADATA(JLNA+5)=0                                            LSHDAT    421
            IADATA(JLNA+6)=0                                            LSHDAT    422
            JLNA=JLNA+6                                                 LSHDAT    423
          ENDIF                                                         LSHDAT    424
          K=K+4                                                         LSHDAT    425
 540    CONTINUE                                                        LSHDAT    426
        IADATA(KPOS)=LEVELS                                             LSHDAT    427
        IADATA(JSCHEM+1)=NSCHEM                                         LSHDAT    428
C                                                                       LSHDAT    429
C   FOR REMOTE RELAY                                                    LSHDAT    430
C                                                                       LSHDAT    431
 545    JREC=JREC+1                                                     LSHDAT    432
        READ(IU31,REC=JREC)(CDATA(LI),LI=1,20)                          LSHDAT    433
        IF(CARD1(1:3).EQ.ESC)THEN                                       LSHDAT    434
          IADATA(IRELAY)=KSWITC                                         LSHDAT    435
        ELSE                                                            LSHDAT    436
          IF(CARD1(1:3).EQ.MPI)THEN                                     LSHDAT    437
            JREC=JREC+1                                                 LSHDAT    438
            READ(IU31,REC=JREC)(CDATA1(LI),LI=1,20)                     LSHDAT    439
          ENDIF                                                         LSHDAT    440
          CALL SWIDAT(CARD1,CARD3,KSWITC,IEBK)                          LSHDAT    441
          GOTO 545                                                      LSHDAT    442
        ENDIF                                                           LSHDAT    443
C                                                                       LSHDAT    444
        IPTR=INXLSD(IPTR)                                               LSHDAT    445
        GOTO 510                                                        LSHDAT    446
C                                                                       LSHDAT    447
 560  CONTINUE                                                          LSHDAT    448
C                                                                       LSHDAT    449
      IF(LRTEMP.NE.LUFVDB)THEN                                          LSHDAT    450
        LUFVDB=LUFVDB+1                                                 LSHDAT    451
        NUFVDB=LRTEMP                                                   LSHDAT    452
      ELSE                                                              LSHDAT    453
        LUFVDB=0                                                        LSHDAT    454
        NUFVDB=0                                                        LSHDAT    455
      ENDIF                                                             LSHDAT    456
C                                                                       LSHDAT    457
C                                                                       LSHDAT    458
      CALL CLOSEF(IU31)                                                 LSHDAT    459
C                                                                       LSHDAT    460
      IF(IEBK.EQ.0)RETURN                                               LSHDAT    461
C                                                                       LSHDAT    462
      CARD='LSHDAT: LOAD SHEDDING RELAY DATA ERROR'                     LSHDAT    463
      CALL ASTOP(CARD,38)                                               LSHDAT    464
C                                                                       LSHDAT    465
C                                                                       LSHDAT    466
 2000  CONTINUE                                                         LSHDAT    467
C                                                                       LSHDAT    468
C   MATCH THE TYPE AND WRITE THE DATA INTO FILE                         LSHDAT    469
C                                                                       LSHDAT    470
       JTYPE=0                                                          LSHDAT    471
       DO 580 I=1,6                                                     LSHDAT    472
        IF(NTYPE.EQ.CTYPE(I))THEN                                       LSHDAT    473
         JTYPE=I                                                        LSHDAT    474
         GOTO 585                                                       LSHDAT    475
        ENDIF                                                           LSHDAT    476
 580   CONTINUE                                                         LSHDAT    477
C                                                                       LSHDAT    478
       IF(JTYPE.EQ.0)THEN                                               LSHDAT    479
         IEBK=3                                                         LSHDAT    480
         WRITE(MSG(1),3080)                                             LSHDAT    481
         MSG(2)=CARD                                                    LSHDAT    482
         CALL PRTMSG(2)                                                 LSHDAT    483
         CALL GETLIN(IU54,CARD)                                         LSHDAT    484
         CALL GETLIN(IU54,CARD)                                         LSHDAT    485
         CALL GETLIN(IU54,CARD)                                         LSHDAT    486
        ENDIF                                                           LSHDAT    487
 585    CONTINUE                                                        LSHDAT    488
        GOTO I2000                                                      LSHDAT    489
C                                                                       LSHDAT    490
C   READ IN THE SHEDDING DATA WRITE THESE DATA ONTO IU31 DA FILE        LSHDAT    491
C                                                                       LSHDAT    492
 2100 CONTINUE                                                          LSHDAT    493
C                                                                       LSHDAT    494
      ITDATA(1)=JFLAG                                                   LSHDAT    495
      ITDATA(2)=JTYPE                                                   LSHDAT    496
      ITDATA(3)=ISOPT                                                   LSHDAT    497
      ITDATA(4)=IFLAG                                                   LSHDAT    498
      CALL GETLIN(IU54,CARD)                                            LSHDAT    499
      READ(CARD,3120) (TDATA(4+LI),LI=1,8)                              LSHDAT    500
      CALL GETLIN(IU54,CARD)                                            LSHDAT    501
      READ(CARD,3120) (TDATA(4+LI),LI=9,16)                             LSHDAT    502
      CALL GETLIN(IU54,CARD)                                            LSHDAT    503
      READ(CARD,3120) (TDATA(4+LI),LI=17,21)                            LSHDAT    504
      JREC=JREC+1                                                       LSHDAT    505
      WRITE(IU31,REC=JREC) TDATA                                        LSHDAT    506
C                                                                       LSHDAT    507
      JREC1=JREC                                                        LSHDAT    508
      II=0                                                              LSHDAT    509
 2105 II=II+1                                                           LSHDAT    510
      IF(II.GT.16)THEN                                                  LSHDAT    511
       IEBK=2                                                           LSHDAT    512
       WRITE(MSG(1),3085)                                               LSHDAT    513
       MSG(2)=CARD                                                      LSHDAT    514
       CALL PRTMSG(2)                                                   LSHDAT    515
       GOTO 2110                                                        LSHDAT    516
      ENDIF                                                             LSHDAT    517
C                                                                       LSHDAT    518
      CALL GETLIN(IU54,CARD)                                            LSHDAT    519
       READ(CARD,3160)(CTDATA(I),I=1,20)                                LSHDAT    520
       JREC1=JREC1+1                                                    LSHDAT    521
       WRITE(IU31,REC=JREC1)CTDATA                                      LSHDAT    522
       IF(CARD(1:3).NE.ESC)GOTO 2105                                    LSHDAT    523
C                                                                       LSHDAT    524
 2110  CONTINUE                                                         LSHDAT    525
      GOTO I2100                                                        LSHDAT    526
C                                                                       LSHDAT    527
C                                                                       LSHDAT    528
 3010 FORMAT(I5,4X,A1,2I5)                                              LSHDAT    529
 3020 FORMAT(' *** ERROR NO. OF RELAY SCHEME EXCEEDS ',I5)              LSHDAT    530
 3040 FORMAT(A12,4X,A1,2I5)                                             LSHDAT    531
 3080 FORMAT(' *** ERROR NO SUCH TYPE OF LOAD SHEDDING')                LSHDAT    532
 3085 FORMAT                                                            LSHDAT    533
     *(' *** ERROR NO. OF RELAY EXCEEDS 15. THE LAST CARD READ IN WAS') LSHDAT    534
 3090 FORMAT(I5,4X,A1,2I5)                                              LSHDAT    535
 3110 FORMAT(A12,4X,A1,2I5)                                             LSHDAT    536
 3160 FORMAT(20A4)                                                      LSHDAT    537
 3120 FORMAT(8F10.5)                                                    LSHDAT    538
 3130 FORMAT(' *** ERROR NO SUCH AREA IN THE LOADFLOW ')                LSHDAT    539
 3140 FORMAT(' *** ERROR NO SUCH ZONE IN THE LOADFLOW ')                LSHDAT    540
      END                                                               LSHDAT    541
C                                                                       LSHDAT    542
      SUBROUTINE LSHDA1(IPTR,JREC,NTLSD,NAUT,JTYPE,JFLAG,XDATA,IERR)    LSHDAT    543
C                                                                       LSHDAT    544
      INCLUDE 'PARX.INS'                                                LSHDAT    545
      INCLUDE 'CNUNIT.INS'                                              LSHDAT    546
C                                                                       LSHDAT    547
*IF -MI2                                                                LSHDAT    548
      INTEGER*2 IFSLSD,INXLSD,ILSREC                                    LSHDAT    549
*ENDIF                                                                  LSHDAT    550
      COMMON/SCRAT4/IFSLSD(NB),INXLSD(MAXSET),ILSREC(MAXSET)            LSHDAT    551
C                                                                       LSHDAT    552
      DIMENSION XDATA(32),IXDATA(2)                                     LSHDAT    553
C                                                                       LSHDAT    554
      IERR=0                                                            LSHDAT    555
C                                                                       LSHDAT    556
      IF(IFSLSD(IPTR).EQ.0)THEN                                         LSHDAT    557
        NTLSD=NTLSD+1                                                   LSHDAT    558
        NAUT=NAUT+1                                                     LSHDAT    559
        IF(NAUT.GT.MAXSET)THEN                                          LSHDAT    560
        IERR=1                                                          LSHDAT    561
        RETURN                                                          LSHDAT    562
        ENDIF                                                           LSHDAT    563
        IFSLSD(IPTR)=NTLSD                                              LSHDAT    564
        ILSREC(NTLSD)=JREC                                              LSHDAT    565
      ELSE                                                              LSHDAT    566
        II=IFSLSD(IPTR)                                                 LSHDAT    567
 3100   JJREC=ILSREC(II)                                                LSHDAT    568
        READ(IU31,REC=JJREC) XDATA                                      LSHDAT    569
        READ(IU31,REC=JJREC) IXDATA                                     LSHDAT    570
        JJFLAG=IXDATA(1)                                                LSHDAT    571
        JJTYPE=IXDATA(2)                                                LSHDAT    572
        IF(JJTYPE.EQ.JTYPE.AND.JJFLAG.LE.JFLAG)THEN                     LSHDAT    573
          ILSREC(II)=JREC                                               LSHDAT    574
          RETURN                                                        LSHDAT    575
        ENDIF                                                           LSHDAT    576
        IF(INXLSD(II).NE.0)THEN                                         LSHDAT    577
          II=INXLSD(II)                                                 LSHDAT    578
          GOTO 3100                                                     LSHDAT    579
        ELSE                                                            LSHDAT    580
          NTLSD=NTLSD+1                                                 LSHDAT    581
          NAUT=NAUT+1                                                   LSHDAT    582
          IF(NAUT.GT.MAXSET)THEN                                        LSHDAT    583
          IERR=1                                                        LSHDAT    584
          RETURN                                                        LSHDAT    585
          ENDIF                                                         LSHDAT    586
          INXLSD(II)=NTLSD                                              LSHDAT    587
          ILSREC(NTLSD)=JREC                                            LSHDAT    588
        ENDIF                                                           LSHDAT    589
      ENDIF                                                             LSHDAT    590
C                                                                       LSHDAT    591
      RETURN                                                            LSHDAT    592
C                                                                       LSHDAT    593
      END                                                               LSHDAT    594
