On Thu, 2006-01-12 at 09:11 -0500, Dan Nagle wrote:
> In fact, DOUBLE PRECISION is _not_ portable, as it means 64 bit real
> on some systems, and 128 bit real on others for example.
... and default REAL means 32-bit real on some systems and 64-bit real
on other.
That is to say, DOUBLE PRECISION is exactly as portable as default REAL.
The precision and range of either one are processor dependent.
If you have a scientific, engineering, mathematical... problem that
requires a particular precision and range, use SELECTED_REAL_KIND to
choose the correct kind (hoping the processor has one that meets your
needs).
If you're writing a library, develop the procedure in a precision-
independent way, and parameterize its REAL data objects using a kind
type parameter. Put everything but the subprogram header, kind type
parameter definition and END statement into a file. Then, twice, in a
module, write subprograms consisting of a subprogram header, the
definition of the kind type parameter, an INCLUDE for the above-
described file, and an END statement. You can put the declarations for
the arguments either below the subprogram headers, or in the include
file, according to your taste. In one subprogram, define the parameter
for the body as KIND(1.0) and in the other as KIND(1.0d0). Then glue
those two procedures together into a single generic. The processor will
choose the correct one when the generic is invoked with arguments whose
kinds are chosen for a particular problem, using SELECTED_REAL_KIND as
described in the previous paragraph.
--
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, Frederick Gregory, George Bush, or anybody else.
|