CFPRIME RELAN                                                           RELAN       1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*               Output Analysis Program for ETMSP (OAP)               *RIGHTE      4
C*               =======================================               *RIGHTE      5
C*                                                                     *RIGHTE     11
C*        copyright @(1993) Electric Power Research Institute          *RIGHTE     12
C*                                                                     *RIGHTE     13
C* EPRI reserves all rights in the software and associated             *RIGHTE     14
C* documentation as delivered. The software and its associated         *RIGHTE     15
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     16
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     17
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     18
C* of any changes or modifications to the software within two (2)      *RIGHTE     19
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     20
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     21
C* new designation sufficiently different from its then current        *RIGHTE     22
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     23
C* the current software as changed or modified.                        *RIGHTE     24
C*                                                                     *RIGHTE     25
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     26
C* directly from EPRI.                                                 *RIGHTE     27
C*                                                                     *RIGHTE     28
C* This program and supporting materials may be independently available*RIGHTE     29
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     30
C* distribution fee. The EPSC is a service of                          *RIGHTE     31
C*                                                                     *RIGHTE     32
C*                    Power Computing Company                          *RIGHTE     33
C*                    1930 Hi Line                                     *RIGHTE     34
C*                    Dallas, Tx 75207                                 *RIGHTE     35
C*                                                                     *RIGHTE     36
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     37
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     38
C*                                                                     *RIGHTE     39
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     40
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     41
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     42
C*    DOCUMENTATION; OR                                                *RIGHTE     43
C*                                                                     *RIGHTE     44
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     45
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     46
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     47
C*                                                                     *RIGHTE     48
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     49
C* THEREOF.                                                            *RIGHTE     50
C*                                                                     *RIGHTE     51
C***********************************************************************RIGHTE     52
      SUBROUTINE RELAN                                                  RELAN       3
CD                                                                      RELAN       4
CD      THIS ROUTINE PARSES FOR THE RELAY MARGIN FILE NAME AND OTHER    RELAN       5
CD      SCALING INFORMATION AND THEN CALL SUBROUTINE RELMAR TO PERFORM  RELAN       6
CD      RELAY ANALYSIS.                                                 RELAN       7
CD                                                                      RELAN       8
      INCLUDE 'PARAM.INS'                                               RELAN       9
      INCLUDE 'JJNAME.INS'                                              RELAN      10
      INCLUDE 'SOAPC1.INS'                                              RELAN      11
      INCLUDE 'XYARAY.INS'                                              RELAN      12
      INCLUDE 'CNDATA.INS'                                              RELAN      13
      INCLUDE 'GPINFO.INS'                                              RELAN      14
      INCLUDE 'GTIT.INS'                                                RELAN      15
      INTEGER*4 JK,JLINE(3,2000),MLINE                                  RELAN      16
      REAL R(MXPT),X(MXPT),TT(MXPT)                                     RELAN      17
C                                                                       RELAN      18
      PARAMETER(MAXSTN=4096)                                            RELAN      19
      COMMON /RLNAME/ ICNAME(12,MAXSTN),NOENTY                          RELAN      20
      CHARACTER*12 JCNAME                                               RELAN      21
      EQUIVALENCE (ICNAME(1,1),JCNAME)                                  RELAN      22
C                                                                       RELAN      23
      COMMON /SCFLAG/ IFLG                                              RELAN      24
      COMMON /RECPT/ KRSTRT, ISTNAM, IIDARY, ITYARY, IHREC,ICHAN,       RELAN      25
     *          NPFL,LRREC,IRREC                                        RELAN      26
      EQUIVALENCE (TT(1),T(1,1))                                        RELAN      27
      CHARACTER*2 UID                                                   RELAN      28
      CHARACTER*80 MSG,RFILE,STRING                                     RELAN      29
      CHARACTER RLYID*12,STATUS*7,LINGEN*4                              RELAN      30
      LOGICAL FLAG,LREL                                                 RELAN      31
      SAVE JLINE,MLINE                                                  RELAN      32
      DATA LREL/.FALSE./,JLINE/6000*0/,MLINE/1/                         RELAN      33
C                                                                       RELAN      34
      IF(.NOT.OPENED)THEN                                               RELAN      35
         WRITE(LOUT,8000)                                               RELAN      36
         RETURN                                                         RELAN      37
      ENDIF                                                             RELAN      38
C                                                                       RELAN      39
      FLAG=.TRUE.                                                       RELAN      40
      CALL RLHEAD                                                       RELAN      41
      NLINE=0                                                           RELAN      42
      J=0                                                               RELAN      43
      DO 20 I=11,ICHAN                                                  RELAN      44
         CALL UNPACK(UID,NTYPE,ITY(1,I))                                RELAN      45
         IF(NTYPE.EQ.40)THEN                                            RELAN      46
            NLINE=NLINE+1                                               RELAN      47
            JLINE(1,NLINE)=I                                            RELAN      48
            J=J+1                                                       RELAN      49
            JLINE(3,NLINE)=J                                            RELAN      50
         ELSEIF(NTYPE.EQ.11)THEN                                        RELAN      51
            NLINE=NLINE+1                                               RELAN      52
            JLINE(1,NLINE)=I                                            RELAN      53
            JLINE(3,NLINE)=0                                            RELAN      54
         ENDIF                                                          RELAN      55
   20 CONTINUE                                                          RELAN      56
      ISTART=1                                                          RELAN      57
      IEND=MIN0(NLINE,18)                                               RELAN      58
C                                                                       RELAN      59
  100 CONTINUE                                                          RELAN      60
      WRITE(LOUT,8200)                                                  RELAN      61
      DO 200 I=ISTART,IEND                                              RELAN      62
         ILINE=JLINE(1,I)                                               RELAN      63
         IF(JLINE(3,I).GT.0)THEN                                        RELAN      64
            CALL GETJK(JLINE(3,I),JK,ICHNL,LOUT)                        RELAN      65
            CALL UPACKI(KRS,JRS,JK)                                     RELAN      66
            IF(JRS.NE.0)THEN                                            RELAN      67
               STATUS='TRIPPED'                                         RELAN      68
            ELSE                                                        RELAN      69
               STATUS='       '                                         RELAN      70
            ENDIF                                                       RELAN      71
            NRLY=MOD(KRS-10,32768)                                      RELAN      72
            IF(NRLY.GT.0)THEN                                           RELAN      73
               RLYID=JCNAME(1:5)//'('//JCNAME(9:12)//')'                RELAN      74
     *         //JCNAME(6:6)                                            RELAN      75
            ELSE                                                        RELAN      76
               RLYID='            '                                     RELAN      77
            ENDIF                                                       RELAN      78
            LINGEN='LINE'                                               RELAN      79
         ELSE                                                           RELAN      80
            STATUS='       '                                            RELAN      81
            RLYID='            '                                        RELAN      82
            LINGEN='GEN.'                                               RELAN      83
         ENDIF                                                          RELAN      84
         CALL BUSNAM(RFILE,ILINE,KLFO,III)                              RELAN      85
         IF(LINGEN.EQ.'GEN.')THEN                                       RELAN      86
            RFILE(31:32)=RFILE(19:20)                                   RELAN      87
            RFILE(19:20)='  '                                           RELAN      88
         ENDIF                                                          RELAN      89
         IF(KLFO.LE.0)THEN                                              RELAN      90
            WRITE(LOUT,8300) I,LINGEN,RFILE(1:14),RFILE(16:29)          RELAN      91
     *                      ,RFILE(31:32),STATUS,RLYID                  RELAN      92
         ELSE                                                           RELAN      93
            WRITE(LOUT,8300) I,LINGEN,RFILE(1:12),RFILE(14:25)          RELAN      94
     *                      ,RFILE(28:29),STATUS,RLYID                  RELAN      95
         ENDIF                                                          RELAN      96
  200 CONTINUE                                                          RELAN      97
C                                                                       RELAN      98
      DO 250 I=IEND,ISTART+17                                           RELAN      99
  250 WRITE(LOUT,*)                                                     RELAN     100
C                                                                       RELAN     101
      MSG='Select by the number, (N)ext page, (L)ast page, (Q)uit'      RELAN     102
      CALL PMTRED(LOUT,LIN,JERR,54,MSG,'RLY',STRING)                    RELAN     103
      IF(RECORD) WRITE(IREC,'(A)') STRING                               RELAN     104
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') RETURN               RELAN     105
      IF(STRING(1:1).EQ.'L'.OR.STRING(1:1).EQ.'l')THEN                  RELAN     106
         IF(ISTART.EQ.1) GOTO 100                                       RELAN     107
         ISTART=MAX0(1,ISTART-18)                                       RELAN     108
         IEND=MIN0(NLINE,ISTART+17)                                     RELAN     109
         GOTO 100                                                       RELAN     110
      ENDIF                                                             RELAN     111
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n')THEN                  RELAN     112
         IF(IEND.EQ.NLINE) GOTO 100                                     RELAN     113
         ISTART=IEND+1                                                  RELAN     114
         IEND=MIN0(NLINE,ISTART+17)                                     RELAN     115
         GOTO 100                                                       RELAN     116
      ENDIF                                                             RELAN     117
      READ(STRING,*,IOSTAT=IOS) ILINE                                   RELAN     118
      IF(IOS.NE.0.OR.ILINE.LE.0.OR.ILINE.GT.NLINE) GOTO 100             RELAN     119
C                                                                       RELAN     120
  300 I=JLINE(1,ILINE)                                                  RELAN     121
      CALL BUSNAM(RFILE,I,KLFO,III)                                     RELAN     122
      IF(JLINE(3,ILINE).GT.0)THEN                                       RELAN     123
         WRITE(LOUT,8400) RFILE(1:14),RFILE(16:29),RFILE(31:32)         RELAN     124
      ELSE                                                              RELAN     125
         WRITE(LOUT,8500) RFILE(1:14),RFILE(19:20)                      RELAN     126
      ENDIF                                                             RELAN     127
      MSG='Select by the number or (Q)uit'                              RELAN     128
      CALL PMTRED(LOUT,LIN,JERR,31,MSG,'RLY',STRING)                    RELAN     129
      IF(RECORD) WRITE(IREC,'(A)') STRING                               RELAN     130
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') GOTO 100             RELAN     131
      READ(STRING,*,IOSTAT=IOS) ITEM                                    RELAN     132
      IF(IOS.NE.0.OR.(ITEM.LT.1.AND.ITEM.GT.3)) GOTO 300                RELAN     133
C                                                                       RELAN     134
      CALL GETJK(JLINE(3,ILINE),JK,ICHNL,LOUT)                          RELAN     135
      CALL UPACKI(KRS,JRS,JK)                                           RELAN     136
      NRLY=MOD(KRS-10,32768)                                            RELAN     137
C                                                                       RELAN     138
      LLINE=JLINE(2,ILINE)                                              RELAN     139
      IF(ITEM.EQ.3)THEN                                                 RELAN     140
         IF(LLINE.EQ.0)THEN                                             RELAN     141
            MLINE=MLINE+1                                               RELAN     142
            LLINE=MLINE                                                 RELAN     143
            JLINE(2,ILINE)=LLINE                                        RELAN     144
            DO 400 I=1,512                                              RELAN     145
  400       RDATA(I,LLINE)=0.0                                          RELAN     146
            IF(NRLY.GT.0) CALL RDLINE(NRLY,LLINE)                       RELAN     147
         ENDIF                                                          RELAN     148
         CALL LISLIN(LLINE)                                             RELAN     149
         GOTO 300                                                       RELAN     150
      ENDIF                                                             RELAN     151
C                                                                       RELAN     152
      IF(LLINE.EQ.0)THEN                                                RELAN     153
         IF(NRLY.LE.0.AND.ITEM.EQ.1) GOTO 300                           RELAN     154
         LLINE=1                                                        RELAN     155
         IF(NRLY.GT.0)THEN                                              RELAN     156
            CALL RDLINE(NRLY,LLINE)                                     RELAN     157
         ELSE                                                           RELAN     158
            CRDATA(1,LLINE)='    '                                      RELAN     159
            CRDATA(2,LLINE)='    '                                      RELAN     160
            CRDATA(3,LLINE)='    '                                      RELAN     161
            IRDATA(17,LLINE)=0                                          RELAN     162
         ENDIF                                                          RELAN     163
      ENDIF                                                             RELAN     164
      KLINE=JLINE(1,ILINE)                                              RELAN     165
      CALL RRELAY(KLINE,TT,R,X,MXPT,NTPT,ICHNL,LOUT)                    RELAN     166
      IF(ITEM.EQ.2) GOTO 700                                            RELAN     167
C                                                                       RELAN     168
      IF(.NOT.LREL)THEN                                                 RELAN     169
         MSG='Enter name of relay margin list file'                     RELAN     170
  500    CALL PMTRED(LOUT,LIN,JERR,36,MSG,'RLY',RFILE)                  RELAN     171
         IF(RECORD) WRITE(IREC,'(A)')RFILE                              RELAN     172
         LENFIL=LENS(RFILE)                                             RELAN     173
         IF(LENFIL.LE.0)GOTO 500                                        RELAN     174
C       ..................................................              RELAN     175
C       : Parse parameter for a logical unit number      :              RELAN     176
         CALL PARSIU(RFILE,LENFIL,IU,LO)                                RELAN     177
         IF(IU.GT.0)THEN                                                RELAN     178
            IREL=IU                                                     RELAN     179
            LENFIL=LO                                                   RELAN     180
         ENDIF                                                          RELAN     181
C       :................................................:              RELAN     182
         CALL OPENFI(IREL,RFILE,LENFIL,IERR,'NEW',1)                    RELAN     183
         IF(IERR.LT.0) THEN                                             RELAN     184
            WRITE(LOUT,8100)                                            RELAN     185
            GOTO 500                                                    RELAN     186
         ENDIF                                                          RELAN     187
         LREL=.TRUE.                                                    RELAN     188
      ENDIF                                                             RELAN     189
C                                                                       RELAN     190
      IF(FLAG)THEN                                                      RELAN     191
         FLAG=.FALSE.                                                   RELAN     192
C        GET START AND END TIMES                                        RELAN     193
         WRITE(LOUT,*)                                                  RELAN     194
         WRITE(LOUT,*)'TMIN= ',TT(1),'  TMAX= ',TT(NTPT)                RELAN     195
         MSG='Enter START and END time values.(M)in,max'                RELAN     196
  600    CALL PMTRED(LOUT,LIN,JERR,ISLEN(MSG),MSG,'RLY',STRING)         RELAN     197
         IF(RECORD) WRITE(IREC,'(A)') STRING                            RELAN     198
         IF(JERR.LT.0) GOTO 600                                         RELAN     199
         IF(STRING(1:1).EQ.'M'.OR.STRING(1:1).EQ.'m')THEN               RELAN     200
            TMIN=TT(1)                                                  RELAN     201
            TMAX=TT(NTPT)                                               RELAN     202
         ELSE                                                           RELAN     203
            READ(STRING,*,IOSTAT=IOS) TMIN,TMAX                         RELAN     204
            IF(IOS.NE.0) GOTO 600                                       RELAN     205
         ENDIF                                                          RELAN     206
      ENDIF                                                             RELAN     207
      CALL RELMAR(TT,R,X,0,NTPT,LLINE,KLINE,TMIN,TMAX)                  RELAN     208
      WRITE(LOUT,'(/,A)') ' HIT RETURN TO CONTINUE'                     RELAN     209
      READ(LIN,*)                                                       RELAN     210
      IF(RECORD) WRITE(IREC,'(A)')                                      RELAN     211
      GOTO 300                                                          RELAN     212
C                                                                       RELAN     213
  700 CONTINUE                                                          RELAN     214
      DO 800 I=1,NTPT                                                   RELAN     215
         XARAY(I,1)=R(I)                                                RELAN     216
         YARAY(I,1)=X(I)                                                RELAN     217
  800 CONTINUE                                                          RELAN     218
      IF(JLINE(3,ILINE).GT.0)THEN                                       RELAN     219
         XTITLE=GRPTIL(40)                                              RELAN     220
         YTITLE(1)=GRPTIL(41)                                           RELAN     221
      ELSE                                                              RELAN     222
         XTITLE=GRPTIL(11)                                              RELAN     223
         YTITLE(1)=GRPTIL(12)                                           RELAN     224
      ENDIF                                                             RELAN     225
      WRITE(LOUT,*)                                                     RELAN     226
      WRITE(LOUT,*) XTITLE                                              RELAN     227
      WRITE(LOUT,*) YTITLE(1)                                           RELAN     228
      IFLG=2                                                            RELAN     229
      FILLED=.TRUE.                                                     RELAN     230
      TMIN=TT(1)                                                        RELAN     231
      TMAX=TT(NTPT)                                                     RELAN     232
      CALL RELPLT(TT,R,X,M,NTPT,LLINE,KLINE,TMIN,TMAX)                  RELAN     233
      IF(M.EQ.0) GOTO 300                                               RELAN     234
      MAXPT(1)=NTPT                                                     RELAN     235
      MAXPT(2)=999                                                      RELAN     236
      MAXPT(3)=999                                                      RELAN     237
      MAXPT(4)=999                                                      RELAN     238
      MAXPT(5)=999                                                      RELAN     239
      MAXPT(6)=999                                                      RELAN     240
      KCH(1)=KLINE                                                      RELAN     241
      MAXPT(KLINE)=M                                                    RELAN     242
      CALL SCALES(1,KCH(1),T)                                           RELAN     243
      KCH(1)=KLINE                                                      RELAN     244
      RETURN                                                            RELAN     245
 8000       FORMAT(/,                                                   RELAN     246
     1      10X,'********************************',/,                   RELAN     247
     1      10X,'*  CHANNEL FILE NOT AVAILABLE  *',/,                   RELAN     248
     1      10X,'* USE "OPENCASE" COMMAND FIRST *',/,                   RELAN     249
     1      10X,'********************************')                     RELAN     250
 8100 FORMAT(//,' ** File Open ERROR **',//)                            RELAN     251
 8200 FORMAT(///,'   NO.            FROM BUS         TO BUS ID'         RELAN     252
     *,'  STATUS   RELAY ID',/                                          RELAN     253
     *,' ----- ---- -------------- -------------- -- -------'           RELAN     254
     *,' ------------')                                                 RELAN     255
 8300 FORMAT(I5,2X,A,1X,A,T28,A,T43,A,1X,A,1X,A)                        RELAN     256
 8400 FORMAT(///,5X,'FROM BUS: ',A,5X,'TO BUS: ',A,5X,'CID: ',A,//      RELAN     257
     *,10X,'(1) RELAY MARGIN',/,10X,'(2) PLOT',/                        RELAN     258
     *,10X,'(3) ADD AND MODIFY RELAY DATA',///)                         RELAN     259
 8500 FORMAT(///,5X,'GENERATOR BUS: ',A,5X,'CID: ',A,//                 RELAN     260
     *,10X,'(1) RELAY MARGIN',/,10X,'(2) PLOT',/                        RELAN     261
     *,10X,'(3) ADD AND MODIFY RELAY DATA',///)                         RELAN     262
      END                                                               RELAN     263
      SUBROUTINE LISLIN(LLINE)                                          RELAN     264
      INCLUDE 'SOAPC1.INS'                                              RELAN     265
      INCLUDE 'CNDATA.INS'                                              RELAN     266
      CHARACTER MSG*80,STRING*80                                        RELAN     267
      DIMENSION JTYPE(8),BUFF(6)                                        RELAN     268
      DATA JTYPE/3,2,1,1,3,3,4,6/,NAMSTA/1/                             RELAN     269
C                                                                       RELAN     270
  100 CONTINUE                                                          RELAN     271
      STRING=' '                                                        RELAN     272
      ISCHEM=0                                                          RELAN     273
      IZONE=0                                                           RELAN     274
      IELM=0                                                            RELAN     275
      NELM=0                                                            RELAN     276
      NZONE=0                                                           RELAN     277
      LWORDS=17                                                         RELAN     278
      WRITE(LOUT,8000)                                                  RELAN     279
      NSCHEM=IRDATA(17,LLINE)                                           RELAN     280
  200 CONTINUE                                                          RELAN     281
      ISCHEM=ISCHEM+1                                                   RELAN     282
      IF(ISCHEM.GT.NSCHEM) GOTO 500                                     RELAN     283
      LWORDS=LWORDS+12                                                  RELAN     284
      NZONE=NZONE+IRDATA(LWORDS,LLINE)                                  RELAN     285
  300 CONTINUE                                                          RELAN     286
      IF(IZONE.GE.NZONE) GOTO 200                                       RELAN     287
      IZONE=IZONE+1                                                     RELAN     288
      STRING(9:14)=CRDATA(LWORDS+1,LLINE)//CRDATA(LWORDS+2,LLINE)(1:2)  RELAN     289
      NELM=NELM+IRDATA(LWORDS+10,LLINE)                                 RELAN     290
      LWORDS=LWORDS+12                                                  RELAN     291
  400 CONTINUE                                                          RELAN     292
      IF(IELM.GE.NELM) GOTO 300                                         RELAN     293
      IELM=IELM+1                                                       RELAN     294
      WRITE(STRING(1:4),'(I4)') IELM                                    RELAN     295
      ITYPE=IRDATA(LWORDS+1,LLINE)+1                                    RELAN     296
      WRITE(STRING(21:21),'(I1)') ITYPE                                 RELAN     297
      IF(ITYPE.EQ.4)THEN                                                RELAN     298
         WRITE(STRING(43:48),'(F6.1)') RDATA(LWORDS+2,LLINE)            RELAN     299
         GOTO 450                                                       RELAN     300
      ENDIF                                                             RELAN     301
      WRITE(STRING(28:33),'(F6.3)') RDATA(LWORDS+2,LLINE)               RELAN     302
      IF(ITYPE.EQ.3) GOTO 450                                           RELAN     303
      IF(ITYPE.EQ.2)THEN                                                RELAN     304
         WRITE(STRING(43:48),'(F6.1)') RDATA(LWORDS+3,LLINE)            RELAN     305
      ELSEIF(ITYPE.EQ.7)THEN                                            RELAN     306
         WRITE(STRING(36:41),'(F6.1)') RDATA(LWORDS+3,LLINE)            RELAN     307
         WRITE(STRING(43:48),'(F6.3)') RDATA(LWORDS+4,LLINE)            RELAN     308
         WRITE(STRING(52:57),'(F6.3)') RDATA(LWORDS+5,LLINE)            RELAN     309
      ELSE                                                              RELAN     310
         WRITE(STRING(36:41),'(F6.3)') RDATA(LWORDS+3,LLINE)            RELAN     311
         WRITE(STRING(43:48),'(F6.1)') RDATA(LWORDS+4,LLINE)            RELAN     312
         IF(ITYPE.EQ.8)THEN                                             RELAN     313
            WRITE(STRING(52:57),'(F6.3)') RDATA(LWORDS+5,LLINE)         RELAN     314
            WRITE(STRING(59:64),'(F6.3)') RDATA(LWORDS+6,LLINE)         RELAN     315
            WRITE(STRING(66:71),'(F6.1)') RDATA(LWORDS+7,LLINE)         RELAN     316
         ENDIF                                                          RELAN     317
      ENDIF                                                             RELAN     318
  450 CONTINUE                                                          RELAN     319
      LWORDS=LWORDS+JTYPE(ITYPE)+1                                      RELAN     320
      WRITE(LOUT,'(A)') STRING                                          RELAN     321
      STRING(9:)='      '                                               RELAN     322
      GOTO 400                                                          RELAN     323
C                                                                       RELAN     324
  500 CONTINUE                                                          RELAN     325
      NNELM=NELM+1                                                      RELAN     326
      WRITE(LOUT,'(I4)') NNELM                                          RELAN     327
      DO 600 I=NELM+2,18                                                RELAN     328
  600 WRITE(LOUT,*)                                                     RELAN     329
C                                                                       RELAN     330
  700 CONTINUE                                                          RELAN     331
      MSG='Select by the number or (P)ick up data from data'            RELAN     332
     *   //' base or (Q)uit'                                            RELAN     333
      CALL PMTRED(LOUT,LIN,JERR,65,MSG,'RLY',STRING)                    RELAN     334
      IF(RECORD) WRITE(IREC,'(A)') STRING                               RELAN     335
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') RETURN               RELAN     336
      IF(STRING(1:1).EQ.'P'.OR.STRING(1:1).EQ.'p') GOTO 2000            RELAN     337
      READ(STRING,*,IOSTAT=IOS) INUM                                    RELAN     338
      IF(IOS.NE.0.OR.INUM.LE.0.OR.INUM.GT.NNELM) GOTO 100               RELAN     339
C                                                                       RELAN     340
  800 CONTINUE                                                          RELAN     341
      MSG='Enter relay type and data or (Q)uit'                         RELAN     342
      CALL PMTRED(LOUT,LIN,JERR,36,MSG,'RLY',STRING)                    RELAN     343
      IF(RECORD) WRITE(IREC,'(A)') STRING                               RELAN     344
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') GOTO 100             RELAN     345
      READ(STRING,*,IOSTAT=IOS) ITYPE                                   RELAN     346
      IF(ITYPE.LE.0.OR.ITYPE.GT.8.OR.IOS.NE.0) GOTO 800                 RELAN     347
      DO 900 I=1,6                                                      RELAN     348
      BUFF(I)=0                                                         RELAN     349
  900 READ(STRING,*,IOSTAT=IOS) ITYPE,(BUFF(J),J=1,I)                   RELAN     350
C                                                                       RELAN     351
      ISCHEM=0                                                          RELAN     352
      IZONE=0                                                           RELAN     353
      IELM=0                                                            RELAN     354
      NELM=0                                                            RELAN     355
      NZONE=0                                                           RELAN     356
      LWORDS=17                                                         RELAN     357
      NSCHEM=IRDATA(17,LLINE)                                           RELAN     358
 1000 CONTINUE                                                          RELAN     359
      ISCHEM=ISCHEM+1                                                   RELAN     360
      IF(ISCHEM.GT.NSCHEM) GOTO 1300                                    RELAN     361
      LWORDS=LWORDS+12                                                  RELAN     362
      NZONE=NZONE+IRDATA(LWORDS,LLINE)                                  RELAN     363
 1100 CONTINUE                                                          RELAN     364
      IF(IZONE.GE.NZONE) GOTO 1000                                      RELAN     365
      IZONE=IZONE+1                                                     RELAN     366
      NELMD=LWORDS+10                                                   RELAN     367
      NELM=NELM+IRDATA(NELMD,LLINE)                                     RELAN     368
      LWORDS=LWORDS+12                                                  RELAN     369
 1200 CONTINUE                                                          RELAN     370
      IF(IELM.GE.NELM) GOTO 1100                                        RELAN     371
      IELM=IELM+1                                                       RELAN     372
      LTYPE=IRDATA(LWORDS+1,LLINE)+1                                    RELAN     373
      IF(IELM.EQ.INUM) GOTO 1300                                        RELAN     374
      LWORDS=LWORDS+JTYPE(LTYPE)+1                                      RELAN     375
      GOTO 1200                                                         RELAN     376
C                                                                       RELAN     377
 1300 CONTINUE                                                          RELAN     378
      IF(NNELM.EQ.1)THEN                                                RELAN     379
         CRDATA(1,LLINE)='    '                                         RELAN     380
         CRDATA(2,LLINE)='    '                                         RELAN     381
         CRDATA(3,LLINE)='    '                                         RELAN     382
         IRDATA(17,LLINE)=1                                             RELAN     383
         IRDATA(29,LLINE)=1                                             RELAN     384
         CRDATA(30,LLINE)='    '                                        RELAN     385
         CRDATA(31,LLINE)='    '                                        RELAN     386
         CRDATA(32,LLINE)='    '                                        RELAN     387
         CRDATA(33,LLINE)='    '                                        RELAN     388
         CRDATA(34,LLINE)='    '                                        RELAN     389
         IRDATA(39,LLINE)=1                                             RELAN     390
         LWORDS=41                                                      RELAN     391
      ELSEIF(INUM.EQ.NNELM)THEN                                         RELAN     392
         IRDATA(NELMD,LLINE)=IRDATA(NELMD,LLINE)+1                      RELAN     393
      ELSEIF(JTYPE(LTYPE).NE.JTYPE(ITYPE))THEN                          RELAN     394
         LSHIFT=JTYPE(LTYPE)-JTYPE(ITYPE)                               RELAN     395
         DO 1400 I=LWORDS+1,500                                         RELAN     396
 1400    RDATA(I,LLINE)=RDATA(I+LSHIFT,LLINE)                           RELAN     397
      ENDIF                                                             RELAN     398
      IRDATA(LWORDS+1,LLINE)=ITYPE-1                                    RELAN     399
      DO 1500 I=1,JTYPE(ITYPE)                                          RELAN     400
 1500 RDATA(LWORDS+I+1,LLINE)=BUFF(I)                                   RELAN     401
      GOTO 100                                                          RELAN     402
C                                                                       RELAN     403
 2000 CONTINUE                                                          RELAN     404
      IF(NAMSTA.EQ.1)THEN                                               RELAN     405
        MSG='Enter ;STATION NAME (C to select by CIRCUIT ID, Q to QUIT)'RELAN     406
      ELSE                                                              RELAN     407
        MSG='Enter ;CIRCUIT ID (C to select by STATION NAME, Q to QUIT)'RELAN     408
      ENDIF                                                             RELAN     409
      CALL PMTRED(LOUT,LIN,JERR,58,MSG,'RLY',STRING)                    RELAN     410
      IF(RECORD) WRITE(IREC,'(A)') STRING                               RELAN     411
      IF(STRING(1:2).EQ.'Q '.OR.STRING(1:2).EQ.'q ') GOTO 100           RELAN     412
      IF(STRING(1:2).EQ.'C '.OR.STRING(1:2).EQ.'c ')THEN                RELAN     413
         NAMSTA=MOD(NAMSTA+1,2)                                         RELAN     414
         GOTO 2000                                                      RELAN     415
      ENDIF                                                             RELAN     416
      K=INDEX(STRING,';')                                               RELAN     417
      IF(K.EQ.0) GOTO 2000                                              RELAN     418
      STRING=STRING(K:80)                                               RELAN     419
      IF(NAMSTA.EQ.1)THEN                                               RELAN     420
         CALL FNSTAT(STRING(2:13),K)                                    RELAN     421
         IF(K.EQ.0)THEN                                                 RELAN     422
            WRITE(LOUT,*) ' *** STATION '//STRING(1:13)//' IS NOT IN'   RELAN     423
     *         //' THE DATA BASE'                                       RELAN     424
            GOTO 2000                                                   RELAN     425
         ENDIF                                                          RELAN     426
      ELSE                                                              RELAN     427
         STRING(21:28)=STRING(2:7)//'  '                                RELAN     428
         STRING(29:32)=STRING(9:12)                                     RELAN     429
         CALL FLINE(STRING(21:32),K)                                    RELAN     430
         IF(K.EQ.0)THEN                                                 RELAN     431
            WRITE(LOUT,*) ' *** CIRCUIT '//STRING(1:13)//' IS NOT IN'   RELAN     432
     *         //' THE DATA BASE'                                       RELAN     433
            GOTO 2000                                                   RELAN     434
         ENDIF                                                          RELAN     435
      ENDIF                                                             RELAN     436
      CALL RDLINE(K,LLINE)                                              RELAN     437
      GOTO 100                                                          RELAN     438
C                                                                       RELAN     439
 8000 FORMAT(///,29X,'REACH  THETA     P1       P2',/,'     ZONE NAME'  RELAN     440
     *,' RELAY TYPE DISTANCE RADIUS  ANGLE DISTANCE RADIUS  ANGLE',/    RELAN     441
     *,'  -- --------- ----------',2(' --------',2(' ------')))         RELAN     442
      END                                                               RELAN     443
