CFPRIME DPSOAP                                                          DPSOAP      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 DPSOAP(OP,IPR,IDV)                                     DPSOAP      3
CD                                                                      DPSOAP      4
CD           THIS ROTUINE IS THE MAIN DRIVER FOR THE LINE               DPSOAP      5
CD           PRINTER PLOT.                                              DPSOAP      6
CD                                                                      DPSOAP      7
CD           CALLING PARAMETERS :                                       DPSOAP      8
CD                                                                      DPSOAP      9
CD                          OP  : COMMAND FOR THE LINE PRINTER PLOT     DPSOAP     10
CD                          IPR : FLAG FOR THE SIZE OF THE PLOT         DPSOAP     11
CD                                   1 : 130 COLUMN PLOT                DPSOAP     12
CD                                   0 : 80  COLUMN PLOT                DPSOAP     13
CD                          IDV : NOT USED                              DPSOAP     14
      INCLUDE 'PARAM.INS'                                               DPSOAP     15
      INCLUDE 'XYARAY.INS'                                              DPSOAP     16
      INCLUDE 'DPPLOT.INS'                                              DPSOAP     17
      INCLUDE 'SOAPC1.INS'                                              DPSOAP     18
      CHARACTER*1 QQ                                                    DPSOAP     19
      CHARACTER*8 OP                                                    DPSOAP     20
      CHARACTER*132 LINE,LINE2                                          DPSOAP     21
      INTEGER ISAME(6)                                                  DPSOAP     22
                                                                        DPSOAP     23
      SAVE LABELC,JPOUT                                                 DPSOAP     24
C     .............................................................     DPSOAP     25
C     : SET UP PLOTTING PAGE DIMENSIONS AND OUTPUT LOGICAL DEVICE :     DPSOAP     26
C     :...........................................................:     DPSOAP     27
      IF (OP.EQ.'SETPAGE ') THEN                                        DPSOAP     28
         IF (IPR.EQ.1) THEN                                             DPSOAP     29
C       ..........................                                      DPSOAP     30
C       : PLOT ON PRINTER 130X60 :                                      DPSOAP     31
           IDPDEV=IDV                                                   DPSOAP     32
C           IXSTRT=31                                                   DPSOAP     33
           IXSTRT=61                                                    DPSOAP     34
           IXEND=131                                                    DPSOAP     35
C           IXINC=10                                                    DPSOAP     36
           IXINC=7                                                      DPSOAP     37
           IYSTRT=5                                                     DPSOAP     38
           IYEND=55                                                     DPSOAP     39
           IYINC=5                                                      DPSOAP     40
           JPOUT=0                                                      DPSOAP     41
         ELSE                                                           DPSOAP     42
C       ..........................                                      DPSOAP     43
C       : PLOT ON TERMINAL 80X22 :                                      DPSOAP     44
           IDPDEV=IDV                                                   DPSOAP     45
           IXSTRT=35                                                    DPSOAP     46
           IXEND=75                                                     DPSOAP     47
           IXINC=10                                                     DPSOAP     48
           IYSTRT=3                                                     DPSOAP     49
           IYEND=23                                                     DPSOAP     50
           IYINC=4                                                      DPSOAP     51
           JPOUT=-1                                                     DPSOAP     52
         ENDIF                                                          DPSOAP     53
         NP=-1                                                          DPSOAP     54
         LABELC=0                                                       DPSOAP     55
         GOTO 9999                                                      DPSOAP     56
      ENDIF                                                             DPSOAP     57
                                                                        DPSOAP     58
      IF (OP.EQ.'CLEARPAG')THEN                                         DPSOAP     59
         CALL DPMAIN(1,LABELC,0,0,0,0)                                  DPSOAP     60
         CALL DPMAIN(2,LABELC,0,0,0,0)                                  DPSOAP     61
         IP2=0                                                          DPSOAP     62
         GOTO 9999                                                      DPSOAP     63
      ENDIF                                                             DPSOAP     64
                                                                        DPSOAP     65
      IF (OP.EQ.'SETOUT  ')THEN                                         DPSOAP     66
         IDPDEV=IDV                                                     DPSOAP     67
         GOTO 9999                                                      DPSOAP     68
      ENDIF                                                             DPSOAP     69
                                                                        DPSOAP     70
C     .........................                                         DPSOAP     71
C     : PLOT CALLING SEQUENCE :                                         DPSOAP     72
C     :.......................:                                         DPSOAP     73
      IF (OP.EQ.'PLOT1   ') THEN                                        DPSOAP     74
C         NCOL=KRECFD(1,1)                                              DPSOAP     75
         LABELC=LABELC+1                                                DPSOAP     76
C         IF(LABELC.GE.4) THEN                                          DPSOAP     77
C            LABELC=1                                                   DPSOAP     78
C            CALL DPMAIN(1,LABELC,0,0,0,0)                              DPSOAP     79
C            CALL DPMAIN(2,LABELC,0,0,0,0)                              DPSOAP     80
C         ENDIF                                                         DPSOAP     81
C       ..........................................................      DPSOAP     82
C       :DON'T RE-SCALE THE TIME (X) AXIS IF NOT THE FIRST CURVE :      DPSOAP     83
C       :(SCALX IS SET IN IGOTO-DPINIT AND RESET HERE)           :      DPSOAP     84
C         IF(SCALX) THEN                                                DPSOAP     85
          IF(.NOT.SSCALE)THEN                                           DPSOAP     86
            SCALX=.FALSE.                                               DPSOAP     87
            IAUTOX=0                                                    DPSOAP     88
          ENDIF                                                         DPSOAP     89
C         ELSE                                                          DPSOAP     90
C           IAUTOX=-1                                                   DPSOAP     91
C         ENDIF                                                         DPSOAP     92
C       :........................................................:      DPSOAP     93
C       ..........................................................      DPSOAP     94
C       : User specified scale option selected if USCALE is true :      DPSOAP     95
C       :                                                        :      DPSOAP     96
C         IF(USCALE) THEN                                               DPSOAP     97
           NSC=1                                                        DPSOAP     98
C         ELSE                                                          DPSOAP     99
C           NSC=0                                                       DPSOAP    100
C         ENDIF                                                         DPSOAP    101
C       :........................................................:      DPSOAP    102
                                                                        DPSOAP    103
C   ................................................. .............     DPSOAP    104
C   : PLOT FROM DATA READ FROM 1ST FILE                           :     DPSOAP    105
C   :                                                             :     DPSOAP    106
        IF(SSCALE)THEN                                                  DPSOAP    107
          IP2M1=IP2+1                                                   DPSOAP    108
          CALL SCALES(IP2M1,KCH(1),XARAY)                               DPSOAP    109
          SSCALE=.FALSE.                                                DPSOAP    110
        ENDIF                                                           DPSOAP    111
        NPREV=IP2                                                       DPSOAP    112
        IP2=IP2+1                                                       DPSOAP    113
C   DO Y-AXIS AND PLOT  :                                               DPSOAP    114
        DO 100 IY=1,KCH(1)-NPREV                                        DPSOAP    115
C       80 COLUMNS                                                      DPSOAP    116
          IF(IPR.EQ.0)THEN                                              DPSOAP    117
            CALL DPMAIN(3,LABELC,-1,IAUTOX,NSC,IP2)                     DPSOAP    118
C       132 COLUMNS                                                     DPSOAP    119
          ELSE                                                          DPSOAP    120
            CALL DPMAIN(3,LABELC,0,IAUTOX,NSC,IP2)                      DPSOAP    121
          ENDIF                                                         DPSOAP    122
          IP2=IP2+1                                                     DPSOAP    123
  100   CONTINUE                                                        DPSOAP    124
        IP2=IP2-1                                                       DPSOAP    125
        IF((IP2.EQ.3).AND.(IPR.EQ.0))THEN                               DPSOAP    126
          IP2=0                                                         DPSOAP    127
        ELSE IF(IP2.EQ.6)THEN                                           DPSOAP    128
          IP2=0                                                         DPSOAP    129
        ENDIF                                                           DPSOAP    130
C         CALL DPMAIN(4,2,1,JPOUT,0,0)                                  DPSOAP    131
         GOTO 9999                                                      DPSOAP    132
      ENDIF                                                             DPSOAP    133
                                                                        DPSOAP    134
      IF (OP.EQ.'LISTDATA') THEN                                        DPSOAP    135
         IPAGE=0                                                        DPSOAP    136
         IP=1                                                           DPSOAP    137
         CALL CHKSAM(ISAME)                                             DPSOAP    138
         LINE(1:132)=' '                                                DPSOAP    139
         DO 10 I1=2,KRECFD(1,1)+1                                       DPSOAP    140
           IF(I1.EQ.2)THEN                                              DPSOAP    141
             WRITE(LINE(IP:IP+20),1027)KCH(I1)                          DPSOAP    142
             IP=IP+20                                                   DPSOAP    143
           ELSE IF(ISAME(I1-1).EQ.ISAME(I1-2))THEN                      DPSOAP    144
             WRITE(LINE(IP:IP+10),1028)KCH(I1)                          DPSOAP    145
             IP=IP+10                                                   DPSOAP    146
           ELSE                                                         DPSOAP    147
             WRITE(LINE(IP:IP+20),1027)KCH(I1)                          DPSOAP    148
             IP=IP+20                                                   DPSOAP    149
           ENDIF                                                        DPSOAP    150
  10     CONTINUE                                                       DPSOAP    151
         WRITE(LOUT,'(132A1)')(LINE(I:I),I=1,ISLEN(LINE)+1)             DPSOAP    152
         ITMAX=0                                                        DPSOAP    153
         DO 15 J=1,KRECFD(1,1)                                          DPSOAP    154
           ITMAX=MAX(ITMAX,MAXPT(J))                                    DPSOAP    155
  15     CONTINUE                                                       DPSOAP    156
         LINE2(1:132)=' '                                               DPSOAP    157
         DO 111 I=1,ITMAX                                               DPSOAP    158
           IP=1                                                         DPSOAP    159
           DO 20 I2=2,KRECFD(1,1)+1                                     DPSOAP    160
           IF(I2.EQ.2)THEN                                              DPSOAP    161
             IF(I.LE.MAXPT(I2-1))THEN                                   DPSOAP    162
               WRITE(LINE2(IP:IP+20),1021)XARAY(I,I2-1),YARAY(I,I2-1)   DPSOAP    163
             ELSE                                                       DPSOAP    164
               WRITE(LINE2(IP:IP+20),'(A20)')'                    '     DPSOAP    165
             ENDIF                                                      DPSOAP    166
             IP=IP+20                                                   DPSOAP    167
           ELSE IF(ISAME(I2-1).EQ.ISAME(I2-2))THEN                      DPSOAP    168
             IF(I.LE.MAXPT(I2-1))THEN                                   DPSOAP    169
               WRITE(LINE2(IP:IP+10),1022)YARAY(I,I2-1)                 DPSOAP    170
             ELSE                                                       DPSOAP    171
               WRITE(LINE2(IP:IP+10),'(A10)')'          '               DPSOAP    172
             ENDIF                                                      DPSOAP    173
             IP=IP+10                                                   DPSOAP    174
           ELSE                                                         DPSOAP    175
             IF(I.LE.MAXPT(I2-1))THEN                                   DPSOAP    176
               WRITE(LINE2(IP:IP+20),1021)XARAY(I,I2-1),YARAY(I,I2-1)   DPSOAP    177
             ELSE                                                       DPSOAP    178
               WRITE(LINE2(IP:IP+20),'(A20)')'                    '     DPSOAP    179
             ENDIF                                                      DPSOAP    180
             IP=IP+20                                                   DPSOAP    181
           ENDIF                                                        DPSOAP    182
  20       CONTINUE                                                     DPSOAP    183
         WRITE(LOUT,'(132A1)')(LINE2(II:II),II=1,ISLEN(LINE2)+1)        DPSOAP    184
           IPAGE=IPAGE+1                                                DPSOAP    185
           IF(.NOT.PLAYBA) THEN                                         DPSOAP    186
              IF (IPAGE.GE.21) THEN                                     DPSOAP    187
                 IPAGE=0                                                DPSOAP    188
                 WRITE(LOUT,*)' '                                       DPSOAP    189
                 IF(QQ(LIN,LOUT).EQ.'Q')THEN                            DPSOAP    190
                  IF(RECORD)WRITE(IREC,2005)                            DPSOAP    191
 2005             FORMAT('Q')                                           DPSOAP    192
                  GOTO 112                                              DPSOAP    193
                 ENDIF                                                  DPSOAP    194
                 WRITE(LOUT,'(132A1)')(LINE(II:II),II=1,ISLEN(LINE)+1)  DPSOAP    195
              ENDIF                                                     DPSOAP    196
          ENDIF                                                         DPSOAP    197
  111   CONTINUE                                                        DPSOAP    198
  112   CONTINUE                                                        DPSOAP    199
        GOTO 9999                                                       DPSOAP    200
      ENDIF                                                             DPSOAP    201
 1021 FORMAT(2(1X,F9.4))                                                DPSOAP    202
 1022 FORMAT(1X,F9.4,1X)                                                DPSOAP    203
 1027 FORMAT('     TIME  ',I9)                                          DPSOAP    204
 1028 FORMAT(1X,I9)                                                     DPSOAP    205
C     ..............................................                    DPSOAP    206
C     : COMPLETED ALL CURVES ON ONE PLOTTING PAGE. :                    DPSOAP    207
C     : NOW PRINT IT OUT                           :                    DPSOAP    208
C     :............................................:                    DPSOAP    209
                                                                        DPSOAP    210
      IF (OP.EQ.'SHOWPLOT') THEN                                        DPSOAP    211
                                                                        DPSOAP    212
C       80 COLUMNS                                                      DPSOAP    213
          IF(IPR.EQ.0)THEN                                              DPSOAP    214
            CALL DPMAIN(4,2,-1,JPOUT,0,0)                               DPSOAP    215
C       132 COLUMNS                                                     DPSOAP    216
          ELSE                                                          DPSOAP    217
            CALL DPMAIN(4,2,0,JPOUT,0,0)                                DPSOAP    218
          ENDIF                                                         DPSOAP    219
                                                                        DPSOAP    220
         GOTO 9999                                                      DPSOAP    221
      ENDIF                                                             DPSOAP    222
                                                                        DPSOAP    223
 9999 CONTINUE                                                          DPSOAP    224
      RETURN                                                            DPSOAP    225
      END                                                               DPSOAP    226
                                                                        DPSOAP    227
        SUBROUTINE CHKSAM(ISAME)                                        DPSOAP    228
CD                                                                      DPSOAP    229
CD          THIS ROUTINE CHECKS FOR THE SAME VALUE IN THE XARAY ARRAY   DPSOAP    230
CD          FOR THE DIFFERENT CHANNELS                                  DPSOAP    231
CD                                                                      DPSOAP    232
CD          CALLING PARAMETERS :                                        DPSOAP    233
CD                                                                      DPSOAP    234
CD                      ISAME  : ARRAY FOR TOTAL NUMBER OF DIFFERENT    DPSOAP    235
CD                               POINTS IN THE CHANNELS                 DPSOAP    236
CD                                                                      DPSOAP    237
      INCLUDE 'PARAM.INS'                                               DPSOAP    238
      INCLUDE 'XYARAY.INS'                                              DPSOAP    239
        INTEGER ISAME(6)                                                DPSOAP    240
        IDIF=1                                                          DPSOAP    241
        ISAME(1)=1                                                      DPSOAP    242
        DO 20 I=1,KRECFD(1,1)-1                                         DPSOAP    243
          DO 10 J=1,MAXPT(I)                                            DPSOAP    244
            IF(XARAY(J,I).NE.XARAY(J,I+1))THEN                          DPSOAP    245
              IDIF=IDIF+1                                               DPSOAP    246
              ISAME(I+1)=IDIF                                           DPSOAP    247
              GOTO 20                                                   DPSOAP    248
            ENDIF                                                       DPSOAP    249
  10      CONTINUE                                                      DPSOAP    250
          ISAME(I+1)=ISAME(I)                                           DPSOAP    251
  20    CONTINUE                                                        DPSOAP    252
        RETURN                                                          DPSOAP    253
        END                                                             DPSOAP    254
