39 use,
intrinsic :: iso_c_binding
45 kim_length_unit_type, &
67 type, bind(c) :: kim_length_unit_type
73 integer(c_int) length_unit_id
74 end type kim_length_unit_type
81 type(kim_length_unit_type),
protected,
save, &
82 bind(c, name=
"KIM_LENGTH_UNIT_unused") &
90 type(kim_length_unit_type),
protected,
save, &
91 bind(c, name=
"KIM_LENGTH_UNIT_A") &
99 type(kim_length_unit_type),
protected,
save, &
100 bind(c, name=
"KIM_LENGTH_UNIT_Bohr") &
108 type(kim_length_unit_type),
protected,
save, &
109 bind(c, name=
"KIM_LENGTH_UNIT_cm") &
117 type(kim_length_unit_type),
protected,
save, &
118 bind(c, name=
"KIM_LENGTH_UNIT_m") &
126 type(kim_length_unit_type),
protected,
save, &
127 bind(c, name=
"KIM_LENGTH_UNIT_nm") &
136 module procedure kim_length_unit_known
137 end interface kim_known
144 interface operator(.eq.)
145 module procedure kim_length_unit_equal
146 end interface operator(.eq.)
153 interface operator(.ne.)
154 module procedure kim_length_unit_not_equal
155 end interface operator(.ne.)
163 interface kim_from_string
164 module procedure kim_length_unit_from_string
165 end interface kim_from_string
172 interface kim_to_string
173 module procedure kim_length_unit_to_string
174 end interface kim_to_string
182 logical recursive function kim_length_unit_known(length_unit)
185 integer(c_int) recursive function known(length_unit) &
186 bind(c, name=
"KIM_LengthUnit_Known")
187 use,
intrinsic :: iso_c_binding
188 import kim_length_unit_type
190 type(kim_length_unit_type),
intent(in),
value :: length_unit
193 type(kim_length_unit_type),
intent(in) :: length_unit
195 kim_length_unit_known = (known(length_unit) /= 0)
196 end function kim_length_unit_known
203 logical recursive function kim_length_unit_equal(lhs, rhs)
205 type(kim_length_unit_type),
intent(in) :: lhs
206 type(kim_length_unit_type),
intent(in) :: rhs
208 kim_length_unit_equal &
209 = (lhs%length_unit_id == rhs%length_unit_id)
210 end function kim_length_unit_equal
217 logical recursive function kim_length_unit_not_equal(lhs, rhs)
219 type(kim_length_unit_type),
intent(in) :: lhs
220 type(kim_length_unit_type),
intent(in) :: rhs
222 kim_length_unit_not_equal = .not. (lhs == rhs)
223 end function kim_length_unit_not_equal
231 recursive subroutine kim_length_unit_from_string(string, length_unit)
234 type(kim_length_unit_type)
recursive function from_string(string) &
235 bind(c, name=
"KIM_LengthUnit_FromString")
236 use,
intrinsic :: iso_c_binding
237 import kim_length_unit_type
239 character(c_char),
intent(in) :: string(*)
240 end function from_string
242 character(len=*, kind=c_char),
intent(in) :: string
243 type(kim_length_unit_type),
intent(out) :: length_unit
245 length_unit = from_string(trim(string)//c_null_char)
246 end subroutine kim_length_unit_from_string
253 recursive subroutine kim_length_unit_to_string(length_unit, string)
254 use kim_convert_string_module
, only: kim_convert_c_char_ptr_to_string
257 type(c_ptr)
recursive function get_string(length_unit) &
258 bind(c, name=
"KIM_LengthUnit_ToString")
259 use,
intrinsic :: iso_c_binding
260 import kim_length_unit_type
262 type(kim_length_unit_type),
intent(in),
value :: length_unit
263 end function get_string
265 type(kim_length_unit_type),
intent(in) :: length_unit
266 character(len=*, kind=c_char),
intent(out) :: string
270 p = get_string(length_unit)
271 call kim_convert_c_char_ptr_to_string(p, string)
272 end subroutine kim_length_unit_to_string
283 recursive subroutine get_number_of_length_units(number_of_length_units) &
284 bind(c, name=
"KIM_LENGTH_UNIT_GetNumberOfLengthUnits")
285 use,
intrinsic :: iso_c_binding
286 integer(c_int),
intent(out) :: number_of_length_units
287 end subroutine get_number_of_length_units
289 integer(c_int),
intent(out) :: number_of_length_units
291 call get_number_of_length_units(number_of_length_units)
302 integer(c_int) recursive function get_length_unit(index, length_unit) &
303 bind(c, name=
"KIM_LENGTH_UNIT_GetLengthUnit")
304 use,
intrinsic :: iso_c_binding
305 import kim_length_unit_type
307 integer(c_int),
intent(in),
value :: index
308 type(kim_length_unit_type),
intent(out) :: length_unit
309 end function get_length_unit
311 integer(c_int),
intent(in) :: index
312 type(kim_length_unit_type),
intent(out) :: length_unit
313 integer(c_int),
intent(out) :: ierr
315 ierr = get_length_unit(index - 1, length_unit)
type(kim_length_unit_type), save, public, protected kim_length_unit_a
type(kim_length_unit_type), save, public, protected kim_length_unit_bohr
type(kim_length_unit_type), save, public, protected kim_length_unit_m
recursive subroutine, public kim_get_number_of_length_units(number_of_length_units)
Get the number of standard LengthUnit's defined by the KIM API.
type(kim_length_unit_type), save, public, protected kim_length_unit_unused
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
type(kim_length_unit_type), save, public, protected kim_length_unit_nm
recursive subroutine, public kim_get_length_unit(index, length_unit, ierr)
Get the identity of each defined standard LengthUnit.
type(kim_length_unit_type), save, public, protected kim_length_unit_cm