Fortran (progress) B(e)ar environment.
The
eis mute: say forbar.
- Documentation: forbear
- GitHub: GitHub - szaghi/forbear: Fortran (progress) B(e)ar environment · GitHub
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).

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.

- 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 dangerousbar_profile='ramp': blocks rising from 1/8 to full height, as the tachometer of a car you could not afford in 1985pulse_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 backdigits='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%writeprints above the running bar,update(message=)shows your residual at its end,suspend/resumelet 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
finishfor 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 withFORBEAR_DISABLE=1ordisabled=(rank /= 0), so that 4096 MPI ranks do not all draw the same bar on the same line -
and much more…

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