ESMF_UtilStringInt2String Function

public function ESMF_UtilStringInt2String(i, keywordEnforcer, rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: rc

Return Value character(len=int2str_len(i))


Source Code

    function ESMF_UtilStringInt2String (i, keywordEnforcer, rc)
!
! !ARGUMENTS:
      integer, intent(in) :: i
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      integer, intent(out), optional  :: rc
! !RETURN VALUE:
      character(int2str_len (i)) :: ESMF_UtilStringInt2String

!
! !DESCRIPTION:
!   Converts given an integer to string representation.  The returned string is
!   sized such that it does not contain leading or trailing blanks.
!
!   This procedure may fail when used in an expression in a {\tt write} statement
!   with some older, pre-Fortran 2003, compiler environments that do not support
!   re-entrant I/O calls.
!
!     The arguments are:
!     \begin{description}
!     \item[i]
!       An integer.
!     \item[{[rc]}]
!       Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!
!EOP

    integer :: ioerr

    write (ESMF_UtilStringInt2String,'(i0)', iostat=ioerr) i
    if (ioerr /= 0) then
      if (ESMF_LogFoundError (ESMF_RC_VAL_OUTOFRANGE, msg=ESMF_METHOD // ': conversion error',  &
          ESMF_CONTEXT, rcToReturn=rc))  &
        return
    end if

    if (present(rc)) rc = ESMF_SUCCESS

  end function ESMF_UtilStringInt2String