kim-api  2.2.1+v2.2.1.GNU.GNU.
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_collection_item_type_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 types
45  kim_collection_item_type_type, &
46  ! Constants
50  ! Routines
51  kim_known, &
52  operator(.eq.), &
53  operator(.ne.), &
54  kim_from_string, &
55  kim_to_string, &
58 
64  type, bind(c) :: kim_collection_item_type_type
71  integer(c_int) collection_item_type_id
72  end type kim_collection_item_type_type
73 
80  type(kim_collection_item_type_type), protected, save, &
81  bind(c, name="KIM_COLLECTION_ITEM_TYPE_modelDriver") &
83 
90  type(kim_collection_item_type_type), protected, save, &
91  bind(c, name="KIM_COLLECTION_ITEM_TYPE_portableModel") &
93 
100  type(kim_collection_item_type_type), protected, save, &
101  bind(c, name="KIM_COLLECTION_ITEM_TYPE_simulatorModel") &
103 
109  interface kim_known
110  module procedure kim_collection_item_type_known
111  end interface kim_known
112 
118  interface operator(.eq.)
119  module procedure kim_collection_item_type_equal
120  end interface operator(.eq.)
121 
127  interface operator(.ne.)
128  module procedure kim_collection_item_type_not_equal
129  end interface operator(.ne.)
130 
138  interface kim_from_string
139  module procedure kim_collection_item_type_from_string
140  end interface kim_from_string
141 
147  interface kim_to_string
148  module procedure kim_collection_item_type_to_string
149  end interface kim_to_string
150 
151 contains
157  logical recursive function kim_collection_item_type_known( &
158  collection_item_type)
159  implicit none
160  interface
161  integer(c_int) recursive function known(collection_item_type) &
162  bind(c, name="KIM_CollectionItemType_Known")
163  use, intrinsic :: iso_c_binding
164  import kim_collection_item_type_type
165  implicit none
166  type(kim_collection_item_type_type), intent(in), value :: &
167  collection_item_type
168  end function known
169  end interface
170  type(kim_collection_item_type_type), intent(in) :: collection_item_type
171 
172  kim_collection_item_type_known = (known(collection_item_type) /= 0)
173  end function kim_collection_item_type_known
174 
180  logical recursive function kim_collection_item_type_equal(lhs, rhs)
181  implicit none
182  type(kim_collection_item_type_type), intent(in) :: lhs
183  type(kim_collection_item_type_type), intent(in) :: rhs
184 
185  kim_collection_item_type_equal &
186  = (lhs%collection_item_type_id == rhs%collection_item_type_id)
187  end function kim_collection_item_type_equal
188 
194  logical recursive function kim_collection_item_type_not_equal(lhs, rhs)
195  implicit none
196  type(kim_collection_item_type_type), intent(in) :: lhs
197  type(kim_collection_item_type_type), intent(in) :: rhs
198 
199  kim_collection_item_type_not_equal = .not. (lhs == rhs)
200  end function kim_collection_item_type_not_equal
201 
209  recursive subroutine kim_collection_item_type_from_string( &
210  string, collection_item_type)
211  implicit none
212  interface
213  type(kim_collection_item_type_type) recursive function &
214  from_string(string) bind(c, name="KIM_CollectionItemType_FromString")
215  use, intrinsic :: iso_c_binding
216  import kim_collection_item_type_type
217  implicit none
218  character(c_char), intent(in) :: string(*)
219  end function from_string
220  end interface
221  character(len=*, kind=c_char), intent(in) :: string
222  type(kim_collection_item_type_type), intent(out) :: collection_item_type
223 
224  collection_item_type = from_string(trim(string)//c_null_char)
225  end subroutine kim_collection_item_type_from_string
226 
232  recursive subroutine kim_collection_item_type_to_string( &
233  collection_item_type, string)
234  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
235  implicit none
236  interface
237  type(c_ptr) recursive function get_string(collection_item_type) &
238  bind(c, name="KIM_CollectionItemType_ToString")
239  use, intrinsic :: iso_c_binding
240  import kim_collection_item_type_type
241  implicit none
242  type(kim_collection_item_type_type), intent(in), value :: &
243  collection_item_type
244  end function get_string
245  end interface
246  type(kim_collection_item_type_type), intent(in) :: collection_item_type
247  character(len=*, kind=c_char), intent(out) :: string
248 
249  type(c_ptr) :: p
250 
251  p = get_string(collection_item_type)
252  call kim_convert_c_char_ptr_to_string(p, string)
253  end subroutine kim_collection_item_type_to_string
254 
261  recursive subroutine kim_get_number_of_collection_item_types( &
262  number_of_collection_item_types)
263  implicit none
264  interface
265  recursive subroutine get_number_of_collection_item_types( &
266  number_of_collection_item_types) &
267  bind(c, name="KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes")
268  use, intrinsic :: iso_c_binding
269  implicit none
270  integer(c_int), intent(out) :: number_of_collection_item_types
271  end subroutine get_number_of_collection_item_types
272  end interface
273  integer(c_int), intent(out) :: number_of_collection_item_types
274 
275  call get_number_of_collection_item_types(number_of_collection_item_types)
277 
284  recursive subroutine kim_get_collection_item_type(index, &
285  collection_item_type, ierr)
286  implicit none
287  interface
288  integer(c_int) recursive function get_collection_item_type( &
289  index, collection_item_type) &
290  bind(c, name="KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType")
291  use, intrinsic :: iso_c_binding
292  import kim_collection_item_type_type
293  implicit none
294  integer(c_int), intent(in), value :: index
295  type(kim_collection_item_type_type), intent(out) :: collection_item_type
296  end function get_collection_item_type
297  end interface
298  integer(c_int), intent(in) :: index
299  type(kim_collection_item_type_type), intent(out) :: collection_item_type
300  integer(c_int), intent(out) :: ierr
301 
302  ierr = get_collection_item_type(index - 1, collection_item_type)
303  end subroutine kim_get_collection_item_type
type(kim_collection_item_type_type), save, public, protected kim_collection_item_type_model_driver
An Extensible Enumeration for the CollectionItemType's supported by the KIM API.
recursive subroutine, public kim_get_collection_item_type(index, collection_item_type, ierr)
Get the identity of each defined standard CollectionItemType.
recursive subroutine, public kim_get_number_of_collection_item_types(number_of_collection_item_types)
Get the number of standard CollectionItemType's defined by the KIM API.
type(kim_collection_item_type_type), save, public, protected kim_collection_item_type_portable_model
type(kim_collection_item_type_type), save, public, protected kim_collection_item_type_simulator_model