ITM Grid Service Library: Fortran 90
 All Classes Files Functions Variables
itm_string.f90
Go to the documentation of this file.
1 module itm_string
2 
3  implicit none
4 
5 contains
6 
7  function itmint2str(intval) result(string)
8  integer , intent(in) :: intval
9  character(len=2-max(sign(1,intval),0)+max( & min(abs(intval)/10**1,1)*1, & min(abs(intval)/10**2,1)*2, & min(abs(intval)/10**3,1)*3, & min(abs(intval)/10**4,1)*4, & min(abs(intval)/10**5,1)*5, & min(abs(intval)/10**6,1)*6, & min(abs(intval)/10**7,1)*7, & min(abs(intval)/10**8,1)*8, & min(abs(intval)/10**9,1)*9) ) :: string
10  integer :: absn,j,k,is
11  absn = abs(intval)
12  if ( absn == intval ) then
13  is = 1
14  else
15  is = 2
16  string(1:1) = "-"
17  end if
18  do j=len(string),is,-1
19  k = modulo(absn,10)+1
20  string(j:j) = "0123456789"(k:k)
21  absn = absn / 10
22  end do
23  return
24  end function itmint2str
25 
26 end module itm_string
27