! itoa  -  convert integer to string

	character*(*) function itoa(ival)
	integer ival
	include 'global.def'
	character*16 buffer
	integer i,n,sign

	if(ival .eq. 0) then
	  itoa = '0'//NULL
	  return
	else if (ival .lt. 0) then
	  sign = -1
	else
	  sign = 1
	end if

	n = abs(ival)
	buffer(16:16) = NULL
	i = 16
	do while (n.gt.0)
	  i = i - 1
	  buffer(i:i) = char(mod(n,10) + ichar('0'))
	  n = n/10
	end do
	if (sign .eq. -1) then
	  i = i - 1
	  buffer(i:i) = '-'
	end if

	itoa = buffer(i:16)
	return
	end
