Debian Codegraph @

Tests/FindOpenMP/Test/scalprod.f90.in

raw
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
9 real(c_double) :: res
10 real(c_double) :: scalpt = 0
11 call c_f_pointer(x_p, x, shape=[n])
12 call c_f_pointer(y_p, y, shape=[n])
13 res = 0
14 !$omp parallel do private(scalpt), reduction(+:res)
15 do i=1,n
16 scalpt = y(i) * x(i)
17 res = res + scalpt
18 end do
19 end subroutine scalprod