kim-api  2.1.2+v2.1.2.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_sem_ver_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-2.1.2 package.
31 !
32 
33 
40  use, intrinsic :: iso_c_binding
41  implicit none
42  private
43 
44  public &
45  ! Routines
49 
50 
51 contains
57  recursive subroutine kim_get_sem_ver(version)
58  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
59  implicit none
60  interface
61  type(c_ptr) recursive function get_sem_ver() &
62  bind(c, name="KIM_SEM_VER_GetSemVer")
63  use, intrinsic :: iso_c_binding
64  implicit none
65  end function get_sem_ver
66  end interface
67  character(len=*, kind=c_char), intent(out) :: version
68 
69  type(c_ptr) :: p
70 
71  p = get_sem_ver()
72  call kim_convert_c_char_ptr_to_string(p, version)
73  end subroutine kim_get_sem_ver
74 
80  recursive subroutine kim_is_less_than(lhs, rhs, is_less_than, &
81  ierr)
82  implicit none
83  interface
84  integer(c_int) recursive function is_less_than_func(lhs, rhs, &
85  is_less_than) bind(c, name="KIM_SEM_VER_IsLessThan")
86  use, intrinsic :: iso_c_binding
87  implicit none
88  character(c_char), intent(in) :: lhs(*)
89  character(c_char), intent(in) :: rhs(*)
90  integer(c_int), intent(out) :: is_less_than
91  end function is_less_than_func
92  end interface
93  character(len=*, kind=c_char), intent(in) :: lhs
94  character(len=*, kind=c_char), intent(in) :: rhs
95  integer(c_int), intent(out) :: is_less_than
96  integer(c_int), intent(out) :: ierr
97 
98  ierr = is_less_than_func(trim(lhs)//c_null_char, trim(rhs)//c_null_char, &
99  is_less_than)
100  end subroutine kim_is_less_than
101 
107  recursive subroutine kim_parse_sem_ver(version, major, minor, patch, &
108  prerelease, build_metadata, ierr)
109  use kim_convert_string_module, only : kim_convert_c_char_array_to_string
110  implicit none
111  interface
112  integer(c_int) recursive function parse_sem_ver(version, &
113  prerelease_length, build_metadata_length, major, minor, patch, &
114  prerelease, build_metadata) bind(c, name="KIM_SEM_VER_ParseSemVer")
115  use, intrinsic :: iso_c_binding
116  implicit none
117  character(c_char), intent(in) :: version(*)
118  integer(c_int), intent(in), value :: prerelease_length
119  integer(c_int), intent(in), value :: build_metadata_length
120  integer(c_int), intent(out) :: major
121  integer(c_int), intent(out) :: minor
122  integer(c_int), intent(out) :: patch
123  type(c_ptr), intent(in), value :: prerelease
124  type(c_ptr), intent(in), value :: build_metadata
125  end function parse_sem_ver
126  end interface
127  character(len=*, kind=c_char), intent(in) :: version
128  integer(c_int), intent(out) :: major
129  integer(c_int), intent(out) :: minor
130  integer(c_int), intent(out) :: patch
131  character(len=*, kind=c_char), intent(out) :: prerelease
132  character(len=*, kind=c_char), intent(out) :: build_metadata
133  integer(c_int), intent(out) :: ierr
134 
135  character(len=1, kind=c_char), target :: prerelease_local(len(prerelease))
136  character(len=1, kind=c_char), target :: &
137  build_metadata_local(len(build_metadata))
138 
139  ierr = parse_sem_ver(trim(version)//c_null_char, len(prerelease), &
140  len(build_metadata), major, minor, patch, c_loc(prerelease_local), &
141  c_loc(build_metadata_local))
142  call kim_convert_c_char_array_to_string(prerelease_local, prerelease)
143  call kim_convert_c_char_array_to_string(build_metadata_local, &
144  build_metadata)
145  end subroutine kim_parse_sem_ver
146 end module kim_sem_ver_module
recursive subroutine, public kim_get_sem_ver(version)
Get the KIM API complete Semantic Version string.
recursive subroutine, public kim_is_less_than(lhs, rhs, is_less_than, ierr)
Compare two Semantic Version strings.
recursive subroutine, public kim_parse_sem_ver(version, major, minor, patch, prerelease, build_metadata, ierr)
Parse Semantic Version string into its six components.
Contains routines related to the KIM API Semantic Version.