CFPRIME RETRIP                                                          RETRIP      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                                                                       RETRIP      3
      SUBROUTINE RETRIP(K,KBUS,KSWITC,IPOINT)                           RETRIP      4
CD                                                                      RETRIP      5
CD    TO WRITE THE REMOTE TRIP SWITCHING DATA OF RELAYS.                RETRIP      6
CD                                                                      RETRIP      7
      INCLUDE 'PARX.INS'                                                RETRIP      8
      INCLUDE 'CNPT.INS'                                                RETRIP      9
      INCLUDE 'CNNNEW.INS'                                              RETRIP     10
      INCLUDE 'CNAUTO.INS'                                              RETRIP     11
      INCLUDE 'CNB4.INS'                                                RETRIP     12
      INCLUDE 'CNB19.INS'                                               RETRIP     13
      INCLUDE 'CNFLAG.INS'                                              RETRIP     14
      INCLUDE 'CNPARX.INS'                                              RETRIP     15
      INCLUDE 'CNREN.INS'                                               RETRIP     16
      INCLUDE 'CNUNIT.INS'                                              RETRIP     17
      INCLUDE 'CNMSG.INS'                                               RETRIP     18
C                                                                       RETRIP     19
      INTEGER*4 ICID,ISID,ITFK                                          RETRIP     20
      INTEGER KSOC(53)                                                  RETRIP     21
      CHARACTER*2  ICKT,ISCKT                                           RETRIP     22
      CHARACTER*1 A                                                     RETRIP     23
C                                                                       RETRIP     24
      INCLUDE 'CNISOC.INS'                                              RETRIP     25
C                                                                       RETRIP     26
      DATA A/'A'/                                                       RETRIP     27
      DATA KSOC/10,11,14,8,7,7,7,7,0,8,7,7,7,7,7,8,10,11,14,0,          RETRIP     28
     & 8,8,6,6,6,0,0,0,0,7,7,0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,4,           RETRIP     29
     & 4,0,0,0,0,0/                                                     RETRIP     30
C                                                                       RETRIP     31
      LDEB=(JDEB(16).NE.0)                                              RETRIP     32
C                                                                       RETRIP     33
      JLNA=K                                                            RETRIP     34
C                                                                       RETRIP     35
      DO 200 JJ=1,KSWITC                                                RETRIP     36
C                                                                       RETRIP     37
      I=IADATA(JLNA+3)                                                  RETRIP     38
C                                                                       RETRIP     39
C    CHECK FOR THE STATUS                                               RETRIP     40
C                                                                       RETRIP     41
      IF(IADATA(JLNA+1).EQ.1)THEN                                       RETRIP     42
       JLNA=JLNA+KSOC(I)                                                RETRIP     43
       GOTO 200                                                         RETRIP     44
      ENDIF                                                             RETRIP     45
C                                                                       RETRIP     46
C    CHECK FOR TIMEOUT                                                  RETRIP     47
C                                                                       RETRIP     48
      IF(ADATA(JLNA+2).GT.TS)THEN                                       RETRIP     49
       JLNA=JLNA+KSOC(I)                                                RETRIP     50
       GOTO 200                                                         RETRIP     51
      ENDIF                                                             RETRIP     52
C                                                                       RETRIP     53
      IADATA(JLNA+1)=1                                                  RETRIP     54
      IADATA(KBUS+IPOINT)=IADATA(KBUS+IPOINT)+1                         RETRIP     55
      IF(IADATA(KBUS+IPOINT).EQ.KSWITC)IADATA(KBUS+IPOINT)=-1           RETRIP     56
C                                                                       RETRIP     57
      ITYP=ISOC(I)                                                      RETRIP     58
C                                                                       RETRIP     59
      IF(IASWX.EQ.0 .AND. I.NE.KTYP)THEN                                RETRIP     60
        WRITE(ISWFA,1010)TS                                             RETRIP     61
 1010   FORMAT(F10.5)                                                   RETRIP     62
        NAWR=NAWR+1                                                     RETRIP     63
        IASWX=1                                                         RETRIP     64
       ENDIF                                                            RETRIP     65
C                                                                       RETRIP     66
      IF(LDEB)WRITE(IUD6,2000)K,JLNA,I,ITYP                             RETRIP     67
 2000 FORMAT(' ** RETRIP ** K,JLNA,I,ITYP ',3I5,A5)                     RETRIP     68
C                                                                       RETRIP     69
C            1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  RETRIP     70
C          ALI ATR APL ABT RLI RTR RPL RBT ASL RSL DLI DTR DPL DLR DBT  RETRIP     71
      GOTO(420,420,420,420,420,420,420,420,420,420,420,420,420,420,420  RETRIP     72
C                                                                       RETRIP     73
C                                F   F   F                              RETRIP     74
C       16  17  18  19  20  21  22  23  24  25  26  27  28  29          RETRIP     75
C      DSL MLI MTR MPL MSL RCG FCG  ZA  ZR  YK LGF LLF LGR LLR          RETRIP     76
     &,420,420,420,420,420,420,420,230,230,230,550,550,550,550          RETRIP     77
C                                                                       RETRIP     78
C       30  31  32  33  34  35  36                                      RETRIP     79
C      SLD RLD  TH  TO  DN AUD RUD                                      RETRIP     80
     &,220,220,550,550,550,550,550                                      RETRIP     81
C                                                                       RETRIP     82
C        F   F   F   F   F   F   F   F   F   F   F                      RETRIP     83
C       37  38  39  40  41  42  43  44  45  46  47  48                  RETRIP     84
C       GR  GM GFD  PR  PM  VR  FV  OF  SR TEB DIM RIM                  RETRIP     85
     &,260,260,260,260,260,260,260,260,260,260,410,410                  RETRIP     86
C                                                                       RETRIP     87
C       49  50  51  52  53                                              RETRIP     88
C       DF  DR  DI  DP ESC                                              RETRIP     89
     &,550,550,550,550,600),I                                           RETRIP     90
C                                                                       RETRIP     91
 220  CONTINUE                                                          RETRIP     92
C                                                                       RETRIP     93
C   READ IN LOAD CHANGE (LD & LS) CARD2                                 RETRIP     94
C                                                                       RETRIP     95
      NLFI=IADATA(JLNA+4)                                               RETRIP     96
      ISHUNT=IADATA(JLNA+5)                                             RETRIP     97
      PSHED=ADATA(JLNA+6)                                               RETRIP     98
      QSHED=ADATA(JLNA+7)                                               RETRIP     99
      JLNA=JLNA+7                                                       RETRIP    100
      WRITE(ISWFA,1000)ITYP,A,NLFI,ISHUNT,PSHED,QSHED                   RETRIP    101
 1000 FORMAT(A3,A1,2I5,2F10.5)                                          RETRIP    102
      NAWR=NAWR+1                                                       RETRIP    103
      GO TO 200                                                         RETRIP    104
C                                                                       RETRIP    105
 230  CONTINUE                                                          RETRIP    106
C                                                                       RETRIP    107
C   FOR ZR,ZA,YK                                                        RETRIP    108
C                                                                       RETRIP    109
      NLFI=IADATA(JLNA+4)                                               RETRIP    110
      XREAL=ADATA(JLNA+5)                                               RETRIP    111
      XIMAG=ADATA(JLNA+6)                                               RETRIP    112
      WRITE(ISWFA,1100)ITYP,A,NLFI,XREAL,XIMAG                          RETRIP    113
 1100 FORMAT(A3,A1,I5,10X,4F10.5)                                       RETRIP    114
      NAWR=NAWR+1                                                       RETRIP    115
      JLNA=JLNA+6                                                       RETRIP    116
      GOTO 200                                                          RETRIP    117
 260  CONTINUE                                                          RETRIP    118
C                                                                       RETRIP    119
C   GENERATION SYSTEM CHANGE                                            RETRIP    120
C                                                                       RETRIP    121
      NLFI=IADATA(JLNA+4)                                               RETRIP    122
      ICID=IADATA(JLNA+5)                                               RETRIP    123
      CALL UNPACK(ICKT,JJJ,ICID)                                        RETRIP    124
      IMACH=IADATA(JLNA+6)                                              RETRIP    125
C                                                                       RETRIP    126
      XREAL=ADATA(JLNA+7)                                               RETRIP    127
      WRITE(ISWFA,1200)ITYP,A,NLFI,IMACH,ICKT,XREAL                     RETRIP    128
 1200 FORMAT(A3,A1,2I5,3X,A2,F10.5)                                     RETRIP    129
      NAWR=NAWR+1                                                       RETRIP    130
      JLNA=JLNA+7                                                       RETRIP    131
      GO TO 200                                                         RETRIP    132
C                                                                       RETRIP    133
 410  CONTINUE                                                          RETRIP    134
C                                                                       RETRIP    135
C   INDUCTION MOTOR SWITCHING                                           RETRIP    136
C                                                                       RETRIP    137
      NLFI=IADATA(JLNA+4)                                               RETRIP    138
      WRITE(ISWFA,1200)ITYP,A,NLFI                                      RETRIP    139
      NAWR=NAWR+1                                                       RETRIP    140
      JLNA=JLNA+4                                                       RETRIP    141
      GO TO 200                                                         RETRIP    142
C                                                                       RETRIP    143
 420  CONTINUE                                                          RETRIP    144
C                                                                       RETRIP    145
C   READ IN LINE DATA CHANGE CARD                                       RETRIP    146
C                                                                       RETRIP    147
      JTYP=I                                                            RETRIP    148
      NLFI=IADATA(JLNA+4)                                               RETRIP    149
      NLFJ=IADATA(JLNA+5)                                               RETRIP    150
      ICID=IADATA(JLNA+6)                                               RETRIP    151
      CALL UNPACK(ICKT,JJJ,ICID)                                        RETRIP    152
      ITFK=IADATA(JLNA+7)                                               RETRIP    153
      CALL UPACKI(NJSELI,NMLINE,ITFK)                                   RETRIP    154
C                                                                       RETRIP    155
C            1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  RETRIP    156
C          ALI ATR APL ABT RLI RTR RPL RBT ASL RSL DLI DTR DPL DLR DBT  RETRIP    157
      GOTO(450,460,470,450,430,430,430,430,550,440,430,430,430,430,430  RETRIP    158
C                                                                       RETRIP    159
C       16  17  18  19  20  21  22                                      RETRIP    160
C      DSL MLI MTR MPL MSL RCG FCG                                      RETRIP    161
     &,440,450,460,470,550,440,440),JTYP                                RETRIP    162
C                                                                       RETRIP    163
 430  CONTINUE                                                          RETRIP    164
      WRITE(ISWFA,1300)ITYP,A,NLFI,NLFJ,ICKT,NMLINE,NJSELI              RETRIP    165
 1300 FORMAT(A3,A1,2I5,1X,A2,62X,2I5)                                   RETRIP    166
      JLNA=JLNA+7                                                       RETRIP    167
      NAWR=NAWR+1                                                       RETRIP    168
      GOTO 200                                                          RETRIP    169
 440  CONTINUE                                                          RETRIP    170
      ISID=IADATA(JLNA+8)                                               RETRIP    171
      CALL UNPACK(ISCKT,JJJ,ISID)                                       RETRIP    172
      WRITE(ISWFA,1400)ITYP,A,NLFI,NLFJ,ICKT,ISCKT,NMLINE,NJSELI        RETRIP    173
 1400 FORMAT(A3,A1,2I5,1X,2A2,60X,2I5)                                  RETRIP    174
      JLNA=JLNA+8                                                       RETRIP    175
      NAWR=NAWR+1                                                       RETRIP    176
      GOTO 200                                                          RETRIP    177
 450  CONTINUE                                                          RETRIP    178
      XREAL=ADATA(JLNA+8)                                               RETRIP    179
      XIMAG=ADATA(JLNA+9)                                               RETRIP    180
      VMG=ADATA(JLNA+10)                                                RETRIP    181
      WRITE(ISWFA,1500)ITYP,A,NLFI,NLFJ,ICKT,ISCKT,XREAL,XIMAG,VMG,     RETRIP    182
     &                NMLINE,NJSELI                                     RETRIP    183
 1500 FORMAT(A3,A1,2I5,1X,2A2,3F10.5,30X,2I5)                           RETRIP    184
      JLNA=JLNA+10                                                      RETRIP    185
      NAWR=NAWR+1                                                       RETRIP    186
      GOTO 200                                                          RETRIP    187
 460  CONTINUE                                                          RETRIP    188
      XREAL=ADATA(JLNA+8)                                               RETRIP    189
      XIMAG=ADATA(JLNA+9)                                               RETRIP    190
      VMG=ADATA(JLNA+10)                                                RETRIP    191
      VPHS=ADATA(JLNA+11)                                               RETRIP    192
      JLNA=JLNA+11                                                      RETRIP    193
      WRITE(ISWFA,1600)ITYP,A,NLFI,NLFJ,ICKT,ISCKT,XREAL,XIMAG,VMG,     RETRIP    194
     &                VPHS,NMLINE,NJSELI                                RETRIP    195
 1600 FORMAT(A3,A1,2I5,1X,2A2,4F10.5,20X,2I5)                           RETRIP    196
      NAWR=NAWR+1                                                       RETRIP    197
      GOTO 200                                                          RETRIP    198
 470  CONTINUE                                                          RETRIP    199
      ISCID=IADATA(JLNA+8)                                              RETRIP    200
      CALL UNPACK(ISCKT,JJJ,ISCID)                                      RETRIP    201
      XREAL=ADATA(JLNA+9)                                               RETRIP    202
      XIMAG=ADATA(JLNA+10)                                              RETRIP    203
      VMG=ADATA(JLNA+11)                                                RETRIP    204
      VPHS=ADATA(JLNA+12)                                               RETRIP    205
      VMG1=ADATA(JLNA+13)                                               RETRIP    206
      VPHS1=ADATA(JLNA+14)                                              RETRIP    207
      WRITE(ISWFA,1700)ITYP,A,NLFI,NLFJ,ICKT,ISCKT,XREAL,XIMAG,VMG,     RETRIP    208
     &                VPHS,VMG1,VPHS1,NJSELI,NJSELI                     RETRIP    209
 1700 FORMAT(A3,A1,2I5,1X,2A2,6F10.5,2I5)                               RETRIP    210
      NAWR=NAWR+1                                                       RETRIP    211
      JLNA=JLNA+14                                                      RETRIP    212
 550  CONTINUE                                                          RETRIP    213
      IEBK=1                                                            RETRIP    214
      WRITE(MSG(1),3020)ITYP                                            RETRIP    215
      CALL PRTMSG(1)                                                    RETRIP    216
 3020 FORMAT(' *** ERROR CONTROL TRIPPING OF TYPE',A4,'IS NOT ALLOWED') RETRIP    217
      GOTO 200                                                          RETRIP    218
 600  CONTINUE                                                          RETRIP    219
 200  CONTINUE                                                          RETRIP    220
C                                                                       RETRIP    221
C    RETURN WITH THE UPDATED POINTER                                    RETRIP    222
C                                                                       RETRIP    223
      K=JLNA                                                            RETRIP    224
C                                                                       RETRIP    225
      RETURN                                                            RETRIP    226
C                                                                       RETRIP    227
       END                                                              RETRIP    228
