* add.f - compensated addition by the Kahan algorithm
SUBROUTINE ADD (X, N, R)
IMPLICIT NONE
INTEGER N
REAL X, R
DIMENSION X(N)
INTEGER K
DOUBLE PRECISION S, C, Y, T
S = 0.
C = 0.
DO K = 1, N
Y = X(K) - C
T = S + Y
C = (T - S) - Y
S = T
END DO
R = SNGL(S)
RETURN
END ! of file add.f