kim-api  2.1.4-git+v2.1.3-git-3-g4c859c7f.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_support_status_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_support_status_type, &
47 
48  ! Constants
53 
54  ! Routines
55  kim_known, &
56  operator (.eq.), &
57  operator (.ne.), &
58  kim_from_string, &
59  kim_to_string, &
62 
63 
69  type, bind(c) :: kim_support_status_type
76  integer(c_int) :: support_status_id
77  end type kim_support_status_type
78 
84  type(kim_support_status_type), protected, save, &
85  bind(c, name="KIM_SUPPORT_STATUS_requiredByAPI") &
87 
93  type(kim_support_status_type), protected, save, &
94  bind(c, name="KIM_SUPPORT_STATUS_notSupported") &
96 
102  type(kim_support_status_type), protected, save, &
103  bind(c, name="KIM_SUPPORT_STATUS_required") &
105 
111  type(kim_support_status_type), protected, save, &
112  bind(c, name="KIM_SUPPORT_STATUS_optional") &
114 
120  interface kim_known
121  module procedure kim_support_status_known
122  end interface kim_known
123 
129  interface operator (.eq.)
130  module procedure kim_support_status_equal
131  end interface operator (.eq.)
132 
138  interface operator (.ne.)
139  module procedure kim_support_status_not_equal
140  end interface operator (.ne.)
141 
148  interface kim_from_string
149  module procedure kim_support_status_from_string
150  end interface kim_from_string
151 
157  interface kim_to_string
158  module procedure kim_support_status_to_string
159  end interface kim_to_string
160 
161 contains
167  logical recursive function kim_support_status_known(support_status)
168  implicit none
169  interface
170  integer(c_int) recursive function known(support_status) &
171  bind(c, name="KIM_SupportStatus_Known")
172  use, intrinsic :: iso_c_binding
173  import kim_support_status_type
174  implicit none
175  type(kim_support_status_type), intent(in), value :: support_status
176  end function known
177  end interface
178  type(kim_support_status_type), intent(in) :: support_status
179 
180  kim_support_status_known = (known(support_status) /= 0)
181  end function kim_support_status_known
182 
188  logical recursive function kim_support_status_equal(lhs, rhs)
189  implicit none
190  type(kim_support_status_type), intent(in) :: lhs
191  type(kim_support_status_type), intent(in) :: rhs
192 
193  kim_support_status_equal &
194  = (lhs%support_status_id .eq. rhs%support_status_id)
195  end function kim_support_status_equal
196 
202  logical recursive function kim_support_status_not_equal(lhs, rhs)
203  implicit none
204  type(kim_support_status_type), intent(in) :: lhs
205  type(kim_support_status_type), intent(in) :: rhs
206 
207  kim_support_status_not_equal = .not. (lhs .eq. rhs)
208  end function kim_support_status_not_equal
209 
216  recursive subroutine kim_support_status_from_string(string, support_status)
217  implicit none
218  interface
219  type(kim_support_status_type) recursive function from_string(string) &
220  bind(c, name="KIM_SupportStatus_FromString")
221  use, intrinsic :: iso_c_binding
222  import kim_support_status_type
223  implicit none
224  character(c_char), intent(in) :: string(*)
225  end function from_string
226  end interface
227  character(len=*, kind=c_char), intent(in) :: string
228  type(kim_support_status_type), intent(out) :: support_status
229 
230  support_status = from_string(trim(string)//c_null_char)
231  end subroutine kim_support_status_from_string
232 
238  recursive subroutine kim_support_status_to_string(support_status, string)
239  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
240  implicit none
241  interface
242  type(c_ptr) recursive function get_string(support_status) &
243  bind(c, name="KIM_SupportStatus_ToString")
244  use, intrinsic :: iso_c_binding
245  import kim_support_status_type
246  implicit none
247  type(kim_support_status_type), intent(in), value :: support_status
248  end function get_string
249  end interface
250  type(kim_support_status_type), intent(in) :: support_status
251  character(len=*, kind=c_char), intent(out) :: string
252 
253  type(c_ptr) :: p
254 
255  p = get_string(support_status)
256  call kim_convert_c_char_ptr_to_string(p, string)
257  end subroutine kim_support_status_to_string
258 
265  recursive subroutine kim_get_number_of_support_statuses( &
266  number_of_support_statuses)
267  implicit none
268  interface
269  recursive subroutine get_number_of_support_statuses( &
270  number_of_support_statuses) &
271  bind(c, name="KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses")
272  use, intrinsic :: iso_c_binding
273  implicit none
274  integer(c_int), intent(out) :: number_of_support_statuses
275  end subroutine get_number_of_support_statuses
276  end interface
277  integer(c_int), intent(out) :: number_of_support_statuses
278 
279  call get_number_of_support_statuses(number_of_support_statuses)
281 
288  recursive subroutine kim_get_support_status(index, support_status, ierr)
289  implicit none
290  interface
291  integer(c_int) recursive function get_support_status(index, &
292  support_status) bind(c, name="KIM_SUPPORT_STATUS_GetSupportStatus")
293  use, intrinsic :: iso_c_binding
294  import kim_support_status_type
295  implicit none
296  integer(c_int), intent(in), value :: index
297  type(kim_support_status_type), intent(out) :: support_status
298  end function get_support_status
299  end interface
300  integer(c_int), intent(in) :: index
301  type(kim_support_status_type), intent(out) :: support_status
302  integer(c_int), intent(out) :: ierr
303 
304  ierr = get_support_status(index-1, support_status)
305  end subroutine kim_get_support_status
306 end module kim_support_status_module
type(kim_support_status_type), save, public, protected kim_support_status_not_supported
recursive subroutine, public kim_get_support_status(index, support_status, ierr)
Get the identity of each defined standard SupportStatus.
recursive subroutine, public kim_get_number_of_support_statuses(number_of_support_statuses)
Get the number of standard SupportStatus's defined by the KIM API.
type(kim_support_status_type), save, public, protected kim_support_status_required_by_api
An Extensible Enumeration for the SupportStatus's supported by the KIM API.
type(kim_support_status_type), save, public, protected kim_support_status_optional
type(kim_support_status_type), save, public, protected kim_support_status_required