The TELEMAC-MASCARET system  trunk
sumtwo.f
Go to the documentation of this file.
1 ! ******************
2  SUBROUTINE sumtwo
3 ! ******************
4 !
5  &(n,p,res)
6 !
7 !***********************************************************************
8 ! PARALLEL V7P3 24/02/2016
9 !***********************************************************************
10 !
11 !brief CALCULATE A COMPENSATED SUM OF A VECTOR.
12 !
13 !history R.NHEILI (Univerte de Perpignan, DALI)
14 !+ 24/02/2016
15 !+ V7P3
16 !
17 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 !| N |-->| INTEGER VECTOR SIZE
19 !| P |-->| DOUBLE PRECISION VECTOR
20 !| Y |<--| DOUBLE PRECISION VECTOR RESULT
21 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 !
24  IMPLICIT NONE
25 !
26 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 !
28  INTEGER ,INTENT(IN) ::n
29  DOUBLE PRECISION, INTENT(IN) :: p(n)
30  DOUBLE PRECISION, INTENT(OUT) :: res
31 !
32 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 !
34  DOUBLE PRECISION r(n)
35  DOUBLE PRECISION tmp, tmp2
36  INTEGER i
37 !
38 !-----------------------------------------------------------------------
39 !
40  res=0.d0
41  r=p
42  DO i = 2 , n
43  tmp = r(i)
44  tmp2 = r(i-1)
45  CALL twosum1(tmp,r(i-1),r(i),tmp2)
46  END DO
47  DO i = 1 , n-1
48  res=res+r(i)
49  END DO
50  res=res+r(n)
51 !
52 !
53 !-----------------------------------------------------------------------
54 !
55  END
56  SUBROUTINE twosum1(A,B,X,Y)
57 
58  DOUBLE PRECISION, INTENT(IN) :: a,b
59  DOUBLE PRECISION, INTENT(OUT) :: x,y
60  DOUBLE PRECISION z, xout
61  xout=a+b
62  z=xout-a
63  y=(a-(xout-z))+(b-z)
64  x = xout
65 
66  END