fdoc

subroutinesize_textprivate

subroutine size_text(bytes, b)

Write a size in bytes, with one decimal once it is in kilobytes or megabytes.

Arguments

NameTypeIntentAttributesDescription
bytesinteger(kind=int64)in

the size

btype(buffer_t)inout

the HTML

Calls

Source

Show the code
subroutine size_text(bytes, b)
    integer(int64), intent(in) :: bytes     !! the size
    type(buffer_t), intent(inout) :: b      !! the HTML
    integer(int64), parameter :: KILO = 1000
    integer(int64) :: unit, tenths

    if (bytes < KILO) then
        call add_int(b, bytes)
        call add(b, ' B')
        return
    end if
    unit = merge(KILO, KILO*KILO, bytes < KILO*KILO)
    tenths = (10*bytes + unit/2)/unit
    call grouped(tenths/10, b)
    call add(b, '.')
    call add_int(b, mod(tenths, 10_int64))
    call add(b, merge(' kB', ' MB', bytes < KILO*KILO))
end subroutine size_text

Graphs

Calls

Called by