kim-api  2.2.1+v2.2.1.GNU.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--2020, 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.2.1 package.
31 !
32 
39  use, intrinsic :: iso_c_binding
40  implicit none
41  private
42 
43  public &
44  ! Derived type
45  kim_temperature_unit_type, &
46  ! Constants
49  ! Routines
50  kim_known, &
51  operator(.eq.), &
52  operator(.ne.), &
53  kim_from_string, &
54  kim_to_string, &
57 
63  type, bind(c) :: kim_temperature_unit_type
70  integer(c_int) temperature_unit_id
71  end type kim_temperature_unit_type
72 
78  type(kim_temperature_unit_type), protected, save, &
79  bind(c, name="KIM_TEMPERATURE_UNIT_unused") &
81 
87  type(kim_temperature_unit_type), protected, save, &
88  bind(c, name="KIM_TEMPERATURE_UNIT_K") &
90 
96  interface kim_known
97  module procedure kim_temperature_unit_known
98  end interface kim_known
99 
105  interface operator(.eq.)
106  module procedure kim_temperature_unit_equal
107  end interface operator(.eq.)
108 
114  interface operator(.ne.)
115  module procedure kim_temperature_unit_not_equal
116  end interface operator(.ne.)
117 
125  interface kim_from_string
126  module procedure kim_temperature_unit_from_string
127  end interface kim_from_string
128 
134  interface kim_to_string
135  module procedure kim_temperature_unit_to_string
136  end interface kim_to_string
137 
138 contains
144  logical recursive function kim_temperature_unit_known(temperature_unit)
145  implicit none
146  interface
147  integer(c_int) recursive function known(temperature_unit) &
148  bind(c, name="KIM_TemperatureUnit_Known")
149  use, intrinsic :: iso_c_binding
150  import kim_temperature_unit_type
151  implicit none
152  type(kim_temperature_unit_type), intent(in), value :: temperature_unit
153  end function known
154  end interface
155  type(kim_temperature_unit_type), intent(in) :: temperature_unit
156 
157  kim_temperature_unit_known = (known(temperature_unit) /= 0)
158  end function kim_temperature_unit_known
159 
165  logical recursive function kim_temperature_unit_equal(lhs, rhs)
166  implicit none
167  type(kim_temperature_unit_type), intent(in) :: lhs
168  type(kim_temperature_unit_type), intent(in) :: rhs
169 
170  kim_temperature_unit_equal &
171  = (lhs%temperature_unit_id == rhs%temperature_unit_id)
172  end function kim_temperature_unit_equal
173 
179  logical recursive function kim_temperature_unit_not_equal(lhs, rhs)
180  implicit none
181  type(kim_temperature_unit_type), intent(in) :: lhs
182  type(kim_temperature_unit_type), intent(in) :: rhs
183 
184  kim_temperature_unit_not_equal = .not. (lhs == rhs)
185  end function kim_temperature_unit_not_equal
186 
194  recursive subroutine kim_temperature_unit_from_string(string, &
195  temperature_unit)
196  implicit none
197  interface
198  type(kim_temperature_unit_type) recursive function from_string(string) &
199  bind(c, name="KIM_TemperatureUnit_FromString")
200  use, intrinsic :: iso_c_binding
201  import kim_temperature_unit_type
202  implicit none
203  character(c_char), intent(in) :: string(*)
204  end function from_string
205  end interface
206  character(len=*, kind=c_char), intent(in) :: string
207  type(kim_temperature_unit_type), intent(out) :: temperature_unit
208 
209  temperature_unit = from_string(trim(string)//c_null_char)
210  end subroutine kim_temperature_unit_from_string
211 
217  recursive subroutine kim_temperature_unit_to_string(temperature_unit, string)
218  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
219  implicit none
220  interface
221  type(c_ptr) recursive function get_string(temperature_unit) &
222  bind(c, name="KIM_TemperatureUnit_ToString")
223  use, intrinsic :: iso_c_binding
224  import kim_temperature_unit_type
225  implicit none
226  type(kim_temperature_unit_type), intent(in), value :: temperature_unit
227  end function get_string
228  end interface
229  type(kim_temperature_unit_type), intent(in) :: temperature_unit
230  character(len=*, kind=c_char), intent(out) :: string
231 
232  type(c_ptr) :: p
233 
234  p = get_string(temperature_unit)
235  call kim_convert_c_char_ptr_to_string(p, string)
236  end subroutine kim_temperature_unit_to_string
237 
244  recursive subroutine kim_get_number_of_temperature_units( &
245  number_of_temperature_units)
246  implicit none
247  interface
248  recursive subroutine get_number_of_temperature_units( &
249  number_of_temperature_units) &
250  bind(c, name="KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits")
251  use, intrinsic :: iso_c_binding
252  implicit none
253  integer(c_int), intent(out) :: number_of_temperature_units
254  end subroutine get_number_of_temperature_units
255  end interface
256  integer(c_int), intent(out) :: number_of_temperature_units
257 
258  call get_number_of_temperature_units(number_of_temperature_units)
260 
267  recursive subroutine kim_get_temperature_unit(index, &
268  temperature_unit, ierr)
269  implicit none
270  interface
271  integer(c_int) recursive function get_temperature_unit(index, &
272  temperature_unit) &
273  bind(c, name="KIM_TEMPERATURE_UNIT_GetTemperatureUnit")
274  use, intrinsic :: iso_c_binding
275  import kim_temperature_unit_type
276  implicit none
277  integer(c_int), intent(in), value :: index
278  type(kim_temperature_unit_type), intent(out) :: temperature_unit
279  end function get_temperature_unit
280  end interface
281  integer(c_int), intent(in) :: index
282  type(kim_temperature_unit_type), intent(out) :: temperature_unit
283  integer(c_int), intent(out) :: ierr
284 
285  ierr = get_temperature_unit(index - 1, temperature_unit)
286  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.