Alvaro Fernandez <[log in to unmask]> wrote:
> .... (The trick is that I _never_ overload based
> on kind - too easy to create ambiguities.) ....
It's trivial to avoid ambiguities. The standard requires that default
real and double precision are different kinds. So I write a real version
and a double precision version of each library procedure, and glue them
together to make a generic. I use kind(0.0e0) and kind(0.0d0) to get
the kind numbers, and then frequently use "include" so as not to need to
write the body twice.
I agree that trying to do generic resolution based on selected_real_kind
is an invitation to portability problems. Therefore I **never** use
selected_real_kind to get the kind numbers for generic resolution,
because selected_real_kind(6) and selected_real_kind(12) might be the
same kind. That's the source of the ambiguity that may be the one Alvaro
is trying to avoid.
If the program author specifies kinds by reference to precision
requirements, which are in turn derived from physical properties of the
problem at hand, there may be variables that are the same kind on some
platform, and different kind on another platform, but the processor
ultimately can figure out which one of a single/double generic to use.
--
Van Snyder | What fraction of Americans believe
[log in to unmask] | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.
|