da_dot.inc
References to this file elsewhere.
1 real function da_dot(n,x,y)
2
3 !-----------------------------------------------------------------------
4 ! Purpose: forms the dot product of two vectors.
5 ! uses unrolled loops for increments equal to one.
6 !-----------------------------------------------------------------------
7
8 implicit none
9
10 integer, intent(in) :: n
11 real, dimension(n), intent(in) :: x,y
12
13 real dtemp1
14 integer i,m,mp1
15
16 da_dot = 0.0
17 if (n <= 0)return
18 dtemp1 = 0.0
19
20 ! code for both increments equal to 1
21
22 if (n > 0) then
23 m = mod(n,5)
24 if (m /= 0) then
25 do i = 1,m
26 dtemp1 = dtemp1 + x(i)*y(i)
27 end do
28 end if
29 if (n >= 5) then
30 mp1 = m + 1
31 do i = mp1,n,5
32 dtemp1 = dtemp1 + x(i )*y(i ) + x(i + 1)*y(i + 1) + &
33 x(i + 2)*y(i + 2) + x(i + 3)*y(i + 3) + &
34 x(i + 4)*y(i + 4)
35 end do
36 end if
37 end if
38
39 da_dot = dtemp1
40
41 end function da_dot
42
43