Utility routine to count the number of digits in an integer. Used to construct filenames.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ip), | intent(in) | :: | l | The integer to count the number of digits in. |
function count_digits ( l )
!! Utility routine to count the number of digits in an integer. Used to
!! construct filenames.
implicit none
integer(ip), intent(in) :: l
!! The integer to count the number of digits in.
integer(ip) :: count_digits
integer(ip) :: ltmp
count_digits = 1
ltmp = l/10
count_the_digits: do
if (ltmp<1) exit count_the_digits
count_digits = count_digits+1
ltmp = ltmp/10
end do count_the_digits
end function count_digits