For example, if I make these definitions:
Real, parameter :: No_01 = 2.34
Real, parameter :: No_02 = 34.56
and I want to write these variables with F
format in this way:
Character(*), parameter :: FMT_01 = '(2x,F4.2)'
Character(*), parameter :: FMT_02 = '(2x,F5.2)'
The result of writing to screen would be:
Write(*, FMT_01 ) NO_01 => 2.34
Write(*, FMT_02 ) NO_02 => 34.56
Is there any kind of F
format which can be used for geting this result of writing instead:
Result is:
!Correct result !Not correct result
002.340 Something 2.340 Something
034.560 Something 34.560 Something
The answers to How to pad floating point output with leading zeros? are not applicable, because the values can be negative.