CFPRIME REDLIN                                                          REDLIN      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 ASTOP(MSG,LN)                                          REDLIN      3
CD                                                                      REDLIN      4
CD    TO CLOSE ALL LOGICAL FILES, STOP THE PROGRAM EXCUTION AND WRITE   REDLIN      5
CD    THE STOP MESSAGES PASSED THROUGH THE ARGUMENT.                    REDLIN      6
CD                                                                      REDLIN      7
      INCLUDE 'CNLSTA.INS'                                              REDLIN      8
      CHARACTER*(*) MSG                                                 REDLIN      9
      WRITE(LOUT,1010) MSG(1:LN)                                        REDLIN     10
      CALL CLOSEA                                                       REDLIN     11
      STOP 'ETMSP ABNORMALLY TERMINATED'                                REDLIN     12
 1010 FORMAT(1X,'STOP MSG : ',(A))                                      REDLIN     13
      END                                                               REDLIN     14
      SUBROUTINE PSTOP                                                  REDLIN     15
CD                                                                      REDLIN     16
CD    TO CLOSE ALL LOGICAL FILES, STOP THE PROGRAM EXCUTION AND WRITE   REDLIN     17
CD    THE STOP MESSAGES PASSED THROUGH THE ARGUMENT.                    REDLIN     18
CD                                                                      REDLIN     19
      INCLUDE 'CNLSTA.INS'                                              REDLIN     20
      CHARACTER*46 MSG                                                  REDLIN     21
C                                                                       REDLIN     22
      MSG='EXCUTION TERMINATED DUE TO PLAYBACK DATA ERROR'              REDLIN     23
      WRITE(LOUT,1010) MSG                                              REDLIN     24
      CALL CLOSEA                                                       REDLIN     25
      STOP 'ETMSP ABNORMALLY TERMINATED DUE TO PLAYBACK DATA ERROR'     REDLIN     26
 1010 FORMAT(1X,'STOP MSG : ',(A))                                      REDLIN     27
      END                                                               REDLIN     28
C                                                                       REDLIN     29
      SUBROUTINE REDLIN(LOUT,LIN,IOERR,LN,MSG,SUBPMT,HELP,REBUF,RECORD, REDLIN     30
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    REDLIN     31
CD                                                                      REDLIN     32
CD    SUBROUTINE FOR GENERALIZED READING IN ETMSP. THIS PROGRAM IS THE  REDLIN     33
CD    INTERFACE BETWEEN THE USER AND THE PROGRAM FOR ALL INTERACTIVE    REDLIN     34
CD    COMMANDS.                                                         REDLIN     35
CD                                                                      REDLIN     36
CD    THE ARGUMENT LIST IS EXPLAINED BELOW.                             REDLIN     37
CD                                                                      REDLIN     38
CD    LOUT   = LOGICAL OUTPUT UNIT NUMBER                               REDLIN     39
CD    LIN    = LOGICAL INPUT UNIT NUMBER                                REDLIN     40
CD    IOERR  = ERROR FLAG DURING READING                                REDLIN     41
CD             = -1 IF THERE IS ERROR                                   REDLIN     42
CD             =  0 IF NO ERROR                                         REDLIN     43
CD    LN     = IABS(LN) IS THE VALID LENGTH OF THE STRING MSG           REDLIN     44
CD             < 0 ONLY PRINT SUBPMT, NO MESSAGE PRINTING               REDLIN     45
CD    MSG    = CHARACTER*80 STRING DISPLAYED ON SCREEN                  REDLIN     46
CD    SUBPMT = CHARACTER*7 STRING SHOWN ON SCREEN AS A SUB-PROMPT SYMBOLREDLIN     47
CD             FOR CONTEXT SENSITIVE DISPLAY                            REDLIN     48
CD    HELP   = CHARACTER*3 STRING FOR USE IN HELP FACILITY AS A KEYWORD REDLIN     49
CD    REBUF  = CHARACTER*80 STRING, STORING THE USERS RESPONSE          REDLIN     50
CD    RECORD = LOGICAL VARIABLE, STORING THE RECORD STATUS              REDLIN     51
CD    IRECD  = LOGICAL UNIT NUMBER FOR RECORDING PURPOSE                REDLIN     52
CD    KLAYER = FLAG TO DETERMINE HOW MANY LAYERS ABOVE THE USER ARE     REDLIN     53
CD             WANTED TO JUMP BACK.                                     REDLIN     54
CD    KEND   = FLAG TO INDICATE END OF FILE DURING READ. IF EOF THEN    REDLIN     55
CD             KEND=-1                                                  REDLIN     56
CD    KREAD  = LOGICAL FLAG                                             REDLIN     57
CD             = .TRUE.  TO READ IN FROM LINE                           REDLIN     58
CD             = .FALSE. TO READ FROM JCARD                             REDLIN     59
CD                                                                      REDLIN     60
      CHARACTER*80 MSG,REBUF,JCARD                                      REDLIN     61
      CHARACTER*7 SUBPMT                                                REDLIN     62
      CHARACTER*3   HELP,HELPT                                          REDLIN     63
      COMMON JSTART,JSLASH,JWIDTH,JCARD                                 REDLIN     64
      LOGICAL RECORD,KREAD,PLAYBA                                       REDLIN     65
C                                                                       REDLIN     66
      DATA JCOUNT/1/                                                    REDLIN     67
C                                                                       REDLIN     68
      IENTRY=1                                                          REDLIN     69
      KLAYER=0                                                          REDLIN     70
      KEND=0                                                            REDLIN     71
      LNN=IABS(LN)                                                      REDLIN     72
      IF(SUBPMT(1:2).EQ.'XX') LSUBPT=1                                  REDLIN     73
      GOTO 50                                                           REDLIN     74
C                                                                       REDLIN     75
      ENTRY PMTRED(LOUT,LIN,IOERR,LN,MSG,HELP,REBUF,KREAD,PLAYBA)       REDLIN     76
CD                                                                      REDLIN     77
CD    THIS ENTRY POINT HAS A SIMILAR FUNCTION AS SUBROUTINE REDLIN,     REDLIN     78
CD    EXCEPT THAT IT DOES NOT HAVE THE RECORDING FACILITY.              REDLIN     79
CD                                                                      REDLIN     80
      IENTRY=2                                                          REDLIN     81
      LNN=IABS(LN)                                                      REDLIN     82
      GOTO 50                                                           REDLIN     83
C                                                                       REDLIN     84
      ENTRY READSC(LOUT,LIN,IOERR,REBUF,KREAD,PLAYBA)                   REDLIN     85
CD                                                                      REDLIN     86
CD    THIS ENTRY POINT HAS A SIMILAR FUNCTION AS SUBROUTINE REDLIN,     REDLIN     87
CD    EXCEPT THAT IT DOES NOT HAVE THE RECORDING FACILITY AND SCREEN    REDLIN     88
CD    PROMTING MESSAGES.                                                REDLIN     89
CD                                                                      REDLIN     90
      IENTRY=3                                                          REDLIN     91
      LNN=1                                                             REDLIN     92
  50  CONTINUE                                                          REDLIN     93
C                                                                       REDLIN     94
*IF PRIME                                                               REDLIN     95
*ENDIF                                                                  REDLIN     97
*IF -PRIME                                                              REDLIN     98
      IOUT5=5                                                           REDLIN     99
*ENDIF                                                                  REDLIN    100
C                                                                       REDLIN    101
      REBUF(1:40)='                                        '            REDLIN    102
      REBUF(41:80)='                                        '           REDLIN    103
      IOERR=0                                                           REDLIN    104
C                                                                       REDLIN    105
 100  CONTINUE                                                          REDLIN    106
      IF(KREAD)THEN                                                     REDLIN    107
         IF(LN.NE.0.AND.IENTRY.NE.3)THEN                                REDLIN    108
            WRITE(LOUT,1000)MSG(1:LNN)                                  REDLIN    109
            IF(IENTRY.EQ.1)THEN                                         REDLIN    110
               IF(RECORD) WRITE(IREC,1010) MSG(1:LNN)                   REDLIN    111
            ENDIF                                                       REDLIN    112
         ENDIF                                                          REDLIN    113
         IF (LIN.EQ.IOUT5) THEN                                         REDLIN    114
            IF (IENTRY.EQ.1.AND.LSUBPT.NE.1) WRITE(LOUT,1020) SUBPMT    REDLIN    115
         END IF                                                         REDLIN    116
C                                                                       REDLIN    117
  110    READ(LIN,1030,IOSTAT=IOS) JCARD                                REDLIN    118
         IF(IOS.LT.0) GOTO 140                                          REDLIN    119
         IF(IOS.GT.0) GOTO 150                                          REDLIN    120
         IF(JCARD(1:1).EQ.'?') GOTO 110                                 REDLIN    121
         IF (LIN.NE.IOUT5) THEN                                         REDLIN    122
            IF (IENTRY.EQ.1.AND.LSUBPT.NE.1) THEN                       REDLIN    123
               WRITE(LOUT,1050) SUBPMT,JCARD(1:68)                      REDLIN    124
            ELSE                                                        REDLIN    125
               WRITE(LOUT,1060) JCARD                                   REDLIN    126
            END IF                                                      REDLIN    127
         END IF                                                         REDLIN    128
      ENDIF                                                             REDLIN    129
         JSTART=IFNBLK(JCARD,79)                                        REDLIN    130
         IF(JSTART.GT.1) JCARD=JCARD(JSTART:80)//JCARD(1:JSTART-1)      REDLIN    131
         JSLASH=INDEX(JCARD,'=')                                        REDLIN    132
         IF(JSLASH.EQ.0)THEN                                            REDLIN    133
             REBUF=JCARD                                                REDLIN    134
             KREAD=.TRUE.                                               REDLIN    135
         ELSE                                                           REDLIN    136
             REBUF(1:JSLASH-1)=JCARD(1:JSLASH-1)                        REDLIN    137
             JCARD=JCARD(JSLASH+1:80)                                   REDLIN    138
             KREAD=.FALSE.                                              REDLIN    139
         ENDIF                                                          REDLIN    140
         LSUBPT=0                                                       REDLIN    141
C                                                                       REDLIN    142
      IF(IENTRY.EQ.1)THEN                                               REDLIN    143
          IF(RECORD) WRITE(IREC,'(A)')REBUF                             REDLIN    144
      ENDIF                                                             REDLIN    145
      IF(IENTRY.NE.3.AND.LN.GT.1) THEN                                  REDLIN    146
         IF((REBUF(1:5).EQ.'help ').OR.(REBUF(1:5).EQ.'HELP ').OR.      REDLIN    147
     *      (REBUF(1:4).EQ.'hel ').OR.(REBUF(1:4).EQ.'HEL '))THEN       REDLIN    148
            IF(HELP.EQ.'MEN')RETURN                                     REDLIN    149
            IBLANK=INDEX(REBUF,' ')                                     REDLIN    150
            DO 105 I=IBLANK+1,80                                        REDLIN    151
               IF (REBUF(I:I).NE.' ') THEN                              REDLIN    152
                  HELPT=REBUF(I:I+2)                                    REDLIN    153
                  CALL HELPSC(HELPT,3)                                  REDLIN    154
                  GOTO 100                                              REDLIN    155
               END IF                                                   REDLIN    156
  105       CONTINUE                                                    REDLIN    157
            CALL HELPSC(HELP,3)                                         REDLIN    158
            GOTO 100                                                    REDLIN    159
         ENDIF                                                          REDLIN    160
         IF(REBUF(1:7).EQ.'CANCEL ') KLAYER=-1                          REDLIN    161
         IF(REBUF(1:7).EQ.'PLAYER ') KLAYER=-2                          REDLIN    162
      ENDIF                                                             REDLIN    163
C                                                                       REDLIN    164
      IF(PLAYBA)THEN                                                    REDLIN    165
      WRITE(LOUT,5020) JCOUNT                                           REDLIN    166
      JCOUNT=JCOUNT+1                                                   REDLIN    167
      ENDIF                                                             REDLIN    168
      RETURN                                                            REDLIN    169
C                                                                       REDLIN    170
 140  CONTINUE                                                          REDLIN    171
C                                                                       REDLIN    172
      IF(LIN.NE.IOUT5) THEN                                             REDLIN    173
        CALL CLOSEF(LIN)                                                REDLIN    174
        LIN=IOUT5                                                       REDLIN    175
        PLAYBA=.FALSE.                                                  REDLIN    176
        WRITE(LOUT,5010)                                                REDLIN    177
        GOTO 100                                                        REDLIN    178
      ENDIF                                                             REDLIN    179
      KEND=-1                                                           REDLIN    180
      KREAD=.TRUE.                                                      REDLIN    181
      RETURN                                                            REDLIN    182
C                                                                       REDLIN    183
 150  CONTINUE                                                          REDLIN    184
      IOERR=-1                                                          REDLIN    185
      KREAD=.TRUE.                                                      REDLIN    186
      RETURN                                                            REDLIN    187
C                                                                       REDLIN    188
 1000 FORMAT(1X,A)                                                      REDLIN    189
 1010 FORMAT('?',A)                                                     REDLIN    190
*IF -MIBM                                                               REDLIN    191
 1020 FORMAT(1X,A,'-->',$)                                              REDLIN    192
*ENDIF                                                                  REDLIN    193
*IF MIBM                                                                REDLIN    194
*ENDIF                                                                  REDLIN    196
 1030 FORMAT(A)                                                         REDLIN    197
 1040 FORMAT(1X,' CONTENT OF REBUF>',A80,'<')                           REDLIN    198
 1050 FORMAT(1X,A,'-->',A)                                              REDLIN    199
 1060 FORMAT(1X,A)                                                      REDLIN    200
 5010 FORMAT(/,                                                         REDLIN    201
     1  10X,'................................................',/,       REDLIN    202
     1  10X,':   -- NO MORE COMMANDS IN RESPONSE FILE --    :',/,       REDLIN    203
     1  10X,':      COMMAND INPUT DEFAULTS TO TERMINAL.     :',/,       REDLIN    204
     1  10X,':..............................................:',/)       REDLIN    205
 5020 FORMAT(' PROCESSING THE ABOVE PLAYBACK INSTRUCTION (NUMBER',I5    REDLIN    206
     &,')')                                                             REDLIN    207
C                                                                       REDLIN    208
      END                                                               REDLIN    209
C                                                                       REDLIN    210
      SUBROUTINE HHMMSS(CTIME)                                          REDLIN    211
CD                                                                      REDLIN    212
CD    TO OBTAIN THE TIME OF THE RUN                                     REDLIN    213
CD                                                                      REDLIN    214
      CHARACTER*(*) CTIME                                               REDLIN    215
*IF -VAX                                                                REDLIN    216
      CTIME='00:00:00'                                                  REDLIN    217
*ENDIF                                                                  REDLIN    218
*IF VAX                                                                 REDLIN    219
*ENDIF                                                                  REDLIN    221
      RETURN                                                            REDLIN    222
      END                                                               REDLIN    223
C                                                                       REDLIN    224
      SUBROUTINE BUSCID(ICODE,NLF,BNAME1,UID,KLFO)                      REDLIN    225
CD                                                                      REDLIN    226
CD    TO INPUT BUS NAME/NUMBER AND CIRCUIT IDENTITY.                    REDLIN    227
CD                                                                      REDLIN    228
      INCLUDE 'CNLSTA.INS'                                              REDLIN    229
      CHARACTER*80 STRING,MSG                                           REDLIN    230
      CHARACTER*32 CNAME                                                REDLIN    231
      CHARACTER*20 UDNAME                                               REDLIN    232
      CHARACTER*12 BNAME1,BNAME2,BNAME                                  REDLIN    233
      CHARACTER*8 DCNAME                                                REDLIN    234
      CHARACTER*2  CID,SID,UID                                          REDLIN    235
      CHARACTER*1 SEPAT                                                 REDLIN    236
      INTEGER LVAR(5),KVAR(5)                                           REDLIN    237
      LOGICAL  ABORT                                                    REDLIN    238
      DATA SEPAT/';'/                                                   REDLIN    239
C                                                                       REDLIN    240
      IMOVE=0                                                           REDLIN    241
 20   CONTINUE                                                          REDLIN    242
      IMOVE=IMOVE+1                                                     REDLIN    243
      IF(IMOVE.GT.5)THEN                                                REDLIN    244
         WRITE(LOUT,'(/A/)')                                            REDLIN    245
     1   ' *** ERROR TOO MANY INVALID BUS NUMBERS/NAMES'                REDLIN    246
         ICODE=1                                                        REDLIN    247
         RETURN                                                         REDLIN    248
      ENDIF                                                             REDLIN    249
 25   IF(ICODE.EQ.2) THEN                                               REDLIN    250
        IF (KLFO.EQ.0) THEN                                             REDLIN    251
           WRITE(LOUT,1201)                                             REDLIN    252
        ELSE                                                            REDLIN    253
           WRITE(LOUT,1301)                                             REDLIN    254
        END IF                                                          REDLIN    255
      ELSEIF(ICODE.EQ.3)THEN                                            REDLIN    256
        IF (KLFO.EQ.0) THEN                                             REDLIN    257
           WRITE(LOUT,1202)                                             REDLIN    258
        ELSE                                                            REDLIN    259
           WRITE(LOUT,1302)                                             REDLIN    260
        END IF                                                          REDLIN    261
      ELSE                                                              REDLIN    262
        IF (KLFO.EQ.0) THEN                                             REDLIN    263
           WRITE(LOUT,1200)                                             REDLIN    264
        ELSE                                                            REDLIN    265
           WRITE(LOUT,1300)                                             REDLIN    266
        END IF                                                          REDLIN    267
      ENDIF                                                             REDLIN    268
      CALL READSC(LOUT,LIN,IOERR,STRING,KREAD,PLAYBA)                   REDLIN    269
      IF (IOERR.NE.0)THEN                                               REDLIN    270
      IF(PLAYBA)CALL PSTOP                                              REDLIN    271
      GOTO 20                                                           REDLIN    272
      ENDIF                                                             REDLIN    273
      IF (RECORD.AND.IREC.NE.0) WRITE(IREC,'(A)') STRING                REDLIN    274
      IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN                REDLIN    275
         ICODE=1                                                        REDLIN    276
         RETURN                                                         REDLIN    277
      ELSE IF (STRING(1:3).EQ.'HEL'.OR.STRING(1:3).EQ.'hel') THEN       REDLIN    278
         CALL HELPSC('RR5',3)                                           REDLIN    279
         GOTO 25                                                        REDLIN    280
      END IF                                                            REDLIN    281
C                                                                       REDLIN    282
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    283
      I1=I+INDEX(STRING(I:80),SEPAT)                                    REDLIN    284
      IF(I1.EQ.I) GOTO 20                                               REDLIN    285
      IF(KLFO.EQ.0)THEN                                                 REDLIN    286
        READ(STRING(I:I1-2),*) NLF                                      REDLIN    287
      ELSE                                                              REDLIN    288
        I2=MIN(I1-2,I+11)                                               REDLIN    289
        BNAME1='            '                                           REDLIN    290
        BNAME1=STRING(I:I2)                                             REDLIN    291
        CALL CHKBUS(BNAME1,NLF)                                         REDLIN    292
        IF(NLF.EQ.0)THEN                                                REDLIN    293
          WRITE(LOUT,1100) BNAME1                                       REDLIN    294
          IF(PLAYBA)CALL PSTOP                                          REDLIN    295
          GOTO 20                                                       REDLIN    296
        ENDIF                                                           REDLIN    297
      ENDIF                                                             REDLIN    298
      UID=STRING(I1:I1+1)                                               REDLIN    299
      ICODE=0                                                           REDLIN    300
      RETURN                                                            REDLIN    301
C                                                                       REDLIN    302
      ENTRY FNZBUS(ICODE,NLFF,NLFT,BNAME1,BNAME2,KLFO,JCAB)             REDLIN    303
CD                                                                      REDLIN    304
CD    TO ENTER ZERO POTENTIAL BUS.                                      REDLIN    305
CD                                                                      REDLIN    306
 40   IOERR=0                                                           REDLIN    307
      WRITE(LOUT,1000)                                                  REDLIN    308
      MSG='IS THERE A FAULT AND/OR ZERO POTENTIAL BUS ? (Y/N)'          REDLIN    309
      CALL PMTRED(LOUT,LIN,IOERR,50,MSG,'XXX',STRING,KREAD,PLAYBA)      REDLIN    310
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    311
      IF(IOERR.LT.0)THEN                                                REDLIN    312
      IF(PLAYBA)CALL PSTOP                                              REDLIN    313
      GOTO 40                                                           REDLIN    314
      ENDIF                                                             REDLIN    315
      IF(ABORT(STRING))THEN                                             REDLIN    316
       JCAB=-1                                                          REDLIN    317
       RETURN                                                           REDLIN    318
      ENDIF                                                             REDLIN    319
C                                                                       REDLIN    320
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') THEN                 REDLIN    321
         NLFF=0                                                         REDLIN    322
         NLFT=0                                                         REDLIN    323
         BNAME1='            '                                          REDLIN    324
         BNAME2='            '                                          REDLIN    325
         ICODE=0                                                        REDLIN    326
         RETURN                                                         REDLIN    327
      ELSEIF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN             REDLIN    328
         KREAD=.TRUE.                                                   REDLIN    329
         GOTO 40                                                        REDLIN    330
      ENDIF                                                             REDLIN    331
C                                                                       REDLIN    332
 60   IOERR=0                                                           REDLIN    333
      WRITE(LOUT,1000)                                                  REDLIN    334
      IF(KLFO.EQ.0) THEN                                                REDLIN    335
       MSG='ENTER ;FAULT BUS NO. ;ZERO POTENTIAL BUS NO. (Q TO QUIT):  'REDLIN    336
      ELSE                                                              REDLIN    337
       MSG='ENTER ;FAULT BUS NAME ;ZERO POTENTIAL BUS NAME (Q TO QUIT):'REDLIN    338
      ENDIF                                                             REDLIN    339
      CALL PMTRED(LOUT,LIN,IOERR,59,MSG,'RR6',STRING,KREAD,PLAYBA)      REDLIN    340
      IF(IOERR.LT.0)THEN                                                REDLIN    341
      IF(PLAYBA)CALL PSTOP                                              REDLIN    342
      GOTO 60                                                           REDLIN    343
      ENDIF                                                             REDLIN    344
C                                                                       REDLIN    345
      IF(ABORT(STRING))THEN                                             REDLIN    346
       JCAB=-1                                                          REDLIN    347
       RETURN                                                           REDLIN    348
      ENDIF                                                             REDLIN    349
C                                                                       REDLIN    350
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    351
C                                                                       REDLIN    352
      NLFF=0                                                            REDLIN    353
      NLFT=0                                                            REDLIN    354
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    355
      I1=I+INDEX(STRING(I:80),SEPAT)                                    REDLIN    356
      IF(I1.EQ.I)THEN                                                   REDLIN    357
      IF(PLAYBA)CALL PSTOP                                              REDLIN    358
      GOTO 60                                                           REDLIN    359
      ENDIF                                                             REDLIN    360
      I2=MIN(I1-2,I+11)                                                 REDLIN    361
      IF(KLFO.EQ.0)THEN                                                 REDLIN    362
        READ(STRING(I:I2),*) NLFF                                       REDLIN    363
        READ(STRING(I1:80),*) NLFT                                      REDLIN    364
      ELSE                                                              REDLIN    365
        BNAME1='            '                                           REDLIN    366
        BNAME1=STRING(I:I2)                                             REDLIN    367
        BNAME2=STRING(I1:I1+11)                                         REDLIN    368
      ENDIF                                                             REDLIN    369
      ICODE=1                                                           REDLIN    370
      RETURN                                                            REDLIN    371
C                                                                       REDLIN    372
      ENTRY LINESI(ICODE,NLFF,NLFT,BNAME1,BNAME2,CID,SID,KLFO)          REDLIN    373
CD                                                                      REDLIN    374
CD    TO INPUT LINE WITH CIRCUIT AND SECTION IDENTITY.                  REDLIN    375
CD                                                                      REDLIN    376
  80  IOERR=0                                                           REDLIN    377
      WRITE(LOUT,1000)                                                  REDLIN    378
      IF(KLFO.EQ.0) THEN                                                REDLIN    379
        MSG='ENTER ;FROM-BUS NO. ;TO-BUS NO. ;CIRCUIT ID '//            REDLIN    380
     1      ';SECTION ID (Q TO QUIT):  '                                REDLIN    381
      ELSE                                                              REDLIN    382
        MSG='ENTER ;FROM-BUS NAME ;TO-BUS NAME ;CIRCUIT ID '//          REDLIN    383
     1      ';SECTION ID (Q TO QUIT):'                                  REDLIN    384
      ENDIF                                                             REDLIN    385
      CALL PMTRED(LOUT,LIN,IOERR,70,MSG,'RR7',STRING,KREAD,PLAYBA)      REDLIN    386
      IF(IOERR.LT.0)THEN                                                REDLIN    387
      IF(PLAYBA)CALL PSTOP                                              REDLIN    388
      GOTO 80                                                           REDLIN    389
      ENDIF                                                             REDLIN    390
C                                                                       REDLIN    391
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    392
       ICODE=-1                                                         REDLIN    393
       RETURN                                                           REDLIN    394
      ENDIF                                                             REDLIN    395
C                                                                       REDLIN    396
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    397
C                                                                       REDLIN    398
      I1=INDEX(STRING,SEPAT)                                            REDLIN    399
      I2=I1+INDEX(STRING(I1+1:80),SEPAT)                                REDLIN    400
      I3=I2+INDEX(STRING(I2+1:80),SEPAT)                                REDLIN    401
      I4=I3+INDEX(STRING(I3+1:80),SEPAT)                                REDLIN    402
      IF(I3.EQ.I4)THEN                                                  REDLIN    403
      IF(PLAYBA)CALL PSTOP                                              REDLIN    404
      GOTO 80                                                           REDLIN    405
      ENDIF                                                             REDLIN    406
      IF(KLFO.EQ.0)THEN                                                 REDLIN    407
        READ(STRING(I1+1:I2-1),*) NLFF                                  REDLIN    408
        READ(STRING(I2+1:I3-1),*) NLFT                                  REDLIN    409
      ELSE                                                              REDLIN    410
        I=MIN(I1+12,I2-1)                                               REDLIN    411
        BNAME1='            '                                           REDLIN    412
        BNAME1=STRING(I1+1:I)                                           REDLIN    413
        I=MIN(I2+12,I3-1)                                               REDLIN    414
        BNAME2='            '                                           REDLIN    415
        BNAME2=STRING(I2+1:I)                                           REDLIN    416
      ENDIF                                                             REDLIN    417
      CID=STRING(I3+1:I3+2)                                             REDLIN    418
      SID=STRING(I4+1:I4+2)                                             REDLIN    419
      ICODE=0                                                           REDLIN    420
      RETURN                                                            REDLIN    421
C                                                                       REDLIN    422
      ENTRY LINEID(ICODE,NLFF,NLFT,BNAME1,BNAME2,CID,KLFO)              REDLIN    423
CD                                                                      REDLIN    424
CD    TO INPUT LINE WITH CIRCUIT IDENTITY.                              REDLIN    425
CD                                                                      REDLIN    426
 100  IOERR=0                                                           REDLIN    427
      WRITE(LOUT,1000)                                                  REDLIN    428
      IF(KLFO.EQ.0) THEN                                                REDLIN    429
        MSG='ENTER ;FROM-BUS NO. ;TO-BUS NO. ;CIRCUIT ID (Q TO QUIT):  'REDLIN    430
      ELSE                                                              REDLIN    431
        MSG='ENTER ;FROM-BUS NAME ;TO-BUS NAME ;CIRCUIT ID (Q TO QUIT):'REDLIN    432
      ENDIF                                                             REDLIN    433
      CALL PMTRED(LOUT,LIN,IOERR,58,MSG,'RR8',STRING,KREAD,PLAYBA)      REDLIN    434
      IF(IOERR.LT.0)THEN                                                REDLIN    435
      IF(PLAYBA)CALL PSTOP                                              REDLIN    436
      GOTO 100                                                          REDLIN    437
      ENDIF                                                             REDLIN    438
C                                                                       REDLIN    439
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    440
       ICODE=-1                                                         REDLIN    441
       RETURN                                                           REDLIN    442
      ENDIF                                                             REDLIN    443
C                                                                       REDLIN    444
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    445
C                                                                       REDLIN    446
      I1=INDEX(STRING,SEPAT)                                            REDLIN    447
      I2=I1+INDEX(STRING(I1+1:80),SEPAT)                                REDLIN    448
      I3=I2+INDEX(STRING(I2+1:80),SEPAT)                                REDLIN    449
      IF(I3.EQ.I2)THEN                                                  REDLIN    450
      IF(PLAYBA)CALL PSTOP                                              REDLIN    451
      GOTO 100                                                          REDLIN    452
      ENDIF                                                             REDLIN    453
      IF(KLFO.EQ.0)THEN                                                 REDLIN    454
        READ(STRING(I1+1:I2-1),*) NLFF                                  REDLIN    455
        READ(STRING(I2+1:I3-1),*) NLFT                                  REDLIN    456
      ELSE                                                              REDLIN    457
        I=MIN(I1+12,I2-1)                                               REDLIN    458
        BNAME1='            '                                           REDLIN    459
        BNAME1=STRING(I1+1:I)                                           REDLIN    460
        I=MIN(I2+12,I3-1)                                               REDLIN    461
        BNAME2='            '                                           REDLIN    462
        BNAME2=STRING(I2+1:I)                                           REDLIN    463
      ENDIF                                                             REDLIN    464
      CID=STRING(I3+1:I3+2)                                             REDLIN    465
      ICODE=0                                                           REDLIN    466
      RETURN                                                            REDLIN    467
C                                                                       REDLIN    468
      ENTRY COVNAM(ICODE,CNAME)                                         REDLIN    469
CD                                                                      REDLIN    470
CD    TO INPUT CONVERTER NAME.                                          REDLIN    471
CD                                                                      REDLIN    472
 120  IOERR=0                                                           REDLIN    473
      WRITE(LOUT,1000)                                                  REDLIN    474
      MSG='ENTER ;CONVERTER NAME (Q TO QUIT):'                          REDLIN    475
      CALL PMTRED(LOUT,LIN,IOERR,34,MSG,'RR9',STRING,KREAD,PLAYBA)      REDLIN    476
      IF(IOERR.LT.0)THEN                                                REDLIN    477
      IF(PLAYBA)CALL PSTOP                                              REDLIN    478
      GOTO 120                                                          REDLIN    479
      ENDIF                                                             REDLIN    480
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    481
       ICODE=-1                                                         REDLIN    482
       RETURN                                                           REDLIN    483
      ENDIF                                                             REDLIN    484
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    485
C                                                                       REDLIN    486
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    487
      IF(I.EQ.1)THEN                                                    REDLIN    488
      IF(PLAYBA)CALL PSTOP                                              REDLIN    489
      GOTO 120                                                          REDLIN    490
      ENDIF                                                             REDLIN    491
      CNAME=STRING(I:I+31)                                              REDLIN    492
      ICODE=0                                                           REDLIN    493
      RETURN                                                            REDLIN    494
C                                                                       REDLIN    495
      ENTRY UDCNAM(ICODE,UDNAME)                                        REDLIN    496
CD                                                                      REDLIN    497
CD    TO INPUT DC CONTROL BLOCK NAME.                                   REDLIN    498
CD                                                                      REDLIN    499
 140  IOERR=0                                                           REDLIN    500
      WRITE(LOUT,1000)                                                  REDLIN    501
      MSG='ENTER ;DC CONTROL BLOCK NAME (Q TO QUIT):'                   REDLIN    502
      CALL PMTRED(LOUT,LIN,IOERR,41,MSG,'R10',STRING,KREAD,PLAYBA)      REDLIN    503
      IF(IOERR.LT.0)THEN                                                REDLIN    504
      IF(PLAYBA)CALL PSTOP                                              REDLIN    505
      GOTO 140                                                          REDLIN    506
      ENDIF                                                             REDLIN    507
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    508
       ICODE=-1                                                         REDLIN    509
       RETURN                                                           REDLIN    510
      ENDIF                                                             REDLIN    511
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    512
C                                                                       REDLIN    513
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    514
      IF(I.EQ.1)THEN                                                    REDLIN    515
      IF(PLAYBA)CALL PSTOP                                              REDLIN    516
      GOTO 140                                                          REDLIN    517
      ENDIF                                                             REDLIN    518
      UDNAME=STRING(I:I+19)                                             REDLIN    519
      ICODE=0                                                           REDLIN    520
      RETURN                                                            REDLIN    521
C                                                                       REDLIN    522
      ENTRY DCBNAM(ICODE,DCNAME)                                        REDLIN    523
CD                                                                      REDLIN    524
CD    TO INPUT DC BUS NAME.                                             REDLIN    525
CD                                                                      REDLIN    526
 160  IOERR=0                                                           REDLIN    527
      WRITE(LOUT,1000)                                                  REDLIN    528
      MSG='ENTER ;DC BUS NAME (Q TO QUIT):'                             REDLIN    529
      CALL PMTRED(LOUT,LIN,IOERR,31,MSG,'R11',STRING,KREAD,PLAYBA)      REDLIN    530
      IF(IOERR.LT.0)THEN                                                REDLIN    531
      IF(PLAYBA)CALL PSTOP                                              REDLIN    532
      GOTO 160                                                          REDLIN    533
      ENDIF                                                             REDLIN    534
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    535
       ICODE=-1                                                         REDLIN    536
       RETURN                                                           REDLIN    537
      ENDIF                                                             REDLIN    538
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    539
C                                                                       REDLIN    540
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    541
      IF(I.EQ.1)THEN                                                    REDLIN    542
      IF(PLAYBA)CALL PSTOP                                              REDLIN    543
      GOTO 160                                                          REDLIN    544
      ENDIF                                                             REDLIN    545
      DCNAME=STRING(I:I+7)                                              REDLIN    546
      ICODE=0                                                           REDLIN    547
      RETURN                                                            REDLIN    548
C                                                                       REDLIN    549
      ENTRY BUSVAR(ICODE,NLF,BNAME1,KLFO,NVAR,KVAR)                     REDLIN    550
CD                                                                      REDLIN    551
CD    TO INPUT BUS NUMBER/NAME AND VARIABLE NUMBERS.                    REDLIN    552
CD                                                                      REDLIN    553
      NVAR=0                                                            REDLIN    554
      CALL MOVE(0,KVAR,KVAR,5)                                          REDLIN    555
 180  IOERR=0                                                           REDLIN    556
      WRITE(LOUT,1000)                                                  REDLIN    557
      IF(KLFO.EQ.0) THEN                                                REDLIN    558
         MSG='ENTER ;BUS NUMBER (Q TO QUIT):'                           REDLIN    559
      ELSE                                                              REDLIN    560
         MSG='ENTER ;BUS NAME (Q TO QUIT):  '                           REDLIN    561
      ENDIF                                                             REDLIN    562
      CALL PMTRED(LOUT,LIN,IOERR,30,MSG,'R12',STRING,KREAD,PLAYBA)      REDLIN    563
      IF(IOERR.LT.0) GOTO 180                                           REDLIN    564
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    565
       ICODE=-1                                                         REDLIN    566
       RETURN                                                           REDLIN    567
      ENDIF                                                             REDLIN    568
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    569
C                                                                       REDLIN    570
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    571
      IF(I.EQ.1)THEN                                                    REDLIN    572
      IF(PLAYBA)CALL PSTOP                                              REDLIN    573
      GOTO 180                                                          REDLIN    574
      ENDIF                                                             REDLIN    575
      IF(KLFO.EQ.0)THEN                                                 REDLIN    576
         READ(STRING(I1:80),*) NLF                                      REDLIN    577
      ELSE                                                              REDLIN    578
        BNAME1=STRING(I:I+11)                                           REDLIN    579
        CALL CHKBUS(BNAME1,NLF)                                         REDLIN    580
        IF(NLF.EQ.0)THEN                                                REDLIN    581
          WRITE(LOUT,1100) BNAME1                                       REDLIN    582
          IF(PLAYBA)CALL PSTOP                                          REDLIN    583
          GOTO 180                                                      REDLIN    584
        ENDIF                                                           REDLIN    585
      ENDIF                                                             REDLIN    586
 200  IOERR=0                                                           REDLIN    587
      WRITE(LOUT,1000)                                                  REDLIN    588
      MSG='ENTER BLOCK NUMBERS - NOT MORE THAN 5 (Q TO QUIT):'          REDLIN    589
      CALL PMTRED(LOUT,LIN,IOERR,50,MSG,'R13',STRING,KREAD,PLAYBA)      REDLIN    590
      IF(IOERR.LT.0)THEN                                                REDLIN    591
      IF(PLAYBA)CALL PSTOP                                              REDLIN    592
      GOTO 200                                                          REDLIN    593
      ENDIF                                                             REDLIN    594
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    595
       ICODE=-1                                                         REDLIN    596
       RETURN                                                           REDLIN    597
      ENDIF                                                             REDLIN    598
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    599
C                                                                       REDLIN    600
      STRING(80:80)='/'                                                 REDLIN    601
      CALL MOVE(0,LVAR,LVAR,5)                                          REDLIN    602
      READ(STRING,*) LVAR                                               REDLIN    603
      DO 220 J=1,5                                                      REDLIN    604
      IF(LVAR(J).NE.0)THEN                                              REDLIN    605
      NVAR=NVAR+1                                                       REDLIN    606
      IF(NVAR.GT.5)GOTO 240                                             REDLIN    607
      KVAR(NVAR)=LVAR(J)                                                REDLIN    608
      ENDIF                                                             REDLIN    609
 220  CONTINUE                                                          REDLIN    610
      IF(NVAR.LT.5)GOTO 200                                             REDLIN    611
 240  CONTINUE                                                          REDLIN    612
      ICODE=0                                                           REDLIN    613
      RETURN                                                            REDLIN    614
C                                                                       REDLIN    615
      ENTRY BNOVAR(ICODE,NLF,BNAME1,KLFO)                               REDLIN    616
CD                                                                      REDLIN    617
CD    TO INPUT BUS NAME/NUMBER.                                         REDLIN    618
CD                                                                      REDLIN    619
 260  IOERR=0                                                           REDLIN    620
      WRITE(LOUT,1000)                                                  REDLIN    621
      IF(KLFO.EQ.0)THEN                                                 REDLIN    622
         MSG='ENTER ;BUS NUMBER (Q TO QUIT):'                           REDLIN    623
      ELSE                                                              REDLIN    624
         MSG='ENTER ;BUS NAME (Q TO QUIT):  '                           REDLIN    625
      ENDIF                                                             REDLIN    626
      CALL PMTRED(LOUT,LIN,IOERR,30,MSG,'R12',STRING,KREAD,PLAYBA)      REDLIN    627
      IF(IOERR.LT.0)THEN                                                REDLIN    628
      IF(PLAYBA)CALL PSTOP                                              REDLIN    629
      GOTO 260                                                          REDLIN    630
      ENDIF                                                             REDLIN    631
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    632
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    633
       ICODE=-1                                                         REDLIN    634
       RETURN                                                           REDLIN    635
      ENDIF                                                             REDLIN    636
C                                                                       REDLIN    637
      I=INDEX(STRING,SEPAT)+1                                           REDLIN    638
      IF(I.EQ.1)THEN                                                    REDLIN    639
      IF(PLAYBA)CALL PSTOP                                              REDLIN    640
      GOTO 260                                                          REDLIN    641
      ENDIF                                                             REDLIN    642
      IF(KLFO.EQ.0)THEN                                                 REDLIN    643
        READ(STRING(I:80),*) NLF                                        REDLIN    644
      ELSE                                                              REDLIN    645
        BNAME1=STRING(I:I+11)                                           REDLIN    646
        CALL CHKBUS(BNAME1,NLF)                                         REDLIN    647
        IF(NLF.EQ.0)THEN                                                REDLIN    648
          WRITE(LOUT,1100) BNAME1                                       REDLIN    649
          IF(PLAYBA)CALL PSTOP                                          REDLIN    650
          GOTO 260                                                      REDLIN    651
        ENDIF                                                           REDLIN    652
      ENDIF                                                             REDLIN    653
      ICODE=0                                                           REDLIN    654
      RETURN                                                            REDLIN    655
C                                                                       REDLIN    656
      ENTRY BUCVAR(ICODE,NLF,BNAME1,UID,KLFO,NVAR,KVAR)                 REDLIN    657
CD                                                                      REDLIN    658
CD    TO INPUT GENERATOR NUMBER/NAME, IDENTITY AND VARIABLE NUMBERS.    REDLIN    659
CD                                                                      REDLIN    660
      NVAR=0                                                            REDLIN    661
      CALL MOVE(0,KVAR,KVAR,5)                                          REDLIN    662
 280  IOERR=0                                                           REDLIN    663
      WRITE(LOUT,1000)                                                  REDLIN    664
      IF(KLFO.EQ.0) THEN                                                REDLIN    665
        IF(ICODE.EQ.1)THEN                                              REDLIN    666
          WRITE(MSG,1200)                                               REDLIN    667
          LMSG=46                                                       REDLIN    668
        ELSE                                                            REDLIN    669
          WRITE(MSG,1201)                                               REDLIN    670
          LMSG=40                                                       REDLIN    671
        ENDIF                                                           REDLIN    672
      ELSE                                                              REDLIN    673
        IF(ICODE.EQ.1)THEN                                              REDLIN    674
          WRITE(MSG,1300)                                               REDLIN    675
          LMSG=44                                                       REDLIN    676
        ELSE                                                            REDLIN    677
          WRITE(MSG,1301)                                               REDLIN    678
          LMSG=38                                                       REDLIN    679
        ENDIF                                                           REDLIN    680
      ENDIF                                                             REDLIN    681
      CALL PMTRED(LOUT,LIN,IOERR,LMSG,MSG,'RR5',STRING,KREAD,PLAYBA)    REDLIN    682
      IF(IOERR.LT.0)THEN                                                REDLIN    683
      IF(PLAYBA)CALL PSTOP                                              REDLIN    684
      GOTO 280                                                          REDLIN    685
      ENDIF                                                             REDLIN    686
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    687
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    688
       ICODE=-1                                                         REDLIN    689
       RETURN                                                           REDLIN    690
      ENDIF                                                             REDLIN    691
C                                                                       REDLIN    692
      I=INDEX(STRING,SEPAT)                                             REDLIN    693
      I1=I+INDEX(STRING(I+1:80),SEPAT)                                  REDLIN    694
      IF(I.EQ.I1)THEN                                                   REDLIN    695
      IF(PLAYBA)CALL PSTOP                                              REDLIN    696
      GOTO 280                                                          REDLIN    697
      ENDIF                                                             REDLIN    698
      IF(KLFO.EQ.0)THEN                                                 REDLIN    699
        READ(STRING(I+1:I1-1),*) NLF                                    REDLIN    700
      ELSE                                                              REDLIN    701
        BNAME1='            '                                           REDLIN    702
        I2=MIN(I1-1,I+12)                                               REDLIN    703
        BNAME1=STRING(I+1:I2)                                           REDLIN    704
        CALL CHKBUS(BNAME1,NLF)                                         REDLIN    705
        IF(NLF.EQ.0)THEN                                                REDLIN    706
          WRITE(LOUT,1100) BNAME1                                       REDLIN    707
          IF(PLAYBA)CALL PSTOP                                          REDLIN    708
          GOTO 280                                                      REDLIN    709
        ENDIF                                                           REDLIN    710
      ENDIF                                                             REDLIN    711
      UID=STRING(I1+1:I1+2)                                             REDLIN    712
 300  IOERR=0                                                           REDLIN    713
      WRITE(LOUT,1000)                                                  REDLIN    714
      MSG='ENTER STATE NUMBERS - NOT MORE THAN 5 (Q TO QUIT):'          REDLIN    715
      CALL PMTRED(LOUT,LIN,IOERR,50,MSG,'R14',STRING,KREAD,PLAYBA)      REDLIN    716
      IF(IOERR.LT.0)THEN                                                REDLIN    717
      IF(PLAYBA)CALL PSTOP                                              REDLIN    718
      GOTO 300                                                          REDLIN    719
      ENDIF                                                             REDLIN    720
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    721
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    722
       ICODE=0                                                          REDLIN    723
       RETURN                                                           REDLIN    724
      ENDIF                                                             REDLIN    725
C                                                                       REDLIN    726
      STRING(80:80)='/'                                                 REDLIN    727
      CALL MOVE(0,LVAR,LVAR,5)                                          REDLIN    728
      READ(STRING,*) LVAR                                               REDLIN    729
      DO 320 J=1,5                                                      REDLIN    730
      IF(LVAR(J).NE.0)THEN                                              REDLIN    731
      NVAR=NVAR+1                                                       REDLIN    732
      IF(NVAR.GT.5)GOTO 340                                             REDLIN    733
      KVAR(NVAR)=LVAR(J)                                                REDLIN    734
      ENDIF                                                             REDLIN    735
 320  CONTINUE                                                          REDLIN    736
      IF(NVAR.LT.5)GOTO 300                                             REDLIN    737
 340  CONTINUE                                                          REDLIN    738
      ICODE=0                                                           REDLIN    739
      RETURN                                                            REDLIN    740
C                                                                       REDLIN    741
      ENTRY FTNCID(ICODE,NLFF,NLFT,UID,KLFO)                            REDLIN    742
CD                                                                      REDLIN    743
CD    TO INPUT FROM- AND TO- BUS AND CIRCUIT IDENTITY.                  REDLIN    744
CD                                                                      REDLIN    745
 360  IOERR=0                                                           REDLIN    746
      WRITE(LOUT,1000)                                                  REDLIN    747
      IF(KLFO.EQ.0) THEN                                                REDLIN    748
        MSG='ENTER ;FROM-BUS NO. ;TO-BUS NO. ;CIRCUIT ID (Q TO QUIT):  'REDLIN    749
      ELSE                                                              REDLIN    750
        MSG='ENTER ;FROM-BUS NAME ;TO-BUS NAME ;CIRCUIT ID (Q TO QUIT):'REDLIN    751
      ENDIF                                                             REDLIN    752
      CALL PMTRED(LOUT,LIN,IOERR,58,MSG,'RR8',STRING,KREAD,PLAYBA)      REDLIN    753
      IF(IOERR.LT.0)THEN                                                REDLIN    754
      IF(PLAYBA)CALL PSTOP                                              REDLIN    755
      GOTO 360                                                          REDLIN    756
      ENDIF                                                             REDLIN    757
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    758
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    759
       ICODE=-1                                                         REDLIN    760
       RETURN                                                           REDLIN    761
      ENDIF                                                             REDLIN    762
C                                                                       REDLIN    763
      I1=INDEX(STRING,SEPAT)                                            REDLIN    764
      I2=I1+INDEX(STRING(I1+1:80),SEPAT)                                REDLIN    765
      I3=I2+INDEX(STRING(I2+1:80),SEPAT)                                REDLIN    766
      IF((I1+1.GT.I2-1).OR.(I2+1.GT.I3-1))THEN                          REDLIN    767
        IF(PLAYBA)CALL PSTOP                                            REDLIN    768
        GOTO 360                                                        REDLIN    769
      ENDIF                                                             REDLIN    770
      IF(KLFO.EQ.0)THEN                                                 REDLIN    771
        READ(STRING(I1+1:I2-1),*,IOSTAT=IOS) NLFF                       REDLIN    772
        IF(IOS.NE.0)THEN                                                REDLIN    773
          IF(PLAYBA)CALL PSTOP                                          REDLIN    774
          GOTO 360                                                      REDLIN    775
        ENDIF                                                           REDLIN    776
        READ(STRING(I2+1:I3-1),*,IOSTAT=IOS) NLFT                       REDLIN    777
        IF(IOS.NE.0)THEN                                                REDLIN    778
          IF(PLAYBA)CALL PSTOP                                          REDLIN    779
          GOTO 360                                                      REDLIN    780
        ENDIF                                                           REDLIN    781
      ELSE                                                              REDLIN    782
        I=MIN(I1+12,I2-1)                                               REDLIN    783
        BNAME=STRING(I1+1:I)                                            REDLIN    784
        CALL CHKBUS (BNAME,NLFF)                                        REDLIN    785
        IF(NLFF.EQ.0)THEN                                               REDLIN    786
          WRITE(LOUT,1100)BNAME                                         REDLIN    787
          IF(PLAYBA)CALL PSTOP                                          REDLIN    788
          GOTO 360                                                      REDLIN    789
        ENDIF                                                           REDLIN    790
        I=MIN(I2+12,I3-1)                                               REDLIN    791
        BNAME=STRING(I2+1:I)                                            REDLIN    792
        CALL CHKBUS (BNAME,NLFT)                                        REDLIN    793
        IF(NLFT.EQ.0)THEN                                               REDLIN    794
          WRITE(LOUT,1100)BNAME                                         REDLIN    795
          IF(PLAYBA)CALL PSTOP                                          REDLIN    796
          GOTO 360                                                      REDLIN    797
        ENDIF                                                           REDLIN    798
      ENDIF                                                             REDLIN    799
      UID=STRING(I3+1:I3+2)                                             REDLIN    800
C                                                                       REDLIN    801
      ICODE=0                                                           REDLIN    802
      RETURN                                                            REDLIN    803
C                                                                       REDLIN    804
      ENTRY FTNVAR(ICODE,NLFF,NLFT,UID,KLFO,NVAR,KVAR)                  REDLIN    805
CD                                                                      REDLIN    806
CD    TO INPUT FROM- AND TO- BUS, CIRCUIT IDENTITY AND VARIABLE NUMBERS.REDLIN    807
CD                                                                      REDLIN    808
 380  IOERR=0                                                           REDLIN    809
      WRITE(LOUT,1000)                                                  REDLIN    810
      IF(KLFO.EQ.0) THEN                                                REDLIN    811
        MSG='ENTER ;FROM-BUS NO. ;TO-BUS NO. ;CIRCUIT ID (Q TO QUIT):  'REDLIN    812
      ELSE                                                              REDLIN    813
        MSG='ENTER ;FROM-BUS NAME ;TO-BUS NAME ;CIRCUIT ID (Q TO QUIT):'REDLIN    814
      ENDIF                                                             REDLIN    815
      CALL PMTRED(LOUT,LIN,IOERR,58,MSG,'RR8',STRING,KREAD,PLAYBA)      REDLIN    816
      IF(IOERR.LT.0)THEN                                                REDLIN    817
      IF(PLAYBA)CALL PSTOP                                              REDLIN    818
      GOTO 380                                                          REDLIN    819
      ENDIF                                                             REDLIN    820
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    821
       ICODE=-1                                                         REDLIN    822
       RETURN                                                           REDLIN    823
      ENDIF                                                             REDLIN    824
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    825
C                                                                       REDLIN    826
      I1=INDEX(STRING,SEPAT)                                            REDLIN    827
      I2=I1+INDEX(STRING(I1+1:80),SEPAT)                                REDLIN    828
      I3=I2+INDEX(STRING(I2+1:80),SEPAT)                                REDLIN    829
      IF((I1+1.GT.I2-1).OR.(I2+1.GT.I3-1))THEN                          REDLIN    830
        IF(PLAYBA)CALL PSTOP                                            REDLIN    831
        GOTO 380                                                        REDLIN    832
      ENDIF                                                             REDLIN    833
      IF(KLFO.EQ.0)THEN                                                 REDLIN    834
        READ(STRING(I1+1:I2-1),*,IOSTAT=IOS) NLFF                       REDLIN    835
        IF(IOS.NE.0)THEN                                                REDLIN    836
          IF(PLAYBA)CALL PSTOP                                          REDLIN    837
          GOTO 380                                                      REDLIN    838
        ENDIF                                                           REDLIN    839
        READ(STRING(I2+1:I3-1),*,IOSTAT=IOS) NLFT                       REDLIN    840
        IF(IOS.NE.0)THEN                                                REDLIN    841
          IF(PLAYBA)CALL PSTOP                                          REDLIN    842
          GOTO 380                                                      REDLIN    843
        ENDIF                                                           REDLIN    844
      ELSE                                                              REDLIN    845
        I=MIN(I1+12,I2-1)                                               REDLIN    846
        BNAME=STRING(I1+1:I)                                            REDLIN    847
        CALL CHKBUS (BNAME,NLFF)                                        REDLIN    848
        IF(NLFF.EQ.0)THEN                                               REDLIN    849
          WRITE(LOUT,1100)BNAME                                         REDLIN    850
          IF(PLAYBA)CALL PSTOP                                          REDLIN    851
          GOTO 380                                                      REDLIN    852
        ENDIF                                                           REDLIN    853
        I=MIN(I2+12,I3-1)                                               REDLIN    854
        BNAME=STRING(I2+1:I)                                            REDLIN    855
        CALL CHKBUS (BNAME,NLFT)                                        REDLIN    856
        IF(NLFT.EQ.0)THEN                                               REDLIN    857
          WRITE(LOUT,1100)BNAME                                         REDLIN    858
          IF(PLAYBA)CALL PSTOP                                          REDLIN    859
          GOTO 380                                                      REDLIN    860
        ENDIF                                                           REDLIN    861
      ENDIF                                                             REDLIN    862
      UID=STRING(I3+1:I3+2)                                             REDLIN    863
C                                                                       REDLIN    864
 400  IOERR=0                                                           REDLIN    865
      WRITE(LOUT,1000)                                                  REDLIN    866
      MSG='ENTER BLOCK NUMBERS - NOT MORE THAN 5 (Q TO QUIT):'          REDLIN    867
      CALL PMTRED(LOUT,LIN,IOERR,50,MSG,'R13',STRING,KREAD,PLAYBA)      REDLIN    868
      IF(IOERR.LT.0)THEN                                                REDLIN    869
      IF(PLAYBA)CALL PSTOP                                              REDLIN    870
      GOTO 400                                                          REDLIN    871
      ENDIF                                                             REDLIN    872
      IF(ABORT(STRING).OR.STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q')THEN REDLIN    873
       ICODE=-1                                                         REDLIN    874
       RETURN                                                           REDLIN    875
      ENDIF                                                             REDLIN    876
      IF(RECORD) WRITE(IREC,'(A)') STRING                               REDLIN    877
C                                                                       REDLIN    878
      STRING(80:80)='/'                                                 REDLIN    879
      CALL MOVE(0,LVAR,LVAR,5)                                          REDLIN    880
      READ(STRING,*) LVAR                                               REDLIN    881
      DO 420 J=1,5                                                      REDLIN    882
      IF(LVAR(J).NE.0)THEN                                              REDLIN    883
      NVAR=NVAR+1                                                       REDLIN    884
      IF(NVAR.GT.5)GOTO 440                                             REDLIN    885
      KVAR(NVAR)=LVAR(J)                                                REDLIN    886
      ENDIF                                                             REDLIN    887
 420  CONTINUE                                                          REDLIN    888
      IF(NVAR.LT.5)GOTO 400                                             REDLIN    889
 440  CONTINUE                                                          REDLIN    890
      ICODE=0                                                           REDLIN    891
      RETURN                                                            REDLIN    892
C                                                                       REDLIN    893
 1000 FORMAT(1X,/)                                                      REDLIN    894
 1100 FORMAT(/,' *** ERROR BUS NAME ',A12,' IS NOT IN THE LOAD FLOW.',/)REDLIN    895
 1200 FORMAT(/,1X,'ENTER ;BUS NUMBER ;GENERATOR ID (Q TO QUIT):')       REDLIN    896
 1201 FORMAT(/,1X,'ENTER ;BUS NUMBER ;SVC ID (Q TO QUIT):')             REDLIN    897
 1202 FORMAT(/,1X,'ENTER ;BUS NUMBER ;MOTOR ID (Q TO QUIT):')           REDLIN    898
 1300 FORMAT(/,1X,'ENTER ;BUS NAME ;GENERATOR ID (Q TO QUIT):  ')       REDLIN    899
 1301 FORMAT(/,1X,'ENTER ;BUS NAME ;SVC ID (Q TO QUIT):')               REDLIN    900
 1302 FORMAT(/,1X,'ENTER ;BUS NAME ;MOTOR ID (Q TO QUIT):')             REDLIN    901
C                                                                       REDLIN    902
      END                                                               REDLIN    903
