Re: allocating arrays, trouble



In article <1196076343_6793@xxxxxxxxxxxxxxxxxxxxx>,
Wade Ward <wade@xxxxxxxxxxx> wrote:

real(kind=kind(1.0d00))
^^^^^^^^^^^ whoops, mpj

Unwhoops. That's perfectly legal. Two different meanings of "kind" are
in use there. This sort of thing is not unusual. After all, "*" has
seven different meanings in these two statements:
character c(*)*(*)
write(*,*) 'a*b =',a*b

If you've taken precautions to portablt get yourself to dp, what do
you have to do to get to quad p?

One way to ask for precision at least twice that of double:

INTEGER,PARAMETER::dp=kind(1d0),qp=selected_real_kind(precision(1d0)*2)
REAL(dp):: xdouble
REAL(qp):: xquad

But in some systems it's not available, so qp < 0, so REAL(qp) fails.
I use compilers both with and without quad precision, and I like to
have a high precision hp that's qp if available, dp if not. The merge
intrinsic could be used to get it in f2003, but not in f95 when
defining a parameter. One well-known method that does work in f95 is

INTEGER,PARAMETER:: hp = qp*(1+sign(1,qp))/2 + dp*(1-sign(1,qp))/2

Some systems don't have quad precision as defined above but do have a
precision higher than dp. On those, you could change *2 to +2, or even
define some more INTEGER,PARAMETERs to deal with every possible case.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.



Relevant Pages

  • Re: Timing function call
    ... A note of caution if you want to use ns precision: ... "One should not use Elapsed.Ticks to calculate the elapsed time in ... The only correct way to get this high precision count is by using ... meanings. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Down with the strong 2C
    ... have two meanings, either the usual or any hand that you want to make ... If you want a forcing 1C opening, what's wrong with Precision? ...
    (rec.games.bridge)
  • Re: How to initialise arrays to zero?
    ... IMPLICIT DOUBLE PRECISION ... This gives an error when compiling with f95 NAG ...
    (comp.lang.fortran)
  • Re: What do you prefer: real(8) or double precision and why?
    ... > I have needed quad precision to test some stuff on the supercomputah here. ... of the non linear equation solver very badly conditioned. ...
    (comp.lang.fortran)
  • named constants vs. literal constants
    ... construct with a CASE construct in the move from F77 to F95.) ... DOUBLE PRECISION:: X ... assignment with that during expression evaluation, ... This means that named constants ARE a good idea, ...
    (comp.lang.fortran)