integer_to_string Function

private 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.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: inumber

Return Value character,ALLOCATABLE


Contents

Source Code


Source Code

   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