CFPRIME DCSDAT                                                          DCSDAT      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
C                                                                       DCSDAT      3
       SUBROUTINE DCSDAT (IEBK)                                         DCSDAT      4
CD                                                                      DCSDAT      5
CD  This subroutine reads in the directional comparison supervisory     DCSDAT      6
CD  overcurrent relay data from a given file                            DCSDAT      7
CD                                                                      DCSDAT      8
C---------------------------------------------------------------------  DCSDAT      9
C                                                        Include files  DCSDAT     10
C                                                                       DCSDAT     11
      INCLUDE 'PARX.INS'                                                DCSDAT     12
      INCLUDE 'CNPT.INS'                                                DCSDAT     13
      INCLUDE 'CNMNEW.INS'                                              DCSDAT     14
      INCLUDE 'CNAUTO.INS'                                              DCSDAT     15
      INCLUDE 'CNLFDA.INS'                                              DCSDAT     16
      INCLUDE 'CNB19.INS'                                               DCSDAT     17
      INCLUDE 'CNFLAG.INS'                                              DCSDAT     18
      INCLUDE 'CNPARX.INS'                                              DCSDAT     19
      INCLUDE 'CNREN.INS'                                               DCSDAT     20
      INCLUDE 'CNUNIT.INS'                                              DCSDAT     21
      INCLUDE 'CNMSG.INS'                                               DCSDAT     22
C---------------------------------------------------------------------  DCSDAT     23
C                                                      Local Variables  DCSDAT     24
C                                                                       DCSDAT     25
       CHARACTER*2   CID                                                DCSDAT     26
       CHARACTER*3   ESC, MPI                                           DCSDAT     27
       CHARACTER*5   EDATA                                              DCSDAT     28
       CHARACTER*80  CARD, CARD1, BUFFER(6)                             DCSDAT     29
C                                                                       DCSDAT     30
       DATA          ESC / 'ESC' /,                                     DCSDAT     31
     +               MPI / 'MPI' /,                                     DCSDAT     32
     +               EDATA / 'EDATA' /                                  DCSDAT     33
C---------------------------------------------------------------------  DCSDAT     34
C                                                       Initialization  DCSDAT     35
C                                                                       DCSDAT     36
      LDEB=.FALSE.                                                      DCSDAT     37
       LDCSI = LRTEMP                                                   DCSDAT     38
C---------------------------------------------------------------------  DCSDAT     39
CD                                                                      DCSDAT     40
CD  1.  Read DCSI relay branch specification                            DCSDAT     41
CD                                                                      DCSDAT     42
1000   NERR = 0                                                         DCSDAT     43
       DO 1100 IK = 1,6                                                 DCSDAT     44
         BUFFER(IK) = ' '                                               DCSDAT     45
1100    CONTINUE                                                        DCSDAT     46
C                                                                       DCSDAT     47
       CALL GETLIN (IU54, CARD)                                         DCSDAT     48
       IF (CARD(1:5) .EQ. EDATA) GOTO 9000                              DCSDAT     49
C                                                                       DCSDAT     50
       IF (KLFO .EQ. 0) THEN                                            DCSDAT     51
C                                                          Bus numbers  DCSDAT     52
         READ (CARD, 5100) NLFI, NLFJ, CID,                             DCSDAT     53
     +                     (IADATA(JLNA + IK), IK = 5, 8)               DCSDAT     54
         IF (NLFI .GT. N99999 .OR. NLFJ .GT. N99999) THEN               DCSDAT     55
           WRITE (MSG(1), 6100) N99999                                  DCSDAT     56
           GOTO 2000                                                    DCSDAT     57
         ENDIF                                                          DCSDAT     58
C                                                                       DCSDAT     59
         IF (MNEW(NLFI) .EQ. 0 .OR. MNEW(NLFJ) .EQ. 0) THEN             DCSDAT     60
           WRITE (MSG(1), 6200)                                         DCSDAT     61
           GOTO 2000                                                    DCSDAT     62
         ENDIF                                                          DCSDAT     63
C                                                                       DCSDAT     64
       ELSE                                                             DCSDAT     65
C                                                            Bus names  DCSDAT     66
         READ (CARD, 5200) BNAME1, BNAME2, CID,                         DCSDAT     67
     +                     (IADATA(JLNA + IK), IK = 5, 8)               DCSDAT     68
         CALL CHKBUS (BNAME1, NLFI)                                     DCSDAT     69
         CALL CHKBUS (BNAME2, NLFJ)                                     DCSDAT     70
         IF (NLFI .EQ. 0 .OR. NLFJ .EQ. 0) THEN                         DCSDAT     71
           WRITE (MSG(1), 6200)                                         DCSDAT     72
           GOTO 2000                                                    DCSDAT     73
         ENDIF                                                          DCSDAT     74
C                                                                       DCSDAT     75
       ENDIF                                                            DCSDAT     76
C                                       Store the branch specification  DCSDAT     77
       IF (NAUT .GE. MAXSET) THEN                                       DCSDAT     78
         WRITE (MSG(1), 6300) MAXSET                                    DCSDAT     79
         GOTO 2000                                                      DCSDAT     80
       ENDIF                                                            DCSDAT     81
C                                           No error in data until now  DCSDAT     82
       NAUT = NAUT + 1                                                  DCSDAT     83
       NAUBUS(NAUT + 1) = NLFI                                          DCSDAT     84
       NAUBUS(NAUT + 2) = NLFJ                                          DCSDAT     85
       LRTEMP = LRTEMP + 1                                              DCSDAT     86
       IDATPT(LRTEMP) = JLNA                                            DCSDAT     87
       LDSTAT=0                                                         DCSDAT     88
       NPROG=MNEW(NLFI)                                                 DCSDAT     89
       IF(JBSTAT(NPROG).GT.2)LDSTAT=10                                  DCSDAT     90
       IF(LDSTAT.EQ.0)THEN                                              DCSDAT     91
       NPROG=MNEW(NLFJ)                                                 DCSDAT     92
       IF(JBSTAT(NPROG).GT.2)LDSTAT=10                                  DCSDAT     93
       ENDIF                                                            DCSDAT     94
       IADATA(JLNA+73)=LDSTAT                                           DCSDAT     95
       IADATA(JLNA + 1) = NLFI                                          DCSDAT     96
       IADATA(JLNA + 2) = NLFJ                                          DCSDAT     97
       CALL PACK (CID, 0, ITFK)                                         DCSDAT     98
       IADATA(JLNA + 3) = ITFK                                          DCSDAT     99
C                                                                       DCSDAT    100
       BUFFER(1) = CARD                                                 DCSDAT    101
C                                                                       DCSDAT    102
       GOTO 3000                                                        DCSDAT    103
C                                               On error print message  DCSDAT    104
C                       and skip subsequent cards until the next relay  DCSDAT    105
2000   IEBK = 1                                                         DCSDAT    106
       MSG(2) = CARD                                                    DCSDAT    107
       CALL PRTMSG (2)                                                  DCSDAT    108
2100   CALL GETLIN (IU54, CARD)                                         DCSDAT    109
       IF (CARD(1:3) .EQ. ESC) GOTO 1000                                DCSDAT    110
       GOTO 2100                                                        DCSDAT    111
C---------------------------------------------------------------------  DCSDAT    112
CD                                                                      DCSDAT    113
CD  2.  Read DCSI relay data and set defaults                           DCSDAT    114
CD                                                                      DCSDAT    115
3000   CALL GETLIN (IU54, CARD)                                         DCSDAT    116
       READ (CARD, 5300) (ADATA(JLNA + IK), IK = 9, 12)                 DCSDAT    117
       IF (ADATA(JLNA + 9) .LT. 0.0 .OR.                                DCSDAT    118
     +     ADATA(JLNA + 10) .LT. 0.0 .OR.                               DCSDAT    119
     +     ADATA(JLNA + 11) .GT. 90.0 .OR.                              DCSDAT    120
     +     ADATA(JLNA + 11) .LT. 0.0 .OR.                               DCSDAT    121
     +     ADATA(JLNA + 12) .LT. 0.0) THEN                              DCSDAT    122
         NERR = 1                                                       DCSDAT    123
         BUFFER(2) = CARD                                               DCSDAT    124
       ENDIF                                                            DCSDAT    125
C                                                                       DCSDAT    126
       CALL GETLIN (IU54, CARD)                                         DCSDAT    127
       READ (CARD, 5400) (ADATA(JLNA + IK), IK = 13, 17)                DCSDAT    128
       IF (ADATA(JLNA + 13) .LT. 0.0 .OR.                               DCSDAT    129
     +     ADATA(JLNA + 14) .LT. 0.0 .OR.                               DCSDAT    130
     +     ADATA(JLNA + 15) .LT. 0.0 .OR.                               DCSDAT    131
     +     ADATA(JLNA + 16) .GT. 90.0 .OR.                              DCSDAT    132
     +     ADATA(JLNA + 16) .LT. 0.0 .OR.                               DCSDAT    133
     +     ADATA(JLNA + 17) .LT. 0.0) THEN                              DCSDAT    134
         NERR = 1                                                       DCSDAT    135
         BUFFER(3) = CARD                                               DCSDAT    136
       ENDIF                                                            DCSDAT    137
C                                                                       DCSDAT    138
       CALL GETLIN (IU54, CARD)                                         DCSDAT    139
       READ (CARD, 5400) (ADATA(JLNA + IK), IK = 18, 22)                DCSDAT    140
       IF (ADATA(JLNA + 18) .LT. 0.0 .OR.                               DCSDAT    141
     +     ADATA(JLNA + 19) .LT. 0.0 .OR.                               DCSDAT    142
     +     ADATA(JLNA + 20) .LT. 0.0 .OR.                               DCSDAT    143
     +     ADATA(JLNA + 21) .GT. 90.0 .OR.                              DCSDAT    144
     +     ADATA(JLNA + 21) .LT. 0.0 .OR.                               DCSDAT    145
     +     ADATA(JLNA + 22) .LT. 0.0) THEN                              DCSDAT    146
         NERR = 1                                                       DCSDAT    147
         BUFFER(4) = CARD                                               DCSDAT    148
       ENDIF                                                            DCSDAT    149
C                                                                       DCSDAT    150
       CALL GETLIN (IU54, CARD)                                         DCSDAT    151
       READ (CARD, 5500) (ADATA(JLNA + IK), IK = 23, 28)                DCSDAT    152
       IF (ADATA(JLNA + 23) .LT. 0.0 .OR.                               DCSDAT    153
     +     ADATA(JLNA + 24) .GT. 90.0 .OR.                              DCSDAT    154
     +     ADATA(JLNA + 24) .LT. 0.0 .OR.                               DCSDAT    155
     +     ADATA(JLNA + 25) .LT. 0.0 .OR.                               DCSDAT    156
     +     ADATA(JLNA + 26) .LT. 0.0 .OR.                               DCSDAT    157
     +     ADATA(JLNA + 27) .GT. 90.0 .OR.                              DCSDAT    158
     +     ADATA(JLNA + 27) .LT. 0.0 .OR.                               DCSDAT    159
     +     ADATA(JLNA + 28) .LT. 0.0) THEN                              DCSDAT    160
         NERR = 1                                                       DCSDAT    161
         BUFFER(5) = CARD                                               DCSDAT    162
       ENDIF                                                            DCSDAT    163
C                                                                       DCSDAT    164
       CALL GETLIN (IU54, CARD)                                         DCSDAT    165
       READ (CARD, 5500) (ADATA(JLNA + IK), IK = 29, 34)                DCSDAT    166
       IF (ADATA(JLNA + 29) .LT. 0.0 .OR.                               DCSDAT    167
     +     ADATA(JLNA + 30) .LT. 0.0 .OR.                               DCSDAT    168
     +     ADATA(JLNA + 31) .LT. 0.0 .OR.                               DCSDAT    169
     +     ADATA(JLNA + 32) .LT. 0.0 .OR.                               DCSDAT    170
     +     ADATA(JLNA + 33) .LT. 0.0 .OR.                               DCSDAT    171
     +     ADATA(JLNA + 34) .LT. 0.0) THEN                              DCSDAT    172
         NERR = 1                                                       DCSDAT    173
         BUFFER(6) = CARD                                               DCSDAT    174
       ENDIF                                                            DCSDAT    175
C                                                                       DCSDAT    176
       IF (IADATA(JLNA + 8) .EQ. 1) THEN                                DCSDAT    177
         CALL GETLIN (IU54, CARD)                                       DCSDAT    178
         READ (CARD, 5500) (ADATA(JLNA + IK), IK = 35, 40)              DCSDAT    179
       ENDIF                                                            DCSDAT    180
C                                                                       DCSDAT    181
       ILNA = JLNA                                                      DCSDAT    182
       JLNA = JLNA + 73                                                 DCSDAT    183
C---------------------------------------------------------------------  DCSDAT    184
CD                                                                      DCSDAT    185
CD  3.  Read DCSI relay remote operation commands                       DCSDAT    186
CD                                                                      DCSDAT    187
       NRMRLY = 0                                                       DCSDAT    188
C                                                                       DCSDAT    189
4000   CALL GETLIN (IU54, CARD)                                         DCSDAT    190
       IF (CARD(1:3) .EQ. ESC) THEN                                     DCSDAT    191
         IADATA(ILNA + 4) = NRMRLY                                      DCSDAT    192
       ELSE                                                             DCSDAT    193
         IF (CARD(1:3) .EQ. MPI) CALL GETLIN (IU54, CARD1)              DCSDAT    194
         CALL SWIDAT (CARD, CARD1, NRMRLY, IEBK)                        DCSDAT    195
         GOTO 4000                                                      DCSDAT    196
       ENDIF                                                            DCSDAT    197
C---------------------------------------------------------------------  DCSDAT    198
       IF (NERR .EQ. 1) THEN                                            DCSDAT    199
         IEBK = 1                                                       DCSDAT    200
         IJ = 1                                                         DCSDAT    201
         WRITE (MSG(IJ), 6400)                                          DCSDAT    202
         DO 4100 IK = 1, 6                                              DCSDAT    203
           IF (BUFFER(IK) .NE. ' ') THEN                                DCSDAT    204
             IJ = IJ + 1                                                DCSDAT    205
             WRITE (MSG(IJ), 6500) IK, BUFFER(IK)(1:74)                 DCSDAT    206
           ENDIF                                                        DCSDAT    207
4100     CONTINUE                                                       DCSDAT    208
         CALL PRTMSG(IJ)                                                DCSDAT    209
       ENDIF                                                            DCSDAT    210
C---------------------------------------------------------------------  DCSDAT    211
       GOTO 1000                                                        DCSDAT    212
C---------------------------------------------------------------------  DCSDAT    213
C                                                              Formats  DCSDAT    214
C                                                                       DCSDAT    215
5100   FORMAT (2I5, A2, 3X, 4I5)                                        DCSDAT    216
5200   FORMAT (2A12, A2, 3X, 4I5)                                       DCSDAT    217
5300   FORMAT (4F10.5)                                                  DCSDAT    218
5400   FORMAT (5F10.5)                                                  DCSDAT    219
5500   FORMAT (6F10.5)                                                  DCSDAT    220
C---------------------------------------------------------------------  DCSDAT    221
C                                                       Error messages  DCSDAT    222
C                                                                       DCSDAT    223
6100   FORMAT (' *** ERROR DCSI RELAY BUS NUMBER EXCEEDS ', I5)         DCSDAT    224
6200   FORMAT (' *** ERROR DCSI RELAY BUS NOT FOUND')                   DCSDAT    225
6300   FORMAT (' *** ERROR RELAY SCHEME EXCEEDS THE LIMIT OF ', I3)     DCSDAT    226
6400   FORMAT (' *** DCSI RELAY DATA ERRORS ***')                       DCSDAT    227
6500   FORMAT (' CD', I1, ': ', A74)                                    DCSDAT    228
C---------------------------------------------------------------------  DCSDAT    229
9000   IF (LRTEMP .NE. LDCSI) THEN                                      DCSDAT    230
         LDCSI = LDCSI + 1                                              DCSDAT    231
         NDCSI = LRTEMP                                                 DCSDAT    232
       ELSE                                                             DCSDAT    233
         LDCSI = 0                                                      DCSDAT    234
         NDCSI = 0                                                      DCSDAT    235
       ENDIF                                                            DCSDAT    236
C---------------------------------------------------------------------  DCSDAT    237
       RETURN                                                           DCSDAT    238
       END                                                              DCSDAT    239
