I have an array xsolar
containing double precision real values:
real*8 xsolar(5)
The array is then filled with numbers using the data
statement:
data xsolar/
. 12.00, 10.93, 1.05, 1.38, 2.70/
By default it looks like the numbers only set the most significant bytes, while the remaining bytes contain random numbers:
12.000000000000000
10.930000305175781
1.0499999523162842
1.3799999952316284
2.7000000476837158
I can fix this problem by writing d0
at the end of the numbers:
data xsolar/
* 12.00d0, 10.93d0, 1.05d0, 1.38d0, 2.70d0/
which will result in much better precision:
12.000000000000000
10.930000000000000
1.0500000000000000
1.3799999999999999
2.7000000000000002
My problem is that I have a huge list of numbers, not just five. So I have to add d0
to all of them. Can it be done automatically, so all constants in this data statement are treated as if they end with d0
? Better yet, can it be done for all my data statements or all real*8
constants?
I'm compiling with gfortran 6.3.0 with flags: -O4 -ffixed-line-length-72 -ff2c
.