CFPRIME OCRINT                                                          OCRINT      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                                                                       OCRINT      3
       SUBROUTINE OCRINT (IEBK)                                         OCRINT      4
CD                                                                      OCRINT      5
CD  This subroutine initializes the overcurrent relay data arrays       OCRINT      6
CD  including remote tripping arrays.                                   OCRINT      7
CD                                                                      OCRINT      8
C---------------------------------------------------------------------  OCRINT      9
C                                                        Include files  OCRINT     10
C                                                                       OCRINT     11
      INCLUDE 'PARX.INS'                                                OCRINT     12
      INCLUDE 'CNPT.INS'                                                OCRINT     13
      INCLUDE 'CNAUTO.INS'                                              OCRINT     14
      INCLUDE 'CNVOLT.INS'                                              OCRINT     15
      INCLUDE 'CNNNEW.INS'                                              OCRINT     16
      INCLUDE 'CNSTN.INS'                                               OCRINT     17
      INCLUDE 'CNB19.INS'                                               OCRINT     18
      INCLUDE 'CNUNIT.INS'                                              OCRINT     19
      INCLUDE 'CNLFDA.INS'                                              OCRINT     20
      INCLUDE 'CNSELI.INS'                                              OCRINT     21
      INCLUDE 'CNMSG.INS'                                               OCRINT     22
C---------------------------------------------------------------------  OCRINT     23
C                                                      Local Variables  OCRINT     24
C                                                                       OCRINT     25
       REAL          TT(2)                                              OCRINT     26
       COMPLEX       PQ                                                 OCRINT     27
       CHARACTER*2   CID, CKK                                           OCRINT     28
C                                                                       OCRINT     29
       EQUIVALENCE (PQ, TT(1), PP), (TT(2), QQ)                         OCRINT     30
C---------------------------------------------------------------------  OCRINT     31
C                                                       Initialization  OCRINT     32
C                                                                       OCRINT     33
C---------------------------------------------------------------------  OCRINT     34
CD                                                                      OCRINT     35
CD  1.  Store the internal bus numbers                                  OCRINT     36
CD                                                                      OCRINT     37
       DO 5000 II = LOCRE, NOCRE                                        OCRINT     38
         JJ = IDATPT(II)                                                OCRINT     39
C                                                                       OCRINT     40
         NLFI = IADATA(JJ + 1)                                          OCRINT     41
         NLFJ = IADATA(JJ + 2)                                          OCRINT     42
         NPROGI = NNEW(NLFI)                                            OCRINT     43
         NPROGJ = NNEW(NLFJ)                                            OCRINT     44
         IADATA(JJ + 1) = NPROGI                                        OCRINT     45
         IADATA(JJ + 2) = NPROGJ                                        OCRINT     46
         NI3 = NPROGI * 3                                               OCRINT     47
         NJ3 = NPROGJ * 3                                               OCRINT     48
C---------------------------------------------------------------------  OCRINT     49
CD                                                                      OCRINT     50
CD  2.  Store the branch parameters and branch current                  OCRINT     51
CD                                                                      OCRINT     52
         ITFK = IADATA(JJ + 3)                                          OCRINT     53
         CALL UNPACK (CID, JJJ, ITFK)                                   OCRINT     54
C                                                                       OCRINT     55
         CALL LOLINE (NPROGI, NPROGJ, CID, JNL)                         OCRINT     56
C                                                                       OCRINT     57
         IF (JNL .EQ. 0) THEN                                           OCRINT     58
           IEBK = 1                                                     OCRINT     59
           WRITE (MSG(1), 6100) NLFI, INAME(NI3 - 2), INAME(NI3 - 1),   OCRINT     60
     +                          INAME(NI3), NLFJ, INAME(NJ3 - 2),       OCRINT     61
     +                          INAME(NJ3 - 1), INAME(NJ3)              OCRINT     62
           WRITE (MSG(2), 6200) CID                                     OCRINT     63
           CALL PRTMSG (2)                                              OCRINT     64
         ELSE                                                           OCRINT     65
C                                                                       OCRINT     66
           JNL5 = IABS(JNL) * 5                                         OCRINT     67
           ITFK = LFTB(JNL5 - 4)                                        OCRINT     68
           CALL UNPACK(CKK,NJSELI,ITFK)                                 OCRINT     69
           IF (NJSELI .NE. 0) THEN                                      OCRINT     70
             ADATA(JJ + 23) = EQPI(1, NJSELI)                           OCRINT     71
             ADATA(JJ + 24) = - EQPI(2, NJSELI)                         OCRINT     72
             ADATA(JJ + 25) = EQPI(3, NJSELI)                           OCRINT     73
             ADATA(JJ + 26) = EQPI(4, NJSELI)                           OCRINT     74
           ELSE                                                         OCRINT     75
             ADATA(JJ + 23) = GA(JNL5 - 2)                              OCRINT     76
             ADATA(JJ + 24) = - BA(JNL5 - 1)                            OCRINT     77
             ADATA(JJ + 25) = 0.0                                       OCRINT     78
             ADATA(JJ + 26) = BCHG(JNL5) / 2.0                          OCRINT     79
           ENDIF                                                        OCRINT     80
           IADATA(JJ + 27) = NJSELI                                     OCRINT     81
C                                                                       OCRINT     82
           IBUS = IADATA(JJ + 1)                                        OCRINT     83
           JBUS = IADATA(JJ + 2)                                        OCRINT     84
           PQ = VOLT(IBUS)                                              OCRINT     85
           EIR = PP                                                     OCRINT     86
           EII = QQ                                                     OCRINT     87
           PQ = VOLT(JBUS)                                              OCRINT     88
           EJR = PP                                                     OCRINT     89
           EJI = QQ                                                     OCRINT     90
           GIJ = ADATA(JJ + 23)                                         OCRINT     91
           BIJ = ADATA(JJ + 24)                                         OCRINT     92
           GIO = ADATA(JJ + 25)                                         OCRINT     93
           BIO = ADATA(JJ + 26)                                         OCRINT     94
           GT = GIJ + GIO                                               OCRINT     95
           BT = BIJ + BIO                                               OCRINT     96
           C1R = EIR * GT - EII * BT                                    OCRINT     97
           C1I = EIR * BT + EII * GT                                    OCRINT     98
           C2R = EJR * GIJ - EJI * BIJ                                  OCRINT     99
           C2I = EJR * BIJ + EJI * GIJ                                  OCRINT    100
           CTR = C1R - C2R                                              OCRINT    101
           CTI = C1I - C2I                                              OCRINT    102
           CURR = SQRT (CTR * CTR + CTI * CTI)                          OCRINT    103
           ADATA(JJ + 28) = CURR                                        OCRINT    104
C---------------------------------------------------------------------  OCRINT    105
CD                                                                      OCRINT    106
CD  3.  Convert cycles to seconds                                       OCRINT    107
CD                                                                      OCRINT    108
           ADATA(JJ + 6) = ADATA(JJ + 6) / FQBASE                       OCRINT    109
           ADATA(JJ + 8) = ADATA(JJ + 8) / FQBASE                       OCRINT    110
           ADATA(JJ + 10) = ADATA(JJ + 10) / FQBASE                     OCRINT    111
           ADATA(JJ + 12) = ADATA(JJ + 12) / FQBASE                     OCRINT    112
           ADATA(JJ + 14) = ADATA(JJ + 14) / FQBASE                     OCRINT    113
           ADATA(JJ + 16) = ADATA(JJ + 16) / FQBASE                     OCRINT    114
           ADATA(JJ + 17) = ADATA(JJ + 17) / FQBASE                     OCRINT    115
C---------------------------------------------------------------------  OCRINT    116
CD                                                                      OCRINT    117
CD  4.  Sanity check of OCRE characteristic                             OCRINT    118
CD                                                                      OCRINT    119
           NPOINT = 0                                                   OCRINT    120
           IOFSET = 3                                                   OCRINT    121
C                                             Compute number of points  OCRINT    122
C                                           on the OCRE characteristic  OCRINT    123
           DO 2000 IJ = 1, 6                                            OCRINT    124
             IOFSET = IOFSET + 2                                        OCRINT    125
             IF (ADATA(JJ + IOFSET) .LE. 0.0) THEN                      OCRINT    126
               NPOINT = IJ - 1                                          OCRINT    127
               GOTO 2100                                                OCRINT    128
             ENDIF                                                      OCRINT    129
2000       CONTINUE                                                     OCRINT    130
           NPOINT = 6                                                   OCRINT    131
C                                                  At least two points  OCRINT    132
C                                                    must be specified  OCRINT    133
2100       IF (NPOINT .LE. 1) GOTO 3000                                 OCRINT    134
C                                             Time to close relay must  OCRINT    135
C                               be positive and decrease progressively  OCRINT    136
C                                                                       OCRINT    137
C                              Current points beyond the first must be  OCRINT    138
C                          greater than 1.0 and increase progressively  OCRINT    139
C                                                                       OCRINT    140
           IOFSET = 6                                                   OCRINT    141
           DO 2200 IJ = 2, NPOINT                                       OCRINT    142
             IOFSET = IOFSET + 2                                        OCRINT    143
             IF (ADATA(JJ + IOFSET) .LT. 0.0) GOTO 3000                 OCRINT    144
             IF (ADATA(JJ + IOFSET - 1) .LE. 1.0) GOTO 3000             OCRINT    145
             IF (IJ .EQ. 2) THEN                                        OCRINT    146
               IF (ADATA(JJ + IOFSET) .GE. 3600.0) GOTO 3000            OCRINT    147
             ELSE                                                       OCRINT    148
               IF (ADATA(JJ + IOFSET) .GE.                              OCRINT    149
     +             ADATA(JJ + IOFSET - 2)) GOTO 3000                    OCRINT    150
               IF (ADATA(JJ + IOFSET - 1) .LE.                          OCRINT    151
     +             ADATA(JJ + IOFSET - 3)) GOTO 3000                    OCRINT    152
             ENDIF                                                      OCRINT    153
2200       CONTINUE                                                     OCRINT    154
C                                           Store the number of points  OCRINT    155
C                                           in the OCRE characteristic  OCRINT    156
           IADATA(JJ + 22) = NPOINT                                     OCRINT    157
C                                                                       OCRINT    158
           GOTO 4000                                                    OCRINT    159
C                                         Error in OCRE characteristic  OCRINT    160
3000       IEBK = 1                                                     OCRINT    161
           WRITE (MSG(1), 6300)                                         OCRINT    162
           WRITE (MSG(2), 6400) NLFI, INAME(NI3 - 2), INAME(NI3 - 1),   OCRINT    163
     +                          INAME(NI3), NLFJ, INAME(NJ3 - 2),       OCRINT    164
     +                          INAME(NJ3 - 1), INAME(NJ3), CID         OCRINT    165
           CALL PRTMSG (2)                                              OCRINT    166
C---------------------------------------------------------------------  OCRINT    167
CD                                                                      OCRINT    168
CD  5.  Initialize relay status, position                               OCRINT    169
CD      and the status of remote breakers                               OCRINT    170
CD                                                                      OCRINT    171
4000       IADATA(JJ + 18) = 0                                          OCRINT    172
           IADATA(JJ + 19) = 0                                          OCRINT    173
           IADATA(JJ + 21) = 0                                          OCRINT    174
C---------------------------------------------------------------------  OCRINT    175
CD                                                                      OCRINT    176
CD  6.  Initialize remote tripping scheme                               OCRINT    177
CD                                                                      OCRINT    178
           NRMRLY = IADATA(JJ + 4)                                      OCRINT    179
           IF (NRMRLY .NE. 0) THEN                                      OCRINT    180
             KK = JJ + 28                                               OCRINT    181
             CALL REMINT (KK, NRMRLY)                                   OCRINT    182
           ENDIF                                                        OCRINT    183
C                                                                       OCRINT    184
         ENDIF                                                          OCRINT    185
5000   CONTINUE                                                         OCRINT    186
C---------------------------------------------------------------------  OCRINT    187
C                                                       Error messages  OCRINT    188
C                                                                       OCRINT    189
6100   FORMAT (' *** ERROR OCRE CIRCUIT FROM: ', I6, 1X, 3A4,           OCRINT    190
     +         '  TO: ', I6, 1X, 3A4)                                   OCRINT    191
6200   FORMAT ('     WITH CIRCUIT ID: ', A2, ' DOES NOT EXIST.')        OCRINT    192
6300   FORMAT (' *** ERROR IN OCRE RELAY CHARACTERISTIC')               OCRINT    193
6400   FORMAT ('     CIRCUIT FROM: ', I6, 1X, 3A4, ' TO: ', I6,         OCRINT    194
     +         1X, 3A4, ' ID: ', A2)                                    OCRINT    195
C---------------------------------------------------------------------  OCRINT    196
       RETURN                                                           OCRINT    197
       END                                                              OCRINT    198
