private pure function pad(value, width) result(text)
value in decimal, zero filled on the left to width characters.
A value too wide to fit is not truncated; the field simply grows.
A negative value keeps its sign at the front: zero filling the text
of -5 to four characters gives 00-5, which is not a number. The
digits are padded to width and the sign prepended, so the answer is
-0005 – sign plus four digits, which is what ISO 8601 asks for in
an expanded year.
The sign is removed from the text rather than by negating value,
because negating the most negative value of a kind is signed
overflow.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Source Code
pure function pad(value,width)result(text)!! `value` in decimal, zero filled on the left to `width` characters.!! A value too wide to fit is not truncated; the field simply grows.!!!! A negative value keeps its sign at the front: zero filling the text!! of `-5` to four characters gives `00-5`, which is not a number. The!! digits are padded to `width` and the sign prepended, so the answer is!! `-0005` -- sign plus four digits, which is what ISO 8601 asks for in!! an expanded year.!!!! The sign is removed from the text rather than by negating `value`,!! because negating the most negative value of a kind is signed!! overflow.integer(default_int),intent(in)::valueinteger,intent(in)::widthcharacter(len=:),allocatable::texttext=to_string(value)if(value<0_default_int)thentext="-"//zfill(text(2:),width)elsetext=zfill(text,width)end if end function pad