CFPRIME ALRLY                                                           ALRLY       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
CD                                                                      ALRLY       3
CD    THIS SUBROUTINE COMPUTES THE RELAY MARGINS FOR ALL THE RELAYS     ALRLY       4
CD    IN THE  STUDIED SYSTEM                                            ALRLY       5
CD                                                                      ALRLY       6
C                                                                       ALRLY       7
      SUBROUTINE ALRLY                                                  ALRLY       8
C                                                                       ALRLY       9
      INCLUDE 'PARAM.INS'                                               ALRLY      10
      INCLUDE 'JJNAME.INS'                                              ALRLY      11
      INCLUDE 'SOAPC1.INS'                                              ALRLY      12
      INCLUDE 'XYARAY.INS'                                              ALRLY      13
      INCLUDE 'CNDATA.INS'                                              ALRLY      14
      INCLUDE 'GPINFO.INS'                                              ALRLY      15
C                                                                       ALRLY      16
      COMMON /RECPT/KRSTRT,ISTNAM,IIDARY,ITYARY,IHREC,ICHAN,NPFL        ALRLY      17
     *,LRREC,IRREC                                                      ALRLY      18
C                                                                       ALRLY      19
      CHARACTER*2 UID                                                   ALRLY      20
      CHARACTER*80 MSG,RFILE,STRING                                     ALRLY      21
      DIMENSION R(MXPT),X(MXPT),TT(MXPT)                                ALRLY      22
      LOGICAL FLAG                                                      ALRLY      23
C                                                                       ALRLY      24
      IF(.NOT.OPENED)THEN                                               ALRLY      25
         WRITE(LOUT,8000)                                               ALRLY      26
         RETURN                                                         ALRLY      27
      ENDIF                                                             ALRLY      28
      FLAG=.TRUE.                                                       ALRLY      29
      CALL RLHEAD                                                       ALRLY      30
      JLINE=0                                                           ALRLY      31
      DO 20 I=11,ICHAN                                                  ALRLY      32
         CALL UNPACK(UID,NTYPE,ITY(1,I))                                ALRLY      33
         IF(NTYPE.EQ.40)THEN                                            ALRLY      34
            JLINE=JLINE+1                                               ALRLY      35
            CALL GETJK(JLINE,JK,ICHNL,LOUT)                             ALRLY      36
            CALL UPACKI(KRS,JRS,JK)                                     ALRLY      37
            IF(JRS.NE.0)THEN                                            ALRLY      38
               NRLY=MOD(KRS-10,32768)                                   ALRLY      39
               IF(NRLY.GT.0)THEN                                        ALRLY      40
                  CALL RDLINE(NRLY,1)                                   ALRLY      41
                  CALL RRELAY(I,TT,R,X,MXPT,NTPT,ICHNL,LOUT)            ALRLY      42
                  IF(FLAG)THEN                                          ALRLY      43
                     MSG='Enter name of relay margin list file'         ALRLY      44
  500                CALL PMTRED(LOUT,LIN,JERR,36,MSG,'RLY',RFILE)      ALRLY      45
                     IF(RECORD) WRITE(IREC,'(A)') RFILE                 ALRLY      46
                     LENFIL=LENS(RFILE)                                 ALRLY      47
                     IF(LENFIL.LE.0) GOTO 500                           ALRLY      48
                     CALL PARSIU(RFILE,LENFIL,IU,LO)                    ALRLY      49
                     IF(IU.GT.0)THEN                                    ALRLY      50
                        IREL=IU                                         ALRLY      51
                        LENFIL=LO                                       ALRLY      52
                     ENDIF                                              ALRLY      53
                     CALL OPENFI(IREL,RFILE,LENFIL,IERR,'UNKNOWN',1)    ALRLY      54
                     IF(IERR.LT.0)THEN                                  ALRLY      55
                        WRITE(LOUT,8100)                                ALRLY      56
                        GOTO 500                                        ALRLY      57
                     ENDIF                                              ALRLY      58
                     FLAG=.FALSE.                                       ALRLY      59
                     WRITE(LOUT,*)                                      ALRLY      60
                     WRITE(LOUT,*) ' TMIN= ',TT(1),'  TMAX= ',TT(NTPT)  ALRLY      61
                     MSG='Enter START and END time values.(M)in,max'    ALRLY      62
  600                CALL PMTRED(LOUT,LIN,JERR,ISLEN(MSG),MSG,'RLY'     ALRLY      63
     *                  ,STRING)                                        ALRLY      64
                     IF(RECORD) WRITE(IREC,'(A)') STRING                ALRLY      65
                     IF(JERR.LT.0) GOTO 600                             ALRLY      66
                     IF(STRING(1:1).EQ.'M'.OR.STRING(1:1).EQ.'m')THEN   ALRLY      67
                        TMIN=TT(1)                                      ALRLY      68
                        TMAX=TT(NTPT)                                   ALRLY      69
                     ELSE                                               ALRLY      70
                        READ(STRING,*,IOSTAT=IOS) TMIN,TMAX             ALRLY      71
                        IF(IOS.NE.0) GOTO 600                           ALRLY      72
                     ENDIF                                              ALRLY      73
                  ENDIF                                                 ALRLY      74
                  CALL RELMAR(TT,R,X,0,NTPT,1,I,TMIN,TMAX)              ALRLY      75
               ENDIF                                                    ALRLY      76
            ENDIF                                                       ALRLY      77
C         ELSEIF(NTYPE.EQ.11)THEN                                       ALRLY      78
         ENDIF                                                          ALRLY      79
   20 CONTINUE                                                          ALRLY      80
      RETURN                                                            ALRLY      81
 8000 FORMAT(/,10X,'********************************',/                 ALRLY      82
     *,10X,'*  CHANNEL FILE NOT AVAILABEL  *',/                         ALRLY      83
     *,10X,'* USE "OPENCASE" COMMAND FIRST *',/                         ALRLY      84
     *,10X,'********************************')                          ALRLY      85
 8100 FORMAT(//,' *** FILE OPEN ERROR',//)                              ALRLY      86
      END                                                               ALRLY      87
