io - Fortran splats my output to asterisks - why? -
i'm having hard time wrapping head around formatting statements in fortran.
without formatting output, (inside loop, happens few times):
write(*,*) t*1e9 t here real*8. output i'd expect - increments of 0.1, 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, try add format statement:
write(*, '(f1.2)') t*1e9 and (with else same) instead asterisks in output:
** ** (etc...) i've tried read on how should work, , can't figure out why happening. i've tried formats more space digits (f15.15 gives me more asterisks per line), i've tried moving format statement own, labelled line... can't seem output i'd like.
what missing here?
fortran format statements defined as:
fw.d, w number of characters used in total, , d number of characters after decimal point. here telling need float, 1 character wide in total, , 2 characters after decimal point, not correct. get, example, float 4 characters in total, 3 decimal places, you'd write:
write(*, '(f4.3)') t*1e9 see http://www.cs.mtu.edu/~shene/courses/cs201/notes/chap05/format.html
also, should mention asterisks indicative number cannot displayed in format stated.
edit:
adding in comment george below:
"for e format fieldwidth has @ least 7 more number of decimals, eg e15.8. 4 exponent, 2 lead 0. 1 possible '-'. add 1 more space numbers don't run together, e16.8"
Comments
Post a Comment