CFPRIME CHALIS                                                          CHALIS      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 CHALIS(CHNLIS,CHN,NCHN,BUFPNT,BUF,TIME,NLIS,NTP,       CHALIS      3
     *          NPOINT,LRECFD,IOK)                                      CHALIS      4
CD                                                                      CHALIS      5
CD            THIS ROUTINE LISTS THE CONTENT OF CHANNEL OR CHANNELS     CHALIS      6
CD            THAT HAVE BEEN ASSIGNED OR MANIPULATED BY THE USER IN     CHALIS      7
CD            FUNCTION PROCESS.                                         CHALIS      8
CD                                                                      CHALIS      9
CD            CALLING PARAMETERS :                                      CHALIS     10
CD                                                                      CHALIS     11
CD                   CHNLIS   :  CHARACTER STRING CONTAINING THE NAME   CHALIS     12
CD                               OF THE CHANNEL ASSIGNED BY THE USER    CHALIS     13
CD                   CHN      :  CONTAIN THE CHANNEL LIST               CHALIS     14
CD                   NCHN     :  NUMBER OF CHANNEL STORED               CHALIS     15
CD                   BUFPNT   :  BUFFER STORE IN THE CHANNELS GOING TO BCHALIS     16
CD                               PROCESSED                              CHALIS     17
CD                   BUF      :  BUFFER STORING THE PROCESSED CHANNEL RECHALIS     18
CD                               RESULT                                 CHALIS     19
CD                   TIME     :  TIME POINT ARRAY                       CHALIS     20
CD                   NLIS     :  NUMBER OF CHANNEL IN THE BUFFER        CHALIS     21
CD                   NTP      :  TOTAL NO. OF POINTS                    CHALIS     22
CD                   NPOINT   :  TOTAL NO. OF POINT IN THE BUFFER       CHALIS     23
CD                   LRECFD   :  ARRAY WITH THE RECORD AND FIELD PONITERCHALIS     24
CD                               INFO.                                  CHALIS     25
CD                   IOK      :  STATUS FLAG FOR CHANNEL READ           CHALIS     26
CD                                                                      CHALIS     27
CD                                                                      CHALIS     28
      INCLUDE 'PARAM.INS'                                               CHALIS     29
      INCLUDE 'SOAPC1.INS'                                              CHALIS     30
      INCLUDE 'DBFLG.INS'                                               CHALIS     31
C!                                                                      CHALIS     32
C      DIMENSION XA(MXPT),YA(MXPT,NBUF),LCH(NBUF1),LRECFD(NBUF1,2)      CHALIS     33
      DIMENSION LRECFD(MCHNL,2)                                         CHALIS     34
C                                                                       CHALIS     35
      CHARACTER*80 CHNLIS(MAXLIS)                                       CHALIS     36
      INTEGER NCHN(MAXLIS),CHN(MAXLIS,MAXCHN),BUFPNT(MAXLIS,NBUF)       CHALIS     37
      REAL BUF(NBUF,MXPT),TIME(MXPT)                                    CHALIS     38
C                                                                       CHALIS     39
      CHARACTER*80 STRING,MSG                                           CHALIS     40
      LDEBUG=DEBUG(9)                                                   CHALIS     41
      IOK=0                                                             CHALIS     42
      LDEB=99                                                           CHALIS     43
C    .................................................................. CHALIS     44
C    : Call PARSCH to parse command parameter for channel numbers and : CHALIS     45
C    : make sure they're the same type. If not issue a warning .      : CHALIS     46
C    : Then read the channel data into buffer.                        : CHALIS     47
C    :                                                                : CHALIS     48
      IF(OPENED) THEN                                                   CHALIS     49
C            CONST=0.0                                                  CHALIS     50
C            CALL PARSPA(PARAM,LENPAR,LCH,LRECFD,NBUF,LOUT,CONST,       CHALIS     51
C     1                  NC2,IOK)                                       CHALIS     52
            CALL PARSCH(CHNLIS,CHN,NCHN,BUFPNT,BUF,NLIS,NTP,NPOINT,     CHALIS     53
     *          LRECFD,LOUT,IOK)                                        CHALIS     54
                                                                        CHALIS     55
C            IF(LDEBUG) WRITE(LDEB,1029) CONST                          CHALIS     56
C 1029       FORMAT(/,1X,'*DEBUG (FUNCTN) CONST = ',F10.4,/)            CHALIS     57
            IF(IOK.EQ.1) THEN                                           CHALIS     58
               WRITE(LOUT,1030)                                         CHALIS     59
 1030          FORMAT(/,1X,'** Channels read in are not the same type', CHALIS     60
     1         ', the plot may not be valid.',/)                        CHALIS     61
               MSG='ABORT or CONTINUE ?'                                CHALIS     62
               CALL PMTRED(LOUT,LIN,JERR,19,MSG,'DIF',STRING)           CHALIS     63
C               CALL SCRPMT(LOUT,MSG,19)                                CHALIS     64
C               READ(LIN,1040) STRING                                   CHALIS     65
               IF(RECORD) WRITE(IREC,1040) STRING                       CHALIS     66
 1040          FORMAT(A)                                                CHALIS     67
               IF((STRING(1:1).EQ.'A').OR.(JERR.LT.0)) IOK=-1           CHALIS     68
            ENDIF                                                       CHALIS     69
            IF(IOK.LT.0) THEN                                           CHALIS     70
               WRITE(LOUT,1050)                                         CHALIS     71
 1050          FORMAT(/,1X,'**FUNCTION ABORTED**',/)                    CHALIS     72
               GOTO 9999                                                CHALIS     73
            ENDIF                                                       CHALIS     74
C!                                                                      CHALIS     75
            CALL RECHN(BUF,TIME,BUFPNT,NLIS,MXPT,NBUF,NTP,ICHNL,        CHALIS     76
     *          LRECFD,LOUT,NCHN,NPOINT)                                CHALIS     77
C                                                                       CHALIS     78
C            IF(LDEBUG) CALL PRNBUF(XA,YA,MXPT,NBUF,NTP,LCH,NBUF,       CHALIS     79
C     1      LOUT,99)                                                   CHALIS     80
      ELSE                                                              CHALIS     81
            WRITE(LOUT,1026)                                            CHALIS     82
            IOK=-1                                                      CHALIS     83
      ENDIF                                                             CHALIS     84
C    :................................................................: CHALIS     85
                                                                        CHALIS     86
 9999 CONTINUE                                                          CHALIS     87
      RETURN                                                            CHALIS     88
1026       FORMAT(/,                                                    CHALIS     89
     1      10X,'********************************',/,                   CHALIS     90
     1      10X,'*  CHANNEL FILE NOT AVAILABLE  *',/,                   CHALIS     91
     1      10X,'* USE "OPENCASE" COMMAND FIRST *',/,                   CHALIS     92
     1      10X,'********************************')                     CHALIS     93
                                                                        CHALIS     94
       END                                                              CHALIS     95
                                                                        CHALIS     96
      SUBROUTINE PARSCH(CHNLIS,CHN,NCHN,BUFPNT,BUF,NLIS,NTP,NPOINT,     CHALIS     97
     *          KR,LOUT,IOK)                                            CHALIS     98
CD                                                                      CHALIS     99
CD          THIS ROUTINE PARSES COMMAND LINE PARAMETER FOR CHANNEL      CHALIS    100
CD          SPEC                                                        CHALIS    101
CD                                                                      CHALIS    102
CD            CALLING PARAMETERS :                                      CHALIS    103
CD                                                                      CHALIS    104
CD                   CHNLIS   :  CHARACTER STRING CONTAINING THE NAME   CHALIS    105
CD                               OF THE CHANNEL ASSIGNED BY THE USER    CHALIS    106
CD                   CHN      :  CONTAIN THE CHANNEL LIST               CHALIS    107
CD                   NCHN     :  NUMBER OF CHANNEL STORED               CHALIS    108
CD                   BUFPNT   :  BUFFER STORE IN THE CHANNELS GOING TO BCHALIS    109
CD                               PROCESSED                              CHALIS    110
CD                   BUF      :  BUFFER STORING THE PROCESSED CHANNEL RECHALIS    111
CD                               RESULT                                 CHALIS    112
CD                   NLIS     :  NUMBER OF CHANNEL IN THE BUFFER        CHALIS    113
CD                   NTP      :  TOTAL NO. OF POINTS                    CHALIS    114
CD                   NPOINT   :  TOTAL NO. OF POINT IN THE BUFFER       CHALIS    115
CD                   KR       :  ARRAY WITH THE RECORD AND FIELD PONITERCHALIS    116
CD                               INFO.                                  CHALIS    117
CD                   LOUT     :  LOGICAL UNIT FOR OUTPUT                CHALIS    118
CD                   IOK      :  STATUS FLAG FOR CHANNEL READ           CHALIS    119
CD                                                                      CHALIS    120
CD                                                                      CHALIS    121
      INCLUDE 'PARAM.INS'                                               CHALIS    122
      INCLUDE 'DBFLG.INS'                                               CHALIS    123
      COMMON /RECPT/ KRSTRT, ISTNAM, IIDARY, ITYARY, IHREC,ICHAN,       CHALIS    124
     *          NPFL,LRREC,IRREC                                        CHALIS    125
      INCLUDE 'JJNAME.INS'                                              CHALIS    126
C                                                                       CHALIS    127
      CHARACTER*2 UID                                                   CHALIS    128
      CHARACTER*80 CHNLIS(MAXLIS)                                       CHALIS    129
      INTEGER NCHN(MAXLIS),CHN(MAXLIS,MAXCHN),BUFPNT(MAXLIS,NBUF)       CHALIS    130
      REAL BUF(NBUF,MXPT)                                               CHALIS    131
C                                                                       CHALIS    132
      LOGICAL WARNED,SAMETY                                             CHALIS    133
      DIMENSION KR(MCHNL,2)                                             CHALIS    134
      IOK=0                                                             CHALIS    135
      LDEB=99                                                           CHALIS    136
      LDEBUG=DEBUG(8)                                                   CHALIS    137
      SAMETY=.FALSE.                                                    CHALIS    138
      LL=0                                                              CHALIS    139
      LR=0                                                              CHALIS    140
      LLCB=INDEX(CHNLIS(NLIS),'(')                                      CHALIS    141
      LRCB=INDEX(CHNLIS(NLIS),')')                                      CHALIS    142
      LLZB=INDEX(CHNLIS(NLIS),'{')                                      CHALIS    143
      LRZB=INDEX(CHNLIS(NLIS),'}')                                      CHALIS    144
      IF(LLCB.GT.0) LL=LLCB                                             CHALIS    145
      IF(LRCB.GT.0) LR=LRCB                                             CHALIS    146
      IF(LRZB.GT.0) LR=LRZB                                             CHALIS    147
      IF(LLZB.GT.0) THEN                                                CHALIS    148
          LL=LLZB                                                       CHALIS    149
          SAMETY=.TRUE.                                                 CHALIS    150
      ENDIF                                                             CHALIS    151
C                                                                       CHALIS    152
      ICOL=INDEX(CHNLIS(NLIS),':')                                      CHALIS    153
      IF(ICOL.NE.0) THEN                                                CHALIS    154
         READ(CHNLIS(NLIS)(LL+1:ICOL-1),*,IOSTAT=IOS)KFROM              CHALIS    155
         IF(IOS.NE.0) GOTO 99                                           CHALIS    156
         READ(CHNLIS(NLIS)(ICOL+1:LR-1),*,IOSTAT=IOS)KTO                CHALIS    157
         IF(IOS.NE.0) GOTO 99                                           CHALIS    158
         IF(KFROM.LT.11) KFROM=11                                       CHALIS    159
         IF(KTO.GT.ICHAN) KTO=ICHAN                                     CHALIS    160
         ISL=0                                                          CHALIS    161
         CALL UNPACK(UID,NTYPE,ITY(1,KFROM))                            CHALIS    162
 98      CONTINUE                                                       CHALIS    163
            IF(SAMETY) THEN                                             CHALIS    164
               CALL UNPACK(UID,NTYPE1,ITY(1,KFROM))                     CHALIS    165
               IF(NTYPE.NE.NTYPE1) THEN                                 CHALIS    166
                   IF(KFROM.GT.KTO) GOTO 97                             CHALIS    167
                   KFROM=KFROM+1                                        CHALIS    168
                   GOTO 98                                              CHALIS    169
               ENDIF                                                    CHALIS    170
            ENDIF                                                       CHALIS    171
            ISL=ISL+1                                                   CHALIS    172
            CHN(NLIS,ISL)=KFROM                                         CHALIS    173
            IF(KFROM.GT.KTO) GOTO 97                                    CHALIS    174
            KFROM=KFROM+1                                               CHALIS    175
         GOTO 98                                                        CHALIS    176
C       ............................................................    CHALIS    177
C       : error on command line parameter. get out..               :    CHALIS    178
 99      CONTINUE                                                       CHALIS    179
         WRITE(LOUT,2011)                                               CHALIS    180
         IOK=-1                                                         CHALIS    181
         GOTO 9999                                                      CHALIS    182
C       :...........................................................:   CHALIS    183
 97      CONTINUE                                                       CHALIS    184
         IF(ISL.GE.NBUF) ISL=NBUF-2                                     CHALIS    185
         NCHN(NLIS)=ISL-1                                               CHALIS    186
         KR(1,1)=NCHN(NLIS)                                             CHALIS    187
         KR(1,2)=NCHN(NLIS)                                             CHALIS    188
C     :.................................................................CHALIS    189
      ELSE                                                              CHALIS    190
C     ..................................................................CHALIS    191
C     : syntax is (I1,I2,I3,..Ix)                                       CHALIS    192
C     :                                                                 CHALIS    193
         NON=1                                                          CHALIS    194
         DO 1020 I=LL+1,LR-1                                            CHALIS    195
            IF(CHNLIS(NLIS)(I:I).EQ.',')NON=NON+1                       CHALIS    196
 1020    CONTINUE                                                       CHALIS    197
                                                                        CHALIS    198
         IF(LDEBUG) THEN                                                CHALIS    199
            WRITE(LDEB,1000) CHNLIS(NLIS),LL,LR,NON                     CHALIS    200
 1000       FORMAT(/,1X,' ** DEBUG (PARSCH) ** CHNLIS : ',A,/,          CHALIS    201
     1      'LL= ',I3,' LR= ',I3,' NON= ',I3)                           CHALIS    202
         ENDIF                                                          CHALIS    203
         IF(NON.GE.NBUF) NON=NBUF-2                                     CHALIS    204
         NCHN(NLIS)=NON                                                 CHALIS    205
         KR(1,1)=NON                                                    CHALIS    206
         KR(1,2)=NON                                                    CHALIS    207
         READ(CHNLIS(NLIS)(LL+1:LR-1),*,IOSTAT=IOS)                     CHALIS    208
     *           (CHN(NLIS,IX),IX=1,NON)                                CHALIS    209
         IF(IOS.NE.0) GOTO 999                                          CHALIS    210
         GOTO 1205                                                      CHALIS    211
C       :.............................................................: CHALIS    212
C       ............................................................    CHALIS    213
C       : error on command line parameter. get out..               :    CHALIS    214
 999     CONTINUE                                                       CHALIS    215
         WRITE(LOUT,2011)                                               CHALIS    216
         IOK=-1                                                         CHALIS    217
         GOTO 9999                                                      CHALIS    218
C       :...........................................................:   CHALIS    219
 1205    CONTINUE                                                       CHALIS    220
                                                                        CHALIS    221
      ENDIF                                                             CHALIS    222
C   *...................................................................CHALIS    223
C   ....................................................................CHALIS    224
C   :                                                                   CHALIS    225
      CALL UNPACK(UID,NTYPE,ITY(1,CHN(NLIS,1)))                         CHALIS    226
      WARNED=.FALSE.                                                    CHALIS    227
      DO 1030 I=1,NCHN(NLIS)                                            CHALIS    228
         CALL UNPACK(UID,NTYPE1,ITY(1,CHN(NLIS,I)))                     CHALIS    229
         IF(NTYPE.NE.NTYPE1) THEN                                       CHALIS    230
            IF(.NOT.WARNED) THEN                                        CHALIS    231
               WARNED=.TRUE.                                            CHALIS    232
               IOK=1                                                    CHALIS    233
               WRITE(LOUT,1031)                                         CHALIS    234
 1031          FORMAT(/,1X,'++WARNING: Different Channel Type++')       CHALIS    235
            ENDIF                                                       CHALIS    236
         ENDIF                                                          CHALIS    237
         CALL RECFLD(CHN(NLIS,I),KR(I+1,1),KR(I+1,2))                   CHALIS    238
 1030 CONTINUE                                                          CHALIS    239
C   :...................................................................CHALIS    240
                                                                        CHALIS    241
C   .....................................................               CHALIS    242
C   : Debug show contains of record/field pointer array :               CHALIS    243
C   :                                                   :               CHALIS    244
      IF(LDEBUG) THEN                                                   CHALIS    245
        WRITE(LDEB,1011)                                                CHALIS    246
        DO 90 I=1,NCHN(NLIS)                                            CHALIS    247
           WRITE(LDEB,1012) KR(I+1,1),KR(I+1,2),CHN(NLIS,I)             CHALIS    248
   90   CONTINUE                                                        CHALIS    249
 1012   FORMAT(1X,3I20)                                                 CHALIS    250
 1011   FORMAT(1X,'+++(PARSCH)+++ (1ST LINE IS NUMBER OF CHANNELS',/,   CHALIS    251
     1         1X,'      PHYSICAL RECORD #       FIELD NUMBER ',/,      CHALIS    252
     1         1X,'      ------------------      -------------')        CHALIS    253
      ENDIF                                                             CHALIS    254
C    :...................................................:              CHALIS    255
                                                                        CHALIS    256
                                                                        CHALIS    257
 9999 CONTINUE                                                          CHALIS    258
      RETURN                                                            CHALIS    259
C                                                                       CHALIS    260
 2011 FORMAT(/,                                                         CHALIS    261
     110X,'*******************************************************',/,  CHALIS    262
     110X,'*                                                     *',/,  CHALIS    263
     110X,'*         ** Command Line Parameter Error **          *',/,  CHALIS    264
     110X,'*                                                     *',/,  CHALIS    265
     110X,'*   Format 1.  (I1:I2)                                *',/,  CHALIS    266
     110X,'*                                                     *',/,  CHALIS    267
     110X,'*              I1 = beginning channel number          *',/,  CHALIS    268
     110X,'*              I2 = ending channel number             *',/,  CHALIS    269
     110X,'*                                                     *',/,  CHALIS    270
     110X,'*                                                     *',/,  CHALIS    271
     110X,'*   Format 2.  (J1,J2,J3,J4,...Jx)                    *',/,  CHALIS    272
     110X,'*                                                     *',/,  CHALIS    273
     110X,'*              J1 to Jx are actual channel numbers.   *',/,  CHALIS    274
     110X,'*                                                     *',/,  CHALIS    275
     110X,'*******************************************************',/)  CHALIS    276
      END                                                               CHALIS    277
C                                                                       CHALIS    278
      SUBROUTINE RECHN(BUF,TIME,BUFPNT,NLIS,M,N,NTP,IU8,KRECFD,LOUT,    CHALIS    279
     1          NCHN,NPOINT)                                            CHALIS    280
CD                                                                      CHALIS    281
CD            THIS ROUTINE READS PLOTTING DATA FROM CHANNEL FILE        CHALIS    282
CD            FOR CHANNEL RECORDING                                     CHALIS    283
CD                                                                      CHALIS    284
CD                                                                      CHALIS    285
CD            CALLING PARAMETER:                                        CHALIS    286
CD                                                                      CHALIS    287
CD                   BUF      :  BUFFER STORING THE PROCESSED CHANNEL RECHALIS    288
CD                               RESULT                                 CHALIS    289
CD                   TIME     :  TIME POINT ARRAY                       CHALIS    290
CD                   BUFPNT   :  BUFFER STORE IN THE CHANNELS GOING TO BCHALIS    291
CD                               PROCESSED                              CHALIS    292
CD                   NLIS     :  NUMBER OF CHANNEL IN THE BUFFER        CHALIS    293
CD                   M        :  MAX. NO. OF POINT ALLOWED              CHALIS    294
CD                   N        :  MAX. NO. OF CHANNEL ALLOWED            CHALIS    295
CD                   NTP      :  TOTAL NO. OF POINTS                    CHALIS    296
CD                   IU8      :  LOGICAL UNIT FOR THE CHANNAL FILE      CHALIS    297
CD                   LRECFD   :  ARRAY WITH THE RECORD AND FIELD PONITERCHALIS    298
CD                               INFO.                                  CHALIS    299
CD                   NPOINT   :  TOTAL NO. OF POINT IN THE BUFFER       CHALIS    300
CD                   NCHN     :  NUMBER OF CHANNEL STORED               CHALIS    301
CD                   LOUT     :  LOGICAL UNIT OUTPUT                    CHALIS    302
CD                                                                      CHALIS    303
CD                                                                      CHALIS    304
      INCLUDE 'PARAM.INS'                                               CHALIS    305
      INCLUDE 'DBFLG.INS'                                               CHALIS    306
      REAL BUF(N,M),TIME(M)                                             CHALIS    307
C!                                                                      CHALIS    308
      INTEGER BUFPNT(MAXLIS,N),NCHN(MAXLIS)                             CHALIS    309
C                                                                       CHALIS    310
      COMMON /REC9/ IRECS,NREC,IREC9(128)                               CHALIS    311
C!                                                                      CHALIS    312
      INTEGER KRECFD(MCHNL,2)                                           CHALIS    313
C                                                                       CHALIS    314
      COMMON /RECPT/ KRSTRT, ISTNAM, IIDARY, ITYARY, IHREC,ICHAN        CHALIS    315
     * , NPFL,LRREC,IRREC                                               CHALIS    316
      LOGICAL IEND                                                      CHALIS    317
      REAL*4  TBUF(128)                                                 CHALIS    318
      LDEBUG=DEBUG(4)                                                   CHALIS    319
C   .....................................................               CHALIS    320
C   : Debug show contains of record/field pointer array :               CHALIS    321
C   :                                                   :               CHALIS    322
      IF(LDEBUG) THEN                                                   CHALIS    323
        WRITE(IDBOUT,1011)                                              CHALIS    324
        DO 90 I=1,MCHNL                                                 CHALIS    325
           WRITE(IDBOUT,1010) KRECFD(I,1),KRECFD(I,2)                   CHALIS    326
   90   CONTINUE                                                        CHALIS    327
 1010   FORMAT(1X,2I20)                                                 CHALIS    328
 1011   FORMAT(1X,'+++(RECHN)+++ (1ST LINE IS NUMBER OF CHANNELS',/,    CHALIS    329
     1         1X,'      PHYSICAL RECORD #       FIELD NUMBER ',/,      CHALIS    330
     1         1X,'      ------------------      -------------')        CHALIS    331
      ENDIF                                                             CHALIS    332
C    :...................................................:              CHALIS    333
                                                                        CHALIS    334
C   ....................................................................CHALIS    335
C   : Initialize pointers before starting                               CHALIS    336
C   : Point next record pointer NREC to absolute start of data KRSTRT   CHALIS    337
      NREC=KRSTRT                                                       CHALIS    338
C   : Initialize Maximum number of points MM                            CHALIS    339
      MM=0                                                              CHALIS    340
C   : Initialize pointer to beginning of a time step. The first one beinCHALIS    341
C   : the absolute start of time step data                              CHALIS    342
      IBEGIN=KRSTRT                                                     CHALIS    343
C   :...................................................................CHALIS    344
                                                                        CHALIS    345
C   ....................................................................CHALIS    346
C   : Continue reading from the SIMU file until EOF                     CHALIS    347
C   :                                                                   CHALIS    348
 11   CONTINUE                                                          CHALIS    349
C                                                                       CHALIS    350
C     ........................................                          CHALIS    351
C     : READ RECORD 1 FOR TIME STEP          :                          CHALIS    352
        MM=MM+1                                                         CHALIS    353
        IF(MM.GE.M-4) THEN                                              CHALIS    354
          MM=MM-1                                                       CHALIS    355
          WRITE(LOUT,1030)BUF(1,MM)                                     CHALIS    356
C          WRITE(LOUT,1030)X(MM)                                        CHALIS    357
 1030     FORMAT(/,                                                     CHALIS    358
     1    10X,'++++++++++++++++++++++++++++++++++++++++++++++++',/,     CHALIS    359
     1    10X,' WARNING: TOO MANY DATA POINTS IN CHANNEL FILE. ',/,     CHALIS    360
     1    10X,'          LAST TIME STEP READ IN IS ',F10.5,//,          CHALIS    361
C     1    10X,'   FOR MORE INFORMATION, TYPE "HELP/LIMITS"     ',/,    CHALIS    362
     1    10X,'++++++++++++++++++++++++++++++++++++++++++++++++',/)     CHALIS    363
          GOTO 940                                                      CHALIS    364
        ENDIF                                                           CHALIS    365
        CALL DAFLWR(IU8,1,NREC,TBUF,128,IEND)                           CHALIS    366
        NOWREC=NREC                                                     CHALIS    367
        IF(TBUF(2).GT.99999) THEN                                       CHALIS    368
           MM=MM-1                                                      CHALIS    369
           GOTO 940                                                     CHALIS    370
        ELSE                                                            CHALIS    371
           IF(NPOINT.EQ.1)BUF(1,MM)=TBUF(2)                             CHALIS    372
           TIME(MM)=TBUF(2)                                             CHALIS    373
C           X(MM)=TBUF(2)                                               CHALIS    374
        ENDIF                                                           CHALIS    375
C     :.......................................:                         CHALIS    376
C                                                                       CHALIS    377
C     ........................................................          CHALIS    378
C     : Start filling in the Y-array one row at a time (I)   :          CHALIS    379
C     : KRECFD(1,1) contains the number of channel requested :          CHALIS    380
C     : Index (I) - Y-array column number                    :          CHALIS    381
C     : Index (II) - KRECFD index array. Column 1 = record#; :          CHALIS    382
C     :                                  Column 2 = field#   :          CHALIS    383
        II=1                                                            CHALIS    384
C        DO 110 I=1,KRECFD(1,1)                                         CHALIS    385
        DO 110 I=1,NCHN(NLIS)                                           CHALIS    386
           II=II+1                                                      CHALIS    387
           BUFPNT(NLIS,I)=NPOINT+I                                      CHALIS    388
           IF(KRECFD(II,1).EQ.(NOWREC-IBEGIN)) THEN                     CHALIS    389
              BUF(BUFPNT(NLIS,I),MM)=TBUF(KRECFD(II,2))                 CHALIS    390
C              Y(MM,I)=TBUF(KRECFD(II,2))                               CHALIS    391
           ELSE                                                         CHALIS    392
              NREC=IBEGIN+KRECFD(II,1)-1                                CHALIS    393
              CALL DAFLWR(IU8,1,NREC,TBUF,128,IEND)                     CHALIS    394
              NOWREC=NREC                                               CHALIS    395
              BUF(BUFPNT(NLIS,I),MM)=TBUF(KRECFD(II,2))                 CHALIS    396
C              Y(MM,I)=TBUF(KRECFD(II,2))                               CHALIS    397
           ENDIF                                                        CHALIS    398
 110    CONTINUE                                                        CHALIS    399
C      :........................................................:       CHALIS    400
        IF(IEND) GOTO 940                                               CHALIS    401
        IBEGIN=IBEGIN+IRECS                                             CHALIS    402
        NREC=IBEGIN                                                     CHALIS    403
      GOTO 11                                                           CHALIS    404
C   :                                                                   CHALIS    405
C   :...................................................................CHALIS    406
C                                                                       CHALIS    407
 940  CONTINUE                                                          CHALIS    408
      NPOINT=NPOINT+NCHN(NLIS)                                          CHALIS    409
      NTP=MM                                                            CHALIS    410
C   ........................................................            CHALIS    411
C   : Debug write                                          :            CHALIS    412
C   :                                                      :            CHALIS    413
      IF(LDEBUG) THEN                                                   CHALIS    414
        WRITE(IDBOUT,1300)MM                                            CHALIS    415
        DO 120 I=1,MM                                                   CHALIS    416
          WRITE(IDBOUT,1200) BUF(1,I),(BUF(BUFPNT(NLIS,II),I),          CHALIS    417
     *          II=1,NCHN(NLIS))                                        CHALIS    418
 1200     FORMAT(1X,12F10.5)                                            CHALIS    419
 120    CONTINUE                                                        CHALIS    420
 1300   FORMAT(1X,'+++(RECHN)++ NUMBER OF DATA POINTS :',I6)            CHALIS    421
      ENDIF                                                             CHALIS    422
C   :.......................................................:           CHALIS    423
                                                                        CHALIS    424
      RETURN                                                            CHALIS    425
      END                                                               CHALIS    426
