dasum takes the sum of the absolute values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ip) | :: | n | ||||
real(kind=wp) | :: | dx(*) | ||||
integer(kind=ip) | :: | incx |
real(wp) function dasum(n,dx,incx) !! dasum takes the sum of the absolute values. integer(ip) :: incx,n real(wp) :: dx(*) real(wp) dtemp integer(ip) i,m,mp1,nincx dasum = 0.0_wp dtemp = 0.0_wp if (n<=0 .or. incx<=0) return if (incx==1) then ! code for increment equal to 1 ! clean-up loop m = mod(n,6) if (m/=0) then do i = 1,m dtemp = dtemp + abs(dx(i)) end do if (n<6) then dasum = dtemp return end if end if mp1 = m + 1 do i = mp1,n,6 dtemp = dtemp + abs(dx(i)) + abs(dx(i+1)) + & abs(dx(i+2)) + abs(dx(i+3)) + & abs(dx(i+4)) + abs(dx(i+5)) end do else ! code for increment not equal to 1 nincx = n*incx do i = 1,nincx,incx dtemp = dtemp + abs(dx(i)) end do end if dasum = dtemp end function dasum