CFPRIME YSCALE                                                          YSCALE      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 YSCALE(Y1,Y2,YY1,YY2)                                YSCALE      3
CD                                                                      YSCALE      4
CD             THIS ROUTINE COMPUTES THE NUMBER  OF Y-AXIS              YSCALE      5
CD             DIVISIONS AND STEP GIVEN T1,T2                           YSCALE      6
CD                                                                      YSCALE      7
CD             CALLING PARAMETERS :                                     YSCALE      8
CD                                                                      YSCALE      9
CD                       Y1,Y2    - RANGE OF THE Y-AXIS                 YSCALE     10
CD                       YY1      - STARTING VALUE OF THE Y-AXIS        YSCALE     11
CD                       YY2      - ENDING VALUE OF THE Y-AXIS          YSCALE     12
CD                                                                      YSCALE     13
        REAL Y1,Y2                                                      YSCALE     14
        INTEGER BSTEP(4)                                                YSCALE     15
        DATA BSTEP/1,2,5,10/                                            YSCALE     16
        NSTEP=5                                                         YSCALE     17
C                                                                       YSCALE     18
        Z=(Y2-Y1)/NSTEP                                                 YSCALE     19
                                                                        YSCALE     20
        IF((Y1.EQ.0.0).AND.(Y2.EQ.0.0))THEN                             YSCALE     21
          YY1=-2.0                                                      YSCALE     22
          YY2=3.0                                                       YSCALE     23
          RETURN                                                        YSCALE     24
        ELSE IF(Z.EQ.0.0)THEN                                           YSCALE     25
                                                                        YSCALE     26
          IEXPY=0                                                       YSCALE     27
          YT=Y1                                                         YSCALE     28
  20      CONTINUE                                                      YSCALE     29
          IF(ABS(YT).GE.10.0)THEN                                       YSCALE     30
            YT=YT/10.0                                                  YSCALE     31
            IEXPY=IEXPY+1                                               YSCALE     32
            GOTO 20                                                     YSCALE     33
          ELSE IF(ABS(YT).LT.1.0)THEN                                   YSCALE     34
            YT=YT*10.0                                                  YSCALE     35
            IEXPY=IEXPY-1                                               YSCALE     36
            GOTO 20                                                     YSCALE     37
          ENDIF                                                         YSCALE     38
          IF(Y1.LT.0.0)THEN                                             YSCALE     39
            YY2=0.0                                                     YSCALE     40
            YY1=-10.0**(IEXPY+1)                                        YSCALE     41
          ELSE                                                          YSCALE     42
            YY1=0.0                                                     YSCALE     43
            YY2=10.0**(IEXPY+1)                                         YSCALE     44
          ENDIF                                                         YSCALE     45
          RETURN                                                        YSCALE     46
        ENDIF                                                           YSCALE     47
                                                                        YSCALE     48
                                                                        YSCALE     49
        IEXP=0                                                          YSCALE     50
  30    CONTINUE                                                        YSCALE     51
        IF(Z.GE.10.0)THEN                                               YSCALE     52
          Z=Z/10.0                                                      YSCALE     53
          IEXP=IEXP+1                                                   YSCALE     54
          GOTO 30                                                       YSCALE     55
        ELSE IF(Z.LT.1.0)THEN                                           YSCALE     56
          Z=Z*10.0                                                      YSCALE     57
          IEXP=IEXP-1                                                   YSCALE     58
          GOTO 30                                                       YSCALE     59
        ENDIF                                                           YSCALE     60
C       TRUNCATE Z TO 4 DIGITS                                          YSCALE     61
        Z=INT(Z*10000)*10.0**(-4)                                       YSCALE     62
        IF(Z.LE.1.0)THEN                                                YSCALE     63
          ISTEP=1                                                       YSCALE     64
        ELSE IF(Z.LE.2.0)THEN                                           YSCALE     65
          ISTEP=2                                                       YSCALE     66
        ELSE IF(Z.LE.5.0)THEN                                           YSCALE     67
          ISTEP=3                                                       YSCALE     68
        ELSE                                                            YSCALE     69
          ISTEP=4                                                       YSCALE     70
        ENDIF                                                           YSCALE     71
  40    CONTINUE                                                        YSCALE     72
        STEP=BSTEP(ISTEP)*10.0**IEXP                                    YSCALE     73
        YY1=Y1                                                          YSCALE     74
C       TRUNCATE Y1/STEP TO 4 DIGITS                                    YSCALE     75
        YT=Y1/STEP                                                      YSCALE     76
        IF(YT.EQ.0.0)GOTO 60                                            YSCALE     77
        IEXPT=0                                                         YSCALE     78
  50    CONTINUE                                                        YSCALE     79
        IF(ABS(YT).GE.10.0)THEN                                         YSCALE     80
          YT=YT/10.0                                                    YSCALE     81
          IEXPT=IEXPT+1                                                 YSCALE     82
          GOTO 50                                                       YSCALE     83
        ELSE IF(ABS(YT).LT.1.0)THEN                                     YSCALE     84
          YT=YT*10.0                                                    YSCALE     85
          IEXPT=IEXPT-1                                                 YSCALE     86
          GOTO 50                                                       YSCALE     87
        ENDIF                                                           YSCALE     88
        YT=INT(YT*10000)*10.0**(IEXPT-4)                                YSCALE     89
  60    CONTINUE                                                        YSCALE     90
        IF(YT-NINT(YT).NE.0.0)THEN                                      YSCALE     91
          YY1=NINT(YT-0.5)*STEP                                         YSCALE     92
        ENDIF                                                           YSCALE     93
        YY2=YY1+5*STEP                                                  YSCALE     94
        IF((YY1.GT.Y1).OR.(YY2.LT.Y2))THEN                              YSCALE     95
          ISTEP=ISTEP+1                                                 YSCALE     96
          IF(ISTEP.EQ.5)THEN                                            YSCALE     97
            ISTEP=2                                                     YSCALE     98
            IEXP=IEXP+1                                                 YSCALE     99
          ENDIF                                                         YSCALE    100
          GOTO 40                                                       YSCALE    101
        ENDIF                                                           YSCALE    102
        RETURN                                                          YSCALE    103
        END                                                             YSCALE    104
