Debian Codegraph @

Tests/FindOpenMP/Test/scaltest.f90.in

raw
1 program scaltest
2 use iso_c_binding
3 implicit none
4 interface
5 subroutine scalprod(n, x_p, y_p, res) bind(c)
6 use iso_c_binding
7 integer(c_int), value :: n
8 type(c_ptr), value :: x_p, y_p
9 real(c_double) :: res
10 end subroutine scalprod
11 end interface
12 type(c_ptr) :: x_pt, y_pt
13 real(c_double), dimension(5), target :: a = (/ 1, 2, 3, 4, 5 /)
14 real(c_double), dimension(5), target :: b = (/ 2, 3, 4, 5, 6 /)
15 integer(c_int) :: n = size(a)
16 real(c_double) :: res
17 x_pt = c_loc(a)
18 y_pt = c_loc(b)
19 call scalprod(n, x_pt, y_pt, res)
20 print *, res
21 end program scaltest