Re: busting sp datatypes



Ron Ford wrote:

It's been a while since I've turned a program from sp to dp, and I wanted
to check my premises. First, does this
INTEGER, PARAMETER :: DP = KIND(1.0D0) ! define DP

yes, as an appropriate KIND for REAL variables.

give dp for all of the following:
integer(kind=dp), parameter:: trials = 300000
integer (kind=dp), dimension(trials)::F

No, DP (or dp) should not be used for integer
variables and parameters.

real (kind=dp):: harvest, tot, t1, t2, diff, t3, t4

Yes, like that.
(snip)

Third, the strategy whereby I turn *everything* dp seems to be a real
loser. What is a portable way to declare an sp integer?

It would be rare that you would need to change both
INTEGER and REAL variables to double precision at the
same time. The one case I can think of, is with
EQUIVALENCE or COMMON if you needed them to always
be the same size.

KIND(0) will be the appropriate KIND for default
(single precision) integer. (Though integer data is
not usually described as single and double precision.)

There may not be a standard way to generate a double
length integer variable.

-- glen


.



Relevant Pages

  • Re: increasing width
    ... Some fellow over in sci.math.num-analysis tells me I can get at least 6 more sig figs, if instead of declaring as type real, I declare as real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: increasing width
    ... which I get every time I want to declare real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: BLAS: dgemm
    ... to a procedure requiring double precision data, ... be 'single precision correct' instead of 'double precision correct'. ... Where is the compiler supposed to get ...
    (comp.lang.fortran)
  • Re: double confusion
    ... Modules that came in in Fortran 90, where you can just declare things "once at ... precision, but not for integer or real ... ... This reflects the implicit Typing of the languages - in C functions return ... Thus you must declare all double precision variables. ...
    (comp.lang.fortran)
  • Re: Singles to Doubles
    ... of the original code difference between direct promotion as opposed to ... Double you would have gotten full precision to start with... ... You have successfully read the existing single precision data directly ...
    (microsoft.public.vb.general.discussion)