CFPRIME RRELAY                                                          RRELAY      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 RRELAY(ICHNL,T,R,X,M ,MAXPT,IU8,LOUT)                  RRELAY      3
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCRRELAY      4
CD                                                                      RRELAY      5
CD          THIS ROUTINE READS IN THE RELAY DATA FROM CHANNEL FILE      RRELAY      6
CD                                                                      RRELAY      7
CD           CALLING PARAMETERS :                                       RRELAY      8
CD                                                                      RRELAY      9
CD                  ICHNL - CHANNEL NUMBER                              RRELAY     10
CD                      T - TIME ARRAY                                  RRELAY     11
CD                   R(M) - real array                                  RRELAY     12
CD                   X(M) - Y-axis array                                RRELAY     13
CD                  MAXPT - Returns with the maximum # of data point    RRELAY     14
CD                    IU8 - Unit number to read from                    RRELAY     15
CD                   LOUT - OUTPUT UNIT NUMBER                          RRELAY     16
CD                                                                      RRELAY     17
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCRRELAY     18
      INCLUDE 'DBFLG.INS'                                               RRELAY     19
      INCLUDE 'PARAM.INS'                                               RRELAY     20
C                                                                       RRELAY     21
      COMMON /REC9/ IRECS,NREC,IREC9(128)                               RRELAY     22
      COMMON /RECPT/ KRSTRT, ISTNAM, IIDARY, ITYARY, IHREC,ICHAN,       RRELAY     23
     *          NPFL,LRREC,IRREC                                        RRELAY     24
      LOGICAL IEND                                                      RRELAY     25
      REAL*4 R(M),X(M),T(M)                                             RRELAY     26
      REAL*4  TBUF(128)                                                 RRELAY     27
C                                                                       RRELAY     28
      LDEBUG=DEBUG(4)                                                   RRELAY     29
C                                                                       RRELAY     30
      KCHNL=ICHNL                                                       RRELAY     31
      CALL RECFLD(KCHNL,KREC,KSLOT)                                     RRELAY     32
C   .....................................................               RRELAY     33
C   : Debug show contains of record/field pointer       :               RRELAY     34
C   :                                                   :               RRELAY     35
      IF(LDEBUG) THEN                                                   RRELAY     36
        WRITE(IDBOUT,1011)                                              RRELAY     37
        WRITE(IDBOUT,1010) KREC,KSLOT                                   RRELAY     38
 1010   FORMAT(1X,2I20)                                                 RRELAY     39
 1011   FORMAT(1X,'+++(REMASS)+++ (1ST LINE IS NUMBER OF CHANNELS',/,   RRELAY     40
     1         1X,'      PHYSICAL RECORD #       FIELD NUMBER ',/,      RRELAY     41
     1         1X,'      ------------------      -------------')        RRELAY     42
      ENDIF                                                             RRELAY     43
C    :...................................................:              RRELAY     44
C   ....................................................................RRELAY     45
C   : Initialize pointers before starting                               RRELAY     46
C   : Point next record pointer NREC to absolute start of data KRSTRT   RRELAY     47
      NREC=KRSTRT                                                       RRELAY     48
C   : Initialize Maximum number of points MM                            RRELAY     49
      MM=0                                                              RRELAY     50
C   : Initialize pointer to beginning of a time step. The first one beinRRELAY     51
C   : the absolute start of time step data                              RRELAY     52
      IBEGIN=KRSTRT                                                     RRELAY     53
C   :...................................................................RRELAY     54
C   ....................................................................RRELAY     55
C   : Continue reading from the SIMU file until EOF                     RRELAY     56
C   :                                                                   RRELAY     57
 10   CONTINUE                                                          RRELAY     58
C                                                                       RRELAY     59
C     ........................................                          RRELAY     60
C     : READ RECORD 1 FOR TIME STEP          :                          RRELAY     61
        MM=MM+1                                                         RRELAY     62
        IF(MM.GE.M-4) THEN                                              RRELAY     63
          MM=MM-1                                                       RRELAY     64
          WRITE(LOUT,1030)T(MM)                                         RRELAY     65
 1030     FORMAT(/,                                                     RRELAY     66
     1    10X,'++++++++++++++++++++++++++++++++++++++++++++++++',/,     RRELAY     67
     1    10X,' WARNING: TOO MANY DATA POINTS IN CHANNEL FILE. ',/,     RRELAY     68
     1    10X,'          LAST TIME STEP READ IN IS ',F10.5,//,          RRELAY     69
     1    10X,'   FOR MORE INFORMATION, TYPE "HELP/LIMITS"     ',/,     RRELAY     70
     1    10X,'++++++++++++++++++++++++++++++++++++++++++++++++',/)     RRELAY     71
          GOTO 940                                                      RRELAY     72
        ENDIF                                                           RRELAY     73
        CALL DAFLWR(IU8,1,NREC,TBUF,128,IEND)                           RRELAY     74
        NOWREC=NREC                                                     RRELAY     75
        IF(TBUF(2).GT.99999) THEN                                       RRELAY     76
           MM=MM-1                                                      RRELAY     77
           GOTO 940                                                     RRELAY     78
        ELSE                                                            RRELAY     79
           T(MM)=TBUF(2)                                                RRELAY     80
        ENDIF                                                           RRELAY     81
C     :.......................................:                         RRELAY     82
C                                                                       RRELAY     83
C     ........................................................          RRELAY     84
         DO 20 I=1,2                                                    RRELAY     85
           IF(I.EQ.1)THEN                                               RRELAY     86
             CALL RECFLD(KCHNL,KREC,KSLOT)                              RRELAY     87
           ELSE                                                         RRELAY     88
             CALL RECFLD(KCHNL+1,KREC,KSLOT)                            RRELAY     89
           ENDIF                                                        RRELAY     90
           IF(KREC.EQ.(NOWREC-IBEGIN)) THEN                             RRELAY     91
              IF(I.EQ.1)THEN                                            RRELAY     92
                R(MM)=TBUF(KSLOT)                                       RRELAY     93
              ELSE                                                      RRELAY     94
                X(MM)=TBUF(KSLOT)                                       RRELAY     95
              ENDIF                                                     RRELAY     96
           ELSE                                                         RRELAY     97
              NREC=IBEGIN+KREC-1                                        RRELAY     98
              CALL DAFLWR(IU8,1,NREC,TBUF,128,IEND)                     RRELAY     99
              NOWREC=NREC                                               RRELAY    100
              IF(I.EQ.1)THEN                                            RRELAY    101
                R(MM)=TBUF(KSLOT)                                       RRELAY    102
              ELSE                                                      RRELAY    103
                X(MM)=TBUF(KSLOT)                                       RRELAY    104
              ENDIF                                                     RRELAY    105
           ENDIF                                                        RRELAY    106
  20    CONTINUE                                                        RRELAY    107
C      :........................................................:       RRELAY    108
        IF(IEND) GOTO 940                                               RRELAY    109
        IBEGIN=IBEGIN+IRECS                                             RRELAY    110
        NREC=IBEGIN                                                     RRELAY    111
      GOTO 10                                                           RRELAY    112
C   :                                                                   RRELAY    113
C   :...................................................................RRELAY    114
 940  CONTINUE                                                          RRELAY    115
      MAXPT=MM                                                          RRELAY    116
C   ........................................................            RRELAY    117
C   : Debug write                                          :            RRELAY    118
C   :                                                      :            RRELAY    119
      IF(LDEBUG) THEN                                                   RRELAY    120
        WRITE(IDBOUT,1300)MM                                            RRELAY    121
        DO 120 I=1,MM                                                   RRELAY    122
          WRITE(IDBOUT,1200) T(I),R(I),X(I)                             RRELAY    123
 1200     FORMAT(1X,12F10.5)                                            RRELAY    124
 120    CONTINUE                                                        RRELAY    125
 1300   FORMAT(1X,'+++(RRELAY)++ NUMBER OF DATA POINTS :',I6)           RRELAY    126
      ENDIF                                                             RRELAY    127
C   :.......................................................:           RRELAY    128
      RETURN                                                            RRELAY    129
      END                                                               RRELAY    130
