9 use iso_c_binding
, only
: c_loc
, c_ptr
, c_bool
12 function my_c_loc1(x
) bind(C
)
15 type(c_ptr
) :: my_c_loc1
17 function my_c_loc2(x
) bind(C
)
20 type(c_ptr
) :: my_c_loc2
22 end interface my_c_loc
24 subroutine sub_scalar (arg1
, presnt
)
25 type(*), target
, optional
:: arg1
28 if (presnt
.neqv
. present (arg1
)) STOP 1
30 end subroutine sub_scalar
32 subroutine sub_array_shape (arg2
, lbounds
, ubounds
)
33 type(*), target
:: arg2(:,:)
35 integer :: lbounds(2), ubounds(2)
36 if (any (lbound(arg2
) /= lbounds
)) STOP 2
37 if (any (ubound(arg2
) /= ubounds
)) STOP 3
38 if (any (shape(arg2
) /= ubounds
-lbounds
+1)) STOP 4
39 if (size(arg2
) /= product (ubounds
-lbounds
+1)) STOP 5
40 if (rank (arg2
) /= 2) STOP 6
41 ! if (.not. is_continuous (arg2)) STOP 7 !<< Not yet implemented
42 ! cpt = c_loc (arg2) ! << FIXME: Valid since TS29113
43 call sub_array_assumed (arg2
)
44 end subroutine sub_array_shape
46 subroutine sub_array_assumed (arg3
)
47 type(*), target
:: arg3(*)
50 end subroutine sub_array_assumed
54 use iso_c_binding
, only
: c_int
, c_null_ptr
68 real, allocatable
:: scalar_real_alloc
69 character, pointer :: scalar_char_ptr
71 integer :: array_int(3)
72 real, allocatable
:: array_real_alloc(:,:)
73 character, pointer :: array_char_ptr(:,:)
76 type(t2
), allocatable
:: scalar_t2_alloc
77 type(t3
), pointer :: scalar_t3_ptr
79 type(t1
) :: array_t1(4)
80 type(t2
), allocatable
:: array_t2_alloc(:,:)
81 type(t3
), pointer :: array_t3_ptr(:,:)
83 class(t1
), allocatable
:: scalar_class_t1_alloc
84 class(t1
), pointer :: scalar_class_t1_ptr
86 class(t1
), allocatable
:: array_class_t1_alloc(:,:)
87 class(t1
), pointer :: array_class_t1_ptr(:,:)
89 scalar_char_ptr
=> null()
90 scalar_t3_ptr
=> null()
92 call sub_scalar (presnt
=.false
.)
93 call sub_scalar (scalar_real_alloc
, .false
.)
94 call sub_scalar (scalar_char_ptr
, .false
.)
95 call sub_scalar (null (), .false
.)
96 call sub_scalar (scalar_t2_alloc
, .false
.)
97 call sub_scalar (scalar_t3_ptr
, .false
.)
99 allocate (scalar_real_alloc
, scalar_char_ptr
, scalar_t3_ptr
)
100 allocate (scalar_class_t1_alloc
, scalar_class_t1_ptr
, scalar_t2_alloc
)
101 allocate (array_real_alloc(3:5,2:4), array_char_ptr(-2:2,2))
102 allocate (array_t2_alloc(3:5,2:4), array_t3_ptr(-2:2,2))
103 allocate (array_class_t1_alloc(3,3), array_class_t1_ptr(4,4))
105 call sub_scalar (scalar_int
, .true
.)
106 call sub_scalar (scalar_real_alloc
, .true
.)
107 call sub_scalar (scalar_char_ptr
, .true
.)
108 call sub_scalar (array_int(2), .true
.)
109 call sub_scalar (array_real_alloc(3,2), .true
.)
110 call sub_scalar (array_char_ptr(0,1), .true
.)
111 call sub_scalar (scalar_t1
, .true
.)
112 call sub_scalar (scalar_t2_alloc
, .true
.)
113 call sub_scalar (scalar_t3_ptr
, .true
.)
114 call sub_scalar (array_t1(2), .true
.)
115 call sub_scalar (array_t2_alloc(3,2), .true
.)
116 call sub_scalar (array_t3_ptr(0,1), .true
.)
117 call sub_scalar (array_class_t1_alloc(2,1), .true
.)
118 call sub_scalar (array_class_t1_ptr(3,3), .true
.)
120 call sub_array_assumed (array_int
)
121 call sub_array_assumed (array_real_alloc
)
122 call sub_array_assumed (array_char_ptr
)
123 call sub_array_assumed (array_t1
)
124 call sub_array_assumed (array_t2_alloc
)
125 call sub_array_assumed (array_t3_ptr
)
126 call sub_array_assumed (array_class_t1_alloc
)
127 call sub_array_assumed (array_class_t1_ptr
)
129 call sub_array_shape (array_real_alloc
, [1,1], shape(array_real_alloc
))
130 call sub_array_shape (array_char_ptr
, [1,1], shape(array_char_ptr
))
131 call sub_array_shape (array_t2_alloc
, [1,1], shape(array_t2_alloc
))
132 call sub_array_shape (array_t3_ptr
, [1,1], shape(array_t3_ptr
))
133 call sub_array_shape (array_class_t1_alloc
, [1,1], shape(array_class_t1_alloc
))
134 call sub_array_shape (array_class_t1_ptr
, [1,1], shape(array_class_t1_ptr
))
136 deallocate (scalar_char_ptr
, scalar_class_t1_ptr
, array_char_ptr
)
137 deallocate (array_class_t1_ptr
, array_t3_ptr
)