I have a question about the formatting of integers in
When I have a line of code like
write(,) "number of differences = ",ndiff
write(*,’(a,i)’) "number of differences = ",ndiff
I find that the integer variable ndiff is formatted to something
like i12 or some really long width which doesn’t make the output
look too nice.
In this application, the value of “ndiff” can range over about 8 orders
of magnitude. Is there an easy way to have “ndiff” formatted so
its output width approximately matches its value, without having to
put in cascading if-else statements to check the order of magnitude
and then explicitly set the width based on the actual value of ndiff?
Thanks for any suggestions,