kim-api 2.3.0+AppleClang.AppleClang.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
Loading...
Searching...
No Matches
kim_temperature_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.3.0 package.
28!
29
36 use, intrinsic :: iso_c_binding
37 implicit none
38 private
39
40 public &
41 ! Derived type
43 ! Constants
46 ! Routines
47 kim_known, &
48 operator(.eq.), &
49 operator(.ne.), &
54
60 type, bind(c) :: kim_temperature_unit_type
67 integer(c_int) temperature_unit_id
69
75 type(kim_temperature_unit_type), protected, save, &
76 bind(c, name="KIM_TEMPERATURE_UNIT_unused") &
78
84 type(kim_temperature_unit_type), protected, save, &
85 bind(c, name="KIM_TEMPERATURE_UNIT_K") &
87
93 interface kim_known
94 module procedure kim_temperature_unit_known
95 end interface kim_known
96
102 interface operator(.eq.)
103 module procedure kim_temperature_unit_equal
104 end interface operator(.eq.)
105
111 interface operator(.ne.)
112 module procedure kim_temperature_unit_not_equal
113 end interface operator(.ne.)
114
123 module procedure kim_temperature_unit_from_string
124 end interface kim_from_string
125
132 module procedure kim_temperature_unit_to_string
133 end interface kim_to_string
134
135contains
141 logical recursive function kim_temperature_unit_known(temperature_unit)
142 implicit none
143 interface
144 integer(c_int) recursive function known(temperature_unit) &
145 bind(c, name="KIM_TemperatureUnit_Known")
146 use, intrinsic :: iso_c_binding
148 implicit none
149 type(kim_temperature_unit_type), intent(in), value :: temperature_unit
150 end function known
151 end interface
152 type(kim_temperature_unit_type), intent(in) :: temperature_unit
153
154 kim_temperature_unit_known = (known(temperature_unit) /= 0)
155 end function kim_temperature_unit_known
156
162 logical recursive function kim_temperature_unit_equal(lhs, rhs)
163 implicit none
164 type(kim_temperature_unit_type), intent(in) :: lhs
165 type(kim_temperature_unit_type), intent(in) :: rhs
166
167 kim_temperature_unit_equal &
168 = (lhs%temperature_unit_id == rhs%temperature_unit_id)
169 end function kim_temperature_unit_equal
170
176 logical recursive function kim_temperature_unit_not_equal(lhs, rhs)
177 implicit none
178 type(kim_temperature_unit_type), intent(in) :: lhs
179 type(kim_temperature_unit_type), intent(in) :: rhs
180
181 kim_temperature_unit_not_equal = .not. (lhs == rhs)
182 end function kim_temperature_unit_not_equal
183
191 recursive subroutine kim_temperature_unit_from_string(string, &
192 temperature_unit)
193 implicit none
194 interface
195 type(kim_temperature_unit_type) recursive function from_string(string) &
196 bind(c, name="KIM_TemperatureUnit_FromString")
197 use, intrinsic :: iso_c_binding
199 implicit none
200 character(c_char), intent(in) :: string(*)
201 end function from_string
202 end interface
203 character(len=*, kind=c_char), intent(in) :: string
204 type(kim_temperature_unit_type), intent(out) :: temperature_unit
205
206 temperature_unit = from_string(trim(string)//c_null_char)
207 end subroutine kim_temperature_unit_from_string
208
214 recursive subroutine kim_temperature_unit_to_string(temperature_unit, string)
215 use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
216 implicit none
217 interface
218 type(c_ptr) recursive function get_string(temperature_unit) &
219 bind(c, name="KIM_TemperatureUnit_ToString")
220 use, intrinsic :: iso_c_binding
222 implicit none
223 type(kim_temperature_unit_type), intent(in), value :: temperature_unit
224 end function get_string
225 end interface
226 type(kim_temperature_unit_type), intent(in) :: temperature_unit
227 character(len=*, kind=c_char), intent(out) :: string
228
229 type(c_ptr) :: p
230
231 p = get_string(temperature_unit)
232 call kim_convert_c_char_ptr_to_string(p, string)
233 end subroutine kim_temperature_unit_to_string
234
242 number_of_temperature_units)
243 implicit none
244 interface
245 recursive subroutine get_number_of_temperature_units( &
246 number_of_temperature_units) &
247 bind(c, name="KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits")
248 use, intrinsic :: iso_c_binding
249 implicit none
250 integer(c_int), intent(out) :: number_of_temperature_units
251 end subroutine get_number_of_temperature_units
252 end interface
253 integer(c_int), intent(out) :: number_of_temperature_units
254
255 call get_number_of_temperature_units(number_of_temperature_units)
257
264 recursive subroutine kim_get_temperature_unit(index, &
265 temperature_unit, ierr)
266 implicit none
267 interface
268 integer(c_int) recursive function get_temperature_unit(index, &
269 temperature_unit) &
270 bind(c, name="KIM_TEMPERATURE_UNIT_GetTemperatureUnit")
271 use, intrinsic :: iso_c_binding
273 implicit none
274 integer(c_int), intent(in), value :: index
275 type(kim_temperature_unit_type), intent(out) :: temperature_unit
276 end function get_temperature_unit
277 end interface
278 integer(c_int), intent(in) :: index
279 type(kim_temperature_unit_type), intent(out) :: temperature_unit
280 integer(c_int), intent(out) :: ierr
281
282 ierr = get_temperature_unit(index - 1, temperature_unit)
283 end subroutine kim_get_temperature_unit
Determines if the object is a quantity known to the KIM API.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
type(kim_temperature_unit_type), save, bind(C, name="KIM_TEMPERATURE_UNIT_K"), public, protected kim_temperature_unit_k
The standard Kelvin unit of temperature.
recursive subroutine, public kim_get_temperature_unit(index, temperature_unit, ierr)
Get the identity of each defined standard TemperatureUnit.
recursive subroutine, public kim_get_number_of_temperature_units(number_of_temperature_units)
Get the number of standard TemperatureUnit's defined by the KIM API.
type(kim_temperature_unit_type), save, bind(C, name="KIM_TEMPERATURE_UNIT_unused"), public, protected kim_temperature_unit_unused
Indicates that a TemperatureUnit is not used.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.