    	SUBROUTINE IFAXIS( ITY, XLN, YLN, TXT, FST, DEL,
     +                     DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: 	RONG-SHENG ZHOU
C		ALFRED UNIVERSITY, 8/1986
C
C	THIS ROUTINE DRAWS AN AXIS AT ACTIVE GRAPH ORIGIN.
C
C	ITY --- AXIS TYPE:
C
C		1: LINEAR X-AXIS.
C		2: INVERSE-LINEAR X-AXIS.
C		3: LOG10 X-AXIS.
C		4: LINEAR Y-AXIS.
C		5: INVERSE-LINEAR Y-AXIS.
C		6: LOG10 Y-AXIS.
C
    	CHARACTER TXT*(*)

    	IF( ITY.EQ.1 ) THEN
     	    CALL IFAXIS_X1( XLN, YLN, TXT, FST, DEL,
     +                      DST, NTK, MTK, NDG, IGD )
     	ELSE IF( ITY.EQ.2 ) THEN
     	    CALL IFAXIS_X2( XLN, YLN, TXT, FST, DEL,
     +                      DST, NTK, MTK, NDG, IGD )
     	ELSE IF( ITY.EQ.3 ) THEN
     	    CALL IFAXIS_X3( XLN, YLN, TXT, FST, DEL,
     +                      DST, NTK, MTK, NDG, IGD )
     	ELSE IF( ITY.EQ.4 ) THEN
     	    CALL IFAXIS_Y1( XLN, YLN, TXT, FST, DEL,
     +                      DST, NTK, MTK, NDG, IGD )
     	ELSE IF( ITY.EQ.5 ) THEN
     	    CALL IFAXIS_Y2( XLN, YLN, TXT, FST, DEL,
     +                      DST, NTK, MTK, NDG, IGD )
     	ELSE IF( ITY.EQ.6 ) THEN
     	    CALL IFAXIS_Y3( XLN, YLN, TXT, FST, DEL,
     +                      DST, NTK, MTK, NDG, IGD )
     	ENDIF
     	RETURN
 	END

    	SUBROUTINE IFAXIS_X1( XLN, YLN, TXT, FST, DEL,
     +                        DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: R.S. ZHOU,		ALFRED UNIVERSITY
C
C	THIS ROUTINE DRAWS A LINEAR X-AXIS AT ACTIVE GRAPH ORIGIN.
C
C	XLN --- X-AXIS LENGTH IN CURRENT UNITS.
C		IF XLN<0.0, AXIS ANNOTATION IS ABOVE THE AXIS.
C	YLN --- Y-AXIS LENGTH IN CURRENT UNITS.
C	TXT --- AXIS TITLE IN CHARACTER FORMAT.
C		IF TXT(1)="!", TITLE IS NOT CENTERED ON AXIS.
C	FST --- SCALE VALUE AT THE FIRST MAJOR TICKMARK.
C	DEL --- CHANGE IN SCALE UNITS BETWEEN MAJOR TICKMARKS.
C	DST --- DISTANCE OF FIRST TICKMARK AWAY FROM ORIGIN.
C 	NTK --- NUMBER OF DIVISIONS ON THE AXIS.
C 	MTK --- NUMBER OF MINOR TICKMARKS ON THE AXIS.
C		IF MTK<0, TICKMARKS TO THE SAME SIDE OF ANNOTATIONS.
C	NDG --- NUMBER OF SIGNIFICANT DIGITS FOR SCALE NUMBERS.
C		0 = ROUTINE DETERMINED, 9=NO ANNOTATION.
C		0<= SKIP DRAWING THE MULTIPLIER.
C	IGD --- AXIS PATTERN CODE:
C		1: DRAW THE AXIS WITH MAJOR AND MINOR TICKS.
C		2: DRAW THE AXIS WITH MAJOR TICK ONLY.
C		3: DRAW THE AXIS WITH GRID LINES ON MAJOR TICKS.
C		4: DRAW THE AXIS WITH GRID LINES ON MINOR TICKS AS WELL.
C	MINUS IGD: DRAW THE AXIS WITH ARROWHEAD.
C	 DUAL IGD: DRAW THE OPPOSITE AXIS OF THE SAME PATTERN.
C
     	INCLUDE 'TEKLIB.CBS'
    	CHARACTER TXT*(*)
     	LOGICAL   PAIR
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C ) RETURN
    	XLEN = ABS(XLN)
    	IGRD = IABS(IGD)
    	PAIR = .FALSE.
    	IF( IGRD.GT.10 ) THEN
    	    IGRD = MOD( IGRD, 10 )
    	    IF( IGRD.LT.1 ) IGRD = 1
    	    PAIR = .TRUE.
    	ENDIF
    	DIST = DST
    	FIRST= FST
    	DELL = DEL
    	NTIK = IABS(NTK)+1
    	MTIK = IABS(MTK)
    	XAD  = (XLEN-2.0*DIST)/ (NTIK-1)
    	IEX  = 0
     	CALL IFAXIS_DIGITS( NDG, NTIK, FIRST, DELL,
     +                      NDIGIT, IEX, XVL, ADX )
    	IF( IABS(NDG).EQ.9 ) GOTO 222
C
C  PUT ON THE SCALE NUMBERS...
C
     	YM = -0.25
    	IF( XLN.LT.0.0 ) YM = 0.125
     	SIZE = 0.1
    	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
C
C  DETERMINE THE LENGTH OF XVL...
C
    	   IF( ABS(XVL).GE.1.0 ) THEN
    	       NDT = LOG10(ABS(XVL))
    	       NDT = NDT + 1
    	   ELSE
    	       NDT = 1
    	   ENDIF
    	   IF( NDIGIT.GT.0 ) NDT = NDT + NDIGIT + 1
    	   IF( XVL.LT.0.0 ) NDT = NDT + 1
    	   XN = DIST - 0.5*SIZE*NDT + XAD*(I-1)
     	   CALL IFTEXT_FPN( XN, YM, SIZE, XVL, 0.0, NDIGIT )
    	   XVL = XVL + ADX
    	ENDDO
C
C  DRAW TICKMARKS OR GRID LINES...
C
  222	IF( IGRD.LT.4 ) THEN
     	    DYB = 0.08
    	    IF( MTK.LT.0 ) DYB = -0.08
    	    IF( XLN.LT.0.0 ) DYB = -DYB
     	    IF( IGRD.EQ.2 ) THEN
     		MTIK = 0
     	    ELSE
     		DYC = 0.65*DYB
     	    ENDIF
     	ENDIF
     	IF( IGRD.GT.2 ) THEN
     	    DYB = YLN
    	    IF( IGRD.EQ.4 ) DYC = YLN
    	ENDIF
     	XD = XAD
    	IF( MTIK.GT.0 ) XD = XAD / (MTIK+1)
     	XD = -XD
     	XN = XLEN-DIST
    	IF( MTIK.GT.0 .AND. DIST.GT.0.1 ) THEN
    	    NTIK = NTIK + 2
    	    XN = XN+XAD
    	ENDIF
     	XB = -0.005
     	XE = XLEN+0.005
     	YM = 0.0
     	IF( IGRD.EQ.4 ) CALL IFSTYL(2,0)
333	ADX = XN
     	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
     	    IF( ADX.LT.XB ) GOTO 444
     	    IF( ADX.LT.XE ) THEN
     		IF( IGRD.EQ.3 ) CALL IFSTYL(2,0)
     		CALL IFPLOT (ADX,YM,3)
     		CALL IFPLOT (ADX,DYB,2)
     		IF( IGRD.EQ.3 ) CALL IFSTYL(1,0)
     	    ENDIF
     	    DO  K=1, MTIK
     		ADX = ADX + XD
     		IF( ADX.LT.XB ) GOTO 444
     		IF( ADX.LT.XE ) THEN
     		    CALL IFPLOT (ADX,YM,3)
     		    CALL IFPLOT (ADX,DYC,2)
     		ENDIF
     	    ENDDO
     	    ADX = ADX + XD
     	ENDDO
444	IF( IGRD.EQ.4 ) CALL IFSTYL(1,0)
     	CALL IFPLOT (0.0,YM,3)
    	CALL IFPLOT (XLEN,YM,2)
     	IF(IGD.LT.0.AND.DELL.GT.0.0) CALL IFARRH( 1, XLEN+0.25,
     +  YM, 0.25, 0.04, 0.15, 0.0 )
    	IF( .NOT.PAIR ) GOTO 555
C
C  DRAW THE OPPOSITE AXIS...
C
     	YM = YLN
     	PAIR = .FALSE.
     	IF( IGRD.EQ.4 ) GOTO 444
     	IF( IGRD.EQ.3 ) DYB = 0.0
     	DYB = YLN - DYB
     	DYC = YLN - DYC
     	GOTO 333
C
C  DRAW THE TITLE AND MAGNITUDE INDICATOR...
C
555	CALL IFAXIS_XLABEL(TXT,XLN,NDG,IEX)
     	RETURN
     	END

    	SUBROUTINE IFAXIS_X2( XLN, YLN, TXT, FST, DEL,
     +                        DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: R.S. ZHOU,		ALFRED UNIVERSITY
C
C     THIS ROUTINE DRAWS A LOG10 X-AXIS AT ACTIVE GRAPH ORIGIN.
C
C	XLN --- X-AXIS LENGTH IN CURRENT UNITS.
C		IF XLN<0.0, AXIS ANNOTATION IS ABOVE THE AXIS.
C	YLN --- Y-AXIS LENGTH IN CURRENT UNITS.
C	TXT --- AXIS TITLE IN CHARACTER FORMAT.
C		IF TXT(1)="!", TITLE IS NOT CENTERED ON AXIS.
C	FST --- SCALE VALUE AT THE FIRST MAJOR TICKMARK.
C 	DEL --- LOG CYCLES ON THE AXIS = MAJOR TICKMARK - 1.
C	DST --- DISTANCE OF FIRST TICKMARK AWAY FROM ORIGIN.
C 	NTK --- NUMBER OF DIVISIONS ON THE AXIS (NOT USED).
C 	MTK --- NUMBER OF MINOR TICKMARKS ON THE AXIS (NOT USED).
C		IF MTK<0, TICKMARKS TO THE SAME SIDE OF ANNOTATIONS.
C	NDG --- NUMBER OF SIGNIFICANT DIGITS FOR SCALE NUMBERS.
C		9=SKIP DRAWING THE SCALE UNMBERS.
C
C	IGD --- AXIS PATTERN CODE:
C
C		1: DRAW THE AXIS WITH MAJOR AND MINOR SCALE NUMBERS.
C		2: DRAW THE AXIS WITH MAJOR SCALE NUMBERS ONLY.
C		3: DRAW THE AXIS WITH GRID LINES ON MAJOR TICKS.
C		4: DRAW THE AXIS WITH GRID LINES ON MINOR TICKS AS WELL.
C	 DUAL IGD: DRAW THE OPPOSITE AXIS OF THE SAME PATTERN.
C	
     	INCLUDE		'TEKLIB.CBS'
    	CHARACTER	TXT*(*)
    	DIMENSION	BLOG(9)
     	LOGICAL		PAIR
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C ) RETURN
    	XLEN = ABS(XLN)
    	IGRD = IABS(IGD)
    	PAIR = .FALSE.
    	IF( IGRD.GT.10 ) THEN
    	    IGRD = IGRD / 10
    	    IF( IGRD.LT.1 ) IGRD = 1
    	    PAIR = .TRUE.
    	ENDIF
    	FIRST = LOG10(FST)
    	SIGN  = 1.0
    	DELL  = DEL
    	DIST  = DST
    	XDD   = 0.05
    	XXD   = 0.02
    	IF( DELL.LT.0.0 ) THEN
    	    FIRST= FIRST + DELL
    	    XDD  = 0.15
    	    XXD  = 0.12
    	ENDIF
    	NTIC = ABS(DELL) + 1.0
C
C  STORE LOG10S OF INTEGERS 1-9...
C
    	DO I=1,9
    	   BLOG(I) = LOG10(FLOAT(I))
    	ENDDO
C
C  DETERMINE THE DELTA VALUE OF LOG10 CYCLES PER INCH...
C
    	DELTA = DELL / (XLEN-2.0*DIST)
    	DELL  = ABS(DELTA)
    	IF( DELL.GT.0.5 ) THEN
    	    XDD = 0.125
    	    XXD = 0.095
    	ENDIF
C
C  IF CYCLE LENGTH < 1.0 INCH, REDUCE THE NUMBER OF MAJOR TICKS...
C
    	IC = INT( 0.5*DELL ) + 1
C
C  PUT ON THE SCALING NUMBERS...
C
    	IF( IGRD.EQ.2 ) THEN
    	    ITC = 1
    	ELSE
    	    IF( DELL.LE.0.25 ) ITC = 9
    	    IF( DELL.GT.0.25 ) ITC = 9-INT((DELL-0.25)/0.1)
    	    IF( ITC.LT.1 ) ITC = 1
    	ENDIF
    	YAD = -0.25
    	YM  = 0.075
    	IF( XLN.LT.0.0 ) THEN
    	    YM = -0.025
    	    YAD = 0.125
    	ENDIF
    	XN = DIST
     	IF( DELTA.LT.0.0 ) XN = XLEN-DIST
    	IF( IGRD.NE.2 .AND. DIST.GT.0.1 ) THEN
    	    NTIC = NTIC + 2
    	    FIRST= FIRST-1.0
    	    XN = XN - 1.0/DELTA
    	ENDIF
     	XB = -0.005
     	XE = XLEN+0.005
   	IF( IABS(NDG).EQ.9 ) GOTO 222
     	SIZE = 0.1
     	SEXT = 0.06
    	DO MJ = 1, NTIC, IC
     	IF( CTRL_C ) RETURN
    	    FMJ = MJ - 1
    	    EX  = FIRST + FMJ
    	    DO  MI = 1, ITC
     		XAD = XN + (BLOG(MI)+FMJ)/DELTA
     		IF( XAD.GT.XB .AND. XAD.LT.XE ) THEN
     		    XAD = XAD - XDD
     		    IF( MI.EQ.1 ) THEN
     	CALL IFTEXT( XAD, YAD, '10', SIZE, SIZE, 0.0 )
     	CALL IFTEXT_FPN( XAD+2*SIZE, YAD+0.8*SIZE, SEXT, EX, 0.0, -1 )
     		    ELSE
     	CALL IFTEXT_FPN( XAD+XXD, YAD+YM, SEXT, FLOAT(MI), 0.0, -1 )
     		    ENDIF
     		ENDIF
     	    ENDDO
     	ENDDO
C
C  DRAW THE TICKMARKS ON THE AXIS...
C
  222	ITC = 9
    	IF( IC.GT.1 ) ITC = 1
     	DYB = 0.08
    	IF( MTK.LT.0.0 ) DYB = -0.08
    	IF( XLN.LT.0.0 ) DYB = -DYB
    	DYC = 0.65*DYB
    	IF( IGRD.GT.2 ) DYB = YLN
    	IF( IGRD.EQ.4 ) DYC = YLN
     	YM = 0.0
     	IF( IGRD.EQ.4 ) CALL IFSTYL(2,0)
  333	DO MJ= 1, NTIC
     	IF( CTRL_C ) RETURN
    	    FMJ = MJ - 1
    	    DO  MI= 1, ITC
     		XAD = XN + (BLOG(MI)+FMJ)/DELTA
     		IF( XAD.GT.XB .AND. XAD.LT.XE ) THEN
     		    IF( MI.EQ.1 ) THEN
     			IF( IGRD.EQ.3 ) CALL IFSTYL(2,0)
     			CALL IFPLOT (XAD,YM,3)
     			CALL IFPLOT (XAD,DYB,2)
     			IF( IGRD.EQ.3 ) CALL IFSTYL(1,0)
     		    ELSE IF( DELL.LT.2.0 ) THEN
     			CALL IFPLOT (XAD,YM,3)
     			CALL IFPLOT (XAD,DYC,2)
     		    ENDIF
     		ENDIF
     	    ENDDO
     	ENDDO
444	IF( IGRD.EQ.4 ) CALL IFSTYL(1,0)
     	IF(IGD.LT.0.AND.DELTA.GT.0.0) CALL IFARRH( 1, XLEN+0.25,
     +  YM, 0.25, 0.04, 0.15, 0.0 )
    	CALL IFPLOT (XLEN,YM,3)
    	CALL IFPLOT (0.0,YM,2)
    	IF( .NOT.PAIR ) GOTO 555
C
C  DRAW THE OPPOSITE AXIS...
C
     	YM = YLN
     	PAIR = .FALSE.
    	IF( IGRD.EQ.4 ) GOTO 444
    	IF( IGRD.EQ.3 ) DYB = 0.0
     	DYB = YLN-DYB
     	DYC = YLN-DYC
     	GOTO 333
C
C  DRAW THE AXIS TITLE IF AT ALL...
C
555	CALL IFAXIS_XLABEL(TXT,XLN,NDG,0)
     	RETURN
    	END

    	SUBROUTINE IFAXIS_X3( XLN, YLN, TXT, FST, DEL,
     +                        DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: R.S. ZHOU,		ALFRED UNIVERSITY
C
C	THIS ROUTINE DRAWS AN INVERSE-LINEAR X-AXIS AT ACTIVE GRAPH ORIGIN.
C
C	XLN --- X-AXIS LENGTH IN CURRENT UNITS.
C		IF XLN<0.0, AXIS ANNOTATION IS ABOVE THE AXIS.
C	YLN --- Y-AXIS LENGTH IN CURRENT UNITS.
C	TXT --- AXIS TITLE IN CHARACTER FORMAT.
C		IF TXT(1)="!", TITLE IS NOT CENTERED ON AXIS.
C	FST --- SCALE VALUE AT THE FIRST MAJOR TICKMARK.
C	DEL --- CHANGE IN SCALE UNITS BETWEEN MAJOR TICKMARKS.
C	DST --- DISTANCE OF FIRST TICKMARK AWAY FROM ORIGIN.
C 	NTK --- NUMBER OF DIVISIONS ON THE AXIS.
C 	MTK --- NUMBER OF MINOR TICKMARKS ON THE AXIS.
C		IF MTK<0, TICKMARKS TO THE SAME SIDE OF ANNOTATIONS.
C	NDG --- NUMBER OF SIGNIFICANT DIGITS FOR SCALE NUMBERS.
C		0 = ROUTINE DETERMINED, 9=NO ANNOTATION.
C		0<= SKIP DRAWING THE MULTIPLIER.
C	IGD --- AXIS PATTERN CODE:
C		1: DRAW THE AXIS WITH MAJOR AND MINOR TICKS.
C		2: DRAW THE AXIS WITH MAJOR TICK ONLY.
C		3: DRAW THE AXIS WITH GRID LINES ON MAJOR TICKS.
C		4: DRAW THE AXIS WITH GRID LINES ON MINOR TICKS AS WELL.
C	MINUS IGD: DRAW THE AXIS WITH ARROWHEAD.
C	 DUAL IGD: DRAW THE OPPOSITE AXIS OF THE SAME PATTERN.
C	
     	INCLUDE		'TEKLIB.CBS'
    	CHARACTER	TXT*(*)
     	LOGICAL		PAIR
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C ) RETURN
    	XLEN = ABS(XLN)
    	IGRD = IABS(IGD)
    	PAIR = .FALSE.
    	IF( IGRD.GT.10 ) THEN
    	    IGRD = MOD( IGRD, 10 )
    	    IF( IGRD.LT.1 ) IGRD = 1
    	    PAIR = .TRUE.
    	ENDIF
    	DIST = DST
    	FIRST= FST
    	DELL = DEL
    	NTIK = IABS(NTK)+1
    	MTIK = IABS(MTK)
C
C  DETERMINE THE LENGTH OF SCALING NUMBERS...
C
    	IEX  = 0
     	CALL IFAXIS_DIGITS( NDG, NTIK, FIRST, DELL,
     +                      NDIGIT, IEX, XVL, ADX )
     	XAD = XVL + (NTIK-1)*ADX
    	XAD = (1.0/XAD-1.0/XVL)/(XLEN-2.0*DIST)
    	IF( IABS(NDG).EQ.9 ) GOTO 222
C
C  PUT ON THE SCALE NUMBERS...
C
     	YM = -0.25
    	IF( XLN.LT.0.0 ) YM = 0.125
     	XVV = XVL
    	XDA = 1.0/XVL
     	SIZE = 0.1
    	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
C
C  DETERMINE THE LENGTH OF XVL...
C
    	   IF( ABS(XVV).GE.1.0 ) THEN
    	       NDT = LOG10(ABS(XVV))
    	       NDT = NDT + 1
    	   ELSE
    	       NDT = 1
    	   ENDIF
    	   IF( NDIGIT.GT.0 ) NDT = NDT + NDIGIT + 1
    	   IF( XVV.LT.0.0 ) NDT = NDT + 1
    	   XN = DIST-0.5*SIZE*NDT+(1.0/XVV-XDA)/XAD
     	   CALL IFTEXT_FPN( XN, YM, SIZE, XVV, 0.0, NDIGIT )
    	   XVV = XVV + ADX
    	ENDDO
C
C  DRAW THE TICKMARKS OR GRID LINES...
C
  222	IF( IGRD.LT.4 ) THEN
     	    DYB = 0.08
    	    IF( MTK.LT.0 ) DYB = -0.08
    	    IF( XLN.LT.0.0 ) DYB = -DYB
     	    IF( IGRD.EQ.2 ) THEN
     		MTIK = 0
     	    ELSE
     		DYC = 0.65*DYB
     	    ENDIF
     	ENDIF
     	IF( IGRD.GT.2 ) THEN
     	    DYB = YLN
    	    IF( IGRD.EQ.4 ) DYC = YLN
    	ENDIF
     	XDA = ADX
    	IF( MTIK.GT.0 ) XDA = ADX / (MTIK+1)
     	XN = DIST
     	XB = -0.005
     	XE = XLEN+0.005
     	YM = 0.0
     	IF( IGRD.EQ.4 ) CALL IFSTYL(2,0)
333	XVV = XVL
    	XV1 = 1.0/XVL
     	ADX = XN
    	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
     	    IF( ADX.GT.XE ) GOTO 444
    	    IF( ADX.GT.XB ) THEN
     		IF( IGRD.EQ.3 ) CALL IFSTYL(2,0)
     		CALL IFPLOT (ADX,YM,3)
     		CALL IFPLOT (ADX,DYB,2)
     		IF( IGRD.EQ.3 ) CALL IFSTYL(1,0)
     	    ENDIF
     	    DO  K=1, MTIK
     		XVV = XVV + XDA
     		ADX = XN + (1.0/XVV-XV1)/XAD
     		IF( ADX.GT.XE ) GOTO 444
     		IF( ADX.GT.XB ) THEN
     		    CALL IFPLOT (ADX,YM,3)
     		    CALL IFPLOT (ADX,DYC,2)
     		ENDIF
     	    ENDDO
     	    XVV = XVV + XDA
     	    ADX = XN + (1.0/XVV-XV1)/XAD
     	ENDDO

444	IF( IGRD.EQ.4 ) CALL IFSTYL(1,0)
     	CALL IFPLOT (0.0,YM,3)
    	CALL IFPLOT (XLEN,YM,2)
     	IF(IGD.LT.0.AND.DELL.GT.0.0) CALL IFARRH( 1, XLEN+0.25,
     +  YM, 0.25, 0.04, 0.15, 0.0 )
    	IF( .NOT.PAIR ) GOTO 555
C
C  DRAW THE OPPOSITE AXIS...
C
     	YM = YLN
     	PAIR = .FALSE.
    	IF( IGRD.EQ.4 ) GOTO 444
     	IF( IGRD.EQ.3 ) DYB = 0.0
     	DYB = YLN-DYB
     	DYC = YLN-DYC
     	GOTO 333
C
C  DRAW THE TITLE AND MAGNITUDE INDICATOR...
C
555	CALL IFAXIS_XLABEL(TXT,XLN,NDG,IEX)

     	RETURN
    	END

     	SUBROUTINE IFAXIS_Y1( XLN, YLN, TXT, FST, DEL,
     +                        DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: R.S. ZHOU,		ALFRED UNIVERSITY
C
C	THIS ROUTINE DRAWS A LINEAR Y-AXIS AT ACTIVE GRAPH ORIGIN.
C
C	XLN --- X-AXIS LENGTH IN INCHES.
C	YLN --- Y-AXIS LENGTH IN INCHES.
C		IF YLN<0.0, AXIS ANNOTATION IS TO THE RIGHT OF AXIS.
C	TXT --- AXIS TITLE IN CHARACTER FORMAT.
C		IF TXT(1)="!", TITLE IS NOT CENTERED ON AXIS.
C		IF TXT(1)="^", TITLE IS PLACED ON TOP OF AXIS.
C	FST --- SCALE VALUE AT THE FIRST MAJOR TICKMARK.
C	DEL --- CHANGE IN SCALE UNITS BETWEEN MAJOR TICKMARKS.
C	DST --- DISTANCE OF FIRST TICKMARK AWAY FROM ORIGIN.
C 	NTK --- NUMBER OF DIVISIONS ON THE AXIS.
C 	MTK --- NUMBER OF MINOR TICKMARKS ON THE AXIS.
C		IF MTK<0, TICKMARKS TO THE SAME SIDE OF ANNOTATIONS.
C	NDG --- NUMBER OF SIGNIFICANT DIGITS FOR SCALE NUMBERS.
C		0 = ROUTINE DETERMINED, 9=NO ANNOTATION.
C		0<= SKIP DRAWING THE MULTIPLIER.
C	IGD --- AXIS PATTERN CODE:
C		1: DRAW THE AXIS WITH MAJOR AND MINOR TICKS.
C		2: DRAW THE AXIS WITH MAJOR TICK ONLY.
C		3: DRAW THE AXIS WITH GRID LINES ON MAJOR TICKS.
C		4: DRAW THE AXIS WITH GRID LINES ON MINOR TICKS AS WELL.
C	MINUS IGD: DRAW THE AXIS WITH ARROWHEAD.
C	 DUAL IGD: DRAW THE OPPOSITE AXIS OF THE SAME PATTERN.
C	
     	INCLUDE		'TEKLIB.CBS'
    	CHARACTER	TXT*(*)
     	LOGICAL		PAIR
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C ) RETURN
    	YLEN = ABS(YLN)
    	IGRD = IABS(IGD)
    	PAIR = .FALSE.
    	IF( IGRD.GT.10 ) THEN
    	    IGRD = MOD( IGRD, 10 )
    	    IF( IGRD.LT.1 ) IGRD = 1
    	    PAIR = .TRUE.
    	ENDIF
    	FIRST= FST
    	DELL = DEL
    	DIST = DST
    	NTIK = IABS(NTK)+1
    	MTIK = IABS(MTK)
    	YAD  = (YLEN-2.0*DIST) / (NTIK-1)
C
C  DETERMINE THE LENGTH OF SCALING NUMBERS...
C
    	IEX  = 0
     	CALL IFAXIS_DIGITS( IABS(NDG), NTIK, FIRST, DELL,
     +                      NDIGIT, IEX, YVL, ADY )
    	NMAX = 0
    	IF( IABS(NDG).EQ.9 ) GOTO 222
C
C  PUT ON THE SCALE NUMBERS...
C
     	SIZE= 0.1
     	YN  = DIST-0.5*SIZE
    	XM  = 0.125
    	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
C
C  DETERMINE THE LENGTH OF YVL...
C
    	   IF( ABS(YVL).GE.1.0 ) THEN
    	       NDT = LOG10(ABS(YVL))
    	       NDT = NDT + 1
    	   ELSE
    	       NDT = 1
    	   ENDIF
    	   IF( NDIGIT.GT.0 ) NDT  = NDT + NDIGIT + 1
    	   IF(  YVL.LT.0.0 ) NDT  = NDT + 1
    	   IF( NDT.GT.NMAX ) NMAX = NDT
    	   IF( YLN.GT.0.0 ) XM = -SIZE*(NDT+1)
    	   YYD = 0.0
     	   IF( DIST.EQ.0.0 ) THEN
    	       IF( I.EQ.NTIK ) YYD = -0.05
    	       IF( I.EQ. 1   ) YYD =  0.05
     	   ENDIF
     	   CALL IFTEXT_FPN( XM, YN+YYD, SIZE, YVL, 0.0, NDIGIT )
    	   YVL = YVL + ADY
    	   YN  = YN  + YAD
    	ENDDO
C
C  DRAW THE TICK MARKS OR GRID LINES...
C
  222	IF( IGRD.LT.4 ) THEN
     	    DYB = 0.08
    	    IF( MTK.LT.0 ) DYB = -0.08
    	    IF( YLN.LT.0.0 ) DYB = -DYB
     	    IF( IGRD.EQ.2 ) THEN
     		MTIK = 0
     	    ELSE
     		DYC = 0.65*DYB
     	    ENDIF
     	ENDIF
     	IF( IGRD.GT.2 ) THEN
     	    DYB = XLN
    	    IF( IGRD.EQ.4 ) DYC = XLN
    	ENDIF
     	YYD = YAD
    	IF( MTIK.GT.0 ) YYD = YAD / (MTIK+1)
     	YYD = -YYD
     	YN = YLEN-DIST
    	IF( MTIK.GT.0 .AND. DIST.GT.0.1 ) THEN
    	    NTIK = NTIK + 2
    	    YN = YN + YAD
    	ENDIF
     	YB = -0.005
     	YE = YLEN+0.005
     	XM = 0.0
     	IF( IGRD.EQ.4 ) CALL IFSTYL(2,0)
333	ADY = YN
     	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
     	    IF( ADY.LT.YB ) GOTO 444
     	    IF( ADY.LT.YE ) THEN
     		IF( IGRD.EQ.3 ) CALL IFSTYL(2,0)
     		CALL IFPLOT (XM,ADY,3)
     		CALL IFPLOT (DYB,ADY,2)
     		IF( IGRD.EQ.3 ) CALL IFSTYL(1,0)
     	    ENDIF
     	    DO  K=1, MTIK
     		ADY = ADY + YYD
     		IF( ADY.LT.YB ) GOTO 444
     		IF( ADY.LT.YE ) THEN
     		    CALL IFPLOT (XM,ADY,3)
     		    CALL IFPLOT (DYC,ADY,2)
     		ENDIF
     	    ENDDO
     	    ADY = ADY + YYD
     	ENDDO
444	IF( IGRD.EQ.4 ) CALL IFSTYL(1,0)
     	CALL IFPLOT (XM,0.0,3)
    	CALL IFPLOT (XM,YLEN,2)
     	IF(IGD.LT.0.AND.DELL.GT.0.0) CALL IFARRH( 1, XM,
     +  YLEN+0.25, 0.25, 0.04, 0.15, 90.0 )
    	IF( .NOT.PAIR ) GOTO 555
C
C  DRAW THE OPPOSITE AXIS...
C
     	XM = XLN
     	PAIR = .FALSE.
     	IF( IGRD.EQ.4 ) GOTO 444
     	IF( IGRD.EQ.3 ) DYB = 0.0
     	DYB = XLN - DYB
     	DYC = XLN - DYC
     	GOTO 333
C
C  DRAW THE TITLE AND MAGNITUDE INDICATOR...
C
  555	CALL IFAXIS_YLABEL(TXT,YLN,NDG,IEX,NMAX)
     	RETURN
    	END

     	SUBROUTINE IFAXIS_Y2( XLN, YLN, TXT, FST, DEL,
     +                        DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: R.S. ZHOU,		ALFRED UNIVERSITY
C
C	THIS ROUTINE DRAWS A LOG10 Y-AXIS AT THE CURRENT GRAPH ORIGIN
C
C	XLN --- X-AXIS LENGTH IN CURRENT UNITS.
C	YLN --- Y-AXIS LENGTH IN CURRENT UNITS.
C		IF YLN<0.0, AXIS ANNOTATION IS TO THE RIGHT OF AXIS.
C	TXT --- AXIS TITLE IN CHARACTER FORMAT.
C		IF TXT(1)="!", TITLE IS NOT CENTERED ON AXIS (LITERAL).
C		IF TXT(1)="^", TITLE IS PLACED ON TOP OF AXIS (HORIZONTAL).
C	FST --- SCALE VALUE AT THE FIRST MAJOR TICKMARK.
C 	DEL --- LOG CYCLES ON THE AXIS = MAJOR TICKMARK - 1.
C	DST --- DISTANCE OF FIRST TICKMARK AWAY FROM ORIGIN.
C 	NTK --- NUMBER OF DIVISIONS ON THE AXIS.
C 	MTK --- NUMBER OF MINOR TICKMARKS ON THE AXIS (NOT USED).
C		IF MTK<0, TICKMARKS TO THE SAME SIDE OF ANNOTATIONS.
C	NDG --- NUMBER OF SIGNIFICANT DIGITS FOR SCALE NUMBERS.
C		9=SKIP DRAWING THE SCALE NUMBERS.
C	IGD --- AXIS PATTERN CODE:
C		1: DRAW THE AXIS WITH MAJOR AND MINOR SCALE NUMBERS.
C		2: DRAW THE AXIS WITH MAJOR SCALE NUMBERS ONLY.
C		3: DRAW THE AXIS WITH GRID LINES ON MAJOR TICKS.
C		4: DRAW THE AXIS WITH GRID LINES ON MINOR TICKS AS WELL.
C	 DUAL IGD: DRAW THE OPPOSITE AXIS OF THE SAME PATTERN.
C	
     	INCLUDE 	'TEKLIB.CBS'
    	CHARACTER	TXT*(*)
    	DIMENSION	BLOG(9)
     	LOGICAL		PAIR
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C ) RETURN
    	YLEN = ABS(YLN)
    	IGRD = IABS(IGD)
    	PAIR = .FALSE.
    	IF( IGRD.GT.10 ) THEN
    	    IGRD = MOD( IGRD, 10 )
    	    IF( IGRD.LT.1 ) IGRD = 1
    	    PAIR = .TRUE.
    	ENDIF
    	FIRST = LOG10(FST)
    	DELL  = DEL
    	DIST  = DST
    	IF( DELL.LT.0.0 ) FIRST = FIRST + DELL
    	NTIC = ABS(DELL) + 1.0
C
C  STORE LOG10S OF INTEGERS 1-9...
C
    	DO I=1, 9
    	   BLOG(I) = LOG10(FLOAT(I))
    	ENDDO
C
C  DETERMINE THE DELTA VALUE OF LOG10 CYCLES PER INCH...
C
    	DELTA = DELL / (YLEN-2.0*DIST)
    	DELL  = ABS(DELTA)
C
C  IF CYCLE LENGTH < 0.5 INCH, REDUCE THE NUMBER OF MAJOR TICKS...
C
    	IC = INT( 0.5*DELL ) + 1
C
C  PUT ON THE SCALING NUMBERS...
C
    	IF( IGRD.EQ.2 ) THEN
    	    ITC = 1
    	ELSE
    	    IF( DELL.LE.0.35 ) ITC = 9
    	    IF( DELL.GT.0.35 ) ITC = 9-INT((DELL-0.35)/0.1)
    	    IF( ITC.LT.1 ) ITC = 1
    	ENDIF
    	YB   = -0.005
    	YE   = YLEN+0.005
    	YN   = DIST
     	IF( DELTA.LT.0.0 ) YN = YLEN-DIST
    	IF( IGRD.NE.2 .AND. DIST.GT.0.1 ) THEN
    	    NTIC = NTIC + 2
    	    FIRST= FIRST - 1.0
    	    YN   = YN - 1.0/DELTA
    	ENDIF
    	NMAX = 0
    	IF( IABS(NDG).EQ.9 ) GOTO 222
     	SIZE = 0.1
     	SEXT = 0.06
     	IF( YLN.LT.0.0 ) THEN
     	    XM = 0.1
     	ELSE
     	    XM = -0.15
     	ENDIF
    	DO MJ = 1, NTIC, IC
     	IF( CTRL_C ) RETURN
    	    FMJ = MJ - 1
    	    EX  = FIRST + FMJ
    	    NDGT= 1
    	    IF( EX.NE.0.0 ) NDGT = INT(LOG10(ABS(EX))) + 1
    	    IF( EX.LT.0.0 ) NDGT = NDGT + 1
     	    IF( NMAX.LT.NDGT ) NMAX = NDGT
    	    IF( YLN.LT.0.0 ) THEN
     		XAD = 0.125
     	    ELSE
    		XAD = -(0.3+0.07*NDGT)
     	    ENDIF
     	    DO  MI = 1, ITC
     		YAD = YN + (BLOG(MI)+FMJ)/DELTA
     		IF( YAD.GT.YB .AND. YAD.LT.YE ) THEN
     		    YAD = YAD - 0.05
     		    IF( MI.EQ.1 ) THEN
     			CALL IFTEXT( XAD, YAD, '10', SIZE, SIZE, 0.0 )
     		CALL IFTEXT_FPN(XAD+2*SIZE,YAD+0.8*SIZE,SEXT,EX,0.0,-1)
     		    ELSE
     		CALL IFTEXT_FPN(XM,YAD+0.02,SEXT,FLOAT(MI),0.0,-1)
     		    ENDIF
     		ENDIF
     	    ENDDO
     	ENDDO
C
C  DRAW THE TICKMARKS...
C
  222	ITC = 9
    	IF( IC.GT.1 ) ITC = 1
     	DYB = 0.08
     	IF( MTK.LT.0 ) DYB = -0.08
     	IF( YLN.LT.0.0 ) DYB = -DYB
     	DYC = 0.65*DYB
     	IF( IGRD.GT.2 ) DYB = XLN
     	IF( IGRD.EQ.4 ) DYC = XLN
     	XM = 0.0
     	IF( IGRD.EQ.4 ) CALL IFSTYL(2,0)
  333	DO MJ = 1, NTIC
     	IF( CTRL_C ) RETURN
    	    FMJ = MJ - 1
    	    DO  MI = 1, ITC
     		YAD = YN + (BLOG(MI)+FMJ)/DELTA
     		IF( YAD.GT.YB .AND. YAD.LT.YE ) THEN
     		IF( MI.EQ.1 ) THEN
     		    IF( IGRD.EQ.3 ) CALL IFSTYL(2,0)
     		    CALL IFPLOT(XM,YAD,3)
     		    CALL IFPLOT(DYB,YAD,2)
     		    IF( IGRD.EQ.3 ) CALL IFSTYL(1,0)
     		ELSE IF( DELL.LT.2.0 ) THEN
     		    CALL IFPLOT(XM,YAD,3)
     		    CALL IFPLOT(DYC,YAD,2)
     		ENDIF
     		ENDIF
     	    ENDDO
     	ENDDO
  444	IF( IGRD.EQ.4 ) CALL IFSTYL(1,0)
     	IF(IGD.LT.0.AND.DELTA.GT.0.0) CALL IFARRH( 1, XM,
     +  YLEN+0.25, 0.25, 0.04, 0.15, 90.0 )
    	CALL IFPLOT (XM,YLEN,3)
    	CALL IFPLOT (XM,0.0,2)
    	IF( .NOT.PAIR ) GOTO 555
C
C  DRAW THE OPPOSITE AXIS...
C
     	XM = XLN
     	PAIR = .FALSE.
    	IF( IGRD.EQ.4 ) GOTO 444
     	IF( IGRD.EQ.3 ) DYB = 0.0
     	DYB = XLN - DYB
     	DYC = XLN - DYC
     	GOTO 333
C
C  DRAW THE AXIS TITLE IF ANY...
C
  555	CALL IFAXIS_YLABEL(TXT,YLN,NDG,0,2+NMAX/2)
     	RETURN
    	END

     	SUBROUTINE IFAXIS_Y3( XLN, YLN, TXT, FST, DEL,
     +                        DST, NTK, MTK, NDG, IGD )
C
C  PROGRAMMER: R.S. ZHOU,		ALFRED UNIVERSITY
C
C	THIS ROUTINE DRAWS AN INVERSE-LINEAR Y-AXIS AT ACTIVE GRAPH ORIGIN.
C
C	XLN --- X-AXIS LENGTH IN INCHES.
C	YLN --- Y-AXIS LENGTH IN INCHES.
C		IF YLN<0.0, AXIS ANNOTATION IS TO THE RIGHT OF AXIS.
C	TXT --- AXIS TITLE IN CHARACTER FORMAT.
C		IF TXT(1)="!", TITLE IS NOT CENTERED ON AXIS.
C		IF TXT(1)="^", TITLE IS PLACED ON TOP OF AXIS.
C	FST --- SCALE VALUE AT THE FIRST MAJOR TICKMARK.
C	DEL --- CHANGE IN SCALE UNITS BETWEEN MAJOR TICKMARKS.
C	DST --- DISTANCE OF FIRST TICKMARK AWAY FROM ORIGIN.
C 	NTK --- NUMBER OF DIVISIONS ON THE AXIS.
C 	MTK --- NUMBER OF MINOR TICKMARKS ON THE AXIS.
C		IF MTK<0, TICKMARKS TO THE SAME SIDE OF ANNOTATIONS.
C	NDG --- NUMBER OF SIGNIFICANT DIGITS FOR SCALE NUMBERS.
C		0 = ROUTINE DETERMINED, 9=NO ANNOTATION.
C		0<= SKIP DRAWING THE MULTIPLIER.
C	IGD --- AXIS PATTERN CODE:
C		1: DRAW THE AXIS WITH MAJOR AND MINOR TICKS.
C		2: DRAW THE AXIS WITH MAJOR TICK ONLY.
C		3: DRAW THE AXIS WITH GRID LINES ON MAJOR TICKS.
C		4: DRAW THE AXIS WITH GRID LINES ON MINOR TICKS AS WELL.
C	MINUS IGD: DRAW THE AXIS WITH ARROWHEAD.
C	 DUAL IGD: DRAW THE OPPOSITE AXIS OF THE SAME PATTERN.
C	
     	INCLUDE		'TEKLIB.CBS'
    	CHARACTER	TXT*(*)
     	LOGICAL		PAIR
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C ) RETURN
    	YLEN = ABS(YLN)
    	IGRD = IABS(IGD)
    	PAIR = .FALSE.
    	IF( IGRD.GT.10 ) THEN
    	    IGRD = MOD( IGRD, 10 )
    	    IF( IGRD.LT.1 ) IGRD = 1
    	    PAIR = .TRUE.
    	ENDIF
    	FIRST= FST
    	DELL = DEL
    	DIST = DST
    	NTIK = IABS(NTK)+1
    	MTIK = IABS(MTK)
C
C  DETERMINE THE LENGTH OF SCALING NUMBERS...
C
    	IEX  = 0
     	CALL IFAXIS_DIGITS( NDG, NTIK, FIRST, DELL,
     +                      NDIGIT, IEX, YVL, ADY )
    	NMAX = 0
     	YAD  = YVL + (NTIK-1)*ADY
    	YAD  = (1.0/YAD-1.0/YVL)/(YLEN-2.0*DIST)
    	IF( IABS(NDG).EQ.9 ) GOTO 222
C
C  PUT ON THE SCALE NUMBERS...
C
     	SIZE= 0.1
    	YDA = 1.0/YVL
     	YN  = DIST - 0.5*SIZE
    	YVV = YVL
    	XM  = 0.125
    	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
C
C  DETERMINE THE LENGTH OF YVV...
C
    	   IF( ABS(YVV).GE.1.0 ) THEN
    	       NDT = LOG10(ABS(YVV))
    	       NDT = NDT + 1
    	   ELSE
    	       NDT = 1
    	   ENDIF
    	   IF( NDIGIT.GT.0 ) NDT = NDT + NDIGIT + 1
    	   IF( YVV.LT.0.0 ) NDT = NDT + 1
    	   IF( NDT.GT.NMAX ) NMAX = NDT
    	   IF( YLN.GT.0.0 ) XM = -SIZE*(NDT+1)
    	   YYD = YN + (1.0/YVV-YDA)/YAD
     	   IF( DIST.EQ.0.0 ) THEN
     		IF( I.EQ.NTIK ) YYD = YYD - 0.05
     		IF( I.EQ. 1   ) YYD = YYD + 0.05
     	   ENDIF
     	   CALL IFTEXT_FPN( XM, YYD, SIZE, YVV, 0.0, NDIGIT )
    	   YVV = YVV + ADY
    	ENDDO
C
C  DRAW THE TICK MARKS OR GRID LINES...
C
  222	IF( IGRD.LT.4 ) THEN
     	    DYB = 0.08
    	    IF( MTK.LT.0 ) DYB = -0.08
    	    IF( YLN.LT.0.0 ) DYB = -DYB
     	    IF( IGRD.EQ.2 ) THEN
     		MTIK = 0
     	    ELSE
     		DYC = 0.65*DYB
     	    ENDIF
     	ENDIF
     	IF( IGRD.GT.2 ) THEN
     	    DYB = XLN
    	    IF( IGRD.EQ.4 ) DYC = XLN
    	ENDIF
     	YDA = ADY
    	IF( MTIK.GT.0 ) YDA = ADY / (MTIK+1)
     	YN = DIST
     	YB = -0.005
     	YE = YLEN+0.005
     	XM = 0.0
     	IF( IGRD.EQ.4 ) CALL IFSTYL(2,0)
333	YVV = YVL
    	YV1 = 1.0/YVL
     	ADY = YN
    	DO I=1, NTIK
     	IF( CTRL_C ) RETURN
     	    IF( ADY.GT.YE ) GOTO 444
    	    IF( ADY.GT.YB ) THEN
     		IF( IGRD.EQ.3 ) CALL IFSTYL(2,0)
     		CALL IFPLOT (XM,ADY,3)
     		CALL IFPLOT (DYB,ADY,2)
     		IF( IGRD.EQ.3 ) CALL IFSTYL(1,0)
     	    ENDIF
     	    DO  K=1, MTIK
     		YVV = YVV + YDA
     		ADY = YN + (1.0/YVV-YV1)/YAD
     		IF( ADY.GT.YE ) GOTO 444
     		IF( ADY.GT.YB ) THEN
     		    CALL IFPLOT (XM,ADY,3)
     		    CALL IFPLOT (DYC,ADY,2)
     		ENDIF
     	    ENDDO
     	    YVV = YVV + YDA
     	    ADY = YN + (1.0/YVV-YV1)/YAD
     	ENDDO
444	IF( IGRD.EQ.4 ) CALL IFSTYL(1,0)
     	CALL IFPLOT (XM,0.0,3)
    	CALL IFPLOT (XM,YLEN,2)
     	IF(IGD.LT.0.AND.DELL.GT.0.0) CALL IFARRH( 1, XM,
     +  YLEN+0.25, 0.25, 0.04, 0.15, 90.0 )
    	IF( .NOT.PAIR ) GOTO 555
C
C  DRAW THE OPPOSITE AXIS...
C
     	XM = XLN
     	PAIR = .FALSE.
    	IF( IGRD.EQ.4 ) GOTO 444
     	IF( IGRD.EQ.3 ) DYB = 0.0
     	DYB = XLN-DYB
     	DYC = XLN-DYC
     	GOTO 333
C
C  DRAW THE TITLE AND MAGNITUDE INDICATOR...
C
  555	CALL IFAXIS_YLABEL(TXT,YLN,NDG,IEX,NMAX)
     	RETURN
    	END

    	FUNCTION IFAXIS_LINSCL( FLEN, AMIN, AMAX )
C
C	THIS ROUTINE DOES AUTOMATIC SCALING OF AXIS UNITS.
C
C	FLEN ----- INPUT AXIS LENGTH IN INCHES.
C	AMIN ----- MINIMUM VALUE OF DATA SET.
C		   RETURN AS "ROUNDOFF" MINIMUM VALUE.
C	AMAX ----- MAXIMUM VALUE OF DATA SET.
C		   RETURN AS "ROUNDOFF" MAXIMUM VALUE.
C
C	IFAXIS_LINSCL = NUMBER OF DIVISION ON THE AXIS.
C
     	FMIN = AMIN
     	FMAX = AMAX
     	STEP = 1.25*(FMAX-FMIN)/FLEN
     	IF( STEP.GT.1.0 ) THEN
     	    EXT = 10.0**INT(LOG10(STEP))
     	ELSE
     	    EXT = 10.0**INT(LOG10(STEP)-1.0)
     	ENDIF
     	STEP = EXT*FLOAT(INT(STEP/EXT+0.5))
     	RMIN = STEP*INT(FMIN/STEP)
     	IF( RMIN.GT.FMIN ) RMIN = RMIN - STEP
     	RMAX = STEP*INT(FMAX/STEP)
     	IF( RMAX.LT.FMAX ) RMAX = RMAX + STEP

     	AMIN = RMIN
     	AMAX = RMAX
     	IFAXIS_LINSCL = (RMAX-RMIN)/STEP + 0.1

     	RETURN
     	END

    	FUNCTION IFAXIS_LOGSCL( AMIN, AMAX )
C
C	AMIN ---- INPUT MINIMUM AND RETURN ROUNDOFF MINIMUM
C	AMAX ---- INPUT MAXIMUM AND RETURN ROUNDOFF MAXIMUM
C
C	IFAXIS_LOGSCL = LOG10 CYCLES ON THE AXIS.
C
    	FLO1 = LOG10(AMIN)
    	FLO2 = INT( FLO1 )
    	IF( FLO1.LT.0.0 .AND. FLO1.LT.(FLO2-0.01) ) FLO2=FLO2-1.0
    	AMIN = 10.0**FLO2

    	FHI1 = LOG10(AMAX)
    	FHI2 = INT( FHI1 )
    	IF( FHI1.GT.(FHI2+0.01) ) FHI2 = FHI2 + 1.0
    	AMAX = 10.0**FHI2

     	IFAXIS_LOGSCL = FHI2-FLO2+0.1
     	RETURN
    	END

     	SUBROUTINE IFAXIS_DIGITS( NNN, NTIK, FIRST, DELL,
     +                            NDIGIT, IEX, XVL, ADX )
C
C  DETERMINE THE LENGTH OF SCALING NUMBERS...
C
     	NDGS  = IABS(NNN)
    	FMAX1 = ABS(FIRST)
    	FMAX2 = ABS( FIRST + DELL*(NTIK-1) )
    	FMAX  = MAX( FMAX1, FMAX2 )
    	ADX   = LOG10( FMAX )
    	IADX  = ADX

    	IF( NDGS.EQ.0 ) THEN
C
C  AUTO SCALING; MAX DIGITS <= 8...
C
    	    IF( IADX.GT.4 ) IEX = IADX
    	    IF( ADX.LT.-1.) THEN
    		IEX = IADX
    		IF( ADX.NE.FLOAT(IADX) ) IEX = IEX - 1
    	    ENDIF
    	ELSE
C
C  USER SPECIFIES THE DIGITS...
C
    	    IF( ADX.GE.0.0 ) THEN
    		IF( NDGS.LT.(IADX+1) ) THEN
    		    IEX = IADX
    		    NDIGIT = NDGS - 1
    		ENDIF
    		IF( NDGS.EQ.(IADX+1) ) NDIGIT = -1
    		IF( NDGS.GT.(IADX+1) ) NDIGIT = NDGS - (IADX+1)
    	    ELSE
    	        IF( ADX.LT.-NDGS ) THEN
    		    IEX = IADX
    		    IF( ADX.NE.FLOAT(IADX) ) IEX = IEX - 1
    		    NDIGIT = NDGS - 1
    		ELSE
    		    NDIGIT = NDGS
    		ENDIF
    	    ENDIF
    	ENDIF

    	XVL = FIRST*10.0**(-IEX)
    	ADX = DELL*10.0**(-IEX)
    	IF( NDGS.GT.0 ) RETURN
C
C  DETERMINE THE LENGTH OF DECIMAL DIGITS...
C
    	MDGS = -2
    	DIGIT = ABS(ADX)
    	DO I=1,2
    	   DIGIT = ABS(AINT((DIGIT-AINT(DIGIT))*1000.0+.5))
    	   IF( DIGIT.GT.0.0 ) NDIGIT = 3
    	   IF( DIGIT.EQ.AINT(DIGIT/10.)*10. ) NDIGIT = 2
    	   IF( DIGIT.EQ.AINT(DIGIT/100.)*100. ) NDIGIT = 1
    	   IF( DIGIT.EQ.0.0 ) NDIGIT = -1
    	   IF( NDIGIT.GT.MDGS ) MDGS = NDIGIT
    	   DIGIT = ABS(XVL)
    	ENDDO
    	NDIGIT = MDGS
     	RETURN
     	END

     	SUBROUTINE IFAXIS_XLABEL(TXT,XLN,NDG,IEX)
    	CHARACTER EXT*7, TXT*(*)

     	YAD = -0.6
    	IF( XLN.LT.0.0 ) YAD = 0.48
    	IF( IABS(NDG).EQ.9 ) YAD = 0.8*YAD
     	ICH = 1					!CENTERED TITLE
     	NCH = IFMISC_LENG( TXT )
     	IF( NCH.GT.0 ) THEN
     	    IF( TXT(1:1).EQ.'!' ) ICH = 2	!LITERAL TITLE
    	    NCH = IFTEXT_STRIP( TXT(ICH:) )
     	ENDIF
     	SIZE = 0.12
    	NEX = NCH
    	IF( IABS(NDG).NE.9.AND.NDG.GE.0.AND.IEX.NE.0 ) NEX = NEX+7
    	IF( NCH.GT.0 ) THEN
     	    IF( ICH.EQ.2 ) XAD = 0.0
    	    IF( ICH.EQ.1 ) XAD = 0.5*(ABS(XLN)-SIZE*NEX)
    	    CALL IFTEXT_EXT( XAD, YAD, TXT(ICH:), SIZE, SIZE, 0.0 )
    	    XAD = XAD + (NCH+1)*SIZE
    	ELSE
    	    XAD = 0.5*(ABS(XLN)-SIZE*(NEX-2))
    	ENDIF
    	IF( IEX.EQ.0.OR.IABS(NDG).EQ.9.OR.NDG.LT.0 ) GOTO 999
    	IF( IEX.EQ.1 ) THEN
    	    EXT = '(x10)'
    	ELSE
    	    EXT = '(x10 )'
    	    IF( IABS(IEX).GT.9 .OR. IEX.LT.0 ) EXT = '(x10  )'
    	ENDIF
    	CALL IFTEXT( XAD, YAD, EXT, SIZE, SIZE, 0.0 )
    	IF( IEX.NE.1 ) CALL IFTEXT_FPN( XAD+4*SIZE,
     +                 YAD+.8*SIZE, 0.06, FLOAT(IEX), 0.0, -1 )
999	RETURN
     	END

     	SUBROUTINE IFAXIS_YLABEL(TXT,YLN,NDG,IEX,MAX)
     	CHARACTER EXT*7, TXT*(*)

     	ICH = 1				!CENTERED TITLE
     	NCH = IFMISC_LENG(TXT)
     	IF( NCH.GT.0 ) THEN
     	    IF(TXT(1:1).EQ.'!'.OR.TXT(1:1).EQ.'^') ICH=2 !LITERAL TITLE
    	    NCH = IFTEXT_STRIP( TXT(ICH:) )
     	ENDIF
    	IK = NCH
    	IF( IABS(NDG).NE.9.AND.NDG.GE.0.AND.IEX.NE.0 ) IK= IK+7
C
C  GET THE X-COORDINATE FOR PLACING THE TITLE...
C
     	SIZE = 0.1
	IFLG = 0
	IF( TXT(1:1).EQ.'^' ) THEN
	    IFLG = 1				!HORIZONTAL LABELING ON
	    XM = -0.5*SIZE*IK
	    IF( XM.LT.-1.5 ) THEN
     		XM = -1.5			!MAX 1.5 INCH OFFSET
     		IF( YLN.LT.0.0 ) XM = 2.0*XM+1.5
     	    ENDIF
	ELSE
	    IF( IABS(NDG).EQ.9 ) THEN
    	    	XM = -0.35
    	    	IF( YLN.LT.0.0 ) XM = 0.47
    	    ELSE
    	    	XM = -SIZE*MAX - 0.25
    	    	IF( YLN.LT.0.0 ) XM = SIZE*MAX+0.37
    	    ENDIF
	ENDIF
C
C  GET THE Y-COORDINATE FOR PLACING THE TITLE...
C
     	SIZE = 0.12
     	YLEN = ABS(YLN)
    	IF( NCH.GT.0 ) THEN
	    IF( IFLG.EQ.0 ) THEN
    	    	IF( ICH.EQ.1 ) THEN
     		    CALL IFSCAL_NOW( XN, YN )
     		    YT = 0.5*(YLEN-SIZE*IK*XN/YN)
     	    	ENDIF
     	    	IF( ICH.EQ.2 ) YT = 0.0
    	        CALL IFTEXT_EXT(XM,YT,TXT(ICH:),SIZE,SIZE,90.)
    	    	YT = YT + (NCH+1)*SIZE
	    ELSE
		YT = YLEN + 0.15
    	    	CALL IFTEXT_EXT(XM,YT,TXT(ICH:),SIZE,SIZE,0.0)
		XM = XM + (NCH+1)*SIZE
	    ENDIF
    	ELSE
    	    IF( IFLG.EQ.0 ) THEN
     		CALL IFSCAL_NOW( XN, YN )
		YT = 0.5*(YLEN-SIZE*(IK-2)*XN/YN)
    	    ELSE
		YT = YLEN + 0.15
		XM = -0.5*SIZE*(IK-2)
	    ENDIF
    	ENDIF
    	IF( IEX.EQ.0.OR.IABS(NDG).EQ.9.OR.NDG.LT.0 )  GOTO 999
    	IF( IEX.EQ.1 ) THEN
    	    EXT = '(x10)'
    	ELSE
    	    EXT = '(x10 )'
    	    IF( IABS(IEX).GT.9 .OR. IEX.LT.0 ) EXT = '(x10  )'
    	ENDIF
	IF( IFLG.EQ.0 ) THEN
     	    CALL IFTEXT( XM, YT, EXT, SIZE, SIZE, 90.0 )
    	    IF( IEX.NE.1 ) CALL IFTEXT_FPN( XM-.8*SIZE,
     +                     YT+4*SIZE, 0.06, FLOAT(IEX), 90., -1 )
	ELSE
     	    CALL IFTEXT( XM, YT, EXT, SIZE, SIZE, 0.0 )
    	    IF( IEX.NE.1 ) CALL IFTEXT_FPN( XM+4*SIZE,
     +                     YT+.8*SIZE, 0.06, FLOAT(IEX), 0.0, -1 )
	ENDIF
999	RETURN
     	END

