CFPRIME SAVEIT                                                          SAVEIT      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 SAVEIT(PARAM,LENPAR)                                   SAVEIT      3
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSAVEIT      4
CD                                                                      SAVEIT      5
CD           THIS ROUTINE SAVES THE CONTENT OF BUFFERS TO A FILE        SAVEIT      6
CD                                                                      SAVEIT      7
CD           CALLING PARAMETERS :                                       SAVEIT      8
CD                                                                      SAVEIT      9
CD                       PARAM  - CHARACTER STRING CONTAINING THE FILE  SAVEIT     10
CD                                NAME                                  SAVEIT     11
CD                       LENPAR - NUMBER OF CHARACTER IN PARAM          SAVEIT     12
CD                                                                      SAVEIT     13
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSAVEIT     14
C                                                                       SAVEIT     15
      CHARACTER*(*) PARAM                                               SAVEIT     16
      INCLUDE 'PARAM.INS'                                               SAVEIT     17
      INCLUDE 'SOAPC1.INS'                                              SAVEIT     18
      INCLUDE 'XYARAY.INS'                                              SAVEIT     19
      INCLUDE 'BUFBIG.INS'                                              SAVEIT     20
      INCLUDE 'DBFLG.INS'                                               SAVEIT     21
      INCLUDE 'GTIT.INS'                                                SAVEIT     22
      INCLUDE 'JJNAME.INS'                                              SAVEIT     23
      INCLUDE 'CHDISP.INS'                                              SAVEIT     24
      CHARACTER CTIME*8,CDATE*9,UID*2                                   SAVEIT     25
      CHARACTER*80 MSG,STRING                                           SAVEIT     26
      LDEBUG=DEBUG(11)                                                  SAVEIT     27
      ISAVE=9                                                           SAVEIT     28
      CALL YYMMDD(CDATE)                                                SAVEIT     29
      CALL HHMMSS(CTIME)                                                SAVEIT     30
C                                                                       SAVEIT     31
      IF(FILLED) THEN                                                   SAVEIT     32
         IF(IPLTYP.NE.1)THEN                                            SAVEIT     33
           WRITE(LOUT,1500)                                             SAVEIT     34
           GOTO 9999                                                    SAVEIT     35
         ENDIF                                                          SAVEIT     36
         WRITE(LOUT,1000)                                               SAVEIT     37
 1000    FORMAT(//,1X,'Saving contents of buffer into a file.',/)       SAVEIT     38
C                                                                       SAVEIT     39
         IF(PARAM(1:1).EQ.' ') THEN                                     SAVEIT     40
           MSG='Enter Output File Name'                                 SAVEIT     41
           CALL PMTRED(LOUT,LIN,JERR,22,MSG,'SAV',STRING)               SAVEIT     42
           IF((JERR.LT.0).OR.(STRING(1:4).EQ.'QUIT').OR.                SAVEIT     43
     1     (STRING(1:5).EQ.'ABORT') ) THEN                              SAVEIT     44
              WRITE(LOUT,1003)                                          SAVEIT     45
              GOTO 9999                                                 SAVEIT     46
           ENDIF                                                        SAVEIT     47
           LENFIL=LENS(STRING)                                          SAVEIT     48
           PARAM(1:50)=STRING(1:50)                                     SAVEIT     49
           IF(LENFIL.LE.0) THEN                                         SAVEIT     50
              WRITE(LOUT,1003)                                          SAVEIT     51
              GOTO 9999                                                 SAVEIT     52
           ENDIF                                                        SAVEIT     53
           IF(RECORD) WRITE(IREC,1140) STRING                           SAVEIT     54
         ELSE                                                           SAVEIT     55
           LENFIL=LENPAR                                                SAVEIT     56
           STRING(1:LENFIL)=PARAM(1:LENFIL)                             SAVEIT     57
         ENDIF                                                          SAVEIT     58
C      ..................................................               SAVEIT     59
C      : Parse parameter for a logical unit number      :               SAVEIT     60
         CALL PARSIU(PARAM,LENFIL,IU,LO)                                SAVEIT     61
         IF(IU.GT.0)THEN                                                SAVEIT     62
            STRING(1:LENFIL)=PARAM(1:LENFIL)                            SAVEIT     63
            ISAVE=IU                                                    SAVEIT     64
            LENFIL=LO                                                   SAVEIT     65
         ENDIF                                                          SAVEIT     66
C      :................................................:               SAVEIT     67
         CALL OPENFI(ISAVE,STRING,LENFIL,IERR,'UNKNOWN',1)              SAVEIT     68
         IF(IERR.LT.0) THEN                                             SAVEIT     69
            WRITE(LOUT,1005)                                            SAVEIT     70
            GOTO 9999                                                   SAVEIT     71
 1005       FORMAT(//,1X,'** File Open ERROR **',//)                    SAVEIT     72
         ENDIF                                                          SAVEIT     73
C                                                                       SAVEIT     74
         DO 1100 II=1,6                                                 SAVEIT     75
           WRITE(ISAVE,'(A)')PTITLE(II)                                 SAVEIT     76
 1100    CONTINUE                                                       SAVEIT     77
C                                                                       SAVEIT     78
         DO 1200 J=1,KCH(1)                                             SAVEIT     79
C   Channel #, file name and case ID                                    SAVEIT     80
           KCHAN=KCH(J+1)                                               SAVEIT     81
           WRITE(ISAVE,'(A,I6,1X,A,1X,A)')'CH# ',KCHAN,FILCHN(J)(1:56), SAVEIT     82
     +                                 CASEID(J)                        SAVEIT     83
C   Y-axis label                                                        SAVEIT     84
           WRITE(ISAVE,'(A)')YTITLE(J)                                  SAVEIT     85
C   Channel description                                                 SAVEIT     86
           WRITE(ISAVE,'(A)')LTITLE(J)                                  SAVEIT     87
C   File description 1                                                  SAVEIT     88
           WRITE(ISAVE,'(A)')LTITL2(J)                                  SAVEIT     89
C   File description 2                                                  SAVEIT     90
           WRITE(ISAVE,'(A)')CTITL2(J)                                  SAVEIT     91
C                                                                       SAVEIT     92
           DO 400 I=1,MAXPT(J)                                          SAVEIT     93
             WRITE(ISAVE,'(2F12.5)') XARAY(I,J),YARAY(I,J)              SAVEIT     94
  400      CONTINUE                                                     SAVEIT     95
           WRITE(ISAVE,'(A)') ' END'                                    SAVEIT     96
 1200    CONTINUE                                                       SAVEIT     97
C                                                                       SAVEIT     98
         CLOSE(ISAVE)                                                   SAVEIT     99
      ELSE                                                              SAVEIT    100
         WRITE(LOUT,2000)                                               SAVEIT    101
 2000    FORMAT(//,1X,'** Nothing in BUFFER to save. ***',//)           SAVEIT    102
      ENDIF                                                             SAVEIT    103
C                                                                       SAVEIT    104
 9999 RETURN                                                            SAVEIT    105
C                                                                       SAVEIT    106
 1003 FORMAT(//,1X,'+++ SAVE COMMAND ABORTED +++',//)                   SAVEIT    107
 1140 FORMAT(A)                                                         SAVEIT    108
 1150 FORMAT(1X,A)                                                      SAVEIT    109
 1500 FORMAT(/,10X,'IN THE CURRENT VERSION, ONLY FUNCTIONS OF TIME,'    SAVEIT    110
     +       /,10X,'CAN BE SAVE/RESTORED')                              SAVEIT    111
      END                                                               SAVEIT    112
