That is why you should never use the literal KIND constant, neither in type declarations nor when specifying integer or real literal constants. You should always define a parameter, say
ik, and use that instead:
integer, parameter :: ik=...
integer(ik) :: ival
ival = 1234567890_ik
That general rule applies also to real KINDs. The main “gotcha” is when types and kinds are inadvertently mixed.
integer, parameter :: wp=selected_real_kind(14)
real(wp) :: x
x = 1234567890_wp
That looks like a real literal because of the
_wp KIND, but it isn’t, it is an integer literal. It is perfectly valid fortran, so the compiler does not know that you have made a mistake. This is the situation that the “unique” KIND convention avoids; in this case, the compiler can recognize the error at compile time.
The standard should have recomended that the prefered kind value should default to the byte size.
The standard is general in this respect, allowing for implementation on word addressable machines that do not even have bytes, many of which were in use in the 1980s when the KIND system was designed. Also, in the 1980s, there existed computers that supported more than one format in a given number of bytes. The VAX, for example, supported two different 8-byte floating point formats, each with different numbers of exponent and mantissa bits. [Ironically, an f90 compiler was never implemented on the VAX, the company went defunct first.]
Also, of course, the byte convention would have precluded the “unique” convention, which many programmers prefer.
I think the standard got this decision right.