I'm having a hard time wrapping my head around formatting statements in Fortran.
Without formatting my output, this is what I do (inside a loop, so this happens a few times):
write(*,*) t*1E9
t
here is real*8
. The output is just what I'd expect - increments of 0.1, with some rounding errors:
0.0000000000000000
0.10000000000000001
0.20000000000000001
0.29999999999999999
0.40000000000000002
0.50000000000000000
0.59999999999999998
0.69999999999999996
0.79999999999999993
0.89999999999999991
0.99999999999999989
Now, I try to add a format statement:
write(*, '(F1.2)') t*1E9
and (with everything else the same) instead I get only asterisks in my output:
**
**
(etc...)
I've tried to read up on how this should work, and I can't figure out why this is happening. I've tried formats with more space for digits (F15.15
just gives me more asterisks per line), I've tried moving the format statement to its own, labelled line... I just can't seem to get the output I'd like.
What am I missing here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…