Right - it is ugly. I was giving one of the situations where I find the
current "kind" system both useful and reasonable, and was partially
answering my own rhetorical question about when 32 vs 64 bit reals were
needed (in my case, I was actually trying to _avoid_ them.) My point is, all
I had to use for my use of kind was kind(1.0e0) and kind(1.0d0), not
selected_real_kind(#,#).
In my experience, aside from the Cray situation, I don't find much use for
different real kinds within the same code; they complicate interfaces,
complicate maintenance, create "ambiguities", and, most importantly,
generally create the false impression that you have more control over the
precision of your numbers than you really have. It's very misleading IMHO.
Just about every Fortran processor that I know has only two or three
possible kinds of reals - "default", "double", and maybe "quad". You can put
any numbers you want into selected_real_kind(), but if those numbers don't
map to one of those two or three possibilities, you either get the "closest"
one, or a kind of -1, which usually isn't signaled and leads to obscure
bugs.
Parameterizing the kinds is still a good idea; I just don't like the idea of
compiler switches. Maybe the best "fix" for kinds is to create something
like an enumerated type with the kinds for the particular processor, and
leave it at that? This should be trivial with proposed F2K syntax.
Alvaro
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of
Greg Lindahl
Sent: Tuesday, March 16, 2004 12:12 AM
To: [log in to unmask]
Subject: Re: configurable default real
On Mon, Mar 15, 2004 at 01:47:42PM -0600, Alvaro Fernandez wrote:
> The trick was that single precision reals were supported in hardware on
the
> Cray, whereas double precision were software implemented (at least when I
> dealt with them). If you just copied and recompiled your Sun code on the
> Cray, "double precision" would be the equivalent of quad precision w.r.t.
> the Sun - usually overkill for most applications,
I'd imagine that the Cray compiler has always had a "ignore double
precision, always use single precision" flag for exactly this reason.
I haven't used Crays before 1989, though.
In new-style code, the alleged way to do this is with kinds. Which is
the point of the current discussion, that that's ugly.
-- greg
|