And for 60 years the results from those codes have been consistently wrong.
I think you are missing my point.
Try this program.
Program ar
USE ISO_FORTRAN_ENV, ONLY: WP=>REAL64
Implicit NONE
Real(WP) :: a(4), b(4), c(4)
a = [Real(WP) :: 1, 2, 3.14, 4]
b = [1.0_WP, 2.0_WP, 3.14_WP, 4.0_WP]
c = [Real(WP) :: 1, 2, 3.14_WP, 4]
Print *,' a = ', a
Print *,' b = ', b
Print *,' c = ', c
Stop
End Program ar
On my Linux system I get the following results for ifx, gfortran-13 and nvfortran
ifx
a = 1.00000000000000 2.00000000000000 3.14000010490417
4.00000000000000
b = 1.00000000000000 2.00000000000000 3.14000000000000
4.00000000000000
c = 1.00000000000000 2.00000000000000 3.14000000000000
4.00000000000000
gfortran-13
a = 1.0000000000000000 2.0000000000000000 3.1400001049041748 4.0000000000000000
b = 1.0000000000000000 2.0000000000000000 3.1400000000000001 4.0000000000000000
c = 1.0000000000000000 2.0000000000000000 3.1400000000000001 4.0000000000000000
nvfortran
a = 1.000000000000000 2.000000000000000
3.140000104904175 4.000000000000000
b = 1.000000000000000 2.000000000000000
3.140000000000000 4.000000000000000
c = 1.000000000000000 2.000000000000000
3.140000000000000 4.000000000000000
If I want 3.14 to be exactly 3.14 I’m left with doing either b or c. My point is using the type spec as in a I should not have to append _WP to 3.14 to get exactly 3.14. To me this is a flaw in the language irrespective if its been that way for 60 years. Say you have a large table of 100 values that you wish to save as a REAL(REAL64) array. Why should I have to append _WP on each of the 100 values. I’ve tried doing this with something like
Real(REAL64), Parameter :: a(100) = REAL([1,2.4,6.....etc],WP)
but that also can get to be a little unwieldy. Using the type-spec as in a and getting exactly the precision you specify in terms of number of decimal digits should not be a big thing to implement and since the [type-spec :: ac-values] form of the array constructor is a new feature in the language (if you consider something 20 years old new) it should not effect legacy code.