kim-api  2.2.1+v2.2.1.GNU.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--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_support_status_type, &
46  ! Constants
51  ! Routines
52  kim_known, &
53  operator(.eq.), &
54  operator(.ne.), &
55  kim_from_string, &
56  kim_to_string, &
59 
65  type, bind(c) :: kim_support_status_type
72  integer(c_int) :: support_status_id
73  end type kim_support_status_type
74 
80  type(kim_support_status_type), protected, save, &
81  bind(c, name="KIM_SUPPORT_STATUS_requiredByAPI") &
83 
89  type(kim_support_status_type), protected, save, &
90  bind(c, name="KIM_SUPPORT_STATUS_notSupported") &
92 
98  type(kim_support_status_type), protected, save, &
99  bind(c, name="KIM_SUPPORT_STATUS_required") &
101 
107  type(kim_support_status_type), protected, save, &
108  bind(c, name="KIM_SUPPORT_STATUS_optional") &
110 
116  interface kim_known
117  module procedure kim_support_status_known
118  end interface kim_known
119 
125  interface operator(.eq.)
126  module procedure kim_support_status_equal
127  end interface operator(.eq.)
128 
134  interface operator(.ne.)
135  module procedure kim_support_status_not_equal
136  end interface operator(.ne.)
137 
144  interface kim_from_string
145  module procedure kim_support_status_from_string
146  end interface kim_from_string
147 
153  interface kim_to_string
154  module procedure kim_support_status_to_string
155  end interface kim_to_string
156 
157 contains
163  logical recursive function kim_support_status_known(support_status)
164  implicit none
165  interface
166  integer(c_int) recursive function known(support_status) &
167  bind(c, name="KIM_SupportStatus_Known")
168  use, intrinsic :: iso_c_binding
169  import kim_support_status_type
170  implicit none
171  type(kim_support_status_type), intent(in), value :: support_status
172  end function known
173  end interface
174  type(kim_support_status_type), intent(in) :: support_status
175 
176  kim_support_status_known = (known(support_status) /= 0)
177  end function kim_support_status_known
178 
184  logical recursive function kim_support_status_equal(lhs, rhs)
185  implicit none
186  type(kim_support_status_type), intent(in) :: lhs
187  type(kim_support_status_type), intent(in) :: rhs
188 
189  kim_support_status_equal &
190  = (lhs%support_status_id == rhs%support_status_id)
191  end function kim_support_status_equal
192 
198  logical recursive function kim_support_status_not_equal(lhs, rhs)
199  implicit none
200  type(kim_support_status_type), intent(in) :: lhs
201  type(kim_support_status_type), intent(in) :: rhs
202 
203  kim_support_status_not_equal = .not. (lhs == rhs)
204  end function kim_support_status_not_equal
205 
212  recursive subroutine kim_support_status_from_string(string, support_status)
213  implicit none
214  interface
215  type(kim_support_status_type) recursive function from_string(string) &
216  bind(c, name="KIM_SupportStatus_FromString")
217  use, intrinsic :: iso_c_binding
218  import kim_support_status_type
219  implicit none
220  character(c_char), intent(in) :: string(*)
221  end function from_string
222  end interface
223  character(len=*, kind=c_char), intent(in) :: string
224  type(kim_support_status_type), intent(out) :: support_status
225 
226  support_status = from_string(trim(string)//c_null_char)
227  end subroutine kim_support_status_from_string
228 
234  recursive subroutine kim_support_status_to_string(support_status, string)
235  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
236  implicit none
237  interface
238  type(c_ptr) recursive function get_string(support_status) &
239  bind(c, name="KIM_SupportStatus_ToString")
240  use, intrinsic :: iso_c_binding
241  import kim_support_status_type
242  implicit none
243  type(kim_support_status_type), intent(in), value :: support_status
244  end function get_string
245  end interface
246  type(kim_support_status_type), intent(in) :: support_status
247  character(len=*, kind=c_char), intent(out) :: string
248 
249  type(c_ptr) :: p
250 
251  p = get_string(support_status)
252  call kim_convert_c_char_ptr_to_string(p, string)
253  end subroutine kim_support_status_to_string
254 
261  recursive subroutine kim_get_number_of_support_statuses( &
262  number_of_support_statuses)
263  implicit none
264  interface
265  recursive subroutine get_number_of_support_statuses( &
266  number_of_support_statuses) &
267  bind(c, name="KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses")
268  use, intrinsic :: iso_c_binding
269  implicit none
270  integer(c_int), intent(out) :: number_of_support_statuses
271  end subroutine get_number_of_support_statuses
272  end interface
273  integer(c_int), intent(out) :: number_of_support_statuses
274 
275  call get_number_of_support_statuses(number_of_support_statuses)
277 
284  recursive subroutine kim_get_support_status(index, support_status, ierr)
285  implicit none
286  interface
287  integer(c_int) recursive function get_support_status(index, &
288  support_status) &
289  bind(c, name="KIM_SUPPORT_STATUS_GetSupportStatus")
290  use, intrinsic :: iso_c_binding
291  import kim_support_status_type
292  implicit none
293  integer(c_int), intent(in), value :: index
294  type(kim_support_status_type), intent(out) :: support_status
295  end function get_support_status
296  end interface
297  integer(c_int), intent(in) :: index
298  type(kim_support_status_type), intent(out) :: support_status
299  integer(c_int), intent(out) :: ierr
300 
301  ierr = get_support_status(index - 1, support_status)
302  end subroutine kim_get_support_status
303 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