40 use,
intrinsic :: iso_c_binding
67 type, bind(c) :: kim_data_type_type
73 integer(c_int) :: data_type_id
74 end type kim_data_type_type
81 type(kim_data_type_type),
protected,
save, &
82 bind(c, name=
"KIM_DATA_TYPE_Integer") &
90 type(kim_data_type_type),
protected,
save, &
91 bind(c, name=
"KIM_DATA_TYPE_Double") &
100 module procedure kim_data_type_known
101 end interface kim_known
108 interface operator (.eq.)
109 module procedure kim_data_type_equal
110 end interface operator (.eq.)
117 interface operator (.ne.)
118 module procedure kim_data_type_not_equal
119 end interface operator (.ne.)
126 interface kim_from_string
127 module procedure kim_data_type_from_string
128 end interface kim_from_string
135 interface kim_to_string
136 module procedure kim_data_type_to_string
137 end interface kim_to_string
145 logical recursive function kim_data_type_known(data_type)
148 integer(c_int) recursive function known(data_type) &
149 bind(c, name=
"KIM_DataType_Known")
150 use,
intrinsic :: iso_c_binding
151 import kim_data_type_type
153 type(kim_data_type_type),
intent(in),
value :: data_type
156 type(kim_data_type_type),
intent(in) :: data_type
158 kim_data_type_known = (known(data_type) /= 0)
159 end function kim_data_type_known
166 logical recursive function kim_data_type_equal(lhs, rhs)
168 type(kim_data_type_type),
intent(in) :: lhs
169 type(kim_data_type_type),
intent(in) :: rhs
171 kim_data_type_equal &
172 = (lhs%data_type_id .eq. rhs%data_type_id)
173 end function kim_data_type_equal
180 logical recursive function kim_data_type_not_equal(lhs, rhs)
182 type(kim_data_type_type),
intent(in) :: lhs
183 type(kim_data_type_type),
intent(in) :: rhs
185 kim_data_type_not_equal = .not. (lhs .eq. rhs)
186 end function kim_data_type_not_equal
193 recursive subroutine kim_data_type_from_string(string, data_type)
196 type(kim_data_type_type)
recursive function from_string(string) &
197 bind(c, name=
"KIM_DataType_FromString")
198 use,
intrinsic :: iso_c_binding
199 import kim_data_type_type
201 character(c_char),
intent(in) :: string(*)
202 end function from_string
204 character(len=*, kind=c_char),
intent(in) :: string
205 type(kim_data_type_type),
intent(out) :: data_type
207 data_type = from_string(trim(string)//c_null_char)
208 end subroutine kim_data_type_from_string
215 recursive subroutine kim_data_type_to_string(data_type, string)
216 use kim_convert_string_module
, only : kim_convert_c_char_ptr_to_string
219 type(c_ptr)
recursive function get_string(data_type) &
220 bind(c, name=
"KIM_DataType_ToString")
221 use,
intrinsic :: iso_c_binding
222 import kim_data_type_type
224 type(kim_data_type_type),
intent(in),
value :: data_type
225 end function get_string
227 type(kim_data_type_type),
intent(in) :: data_type
228 character(len=*, kind=c_char),
intent(out) :: string
232 p = get_string(data_type)
233 call kim_convert_c_char_ptr_to_string(p, string)
234 end subroutine kim_data_type_to_string
245 recursive subroutine get_number_of_data_types(number_of_data_types) &
246 bind(c, name=
"KIM_DATA_TYPE_GetNumberOfDataTypes")
247 use,
intrinsic :: iso_c_binding
249 integer(c_int),
intent(out) :: number_of_data_types
250 end subroutine get_number_of_data_types
252 integer(c_int),
intent(out) :: number_of_data_types
254 call get_number_of_data_types(number_of_data_types)
265 integer(c_int) recursive function get_data_type(index, data_type) &
266 bind(c, name=
"KIM_DATA_TYPE_GetDataType")
267 use,
intrinsic :: iso_c_binding
268 import kim_data_type_type
270 integer(c_int),
intent(in),
value :: index
271 type(kim_data_type_type),
intent(out) :: data_type
272 end function get_data_type
274 integer(c_int),
intent(in) :: index
275 type(kim_data_type_type),
intent(out) :: data_type
276 integer(c_int),
intent(out) :: ierr
278 ierr = get_data_type(index-1, data_type)
recursive subroutine, public kim_get_number_of_data_types(number_of_data_types)
Get the number of standard DataType's defined by the KIM API.
type(kim_data_type_type), save, public, protected kim_data_type_double
type(kim_data_type_type), save, public, protected kim_data_type_integer
recursive subroutine, public kim_get_data_type(index, data_type, ierr)
Get the identity of each defined standard DataType.
An Extensible Enumeration for the DataType's supported by the KIM API.