fdoc

functionint_textpure

pure character(len=12) function int_text(k) result(text)

k as text, in a fixed width. This is for parallel code, as an internal write takes a lock that threads end up spending most of their time on.

Arguments

NameTypeIntentAttributesDescription
kintegerin

the number

Result

NameTypeAttributesDescription
textcharacter(len=12)private

Source

Show the code
pure function int_text(k) result(text)
    integer, intent(in) :: k    !! the number
    character(len=12) :: text
    character(len=12) :: digits
    integer :: at, rest

    at = len(digits) + 1
    rest = abs(k)
    do
        at = at - 1
        digits(at:at) = achar(iachar('0') + mod(rest, 10))
        rest = rest/10
        if (rest == 0) exit
    end do
    if (k < 0) then
        at = at - 1
        digits(at:at) = '-'
    end if
    text = digits(at:)
end function int_text

Graphs

Called by