-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_example.f90
More file actions
37 lines (28 loc) · 876 Bytes
/
number_example.f90
File metadata and controls
37 lines (28 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module number_test
use iso_c_binding, only: c_int, c_float, c_double, c_double_complex
contains
subroutine num_addition(a, b, ans) bind(c, name="c_num_addition")
! pass by referrence, mixed types
integer(c_int), intent(in) :: a
real(c_double), intent(in) :: b
real(c_double), intent(out) :: ans
ans = a + b
end subroutine
subroutine num_multi(a, b, ans) bind(c, name="c_num_multi")
! pass by copy
real(c_double), intent(in), value :: a, b
real(c_double), intent(out) :: ans
ans = a * b
end subroutine
subroutine num_plus1(a) bind(c, name="c_num_plus1")
! in place operation
real(c_float), intent(inout) :: a
a = a + 1
end subroutine
function cplxdiv(u ,v) bind(c, name="c_cplxdiv")
! a function return a copy?
complex(c_double_complex), intent(in) :: u, v
complex(c_double_complex) :: cplxdiv
cplxdiv = u / v
end function
end module