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,    intent(in) :: x(n)
12    real,    intent(in) :: y(n)
13 
14    real    :: dtemp1
15    integer :: i,m,mp1
16 
17    da_dot = 0.0
18    if (n <= 0) return
19 
20    if (trace_use) call da_trace_entry("da_dot")    
21 
22    dtemp1 = 0.0
23 
24    ! code for both increments equal to 1
25 
26    if (n > 0) then
27       m = mod(n,5)
28       if (m /= 0) then
29          do i = 1,m
30             dtemp1 = dtemp1 + x(i)*y(i)
31          end do
32       end if
33       if (n >= 5) then
34          mp1 = m + 1
35          do i = mp1,n,5
36             dtemp1 = dtemp1 + x(i   )*y(i   ) + x(i + 1)*y(i + 1) + &
37                               x(i + 2)*y(i + 2) + x(i + 3)*y(i + 3) + &
38                               x(i + 4)*y(i + 4)
39          end do
40       end if
41    end if
42 
43    da_dot = dtemp1
44 
45    if (trace_use) call da_trace_exit("da_dot")    
46 
47 
48 end function da_dot
49 
50