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