Converts an integer number to a string. The WRITE statement will return an error message, if the number of digits of the integer number is larger the than the length of the supplied string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | inumber |
FUNCTION integer_to_string(inumber) RESULT(string) !! Converts an integer number to a string. !! The WRITE statement will return an error message, if the number of !! digits of the integer number is larger the than the length of the !! supplied string. INTEGER, INTENT(IN) :: inumber CHARACTER(:), ALLOCATABLE :: string CHARACTER(RANGE(inumber) + 2) :: tmp WRITE (UNIT=tmp, FMT='(I0)') inumber string = TRIM(tmp) END FUNCTION integer_to_string