Forbear v1.9.1 is out

Fortran (progress) B(e)ar environment.

The e is mute: say forbar.

Your solver has been running for six hours. Is it converging, diverging, or quietly computing the heat death of the universe? forbear will not tell you. It will, however, tell you how fast it is getting there, and how long is left, with a pretty bar.

forbear is a pure Fortran 2008 library for progress bars and spinners in long-running programs: one object, three calls (initialize, start, update). On a terminal it animates; in the log of a batch job it writes clean, boring lines, because nobody wants 40,000 carriage returns and escape codes in their SLURM output (ask your sysadmin how they feel about it).

a pretend CFD run: a mesh bar, then nested time-step and Newton bars, with checkpoints printed above, a residual and the ETA, and a closing summary

New in v1.9.0: your terminal is now a 1980s car

Somewhere between the Walkman and the fax machine, car makers decided that a needle was too analogue and filled the dashboard with glowing segments, rising bar graphs and seven-segment numbers. It was the future. Then the future moved on. forbear did not.

three bars at once: a blue-green segmented bar with a redline, an amber rising ramp, a red scanner, seven-segment numbers

  • 24-bit colours: '#rrggbb' in every colour keyword. Your teal is finally your teal, not whatever your terminal theme thinks “cyan” means today
  • bar_zones: each cell coloured by its position, '0.75:#2EF5C0 0.9:#FFB000 1:#FF3B30'. Your bar now has a redline. It means nothing, the solver does not care, but it feels dangerous
  • bar_profile='ramp': blocks rising from 1/8 to full height, as the tachometer of a car you could not afford in 1985
  • pulse_trail: a bar of unknown length becomes a scanner, with a fading trail that folds back at each end. Yes, that scanner. No, your Newton iterations will not talk back
  • digits='segment': percent, count and ETA in seven-segment digits, padded with unlit 8s, as a real display. Your font must have U+1FBF0-9 (Cascadia Code, Iosevka and JuliaMono do; your 1985 font does not)
  • theme='vfd', 'amber' or 'kitt': all of the above in one keyword, for the busy scientist with no time to pick hex codes. Any keyword you pass still wins

The serious part (it does real work too)

  • bars of any width and characters, smooth partial blocks, any Unicode string, 17 named colours plus #rrggbb, 16 styles

  • percent, count, smoothed speed, ETA, scale, start and end time, and a closing summary, so you know exactly how long you waited

  • 40 spinners, because one is never enough and 41 would be excessive

  • bar%write prints above the running bar, update(message=) shows your residual at its end, suspend/resume let a chatty library print without shredding your bar

  • nested bars, one per loop level, for when your loops have loops

  • bars of unknown length, for solvers that “will converge eventually”, and finish for loops that give up early

  • layout templates, '{bar:30} {percent:yellow} ETA {eta}', and fields of your own, e.g. the residual, the CFL, or your remaining patience

  • plain log lines off a terminal, a sign of life every so often in long jobs (FORBEAR_LOG_INTERVAL), and every bar off with FORBEAR_DISABLE=1 or disabled=(rank /= 0), so that 4096 MPI ranks do not all draw the same bar on the same line

  • and much more…

    eighteen spinners animating, one per line

    A time loop, dressed for 1985:

    program march
    use, intrinsic :: iso_fortran_env, only : R8P=>real64
    use forbear, only : bar_object
    implicit none
    type(bar_object) :: bar
    integer          :: step

    call bar%initialize(theme='vfd', prefix_string='march ', bar_zones='0.75:#2EF5C0 0.9:#FFB000 1:#FF3B30', &
                        add_progress_percent=.true., add_eta=.true., max_value=50._R8P)
    call bar%start
    do step = 1, 50
       ! ... one time step of your solver (the actual hard part, not included) ...
       call bar%update(current=real(step, R8P))
    enddo
    endprogram march

The gallery shows every kind of output forbear draws, each the real output of a compiled program, no mock-ups: forbear. There is also a tutorial (11 chapters) and a cookbook (33 recipes), for the three people who read documentation.

forbear builds with FoBiS or fpm (its only dependency, FACE, is fetched for you), is tested with GNU gfortran, NVIDIA nvfortran and Intel ifx, and is multi-licensed (GPL v3, BSD 2-Clause, BSD 3-Clause, MIT).

Feedback, issues, and contributions are welcome.

Stefano

12 Likes