scalprod.f90.in 543 B

12345678910111213141516171819
  1. subroutine scalprod(n, x_p, y_p, res) bind(c)
  2. use iso_c_binding
  3. implicit none
  4. integer(c_int), intent(in), value :: n
  5. type(c_ptr), intent(in), value :: x_p, y_p
  6. real(c_double), pointer :: x(:), y(:)
  7. integer :: i
  8. real(c_double) :: res
  9. real(c_double) :: scalpt = 0
  10. call c_f_pointer(x_p, x, shape=[n])
  11. call c_f_pointer(y_p, y, shape=[n])
  12. res = 0
  13. !$omp parallel do private(scalpt), reduction(+:res)
  14. do i=1,n
  15. scalpt = y(i) * x(i)
  16. res = res + scalpt
  17. end do
  18. end subroutine scalprod