Phillip Helbig wrote:
>
> Nice post by Richard. Just two comments/questions.
>
> I think it makes code less readable to specify kind values on literals.
> It would be nice to be able to alter the default kind for literals
> within a scoping unit.
>
> Many folks have the impression that DOUBLE PRECISION has been superseded
> by the KIND mechanism. Sure, KIND can do more stuff, but am I mistaken
> that there are some applications where the RELATIVE precisions are more
> important? For example, some subroutine deep down might want to use
> higher precision than the stuff the user is interfacing with,
> independent of the actual precisions involved.
I agree you can need a relative double precision and that
A solution should be to use :
integer, parameter :: digits = 10 ! my regular precision
integer, parameter :: R1 = selected_real_kind(digits)
integer, parameter :: R2 = selected_real-kind(2*digits)
for portability, i think we should always use kind.
does someone known about a tool verifying we didn't forget any kind ?
> I think there is another issue involved here. Most folks don't know
> what precision they actually need. They try out something and it works.
> The problem is, what one gets is the smallest data type which complies
> with the constraints. Perhaps this is, say, 64 bits on one machine.
> Obviously, this might not work if a 32-bit type is available. So much
> for portability. In this example, REAL MIGHT suffer from the same
> problem (though note that the default size of REAL is not necessarily
> the same as "the number of bits the machine is"---it is on Cray, it
> isn't on VMS); my point is that KIND doesn't solve all portability
> problems.
i agree that the initial value 'digits' has to be chosen with care
and that the fact that it works on a machine doesn't assure portability.
on certain compilers, we can do several tries, adjusting the mantissa
lenght to determine a minimal portable value of 'digits' (option -t num
of the Cray f90 compiler).
in fact, it is not sufficient to make the code portable as the mantissa
lenght is not the only parameter (rounding modes...).
Pascal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|