File: bindc_02b.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (59 lines) | stat: -rw-r--r-- 1,660 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module bindc_02b
use iso_c_binding, only: c_ptr, c_int
implicit none

interface
    ! void driver();
    subroutine driver() bind(c)
    end subroutine

    ! void print_ptr1(int n, float *A);
    subroutine print_ptr1(n, A) bind(c)
    import :: c_ptr, c_int
    integer(c_int), value, intent(in) :: n
    type(c_ptr), value, intent(in) :: A
    end subroutine

    ! void print_ptr2(int *n, float *A);
    subroutine print_ptr2(n, A) bind(c)
    import :: c_ptr, c_int
    integer(c_int), intent(in) :: n
    type(c_ptr), value, intent(in) :: A
    end subroutine
end interface

contains

    ! void callback1(int n, float *A);
    subroutine callback1(n, A) bind(c)
    integer(c_int), value, intent(in) :: n
    type(c_ptr), value, intent(in) :: A
    print *, "callback1: calling print_ptr1(n, A), n =", n
    call print_ptr1(n, A)
    end subroutine

    ! void callback1b(int n, float *A);
    subroutine callback1b(n, A) bind(c)
    integer(c_int), value, intent(in) :: n
    type(c_ptr), value, intent(in) :: A
    print *, "callback1b: calling print_ptr2(n, A), n =", n
    call print_ptr2(n, A)
    end subroutine

    ! void callback2(int *n, float *A);
    subroutine callback2(n, A) bind(c)
    integer(c_int), intent(in) :: n
    type(c_ptr), value, intent(in) :: A
    print *, "callback2: calling print_ptr2(n, A), n =", n
    call print_ptr2(n, A)
    end subroutine

    ! void callback2b(int *n, float *A);
    subroutine callback2b(n, A) bind(c)
    integer(c_int), intent(in) :: n
    type(c_ptr), value, intent(in) :: A
    print *, "callback2b: calling print_ptr1(n, A), n =", n
    call print_ptr1(n, A)
    end subroutine

end module