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_collection_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 types
43 ! Constants
48 ! Routines
49 kim_known, &
50 operator(.eq.), &
51 operator(.ne.), &
56
62 type, bind(c) :: kim_collection_type
68 integer(c_int) collection_id
69 end type kim_collection_type
70
76 type(kim_collection_type), protected, save, &
77 bind(c, name="KIM_COLLECTION_system") &
79
85 type(kim_collection_type), protected, save, &
86 bind(c, name="KIM_COLLECTION_user") &
88
95 type(kim_collection_type), protected, save, &
96 bind(c, name="KIM_COLLECTION_environmentVariable") &
98
105 type(kim_collection_type), protected, save, &
106 bind(c, name="KIM_COLLECTION_currentWorkingDirectory") &
108
114 interface kim_known
115 module procedure kim_collection_known
116 end interface kim_known
117
123 interface operator(.eq.)
124 module procedure kim_collection_equal
125 end interface operator(.eq.)
126
132 interface operator(.ne.)
133 module procedure kim_collection_not_equal
134 end interface operator(.ne.)
135
143 module procedure kim_collection_from_string
144 end interface kim_from_string
145
152 module procedure kim_collection_to_string
153 end interface kim_to_string
154
155contains
161 logical recursive function kim_collection_known(collection)
162 implicit none
163 interface
164 integer(c_int) recursive function known(collection) &
165 bind(c, name="KIM_Collection_Known")
166 use, intrinsic :: iso_c_binding
168 implicit none
169 type(kim_collection_type), intent(in), value :: collection
170 end function known
171 end interface
172 type(kim_collection_type), intent(in) :: collection
173
174 kim_collection_known = (known(collection) /= 0)
175 end function kim_collection_known
176
182 logical recursive function kim_collection_equal(lhs, rhs)
183 implicit none
184 type(kim_collection_type), intent(in) :: lhs
185 type(kim_collection_type), intent(in) :: rhs
186
187 kim_collection_equal &
188 = (lhs%collection_id == rhs%collection_id)
189 end function kim_collection_equal
190
196 logical recursive function kim_collection_not_equal(lhs, rhs)
197 implicit none
198 type(kim_collection_type), intent(in) :: lhs
199 type(kim_collection_type), intent(in) :: rhs
200
201 kim_collection_not_equal = .not. (lhs == rhs)
202 end function kim_collection_not_equal
203
210 recursive subroutine kim_collection_from_string(string, collection)
211 implicit none
212 interface
213 type(kim_collection_type) recursive function from_string(string) &
214 bind(c, name="KIM_Collection_FromString")
215 use, intrinsic :: iso_c_binding
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_type), intent(out) :: collection
223
224 collection = from_string(trim(string)//c_null_char)
225 end subroutine kim_collection_from_string
226
232 recursive subroutine kim_collection_to_string(collection, string)
233 use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
234 implicit none
235 interface
236 type(c_ptr) recursive function get_string(collection) &
237 bind(c, name="KIM_Collection_ToString")
238 use, intrinsic :: iso_c_binding
240 implicit none
241 type(kim_collection_type), intent(in), value :: collection
242 end function get_string
243 end interface
244 type(kim_collection_type), intent(in) :: collection
245 character(len=*, kind=c_char), intent(out) :: string
246
247 type(c_ptr) :: p
248
249 p = get_string(collection)
250 call kim_convert_c_char_ptr_to_string(p, string)
251 end subroutine kim_collection_to_string
252
259 recursive subroutine kim_get_number_of_collections(number_of_collections)
260 implicit none
261 interface
262 recursive subroutine get_number_of_collections(number_of_collections) &
263 bind(c, name="KIM_COLLECTION_GetNumberOfCollections")
264 use, intrinsic :: iso_c_binding
265 implicit none
266 integer(c_int), intent(out) :: number_of_collections
267 end subroutine get_number_of_collections
268 end interface
269 integer(c_int), intent(out) :: number_of_collections
270
271 call get_number_of_collections(number_of_collections)
272 end subroutine kim_get_number_of_collections
273
279 recursive subroutine kim_get_collection(index, collection, ierr)
280 implicit none
281 interface
282 integer(c_int) recursive function get_collection(index, collection) &
283 bind(c, name="KIM_COLLECTION_GetCollection")
284 use, intrinsic :: iso_c_binding
286 implicit none
287 integer(c_int), intent(in), value :: index
288 type(kim_collection_type), intent(out) :: collection
289 end function get_collection
290 end interface
291 integer(c_int), intent(in) :: index
292 type(kim_collection_type), intent(out) :: collection
293 integer(c_int), intent(out) :: ierr
294
295 ierr = get_collection(index - 1, collection)
296 end subroutine kim_get_collection
297end module kim_collection_module
Create a Collection object corresponding to the provided string. If the string does not match one of ...
Determines if the object is a quantity known to the KIM API.
Converts the object to a string.
An Extensible Enumeration for the Collection's supported by the KIM API.
type(kim_collection_type), save, bind(C, name="KIM_COLLECTION_system"), public, protected kim_collection_system
The standard system Collection.
type(kim_collection_type), save, bind(C, name="KIM_COLLECTION_user"), public, protected kim_collection_user
The standard user Collection.
type(kim_collection_type), save, bind(C, name="KIM_COLLECTION_environmentVariable"), public, protected kim_collection_environment_variable
The standard environmentVariable Collection.
type(kim_collection_type), save, bind(C, name="KIM_COLLECTION_currentWorkingDirectory"), public, protected kim_collection_current_working_directory
The standard currentWorkingDirectory Collection.
recursive subroutine, public kim_get_collection(index, collection, ierr)
Get the identity of each defined standard Collection.
recursive subroutine, public kim_get_number_of_collections(number_of_collections)
Get the number of standard Collection's defined by the KIM API.
An Extensible Enumeration for the Collection's supported by the KIM API.