36 use,
intrinsic :: iso_c_binding
60 type, bind(c) :: kim_data_type_type
66 integer(c_int) :: data_type_id
67 end type kim_data_type_type
74 type(kim_data_type_type),
protected,
save, &
75 bind(c, name=
"KIM_DATA_TYPE_Integer") &
83 type(kim_data_type_type),
protected,
save, &
84 bind(c, name=
"KIM_DATA_TYPE_Double") &
93 module procedure kim_data_type_known
94 end interface kim_known
101 interface operator(.eq.)
102 module procedure kim_data_type_equal
103 end interface operator(.eq.)
110 interface operator(.ne.)
111 module procedure kim_data_type_not_equal
112 end interface operator(.ne.)
119 interface kim_from_string
120 module procedure kim_data_type_from_string
121 end interface kim_from_string
128 interface kim_to_string
129 module procedure kim_data_type_to_string
130 end interface kim_to_string
138 logical recursive function kim_data_type_known(data_type)
141 integer(c_int) recursive function known(data_type) &
142 bind(c, name=
"KIM_DataType_Known")
143 use,
intrinsic :: iso_c_binding
144 import kim_data_type_type
146 type(kim_data_type_type),
intent(in),
value :: data_type
149 type(kim_data_type_type),
intent(in) :: data_type
151 kim_data_type_known = (known(data_type) /= 0)
152 end function kim_data_type_known
159 logical recursive function kim_data_type_equal(lhs, rhs)
161 type(kim_data_type_type),
intent(in) :: lhs
162 type(kim_data_type_type),
intent(in) :: rhs
164 kim_data_type_equal &
165 = (lhs%data_type_id == rhs%data_type_id)
166 end function kim_data_type_equal
173 logical recursive function kim_data_type_not_equal(lhs, rhs)
175 type(kim_data_type_type),
intent(in) :: lhs
176 type(kim_data_type_type),
intent(in) :: rhs
178 kim_data_type_not_equal = .not. (lhs == rhs)
179 end function kim_data_type_not_equal
186 recursive subroutine kim_data_type_from_string(string, data_type)
189 type(kim_data_type_type)
recursive function from_string(string) &
190 bind(c, name=
"KIM_DataType_FromString")
191 use,
intrinsic :: iso_c_binding
192 import kim_data_type_type
194 character(c_char),
intent(in) :: string(*)
195 end function from_string
197 character(len=*, kind=c_char),
intent(in) :: string
198 type(kim_data_type_type),
intent(out) :: data_type
200 data_type = from_string(trim(string)//c_null_char)
201 end subroutine kim_data_type_from_string
208 recursive subroutine kim_data_type_to_string(data_type, string)
209 use kim_convert_string_module
, only: kim_convert_c_char_ptr_to_string
212 type(c_ptr)
recursive function get_string(data_type) &
213 bind(c, name=
"KIM_DataType_ToString")
214 use,
intrinsic :: iso_c_binding
215 import kim_data_type_type
217 type(kim_data_type_type),
intent(in),
value :: data_type
218 end function get_string
220 type(kim_data_type_type),
intent(in) :: data_type
221 character(len=*, kind=c_char),
intent(out) :: string
225 p = get_string(data_type)
226 call kim_convert_c_char_ptr_to_string(p, string)
227 end subroutine kim_data_type_to_string
238 recursive subroutine get_number_of_data_types(number_of_data_types) &
239 bind(c, name=
"KIM_DATA_TYPE_GetNumberOfDataTypes")
240 use,
intrinsic :: iso_c_binding
242 integer(c_int),
intent(out) :: number_of_data_types
243 end subroutine get_number_of_data_types
245 integer(c_int),
intent(out) :: number_of_data_types
247 call get_number_of_data_types(number_of_data_types)
258 integer(c_int) recursive function get_data_type(index, data_type) &
259 bind(c, name=
"KIM_DATA_TYPE_GetDataType")
260 use,
intrinsic :: iso_c_binding
261 import kim_data_type_type
263 integer(c_int),
intent(in),
value :: index
264 type(kim_data_type_type),
intent(out) :: data_type
265 end function get_data_type
267 integer(c_int),
intent(in) :: index
268 type(kim_data_type_type),
intent(out) :: data_type
269 integer(c_int),
intent(out) :: ierr
271 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.