kim-api  2.1.4-git+v2.1.3-git-1-g7847914a.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--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.git repository.
31 !
32 
33 
40  use, intrinsic :: iso_c_binding
41  implicit none
42  private
43 
44  public &
45  ! Derived types
46  kim_collection_item_type_type, &
47 
48  ! Constants
52 
53  ! Routines
54  kim_known, &
55  operator (.eq.), &
56  operator (.ne.), &
57  kim_from_string, &
58  kim_to_string, &
61 
62 
68  type, bind(c) :: kim_collection_item_type_type
75  integer(c_int) collection_item_type_id
76  end type kim_collection_item_type_type
77 
84  type(kim_collection_item_type_type), protected, save, &
85  bind(c, name="KIM_COLLECTION_ITEM_TYPE_modelDriver") &
87 
94  type(kim_collection_item_type_type), protected, save, &
95  bind(c, name="KIM_COLLECTION_ITEM_TYPE_portableModel") &
97 
104  type(kim_collection_item_type_type), protected, save, &
105  bind(c, name="KIM_COLLECTION_ITEM_TYPE_simulatorModel") &
107 
113  interface kim_known
114  module procedure kim_collection_item_type_known
115  end interface kim_known
116 
122  interface operator (.eq.)
123  module procedure kim_collection_item_type_equal
124  end interface operator (.eq.)
125 
131  interface operator (.ne.)
132  module procedure kim_collection_item_type_not_equal
133  end interface operator (.ne.)
134 
142  interface kim_from_string
143  module procedure kim_collection_item_type_from_string
144  end interface kim_from_string
145 
151  interface kim_to_string
152  module procedure kim_collection_item_type_to_string
153  end interface kim_to_string
154 
155 contains
161  logical recursive function kim_collection_item_type_known( &
162  collection_item_type)
163  implicit none
164  interface
165  integer(c_int) recursive function known(collection_item_type) &
166  bind(c, name="KIM_CollectionItemType_Known")
167  use, intrinsic :: iso_c_binding
168  import kim_collection_item_type_type
169  implicit none
170  type(kim_collection_item_type_type), intent(in), value :: &
171  collection_item_type
172  end function known
173  end interface
174  type(kim_collection_item_type_type), intent(in) :: collection_item_type
175 
176  kim_collection_item_type_known = (known(collection_item_type) /= 0)
177  end function kim_collection_item_type_known
178 
184  logical recursive function kim_collection_item_type_equal(lhs, rhs)
185  implicit none
186  type(kim_collection_item_type_type), intent(in) :: lhs
187  type(kim_collection_item_type_type), intent(in) :: rhs
188 
189  kim_collection_item_type_equal &
190  = (lhs%collection_item_type_id .eq. rhs%collection_item_type_id)
191  end function kim_collection_item_type_equal
192 
198  logical recursive function kim_collection_item_type_not_equal(lhs, rhs)
199  implicit none
200  type(kim_collection_item_type_type), intent(in) :: lhs
201  type(kim_collection_item_type_type), intent(in) :: rhs
202 
203  kim_collection_item_type_not_equal = .not. (lhs .eq. rhs)
204  end function kim_collection_item_type_not_equal
205 
213  recursive subroutine kim_collection_item_type_from_string(string, &
214  collection_item_type)
215  implicit none
216  interface
217  type(kim_collection_item_type_type) recursive function &
218  from_string(string) bind(c, name="KIM_CollectionItemType_FromString")
219  use, intrinsic :: iso_c_binding
220  import kim_collection_item_type_type
221  implicit none
222  character(c_char), intent(in) :: string(*)
223  end function from_string
224  end interface
225  character(len=*, kind=c_char), intent(in) :: string
226  type(kim_collection_item_type_type), intent(out) :: collection_item_type
227 
228  collection_item_type = from_string(trim(string)//c_null_char)
229  end subroutine kim_collection_item_type_from_string
230 
236  recursive subroutine kim_collection_item_type_to_string( &
237  collection_item_type, 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(collection_item_type) &
242  bind(c, name="KIM_CollectionItemType_ToString")
243  use, intrinsic :: iso_c_binding
244  import kim_collection_item_type_type
245  implicit none
246  type(kim_collection_item_type_type), intent(in), value :: &
247  collection_item_type
248  end function get_string
249  end interface
250  type(kim_collection_item_type_type), intent(in) :: collection_item_type
251  character(len=*, kind=c_char), intent(out) :: string
252 
253  type(c_ptr) :: p
254 
255  p = get_string(collection_item_type)
256  call kim_convert_c_char_ptr_to_string(p, string)
257  end subroutine kim_collection_item_type_to_string
258 
265  recursive subroutine kim_get_number_of_collection_item_types( &
266  number_of_collection_item_types)
267  implicit none
268  interface
269  recursive subroutine get_number_of_collection_item_types( &
270  number_of_collection_item_types) &
271  bind(c, name="KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes")
272  use, intrinsic :: iso_c_binding
273  implicit none
274  integer(c_int), intent(out) :: number_of_collection_item_types
275  end subroutine get_number_of_collection_item_types
276  end interface
277  integer(c_int), intent(out) :: number_of_collection_item_types
278 
279  call get_number_of_collection_item_types(number_of_collection_item_types)
281 
288  recursive subroutine kim_get_collection_item_type(index, &
289  collection_item_type, ierr)
290  implicit none
291  interface
292  integer(c_int) recursive function get_collection_item_type(index, &
293  collection_item_type) &
294  bind(c, name="KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType")
295  use, intrinsic :: iso_c_binding
296  import kim_collection_item_type_type
297  implicit none
298  integer(c_int), intent(in), value :: index
299  type(kim_collection_item_type_type), intent(out) :: collection_item_type
300  end function get_collection_item_type
301  end interface
302  integer(c_int), intent(in) :: index
303  type(kim_collection_item_type_type), intent(out) :: collection_item_type
304  integer(c_int), intent(out) :: ierr
305 
306  ierr = get_collection_item_type(index-1, collection_item_type)
307  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