int_to_string2 Function

public function int_to_string2(i)

Converts a positive integer into a two-digit character string author: P J Knight, CCFE, Culham Science Centre i : input integer : must be between 0 and 99 This routine converts a positive integer into a two-digit character string. If the integer is negative, the routine stops with an error. If the integer is greater than 99, the routine returns a string containing its last two digits. None

Arguments

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

Return Value character(len=2)


Contents

Source Code


Source Code

  function int_to_string2(i)

    !! Converts a positive integer into a two-digit character string
    !! author: P J Knight, CCFE, Culham Science Centre
    !! i : input integer : must be between 0 and 99
    !! This routine converts a positive integer into a two-digit
    !! character string.
    !! If the integer is negative, the routine stops with an error.
    !! If the integer is greater than 99, the routine returns a
    !! string containing its last two digits.
    !! None
    !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

		use numerics, only: boundu
		use constants, only: pi
    implicit none

    character(len=2) :: int_to_string2

    !  Arguments

    integer, intent(in) :: i

    !  Local variables

    character(len=1) :: a0, a1

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

    if (i < 0) then
       write(*,*) 'INT_TO_STRING2: illegal argument'
       stop 1
    end if

    a0 = int2char(mod(i,10))
    a1 = int2char(mod(int(i/10),10))

    int_to_string2 = a1//a0

  end function int_to_string2