On Wed, 20 Sep 2000, Peter Shenkin wrote:
> Hi,
>
> It is common to have code like the following, where accumulation
> is into a DP variable:
>
> REAL :: x( 100 )
> DOUBLE PRECISION :: sumx
> INTEGER i
>
> ...
>
> sum = 0
> DO i = 1, 100
> sumx = sumx + x( i )
> END DO
>
>
> One is tempted to preplace the DO loop with the F90 statement:
>
> sumx = sum( x )
>
> However, AFAIK, the summation will then be done in single precision.
>
> Is this correct? If so, I guess I still have to use the
> DO loop. :-)
How about sumx = sum( real( x, kind(0d0) ) )
Wes
Dr. W. J. Metzger Experimental High Energy Physics Group
tel. +31-24-3653127 Faculty of Natural Sciences
+31-24-3652099 (secr.) University of Nijmegen
fax. +31-24-3652191 Toernooiveld 1
telex 48228 wina nl 6525 ED Nijmegen, The Netherlands
e-mail: [log in to unmask] or [log in to unmask]
http://home.cern.ch/metzger/ or http://www.hef.kun.nl/~wes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|