kim-api  2.3.1-git+v2.3.0-git-2-g378406f9.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 ! 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.git repository.
28 !
29 
36  use, intrinsic :: iso_c_binding
37  implicit none
38  private
39 
40  public &
41  ! Derived types
42  kim_support_status_type, &
43  ! Constants
48  ! Routines
49  kim_known, &
50  operator(.eq.), &
51  operator(.ne.), &
52  kim_from_string, &
53  kim_to_string, &
56 
62  type, bind(c) :: kim_support_status_type
69  integer(c_int) :: support_status_id
70  end type kim_support_status_type
71 
77  type(kim_support_status_type), protected, save, &
78  bind(c, name="KIM_SUPPORT_STATUS_requiredByAPI") &
80 
86  type(kim_support_status_type), protected, save, &
87  bind(c, name="KIM_SUPPORT_STATUS_notSupported") &
89 
95  type(kim_support_status_type), protected, save, &
96  bind(c, name="KIM_SUPPORT_STATUS_required") &
98 
104  type(kim_support_status_type), protected, save, &
105  bind(c, name="KIM_SUPPORT_STATUS_optional") &
107 
113  interface kim_known
114  module procedure kim_support_status_known
115  end interface kim_known
116 
122  interface operator(.eq.)
123  module procedure kim_support_status_equal
124  end interface operator(.eq.)
125 
131  interface operator(.ne.)
132  module procedure kim_support_status_not_equal
133  end interface operator(.ne.)
134 
141  interface kim_from_string
142  module procedure kim_support_status_from_string
143  end interface kim_from_string
144 
150  interface kim_to_string
151  module procedure kim_support_status_to_string
152  end interface kim_to_string
153 
154 contains
160  logical recursive function kim_support_status_known(support_status)
161  implicit none
162  interface
163  integer(c_int) recursive function known(support_status) &
164  bind(c, name="KIM_SupportStatus_Known")
165  use, intrinsic :: iso_c_binding
166  import kim_support_status_type
167  implicit none
168  type(kim_support_status_type), intent(in), value :: support_status
169  end function known
170  end interface
171  type(kim_support_status_type), intent(in) :: support_status
172 
173  kim_support_status_known = (known(support_status) /= 0)
174  end function kim_support_status_known
175 
181  logical recursive function kim_support_status_equal(lhs, rhs)
182  implicit none
183  type(kim_support_status_type), intent(in) :: lhs
184  type(kim_support_status_type), intent(in) :: rhs
185 
186  kim_support_status_equal &
187  = (lhs%support_status_id == rhs%support_status_id)
188  end function kim_support_status_equal
189 
195  logical recursive function kim_support_status_not_equal(lhs, rhs)
196  implicit none
197  type(kim_support_status_type), intent(in) :: lhs
198  type(kim_support_status_type), intent(in) :: rhs
199 
200  kim_support_status_not_equal = .not. (lhs == rhs)
201  end function kim_support_status_not_equal
202 
209  recursive subroutine kim_support_status_from_string(string, support_status)
210  implicit none
211  interface
212  type(kim_support_status_type) recursive function from_string(string) &
213  bind(c, name="KIM_SupportStatus_FromString")
214  use, intrinsic :: iso_c_binding
215  import kim_support_status_type
216  implicit none
217  character(c_char), intent(in) :: string(*)
218  end function from_string
219  end interface
220  character(len=*, kind=c_char), intent(in) :: string
221  type(kim_support_status_type), intent(out) :: support_status
222 
223  support_status = from_string(trim(string)//c_null_char)
224  end subroutine kim_support_status_from_string
225 
231  recursive subroutine kim_support_status_to_string(support_status, string)
232  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
233  implicit none
234  interface
235  type(c_ptr) recursive function get_string(support_status) &
236  bind(c, name="KIM_SupportStatus_ToString")
237  use, intrinsic :: iso_c_binding
238  import kim_support_status_type
239  implicit none
240  type(kim_support_status_type), intent(in), value :: support_status
241  end function get_string
242  end interface
243  type(kim_support_status_type), intent(in) :: support_status
244  character(len=*, kind=c_char), intent(out) :: string
245 
246  type(c_ptr) :: p
247 
248  p = get_string(support_status)
249  call kim_convert_c_char_ptr_to_string(p, string)
250  end subroutine kim_support_status_to_string
251 
258  recursive subroutine kim_get_number_of_support_statuses( &
259  number_of_support_statuses)
260  implicit none
261  interface
262  recursive subroutine get_number_of_support_statuses( &
263  number_of_support_statuses) &
264  bind(c, name="KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses")
265  use, intrinsic :: iso_c_binding
266  implicit none
267  integer(c_int), intent(out) :: number_of_support_statuses
268  end subroutine get_number_of_support_statuses
269  end interface
270  integer(c_int), intent(out) :: number_of_support_statuses
271 
272  call get_number_of_support_statuses(number_of_support_statuses)
274 
281  recursive subroutine kim_get_support_status(index, support_status, ierr)
282  implicit none
283  interface
284  integer(c_int) recursive function get_support_status(index, &
285  support_status) &
286  bind(c, name="KIM_SUPPORT_STATUS_GetSupportStatus")
287  use, intrinsic :: iso_c_binding
288  import kim_support_status_type
289  implicit none
290  integer(c_int), intent(in), value :: index
291  type(kim_support_status_type), intent(out) :: support_status
292  end function get_support_status
293  end interface
294  integer(c_int), intent(in) :: index
295  type(kim_support_status_type), intent(out) :: support_status
296  integer(c_int), intent(out) :: ierr
297 
298  ierr = get_support_status(index - 1, support_status)
299  end subroutine kim_get_support_status
300 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