Convert an integer to a string. Works for up to 256 digits.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | i |
integer to convert |
string result
function int2str(i) result(s) integer, intent(in) :: i !! integer to convert character(len=:),allocatable :: s !! string result character(len=256) :: tmp !! temp string integer :: iostat !! write `iostat` code write(tmp,fmt=*,iostat=iostat) i if (iostat/=0) then s = '****' else s = trim(adjustl(tmp)) end if end function int2str