int_to_string3 Function

public function int_to_string3(i)

Converts a positive integer into a 3-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 three-digit character string. If the integer is negative, the routine stops with an error. If the integer is greater than 999, the routine returns a string containing its last three digits. None

Arguments

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

Return Value character(len=3)


Contents

Source Code


Source Code

  function int_to_string3(i)

    !! Converts a positive integer into a 3-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 three-digit
    !! character string.
    !! If the integer is negative, the routine stops with an error.
    !! If the integer is greater than 999, the routine returns a
    !! string containing its last three digits.
    !! None
    !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

    character(len=3) :: int_to_string3

    !  Arguments

    integer, intent(in) :: i

    !  Local variables

    character(len=1) :: a0, a1, a2

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

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

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

    int_to_string3 = a2//a1//a0

  end function int_to_string3