Shouldn’t 1_10 be accepted like the rest ones ie 1_4, 1_8, 1_16 in which 1 is in integer form and not in decimal form 1.? If not, please provide a documentation link which justifies this small inconsistency.
This is a common mistake, even among experienced programmers. It sometimes doesn’t matter because the integer is converted to a real anyway, just not in the straightforward way that the programmer intended. Some compilers have separate KIND values for integers and reals, so the compiler can catch the mistake.
I thought that semantics/notation _n was interpreted based, at first, on real declaration. On the contrary, it is interpreted on the previous number type and next is coerced to a real number. I hope there is a point in the documentation which clarifies this detail (X_n = X(kind=n)).
In this Fortran statement,
“1_4” is an integer constant “1” whose kind attribute is kind=4
“r4” is a real variable, whose kind attribute is kind=4, from the declaration.
The properties of “1_4” are not affected by “r4”.
Using gfortran, a real kind=10 is different, as it refers to an 80-bit real format, which is stored in a 128 bit (16 byte) storage allocation. This is different to the real*10 format associated with a Win-32 8087 register.
Indeed, it’s confusing and the compilers could potentially warn about some such usage that is almost always a bug in the code that we would prefer for compilers to point out.