CFPRIME RDREC9                                                          RDREC9      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 RDREC9(IU8,ISTOP)                                      RDREC9      3
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCRDREC9      4
CD                                                                      RDREC9      5
CD            THIS ROUTINE READS RECORD 9 FROM PLOTTING DATA            RDREC9      6
CD            FROM CHANNEL FILE TO GET FILE POINTER INFORMATION         RDREC9      7
CD                                                                      RDREC9      8
CD            CALLING PARAMETERS :                                      RDREC9      9
CD                                                                      RDREC9     10
CD                           IU8 - Unit number to read from             RDREC9     11
CD                         ISTOP - Logical flag to indicate success     RDREC9     12
CD                                 or failure                           RDREC9     13
CD                                                                      RDREC9     14
CD            FOR DC plotting.                                          RDREC9     15
CD                   NCONVO=IBUF(105)->.NE.0 flag to read additional    RDREC9     16
CD                                      name records.                   RDREC9     17
CD                   IOFF=IBUF(106)->Offset required to point to        RDREC9     18
CD                                   converter names.                   RDREC9     19
CD                                                                      RDREC9     20
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCRDREC9     21
                                                                        RDREC9     22
      INCLUDE 'PARAM.INS'                                               RDREC9     23
      INCLUDE 'XYARAY.INS'                                              RDREC9     24
      INCLUDE 'SOAPC1.INS'                                              RDREC9     25
      INCLUDE 'DBFLG.INS'                                               RDREC9     26
      COMMON /REC9/ IRECS,NREC,IREC9(128)                               RDREC9     27
      COMMON /RECPT/ KRSTRT, ISTNAM, IIDARY, ITYARY, IHREC,ICHAN,NPFL,  RDREC9     28
     *          LRREC,IRREC                                             RDREC9     29
                                                                        RDREC9     30
      DIMENSION IREC8(128),RREC8(128)                                   RDREC9     31
      EQUIVALENCE (IREC8(1),RREC8(1))                                   RDREC9     32
C   .....................................................               RDREC9     33
C   : TEXTS READ FROM BIN FILE                          :               RDREC9     34
      CHARACTER*80 TITCAS,TITSWI,TITEXT                                 RDREC9     35
      CHARACTER*12 TITDAT                                               RDREC9     36
      CHARACTER*4  TITVER                                               RDREC9     37
      COMMON /BITEXT/ TITCAS,TITSWI,TITEXT,TITDAT,TITVER                RDREC9     38
C   :....................................................:              RDREC9     39
      CHARACTER*80 MSG,STRING                                           RDREC9     40
      LOGICAL IEND,ISTOP                                                RDREC9     41
      ISTOP=.FALSE.                                                     RDREC9     42
      LDEBUG=DEBUG(2)                                                   RDREC9     43
      JREC=7                                                            RDREC9     44
      CALL DAIWR4(IU8,1,JREC,IREC9,128,IEND)                            RDREC9     45
      IF(IEND) THEN                                                     RDREC9     46
         WRITE(LOUT,1002)                                               RDREC9     47
         ISTOP=.TRUE.                                                   RDREC9     48
         RETURN                                                         RDREC9     49
 1002    FORMAT(' *** ERROR READING CHANNEL FILE RECORD 7 ***')         RDREC9     50
      ENDIF                                                             RDREC9     51
      IF(IREC9(1).EQ.0)THEN                                             RDREC9     52
         CASID=' '                                                      RDREC9     53
      ELSE                                                              RDREC9     54
         WRITE(CASID,'(3A4)') IREC9(1),IREC9(2),IREC9(3)                RDREC9     55
      ENDIF                                                             RDREC9     56
      IJ=4                                                              RDREC9     57
      DO 1 I=1,6                                                        RDREC9     58
         IF(IREC9(IJ).EQ.0)THEN                                         RDREC9     59
            PTITLE(I)=' '                                               RDREC9     60
         ELSE                                                           RDREC9     61
            WRITE(PTITLE(I),'(20A4)') (IREC9(J),J=IJ,IJ+19)             RDREC9     62
         ENDIF                                                          RDREC9     63
         IJ=IJ+20                                                       RDREC9     64
    1 CONTINUE                                                          RDREC9     65
C  .....................................                                RDREC9     66
C  : READ  REC9 FROM THE RESULT FILE   :                                RDREC9     67
C  :                                   :                                RDREC9     68
      JREC=9                                                            RDREC9     69
      CALL DAIWR4(IU8,1,JREC,IREC9,128,IEND)                            RDREC9     70
      IF(IEND) THEN                                                     RDREC9     71
         WRITE(LOUT,1000)                                               RDREC9     72
         ISTOP=.TRUE.                                                   RDREC9     73
         GOTO 940                                                       RDREC9     74
 1000    FORMAT(1X,'*** ERROR READING CHANNEL FILE RECORD 9 ***')       RDREC9     75
      ENDIF                                                             RDREC9     76
C  :...................................:                                RDREC9     77
C                                                                       RDREC9     78
C   ....................................                                RDREC9     79
C   : TOTAL NUMBER OF CHANNELS         :                                RDREC9     80
C   :                                  :                                RDREC9     81
      ICHAN=IREC9(1)                                                    RDREC9     82
C      IF(ICHAN.GT.NBUF) THEN                                           RDREC9     83
C         WRITE(LOUT,1201) NBUF                                         RDREC9     84
C         ISTOP=.TRUE.                                                  RDREC9     85
C         GOTO 940                                                      RDREC9     86
C 1201    FORMAT(1X,'** ERROR (RDREC9) TOO MANY CHANNELS ***',/,        RDREC9     87
C     1   ' MAXIMUM CHANNELS ALLOWED IS ',I5,/)                         RDREC9     88
C      ENDIF                                                            RDREC9     89
C   :..................................:                                RDREC9     90
C   : RECORDS PER TIME POINT           :                                RDREC9     91
C   :                                  :                                RDREC9     92
      IRECS=IREC9(2)                                                    RDREC9     93
C   :..................................:                                RDREC9     94
C   : Used by SAA for DC CONVERTER NAME:                                RDREC9     95
C   : record pointer                   :                                RDREC9     96
      IHREC=IREC9(3)                                                    RDREC9     97
C   :..................................:                                RDREC9     98
C   : STARTING RECORD OF ITY ARRAY     :                                RDREC9     99
C   :                                  :                                RDREC9    100
      ITYARY=IREC9(4)                                                   RDREC9    101
C   :..................................:                                RDREC9    102
C   : STARTING RECORD OF IID ARRAY     :                                RDREC9    103
C   :                                  :                                RDREC9    104
        IIDARY=IREC9(5)                                                 RDREC9    105
C   :..................................:                                RDREC9    106
C   : STARTING RECORD OF STATION NAMES :                                RDREC9    107
C   :                                  :                                RDREC9    108
       ISTNAM=IREC9(6)                                                  RDREC9    109
C   :..................................:                                RDREC9    110
C   : STARTING RECORD OF TIME POINTS   :                                RDREC9    111
C   :                                  :                                RDREC9    112
       KRSTRT=IREC9(7)                                                  RDREC9    113
C   :..................................:                                RDREC9    114
C   : NUMBER OF LINES MONITORED        :                                RDREC9    115
C   :                                  :                                RDREC9    116
       NPFL=IREC9(8)                                                    RDREC9    117
C   :..................................:                                RDREC9    118
C   : STARTING RECORD OF JRSKRS ARRAY  :                                RDREC9    119
C   :                                  :                                RDREC9    120
       LRREC=IREC9(9)                                                   RDREC9    121
C   :..................................:                                RDREC9    122
C   : RECORDS PER TIME POINT           :                                RDREC9    123
C   :                                  :                                RDREC9    124
       IRREC=IREC9(10)                                                  RDREC9    125
C   :..................................:                                RDREC9    126
                                                                        RDREC9    127
C   ................................................................    RDREC9    128
C   : DEBUG WRITE                                                  :    RDREC9    129
C   :                                                              :    RDREC9    130
      IF (LDEBUG) THEN                                                  RDREC9    131
      WRITE(IDBOUT,1010) ICHAN,IRECS,IHREC,ITYARY,IIDARY,ISTNAM,KRSTRT, RDREC9    132
     *          NPFL,LRREC,IRREC                                        RDREC9    133
 1010 FORMAT(/,'+++(RDREC9)+++',/,                                      RDREC9    134
     1 1X,' TOTAL NUMBER OF CHANNELS       (ICHAN) : ',I6,/,            RDREC9    135
     1 1X,' RECORDS PER TIME POINT         (IRECS) : ',I6,/,            RDREC9    136
     1 1X,' ???? CHECK WITH DYW            (IHREC) : ',I6,/,            RDREC9    137
     1 1X,' STARTING RECORD OF ITY ARRAY   (ITYARY): ',I6,/,            RDREC9    138
     1 1X,' STARTING RECORD OF IID ARRAY   (IIDARY): ',I6,/,            RDREC9    139
     1 1X,' STARTING ECORD OF STATION NAMES(ISTNAM): ',I6,/,            RDREC9    140
     1 1X,' STARTING RECORD OF TIME POINTS (KRSTRT): ',I6,/,            RDREC9    141
     1 1X,' NUMBER OF LINES MONITORED      (NPFL)  : ',I6,/,            RDREC9    142
     1 1X,' STARTING RECORD OF JRSKRS ARRAY(LRREC) : ',I6,/,            RDREC9    143
     1 1X,' NUMBER OF RECORDS/ TIME POINT  (IRREC) : ',I6,/,            RDREC9    144
     1 1X,' +++++++++++',/)                                             RDREC9    145
       ENDIF                                                            RDREC9    146
C    :...............................................................:  RDREC9    147
                                                                        RDREC9    148
                                                                        RDREC9    149
C  .....................................                                RDREC9    150
C  : READ  REC8 FROM THE RESULT FILE   :                                RDREC9    151
C  :                                   :                                RDREC9    152
      JREC=8                                                            RDREC9    153
      CALL DAIWR4(IU8,1,JREC,IREC8,128,IEND)                            RDREC9    154
      IF(IEND) THEN                                                     RDREC9    155
         WRITE(LOUT,2000)                                               RDREC9    156
         ISTOP=.TRUE.                                                   RDREC9    157
         GOTO 940                                                       RDREC9    158
 2000    FORMAT(1X,'*** ERROR READING CHANNEL FILE RECORD 8 ***')       RDREC9    159
      ENDIF                                                             RDREC9    160
C  :...................................:                                RDREC9    161
                                                                        RDREC9    162
C   ................................................................    RDREC9    163
C   : read record 8 for titles and flags                           :    RDREC9    164
C   :                                                              :    RDREC9    165
      WRITE(TITCAS,3200) (IREC8(I),I=1,20)                              RDREC9    166
      WRITE(TITSWI,3200) (IREC8(20+I),I=1,20)                           RDREC9    167
      WRITE(TITEXT,3200) (IREC8(40+I),I=1,20)                           RDREC9    168
      WRITE(TITDAT,3200) (IREC8(100+I),I=1,3)                           RDREC9    169
      WRITE(TITVER,3200) IREC8(104)                                     RDREC9    170
      NCONVO=IREC8(105)                                                 RDREC9    171
      IOFF=IREC8(106)                                                   RDREC9    172
      IF(KLFO.EQ.100.OR.KLFO.EQ.-100)THEN                               RDREC9    173
         MSG=' '                                                        RDREC9    174
         IF(KLFO.EQ.100.AND.IREC8(107).EQ.0)                            RDREC9    175
     *      MSG='Do you want to keep using BUS NAME (Y/N)?'             RDREC9    176
         IF(KLFO.EQ.-100.AND.IREC8(107).GT.0)                           RDREC9    177
     *      MSG='Do you want to keep using BUS NUMBER (Y/N)?'           RDREC9    178
         IF(MSG(1:1).EQ.'D')THEN                                        RDREC9    179
            CALL PMTRED(LOUT,LIN,JERR,41,MSG,'SP7',STRING)              RDREC9    180
            IF(STRING(1:1).EQ.'N') KLFO=IREC8(107)                      RDREC9    181
         ENDIF                                                          RDREC9    182
      ELSE                                                              RDREC9    183
         KLFO=IREC8(107)                                                RDREC9    184
      ENDIF                                                             RDREC9    185
      BASPC=RREC8(108)                                                  RDREC9    186
      IF(BASPC.EQ.0.0)BASPC=100.                                        RDREC9    187
      FQBASE=RREC8(109)                                                 RDREC9    188
      IF(FQBASE.EQ.0.0)FQBASE=60.                                       RDREC9    189
      IF(LDEBUG) THEN                                                   RDREC9    190
         WRITE(IDBOUT,3210) TITCAS,TITSWI,TITEXT,TITDAT,TITVER,         RDREC9    191
     1   NCONVO,IOFF                                                    RDREC9    192
 3210    FORMAT(1X,'(RDREC9) CASE TITLE : ',/,A80,/,                    RDREC9    193
     1          1X,'         SWITCH     : ',/,A80,/,                    RDREC9    194
     1          1X,'         TEXT       : ',/,A80,/,                    RDREC9    195
     1          1X,'         DATE       : ',A12,/,                      RDREC9    196
     1          1X,'         VERSION    : ',A4,/,                       RDREC9    197
     1          1X,'         DC CONVERT : ',I4,/,                       RDREC9    198
     1          1X,'         IOFF       : ',I4,/)                       RDREC9    199
      ENDIF                                                             RDREC9    200
 3200 FORMAT(20A4)                                                      RDREC9    201
C   :...............................................................:   RDREC9    202
                                                                        RDREC9    203
C   ................................................................    RDREC9    204
C   : read header info                                             :    RDREC9    205
C   :                                                              :    RDREC9    206
      CALL RDHEAD(IU8,IEND,NCONVO,IOFF)                                 RDREC9    207
      IF(IEND) THEN                                                     RDREC9    208
         WRITE(LOUT,1001)                                               RDREC9    209
         ISTOP=.TRUE.                                                   RDREC9    210
         GOTO 940                                                       RDREC9    211
 1001    FORMAT(1X,'*** ERROR READING CHANNEL FILE HEADER INFO ***')    RDREC9    212
      ENDIF                                                             RDREC9    213
C   :...............................................................:   RDREC9    214
                                                                        RDREC9    215
      DO 500 I=6,1,-1                                                   RDREC9    216
  500 IF(LENS(PTITLE(I)).NE.0) GOTO 600                                 RDREC9    217
  600 CONTINUE                                                          RDREC9    218
      IF(I.LT.6) PTITLE(I+1)=TITSWI                                     RDREC9    219
 940  CONTINUE                                                          RDREC9    220
      RETURN                                                            RDREC9    221
      END                                                               RDREC9    222
