40 use,
intrinsic :: iso_c_binding
70 type, bind(c) :: kim_time_unit_type
76 integer(c_int) time_unit_id
77 end type kim_time_unit_type
84 type(kim_time_unit_type),
protected,
save, &
85 bind(c, name=
"KIM_TIME_UNIT_unused") &
93 type(kim_time_unit_type),
protected,
save, &
94 bind(c, name=
"KIM_TIME_UNIT_fs") &
102 type(kim_time_unit_type),
protected,
save, &
103 bind(c, name=
"KIM_TIME_UNIT_ps") &
111 type(kim_time_unit_type),
protected,
save, &
112 bind(c, name=
"KIM_TIME_UNIT_ns") &
120 type(kim_time_unit_type),
protected,
save, &
121 bind(c, name=
"KIM_TIME_UNIT_s") &
130 module procedure kim_time_unit_known
131 end interface kim_known
138 interface operator (.eq.)
139 module procedure kim_time_unit_equal
140 end interface operator (.eq.)
147 interface operator (.ne.)
148 module procedure kim_time_unit_not_equal
149 end interface operator (.ne.)
156 interface kim_from_string
157 module procedure kim_time_unit_from_string
158 end interface kim_from_string
165 interface kim_to_string
166 module procedure kim_time_unit_to_string
167 end interface kim_to_string
175 logical recursive function kim_time_unit_known(time_unit)
178 integer(c_int) recursive function known(time_unit) &
179 bind(c, name=
"KIM_TimeUnit_Known")
180 use,
intrinsic :: iso_c_binding
181 import kim_time_unit_type
183 type(kim_time_unit_type),
intent(in),
value :: time_unit
186 type(kim_time_unit_type),
intent(in) :: time_unit
188 kim_time_unit_known = (known(time_unit) /= 0)
189 end function kim_time_unit_known
196 logical recursive function kim_time_unit_equal(lhs, rhs)
198 type(kim_time_unit_type),
intent(in) :: lhs
199 type(kim_time_unit_type),
intent(in) :: rhs
201 kim_time_unit_equal &
202 = (lhs%time_unit_id .eq. rhs%time_unit_id)
203 end function kim_time_unit_equal
210 logical recursive function kim_time_unit_not_equal(lhs, rhs)
212 type(kim_time_unit_type),
intent(in) :: lhs
213 type(kim_time_unit_type),
intent(in) :: rhs
215 kim_time_unit_not_equal = .not. (lhs .eq. rhs)
216 end function kim_time_unit_not_equal
223 recursive subroutine kim_time_unit_from_string(string, time_unit)
226 type(kim_time_unit_type)
recursive function from_string(string) &
227 bind(c, name=
"KIM_TimeUnit_FromString")
228 use,
intrinsic :: iso_c_binding
229 import kim_time_unit_type
231 character(c_char),
intent(in) :: string(*)
232 end function from_string
234 character(len=*, kind=c_char),
intent(in) :: string
235 type(kim_time_unit_type),
intent(out) :: time_unit
237 time_unit = from_string(trim(string)//c_null_char)
238 end subroutine kim_time_unit_from_string
245 recursive subroutine kim_time_unit_to_string(time_unit, string)
246 use kim_convert_string_module
, only : kim_convert_c_char_ptr_to_string
249 type(c_ptr)
recursive function get_string(time_unit) &
250 bind(c, name=
"KIM_TimeUnit_ToString")
251 use,
intrinsic :: iso_c_binding
252 import kim_time_unit_type
254 type(kim_time_unit_type),
intent(in),
value :: time_unit
255 end function get_string
257 type(kim_time_unit_type),
intent(in) :: time_unit
258 character(len=*, kind=c_char),
intent(out) :: string
262 p = get_string(time_unit)
263 call kim_convert_c_char_ptr_to_string(p, string)
264 end subroutine kim_time_unit_to_string
275 recursive subroutine get_number_of_time_units(number_of_time_units) &
276 bind(c, name=
"KIM_TIME_UNIT_GetNumberOfTimeUnits")
277 use,
intrinsic :: iso_c_binding
279 integer(c_int),
intent(out) :: number_of_time_units
280 end subroutine get_number_of_time_units
282 integer(c_int),
intent(out) :: number_of_time_units
284 call get_number_of_time_units(number_of_time_units)
295 integer(c_int) recursive function get_time_unit(index, time_unit) &
296 bind(c, name=
"KIM_TIME_UNIT_GetTimeUnit")
297 use,
intrinsic :: iso_c_binding
298 import kim_time_unit_type
300 integer(c_int),
intent(in),
value :: index
301 type(kim_time_unit_type),
intent(out) :: time_unit
302 end function get_time_unit
304 integer(c_int),
intent(in) :: index
305 type(kim_time_unit_type),
intent(out) :: time_unit
306 integer(c_int),
intent(out) :: ierr
308 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