CFPRIME DCSMON                                                          DCSMON      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                                                                       DCSMON      3
       SUBROUTINE DCSMON (DELT)                                         DCSMON      4
CD                                                                      DCSMON      5
CD  This subroutine monitors the operation of directional comparison    DCSMON      6
CD  supervisory overcurrent relays during the time simulation.          DCSMON      7
CD                                                                      DCSMON      8
CD  Routine Inputs:                                                     DCSMON      9
CD  DELT   : Integration step size in seconds                           DCSMON     10
CD                                                                      DCSMON     11
C---------------------------------------------------------------------  DCSMON     12
C                                                        Include files  DCSMON     13
C                                                                       DCSMON     14
      INCLUDE 'PARX.INS'                                                DCSMON     15
      INCLUDE 'CNPT.INS'                                                DCSMON     16
      INCLUDE 'CNAUTO.INS'                                              DCSMON     17
      INCLUDE 'CNVOLT.INS'                                              DCSMON     18
      INCLUDE 'CNFLAG.INS'                                              DCSMON     19
      INCLUDE 'CNB4.INS'                                                DCSMON     20
      INCLUDE 'CNB19.INS'                                               DCSMON     21
      INCLUDE 'CNUNIT.INS'                                              DCSMON     22
      INCLUDE 'CNSTN.INS'                                               DCSMON     23
      INCLUDE 'CNIPTR.INS'                                              DCSMON     24
C---------------------------------------------------------------------  DCSMON     25
C                                                      Local Variables  DCSMON     26
C                                                                       DCSMON     27
       INTEGER       NLFIJ(2), NIJ3(2)                                  DCSMON     28
       INTEGER       NZONE(2, 4)                                        DCSMON     29
       LOGICAL       Z2BLOC, TIMOUT                                     DCSMON     30
       REAL          TT(2), OLDCUR(2)                                   DCSMON     31
       COMPLEX       PQ, ZAPP, ZC, OFFSET                               DCSMON     32
       CHARACTER*1   STRNG1(4), NUMBER(4)                               DCSMON     33
       CHARACTER*2   CID                                                DCSMON     34
       CHARACTER*4   STRNG4                                             DCSMON     35
C                                                                       DCSMON     36
       EQUIVALENCE   (PQ, TT(1), PP), (TT(2), QQ)                       DCSMON     37
       EQUIVALENCE   (NLFIJ(1), NLFI), (NLFIJ(2), NLFJ)                 DCSMON     38
       EQUIVALENCE   (NIJ3(1), NI3), (NIJ3(2), NJ3)                     DCSMON     39
       EQUIVALENCE   (STRNG4, STRNG1)                                   DCSMON     40
C                                                                       DCSMON     41
       DATA          NUMBER / '1', '2', '3', '4' /                      DCSMON     42
C---------------------------------------------------------------------  DCSMON     43
      LDEB=.FALSE.                                                      DCSMON     44
C                                                                       DCSMON     45
       DO 6000 II = LDCSI, NDCSI                                        DCSMON     46
         JJ = IDATPT(II)                                                DCSMON     47
C                                                                       DCSMON     48
         IF(IADATA(JJ+73).GT.9)GOTO 6000                                DCSMON     49
C                                                                       DCSMON     50
         KK = JJ + 73                                                   DCSMON     51
         NRMRLY = IADATA(JJ + 4)                                        DCSMON     52
         IBUS = IADATA(JJ + 1)                                          DCSMON     53
         JBUS = IADATA(JJ + 2)                                          DCSMON     54
         NLFI = NOLD(IBUS)                                              DCSMON     55
         NLFJ = NOLD(JBUS)                                              DCSMON     56
         NI3 = (IBUS - 1) * 3                                           DCSMON     57
         NJ3 = (JBUS - 1) * 3                                           DCSMON     58
         ITFK = IADATA(JJ + 3)                                          DCSMON     59
         CALL UNPACK (CID, JJJ, ITFK)                                   DCSMON     60
C                                    Main circuit breaker timer is OUT  DCSMON     61
         IF (IADATA(JJ + 54) .EQ. -1) GOTO 5000                         DCSMON     62
C                                     Main circuit breaker timer is ON  DCSMON     63
         IF (IADATA(JJ + 54) .EQ. 1) GOTO 4000                          DCSMON     64
C                                    Main circuit breaker timer is OFF  DCSMON     65
C---------------------------------------------------------------------  DCSMON     66
C                                      Compute currents and impedances  DCSMON     67
C                                                                       DCSMON     68
         OLDCUR(1) = ADATA(JJ + 64)                                     DCSMON     69
         OLDCUR(2) = ADATA(JJ + 65)                                     DCSMON     70
C                                                                       DCSMON     71
         PQ = VOLT(IBUS)                                                DCSMON     72
         EIR = PP                                                       DCSMON     73
         EII = QQ                                                       DCSMON     74
         PQ = VOLT(JBUS)                                                DCSMON     75
         EJR = PP                                                       DCSMON     76
         EJI = QQ                                                       DCSMON     77
         GIJ = ADATA(JJ + 57)                                           DCSMON     78
         BIJ = ADATA(JJ + 58)                                           DCSMON     79
C                                          Compute branch currents and  DCSMON     80
C                                  apparent impedances at the From bus  DCSMON     81
         GIO = ADATA(JJ + 59)                                           DCSMON     82
         BIO = ADATA(JJ + 60)                                           DCSMON     83
         GT = GIJ + GIO                                                 DCSMON     84
         BT = BIJ + BIO                                                 DCSMON     85
         C1R = EIR * GT - EII * BT                                      DCSMON     86
         C1I = EIR * BT + EII * GT                                      DCSMON     87
         C2R = EJR * GIJ - EJI * BIJ                                    DCSMON     88
         C2I = EJR * BIJ + EJI * GIJ                                    DCSMON     89
         CTR = C1R - C2R                                                DCSMON     90
         CTI = C1I - C2I                                                DCSMON     91
         CURR = SQRT (CTR * CTR + CTI * CTI)                            DCSMON     92
         ADATA(JJ + 64) = CURR                                          DCSMON     93
         PQ = CMPLX (EIR, EII) / CMPLX (CTR, CTI)                       DCSMON     94
         ADATA(JJ + 66) = PP                                            DCSMON     95
         ADATA(JJ + 67) = QQ                                            DCSMON     96
C                                          Compute branch currents and  DCSMON     97
C                                    apparent impedances at the To bus  DCSMON     98
         GIO = ADATA(JJ + 61)                                           DCSMON     99
         BIO = ADATA(JJ + 62)                                           DCSMON    100
         GT = GIJ + GIO                                                 DCSMON    101
         BT = BIJ + BIO                                                 DCSMON    102
         C2R = EJR * GT - EJI * BT                                      DCSMON    103
         C2I = EJR * BT + EJI * GT                                      DCSMON    104
         C1R = EIR * GIJ - EII * BIJ                                    DCSMON    105
         C1I = EIR * BIJ + EII * GIJ                                    DCSMON    106
         CTR = C2R - C1R                                                DCSMON    107
         CTI = C2I - C1I                                                DCSMON    108
         CURR = SQRT (CTR * CTR + CTI * CTI)                            DCSMON    109
         ADATA(JJ + 65) = CURR                                          DCSMON    110
         PQ = CMPLX (EJR, EJI) / CMPLX (CTR, CTI)                       DCSMON    111
         ADATA(JJ + 68) = PP                                            DCSMON    112
         ADATA(JJ + 69) = QQ                                            DCSMON    113
C---------------------------------------------------------------------  DCSMON    114
C                           Check if current exceeds supervisory level  DCSMON    115
C                                                                       DCSMON    116
         DO 1000 IQ = 1, 2                                              DCSMON    117
           IF (IABS(IADATA(JJ + 4 + IQ)) .EQ. 1) THEN                   DCSMON    118
             IF (ADATA(JJ + 63 + IQ) .GT. ADATA(JJ + 28 + IQ)           DCSMON    119
     +           .AND. OLDCUR(IQ) .LE. ADATA(JJ + 28 + IQ)) THEN        DCSMON    120
C                                                                       DCSMON    121
               WRITE (IU6, 7000)                                        DCSMON    122
     +               NLFI, (INAME(NI3 + IK), IK = 1, 3),                DCSMON    123
     +               NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID            DCSMON    124
               WRITE (IU6, 7100)                                        DCSMON    125
     +               NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS   DCSMON    126
               WRITE (IU6, 7200)                                        DCSMON    127
C                                                                       DCSMON    128
             ELSE IF (ADATA(JJ + 63 + IQ) .LT. ADATA(JJ + 28 + IQ)      DCSMON    129
     +                .AND. OLDCUR(IQ) .GE. ADATA(JJ + 28 + IQ)) THEN   DCSMON    130
C                                                                       DCSMON    131
               WRITE (IU6, 7000)                                        DCSMON    132
     +               NLFI, (INAME(NI3 + IK), IK = 1, 3),                DCSMON    133
     +               NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID            DCSMON    134
               WRITE (IU6, 7100)                                        DCSMON    135
     +               NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS   DCSMON    136
               WRITE (IU6, 7300)                                        DCSMON    137
C                                                                       DCSMON    138
             ENDIF                                                      DCSMON    139
           ENDIF                                                        DCSMON    140
1000     CONTINUE                                                       DCSMON    141
C---------------------------------------------------------------------  DCSMON    142
C                                                      Determine zones  DCSMON    143
C                                                                       DCSMON    144
         DO 1500 IQ = 1, 2                                              DCSMON    145
C                                                                       DCSMON    146
           DO 1100 IJ = 1, 4                                            DCSMON    147
             NZONE(IQ, IJ) = 0                                          DCSMON    148
1100       CONTINUE                                                     DCSMON    149
C                                                                       DCSMON    150
           I1 = JJ + 66 + (IQ - 1) * 2                                  DCSMON    151
           PP = ADATA(I1)                                               DCSMON    152
           QQ = ADATA(I1 + 1)                                           DCSMON    153
           ZAPP = PQ                                                    DCSMON    154
C                                                   Check if in zone 1  DCSMON    155
           IZ = 1                                                       DCSMON    156
           ANG = ADATA(JJ + 11) * 3.141592654 / 180.0                   DCSMON    157
           RADIUS = ADATA(JJ + 10) / 2.0                                DCSMON    158
           ZC = ADATA(JJ + 12) * CMPLX (COS(ANG), SIN(ANG))             DCSMON    159
           IF (CABS(ZAPP - ZC) .LT. RADIUS) NZONE(IQ, IZ) = 1           DCSMON    160
C                                                   Check if in zone 2  DCSMON    161
           IZ = 2                                                       DCSMON    162
           I1 = JJ + 14 + (IQ - 1) * 5                                  DCSMON    163
           ANG1 = ADATA(I1 + 2) * 3.141592654 / 180.0                   DCSMON    164
           OFFSET = ADATA(I1 + 1) * CMPLX (COS(ANG1), SIN(ANG1))        DCSMON    165
           ANG2 = ACOS ((ADATA(I1) + ADATA(I1 + 1)) / (ADATA(I1 + 3)))  DCSMON    166
           ANG = ANG1 - ANG2                                            DCSMON    167
           RADIUS = ADATA(I1 + 3) / 2.0                                 DCSMON    168
           ZC = RADIUS * CMPLX (COS(ANG), SIN(ANG)) - OFFSET            DCSMON    169
           IF (CABS(ZAPP - ZC) .LT. RADIUS) THEN                        DCSMON    170
             ANG = ANG1 + ANG2                                          DCSMON    171
             ZC = RADIUS * CMPLX (COS(ANG), SIN(ANG)) - OFFSET          DCSMON    172
             IF (CABS(ZAPP - ZC) .LT. RADIUS) NZONE(IQ, IZ) = 1         DCSMON    173
           ENDIF                                                        DCSMON    174
C                                                   Check if in zone 3  DCSMON    175
           IF (IADATA(JJ + 7) .EQ. 1 .AND.                              DCSMON    176
     +         NZONE(IQ, 2) .EQ. 0) THEN                                DCSMON    177
             IZ = 3                                                     DCSMON    178
             ANG = ADATA(I1 + 2) * 3.141592654 / 180.0                  DCSMON    179
             RADIUS = (ADATA(I1) + ADATA(I1 + 1)) / 2.0                 DCSMON    180
             ZC = (ADATA(I1) - RADIUS) * CMPLX (COS(ANG), SIN(ANG))     DCSMON    181
             IF (CABS(ZAPP - ZC) .LT. RADIUS) NZONE(IQ, IZ) = 1         DCSMON    182
           ENDIF                                                        DCSMON    183
C                                                   Check if in zone 4  DCSMON    184
           IZ = 4                                                       DCSMON    185
           I1 = JJ + 23 + (IQ - 1) * 3                                  DCSMON    186
           ANG = ADATA(I1 + 1) * 3.141592654 / 180.0                    DCSMON    187
           RADIUS = ADATA(I1) / 2.0                                     DCSMON    188
           ZC = - ADATA(I1 + 2) * CMPLX (COS(ANG), SIN(ANG))            DCSMON    189
           IF (CABS(ZAPP - ZC) .LT. RADIUS) NZONE(IQ, IZ) = 1           DCSMON    190
C                                                 Set master zone flag  DCSMON    191
           IZFL = NZONE(IQ, 1) + 2 * NZONE(IQ, 2) +                     DCSMON    192
     +            4 * NZONE(IQ, 3) + 8 * NZONE(IQ, 4)                   DCSMON    193
C                                                  Report zone changes  DCSMON    194
           IF (IZFL .EQ. 0) THEN                                        DCSMON    195
             IF (IADATA(JJ + 69 + IQ) .NE. IZFL) THEN                   DCSMON    196
               IADATA(JJ + 69 + IQ) = 0                                 DCSMON    197
               WRITE (IU6, 7000)                                        DCSMON    198
     +               NLFI, (INAME(NI3 + IK), IK = 1, 3),                DCSMON    199
     +               NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID            DCSMON    200
               WRITE (IU6, 7100)                                        DCSMON    201
     +               NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS   DCSMON    202
               WRITE (IU6, 7400)                                        DCSMON    203
             ENDIF                                                      DCSMON    204
           ELSE                                                         DCSMON    205
             IF (IADATA(JJ + 69 + IQ) .NE. IZFL) THEN                   DCSMON    206
               IADATA(JJ + 69 + IQ) = IZFL                              DCSMON    207
               STRNG4 = ' '                                             DCSMON    208
               IK = 0                                                   DCSMON    209
               DO 1200 IJ = 1, 4                                        DCSMON    210
                 IF (NZONE(IQ, IJ) .EQ. 1) THEN                         DCSMON    211
                   IK = IK + 1                                          DCSMON    212
                   STRNG1(IK) = NUMBER(IJ)                              DCSMON    213
                 ENDIF                                                  DCSMON    214
1200           CONTINUE                                                 DCSMON    215
               WRITE (IU6, 7000)                                        DCSMON    216
     +               NLFI, (INAME(NI3 + IK), IK = 1, 3),                DCSMON    217
     +               NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID            DCSMON    218
               WRITE (IU6, 7100)                                        DCSMON    219
     +               NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS   DCSMON    220
               WRITE (IU6, 7500) (STRNG1(IK), IK = 1, 4)                DCSMON    221
             ENDIF                                                      DCSMON    222
           ENDIF                                                        DCSMON    223
C                                                                       DCSMON    224
1500     CONTINUE                                                       DCSMON    225
C---------------------------------------------------------------------  DCSMON    226
C                                                    Start zone timers  DCSMON    227
C                                                                       DCSMON    228
         DO 2000 IQ = 1, 2                                              DCSMON    229
           I1 = JJ + 42 + (IQ - 1) * 2                                  DCSMON    230
           IJ = 0                                                       DCSMON    231
           STRNG4 = ' '                                                 DCSMON    232
           DO 1600 IZ = 1, 3                                            DCSMON    233
             I2 = I1 + (IZ - 1) * 4                                     DCSMON    234
             IF (IADATA(I2) .EQ. 0 .AND. NZONE(IQ, IZ) .EQ. 1) THEN     DCSMON    235
               IF (IZ .EQ. 1) THEN                                      DCSMON    236
                 I3 = JJ + 9                                            DCSMON    237
               ELSE IF (IZ .EQ. 2) THEN                                 DCSMON    238
                 I3 = JJ + 13 + (IQ - 1) * 5                            DCSMON    239
               ELSE                                                     DCSMON    240
                 I3 = JJ + 30 + IQ                                      DCSMON    241
               ENDIF                                                    DCSMON    242
               IADATA(I2) = 1                                           DCSMON    243
               ADATA(I2 - 1) = TS + ADATA(I3) - 0.5 * DELT              DCSMON    244
               IJ = IJ + 1                                              DCSMON    245
               STRNG1(IJ) = NUMBER(IZ)                                  DCSMON    246
             ENDIF                                                      DCSMON    247
1600       CONTINUE                                                     DCSMON    248
C                                                                       DCSMON    249
           IF (IJ .GT. 0) THEN                                          DCSMON    250
             WRITE (IU6, 7000)                                          DCSMON    251
     +             NLFI, (INAME(NI3 + IK), IK = 1, 3),                  DCSMON    252
     +             NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID              DCSMON    253
             WRITE (IU6, 7100)                                          DCSMON    254
     +             NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS     DCSMON    255
             WRITE (IU6, 7600) (STRNG1(IK), IK = 1, 4)                  DCSMON    256
           ENDIF                                                        DCSMON    257
2000     CONTINUE                                                       DCSMON    258
C---------------------------------------------------------------------  DCSMON    259
C                                                    Reset zone timers  DCSMON    260
C                                                                       DCSMON    261
         DO 2500 IQ = 1, 2                                              DCSMON    262
           I1 = JJ + 42 + (IQ - 1) * 2                                  DCSMON    263
           IJ = 0                                                       DCSMON    264
           STRNG4 = ' '                                                 DCSMON    265
           DO 2100 IZ = 1, 3                                            DCSMON    266
             I2 = I1 + (IZ - 1) * 4                                     DCSMON    267
             IF (IADATA(I2) .NE. 0 .AND. NZONE(IQ, IZ) .EQ. 0) THEN     DCSMON    268
C                          Do not reset zone 3 timer if it is timed out DCSMON    269
C                                             and if Zapp is in zone 2  DCSMON    270
C                        This is to ensure proper out-of-step blocking  DCSMON    271
               IF (IZ .NE. 3 .OR.                                       DCSMON    272
     +             IADATA(I2) .GE. 0 .OR.                               DCSMON    273
     +             NZONE(IQ, 2) .EQ. 0) THEN                            DCSMON    274
                 IADATA(I2) = 0                                         DCSMON    275
                 IADATA(I2 - 1) = 0.0                                   DCSMON    276
                 IJ = IJ + 1                                            DCSMON    277
                 STRNG1(IJ) = NUMBER(IZ)                                DCSMON    278
               ENDIF                                                    DCSMON    279
             ENDIF                                                      DCSMON    280
2100       CONTINUE                                                     DCSMON    281
C                                                                       DCSMON    282
           IF (IJ .GT. 0) THEN                                          DCSMON    283
             WRITE (IU6, 7000)                                          DCSMON    284
     +             NLFI, (INAME(NI3 + IK), IK = 1, 3),                  DCSMON    285
     +             NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID              DCSMON    286
             WRITE (IU6, 7100)                                          DCSMON    287
     +             NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS     DCSMON    288
             WRITE (IU6, 7700) (STRNG1(IK), IK = 1, 4)                  DCSMON    289
           ENDIF                                                        DCSMON    290
2500     CONTINUE                                                       DCSMON    291
C---------------------------------------------------------------------  DCSMON    292
C                                    Check for time out of zone timers  DCSMON    293
C                                                                       DCSMON    294
         TIMOUT = .FALSE.                                               DCSMON    295
         DO 3000 IQ = 1, 2                                              DCSMON    296
           I1 = JJ + 42 + (IQ - 1) * 2                                  DCSMON    297
           IJ = 0                                                       DCSMON    298
           STRNG4 = ' '                                                 DCSMON    299
           DO 2900 IZ = 1, 3                                            DCSMON    300
             I2 = I1 + (IZ - 1) * 4                                     DCSMON    301
             IF (IADATA(I2) .EQ. 1) THEN                                DCSMON    302
               IF (IZ .EQ. 1) THEN                                      DCSMON    303
                 I3 = JJ + 9                                            DCSMON    304
               ELSE IF (IZ .EQ. 2) THEN                                 DCSMON    305
                 I3 = JJ + 13 + (IQ - 1) * 5                            DCSMON    306
               ELSE                                                     DCSMON    307
                 I3 = JJ + 30 + IQ                                      DCSMON    308
               ENDIF                                                    DCSMON    309
               IF (ADATA(I2 - 1) .LT. TS) THEN                          DCSMON    310
                 IJ = IJ + 1                                            DCSMON    311
                 IADATA(I2) = -1                                        DCSMON    312
                 STRNG1(IJ) = NUMBER(IZ)                                DCSMON    313
               ENDIF                                                    DCSMON    314
             ENDIF                                                      DCSMON    315
2900       CONTINUE                                                     DCSMON    316
C                                                                       DCSMON    317
           IF (IJ .GT. 0) THEN                                          DCSMON    318
             TIMOUT = .TRUE.                                            DCSMON    319
             WRITE (IU6, 7000)                                          DCSMON    320
     +             NLFI, (INAME(NI3 + IK), IK = 1, 3),                  DCSMON    321
     +             NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID              DCSMON    322
             WRITE (IU6, 7100)                                          DCSMON    323
     +             NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS     DCSMON    324
             WRITE (IU6, 7800) (STRNG1(IK), IK = 1, 4)                  DCSMON    325
           ENDIF                                                        DCSMON    326
3000     CONTINUE                                                       DCSMON    327
C---------------------------------------------------------------------  DCSMON    328
C                         Check for overcurrent violation trip signals  DCSMON    329
C                                                                       DCSMON    330
         DO 3100 IQ = 1, 2                                              DCSMON    331
           IF (IADATA(JJ + 4 + IQ) .EQ. 1 .AND.                         DCSMON    332
     +         ADATA(JJ + 63 + IQ) .GT. ADATA(JJ + 28 + IQ)) THEN       DCSMON    333
             WRITE (IU6, 7000)                                          DCSMON    334
     +             NLFI, (INAME(NI3 + IK), IK = 1, 3),                  DCSMON    335
     +             NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID              DCSMON    336
             WRITE (IU6, 7100)                                          DCSMON    337
     +             NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS     DCSMON    338
             WRITE (IU6, 7900)                                          DCSMON    339
             GOTO 3500                                                  DCSMON    340
           ENDIF                                                        DCSMON    341
3100     CONTINUE                                                       DCSMON    342
C                                                           Next relay  DCSMON    343
         IF (.NOT. TIMOUT) GOTO 6000                                    DCSMON    344
C---------------------------------------------------------------------  DCSMON    345
C                                        Check for zone 1 trip signals  DCSMON    346
C                                                                       DCSMON    347
         DO 3200 IQ = 1, 2                                              DCSMON    348
           I1 = JJ + 42 + (IQ - 1) * 2                                  DCSMON    349
           IF (IADATA(I1) .EQ. -1) THEN                                 DCSMON    350
             IADATA(JJ + 71) = 1                                        DCSMON    351
             WRITE (IU6, 7000)                                          DCSMON    352
     +             NLFI, (INAME(NI3 + IK), IK = 1, 3),                  DCSMON    353
     +             NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID              DCSMON    354
             WRITE (IU6, 7100)                                          DCSMON    355
     +             NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS     DCSMON    356
             WRITE (IU6, 8000)                                          DCSMON    357
             GOTO 3500                                                  DCSMON    358
           ENDIF                                                        DCSMON    359
3200     CONTINUE                                                       DCSMON    360
C---------------------------------------------------------------------  DCSMON    361
C                                        Check for zone 2 trip signals  DCSMON    362
C                                                                       DCSMON    363
         Z2BLOC = .FALSE.                                               DCSMON    364
C                                                                       DCSMON    365
         DO 3300 IQ = 1, 2                                              DCSMON    366
           I1 = JJ + 46 + (IQ - 1) * 2                                  DCSMON    367
           IF (IADATA(I1) .EQ. -1) THEN                                 DCSMON    368
             WRITE (IU6, 7000)                                          DCSMON    369
     +             NLFI, (INAME(NI3 + IK), IK = 1, 3),                  DCSMON    370
     +             NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID              DCSMON    371
             WRITE (IU6, 7100)                                          DCSMON    372
     +             NLFIJ(IQ), (INAME(NIJ3(IQ) + IK), IK = 1, 3), TS     DCSMON    373
C                                                                       DCSMON    374
             IF (IQ .EQ. 1) THEN                                        DCSMON    375
               I2 = 2                                                   DCSMON    376
             ELSE                                                       DCSMON    377
               I2 = 1                                                   DCSMON    378
             ENDIF                                                      DCSMON    379
C                                               Check for zone 2 block  DCSMON    380
             IF (NZONE(I2, 4) .EQ. 1) THEN                              DCSMON    381
C                                                        Reverse block  DCSMON    382
               Z2BLOC = .TRUE.                                          DCSMON    383
               WRITE (IU6, 8100)                                        DCSMON    384
             ELSE IF (IADATA(JJ + 4 + IQ) .EQ. -1 .AND.                 DCSMON    385
     +                ADATA(JJ + 63 + IQ) .GT.                          DCSMON    386
     +                ADATA(JJ + 28 + IQ)) THEN                         DCSMON    387
C                                            Supervisory current block  DCSMON    388
               Z2BLOC = .TRUE.                                          DCSMON    389
               WRITE (IU6, 8200)                                        DCSMON    390
             ELSE IF (IADATA(JJ + 7) .EQ. 1 .AND.                       DCSMON    391
     +                IADATA(JJ + 48 + 2 * IQ) .EQ. -1) THEN            DCSMON    392
C                                                    Out-of-step block  DCSMON    393
               Z2BLOC = .TRUE.                                          DCSMON    394
               WRITE (IU6, 8300)                                        DCSMON    395
             ENDIF                                                      DCSMON    396
C                                                                       DCSMON    397
             IF (Z2BLOC) THEN                                           DCSMON    398
C                                                   Reset zone 2 timer  DCSMON    399
               IADATA(I1) = 0                                           DCSMON    400
               ADATA(I1 - 1) = 0.0                                      DCSMON    401
               WRITE (IU6, 8400)                                        DCSMON    402
             ELSE                                                       DCSMON    403
C                                                 Initiate zone 2 trip  DCSMON    404
               IADATA(I1) = -1                                          DCSMON    405
               WRITE (IU6, 8500)                                        DCSMON    406
               GOTO 3500                                                DCSMON    407
             ENDIF                                                      DCSMON    408
           ENDIF                                                        DCSMON    409
3300     CONTINUE                                                       DCSMON    410
C                                                           Next relay  DCSMON    411
         GOTO 6000                                                      DCSMON    412
C---------------------------------------------------------------------  DCSMON    413
C                                   Start breaker and reclosure timers  DCSMON    414
C                                                                       DCSMON    415
3500     WRITE (IU6, 8600)                                              DCSMON    416
C                                                   Main circuit timer  DCSMON    417
         ADATA(JJ + 53) = TS + ADATA(JJ + 33) - 0.5 * DELT              DCSMON    418
         IADATA(JJ + 54) = 1.0                                          DCSMON    419
C                                                      Reclosure timer  DCSMON    420
         IF (IADATA(JJ + 56) .NE. -1 .AND.                              DCSMON    421
     +       IADATA(JJ + 72) .EQ. 1) THEN                               DCSMON    422
           ADATA(JJ + 55) = TS + ADATA(JJ + 34) - 0.5 * DELT            DCSMON    423
           IADATA(JJ + 56) = 1                                          DCSMON    424
         ENDIF                                                          DCSMON    425
C                                                        Remote timers  DCSMON    426
         IF (NRMRLY .NE. 0) CALL RTIMER (KK, NRMRLY)                    DCSMON    427
C---------------------------------------------------------------------  DCSMON    428
C                                           Check to trip main circuit  DCSMON    429
C                                                                       DCSMON    430
4000     IF (ADATA(JJ + 53) .GT. TS) GOTO 6000                          DCSMON    431
C                                                                       DCSMON    432
         IF (IASWX .EQ. 0) THEN                                         DCSMON    433
           WRITE (ISWFA, 9100) TS                                       DCSMON    434
           NAWR = NAWR + 1                                              DCSMON    435
           IASWX = 1                                                    DCSMON    436
         ENDIF                                                          DCSMON    437
C                                                                       DCSMON    438
         IADATA(JJ + 54) = -1                                           DCSMON    439
         WRITE (IU6, 7000)                                              DCSMON    440
     +         NLFI, (INAME(NI3 + IK), IK = 1, 3),                      DCSMON    441
     +         NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID                  DCSMON    442
         IF (IADATA(JJ + 8) .EQ. 1) THEN                                DCSMON    443
C                                                       Trip one phase  DCSMON    444
           WRITE (IU6, 8700) TS                                         DCSMON    445
           WRITE (ISWFA, 9200) IBUS, JBUS, CID,                         DCSMON    446
     +                         (ADATA(JJ + IK), IK = 35, 40)            DCSMON    447
         ELSE                                                           DCSMON    448
C                                                         Trip circuit  DCSMON    449
           WRITE (IU6, 8800) TS                                         DCSMON    450
           NJSELI = IADATA(JJ + 63)                                     DCSMON    451
           IF (NJSELI .NE. 0) THEN                                      DCSMON    452
             WRITE (ISWFA, 9300) IBUS, JBUS, CID                        DCSMON    453
           ELSE                                                         DCSMON    454
             WRITE (ISWFA, 9400) IBUS, JBUS, CID                        DCSMON    455
           ENDIF                                                        DCSMON    456
           NAWR = NAWR + 1                                              DCSMON    457
         ENDIF                                                          DCSMON    458
C---------------------------------------------------------------------  DCSMON    459
C                                        Check to trip remote circuits  DCSMON    460
C                                                                       DCSMON    461
5000     IF (NRMRLY .NE. 0 .AND. IADATA(JJ + 73) .NE. -1) THEN          DCSMON    462
           IPOINT = 73                                                  DCSMON    463
           CALL RETRIP (KK, JJ, NRMRLY, IPOINT)                         DCSMON    464
         ENDIF                                                          DCSMON    465
C---------------------------------------------------------------------  DCSMON    466
C                                        Check to reclose main circuit  DCSMON    467
C                                                                       DCSMON    468
         IF (IADATA(JJ + 56) .EQ. 1) THEN                               DCSMON    469
           IF (ADATA(JJ + 55) .GT. TS) GOTO 6000                        DCSMON    470
           IADATA(JJ + 56) = -1                                         DCSMON    471
C                                                                       DCSMON    472
           IF (IASWX .EQ. 0) THEN                                       DCSMON    473
             WRITE (ISWFA, 9100) TS                                     DCSMON    474
             NAWR = NAWR + 1                                            DCSMON    475
             IASWX = 1                                                  DCSMON    476
           ENDIF                                                        DCSMON    477
C                                                                       DCSMON    478
           WRITE (IU6, 7000)                                            DCSMON    479
     +           NLFI, (INAME(NI3 + IK), IK = 1, 3),                    DCSMON    480
     +           NLFJ, (INAME(NJ3 + IK), IK = 1, 3), CID                DCSMON    481
C                                                                       DCSMON    482
           IF (IADATA(JJ + 8) .EQ. 1) THEN                              DCSMON    483
C                                                    Reclose one phase  DCSMON    484
             WRITE (IU6, 8900) TS                                       DCSMON    485
             WRITE (ISWFA, 9200) IBUS, JBUS, CID,                       DCSMON    486
     +                           (ADATA(JJ + IK), IK = 57, 62)          DCSMON    487
           ELSE                                                         DCSMON    488
C                                                      Reclose circuit  DCSMON    489
             WRITE (IU6, 9000) TS                                       DCSMON    490
             NJSELI = IADATA(JJ + 63)                                   DCSMON    491
             IF (NJSELI .NE. 0) THEN                                    DCSMON    492
               WRITE (ISWFA, 9500) IBUS, JBUS, CID                      DCSMON    493
             ELSE                                                       DCSMON    494
               WRITE (ISWFA, 9600) IBUS, JBUS, CID                      DCSMON    495
             ENDIF                                                      DCSMON    496
             NAWR = NAWR + 1                                            DCSMON    497
           ENDIF                                                        DCSMON    498
C                                                       Initialization  DCSMON    499
           ADATA(JJ + 41) = 0.0                                         DCSMON    500
           ADATA(JJ + 43) = 0.0                                         DCSMON    501
           ADATA(JJ + 45) = 0.0                                         DCSMON    502
           ADATA(JJ + 47) = 0.0                                         DCSMON    503
           ADATA(JJ + 49) = 0.0                                         DCSMON    504
           ADATA(JJ + 51) = 0.0                                         DCSMON    505
           ADATA(JJ + 53) = 0.0                                         DCSMON    506
C                                                                       DCSMON    507
           IADATA(JJ + 42) = 0                                          DCSMON    508
           IADATA(JJ + 44) = 0                                          DCSMON    509
           IADATA(JJ + 46) = 0                                          DCSMON    510
           IADATA(JJ + 48) = 0                                          DCSMON    511
           IADATA(JJ + 50) = 0                                          DCSMON    512
           IADATA(JJ + 52) = 0                                          DCSMON    513
           IADATA(JJ + 54) = 0                                          DCSMON    514
C                                                                       DCSMON    515
           IADATA(JJ + 70) = 0                                          DCSMON    516
           IADATA(JJ + 71) = 0                                          DCSMON    517
C                                                                       DCSMON    518
         ENDIF                                                          DCSMON    519
C---------------------------------------------------------------------  DCSMON    520
6000   CONTINUE                                                         DCSMON    521
C---------------------------------------------------------------------  DCSMON    522
C                                                 Formats and messages  DCSMON    523
C                                                                       DCSMON    524
7000   FORMAT (' *** DSCI RELAY CIRCUIT FROM: ', I6, 1X, 3A4,           DCSMON    525
     +         '  TO: ', I6, 1X, 3A4, '  ID: ', A2)                     DCSMON    526
7100   FORMAT ('     AT BUS: ', I6, 1X, 3A4, '  AND TIME: ', F8.5)      DCSMON    527
7200   FORMAT ('     CURRENT INCREASED TO ABOVE SUPERVISORY LEVEL')     DCSMON    528
7300   FORMAT ('     CURRENT DECREASED TO BELOW SUPERVISORY LEVEL')     DCSMON    529
7400   FORMAT ('     APPARENT IMPEDANCE MOVED OUTSIDE ZONES')           DCSMON    530
7500   FORMAT ('     APPARENT IMPEDANCE MOVED INTO ZONES: ',            DCSMON    531
     +         4(A1, 1X))                                               DCSMON    532
7600   FORMAT ('     TIMER(S) STARTED FOR ZONE(S): ', 4(A1, 1X))        DCSMON    533
7700   FORMAT ('     TIMER(S) RESET FOR ZONE(S): ', 4(A1, 1X))          DCSMON    534
7800   FORMAT ('     TIMER(S) TIMED OUT FOR ZONE(S): ', 4(A1, 1X))      DCSMON    535
7900   FORMAT ('     TRIPPING INITIATED BY SUPERVISORY OVERCURRENT')    DCSMON    536
8000   FORMAT ('     TRIPPING INITIATED BY ZONE 1')                     DCSMON    537
8100   FORMAT ('     ZONE 2 TRIP IS BLOCKED BY REVERSE REACH')          DCSMON    538
8200   FORMAT ('     ZONE 2 TRIP IS BLOCKED BY OUT OF STEP BLOCKING')   DCSMON    539
8300   FORMAT ('     ZONE 2 TRIP IS BLOCKED BY SUPERVISORY ',           DCSMON    540
     +         'OVERCURRENT')                                           DCSMON    541
8400   FORMAT ('     ZONE 2 TIMER IS RESET')                            DCSMON    542
8500   FORMAT ('     TRIPPING INITIATED BY ZONE 2')                     DCSMON    543
8600   FORMAT ('     BREAKER AND RECLOSURE TIMERS ARE STARTED')         DCSMON    544
8700   FORMAT ('     TRIPPED AT TIME = ', F8.5)                         DCSMON    545
8800   FORMAT ('     ONE PHASE TRIPPED AT TIME = ', F8.5)               DCSMON    546
8900   FORMAT ('     RECLOSED AT TIME = ', F8.5)                        DCSMON    547
9000   FORMAT ('     ONE PHASE RECLOSED AT TIME = ', F8.5)              DCSMON    548
C---------------------------------------------------------------------  DCSMON    549
9100   FORMAT (F10.5)                                                   DCSMON    550
9200   FORMAT ('MLI', 1X, 2I5, A2, 2X, 6F10.5)                          DCSMON    551
9300   FORMAT ('DPIA', 2I5, 1X, A2)                                     DCSMON    552
9400   FORMAT ('DLIA', 2I5, 1X, A2)                                     DCSMON    553
9500   FORMAT ('RPIA', 2I5, 1X, A2)                                     DCSMON    554
9600   FORMAT ('RLIA', 2I5, 1X, A2)                                     DCSMON    555
C---------------------------------------------------------------------  DCSMON    556
       RETURN                                                           DCSMON    557
       END                                                              DCSMON    558
