CFPRIME SCGMON                                                          SCGMON      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 SCGMON(H)                                              SCGMON      3
CD                                                                      SCGMON      4
CD    THIS SUBBROUTINE CHECKS THE SERIES CAPACITOR GAP RELAY STATUS     SCGMON      5
CD    DURING THE TIME SIMULATION.                                       SCGMON      6
CD                                                                      SCGMON      7
CD    ROUTINE INPUT H IS THE INTEGRATION STEP SIZE IN SECONDS           SCGMON      8
CD                                                                      SCGMON      9
CD                                                                      SCGMON     10
CD     LSCGRE          Starting position of IDATPT array  of SCGR relay SCGMON     11
CD                     scheme, LSCGRE is in the common labelled PT of   SCGMON     12
CD                     include file CNPT.                               SCGMON     13
CD                                                                      SCGMON     14
CD     NSCGRE          Finishing position of IDATPT array of SCGR relay SCGMON     15
CD                     scheme, NSCGRE is in common labelled AUTO of     SCGMON     16
CD                     include file CNAUTO.                             SCGMON     17
CD                                                                      SCGMON     18
CD     let k = k-th SCGR RELAY                                          SCGMON     19
CD                                                                      SCGMON     20
CD     N = IDATPT(k)    IDATPT is the array that stores the start       SCGMON     21
CD                      position of the K-TH SCGR relay scheme data     SCGMON     22
CD                                                                      SCGMON     23
CD                                                                      SCGMON     24
CD ADATA(N+1)=ICD1RG     LOCAL RELAY TRIP STATUS:                       SCGMON     25
CD                       1 = CAPACITOR GAP NOT FIRED                    SCGMON     26
CD                       2 = CAPACITOR GAP PERMANENTLY FIRED REMOTE     SCGMON     27
CD                           RELAY NOT TRIPPED                          SCGMON     28
CD                       3 = CAPACITOR GAP PERNANEMTLY FIRED REMOTE     SCGMON     29
CD                           RELAY TRIPPED                              SCGMON     30
CD                       4 = GAP SHORTED I .GT. IFC PERM TIMER STARTED  SCGMON     31
CD                       5 = GAP SHORTED I .LT. IRE PERM TIMER STARTED  SCGMON     32
CD                       6 = GAP SHORTED I .LT. IRE REINSERTION TIMER   SCGMON     33
CD                           STARTED                                    SCGMON     34
CD                                                                      SCGMON     35
CD IADATA(N+2)=IBUSRG    LEFT HAND BUS NUMBER                           SCGMON     36
CD IADATA(N+3)=JBUSRG    RIGHT HAND BUS NUMBER                          SCGMON     37
CD IADATA(N+4)=IPARRG    PARALLEL IDENTIFICATION FOR THIS LINE          SCGMON     38
CD IADATA(N+5)(=KSECRG   SECTION IDENTIFICATION FOR THIS CAPACITOR      SCGMON     39
CD IADATA(N+6)(=NRECRG   MAXIMUM NUMBER OF REINSERTION ATTEMPTS.  CAPS  SCGMON     40
CD                       WILL BE PERMANENTLY SHORT CIRCUITED WHEN THIS  SCGMON     41
CD                       NUMBER IS REACHED.                             SCGMON     42
CD IADATA(N+7)=ICD3RG    COUNTS THE NUMBER OF REINSERTION ATTEMPTS      SCGMON     43
CD IADATA(N+8)=KBORRG    TRANSFER TRIP STATUS                           SCGMON     44
CD                       1 = 'B' REMOTE RELAY TRANSFER TRIP ACTIVATED   SCGMON     45
CD                               THE FIRST TIME THE GAP IS FIRED.       SCGMON     46
CD                       2 = 'E' REMOTE RELAY TRANSFER TRIP ACTIVATED   SCGMON     47
CD                               AFTER GAP IS PERMANENTLY SHORTED       SCGMON     48
CD                       3 = REMOTE RELAY TRANSFER TRIP ACTIVATED       SCGMON     49
CD                       4 = REMOTE RELAY TRANSFER TRIP COMPLETE        SCGMON     50
CD                                                                      SCGMON     51
CD ADATA(N+9)=GPFRG      GAP FIRING CURRENT PER UNIT                    SCGMON     52
CD                                                                      SCGMON     53
CD ADATA(N+10)=RINCRG    GAP REINSETION CURRENT PER UNIT                SCGMON     54
CD                                                                      SCGMON     55
CD ADATA(N+11)=RETDRG    REINSERTION TIME DELAY IN CYCLES.  CAPACITOR   SCGMON     56
CD                       CURRENT MUST REMAIN BELOW REINSERTION CURRENT  SCGMON     57
CD                       FOR THIS LENGTH OF TIME BEFORE CAPS ARE        SCGMON     58
CD                       REINSERTED.                                    SCGMON     59
CD                                                                      SCGMON     60
CD ADATA(N+12)=PERMRG    PERMANENT SHORTING SWITCH TIME DELAY.  IF GAP  SCGMON     61
CD                       REMAINS FIRED FOR THIS LENGTH OF TIME, IT WILL SCGMON     62
CD                       BE PERMANENTLY SHORT CIRCUITED.                SCGMON     63
CD                                                                      SCGMON     64
CD ADATA(N+13)=TIMPRG    PERMANENT SHORT CIRCUIT TIMER                  SCGMON     65
CD                                                                      SCGMON     66
CD ADATA(N+14)=TIMRRG    REINSERTION TIMER                              SCGMON     67
CD                                                                      SCGMON     68
CD ADATA(N+15)           NO. OF  REMOTE RELAY                           SCGMON     69
CD                                                                      SCGMON     70
CD ADATA(N+16)=TTRPG     REMOTE RELAY TRIP FLAG                         SCGMON     71
CD                                                                      SCGMON     72
CD                                                                      SCGMON     73
CD ADATA(N+17)=GIJARG                                                   SCGMON     74
CD ADATA(N+18)=BIJARG                                                   SCGMON     75
CD ADATA(N+19)=GIOARG    PI EQUIVALENT ADMITTANCES FOR TOTAL LINE       SCGMON     76
CD ADATA(N+20)=BIOARG                                                   SCGMON     77
CD ADATA(N+21)=GJOARG                                                   SCGMON     78
CD ADATA(N+22)=BJOARG                                                   SCGMON     79
CD                                                                      SCGMON     80
CD ADATA(N+23)=GIJPRG                                                   SCGMON     81
CD ADATA(N+24)=BIJPRG                                                   SCGMON     82
CD ADATA(N+25)=GIOPRG    PI EQUIVALENT ADMITTANCES FOR LINE SECTION     SCGMON     83
CD ADATA(N+26)=BIOPRG    TO THE LEFT OF THE CAPACITOR                   SCGMON     84
CD ADATA(N+27)=GJOPRG                                                   SCGMON     85
CD ADATA(N+28)=BJOPRG                                                   SCGMON     86
CD                                                                      SCGMON     87
CD ADATA(N+29)=GIJSRG                                                   SCGMON     88
CD ADATA(N+30)=BIJSRG                                                   SCGMON     89
CD ADATA(N+31)=GIOSRG    PI EQUIVALENT ADMITTANCES FOR TOTAL LINE       SCGMON     90
CD ADATA(N+32)=BIOSRG    WITH CAPACITOR SHORT CIRCUITED                 SCGMON     91
CD ADATA(N+33)=GJOSRG                                                   SCGMON     92
CD ADATA(N+34)=BJOSRG                                                   SCGMON     93
CD                                                                      SCGMON     94
CD                                                                      SCGMON     95
      INCLUDE 'PARX.INS'                                                SCGMON     96
      INCLUDE 'CNPT.INS'                                                SCGMON     97
      INCLUDE 'CNAUTO.INS'                                              SCGMON     98
      INCLUDE 'CNVOLT.INS'                                              SCGMON     99
      INCLUDE 'CNFLAG.INS'                                              SCGMON    100
      INCLUDE 'CNB4.INS'                                                SCGMON    101
      INCLUDE 'CNB19.INS'                                               SCGMON    102
      INCLUDE 'CNUNIT.INS'                                              SCGMON    103
C                                                                       SCGMON    104
      CHARACTER*4 CID,SID                                               SCGMON    105
      INTEGER*4 ICID,ISID                                               SCGMON    106
      EQUIVALENCE (ICID,CID),(ISID,SID)                                 SCGMON    107
      CHARACTER*2 ICKT,ISCKT                                            SCGMON    108
C                                                                       SCGMON    109
      INTEGER*4 ITFK                                                    SCGMON    110
      INTEGER*2 IFRTO(2)                                                SCGMON    111
      EQUIVALENCE (ITFK,IFRTO(1))                                       SCGMON    112
C                                                                       SCGMON    113
      COMPLEX VOLTK                                                     SCGMON    114
      DIMENSION VOLTX(2)                                                SCGMON    115
      EQUIVALENCE (VOLTK,VOLTX(1)),(VOLTX(1),VREAL),(VOLTX(2),VIMAG)    SCGMON    116
C                                                                       SCGMON    117
      IF(H.EQ.0.0)RETURN                                                SCGMON    118
C                                                                       SCGMON    119
      LDEB=(JDEB(37).NE.0)                                              SCGMON    120
C                                                                       SCGMON    121
      DO 500 I=LSCGRE,NSCGRE                                            SCGMON    122
C                                                                       SCGMON    123
      K=IDATPT(I)                                                       SCGMON    124
C                                                                       SCGMON    125
      IF(IADATA(K+1).GT.9)GOTO 500                                      SCGMON    126
CD                                                                      SCGMON    127
CD       IF ICD1RG=3 THIS CAPACITOR IS PERMANENTLY SHORT CIRCUITED      SCGMON    128
CD       AND TRANSFER TRIP TO THE REMOTE RELAYS HAS BEEN COMPLETED.     SCGMON    129
CD                                                                      SCGMON    130
      IF(IADATA(K+1).EQ.3)GOTO 500                                      SCGMON    131
CD                                                                      SCGMON    132
CD       IF ICD1RG=2 THIS CAPACITOR IS PERMANENTLY SHORT CIRCUITED      SCGMON    133
CD       AND TRANSFER TRIP TO THE REMOTE RELAYS HAS NOT TIMED OUT       SCGMON    134
CD                                                                      SCGMON    135
      IF(IADATA(K+1).EQ.2)GOTO 280                                      SCGMON    136
      IBUS=IADATA(K+2)                                                  SCGMON    137
      JBUS=IADATA(K+3)                                                  SCGMON    138
      VOLTK=VOLT(IBUS)                                                  SCGMON    139
      EI=VREAL                                                          SCGMON    140
      FI=VIMAG                                                          SCGMON    141
      VOLTK=VOLT(JBUS)                                                  SCGMON    142
      EJ=VREAL                                                          SCGMON    143
      FJ=VIMAG                                                          SCGMON    144
C                                                                       SCGMON    145
C     GET PI EQUIVALENT ADMITTANCES FOR TOTAL LINE                      SCGMON    146
C                                                                       SCGMON    147
      GIJA=ADATA(K+17)                                                  SCGMON    148
      BIJA=ADATA(K+18)                                                  SCGMON    149
      GIOA=ADATA(K+19)                                                  SCGMON    150
      BIOA=ADATA(K+20)                                                  SCGMON    151
      GJOA=ADATA(K+21)                                                  SCGMON    152
      BJOA=ADATA(K+22)                                                  SCGMON    153
C                                                                       SCGMON    154
C     GET PI EQUIVALENT ADMITTANCES FOR LINE SECTION TO THE             SCGMON    155
C     LEFT OF SERIES CAPACITOR                                          SCGMON    156
C                                                                       SCGMON    157
      GIJP=ADATA(K+23)                                                  SCGMON    158
      BIJP=ADATA(K+24)                                                  SCGMON    159
      GIOP=ADATA(K+25)                                                  SCGMON    160
      BIOP=ADATA(K+26)                                                  SCGMON    161
      GJOP=ADATA(K+27)                                                  SCGMON    162
      BJOP=ADATA(K+28)                                                  SCGMON    163
C                                                                       SCGMON    164
      C1R=EI*(GIOA+GIJA+GIOP)-FI*(BIOA+BIJA+BIOP)                       SCGMON    165
      C1I=EI*(BIOA+BIJA+BIOP)+FI*(GIOA+GIJA+GIOP)                       SCGMON    166
      C2R=C1R-EJ*GIJA+FJ*BIJA                                           SCGMON    167
      C2I=C1I-EJ*BIJA-FJ*GIJA                                           SCGMON    168
C                                                                       SCGMON    169
      IF ((GIJP.NE.0.0).OR.(BIJP.NE.0.0))GOTO 100                       SCGMON    170
      CAPR=C2R                                                          SCGMON    171
      CAPI=C2I                                                          SCGMON    172
      GOTO 120                                                          SCGMON    173
C                                                                       SCGMON    174
C       CALCULATE CURRENT THRU CAPACITOR--GAPCUR                        SCGMON    175
C                                                                       SCGMON    176
  100 RIJP=GIJP/(GIJP*GIJP+BIJP*BIJP)                                   SCGMON    177
      XIJP=-BIJP/(GIJP*GIJP+BIJP*BIJP)                                  SCGMON    178
      CNSTR=RIJP*GJOP-XIJP*BJOP+1.                                      SCGMON    179
      CNSTI=RIJP*BJOP+XIJP*GJOP                                         SCGMON    180
      C3R=C2R*CNSTR-C2I*CNSTI                                           SCGMON    181
      C3I=C2R*CNSTI+C2I*CNSTR                                           SCGMON    182
      CAPR=C3R-EI*GJOP+FI*BJOP                                          SCGMON    183
      CAPI=C3I-EI*BJOP-FI*GJOP                                          SCGMON    184
  120 GAPCUR=SQRT(CAPR*CAPR+CAPI*CAPI)                                  SCGMON    185
      GAPFC=ADATA(K+9)                                                  SCGMON    186
      REINC=ADATA(K+10)                                                 SCGMON    187
C                                                                       SCGMON    188
      IF(LDEB)WRITE(IUD6,2200)GAPCUR,GAPFC,TS,IADATA(K+1),              SCGMON    189
     & IADATA(K+8),IADATA(K+7),IADATA(K+6)                              SCGMON    190
 2200 FORMAT(' CAL ICAP = ',F10.4,' SPEC. ICAP = ',F10.4,' TS = ',F9.3  SCGMON    191
     & , 4I5)                                                           SCGMON    192
C                                                                       SCGMON    193
      IF (GAPCUR .LE. GAPFC)GOTO 200                                    SCGMON    194
CD                                                                      SCGMON    195
CD       IF ICD1RG NOT EQUAL 1 THE SERIES CAPACITOR GAP HAS  FIRED      SCGMON    196
CD       PRIOR TO THIS                                                  SCGMON    197
CD                                                                      SCGMON    198
         IF(IADATA(K+1).NE.1)THEN                                       SCGMON    199
CD                                                                      SCGMON    200
CD       ICD1RG=4 MEANS THE LINE CURRENT EXCEEDS THE FIRING CURRENT     SCGMON    201
CD       AND THE GAP IS ALREADY FIRED, SO  CHECK                        SCGMON    202
CD       THE PERMANENT SHORT CIRCUIT TIMER                              SCGMON    203
CD                                                                      SCGMON    204
         IADATA(K+1)=4                                                  SCGMON    205
         IF(ADATA(K+13) - .0001.GT.TS)GOTO 140                          SCGMON    206
CD                                                                      SCGMON    207
CD        GAP IS PERMANENTLY SHORT CIRCUITED IF KBORRG =3,              SCGMON    208
CD        REMOTE TRANSFER TRIP IS NOT COMPLETE.  IF KBORRG=4            SCGMON    209
CD        RETMOTE TRANSER TRIP IS COMPLETE.                             SCGMON    210
CD                                                                      SCGMON    211
         IF(IADATA(K+8).EQ.3) IADATA(K+1)=2                             SCGMON    212
         IF(IADATA(K+8).EQ.4) IADATA(K+1)=3                             SCGMON    213
CD                                                                      SCGMON    214
CD       IF KBORRG=3 REMOTE RELAY ACTIVATED                             SCGMON    215
CD                                                                      SCGMON    216
  140    IF (IADATA(K+8).EQ.3)GOTO 280                                  SCGMON    217
         GOTO 500                                                       SCGMON    218
      ENDIF                                                             SCGMON    219
CD                                                                      SCGMON    220
CD       IF ICD1RG EQUAL 1 THE SERIES CAPACITOR GAP HAS NOT FIRED       SCGMON    221
CD       PRIOR TO THIS SO SHORT CIRCUIT THE GAP NOW                     SCGMON    222
CD                                                                      SCGMON    223
      IADATA(K+1)=4                                                     SCGMON    224
      ADATA(K+14)=(ADATA(K+12) + TS)                                    SCGMON    225
C                                                                       SCGMON    226
C       GET PI EQUIVALENT ADMITTANCE FOR LINE WITH CAPACITOR            SCGMON    227
C       SHORT CIRCUITED AND MODIFY ADMITTANCE MATRIX  TO                SCGMON    228
C       TO REFLECT NEW LINE ADMITTANCE                                  SCGMON    229
C                                                                       SCGMON    230
      GIJAS=ADATA(K+29)                                                 SCGMON    231
      BIJAS=ADATA(K+30)                                                 SCGMON    232
      GIOAS=ADATA(K+31)                                                 SCGMON    233
      BIOAS=ADATA(K+32)                                                 SCGMON    234
      GJOAS=ADATA(K+33)                                                 SCGMON    235
      BJOAS=ADATA(K+34)                                                 SCGMON    236
      IRCALL=2                                                          SCGMON    237
      IBUSN=IBUS                                                        SCGMON    238
      JBUSN=JBUS                                                        SCGMON    239
C                                                                       SCGMON    240
      ICID=IADATA(K+4)                                                  SCGMON    241
      ICKT=CID(1:2)                                                     SCGMON    242
      ISID=IADATA(K+5)                                                  SCGMON    243
      ISCKT=SID(1:2)                                                    SCGMON    244
CD                                                                      SCGMON    245
CD IF FLASHED WRITE CAPACITOR GAP FLASHING CARD TO ISWFA FILE           SCGMON    246
CD                                                                      SCGMON    247
       IF(IASWX.EQ.0)THEN                                               SCGMON    248
       WRITE(ISWFA,2010) TS                                             SCGMON    249
 2010  FORMAT(F10.5)                                                    SCGMON    250
       NAWR=NAWR+1                                                      SCGMON    251
       IASWX=1                                                          SCGMON    252
       ENDIF                                                            SCGMON    253
       WRITE(ISWFA,2020) IBUS,JBUS,ICKT,ISCKT,GIJAS,BIJAS,              SCGMON    254
     &                  GIOAS,BIOAS,GJOAS,BJOAS                         SCGMON    255
       NAWR=NAWR+1                                                      SCGMON    256
 2020 FORMAT('FCGA',2I5,1X,2A2,6F10.5)                                  SCGMON    257
C                                                                       SCGMON    258
      IF(IBUS .LT. JBUS)GOTO 160                                        SCGMON    259
      IBUSN=JBUS                                                        SCGMON    260
      JBUSN=IBUS                                                        SCGMON    261
  160 ICDEN=1                                                           SCGMON    262
      GIJT=ADATA(K+29)                                                  SCGMON    263
      BIJT=ADATA(K+30)                                                  SCGMON    264
      GIOT=ADATA(K+31)                                                  SCGMON    265
      BIOT=ADATA(K+32)                                                  SCGMON    266
      GJOT=ADATA(K+33)                                                  SCGMON    267
      BJOT=ADATA(K+34)                                                  SCGMON    268
      ITPARN=0                                                          SCGMON    269
CD                                                                      SCGMON    270
CD       CALL TRPHIS TO FORM A TABLE OF LINES THAT HAVE BEEN TRIPPED    SCGMON    271
CD       OR MODIFIED.                                                   SCGMON    272
CD                                                                      SCGMON    273
CD       SWITCH ADMITTANCES TABLES SO GIJARG CONTAINS SHORT CIRCUITED   SCGMON    274
CD       DATA AND GIJSRG CONTAINS ORGINAL LINE DATA                     SCGMON    275
CD                                                                      SCGMON    276
      T51N=ADATA(K+17)                                                  SCGMON    277
      T52N=ADATA(K+18)                                                  SCGMON    278
      T61N=ADATA(K+19)                                                  SCGMON    279
      T62N=ADATA(K+20)                                                  SCGMON    280
      T71N=ADATA(K+21)                                                  SCGMON    281
      T72N=ADATA(K+22)                                                  SCGMON    282
      ADATA(K+17)=ADATA(K+29)                                           SCGMON    283
      ADATA(K+18)=ADATA(K+30)                                           SCGMON    284
      ADATA(K+19)=ADATA(K+31)                                           SCGMON    285
      ADATA(K+21)=ADATA(K+32)                                           SCGMON    286
      ADATA(K+22)=ADATA(K+33)                                           SCGMON    287
      ADATA(K+23)=ADATA(K+34)                                           SCGMON    288
      ADATA(K+29)=T51N                                                  SCGMON    289
      ADATA(K+30)=T52N                                                  SCGMON    290
      ADATA(K+31)=T61N                                                  SCGMON    291
      ADATA(K+32)=T62N                                                  SCGMON    292
      ADATA(K+33)=T71N                                                  SCGMON    293
      ADATA(K+34)=T72N                                                  SCGMON    294
CD                                                                      SCGMON    295
CD       IF TRANSFER TRIP TO REMOTE RELAYS STARTS THEN                  SCGMON    296
CD       FIRST TIME THE GAP IS FIRED, CHECK TO SEE                      SCGMON    297
CD       IF REMOTE TIMER HAS STARTED                                    SCGMON    298
CD                                                                      SCGMON    299
      IF(IADATA(K+8).EQ.1)THEN                                          SCGMON    300
        IF(IDRRR.NE.0)THEN                                              SCGMON    301
         KADD=K+34                                                      SCGMON    302
         CALL RTIMER(KADD,IDRRR)                                        SCGMON    303
        ENDIF                                                           SCGMON    304
        IADATA(K+8)=3                                                   SCGMON    305
      ENDIF                                                             SCGMON    306
CD                                                                      SCGMON    307
CD       CHECK TO SEE IF NUMBER OF REINSERTIONS EQUALS MAX,             SCGMON    308
CD       IF SO, PERMANENTLY SHORT CIRCUIT CAPACITOR                     SCGMON    309
CD                                                                      SCGMON    310
      IF(IADATA(K+7).NE.IADATA(K+6))THEN                                SCGMON    311
         IF(IADATA(K+8).EQ.3)GOTO 280                                   SCGMON    312
         GOTO 500                                                       SCGMON    313
      ENDIF                                                             SCGMON    314
CD                                                                      SCGMON    315
CD       IDC1RG=2 MEANS THE GAP IS PERMANENTLY SHORT CIRCUITED          SCGMON    316
CD       AS THE NUMBER OF REINSETION ATTEMPS HAS REACHED                SCGMON    317
CD       THE MAXIMUM OF NRECRG.                                         SCGMON    318
CD                                                                      SCGMON    319
      IADATA(K+1)=2                                                     SCGMON    320
CD                                                                      SCGMON    321
CD       KBORRG=2 MEANS THE REMOTE RELAY TRANSFER TRIP STARTS           SCGMON    322
CD       WHEN ALL REINSERTIONS ARE COMPLETE SO START REMOTE TIMER       SCGMON    323
CD                                                                      SCGMON    324
      IF(IADATA(K+8).EQ.2)THEN                                          SCGMON    325
        IF(IDRRR.NE.0)THEN                                              SCGMON    326
          KADD=K+34                                                     SCGMON    327
          CALL RTIMER(KADD,IDRRR)                                       SCGMON    328
        ENDIF                                                           SCGMON    329
        IADATA(K+8)=3                                                   SCGMON    330
        GOTO 280                                                        SCGMON    331
      ENDIF                                                             SCGMON    332
CD                                                                      SCGMON    333
CD       KBORRG=4 MEANS THE GAP IS PERMANENTLY SHORT CIRCUITED AND      SCGMON    334
CD       TRANSFER TRIP DELAY HAS BEEN COMPLETED                         SCGMON    335
CD                                                                      SCGMON    336
      IF(IADATA(K+8).EQ.4)IADATA(K+1)=3                                 SCGMON    337
      GOTO 500                                                          SCGMON    338
                                                                        SCGMON    339
CD                                                                      SCGMON    340
CD       THIS BLOCK OF LOGIC IS FOR THE CONDITON THAT THE CAPACITOR     SCGMON    341
CD       CURRENT IS LESS THAN THE FIRING CURRENT                        SCGMON    342
CD                                                                      SCGMON    343
  200 IF(IADATA(K+1).EQ.1)THEN                                          SCGMON    344
         IF(IADATA(K+8).EQ.3)GOTO 280                                   SCGMON    345
         GOTO 500                                                       SCGMON    346
      ENDIF                                                             SCGMON    347
CD                                                                      SCGMON    348
CD       SET PERMANENT SHORT CIRCUIT TIMER TO ZERO                      SCGMON    349
CD                                                                      SCGMON    350
      ADATA(K+13)=0.0                                                   SCGMON    351
      IF(GAPCUR.GT.ADATA(K+10))THEN                                     SCGMON    352
         IF(IADATA(K+8).EQ.3)GOTO 280                                   SCGMON    353
         GOTO 500                                                       SCGMON    354
      ENDIF                                                             SCGMON    355
CD                                                                      SCGMON    356
CD       ICD1RG=6 MEANS THE LINE CURRENT IS LESS THAN THE REINSETION CU SCGMON    357
CD       AND THE REINSERTTION TIMER IT2 HAS STARTED.                    SCGMON    358
CD                                                                      SCGMON    359
      IF(IADATA(K+1) .NE. 6)THEN                                        SCGMON    360
         IADATA(K+1)=6                                                  SCGMON    361
         ADATA(K+14)=TS + ADATA(K+11)                                   SCGMON    362
      ENDIF                                                             SCGMON    363
      IF(ADATA(K+14).GT.TS)GOTO 260                                     SCGMON    364
CD                                                                      SCGMON    365
CD     INCREMENT THE NUMBER OF REINSERTION ATTEMPTS-ICD3RG              SCGMON    366
CD                                                                      SCGMON    367
      IADATA(K+7)=IADATA(K+7) +1                                        SCGMON    368
CD                                                                      SCGMON    369
CD     RESET ICD1RG=1 WHICH MEANS GAP IS NOT FIRED                      SCGMON    370
CD                                                                      SCGMON    371
      IADATA(K+1)=1                                                     SCGMON    372
CD                                                                      SCGMON    373
CD     OBTAIN EQUIVALENT SHORT CIRCUITED ADMITTANCE AND REINSERT        SCGMON    374
CD     THE CAPACITOR IN THE LINE                                        SCGMON    375
CD                                                                      SCGMON    376
      GIJAS=ADATA(K+29)                                                 SCGMON    377
      BIJAS=ADATA(K+30)                                                 SCGMON    378
      GIOAS=ADATA(K+31)                                                 SCGMON    379
      BIOAS=ADATA(K+32)                                                 SCGMON    380
      GJOAS=ADATA(K+33)                                                 SCGMON    381
      BJOAS=ADATA(K+34)                                                 SCGMON    382
      IRCALL=2                                                          SCGMON    383
      IBUSN=IBUS                                                        SCGMON    384
      JBUSN=JBUS                                                        SCGMON    385
C                                                                       SCGMON    386
      IF(IBUS .LT. JBUS)GOTO 220                                        SCGMON    387
      IBUSN=JBUS                                                        SCGMON    388
      JBUSN=IBUS                                                        SCGMON    389
  220 ICDEN=1                                                           SCGMON    390
      GIJT=ADATA(K+29)                                                  SCGMON    391
      BIJT=ADATA(K+30)                                                  SCGMON    392
      GIOT=ADATA(K+31)                                                  SCGMON    393
      BIOT=ADATA(K+32)                                                  SCGMON    394
      GJOT=ADATA(K+33)                                                  SCGMON    395
      BJOT=ADATA(K+34)                                                  SCGMON    396
      ITPARN=0                                                          SCGMON    397
CD                                                                      SCGMON    398
CD     CALL TRPHIS TO FORM A TABLE OF LINES THAT HAVE BEEN TRIPPED      SCGMON    399
CD     OR MODIFIED                                                      SCGMON    400
CD                                                                      SCGMON    401
      IDUM=IBUS                                                         SCGMON    402
      IBUS=JBUS                                                         SCGMON    403
      JBUS=IDUM                                                         SCGMON    404
      GIOA=GJOA                                                         SCGMON    405
      BIOA=BJOA                                                         SCGMON    406
      GIOAS=GJOAS                                                       SCGMON    407
      BIOAS=BJOAS                                                       SCGMON    408
      T51N=ADATA(K+17)                                                  SCGMON    409
      T52N=ADATA(K+18)                                                  SCGMON    410
      T61N=ADATA(K+19)                                                  SCGMON    411
      T62N=ADATA(K+20)                                                  SCGMON    412
      T71N=ADATA(K+21)                                                  SCGMON    413
      T72N=ADATA(K+22)                                                  SCGMON    414
      ADATA(K+17)=ADATA(K+29)                                           SCGMON    415
      ADATA(K+18)=ADATA(K+30)                                           SCGMON    416
      ADATA(K+19)=ADATA(K+31)                                           SCGMON    417
      ADATA(K+20)=ADATA(K+32)                                           SCGMON    418
      ADATA(K+21)=ADATA(K+33)                                           SCGMON    419
      ADATA(K+22)=ADATA(K+34)                                           SCGMON    420
      ADATA(K+29)=T51N                                                  SCGMON    421
      ADATA(K+30)=T52N                                                  SCGMON    422
      ADATA(K+31)=T61N                                                  SCGMON    423
      ADATA(K+32)=T62N                                                  SCGMON    424
      ADATA(K+33)=T71N                                                  SCGMON    425
      ADATA(K+34)=T72N                                                  SCGMON    426
C                                                                       SCGMON    427
      ICID=IADATA(K+4)                                                  SCGMON    428
      ICKT=CID(1:2)                                                     SCGMON    429
      ISID=IADATA(K+5)                                                  SCGMON    430
      ISCKT=SID(1:2)                                                    SCGMON    431
CD                                                                      SCGMON    432
CD IF RENINSERT WRITE CAPACITOR REINSERTION CARD TO ISWFA FILE          SCGMON    433
CD                                                                      SCGMON    434
       IF(IASWX.EQ.0)THEN                                               SCGMON    435
       WRITE(ISWFA,2010) TS                                             SCGMON    436
       NAWR=NAWR+1                                                      SCGMON    437
       IASWX=1                                                          SCGMON    438
       ENDIF                                                            SCGMON    439
       WRITE(ISWFA,2025) IBUS,JBUS,ICKT,ISCKT,GIJAS,BIJAS,              SCGMON    440
     &                  GIOAS,BIOAS,GJOAS,BJOAS                         SCGMON    441
       NAWR=NAWR+1                                                      SCGMON    442
 2025 FORMAT('RCGA',2I5,1X,2A2,6F10.4,2I5)                              SCGMON    443
  260 IF(IADATA(K+8).EQ.3)GOTO 280                                      SCGMON    444
      GOTO 500                                                          SCGMON    445
CD                                                                      SCGMON    446
CD       IF KBORRG=3, REMOTE RELAY TRANSFER TRIP TIMER HAS              SCGMON    447
CD       STARTED                                                        SCGMON    448
CD                                                                      SCGMON    449
  280 CONTINUE                                                          SCGMON    450
      IDRRR=IADATA(K+15)                                                SCGMON    451
       IF(IDRRR.NE.0)THEN                                               SCGMON    452
         KBUS=K                                                         SCGMON    453
         KADD=K+34                                                      SCGMON    454
         IPOINT=16                                                      SCGMON    455
         CALL RETRIP(KADD,KBUS,IDRRR,IPOINT)                            SCGMON    456
         IF(IADATA(KBUS+IPOINT).EQ.-1)THEN                              SCGMON    457
          IADATA(K+8)=4                                                 SCGMON    458
          IF(IADATA(K+1).EQ.2)IADATA(K+1)=3                             SCGMON    459
         ENDIF                                                          SCGMON    460
        ENDIF                                                           SCGMON    461
  500 CONTINUE                                                          SCGMON    462
C                                                                       SCGMON    463
      RETURN                                                            SCGMON    464
      END                                                               SCGMON    465
