47 MODULE test_idxlist_utils
50 USE ftest_common
, ONLY: test_abort
51 USE iso_c_binding
, ONLY: c_ptr, c_int, c_size_t
55 FUNCTION test_err_count() bind(c, name='test_err_count')
RESULT(code)
57 INTEGER(c_int) :: code
58 END FUNCTION test_err_count
60 PUBLIC :: test_err_count
61 PUBLIC :: check_idxlist, check_stripes, check_offsets, &
62 idxlist_pack_unpack_copy, check_idxlist_copy
64 SUBROUTINE check_idxlist(idxlist, ref_indices)
65 TYPE(xt_idxlist),
INTENT(in) :: idxlist
66 INTEGER(xt_int_kind),
INTENT(in) :: ref_indices(:)
68 INTEGER :: num_ref_indices
69 INTEGER(xt_int_kind) :: dummy(1)
70 INTEGER(c_int) :: num_ref_indices_c
73 SUBROUTINE check_idxlist_c(idxlist, ref_indices, ref_num_indices) &
74 bind(c, name=
'check_idxlist')
75 IMPORT :: xt_int_kind, c_ptr, c_int
77 TYPE(c_ptr),
VALUE,
INTENT(in) :: idxlist
78 INTEGER(xt_int_kind),
INTENT(in) :: ref_indices(*)
79 INTEGER(c_int),
VALUE,
INTENT(in) :: ref_num_indices
80 END SUBROUTINE check_idxlist_c
83 num_ref_indices =
SIZE(ref_indices)
84 IF (num_ref_indices > 0)
THEN 85 num_ref_indices_c = int(num_ref_indices, c_int)
92 END SUBROUTINE check_idxlist
94 SUBROUTINE check_stripes(stripes, ref_stripes)
95 TYPE(
xt_stripe),
INTENT(in) :: stripes(:), ref_stripes(:)
96 INTEGER(c_int) :: num_stripes_c, ref_num_stripes_c
98 SUBROUTINE check_stripes_c(stripes, num_stripes, ref_stripes, &
99 ref_num_stripes) bind(c, name='check_stripes')
102 TYPE(
xt_stripe),
INTENT(in) :: stripes(*), ref_stripes(*)
103 INTEGER(c_int),
VALUE,
INTENT(in) :: num_stripes, ref_num_stripes
104 END SUBROUTINE check_stripes_c
107 num_stripes_c = int(
SIZE(stripes), c_int)
108 ref_num_stripes_c = int(
SIZE(ref_stripes), c_int)
109 CALL check_stripes_c(stripes, num_stripes_c, ref_stripes, ref_num_stripes_c)
111 END SUBROUTINE check_stripes
113 SUBROUTINE check_offsets(offsets_a, offsets_b)
114 INTEGER(c_int),
INTENT(in) :: offsets_a(:), offsets_b(:)
115 INTEGER(c_size_t) :: num_offsets_c
117 SUBROUTINE check_offsets_c(num_offsets, offsets_a, offsets_b) &
118 bind(c, name=
'check_offsets')
119 IMPORT :: c_size_t, c_int
121 INTEGER(c_size_t),
VALUE,
INTENT(in) :: num_offsets
122 INTEGER(c_int),
INTENT(IN) :: offsets_a(num_offsets), &
123 offsets_b(num_offsets)
124 END SUBROUTINE check_offsets_c
127 IF (
SIZE(offsets_a) /=
size(offsets_b)) &
128 CALL test_abort(
"inequal number of array elements in eq test", &
132 num_offsets_c = int(
SIZE(offsets_a), c_size_t)
133 CALL check_offsets_c(num_offsets_c, offsets_a, offsets_b)
135 END SUBROUTINE check_offsets
137 FUNCTION idxlist_pack_unpack_copy(idxlist)
RESULT(idxlist_copy)
138 TYPE(xt_idxlist),
INTENT(in) :: idxlist
139 TYPE(xt_idxlist) :: idxlist_copy
142 FUNCTION idxlist_pack_unpack_copy_c(idxlist)
RESULT(idxlist_copy) &
143 bind(c, name=
'idxlist_pack_unpack_copy')
145 TYPE(c_ptr),
VALUE,
INTENT(in) :: idxlist
146 TYPE(c_ptr) :: idxlist_copy
147 END FUNCTION idxlist_pack_unpack_copy_c
151 = xt_idxlist_c2f(idxlist_pack_unpack_copy_c(
xt_idxlist_f2c(idxlist)))
153 END FUNCTION idxlist_pack_unpack_copy
155 SUBROUTINE check_idxlist_copy(idxlist, idxlist_copy, ref_indices, ref_stripes)
156 TYPE(xt_idxlist),
INTENT(in) :: idxlist, idxlist_copy
157 INTEGER(xt_int_kind),
INTENT(in) :: ref_indices(:)
158 TYPE(
xt_stripe),
INTENT(in) :: ref_stripes(:)
159 INTEGER(c_size_t) :: num_ref_indices_c, num_ref_stripes_c
161 SUBROUTINE check_idxlist_copy_c(idxlist, idxlist_copy, &
162 num_ref_indices, ref_indices, &
163 num_ref_stripes, ref_stripes) bind(c, name='check_idxlist_copy')
164 IMPORT :: c_size_t, c_ptr, xt_int_kind,
xt_stripe 165 TYPE(c_ptr),
VALUE,
INTENT(in) :: idxlist, idxlist_copy
166 INTEGER(c_size_t),
VALUE,
INTENT(in) :: num_ref_indices, num_ref_stripes
167 INTEGER(xt_int_kind),
INTENT(in) :: ref_indices(*)
168 TYPE(
xt_stripe),
INTENT(in) :: ref_stripes(*)
169 END SUBROUTINE check_idxlist_copy_c
171 num_ref_indices_c = int(
SIZE(ref_indices), c_size_t)
172 num_ref_stripes_c = int(
SIZE(ref_stripes), c_size_t)
175 num_ref_stripes_c, ref_stripes)
176 END SUBROUTINE check_idxlist_copy
178 END MODULE test_idxlist_utils