      subroutine logscale(z1,z2,multmax,pmax,dec)
C  determine a suitable range for a truncated log scale

      implicit none
c...	functions
      integer myint
      
c...	passed variables
      integer dec,multmax,pmax
      real z1,z2

c...	local variables

C      z1=.89e-4
C      z2=.120e+3

C      write(*,'(a,g7.2,2x,g7.2)') 'min and max data range ',z1,z2
C how many decades between z1 and z2? should be at least 2 if this
C routine is called, put in a bit of overshoot tolerence      

      dec=int(log10(z2/z1)-.05)+1
C      write(*,*) dec,' decades'

C what is the multiplier that should be used for the maximum
C value?
      
      pmax=myint(log10(z2))
      multmax=int(.9+z2/10.0**pmax)
cUnused      pmin=myint(log10(z1))
cUnused      multmin=int(.1+z1/10.0**pmin)
C      write(*,*) 'maxmultiplier is ',multmax,' maxpower is ',pmax
C      write(*,*) 'minmultiplier is ',multmin,' minpower is ',pmin
C      write(*,*) 'maximum at ',float(multmax)*10.0**float(pmax)
C      write(*,*) 'minimum at ',float(multmax)*10.0**float(pmax-dec)
      return
      end

c=======================================================================
      integer function myint(x)

      implicit none
      real x
c      integer myint

      if (x.lt.0.0) then
        myint=int(aint(x+.1e-10)-1.0)
      else
        myint=int(x)
      endif

      return
      end
