kim-api  2.2.1+v2.2.1.GNU.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--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  ! Routines
48 
49 contains
55  recursive subroutine kim_get_sem_ver(version)
56  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
57  implicit none
58  interface
59  type(c_ptr) recursive function get_sem_ver() &
60  bind(c, name="KIM_SEM_VER_GetSemVer")
61  use, intrinsic :: iso_c_binding
62  implicit none
63  end function get_sem_ver
64  end interface
65  character(len=*, kind=c_char), intent(out) :: version
66 
67  type(c_ptr) :: p
68 
69  p = get_sem_ver()
70  call kim_convert_c_char_ptr_to_string(p, version)
71  end subroutine kim_get_sem_ver
72 
78  recursive subroutine kim_is_less_than(lhs, rhs, is_less_than, ierr)
79  implicit none
80  interface
81  integer(c_int) recursive function is_less_than_func(lhs, rhs, &
82  is_less_than) &
83  bind(c, name="KIM_SEM_VER_IsLessThan")
84  use, intrinsic :: iso_c_binding
85  implicit none
86  character(c_char), intent(in) :: lhs(*)
87  character(c_char), intent(in) :: rhs(*)
88  integer(c_int), intent(out) :: is_less_than
89  end function is_less_than_func
90  end interface
91  character(len=*, kind=c_char), intent(in) :: lhs
92  character(len=*, kind=c_char), intent(in) :: rhs
93  integer(c_int), intent(out) :: is_less_than
94  integer(c_int), intent(out) :: ierr
95 
96  ierr = is_less_than_func(trim(lhs)//c_null_char, trim(rhs)//c_null_char, &
97  is_less_than)
98  end subroutine kim_is_less_than
99 
105  recursive subroutine kim_parse_sem_ver(version, major, minor, patch, &
106  prerelease, build_metadata, ierr)
107  use kim_convert_string_module, only: kim_convert_c_char_array_to_string
108  implicit none
109  interface
110  integer(c_int) recursive function parse_sem_ver( &
111  version, prerelease_length, build_metadata_length, major, minor, &
112  patch, prerelease, build_metadata) &
113  bind(c, name="KIM_SEM_VER_ParseSemVer")
114  use, intrinsic :: iso_c_binding
115  implicit none
116  character(c_char), intent(in) :: version(*)
117  integer(c_int), intent(in), value :: prerelease_length
118  integer(c_int), intent(in), value :: build_metadata_length
119  integer(c_int), intent(out) :: major
120  integer(c_int), intent(out) :: minor
121  integer(c_int), intent(out) :: patch
122  type(c_ptr), intent(in), value :: prerelease
123  type(c_ptr), intent(in), value :: build_metadata
124  end function parse_sem_ver
125  end interface
126  character(len=*, kind=c_char), intent(in) :: version
127  integer(c_int), intent(out) :: major
128  integer(c_int), intent(out) :: minor
129  integer(c_int), intent(out) :: patch
130  character(len=*, kind=c_char), intent(out) :: prerelease
131  character(len=*, kind=c_char), intent(out) :: build_metadata
132  integer(c_int), intent(out) :: ierr
133 
134  character(len=1, kind=c_char), target :: prerelease_local(len(prerelease))
135  character(len=1, kind=c_char), target :: &
136  build_metadata_local(len(build_metadata))
137 
138  ierr = parse_sem_ver(trim(version)//c_null_char, len(prerelease), &
139  len(build_metadata), major, minor, patch, &
140  c_loc(prerelease_local), c_loc(build_metadata_local))
141  call kim_convert_c_char_array_to_string(prerelease_local, prerelease)
142  call kim_convert_c_char_array_to_string(build_metadata_local, &
143  build_metadata)
144  end subroutine kim_parse_sem_ver
145 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.