Len Makin wrote:
> Fortran 90/95 has introduced KIND=n for characters, but as for INTEGER,
> REAL etc. has avoided pinning down a particular KIND to a particular
> representation - it's all compiler/machine dependent, hence making
> every program that uses KIND non-portable....
Using KIND doesn't necessarily make programs non-portable. Quite the
opposite, it makes them portable, if you use KIND correctly. What
makes programs non-portable is using constants for KIND values. If
I use the inquiry functions, I get portability. If I use
SELECTED_REAL_KIND(14), I get single precision on my 64-bit
workstation, and double precision on my 32-bit PC. On the other
hand, if I use KIND=4, who knows what I get?
I develop my math library software using REAL and DOUBLE PRECISION. In
each procedure, I use inquiry functions to discover round-off, overflow,
underflow, as necessary, and the procedure adapts its internal parameters
to the machine characteristics. I put the procedures together into
a generic. In my applications, I use SELECTED_REAL_KIND, and let
the compiler choose whether to call the REAL or DOUBLE PRECISION
library code. That's pretty good portability.
Best regards,
Van Snyder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|