How does a target make Fortran work?

William Clodius w.clodius@icloud.com
Fri Jul 13 18:32:00 GMT 2018



> On Jul 13, 2018, at 7:36 AM, Janus Weil <janus@gcc.gnu.org> wrote:
> 
> <sni>
> A "kind" in Fortran is the size of the data type in bytes. E.g.
> "real(kind=4)" would be a 'single-precision' 32-bit float number,
> while "real(kind=8)" would be a 'double-precision' 64-bit float
> number. The default kind for REAL variables is 4 in gfortran, see:
> 
> https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gfortran/KIND-Type-Parameters.html
> 
> Since pdp-11 seems to be a 16-bit platform, such a 32-bit
> floating-point type might not be available there? Possibly it makes
> sense to set the default REAL kind to 2 for such a target?
> 
> Cheers,
> Janus

Not quite. The kind is a mapping of integer values to different implementations of fundamental types. In gfortran, and most other F90 compilers, this mapping usually corresponds to the size of the data in bytes, but the standard doesn’t require that and NAG, for example, doesn’t follow that mapping. The mapping to byte size can be inconvenient, for the implementor and user. What is the appropriate kind value for Intel’s extended precision that is nominally five bytes of information, but is normally stored in eight bytes of main memory. Suppose the system provided multiple implementations of four byte real precision, i.e.., a slow version that provides guaranteed bit accuracy on all operations, and a fast vectorized real that sacrifices accuracy on say the transcendentals, or that differ in their tradeoffs of exponent and precision range. The kind mechanism, in principle allows the user to have access to both types, but at least one of them would have to have a kind value that differs from its byte size.


More information about the Fortran mailing list