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