8. Batch jobs and logs

march will also run as a batch job, its output written to a log file: there, a bar that redraws its line would leave every frame in the file, carriage returns and escape sequences included. forbear knows where it writes:
call bar%initialize(prefix_string='march ', bracket_left_string='[', bracket_right_string=']', &
filled_char_string='#', empty_char_string='.', add_progress_percent=.true.,&
add_progress_count=.true., add_eta=.true., add_summary=.true., &
progress_percent_color_fg='yellow', eta_color_fg='blue', &
width=30, max_value=real(steps, R8P))On a terminal:
$ march
march [##############################] 100% 50/50 ETA hh:mm:ss
[done in n.nn s, nn.nn/s]
march: doneWith the output sent to a file:
$ march > run.log; cat run.log
march [..............................] 0% 0/50 ETA --:--:--
march [###...........................] 10% 5/50 ETA hh:mm:ss
march [######........................] 20% 10/50 ETA hh:mm:ss
march [#########.....................] 30% 15/50 ETA hh:mm:ss
march [############..................] 40% 20/50 ETA hh:mm:ss
march [###############...............] 50% 25/50 ETA hh:mm:ss
march [##################............] 60% 30/50 ETA hh:mm:ss
march [#####################.........] 70% 35/50 ETA hh:mm:ss
march [########################......] 80% 40/50 ETA hh:mm:ss
march [###########################...] 90% 45/50 ETA hh:mm:ss
march [##############################] 100% 50/50 ETA hh:mm:ss
[done in n.nn s, nn.nn/s]
march: doneinitializelooks at the unit of the bar: when it is the standard output or error and that is a terminal, the bar is interactive, and animates; otherwise it writes a plain line at every 10% (at everyfrequency% if larger than 1), with no colours, no carriage returns and no escape sequences, then the date and time and the summary lines. The same program, the same calls, a readable log.interactive=.true.or.false.forces either mode; the environment variableFORBEAR_INTERACTIVE=1or0does the same for every bar, when the keyword is not passed.- Bars below the current line (
positionlarger than 0) write nothing in a log.
Signs of life in long jobs
A line every 10% is a fine log for a job of an hour; for a job of two days, ten lines leave hours of silence, and an indeterminate bar writes nothing between its first and last lines. log_interval adds a line whenever that many seconds have passed since the last one:
call bar%initialize(template='solve {count} iterations, {elapsed} elapsed', indeterminate=.true., &
log_interval=0.3_R8P) ! in a log, a line at least every 0.3 s (in a real job: minutes)$ march > run.log; cat run.log
solve 0 iterations, hh:mm:ss elapsed
solve 2 iterations, hh:mm:ss elapsed
solve 4 iterations, hh:mm:ss elapsed
solve 6 iterations, hh:mm:ss elapsed
solve 8 iterations, hh:mm:ss elapsed
solve 10 iterations, hh:mm:ss elapsedEach iteration of this solver takes 0.2 s: a line every 0.3 s comes every other iteration. In a real job, log_interval=600 gives a line every ten minutes; FORBEAR_LOG_INTERVAL=600 in the job script does it for every bar, without recompiling. On a terminal, log_interval does nothing.
Turning the bars off
disabled=.true. turns a bar off: start and update draw nothing, write still prints its lines. The environment variable FORBEAR_DISABLE=1 turns every bar of the program off, without recompiling:
$ FORBEAR_DISABLE=1 march
march: doneUnder MPI every process would draw its own bar on the same terminal: draw the bar of one process only,
call bar%initialize(max_value=real(steps, R8P), disabled=(rank /= 0)) ! rank from MPI_Comm_rankWhat you learned
Interactive and log modes, log_interval, interactive, disabled, the FORBEAR_* environment variables, one bar under MPI. Reference: Terminals and logs.
Next: 9. Layout templates.