39 use,
intrinsic :: iso_c_binding
63 type, bind(c) :: kim_data_type_type
69 integer(c_int) :: data_type_id
70 end type kim_data_type_type
77 type(kim_data_type_type),
protected,
save, &
78 bind(c, name=
"KIM_DATA_TYPE_Integer") &
86 type(kim_data_type_type),
protected,
save, &
87 bind(c, name=
"KIM_DATA_TYPE_Double") &
96 module procedure kim_data_type_known
97 end interface kim_known
104 interface operator(.eq.)
105 module procedure kim_data_type_equal
106 end interface operator(.eq.)
113 interface operator(.ne.)
114 module procedure kim_data_type_not_equal
115 end interface operator(.ne.)
122 interface kim_from_string
123 module procedure kim_data_type_from_string
124 end interface kim_from_string
131 interface kim_to_string
132 module procedure kim_data_type_to_string
133 end interface kim_to_string
141 logical recursive function kim_data_type_known(data_type)
144 integer(c_int) recursive function known(data_type) &
145 bind(c, name=
"KIM_DataType_Known")
146 use,
intrinsic :: iso_c_binding
147 import kim_data_type_type
149 type(kim_data_type_type),
intent(in),
value :: data_type
152 type(kim_data_type_type),
intent(in) :: data_type
154 kim_data_type_known = (known(data_type) /= 0)
155 end function kim_data_type_known
162 logical recursive function kim_data_type_equal(lhs, rhs)
164 type(kim_data_type_type),
intent(in) :: lhs
165 type(kim_data_type_type),
intent(in) :: rhs
167 kim_data_type_equal &
168 = (lhs%data_type_id == rhs%data_type_id)
169 end function kim_data_type_equal
176 logical recursive function kim_data_type_not_equal(lhs, rhs)
178 type(kim_data_type_type),
intent(in) :: lhs
179 type(kim_data_type_type),
intent(in) :: rhs
181 kim_data_type_not_equal = .not. (lhs == rhs)
182 end function kim_data_type_not_equal
189 recursive subroutine kim_data_type_from_string(string, data_type)
192 type(kim_data_type_type)
recursive function from_string(string) &
193 bind(c, name=
"KIM_DataType_FromString")
194 use,
intrinsic :: iso_c_binding
195 import kim_data_type_type
197 character(c_char),
intent(in) :: string(*)
198 end function from_string
200 character(len=*, kind=c_char),
intent(in) :: string
201 type(kim_data_type_type),
intent(out) :: data_type
203 data_type = from_string(trim(string)//c_null_char)
204 end subroutine kim_data_type_from_string
211 recursive subroutine kim_data_type_to_string(data_type, string)
212 use kim_convert_string_module
, only: kim_convert_c_char_ptr_to_string
215 type(c_ptr)
recursive function get_string(data_type) &
216 bind(c, name=
"KIM_DataType_ToString")
217 use,
intrinsic :: iso_c_binding
218 import kim_data_type_type
220 type(kim_data_type_type),
intent(in),
value :: data_type
221 end function get_string
223 type(kim_data_type_type),
intent(in) :: data_type
224 character(len=*, kind=c_char),
intent(out) :: string
228 p = get_string(data_type)
229 call kim_convert_c_char_ptr_to_string(p, string)
230 end subroutine kim_data_type_to_string
241 recursive subroutine get_number_of_data_types(number_of_data_types) &
242 bind(c, name=
"KIM_DATA_TYPE_GetNumberOfDataTypes")
243 use,
intrinsic :: iso_c_binding
245 integer(c_int),
intent(out) :: number_of_data_types
246 end subroutine get_number_of_data_types
248 integer(c_int),
intent(out) :: number_of_data_types
250 call get_number_of_data_types(number_of_data_types)
261 integer(c_int) recursive function get_data_type(index, data_type) &
262 bind(c, name=
"KIM_DATA_TYPE_GetDataType")
263 use,
intrinsic :: iso_c_binding
264 import kim_data_type_type
266 integer(c_int),
intent(in),
value :: index
267 type(kim_data_type_type),
intent(out) :: data_type
268 end function get_data_type
270 integer(c_int),
intent(in) :: index
271 type(kim_data_type_type),
intent(out) :: data_type
272 integer(c_int),
intent(out) :: ierr
274 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.