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_language_name_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_language_name_type, &
47 
48  ! Constants
52 
53  ! Routines
54  kim_known, &
55  operator (.eq.), &
56  operator (.ne.), &
57  kim_from_string, &
58  kim_to_string, &
61 
62 
68  type, bind(c) :: kim_language_name_type
74  integer(c_int) :: language_name_id
75  end type kim_language_name_type
76 
82  type(kim_language_name_type), protected, save, &
83  bind(c, name="KIM_LANGUAGE_NAME_cpp") &
85 
91  type(kim_language_name_type), protected, save, &
92  bind(c, name="KIM_LANGUAGE_NAME_c") &
94 
100  type(kim_language_name_type), protected, save, &
101  bind(c, name="KIM_LANGUAGE_NAME_fortran") &
103 
109  interface kim_known
110  module procedure kim_language_name_known
111  end interface kim_known
112 
118  interface operator (.eq.)
119  module procedure kim_language_name_equal
120  end interface operator (.eq.)
121 
127  interface operator (.ne.)
128  module procedure kim_language_name_not_equal
129  end interface operator (.ne.)
130 
137  interface kim_from_string
138  module procedure kim_language_name_from_string
139  end interface kim_from_string
140 
146  interface kim_to_string
147  module procedure kim_language_name_to_string
148  end interface kim_to_string
149 
150 contains
156  logical recursive function kim_language_name_known(language_name)
157  implicit none
158  interface
159  integer(c_int) recursive function known(language_name) &
160  bind(c, name="KIM_LanguageName_Known")
161  use, intrinsic :: iso_c_binding
162  import kim_language_name_type
163  implicit none
164  type(kim_language_name_type), intent(in), value :: language_name
165  end function known
166  end interface
167  type(kim_language_name_type), intent(in) :: language_name
168 
169  kim_language_name_known = (known(language_name) /= 0)
170  end function kim_language_name_known
171 
177  logical recursive function kim_language_name_equal(lhs, rhs)
178  implicit none
179  type(kim_language_name_type), intent(in) :: lhs
180  type(kim_language_name_type), intent(in) :: rhs
181 
182  kim_language_name_equal &
183  = (lhs%language_name_id .eq. rhs%language_name_id)
184  end function kim_language_name_equal
185 
191  logical recursive function kim_language_name_not_equal(lhs, rhs)
192  implicit none
193  type(kim_language_name_type), intent(in) :: lhs
194  type(kim_language_name_type), intent(in) :: rhs
195 
196  kim_language_name_not_equal = .not. (lhs .eq. rhs)
197  end function kim_language_name_not_equal
198 
205  recursive subroutine kim_language_name_from_string(string, language_name)
206  implicit none
207  interface
208  type(kim_language_name_type) recursive function from_string(string) &
209  bind(c, name="KIM_LanguageName_FromString")
210  use, intrinsic :: iso_c_binding
211  import kim_language_name_type
212  implicit none
213  character(c_char), intent(in) :: string(*)
214  end function from_string
215  end interface
216  character(len=*, kind=c_char), intent(in) :: string
217  type(kim_language_name_type), intent(out) :: language_name
218 
219  language_name = from_string(trim(string)//c_null_char)
220  end subroutine kim_language_name_from_string
221 
227  recursive subroutine kim_language_name_to_string(language_name, string)
228  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
229  implicit none
230  interface
231  type(c_ptr) recursive function get_string(language_name) &
232  bind(c, name="KIM_LanguageName_ToString")
233  use, intrinsic :: iso_c_binding
234  import kim_language_name_type
235  implicit none
236  type(kim_language_name_type), intent(in), value :: language_name
237  end function get_string
238  end interface
239  type(kim_language_name_type), intent(in) :: language_name
240  character(len=*, kind=c_char), intent(out) :: string
241 
242  type(c_ptr) :: p
243 
244  p = get_string(language_name)
245  call kim_convert_c_char_ptr_to_string(p, string)
246  end subroutine kim_language_name_to_string
247 
254  recursive subroutine kim_get_number_of_language_names( &
255  number_of_language_names)
256  implicit none
257  interface
258  recursive subroutine get_number_of_language_names( &
259  number_of_language_names) &
260  bind(c, name="KIM_LANGUAGE_NAME_GetNumberOfLanguageNames")
261  use, intrinsic :: iso_c_binding
262  integer(c_int), intent(out) :: number_of_language_names
263  end subroutine get_number_of_language_names
264  end interface
265  integer(c_int), intent(out) :: number_of_language_names
266 
267  call get_number_of_language_names(number_of_language_names)
268  end subroutine kim_get_number_of_language_names
269 
275  recursive subroutine kim_get_language_name(index, language_name, ierr)
276  implicit none
277  interface
278  integer(c_int) recursive function get_language_name(index, &
279  language_name) bind(c, name="KIM_LANGUAGE_NAME_GetLanguageName")
280  use, intrinsic :: iso_c_binding
281  import kim_language_name_type
282  integer(c_int), intent(in), value :: index
283  type(kim_language_name_type), intent(out) :: language_name
284  end function get_language_name
285  end interface
286  integer(c_int), intent(in) :: index
287  type(kim_language_name_type), intent(out) :: language_name
288  integer(c_int), intent(out) :: ierr
289 
290  ierr = get_language_name(index-1, language_name)
291  end subroutine kim_get_language_name
292 end module kim_language_name_module
type(kim_language_name_type), save, public, protected kim_language_name_cpp
recursive subroutine, public kim_get_number_of_language_names(number_of_language_names)
Get the number of standard LanguageName's defined by the KIM API.
recursive subroutine, public kim_get_language_name(index, language_name, ierr)
Get the identity of each defined standard LanguageName.
type(kim_language_name_type), save, public, protected kim_language_name_c
An Extensible Enumeration for the LanguageName's supported by the KIM API.
type(kim_language_name_type), save, public, protected kim_language_name_fortran