kim-api  2.1.2+v2.1.2.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_temperature_unit_module.f90
Go to the documentation of this file.
1 !
2 ! CDDL HEADER START
3 !
4 ! The contents of this file are subject to the terms of the Common Development
5 ! and Distribution License Version 1.0 (the "License").
6 !
7 ! You can obtain a copy of the license at
8 ! http://www.opensource.org/licenses/CDDL-1.0. See the License for the
9 ! specific language governing permissions and limitations under the License.
10 !
11 ! When distributing Covered Code, include this CDDL HEADER in each file and
12 ! include the License file in a prominent location with the name LICENSE.CDDL.
13 ! If applicable, add the following below this CDDL HEADER, with the fields
14 ! enclosed by brackets "[]" replaced with your own identifying information:
15 !
16 ! Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
17 !
18 ! CDDL HEADER END
19 !
20 
21 !
22 ! Copyright (c) 2016--2019, Regents of the University of Minnesota.
23 ! All rights reserved.
24 !
25 ! Contributors:
26 ! Ryan S. Elliott
27 !
28 
29 !
30 ! Release: This file is part of the kim-api-2.1.2 package.
31 !
32 
33 
40  use, intrinsic :: iso_c_binding
41  implicit none
42  private
43 
44  public &
45  ! Derived type
46  kim_temperature_unit_type, &
47 
48  ! Constants
51 
52  ! Routines
53  kim_known, &
54  operator (.eq.), &
55  operator (.ne.), &
56  kim_from_string, &
57  kim_to_string, &
60 
61 
67  type, bind(c) :: kim_temperature_unit_type
74  integer(c_int) temperature_unit_id
75  end type kim_temperature_unit_type
76 
82  type(kim_temperature_unit_type), protected, save, &
83  bind(c, name="KIM_TEMPERATURE_UNIT_unused") &
85 
91  type(kim_temperature_unit_type), protected, save, &
92  bind(c, name="KIM_TEMPERATURE_UNIT_K") &
94 
100  interface kim_known
101  module procedure kim_temperature_unit_known
102  end interface kim_known
103 
109  interface operator (.eq.)
110  module procedure kim_temperature_unit_equal
111  end interface operator (.eq.)
112 
118  interface operator (.ne.)
119  module procedure kim_temperature_unit_not_equal
120  end interface operator (.ne.)
121 
129  interface kim_from_string
130  module procedure kim_temperature_unit_from_string
131  end interface kim_from_string
132 
138  interface kim_to_string
139  module procedure kim_temperature_unit_to_string
140  end interface kim_to_string
141 
142 contains
148  logical recursive function kim_temperature_unit_known(temperature_unit)
149  implicit none
150  interface
151  integer(c_int) recursive function known(temperature_unit) &
152  bind(c, name="KIM_TemperatureUnit_Known")
153  use, intrinsic :: iso_c_binding
154  import kim_temperature_unit_type
155  implicit none
156  type(kim_temperature_unit_type), intent(in), value :: temperature_unit
157  end function known
158  end interface
159  type(kim_temperature_unit_type), intent(in) :: temperature_unit
160 
161  kim_temperature_unit_known = (known(temperature_unit) /= 0)
162  end function kim_temperature_unit_known
163 
169  logical recursive function kim_temperature_unit_equal(lhs, rhs)
170  implicit none
171  type(kim_temperature_unit_type), intent(in) :: lhs
172  type(kim_temperature_unit_type), intent(in) :: rhs
173 
174  kim_temperature_unit_equal &
175  = (lhs%temperature_unit_id .eq. rhs%temperature_unit_id)
176  end function kim_temperature_unit_equal
177 
183  logical recursive function kim_temperature_unit_not_equal(lhs, rhs)
184  implicit none
185  type(kim_temperature_unit_type), intent(in) :: lhs
186  type(kim_temperature_unit_type), intent(in) :: rhs
187 
188  kim_temperature_unit_not_equal = .not. (lhs .eq. rhs)
189  end function kim_temperature_unit_not_equal
190 
198  recursive subroutine kim_temperature_unit_from_string(string, &
199  temperature_unit)
200  implicit none
201  interface
202  type(kim_temperature_unit_type) recursive function from_string(string) &
203  bind(c, name="KIM_TemperatureUnit_FromString")
204  use, intrinsic :: iso_c_binding
205  import kim_temperature_unit_type
206  implicit none
207  character(c_char), intent(in) :: string(*)
208  end function from_string
209  end interface
210  character(len=*, kind=c_char), intent(in) :: string
211  type(kim_temperature_unit_type), intent(out) :: temperature_unit
212 
213  temperature_unit = from_string(trim(string)//c_null_char)
214  end subroutine kim_temperature_unit_from_string
215 
221  recursive subroutine kim_temperature_unit_to_string(temperature_unit, string)
222  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
223  implicit none
224  interface
225  type(c_ptr) recursive function get_string(temperature_unit) &
226  bind(c, name="KIM_TemperatureUnit_ToString")
227  use, intrinsic :: iso_c_binding
228  import kim_temperature_unit_type
229  implicit none
230  type(kim_temperature_unit_type), intent(in), value :: temperature_unit
231  end function get_string
232  end interface
233  type(kim_temperature_unit_type), intent(in) :: temperature_unit
234  character(len=*, kind=c_char), intent(out) :: string
235 
236  type(c_ptr) :: p
237 
238  p = get_string(temperature_unit)
239  call kim_convert_c_char_ptr_to_string(p, string)
240  end subroutine kim_temperature_unit_to_string
241 
248  recursive subroutine kim_get_number_of_temperature_units( &
249  number_of_temperature_units)
250  implicit none
251  interface
252  recursive subroutine get_number_of_temperature_units( &
253  number_of_temperature_units) &
254  bind(c, name="KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits")
255  use, intrinsic :: iso_c_binding
256  implicit none
257  integer(c_int), intent(out) :: number_of_temperature_units
258  end subroutine get_number_of_temperature_units
259  end interface
260  integer(c_int), intent(out) :: number_of_temperature_units
261 
262  call get_number_of_temperature_units(number_of_temperature_units)
264 
271  recursive subroutine kim_get_temperature_unit(index, &
272  temperature_unit, ierr)
273  implicit none
274  interface
275  integer(c_int) recursive function get_temperature_unit(index, &
276  temperature_unit) &
277  bind(c, name="KIM_TEMPERATURE_UNIT_GetTemperatureUnit")
278  use, intrinsic :: iso_c_binding
279  import kim_temperature_unit_type
280  implicit none
281  integer(c_int), intent(in), value :: index
282  type(kim_temperature_unit_type), intent(out) :: temperature_unit
283  end function get_temperature_unit
284  end interface
285  integer(c_int), intent(in) :: index
286  type(kim_temperature_unit_type), intent(out) :: temperature_unit
287  integer(c_int), intent(out) :: ierr
288 
289  ierr = get_temperature_unit(index-1, temperature_unit)
290  end subroutine kim_get_temperature_unit
recursive subroutine, public kim_get_temperature_unit(index, temperature_unit, ierr)
Get the identity of each defined standard TemperatureUnit.
type(kim_temperature_unit_type), save, public, protected kim_temperature_unit_k
type(kim_temperature_unit_type), save, public, protected kim_temperature_unit_unused
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.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.