39 use,
intrinsic :: iso_c_binding
66 type, bind(c) :: kim_time_unit_type
72 integer(c_int) time_unit_id
73 end type kim_time_unit_type
80 type(kim_time_unit_type),
protected,
save, &
81 bind(c, name=
"KIM_TIME_UNIT_unused") &
89 type(kim_time_unit_type),
protected,
save, &
90 bind(c, name=
"KIM_TIME_UNIT_fs") &
98 type(kim_time_unit_type),
protected,
save, &
99 bind(c, name=
"KIM_TIME_UNIT_ps") &
107 type(kim_time_unit_type),
protected,
save, &
108 bind(c, name=
"KIM_TIME_UNIT_ns") &
116 type(kim_time_unit_type),
protected,
save, &
117 bind(c, name=
"KIM_TIME_UNIT_s") &
126 module procedure kim_time_unit_known
127 end interface kim_known
134 interface operator(.eq.)
135 module procedure kim_time_unit_equal
136 end interface operator(.eq.)
143 interface operator(.ne.)
144 module procedure kim_time_unit_not_equal
145 end interface operator(.ne.)
152 interface kim_from_string
153 module procedure kim_time_unit_from_string
154 end interface kim_from_string
161 interface kim_to_string
162 module procedure kim_time_unit_to_string
163 end interface kim_to_string
171 logical recursive function kim_time_unit_known(time_unit)
174 integer(c_int) recursive function known(time_unit) &
175 bind(c, name=
"KIM_TimeUnit_Known")
176 use,
intrinsic :: iso_c_binding
177 import kim_time_unit_type
179 type(kim_time_unit_type),
intent(in),
value :: time_unit
182 type(kim_time_unit_type),
intent(in) :: time_unit
184 kim_time_unit_known = (known(time_unit) /= 0)
185 end function kim_time_unit_known
192 logical recursive function kim_time_unit_equal(lhs, rhs)
194 type(kim_time_unit_type),
intent(in) :: lhs
195 type(kim_time_unit_type),
intent(in) :: rhs
197 kim_time_unit_equal = (lhs%time_unit_id == rhs%time_unit_id)
198 end function kim_time_unit_equal
205 logical recursive function kim_time_unit_not_equal(lhs, rhs)
207 type(kim_time_unit_type),
intent(in) :: lhs
208 type(kim_time_unit_type),
intent(in) :: rhs
210 kim_time_unit_not_equal = .not. (lhs == rhs)
211 end function kim_time_unit_not_equal
218 recursive subroutine kim_time_unit_from_string(string, time_unit)
221 type(kim_time_unit_type)
recursive function from_string(string) &
222 bind(c, name=
"KIM_TimeUnit_FromString")
223 use,
intrinsic :: iso_c_binding
224 import kim_time_unit_type
226 character(c_char),
intent(in) :: string(*)
227 end function from_string
229 character(len=*, kind=c_char),
intent(in) :: string
230 type(kim_time_unit_type),
intent(out) :: time_unit
232 time_unit = from_string(trim(string)//c_null_char)
233 end subroutine kim_time_unit_from_string
240 recursive subroutine kim_time_unit_to_string(time_unit, string)
241 use kim_convert_string_module
, only: kim_convert_c_char_ptr_to_string
244 type(c_ptr)
recursive function get_string(time_unit) &
245 bind(c, name=
"KIM_TimeUnit_ToString")
246 use,
intrinsic :: iso_c_binding
247 import kim_time_unit_type
249 type(kim_time_unit_type),
intent(in),
value :: time_unit
250 end function get_string
252 type(kim_time_unit_type),
intent(in) :: time_unit
253 character(len=*, kind=c_char),
intent(out) :: string
257 p = get_string(time_unit)
258 call kim_convert_c_char_ptr_to_string(p, string)
259 end subroutine kim_time_unit_to_string
270 recursive subroutine get_number_of_time_units(number_of_time_units) &
271 bind(c, name=
"KIM_TIME_UNIT_GetNumberOfTimeUnits")
272 use,
intrinsic :: iso_c_binding
274 integer(c_int),
intent(out) :: number_of_time_units
275 end subroutine get_number_of_time_units
277 integer(c_int),
intent(out) :: number_of_time_units
279 call get_number_of_time_units(number_of_time_units)
290 integer(c_int) recursive function get_time_unit(index, time_unit) &
291 bind(c, name=
"KIM_TIME_UNIT_GetTimeUnit")
292 use,
intrinsic :: iso_c_binding
293 import kim_time_unit_type
295 integer(c_int),
intent(in),
value :: index
296 type(kim_time_unit_type),
intent(out) :: time_unit
297 end function get_time_unit
299 integer(c_int),
intent(in) :: index
300 type(kim_time_unit_type),
intent(out) :: time_unit
301 integer(c_int),
intent(out) :: ierr
303 ierr = get_time_unit(index - 1, time_unit)
recursive subroutine, public kim_get_number_of_time_units(number_of_time_units)
Get the number of standard TimeUnit's defined by the KIM API.
type(kim_time_unit_type), save, public, protected kim_time_unit_unused
recursive subroutine, public kim_get_time_unit(index, time_unit, ierr)
Get the identity of each defined standard TimeUnit.
type(kim_time_unit_type), save, public, protected kim_time_unit_s
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
type(kim_time_unit_type), save, public, protected kim_time_unit_ns
type(kim_time_unit_type), save, public, protected kim_time_unit_fs
type(kim_time_unit_type), save, public, protected kim_time_unit_ps