36 use,
intrinsic :: iso_c_binding
63 type, bind(c) :: kim_time_unit_type
69 integer(c_int) time_unit_id
70 end type kim_time_unit_type
77 type(kim_time_unit_type),
protected,
save, &
78 bind(c, name=
"KIM_TIME_UNIT_unused") &
86 type(kim_time_unit_type),
protected,
save, &
87 bind(c, name=
"KIM_TIME_UNIT_fs") &
95 type(kim_time_unit_type),
protected,
save, &
96 bind(c, name=
"KIM_TIME_UNIT_ps") &
104 type(kim_time_unit_type),
protected,
save, &
105 bind(c, name=
"KIM_TIME_UNIT_ns") &
113 type(kim_time_unit_type),
protected,
save, &
114 bind(c, name=
"KIM_TIME_UNIT_s") &
123 module procedure kim_time_unit_known
124 end interface kim_known
131 interface operator(.eq.)
132 module procedure kim_time_unit_equal
133 end interface operator(.eq.)
140 interface operator(.ne.)
141 module procedure kim_time_unit_not_equal
142 end interface operator(.ne.)
149 interface kim_from_string
150 module procedure kim_time_unit_from_string
151 end interface kim_from_string
158 interface kim_to_string
159 module procedure kim_time_unit_to_string
160 end interface kim_to_string
168 logical recursive function kim_time_unit_known(time_unit)
171 integer(c_int) recursive function known(time_unit) &
172 bind(c, name=
"KIM_TimeUnit_Known")
173 use,
intrinsic :: iso_c_binding
174 import kim_time_unit_type
176 type(kim_time_unit_type),
intent(in),
value :: time_unit
179 type(kim_time_unit_type),
intent(in) :: time_unit
181 kim_time_unit_known = (known(time_unit) /= 0)
182 end function kim_time_unit_known
189 logical recursive function kim_time_unit_equal(lhs, rhs)
191 type(kim_time_unit_type),
intent(in) :: lhs
192 type(kim_time_unit_type),
intent(in) :: rhs
194 kim_time_unit_equal = (lhs%time_unit_id == rhs%time_unit_id)
195 end function kim_time_unit_equal
202 logical recursive function kim_time_unit_not_equal(lhs, rhs)
204 type(kim_time_unit_type),
intent(in) :: lhs
205 type(kim_time_unit_type),
intent(in) :: rhs
207 kim_time_unit_not_equal = .not. (lhs == rhs)
208 end function kim_time_unit_not_equal
215 recursive subroutine kim_time_unit_from_string(string, time_unit)
218 type(kim_time_unit_type)
recursive function from_string(string) &
219 bind(c, name=
"KIM_TimeUnit_FromString")
220 use,
intrinsic :: iso_c_binding
221 import kim_time_unit_type
223 character(c_char),
intent(in) :: string(*)
224 end function from_string
226 character(len=*, kind=c_char),
intent(in) :: string
227 type(kim_time_unit_type),
intent(out) :: time_unit
229 time_unit = from_string(trim(string)//c_null_char)
230 end subroutine kim_time_unit_from_string
237 recursive subroutine kim_time_unit_to_string(time_unit, string)
238 use kim_convert_string_module
, only: kim_convert_c_char_ptr_to_string
241 type(c_ptr)
recursive function get_string(time_unit) &
242 bind(c, name=
"KIM_TimeUnit_ToString")
243 use,
intrinsic :: iso_c_binding
244 import kim_time_unit_type
246 type(kim_time_unit_type),
intent(in),
value :: time_unit
247 end function get_string
249 type(kim_time_unit_type),
intent(in) :: time_unit
250 character(len=*, kind=c_char),
intent(out) :: string
254 p = get_string(time_unit)
255 call kim_convert_c_char_ptr_to_string(p, string)
256 end subroutine kim_time_unit_to_string
267 recursive subroutine get_number_of_time_units(number_of_time_units) &
268 bind(c, name=
"KIM_TIME_UNIT_GetNumberOfTimeUnits")
269 use,
intrinsic :: iso_c_binding
271 integer(c_int),
intent(out) :: number_of_time_units
272 end subroutine get_number_of_time_units
274 integer(c_int),
intent(out) :: number_of_time_units
276 call get_number_of_time_units(number_of_time_units)
287 integer(c_int) recursive function get_time_unit(index, time_unit) &
288 bind(c, name=
"KIM_TIME_UNIT_GetTimeUnit")
289 use,
intrinsic :: iso_c_binding
290 import kim_time_unit_type
292 integer(c_int),
intent(in),
value :: index
293 type(kim_time_unit_type),
intent(out) :: time_unit
294 end function get_time_unit
296 integer(c_int),
intent(in) :: index
297 type(kim_time_unit_type),
intent(out) :: time_unit
298 integer(c_int),
intent(out) :: ierr
300 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