foresight_readout
foresight_readout, seven-segment readouts: the glass a printf format defines and the segments a value lights on it.
A readout shows one number (the last finite value of a series) on a fixed-segment display, as the digital clusters of 1980s cars: every cell of the glass is always there, the value only lights some of its segments. The glass is therefore decided by the format, never by the value: %9.2e makes 8 cells (the decimal point is a segment of the cell before it, as on real displays), and it keeps that width whatever the value, so a watched readout never jumps.
A cell is a bit mask: bits 0 to 6 the segments a (top), b (top right), c (bottom right), d (bottom), e (bottom left), f (top left), g (middle), bit 7 (SEGMENT_DP) the decimal point. A value with no finite reading, or wider than the glass (printf would widen the field), lights the middle segment of every cell: dashes, never truncated digits. The text around the conversion ('%5.2f h') is not on the glass: it is the printed unit beside it.
Source: src/lib/foresight_readout.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
DEFAULT_READOUT_FORMAT | character(len=*) | parameter | Format of a readout without one: any magnitude. |
SEGMENT_DP | integer(kind=I4P) | parameter | Bit of the decimal point. |
SEGMENT_MIDDLE | integer(kind=I4P) | parameter | Mask of the middle segment g alone: a dash. |
DIGITS | integer(kind=I4P) | parameter | Masks of the digits 0..9. |
LETTER_E | integer(kind=I4P) | parameter | Mask of E: segments a, d, e, f, g. |
Subroutines
readout_glass
Cells of the glass of the readout format (see readout_check), lit by value; prefix and suffix are the text around the conversion, printed beside the glass.
Attributes: pure
subroutine readout_glass(format, value, masks, prefix, suffix)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
format | character(len=*) | in | Readout format. | |
value | real(kind=R8P) | in | Value shown; not finite for none. | |
masks | integer(kind=I4P) | out | allocatable | Segments of each cell, left to right. |
prefix | character(len=:) | out | allocatable | Text before the glass. |
suffix | character(len=:) | out | allocatable | Text after the glass. |
Call graph
Functions
readout_check
Empty if format is a readout format: a tick format (see foresight_format format_check) with a field width, which fixes the glass, and not %h, whose superscript has no seven-segment form.
Attributes: pure
Returns: character(len=:)
function readout_check(format) result(message)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
format | character(len=*) | in | Format. |
Call graph
last_finite
Last finite element of y, NaN if none: the reading of a readout.
Attributes: pure
Returns: real(kind=R8P)
function last_finite(y) result(value)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
y | real(kind=R8P) | in | Series ordinates. |
Call graph
glass_cells
Cells of the glass of a conversion: its field width, less the decimal point that f and e always print with a non-zero precision (it lights a segment of a cell); g may print one or not, the spare cell stays blank.
Attributes: pure
Returns: integer(kind=I4P)
function glass_cells(width, prec, type) result(cells)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
width | integer(kind=I4P) | in | Field width. | |
prec | integer(kind=I4P) | in | Precision, -1 if absent (6). | |
type | character(len=1) | in | Conversion type. |
Call graph
glyph
Segments lit by the character c of a formatted number: a digit, - (the middle segment), e or E; blanks and + (an exponent sign) light none, keeping e+02 and e-02 on the same cells.
Attributes: elemental
Returns: integer(kind=I4P)
function glyph(c) result(mask)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
c | character(len=1) | in | Character. |
Call graph