      include 'FGRAPH.FI'



      SUBROUTINE ConvertNum (innum, a1, a2, TicSpace, LogFlag, outstr)
      INCLUDE 'GRAFTYPE.FOR'
      REAL innum, a1, a2, TicSpace, tempnum
      LOGICAL LogFlag
      INTEGER  n1, n2, cwin, i
      CHARACTER * 80 outstr
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin
      DO i = 1, 80
        outstr(i:i) = ' '
      END DO
      tempnum = innum

      IF (LogFlag) THEN
        n2 = NumExp(tempnum)
        n1 = NumExp(tempnum)
      ELSE
        IF (ABS(a2) .GE. ABS(a1)) THEN
          n1 = NumExp(a2)
        ELSE
          n1 = NumExp(a1)
        END IF
        n2 = NumExp(TicSpace) - 1
      END IF

      SELECT CASE (n1)
         CASE (-1, -2)
                  IF (n2 .LT. 0) THEN
                     n2 = -n2
                  ELSE
                    n2 = 1
                  END IF
                  CALL RealToString(tempnum, n2, 1, outstr)

         CASE (0, 1, 2)
                  IF (n2 .LT. 0) THEN
                    n2 = -n2
                  ELSE
                    n2 = 1
                  END IF
                  CALL RealToString(tempnum, n2, 1, outstr)

        CASE (3, 4, 5)
                  tempnum = tempnum / 1000.0
                  n1 = n1 - 3
                  n2 = n2 - 3
                  IF (n2 .LT. 0) THEN
                    n2 = -n2
                  ELSE
                    n2 = 1
                  END IF
                  CALL RealToString(tempnum, n2, 1, outstr)
                  CALL AddChar( outstr, 'k')

         CASE (6, 7, 8)
                  tempnum = tempnum / 1000000.0
                  n1 = n1 - 6
                  n2 = n2 - 6
                  IF (n2 .LT. 0) THEN
                    n2 = -n2
                  ELSE
                    n2 = 1
                  END IF
                  CALL RealToString(tempnum, n2, 1, outstr)
                  CALL AddChar(outstr, 'm')
         CASE (9, 10, 11)
                  tempnum = tempnum / 1000000000.0
                  n1 = n1 - 9
                  n2 = n2 - 9
                  IF (n2 .LT. 0) THEN
                    n2 = -n2
                  ELSE
                     n2 = 1
                  END IF
                  CALL RealToString(tempnum, n2, 1, outstr)
                  CALL AddChar(outstr, 'b')

         CASE DEFAULT
           CALL RealToString(tempnum, -1, n2, outstr)
      END SELECT
      END !SUBROUTINE





      SUBROUTINE DrawTicX (x, y, l)
      REAL x, y, l
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin
      IF (x .LE. grstat(cwin).plotclip.right .AND.
     +    x .GE. grstat(cwin).plotclip.left) THEN
        CALL moveworldabs(x, y)
        CALL lineworldabs(x, y - l)
      END IF
      END !SUBROUTINE



      SUBROUTINE DrawTicY (x, y, l)
      REAL x, y, l
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      IF (y .LE. grstat(cwin).plotclip.top .AND.
     +    y .GE. grstat(cwin).plotclip.bottom) THEN
        CALL moveworldabs(x, y)
        CALL lineworldabs(x - l, y)
      END IF
      END !SUBROUTINE


      SUBROUTINE DrLinXAx (TicSpace, dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL TicSpace, tl, xx1, ticlen
      INTEGER dir, cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin
      CALL SetWorldCoordinates(grstat(cwin).plotworld)
      CALL moveworldabs(grstat(cwin).plotclip.left,
     +                   grstat(cwin).yint)
      CALL lineworldabs(grstat(cwin).plotclip.right,
     +                   grstat(cwin).yint)
      grstat(cwin).numticx = NINT((grstat(cwin).plotclip.right -
     +                   grstat(cwin).plotclip.left) / TicSpace)
      grstat(cwin).ticspacex = TicSpace

      xx1 = grstat(cwin).xint + grstat(cwin).ticspacex
      tl = 0.015 * (grstat(cwin).plotclip.top -
     +              grstat(cwin).plotclip.bottom)
      IF (dir .EQ. 0) THEN
        ticlen = tl
      ELSE
        ticlen = -tl
      END IF
      DO WHILE (xx1 .LE. grstat(cwin).plotclip.right)
        CALL DrawTicX(xx1, grstat(cwin).yint, ticlen)
        xx1 = xx1 + grstat(cwin).ticspacex
      END DO
      xx1 = grstat(cwin).xint - grstat(cwin).ticspacex
      DO WHILE (xx1 .GE. grstat(cwin).plotclip.left)
        CALL DrawTicX(xx1, grstat(cwin).yint, ticlen)
        xx1 = xx1 - grstat(cwin).ticspacex
      END DO
      END !SUBROUTINE



      SUBROUTINE DrLinYAx (TicSpace, dir)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER dir, cwin
      REAL TicSpace, tl, yy1, ticlen
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      CALL SetWorldCoordinates(grstat(cwin).plotworld)
      CALL moveworldabs(grstat(cwin).xint,
     +                  grstat(cwin).plotclip.bottom)
      CALL lineworldabs(grstat(cwin).xint,
     +                  grstat(cwin).plotclip.top)
      grstat(cwin).numticy = NINT((grstat(cwin).plotclip.top -
     +                  grstat(cwin).plotclip.bottom) / TicSpace)
      grstat(cwin).ticspacey = TicSpace
      yy1 = grstat(cwin).yint + grstat(cwin).ticspacey
      tl = 0.01 * (grstat(cwin).plotclip.right -
     +            grstat(cwin).plotclip.left)
      IF (dir .EQ. 0 ) THEN
        ticlen = tl
      ELSE
        ticlen = -tl
      END IF
      DO WHILE (yy1 .LE. grstat(cwin).plotclip.top)
        CALL DrawTicY(grstat(cwin).xint, yy1, ticlen)
        yy1 = yy1 + grstat(cwin).ticspacey
      END DO
      yy1 = grstat(cwin).yint - grstat(cwin).ticspacey
      DO WHILE (yy1 .GE. grstat(cwin).plotclip.bottom)
        CALL DrawTicY(grstat(cwin).xint, yy1, ticlen)
        yy1 = yy1 - grstat(cwin).ticspacey
      END DO
      END !SUBROUTINE




      SUBROUTINE DrLogXAx (dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL tl1, tl2, xx1, yy1, ticlen,mts,LogSCFactor(1:10)
      INTEGER dir, i, j, XLogMin, XLogMax, cwin
      COMMON /LogSC/ LogSCFactor
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      CALL SetWorldCoordinates(grstat(cwin).plotworld)
      CALL moveworldabs(grstat(cwin).plotclip.left,
     +                  grstat(cwin).plotclip.bottom)
      CALL lineworldabs(grstat(cwin).plotclip.right,
     +                  grstat(cwin).plotclip.bottom)
      XLogMin = NumExp(grstat(cwin).plotclip.left)
      XLogMax = NumExp(grstat(cwin).plotclip.right)
      grstat(cwin).numticx = XLogMax - XLogMin
      mts = (grstat(cwin).plotclip.right -
     +     grstat(cwin).plotclip.left) / REAL(grstat(cwin).numticx)
      grstat(cwin).ticspacex = mts
      tl1 = 0.015 * (grstat(cwin).plotclip.top -
     +       grstat(cwin).plotclip.bottom)
      tl2 = 2 * tl1
      DO i = 0, grstat(cwin).numticx - 1
        DO j = 1, 10
          xx1 = grstat(cwin).plotclip.left + i * mts +
     +           LogSCFactor(j) * mts
          yy1 = grstat(cwin).plotclip.bottom
          IF (MOD(j, 9) .EQ. 1) THEN
            ticlen = tl2
          ELSE
            ticlen = tl1
          END IF
          IF (dir .EQ. 1)   ticlen = -ticlen
          CALL DrawTicX(xx1, yy1, ticlen)
        END DO
      END DO
      END !SUBROUTINE



      SUBROUTINE DrLogYAx (dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL tl1, tl2, xx1, yy1, ticlen,mts, LogSCFactor(1:10)
      INTEGER i, j, YLogMin, YLogMax, dir ,cwin
      COMMON /LogSC/ LogSCFactor
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      CALL SetWorldCoordinates(grstat(cwin).plotworld)
      CALL moveworldabs(grstat(cwin).plotclip.left,
     +                  grstat(cwin).plotclip.bottom)
      CALL lineworldabs(grstat(cwin).plotclip.left,
     +                  grstat(cwin).plotclip.top)
      YLogMin = NumExp(grstat(cwin).plotclip.bottom)
      YLogMax = NumExp(grstat(cwin).plotclip.top)
      grstat(cwin).numticy = YLogMax - YLogMin
      mts = (grstat(cwin).plotclip.top -
     +       grstat(cwin).plotclip.bottom) /
     +       REAL( grstat(cwin).numticy)
      grstat(cwin).ticspacey = mts
      tl1 = 0.01 * (grstat(cwin).plotclip.right -
     +       grstat(cwin).plotclip.left)
      tl2 = 2 * tl1
      DO i = 0, grstat(cwin).numticy - 1
        DO j = 1, 10
          yy1 = grstat(cwin).plotclip.bottom + i * mts +
     +          LogSCFactor(j) * mts
          xx1 = grstat(cwin).plotclip.left
          IF (MOD(j, 9) .EQ. 1) THEN
            ticlen = tl2
          ELSE
            ticlen = tl1
          END IF
          IF (dir .EQ. 1) ticlen = -ticlen
          CALL DrawTicY(xx1, yy1, ticlen)
       END DO
      END DO
      END !SUBROUTINE





      SUBROUTINE DrXLinGrid (NthTic)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER NthTic, cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin
      REAL xx1, yy1, yy2

      grstat(cwin).tsx = grstat(cwin).ticspacex * NthTic
      xx1 = grstat(cwin).xint + grstat(cwin).tsx
      yy1 = grstat(cwin).plotclip.bottom
      yy2 = grstat(cwin).plotclip.top
      DO WHILE (xx1 .LE. grstat(cwin).plotclip.right )
        CALL moveworldabs(xx1, yy1)
        CALL lineworldabs(xx1, yy2)
        xx1 = xx1 + grstat(cwin).tsx
      END DO
      xx1 = grstat(cwin).xint - grstat(cwin).tsx
      DO WHILE (xx1 .GE. grstat(cwin).plotclip.left)
        CALL moveworldabs(xx1, yy1)
        CALL lineworldabs(xx1, yy2)
        xx1 = xx1 - grstat(cwin).tsx
      END DO
      END !SUBROUTINE





      SUBROUTINE DrXLogGrid (NthTic)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER NthTic, i, cwin
      REAL xx1, yy1, yy2
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      yy1 = grstat(cwin).plotclip.bottom
      yy2 = grstat(cwin).plotclip.top
      grstat(cwin).tsx = grstat(cwin).ticspacex * NthTic
      xx1 = grstat(cwin).xint + grstat(cwin).tsx
      DO i = 0, grstat(cwin).numticx - 1
        CALL moveworldabs(xx1, yy1)
        CALL lineworldabs(xx1, yy2)
        xx1 = xx1 + grstat(cwin).tsx
      END DO
      END !SUBROUTINE





      SUBROUTINE DrYLinGrid (NthTic)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER NthTic, cwin
      REAL xx1, xx2, yy1
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      grstat(cwin).tsy = grstat(cwin).ticspacey * NthTic
      xx1 = grstat(cwin).plotclip.left
      xx2 = grstat(cwin).plotclip.right
      yy1 = grstat(cwin).yint + grstat(cwin).tsy
      DO WHILE (yy1 .LE. grstat(cwin).plotclip.top)
        CALL moveworldabs(xx1, yy1)
        CALL lineworldabs(xx2, yy1)
        yy1 = yy1 + grstat(cwin).tsy
      END DO
      yy1 = grstat(cwin).yint - grstat(cwin).tsy
      DO WHILE (yy1 .GE. grstat(cwin).plotclip.bottom)
        CALL moveworldabs(xx1, yy1)
        CALL lineworldabs(xx2, yy1)
        yy1 = yy1 - grstat(cwin).tsy
      END DO
      END !SUBROUTINE



      SUBROUTINE DrYLogGrid (NthTic)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER NthTic, i, cwin
      REAL xx1, xx2, yy1
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      xx1 = grstat(cwin).plotclip.left
      xx2 = grstat(cwin).plotclip.right
      grstat(cwin).tsy = grstat(cwin).ticspacey * NthTic
      yy1 = grstat(cwin).yint + grstat(cwin).tsy
      DO i = 0, grstat(cwin).numticy - 1
        CALL moveworldabs(xx1, yy1)
        CALL lineworldabs(xx2, yy1)
        yy1 = yy1 + grstat(cwin).tsy
      END DO
      END !SUBROUTINE

      FUNCTION exp10 (e)
      INTEGER  e, i
      REAL x

      x = 1.0
      IF (e .GT. 0) THEN
        DO i = 1, e
          x = x * 10.0
        END DO
      ELSE
        DO i = 1, -e, -1
          x = x / 10.0
        END DO
        exp10 = x
      END IF
      END !FUNCTION


      INTEGER FUNCTION NumExp (realnum)

      REAL realnum
      if (ABS(realnum) .LT. 1.0e-16)  realnum = 1.0e-16
      NumExp = INT(xlog10(ABS(realnum)))
      RETURN
      END !FUNCTION

      FUNCTION PowerCalc (realnum, power)
      REAL realnum, power

        PowerCalc = EXP(power * LOG(realnum))
      RETURN
      END !FUNCTION



      SUBROUTINE LabelTicX (x, y, xval, lf, dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL x,y,xval
      INTEGER  dir, cwin, i
      LOGICAL lf
      CHARACTER * 80  labvalstr
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      DO i = 1, 80
        labvalstr(i:i) = ' '
      END DO
      CALL ConvertNum(xval, grstat(cwin).plotclip.left,
     +              grstat(cwin).plotclip.right, grstat(cwin).tsx,
     +              lf, labvalstr)
      CALL LabelTicXString(x, y, labvalstr, dir)
      END !SUBROUTINE



      SUBROUTINE LabelTicXString (x, y, TicLabel, dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL x,y, tl, xx1, yy1
      INTEGER  dir, cwin
      CHARACTER * 80 TicLabel
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      IF (x .LE. grstat(cwin).plotclip.right .AND.
     +    x .GE. grstat(cwin).plotclip.left)  THEN
        tl = 0.03 * (grstat(cwin).plotclip.top -
     +              grstat(cwin).plotclip.bottom)
        IF (dir .EQ. 0) THEN
          CALL DrawTicX(x, y, tl)
        ELSE
           CALL DrawTicX(x, y, -tl)
        END IF
        tl = 0.040 * (grstat(cwin).plotclip.top -
     +               grstat(cwin).plotclip.bottom)
        IF (dir .EQ. 0) THEN
          yy1 = y - tl
        ELSE
          yy1 = y + tl
        END IF
        xx1 = x
        CALL moveworldabs(xx1, yy1)
        CALL OutRealXX(TicLabel)
      END IF
      END !SUBROUTINE



      SUBROUTINE LabelTicY (x, y, yval, lf, dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL x,y
      INTEGER  dir, cwin
      LOGICAL lf
      CHARACTER * 80  labvalstr
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      CALL ConvertNum(yval, grstat(cwin).plotclip.bottom,
     +     grstat(cwin).plotclip.top, grstat(cwin).tsy, lf, labvalstr)
      CALL LabelTicYString(x, y, labvalstr, dir)
      END !SUBROUTINE


      SUBROUTINE LabelTicYString (xx, yy, TicLabel, dir)
      INCLUDE 'GRAFTYPE.FOR'
      REAL xx,yy,  tl, xx1, yy1
      INTEGER  dir, cwin
      CHARACTER * 80 TicLabel
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      IF ((yy .LE. grstat(cwin).plotclip.top) .AND.
     +    (yy .GE. grstat(cwin).plotclip.bottom)) THEN
        tl = 0.015 * (grstat(cwin).plotclip.right -
     +               grstat(cwin).plotclip.left)
        IF (dir .EQ. 0) THEN
          CALL DrawTicY(xx, yy, tl)
        ELSE
          CALL DrawTicY(xx, yy, -tl)
        END IF
        tl = 0.02 * (grstat(cwin).plotclip.right -
     +              grstat(cwin).plotclip.left)
        yy1 = yy
        IF (dir .EQ. 0) THEN
          xx1 = xx - tl
        ELSE
          xx1 = xx + tl
        END IF
        CALL moveworldabs(xx1, yy1)
       CALL OutRealXX(TicLabel)
      END IF
      END !SUBROUTINE



      SUBROUTINE LabLinXAx (NthTic, dir)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER NthTic,dir, cwin
      REAL xx1
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      grstat(cwin).tsx = grstat(cwin).ticspacex * REAL(NthTic)
      xx1 = grstat(cwin).xint
      IF (dir .EQ. 0) THEN
        IF (grstat(cwin).yint .NE. grstat(cwin).plotclip.bottom)
     +     xx1 = xx1 + grstat(cwin).tsx
      ELSE
        IF (grstat(cwin).yint .NE. grstat(cwin).plotclip.top)
     +     xx1 = xx1 + grstat(cwin).tsx
      END IF
      DO WHILE (xx1 .LE. grstat(cwin).plotclip.right)
        CALL LabelTicX(xx1, grstat(cwin).yint, xx1, .FALSE., dir)
        xx1 = xx1 + grstat(cwin).tsx
      END DO
      xx1 = grstat(cwin).xint - grstat(cwin).tsx
      DO WHILE ( xx1 .GE. grstat(cwin).plotclip.left )
        CALL LabelTicX(xx1, grstat(cwin).yint, xx1, .FALSE., dir)
        xx1 = xx1 - grstat(cwin).tsx
      END DO
      END !SUBROUTINE




      SUBROUTINE LabLinYAx (NthTic, dir)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER NthTic,dir, cwin
      REAL  yy1
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      grstat(cwin).tsy = grstat(cwin).ticspacey * REAL(NthTic)
      yy1 = grstat(cwin).yint
      IF (dir .EQ. 0) THEN
        IF (grstat(cwin).xint .NE. grstat(cwin).plotclip.left)
     +       yy1 = yy1 + grstat(cwin).tsy
      ELSE
        IF (grstat(cwin).xint .NE. grstat(cwin).plotclip.right)
     +       yy1 = yy1 + grstat(cwin).tsy
      END IF
      DO WHILE (yy1 .LE. grstat(cwin).plotclip.top)
        CALL LabelTicY(grstat(cwin).xint, yy1, yy1, .FALSE., dir)
        yy1 = yy1 + grstat(cwin).tsy
      END DO
      yy1 = grstat(cwin).yint - grstat(cwin).tsy
      DO WHILE (yy1 .GE. grstat(cwin).plotclip.bottom)
        CALL LabelTicY(grstat(cwin).xint, yy1, yy1, .FALSE., dir)
        yy1 = yy1 - grstat(cwin).tsy
      END DO
      END !SUBROUTINE




      SUBROUTINE LabLogXAx (dir)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER dir, i, cwin
      REAL xx1, labval
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      grstat(cwin).tsx = grstat(cwin).ticspacex
      DO i = 0, grstat(cwin).numticx
        xx1 = grstat(cwin).plotclip.left + i * grstat(cwin).tsx
        labval = grstat(cwin).plotclip.left * PowerCalc(10.0, REAL(i))
        CALL LabelTicX(xx1, grstat(cwin).yint, labval, .TRUE., dir)
      END DO
      END !SUBROUTINE



      SUBROUTINE LabLogYAx (dir)
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER dir, i, cwin
      REAL yy1, labval
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      grstat(cwin).tsy = grstat(cwin).ticspacey
      DO i = 0, grstat(cwin).numticy
        yy1 = grstat(cwin).plotclip.bottom + i * grstat(cwin).tsy
        labval = grstat(cwin).plotclip.bottom * PowerCalc(10.0,REAL(i))
        CALL LabelTicY(grstat(cwin).xint, yy1, labval, .TRUE., dir)
      END DO
      END !SUBROUTINE

      FUNCTION xlog10 (realnum)

      IF (realnum .LT. 1E-16) THEN
        xlog10 = -16.0
      ELSE
        xlog10 = LOG10(realnum)
      END IF
      END !FUNCTION


      SUBROUTINE ScaleLinY (yy1, yy2)
      REAL yy1, yy2
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      CALL SetGraphAreaWorld(grstat(cwin).plotclip.left, yy1,
     +                       grstat(cwin).plotclip.right, yy2)
      grstat(cwin).LogY = .FALSE.
      END !SUBROUTINE




      SUBROUTINE ScaleLogX (xx1,xx2)
      REAL xx1, xx2, ex1, ex2
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      xx2 = xx2 - xx2 / 10000.0
      ex2 = NumExp(xx2) + 1
      xx2 = PowerCalc(10.0, ex2)
      xx1 = xx1 + xx1 / 10000.0
      ex1 = NumExp(xx1)
      IF (ex1 .LE. 0)  ex1 = ex1 - 1
      xx1 = PowerCalc(10.0, ex1)
      CALL SetGraphAreaWorld(xx1, grstat(cwin).plotclip.bottom,
     +                       xx2, grstat(cwin).plotclip.top)
      grstat(cwin).LogX = .TRUE.
      END !SUBROUTINE



      SUBROUTINE ScaleLogY (yy1, yy2)
      REAL yy1, yy2, ex1, ex2
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      yy2 = yy2 - yy2 / 10000.0
      ex2 = NumExp(yy2) + 1
      yy2 = PowerCalc(10.0, ex2)
      yy1 = yy1 + yy1 / 10000.0
      ex1 = NumExp(yy1)
      IF (ex1 .LE. 0) ex1 = ex1 - 1
      yy1 = PowerCalc(10.0, ex1)
      CALL SetGraphAreaWorld(grstat(cwin).plotclip.left, yy1,
     +                       grstat(cwin).plotclip.right, yy2)
      grstat(cwin).LogY = .TRUE.
      END !SUBROUTINE


      SUBROUTINE SetGraphAreaWorld (x1, y1, x2, y2)
      REAL x1, y1, x2, y2
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER cwin
      RECORD /grstype/ grstat(1:10)
      COMMON /GrAttr/ grstat, cwin

      grstat(cwin).plotworld.left = x1 - (x2 - x1) *
     +   (grstat(cwin).win2plotratio.left / (1.0 -
     +   (grstat(cwin).win2plotratio.left +
     +    grstat(cwin).win2plotratio.right)))
      grstat(cwin).plotworld.bottom = y1 - (y2 - y1) *
     +   (grstat(cwin).win2plotratio.bottom / (1.0 -
     +   (grstat(cwin).win2plotratio.bottom +
     +    grstat(cwin).win2plotratio.top)))
      grstat(cwin).plotworld.right = x2 + (x2 - x1) *
     +   (grstat(cwin).win2plotratio.right / (1.0 -
     +   (grstat(cwin).win2plotratio.right +
     +    grstat(cwin).win2plotratio.left)))
      grstat(cwin).plotworld.top = y2 + (y2 - y1) *
     +   (grstat(cwin).win2plotratio.top / (1.0 -
     +   (grstat(cwin).win2plotratio.top +
     +   grstat(cwin).win2plotratio.bottom)))

      CALL SetWorldRect(grstat(cwin).plotclip, x1, y1, x2, y2)
      END !SUBROUTINE


      ! 5/2/90 Changed Log10 function to xlog10 function