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_numbering_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
46 ! Routines
47 kim_known, &
48 operator(.eq.), &
49 operator(.ne.), &
54
60 type, bind(c) :: kim_numbering_type
61 integer(c_int) :: numbering_id
62 end type kim_numbering_type
63
69 type(kim_numbering_type), protected, save, &
70 bind(c, name="KIM_NUMBERING_zeroBased") &
72
78 type(kim_numbering_type), protected, save, &
79 bind(c, name="KIM_NUMBERING_oneBased") &
81
87 interface kim_known
88 module procedure kim_numbering_known
89 end interface kim_known
90
96 interface operator(.eq.)
97 module procedure kim_numbering_equal
98 end interface operator(.eq.)
99
105 interface operator(.ne.)
106 module procedure kim_numbering_not_equal
107 end interface operator(.ne.)
108
116 module procedure kim_numbering_from_string
117 end interface kim_from_string
118
125 module procedure kim_numbering_to_string
126 end interface kim_to_string
127
128contains
134 logical recursive function kim_numbering_known(numbering)
135 implicit none
136 interface
137 integer(c_int) recursive function known(numbering) &
138 bind(c, name="KIM_Numbering_Known")
139 use, intrinsic :: iso_c_binding
140 import kim_numbering_type
141 implicit none
142 type(kim_numbering_type), intent(in), value :: numbering
143 end function known
144 end interface
145 type(kim_numbering_type), intent(in) :: numbering
146
147 kim_numbering_known = (known(numbering) /= 0)
148 end function kim_numbering_known
149
155 logical recursive function kim_numbering_equal(lhs, rhs)
156 implicit none
157 type(kim_numbering_type), intent(in) :: lhs
158 type(kim_numbering_type), intent(in) :: rhs
159
160 kim_numbering_equal = (lhs%numbering_id == rhs%numbering_id)
161 end function kim_numbering_equal
162
168 logical recursive function kim_numbering_not_equal(lhs, rhs)
169 implicit none
170 type(kim_numbering_type), intent(in) :: lhs
171 type(kim_numbering_type), intent(in) :: rhs
172
173 kim_numbering_not_equal = .not. (lhs == rhs)
174 end function kim_numbering_not_equal
175
182 recursive subroutine kim_numbering_from_string(string, numbering)
183 implicit none
184 interface
185 type(kim_numbering_type) recursive function from_string(string) &
186 bind(c, name="KIM_Numbering_FromString")
187 use, intrinsic :: iso_c_binding
188 import kim_numbering_type
189 implicit none
190 character(c_char), intent(in) :: string(*)
191 end function from_string
192 end interface
193 character(len=*, kind=c_char), intent(in) :: string
194 type(kim_numbering_type), intent(out) :: numbering
195
196 numbering = from_string(trim(string)//c_null_char)
197 end subroutine kim_numbering_from_string
198
204 recursive subroutine kim_numbering_to_string(numbering, string)
205 use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
206 implicit none
207 interface
208 type(c_ptr) recursive function get_string(numbering) &
209 bind(c, name="KIM_Numbering_ToString")
210 use, intrinsic :: iso_c_binding
211 import kim_numbering_type
212 implicit none
213 type(kim_numbering_type), intent(in), value :: numbering
214 end function get_string
215 end interface
216 type(kim_numbering_type), intent(in) :: numbering
217 character(len=*, kind=c_char), intent(out) :: string
218
219 type(c_ptr) :: p
220
221 p = get_string(numbering)
222 call kim_convert_c_char_ptr_to_string(p, string)
223 end subroutine kim_numbering_to_string
224
231 recursive subroutine kim_get_number_of_numberings(number_of_numberings)
232 implicit none
233 interface
234 recursive subroutine get_number_of_numberings(number_of_numberings) &
235 bind(c, name="KIM_NUMBERING_GetNumberOfNumberings")
236 use, intrinsic :: iso_c_binding
237 implicit none
238 integer(c_int), intent(out) :: number_of_numberings
239 end subroutine get_number_of_numberings
240 end interface
241 integer(c_int), intent(out) :: number_of_numberings
242
243 call get_number_of_numberings(number_of_numberings)
244 end subroutine kim_get_number_of_numberings
245
251 recursive subroutine kim_get_numbering(index, numbering, ierr)
252 implicit none
253 interface
254 integer(c_int) recursive function get_numbering(index, numbering) &
255 bind(c, name="KIM_NUMBERING_GetNumbering")
256 use, intrinsic :: iso_c_binding
257 import kim_numbering_type
258 implicit none
259 integer(c_int), intent(in), value :: index
260 type(kim_numbering_type), intent(out) :: numbering
261 end function get_numbering
262 end interface
263 integer(c_int), intent(in) :: index
264 type(kim_numbering_type), intent(out) :: numbering
265 integer(c_int), intent(out) :: ierr
266
267 ierr = get_numbering(index - 1, numbering)
268 end subroutine kim_get_numbering
269end module kim_numbering_module
Create a Numbering object corresponding to the provided string. If the string does not match one of t...
Determines if the object is a quantity known to the KIM API.
Converts the object to a string.
An Extensible Enumeration for the Numbering's supported by the KIM API.
recursive subroutine, public kim_get_number_of_numberings(number_of_numberings)
Get the number of standard Numbering's defined by the KIM API.
type(kim_numbering_type), save, bind(C, name="KIM_NUMBERING_zeroBased"), public, protected kim_numbering_zero_based
The standard zeroBased numbering.
recursive subroutine, public kim_get_numbering(index, numbering, ierr)
Get the identity of each defined standard Numbering.
type(kim_numbering_type), save, bind(C, name="KIM_NUMBERING_oneBased"), public, protected kim_numbering_one_based
The standard oneBased numbering.
An Extensible Enumeration for the Numbering's supported by the KIM API.