CFPRIME XSTEP                                                           XSTEP       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 XSTEP(T1,T2,DIV,TT1)                                 XSTEP       3
CD                                                                      XSTEP       4
CD            THIS ROUTINE COMPUTES THE NUMBER OF X-AXIS DIVISIONS      XSTEP       5
CD            AND STEP GIVEN T1,T2                                      XSTEP       6
CD                                                                      XSTEP       7
CD            CALLING PARAMETERS :                                      XSTEP       8
CD                                                                      XSTEP       9
CD                        T1,T2  - THE RANGE OF X-AXIS                  XSTEP      10
CD                        DIV    - NUMBER OF X DIVISIONS                XSTEP      11
CD                        TT1    - COMPUTED START OF X AXIS WHICH IS    XSTEP      12
CD                                 MULTIPLE OF STEP                     XSTEP      13
CD                                                                      XSTEP      14
        REAL T1,T2,DIV                                                  XSTEP      15
        REAL DIVMAX,DIVMIN,BSTEP(6)                                     XSTEP      16
        DIVMAX=10.0                                                     XSTEP      17
        DIVMIN=2.0                                                      XSTEP      18
        DATA BSTEP/1,2,5,.1,.2,.5/                                      XSTEP      19
C                                                                       XSTEP      20
        X=T2-T1                                                         XSTEP      21
  10    CONTINUE                                                        XSTEP      22
        IF(X.GE.10.0)THEN                                               XSTEP      23
          X=X/10.0                                                      XSTEP      24
          GOTO 10                                                       XSTEP      25
        ELSE IF(X.LT.1.0)THEN                                           XSTEP      26
          X=X*10.0                                                      XSTEP      27
          GOTO 10                                                       XSTEP      28
        ENDIF                                                           XSTEP      29
C       FIND THE MAXIMUM NUMBER OF XDIVISIONS                           XSTEP      30
        DIV=0                                                           XSTEP      31
        DO 100 K=1,6                                                    XSTEP      32
          TDIV=X/BSTEP(K)                                               XSTEP      33
          IF(ABS(TDIV-INT(TDIV)).LE.1.E-6)THEN                          XSTEP      34
            IF((TDIV.GE.DIVMIN).AND.(TDIV.LE.DIVMAX))THEN               XSTEP      35
              DIV=MAX(DIV,TDIV)                                         XSTEP      36
            ENDIF                                                       XSTEP      37
          ENDIF                                                         XSTEP      38
  100   CONTINUE                                                        XSTEP      39
C       USE THE MAXIMUM REAL # OF DIVISIONS                             XSTEP      40
        IF(ABS(DIV).LE.1.0E-6)THEN                                      XSTEP      41
          DO 200 K=1,6                                                  XSTEP      42
            TDIV=X/BSTEP(K)                                             XSTEP      43
            IF((TDIV.GE.DIVMIN).AND.(TDIV.LE.DIVMAX))THEN               XSTEP      44
              DIV=MAX(DIV,X/BSTEP(K))                                   XSTEP      45
            ENDIF                                                       XSTEP      46
  200     CONTINUE                                                      XSTEP      47
        ENDIF                                                           XSTEP      48
C       COMPUTE START OF X AXIS WHICH IS MULTIPLE OF STEP               XSTEP      49
        TT1=T1                                                          XSTEP      50
        STEP=(T2-T1)/DIV                                                XSTEP      51
        IF(ABS(T1/STEP-INT(T1/STEP)).GE.1.0E-6)THEN                     XSTEP      52
          TT1=NINT(T1/STEP+0.5)*STEP                                    XSTEP      53
        ENDIF                                                           XSTEP      54
        RETURN                                                          XSTEP      55
        END                                                             XSTEP      56
