CFPRIME DCSINT                                                          DCSINT      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                                                                       DCSINT      3
       SUBROUTINE DCSINT (IEBK)                                         DCSINT      4
CD                                                                      DCSINT      5
CD  This subroutine initializes the directional comparison supervisory  DCSINT      6
CD  overcurrent relay data arrays including remote tripping arrays.     DCSINT      7
CD                                                                      DCSINT      8
C---------------------------------------------------------------------  DCSINT      9
C                                                        Include files  DCSINT     10
C                                                                       DCSINT     11
      INCLUDE 'PARX.INS'                                                DCSINT     12
      INCLUDE 'CNPT.INS'                                                DCSINT     13
      INCLUDE 'CNAUTO.INS'                                              DCSINT     14
      INCLUDE 'CNVOLT.INS'                                              DCSINT     15
      INCLUDE 'CNNNEW.INS'                                              DCSINT     16
      INCLUDE 'CNSTN.INS'                                               DCSINT     17
      INCLUDE 'CNB19.INS'                                               DCSINT     18
      INCLUDE 'CNUNIT.INS'                                              DCSINT     19
      INCLUDE 'CNLFDA.INS'                                              DCSINT     20
      INCLUDE 'CNSELI.INS'                                              DCSINT     21
      INCLUDE 'CNMSG.INS'                                               DCSINT     22
C---------------------------------------------------------------------  DCSINT     23
C                                                      Local Variables  DCSINT     24
C                                                                       DCSINT     25
       INTEGER       NLFIJ(2), NIJ3(2)                                  DCSINT     26
       REAL          TT(2)                                              DCSINT     27
       COMPLEX       PQ                                                 DCSINT     28
       CHARACTER*2   CID, CKK                                           DCSINT     29
C                                                                       DCSINT     30
       EQUIVALENCE   (PQ, TT(1), PP), (TT(2), QQ)                       DCSINT     31
       EQUIVALENCE   (NLFIJ(1), NLFI), (NLFIJ(2), NLFJ)                 DCSINT     32
       EQUIVALENCE   (NIJ3(1), NI3), (NIJ3(2), NJ3)                     DCSINT     33
C---------------------------------------------------------------------  DCSINT     34
CD                                                                      DCSINT     35
CD  1.  Store the internal bus numbers                                  DCSINT     36
CD                                                                      DCSINT     37
       DO 5000 II = LDCSI, NDCSI                                        DCSINT     38
         JJ = IDATPT(II)                                                DCSINT     39
C                                                                       DCSINT     40
         IF(IADATA(JJ+73).GT.9)GOTO 5000                                DCSINT     41
C                                                                       DCSINT     42
         NLFI = IADATA(JJ + 1)                                          DCSINT     43
         NLFJ = IADATA(JJ + 2)                                          DCSINT     44
         NPROGI = NNEW(NLFI)                                            DCSINT     45
         NPROGJ = NNEW(NLFJ)                                            DCSINT     46
         IADATA(JJ + 1) = NPROGI                                        DCSINT     47
         IADATA(JJ + 2) = NPROGJ                                        DCSINT     48
         NI3 = (NPROGI - 1) * 3                                         DCSINT     49
         NJ3 = (NPROGJ - 1) * 3                                         DCSINT     50
C---------------------------------------------------------------------  DCSINT     51
CD                                                                      DCSINT     52
CD  2.  Store the branch parameters and branch current                  DCSINT     53
CD                                                                      DCSINT     54
         ITFK = IADATA(JJ + 3)                                          DCSINT     55
         CALL UNPACK (CID, JJJ, ITFK)                                   DCSINT     56
C                                                                       DCSINT     57
         CALL LOLINE (NPROGI, NPROGJ, CID, JNL)                         DCSINT     58
C                                                                       DCSINT     59
         IF (JNL .EQ. 0) THEN                                           DCSINT     60
           IEBK = 1                                                     DCSINT     61
           WRITE (MSG(1), 6100) NLFI, (INAME(NI3 + IK), IK = 1, 3),     DCSINT     62
     +                          NLFJ, (INAME(NJ3 + IK), IK = 1, 3)      DCSINT     63
           WRITE (MSG(2), 6200) CID                                     DCSINT     64
           CALL PRTMSG (2)                                              DCSINT     65
         ELSE                                                           DCSINT     66
C                                                                       DCSINT     67
           JNL5 = IABS(JNL) * 5                                         DCSINT     68
           ITFK = LFTB(JNL5 - 4)                                        DCSINT     69
           CALL UNPACK (CKK, NJSELI, ITFK)                              DCSINT     70
           IF (NJSELI .NE. 0) THEN                                      DCSINT     71
             ADATA(JJ + 57) = EQPI(1, NJSELI)                           DCSINT     72
             ADATA(JJ + 58) = - EQPI(2, NJSELI)                         DCSINT     73
             ADATA(JJ + 59) = EQPI(3, NJSELI)                           DCSINT     74
             ADATA(JJ + 60) = EQPI(4, NJSELI)                           DCSINT     75
             ADATA(JJ + 61) = EQPI(5, NJSELI)                           DCSINT     76
             ADATA(JJ + 62) = EQPI(6, NJSELI)                           DCSINT     77
           ELSE                                                         DCSINT     78
             ADATA(JJ + 57) = GA(JNL5 - 2)                              DCSINT     79
             ADATA(JJ + 58) = - BA(JNL5 - 1)                            DCSINT     80
             ADATA(JJ + 59) = 0.0                                       DCSINT     81
             ADATA(JJ + 60) = BCHG(JNL5) / 2.0                          DCSINT     82
             ADATA(JJ + 61) = 0.0                                       DCSINT     83
             ADATA(JJ + 62) = BCHG(JNL5) / 2.0                          DCSINT     84
           ENDIF                                                        DCSINT     85
           IADATA(JJ + 63) = NJSELI                                     DCSINT     86
C                                                                       DCSINT     87
           IBUS = IADATA(JJ + 1)                                        DCSINT     88
           JBUS = IADATA(JJ + 2)                                        DCSINT     89
           PQ = VOLT(IBUS)                                              DCSINT     90
           EIR = PP                                                     DCSINT     91
           EII = QQ                                                     DCSINT     92
           PQ = VOLT(JBUS)                                              DCSINT     93
           EJR = PP                                                     DCSINT     94
           EJI = QQ                                                     DCSINT     95
           GIJ = ADATA(JJ + 57)                                         DCSINT     96
           BIJ = ADATA(JJ + 58)                                         DCSINT     97
C                                          Compute branch currents and  DCSINT     98
C                                  apparent impedances at the From bus  DCSINT     99
           GIO = ADATA(JJ + 59)                                         DCSINT    100
           BIO = ADATA(JJ + 60)                                         DCSINT    101
           GT = GIJ + GIO                                               DCSINT    102
           BT = BIJ + BIO                                               DCSINT    103
           C1R = EIR * GT - EII * BT                                    DCSINT    104
           C1I = EIR * BT + EII * GT                                    DCSINT    105
           C2R = EJR * GIJ - EJI * BIJ                                  DCSINT    106
           C2I = EJR * BIJ + EJI * GIJ                                  DCSINT    107
           CTR = C1R - C2R                                              DCSINT    108
           CTI = C1I - C2I                                              DCSINT    109
           CURR = SQRT (CTR * CTR + CTI * CTI)                          DCSINT    110
           ADATA(JJ + 64) = CURR                                        DCSINT    111
           PQ = CMPLX (EIR, EII) / CMPLX (CTR, CTI)                     DCSINT    112
           ADATA(JJ + 66) = PP                                          DCSINT    113
           ADATA(JJ + 67) = QQ                                          DCSINT    114
C                                          Compute branch currents and  DCSINT    115
C                                    apparent impedances at the To bus  DCSINT    116
           GIO = ADATA(JJ + 61)                                         DCSINT    117
           BIO = ADATA(JJ + 62)                                         DCSINT    118
           GT = GIJ + GIO                                               DCSINT    119
           BT = BIJ + BIO                                               DCSINT    120
           C2R = EJR * GT - EJI * BT                                    DCSINT    121
           C2I = EJR * BT + EJI * GT                                    DCSINT    122
           C1R = EIR * GIJ - EII * BIJ                                  DCSINT    123
           C1I = EIR * BIJ + EII * GIJ                                  DCSINT    124
           CTR = C2R - C1R                                              DCSINT    125
           CTI = C2I - C1I                                              DCSINT    126
           CURR = SQRT (CTR * CTR + CTI * CTI)                          DCSINT    127
           ADATA(JJ + 65) = CURR                                        DCSINT    128
           PQ = CMPLX (EJR, EJI) / CMPLX (CTR, CTI)                     DCSINT    129
           ADATA(JJ + 68) = PP                                          DCSINT    130
           ADATA(JJ + 69) = QQ                                          DCSINT    131
C---------------------------------------------------------------------  DCSINT    132
CD                                                                      DCSINT    133
CD  3.  Convert cycles to seconds                                       DCSINT    134
CD                                                                      DCSINT    135
           ADATA(JJ + 9) = ADATA(JJ + 9) / FQBASE                       DCSINT    136
           ADATA(JJ + 13) = ADATA(JJ + 13) / FQBASE                     DCSINT    137
           ADATA(JJ + 18) = ADATA(JJ + 18) / FQBASE                     DCSINT    138
           ADATA(JJ + 31) = ADATA(JJ + 31) / FQBASE                     DCSINT    139
           ADATA(JJ + 32) = ADATA(JJ + 32) / FQBASE                     DCSINT    140
           ADATA(JJ + 33) = ADATA(JJ + 33) / FQBASE                     DCSINT    141
           ADATA(JJ + 34) = ADATA(JJ + 34) / FQBASE                     DCSINT    142
C---------------------------------------------------------------------  DCSINT    143
CD                                                                      DCSINT    144
CD  4.  Initialize timers, timer flags, zone flags,                     DCSINT    145
CD      zone 1 trip flag and the status of remote breakers              DCSINT    146
CD                                                                      DCSINT    147
           ADATA(JJ + 41) = 0.0                                         DCSINT    148
           ADATA(JJ + 43) = 0.0                                         DCSINT    149
           ADATA(JJ + 45) = 0.0                                         DCSINT    150
           ADATA(JJ + 47) = 0.0                                         DCSINT    151
           ADATA(JJ + 49) = 0.0                                         DCSINT    152
           ADATA(JJ + 51) = 0.0                                         DCSINT    153
           ADATA(JJ + 53) = 0.0                                         DCSINT    154
           ADATA(JJ + 55) = 0.0                                         DCSINT    155
C                                                                       DCSINT    156
           IADATA(JJ + 42) = 0                                          DCSINT    157
           IADATA(JJ + 44) = 0                                          DCSINT    158
           IADATA(JJ + 46) = 0                                          DCSINT    159
           IADATA(JJ + 48) = 0                                          DCSINT    160
           IADATA(JJ + 50) = 0                                          DCSINT    161
           IADATA(JJ + 52) = 0                                          DCSINT    162
           IADATA(JJ + 54) = 0                                          DCSINT    163
           IADATA(JJ + 56) = 0                                          DCSINT    164
C                                                                       DCSINT    165
           IADATA(JJ + 70) = 0                                          DCSINT    166
           IADATA(JJ + 71) = 0                                          DCSINT    167
C                                                                       DCSINT    168
           IADATA(JJ + 72) = 0                                          DCSINT    169
C                                                                       DCSINT    170
           IADATA(JJ + 73) = 0                                          DCSINT    171
C---------------------------------------------------------------------  DCSINT    172
CD                                                                      DCSINT    173
CD  5.  Initialize remote tripping scheme                               DCSINT    174
CD                                                                      DCSINT    175
           NRMRLY = IADATA(JJ + 4)                                      DCSINT    176
           IF (NRMRLY .NE. 0) THEN                                      DCSINT    177
             KK = JJ + 73                                               DCSINT    178
             CALL REMINT (KK, NRMRLY)                                   DCSINT    179
           ENDIF                                                        DCSINT    180
C---------------------------------------------------------------------  DCSINT    181
CD                                                                      DCSINT    182
CD  6.  Write out a message if a current exceeds its supervisory level  DCSINT    183
CD                                                                      DCSINT    184
         DO 4000 IQ = 1, 2                                              DCSINT    185
           IF (IABS(IADATA(JJ + 4 + IQ)) .EQ. 1) THEN                   DCSINT    186
             IF (ADATA(JJ + 63 + IQ) .GT. ADATA(JJ + 28 + IQ)) THEN     DCSINT    187
               WRITE (MSG(1), 7000)                                     DCSINT    188
     +               NLFI, (INAME(NI3 + IK), IK = 1, 3),                DCSINT    189
     +               NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID            DCSINT    190
               WRITE (MSG(2), 7100)                                     DCSINT    191
     +               NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3)       DCSINT    192
               WRITE (MSG(3), 7200)                                     DCSINT    193
               CALL PRTMSG (3)                                          DCSINT    194
             ENDIF                                                      DCSINT    195
           ENDIF                                                        DCSINT    196
4000     CONTINUE                                                       DCSINT    197
C                                                                       DCSINT    198
         ENDIF                                                          DCSINT    199
5000   CONTINUE                                                         DCSINT    200
C---------------------------------------------------------------------  DCSINT    201
C                                                       Error messages  DCSINT    202
C                                                                       DCSINT    203
6100   FORMAT (' *** ERROR DCSI CIRCUIT FROM: ', I6, 1X, 3A4,           DCSINT    204
     +         '  TO: ', I6, 1X, 3A4)                                   DCSINT    205
6200   FORMAT ('     WITH CIRCUIT ID: ', A2, ' DOES NOT EXIST.')        DCSINT    206
C---------------------------------------------------------------------  DCSINT    207
C                                                       Other messages  DCSINT    208
C                                                                       DCSINT    209
7000   FORMAT (' *** DSCI RELAY CIRCUIT FROM: ', I6, 1X, 3A4,           DCSINT    210
     +         '  TO: ', I6, 1X, 3A4, '  ID: ', A2)                     DCSINT    211
7100   FORMAT ('     DURING INITIALIZATION AT BUS: ', I6, 1X, 3A4)      DCSINT    212
7200   FORMAT ('     CURRENT IS ABOVE SUPERVISORY LEVEL')               DCSINT    213
C---------------------------------------------------------------------  DCSINT    214
       RETURN                                                           DCSINT    215
       END                                                              DCSINT    216
