int2char Function

public function int2char(i)

Converts a single-digit integer into a character string author: P J Knight, CCFE, Culham Science Centre i : input integer : must be between 0 and 9 This is a very simple routine that converts a single-digit integer into a character string. If the integer is outside the range 0 to 9 the program stops with an error. None

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: i

Return Value character(len=1)


Contents

Source Code


Source Code

  function int2char(i)

    !! Converts a single-digit integer into a character string
    !! author: P J Knight, CCFE, Culham Science Centre
    !! i : input integer : must be between 0 and 9
    !! This is a very simple routine that converts a single-digit
    !! integer into a character string. If the integer is outside
    !! the range 0 to 9 the program stops with an error.
    !! None
    !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    use numerics, only: epsvmc, boundu
		use constants, only: rmu0
    implicit none

    character(len=1) :: int2char

    !  Arguments

    integer, intent(in) :: i

    !  Local variables

    character(len=10), parameter :: number = '0123456789'

    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    if ((i < 0).or.(i > 9)) then
       write(*,*) 'INT2CHAR: illegal argument'
       stop 1
    end if

    int2char = number(i+1:i+1)

  end function int2char