kim-api 2.4.1+AppleClang.AppleClang.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
 
Loading...
Searching...
No Matches
kim_time_unit_module.f90
Go to the documentation of this file.
1!
2! KIM-API: An API for interatomic models
3! Copyright (c) 2013--2022, Regents of the University of Minnesota.
4! All rights reserved.
5!
6! Contributors:
7! Ryan S. Elliott
8!
9! SPDX-License-Identifier: LGPL-2.1-or-later
10!
11! This library is free software; you can redistribute it and/or
12! modify it under the terms of the GNU Lesser General Public
13! License as published by the Free Software Foundation; either
14! version 2.1 of the License, or (at your option) any later version.
15!
16! This library is distributed in the hope that it will be useful,
17! but WITHOUT ANY WARRANTY; without even the implied warranty of
18! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19! Lesser General Public License for more details.
20!
21! You should have received a copy of the GNU Lesser General Public License
22! along with this library; if not, write to the Free Software Foundation,
23! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24!
25
26!
27! Release: This file is part of the kim-api-2.4.1 package.
28!
29
30!> \brief \copybrief KIM::TimeUnit
31!!
32!! \sa KIM::TimeUnit, KIM_TimeUnit
33!!
34!! \since 2.0
36 use, intrinsic :: iso_c_binding
37 implicit none
38 private
39
40 public &
41 ! Derived types
43 ! Constants
49 ! Routines
50 kim_known, &
51 operator(.eq.), &
52 operator(.ne.), &
57
58 !> \brief \copybrief KIM::TimeUnit
59 !!
60 !! \sa KIM::TimeUnit, KIM_TimeUnit
61 !!
62 !! \since 2.0
63 type, bind(c) :: kim_time_unit_type
64 !> \brief \copybrief KIM::TimeUnit::timeUnitID
65 !!
66 !! \sa KIM::TimeUnit::timeUnitID, KIM_TimeUnit::timeUnitID
67 !!
68 !! \since 2.0
69 integer(c_int) time_unit_id
70 end type kim_time_unit_type
71
72 !> \brief \copybrief KIM::TIME_UNIT::unused
73 !!
74 !! \sa KIM::TIME_UNIT::unused, KIM_TIME_UNIT_unused
75 !!
76 !! \since 2.0
77 type(kim_time_unit_type), protected, save, &
78 bind(c, name="KIM_TIME_UNIT_unused") &
80
81 !> \brief \copybrief KIM::TIME_UNIT::fs
82 !!
83 !! \sa KIM::TIME_UNIT::fs, KIM_TIME_UNIT_fs
84 !!
85 !! \since 2.0
86 type(kim_time_unit_type), protected, save, &
87 bind(c, name="KIM_TIME_UNIT_fs") &
89
90 !> \brief \copybrief KIM::TIME_UNIT::ps
91 !!
92 !! \sa KIM::TIME_UNIT::ps, KIM_TIME_UNIT_ps
93 !!
94 !! \since 2.0
95 type(kim_time_unit_type), protected, save, &
96 bind(c, name="KIM_TIME_UNIT_ps") &
98
99 !> \brief \copybrief KIM::TIME_UNIT::ns
100 !!
101 !! \sa KIM::TIME_UNIT::ns, KIM_TIME_UNIT_ns
102 !!
103 !! \since 2.0
104 type(kim_time_unit_type), protected, save, &
105 bind(c, name="KIM_TIME_UNIT_ns") &
107
108 !> \brief \copybrief KIM::TIME_UNIT::s
109 !!
110 !! \sa KIM::TIME_UNIT::s, KIM_TIME_UNIT_s
111 !!
112 !! \since 2.0
113 type(kim_time_unit_type), protected, save, &
114 bind(c, name="KIM_TIME_UNIT_s") &
116
117 !> \brief \copybrief KIM::TimeUnit::Known
118 !!
119 !! \sa KIM::TimeUnit::Known, KIM_TimeUnit_Known
120 !!
121 !! \since 2.0
122 interface kim_known
123 module procedure kim_time_unit_known
124 end interface kim_known
125
126 !> \brief \copybrief KIM::TimeUnit::operator==()
127 !!
128 !! \sa KIM::TimeUnit::operator==(), KIM_TimeUnit_Equal
129 !!
130 !! \since 2.0
131 interface operator(.eq.)
132 module procedure kim_time_unit_equal
133 end interface operator(.eq.)
134
135 !> \brief \copybrief KIM::TimeUnit::operator!=()
136 !!
137 !! \sa KIM::TimeUnit::operator!=(), KIM_TimeUnit_NotEqual
138 !!
139 !! \since 2.0
140 interface operator(.ne.)
141 module procedure kim_time_unit_not_equal
142 end interface operator(.ne.)
143
144 !> \brief \copybrief KIM::TimeUnit::TimeUnit(std::string const &)
145 !!
146 !! \sa KIM::TimeUnit::TimeUnit(std::string const &), KIM_TimeUnit_FromString
147 !!
148 !! \since 2.0
150 module procedure kim_time_unit_from_string
151 end interface kim_from_string
152
153 !> \brief \copybrief KIM::TimeUnit::ToString
154 !!
155 !! \sa KIM::TimeUnit::ToString, KIM_TimeUnit_ToString
156 !!
157 !! \since 2.0
159 module procedure kim_time_unit_to_string
160 end interface kim_to_string
161
162contains
163 !> \brief \copybrief KIM::TimeUnit::Known
164 !!
165 !! \sa KIM::TimeUnit::Known, KIM_TimeUnit_Known
166 !!
167 !! \since 2.0
168 logical recursive function kim_time_unit_known(time_unit)
169 implicit none
170 interface
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
175 implicit none
176 type(kim_time_unit_type), intent(in), value :: time_unit
177 end function known
178 end interface
179 type(kim_time_unit_type), intent(in) :: time_unit
180
181 kim_time_unit_known = (known(time_unit) /= 0)
182 end function kim_time_unit_known
183
184 !> \brief \copybrief KIM::TimeUnit::operator==()
185 !!
186 !! \sa KIM::TimeUnit::operator==(), KIM_TimeUnit_Equal
187 !!
188 !! \since 2.0
189 logical recursive function kim_time_unit_equal(lhs, rhs)
190 implicit none
191 type(kim_time_unit_type), intent(in) :: lhs
192 type(kim_time_unit_type), intent(in) :: rhs
193
194 kim_time_unit_equal = (lhs%time_unit_id == rhs%time_unit_id)
195 end function kim_time_unit_equal
196
197 !> \brief \copybrief KIM::TimeUnit::operator!=()
198 !!
199 !! \sa KIM::TimeUnit::operator!=(), KIM_TimeUnit_NotEqual
200 !!
201 !! \since 2.0
202 logical recursive function kim_time_unit_not_equal(lhs, rhs)
203 implicit none
204 type(kim_time_unit_type), intent(in) :: lhs
205 type(kim_time_unit_type), intent(in) :: rhs
206
207 kim_time_unit_not_equal = .not. (lhs == rhs)
208 end function kim_time_unit_not_equal
209
210 !> \brief \copybrief KIM::TimeUnit::TimeUnit(std::string const &)
211 !!
212 !! \sa KIM::TimeUnit::TimeUnit(std::string const &), KIM_TimeUnit_FromString
213 !!
214 !! \since 2.0
215 recursive subroutine kim_time_unit_from_string(string, time_unit)
216 implicit none
217 interface
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
222 implicit none
223 character(c_char), intent(in) :: string(*)
224 end function from_string
225 end interface
226 character(len=*, kind=c_char), intent(in) :: string
227 type(kim_time_unit_type), intent(out) :: time_unit
228
229 time_unit = from_string(trim(string)//c_null_char)
230 end subroutine kim_time_unit_from_string
231
232 !> \brief \copybrief KIM::TimeUnit::ToString
233 !!
234 !! \sa KIM::TimeUnit::ToString, KIM_TimeUnit_ToString
235 !!
236 !! \since 2.0
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
239 implicit none
240 interface
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
245 implicit none
246 type(kim_time_unit_type), intent(in), value :: time_unit
247 end function get_string
248 end interface
249 type(kim_time_unit_type), intent(in) :: time_unit
250 character(len=*, kind=c_char), intent(out) :: string
251
252 type(c_ptr) :: p
253
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
257
258 !> \brief \copybrief KIM::TIME_UNIT::GetNumberOfTimeUnits
259 !!
260 !! \sa KIM::TIME_UNIT::GetNumberOfTimeUnits,
261 !! KIM_TIME_UNIT_GetNumberOfTimeUnits
262 !!
263 !! \since 2.0
264 recursive subroutine kim_get_number_of_time_units(number_of_time_units)
265 implicit none
266 interface
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
270 implicit none
271 integer(c_int), intent(out) :: number_of_time_units
272 end subroutine get_number_of_time_units
273 end interface
274 integer(c_int), intent(out) :: number_of_time_units
275
276 call get_number_of_time_units(number_of_time_units)
277 end subroutine kim_get_number_of_time_units
278
279 !> \brief \copybrief KIM::TIME_UNIT::GetTimeUnit
280 !!
281 !! \sa KIM::TIME_UNIT::GetTimeUnit, KIM_TIME_UNIT_GetTimeUnit
282 !!
283 !! \since 2.0
284 recursive subroutine kim_get_time_unit(index, time_unit, ierr)
285 implicit none
286 interface
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
291 implicit none
292 integer(c_int), intent(in), value :: index
293 type(kim_time_unit_type), intent(out) :: time_unit
294 end function get_time_unit
295 end interface
296 integer(c_int), intent(in) :: index
297 type(kim_time_unit_type), intent(out) :: time_unit
298 integer(c_int), intent(out) :: ierr
299
300 ierr = get_time_unit(index - 1, time_unit)
301 end subroutine kim_get_time_unit
302end module kim_time_unit_module
Create a TimeUnit object corresponding to the provided string. If the string does not match one of th...
Determines if the object is a quantity known to the KIM API.
Converts the object to a string.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
type(kim_time_unit_type), save, bind(C, name="KIM_TIME_UNIT_ps"), public, protected kim_time_unit_ps
The standard picosecond unit of time.
type(kim_time_unit_type), save, bind(C, name="KIM_TIME_UNIT_ns"), public, protected kim_time_unit_ns
The standard nanosecond unit of time.
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, bind(C, name="KIM_TIME_UNIT_fs"), public, protected kim_time_unit_fs
The standard femtosecond unit of time.
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, bind(C, name="KIM_TIME_UNIT_unused"), public, protected kim_time_unit_unused
Indicates that a TimeUnit is not used.
type(kim_time_unit_type), save, bind(C, name="KIM_TIME_UNIT_s"), public, protected kim_time_unit_s
The standard second unit of time.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.