CFPRIME SCGDAT                                                          SCGDAT      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE SCGDAT(IEBK)                                           SCGDAT      3
CD                                                                      SCGDAT      4
CD    THIS SUBROUTINE READS IN THE SERIES CAPACITOR RELAY DATA CARD     SCGDAT      5
CD                                                                      SCGDAT      6
CD    IEBK IS AN ERROR INDICATOR                                        SCGDAT      7
CD    IEBK = 0 NO ERROR                                                 SCGDAT      8
CD    IEBK = 1 WHEN                                                     SCGDAT      9
CD             SERIES CAPACITOR GAP RELAY BUS NOT FOUND                 SCGDAT     10
CD             RELAY SCHEME EXCEEDS THE PROGRAM LIMIT                   SCGDAT     11
CD                                                                      SCGDAT     12
CD                                                                      SCGDAT     13
CD     LSCGRE          Starting position of IDATPT array  of SCGR relay SCGDAT     14
CD                     scheme, LSCGRE is in the common labelled PT of   SCGDAT     15
CD                     include file CNPT.                               SCGDAT     16
CD                                                                      SCGDAT     17
CD     NSCGRE          Finishing position of IDATPT array of SCGR relay SCGDAT     18
CD                     scheme, NSCGRE is in common labelled AUTO of     SCGDAT     19
CD                     include file CNAUTO.                             SCGDAT     20
CD                                                                      SCGDAT     21
CD     let k = k-th SCGR RELAY                                          SCGDAT     22
CD                                                                      SCGDAT     23
CD     N = IDATPT(k)    IDATPT is the array that stores the start       SCGDAT     24
CD                      position of the K-TH SCGR relay scheme data     SCGDAT     25
CD                                                                      SCGDAT     26
CD                                                                      SCGDAT     27
CD ADATA(N+1)=ICD1RG     LOCAL RELAY TRIP STATUS:                       SCGDAT     28
CD                       1 = CAPACITOR GAP NOT FIRED                    SCGDAT     29
CD                       2 = CAPACITOR GAP PERMANENTLY FIRED REMOTE     SCGDAT     30
CD                           RELAY NOT TRIPPED                          SCGDAT     31
CD                       3 = CAPACITOR GAP PERNANEMTLY FIRED REMOTE     SCGDAT     32
CD                           RELAY TRIPPED                              SCGDAT     33
CD                       4 = GAP SHORTED I .GT. IFC PERM TIMER STARTED  SCGDAT     34
CD                       5 = GAP SHORTED I .LT. IRE PERM TIMER STARTED  SCGDAT     35
CD                       6 = GAP SHORTED I .LT. IRE REINSERTION TIMER   SCGDAT     36
CD                           STARTED                                    SCGDAT     37
CD                                                                      SCGDAT     38
CD IADATA(N+2)=IBUSRG    LEFT HAND BUS NUMBER                           SCGDAT     39
CD IADATA(N+3)=JBUSRG    RIGHT HAND BUS NUMBER                          SCGDAT     40
CD IADATA(N+4)=IPARRG    PARALLEL IDENTIFICATION FOR THIS LINE          SCGDAT     41
CD IADATA(N+5)(=KSECRG   SECTION IDENTIFICATION FOR THIS CAPACITOR      SCGDAT     42
CD IADATA(N+6)(=NRECRG   MAXIMUM NUMBER OF REINSERTION ATTEMPTS.  CAPS  SCGDAT     43
CD                       WILL BE PERMANENTLY SHORT CIRCUITED WHEN THIS  SCGDAT     44
CD                       NUMBER IS REACHED.                             SCGDAT     45
CD IADATA(N+7)=ICD3RG    COUNTS THE NUMBER OF REINSERTION ATTEMPTS      SCGDAT     46
CD IADATA(N+8)=KBORRG    TRANSFER TRIP STATUS                           SCGDAT     47
CD                       1 = 'B' REMOTE RELAY TRANSFER TRIP ACTIVATED   SCGDAT     48
CD                               THE FIRST TIME THE GAP IS FIRED.       SCGDAT     49
CD                       2 = 'E' REMOTE RELAY TRANSFER TRIP ACTIVATED   SCGDAT     50
CD                               AFTER GAP IS PERMANENTLY SHORTED       SCGDAT     51
CD                       3 = REMOTE RELAY TRANSFER TRIP ACTIVATED       SCGDAT     52
CD                       4 = REMOTE RELAY TRANSFER TRIP COMPLETE        SCGDAT     53
CD                                                                      SCGDAT     54
CD ADATA(N+9)=GPFRG      GAP FIRING CURRENT PER UNIT                    SCGDAT     55
CD                                                                      SCGDAT     56
CD ADATA(N+10)=RINCRG    GAP REINSETION CURRENT PER UNIT                SCGDAT     57
CD                                                                      SCGDAT     58
CD ADATA(N+11)=RETDRG    REINSERTION TIME DELAY IN CYCLES.  CAPACITOR   SCGDAT     59
CD                       CURRENT MUST REMAIN BELOW REINSERTION CURRENT  SCGDAT     60
CD                       FOR THIS LENGTH OF TIME BEFORE CAPS ARE        SCGDAT     61
CD                       REINSERTED.                                    SCGDAT     62
CD                                                                      SCGDAT     63
CD ADATA(N+12)=PERMRG    PERMANENT SHORTING SWITCH TIME DELAY.  IF GAP  SCGDAT     64
CD                       REMAINS FIRED FOR THIS LENGTH OF TIME, IT WILL SCGDAT     65
CD                       BE PERMANENTLY SHORT CIRCUITED.                SCGDAT     66
CD                                                                      SCGDAT     67
CD ADATA(N+13)=TIMPRG    PERMANENT SHORT CIRCUIT TIMER                  SCGDAT     68
CD                                                                      SCGDAT     69
CD ADATA(N+14)=TIMRRG    REINSERTION TIMER                              SCGDAT     70
CD                                                                      SCGDAT     71
CD ADATA(N+15)           NO. OF  REMOTE RELAY                           SCGDAT     72
CD                                                                      SCGDAT     73
CD ADATA(N+16)=TTRPG     REMOTE RELAY TRIP FLAG                         SCGDAT     74
CD                                                                      SCGDAT     75
CD                                                                      SCGDAT     76
CD ADATA(N+17)=GIJARG                                                   SCGDAT     77
CD ADATA(N+18)=BIJARG                                                   SCGDAT     78
CD ADATA(N+19)=GIOARG    PI EQUIVALENT ADMITTANCES FOR TOTAL LINE       SCGDAT     79
CD ADATA(N+20)=BIOARG                                                   SCGDAT     80
CD ADATA(N+21)=GJOARG                                                   SCGDAT     81
CD ADATA(N+22)=BJOARG                                                   SCGDAT     82
CD                                                                      SCGDAT     83
CD ADATA(N+23)=GIJPRG                                                   SCGDAT     84
CD ADATA(N+24)=BIJPRG                                                   SCGDAT     85
CD ADATA(N+25)=GIOPRG    PI EQUIVALENT ADMITTANCES FOR LINE SECTION     SCGDAT     86
CD ADATA(N+26)=BIOPRG    TO THE LEFT OF THE CAPACITOR                   SCGDAT     87
CD ADATA(N+27)=GJOPRG                                                   SCGDAT     88
CD ADATA(N+28)=BJOPRG                                                   SCGDAT     89
CD                                                                      SCGDAT     90
CD ADATA(N+29)=GIJSRG                                                   SCGDAT     91
CD ADATA(N+30)=BIJSRG                                                   SCGDAT     92
CD ADATA(N+31)=GIOSRG    PI EQUIVALENT ADMITTANCES FOR TOTAL LINE       SCGDAT     93
CD ADATA(N+32)=BIOSRG    WITH CAPACITOR SHORT CIRCUITED                 SCGDAT     94
CD ADATA(N+33)=GJOSRG                                                   SCGDAT     95
CD ADATA(N+34)=BJOSRG                                                   SCGDAT     96
CD                                                                      SCGDAT     97
CD                                                                      SCGDAT     98
      INCLUDE 'PARX.INS'                                                SCGDAT     99
      INCLUDE 'CNPT.INS'                                                SCGDAT    100
      INCLUDE 'CNMNEW.INS'                                              SCGDAT    101
      INCLUDE 'CNAUTO.INS'                                              SCGDAT    102
      INCLUDE 'CNLFDA.INS'                                              SCGDAT    103
      INCLUDE 'CNB19.INS'                                               SCGDAT    104
      INCLUDE 'CNFLAG.INS'                                              SCGDAT    105
      INCLUDE 'CNPARX.INS'                                              SCGDAT    106
      INCLUDE 'CNREN.INS'                                               SCGDAT    107
      INCLUDE 'CNUNIT.INS'                                              SCGDAT    108
      INCLUDE 'CNMSG.INS'                                               SCGDAT    109
C                                                                       SCGDAT    110
      CHARACTER*80 CARD1,CARD3                                          SCGDAT    111
      CHARACTER*12 BNAME1,BNAME2                                        SCGDAT    112
      CHARACTER*2 CID2,SID2                                             SCGDAT    113
      CHARACTER*1 TFLAG,B,E,BLK                                         SCGDAT    114
      INTEGER*4 ICID,ISID                                               SCGDAT    115
      CHARACTER*5 EDATA                                                 SCGDAT    116
      CHARACTER*3 ESC,MPI                                               SCGDAT    117
C                                                                       SCGDAT    118
C                                                                       SCGDAT    119
      DATA EDATA/'EDATA'/,B/'B'/,E/'E'/,BLK/' '/,ESC/'ESC'/,MPI/'MPI'/  SCGDAT    120
CD                                                                      SCGDAT    121
CD STEP 1. READ SERIES CAPACITOR RELAY DATA CARDS                       SCGDAT    122
CD                                                                      SCGDAT    123
      LDEB=.FALSE.                                                      SCGDAT    124
C                                                                       SCGDAT    125
  110 CONTINUE                                                          SCGDAT    126
      CALL GETLIN(IU54,CARD1)                                           SCGDAT    127
      IF(CARD1(1:5).NE.EDATA)THEN                                       SCGDAT    128
       IF(KLFO.EQ.0)THEN                                                SCGDAT    129
           READ (CARD1,2010) NLFI,NLFJ,CID2,SID2,TFLAG                  SCGDAT    130
           IF(NLFI.EQ.0.OR.NLFJ.EQ.0                                    SCGDAT    131
     &.OR.MNEW(NLFI).EQ.0.OR.MNEW(NLFJ).EQ.0)THEN                       SCGDAT    132
            IEBK=1                                                      SCGDAT    133
            WRITE(MSG(1),2030)                                          SCGDAT    134
            MSG(2)=CARD1                                                SCGDAT    135
            CALL PRTMSG(2)                                              SCGDAT    136
            CALL GETLIN(IU54,CARD1)                                     SCGDAT    137
            KSWITC=0                                                    SCGDAT    138
C                                                                       SCGDAT    139
 115        CALL GETLIN(IU54,CARD1)                                     SCGDAT    140
            IF(CARD1(1:3).EQ.ESC)THEN                                   SCGDAT    141
             GOTO 110                                                   SCGDAT    142
            ELSE                                                        SCGDAT    143
             GOTO 115                                                   SCGDAT    144
            ENDIF                                                       SCGDAT    145
           ENDIF                                                        SCGDAT    146
       ELSE                                                             SCGDAT    147
           READ (CARD1,2020) BNAME1,BNAME2,CID2,SID2,TFLAG              SCGDAT    148
           CALL CHKBUS(BNAME1,NLFI)                                     SCGDAT    149
           CALL CHKBUS(BNAME2,NLFJ)                                     SCGDAT    150
           IF(NLFI.EQ.0.OR.NLFJ.EQ.0)THEN                               SCGDAT    151
            IEBK=1                                                      SCGDAT    152
            WRITE(MSG(1),2030)                                          SCGDAT    153
            MSG(2)=CARD1                                                SCGDAT    154
            CALL PRTMSG(2)                                              SCGDAT    155
 125        CALL GETLIN(IU54,CARD1)                                     SCGDAT    156
            IF(CARD1(1:3).EQ.ESC)THEN                                   SCGDAT    157
             GOTO 110                                                   SCGDAT    158
            ELSE                                                        SCGDAT    159
             GOTO 125                                                   SCGDAT    160
            ENDIF                                                       SCGDAT    161
           ENDIF                                                        SCGDAT    162
       ENDIF                                                            SCGDAT    163
CD                                                                      SCGDAT    164
CD STEP 2. STORE THE DATA INTO THE PERMANENT ARRAY                      SCGDAT    165
CD                                                                      SCGDAT    166
      IF(NAUT.LT.MAXSET)THEN                                            SCGDAT    167
C                                                                       SCGDAT    168
      NAUT=NAUT+1                                                       SCGDAT    169
C                                                                       SCGDAT    170
      LDSTAT=0                                                          SCGDAT    171
      NPROG=MNEW(NLFI)                                                  SCGDAT    172
      IF(JBSTAT(NPROG).GT.2)LDSTAT=10                                   SCGDAT    173
      IF(LDSTAT.EQ.0)THEN                                               SCGDAT    174
      NPROG=MNEW(NLFJ)                                                  SCGDAT    175
      IF(JBSTAT(NPROG).GT.2)LDSTAT=10                                   SCGDAT    176
      ENDIF                                                             SCGDAT    177
      IADATA(JLNA+1)=LDSTAT                                             SCGDAT    178
      NAUTB=NAUTB+2                                                     SCGDAT    179
      NAUBUS(NAUTB-1)=NLFI                                              SCGDAT    180
      NAUBUS(NAUTB)=NLFJ                                                SCGDAT    181
      LRTEMP=LRTEMP+1                                                   SCGDAT    182
      IDATPT(LRTEMP)=JLNA                                               SCGDAT    183
C                                                                       SCGDAT    184
      IADATA(JLNA+2)=NLFI                                               SCGDAT    185
      IADATA(JLNA+3)=NLFJ                                               SCGDAT    186
      IADATA(JLNA+8)=0                                                  SCGDAT    187
      IF(TFLAG.EQ.B.OR.TFLAG.EQ.BLK)IADATA(JLNA+8)=1                    SCGDAT    188
      IF(TFLAG.EQ.E)IADATA(JLNA+8)=2                                    SCGDAT    189
      CALL PACK(CID2,0,ICID)                                            SCGDAT    190
      CALL PACK(SID2,0,ISID)                                            SCGDAT    191
      IADATA(JLNA+4)=ICID                                               SCGDAT    192
      IADATA(JLNA+5)=ISID                                               SCGDAT    193
C                                                                       SCGDAT    194
      CALL GETLIN(IU54,CARD1)                                           SCGDAT    195
      READ(CARD1,2050) ADATA(JLNA+9),ADATA(JLNA+10),ADATA(JLNA+11)      SCGDAT    196
     &,ADATA(JLNA+12),IADATA(JLNA+6)                                    SCGDAT    197
      JSWITC=JLNA+15                                                    SCGDAT    198
      JLNA=JLNA+34                                                      SCGDAT    199
      KSWITC=0                                                          SCGDAT    200
CD                                                                      SCGDAT    201
CD STEP 3. READ IN THE REMOTE RELAYS                                    SCGDAT    202
CD                                                                      SCGDAT    203
 150  CALL GETLIN(IU54,CARD1)                                           SCGDAT    204
      IF(CARD1(1:3).EQ.ESC)THEN                                         SCGDAT    205
       IADATA(JSWITC)=KSWITC                                            SCGDAT    206
      ELSE                                                              SCGDAT    207
       IF(CARD1(1:3).EQ.MPI)THEN                                        SCGDAT    208
        CALL GETLIN(IU54,CARD3)                                         SCGDAT    209
       ENDIF                                                            SCGDAT    210
       CALL SWIDAT(CARD1,CARD3,KSWITC,IEBK)                             SCGDAT    211
       GOTO 150                                                         SCGDAT    212
      ENDIF                                                             SCGDAT    213
C                                                                       SCGDAT    214
      GOTO 110                                                          SCGDAT    215
C                                                                       SCGDAT    216
C                                                                       SCGDAT    217
      ELSE                                                              SCGDAT    218
       WRITE(MSG(1),2040) MXASCH                                        SCGDAT    219
       MSG(2)=CARD1                                                     SCGDAT    220
       CALL PRTMSG(2)                                                   SCGDAT    221
       CALL GETLIN(IU54,CARD1)                                          SCGDAT    222
       IEBK=1                                                           SCGDAT    223
 135     CALL GETLIN(IU54,CARD1)                                        SCGDAT    224
          IF(CARD1(1:3).EQ.ESC)THEN                                     SCGDAT    225
             GOTO 110                                                   SCGDAT    226
          ELSE                                                          SCGDAT    227
             GOTO 135                                                   SCGDAT    228
          ENDIF                                                         SCGDAT    229
       ENDIF                                                            SCGDAT    230
      ENDIF                                                             SCGDAT    231
C                                                                       SCGDAT    232
CD                                                                      SCGDAT    233
CD STEP 4. UPDATE RELAY COUNTERS                                        SCGDAT    234
CD                                                                      SCGDAT    235
      IF(LRTEMP.NE.LSCGRE)THEN                                          SCGDAT    236
      LSCGRE=LSCGRE+1                                                   SCGDAT    237
      NSCGRE=LRTEMP                                                     SCGDAT    238
      ELSE                                                              SCGDAT    239
      LSCGRE=0                                                          SCGDAT    240
      NSCGRE=0                                                          SCGDAT    241
      ENDIF                                                             SCGDAT    242
C                                                                       SCGDAT    243
 2020 FORMAT(2A12,2A2,1X,A1)                                            SCGDAT    244
 2010 FORMAT(2I5,2A2,1X,A1)                                             SCGDAT    245
 2030 FORMAT(1X,'*** ERROR SERIES CAPACITOR GAP RELAY BUS NOT FOUND')   SCGDAT    246
 2040 FORMAT(1X,'*** RELAY SCHEME EXCEEDS THE LIMIT OF ',I3)            SCGDAT    247
 2050 FORMAT(4F10.5,I10,F10.5)                                          SCGDAT    248
C                                                                       SCGDAT    249
      END                                                               SCGDAT    250
C                                                                       SCGDAT    251
