ITM Grid Service Library: Fortran 90

src/itm_assert/itm_string.f90

Go to the documentation of this file.
00001 module itm_string
00002 
00003   implicit none
00004 
00005 contains
00006 
00007   function itmInt2str(intval) result(string)
00008     integer , intent(in) :: intval
00009     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
00010     integer :: absn,j,k,is
00011     absn = abs(intval)
00012     if ( absn == intval ) then
00013             is = 1
00014     else
00015             is = 2
00016             string(1:1) = "-"
00017     end if
00018     do j=len(string),is,-1
00019             k = modulo(absn,10)+1
00020             string(j:j) = "0123456789"(k:k)
00021             absn = absn / 10
00022     end do
00023     return
00024   end function itmInt2str
00025 
00026 end module itm_string
00027 
 All Classes Namespaces Files Functions Variables