      subroutine scale (array,axlen,npts,inc)
	save
c
c               compute minimun and delta for line routine
c
      dimension  array(1),tst(7)
      data tst / 1.0, 2.0, 4.0, 5.0, 8.0,  10.0, 20.0 /
      fad = 0.01
      k   = iabs(inc)
      n   = npts*k
      y0  = array(1)
      yn  = y0
      do 20 i = 1,n,k
      ys = array(i)
      if (y0.le.ys) go to 10
      y0 = ys
      go to 20
   10 if (ys.gt.yn)  yn=ys
   20 continue
      firstv = y0
      if (y0.lt.0.0) fad=fad-1.0
      deltav =(yn-firstv)/ axlen
      if (deltav.le.0.0) go to 70
      i= alog10(deltav)+1000.0
      p= 10.0**(i-1000)
      deltav= deltav/p - 0.01
      do 30 i = 1,6
      is= i
      if (tst(i).ge.deltav) go to 40
   30 continue
   40 deltav= tst(is)*p
      firstv= deltav* aint(y0/deltav+fad)
      t=firstv + (axlen+0.01)*deltav
      if (t.ge.yn) go to 50
      is= is+1
      go to 40
   50 firstv= firstv-aint((axlen+(firstv-yn)/deltav)/2.0) * deltav
      if((y0*firstv).le.0.0)   firstv=0.0
      if (inc.gt.0) go to 60
      firstv= firstv + axlen*deltav
      deltav= -deltav
   60 n=n+1
      array(n)= firstv
      n= n+k
      array(n)= deltav
      return
   70 deltav=1.0
      firstv= firstv-0.5
      go to 60
      end
