integer function width(n)
integer n
! Returns the number of digits:
if(n==0) then
width =1
else
width =log10(real(abs(n)))+1
endif
! n<0: Ex: n=-12
if(n<0) width =width+1
end

integer function width8(n)
integer(8) n
! Returns the number of digits:
if(n==0) then
width8 =1
else
width8 =log10(real(abs(n)))+1
endif
! n<0: Ex: n=-12
if(n<0) width8 =width8+1
end
