| 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 |
|
| 30 |
!> \brief \copybrief KIM::SupportStatus |
| 31 |
!! |
| 32 |
!! \sa KIM::SupportStatus, KIM_SupportStatus |
| 33 |
!! |
| 34 |
!! \since 2.0 |
| 35 |
module kim_support_status_module |
| 36 |
use, intrinsic :: iso_c_binding |
| 37 |
implicit none |
| 38 |
private |
| 39 |
|
| 40 |
public & |
| 41 |
! Derived types |
| 42 |
kim_support_status_type, & |
| 43 |
! Constants |
| 44 |
KIM_SUPPORT_STATUS_REQUIRED_BY_API, & |
| 45 |
KIM_SUPPORT_STATUS_NOT_SUPPORTED, & |
| 46 |
KIM_SUPPORT_STATUS_REQUIRED, & |
| 47 |
KIM_SUPPORT_STATUS_OPTIONAL, & |
| 48 |
! Routines |
| 49 |
kim_known, & |
| 50 |
operator(.eq.), & |
| 51 |
operator(.ne.), & |
| 52 |
kim_from_string, & |
| 53 |
kim_to_string, & |
| 54 |
kim_get_number_of_support_statuses, & |
| 55 |
kim_get_support_status |
| 56 |
|
| 57 |
!> \brief \copybrief KIM::SupportStatus |
| 58 |
!! |
| 59 |
!! \sa KIM::SupportStatus, KIM_SupportStatus |
| 60 |
!! |
| 61 |
!! \since 2.0 |
| 62 |
type, bind(c) :: kim_support_status_type |
| 63 |
!> \brief \copybrief KIM::SupportStatus::supportStatusID |
| 64 |
!! |
| 65 |
!! \sa KIM::SupportStatus::supportStatusID, |
| 66 |
!! KIM_SupportStatus::supportStatusID |
| 67 |
!! |
| 68 |
!! \since 2.0 |
| 69 |
integer(c_int) :: support_status_id |
| 70 |
end type kim_support_status_type |
| 71 |
|
| 72 |
!> \brief \copybrief KIM::SUPPORT_STATUS::requiredByAPI |
| 73 |
!! |
| 74 |
!! \sa KIM::SUPPORT_STATUS::requiredByAPI, KIM_SUPPORT_STATUS_requiredByAPI |
| 75 |
!! |
| 76 |
!! \since 2.0 |
| 77 |
type(kim_support_status_type), protected, save, & |
| 78 |
bind(c, name="KIM_SUPPORT_STATUS_requiredByAPI") & |
| 79 |
:: KIM_SUPPORT_STATUS_REQUIRED_BY_API |
| 80 |
|
| 81 |
!> \brief \copybrief KIM::SUPPORT_STATUS::notSupported |
| 82 |
!! |
| 83 |
!! \sa KIM::SUPPORT_STATUS::notSupported, KIM_SUPPORT_STATUS_notSupported |
| 84 |
!! |
| 85 |
!! \since 2.0 |
| 86 |
type(kim_support_status_type), protected, save, & |
| 87 |
bind(c, name="KIM_SUPPORT_STATUS_notSupported") & |
| 88 |
:: KIM_SUPPORT_STATUS_NOT_SUPPORTED |
| 89 |
|
| 90 |
!> \brief \copybrief KIM::SUPPORT_STATUS::required |
| 91 |
!! |
| 92 |
!! \sa KIM::SUPPORT_STATUS::required, KIM_SUPPORT_STATUS_required |
| 93 |
!! |
| 94 |
!! \since 2.0 |
| 95 |
type(kim_support_status_type), protected, save, & |
| 96 |
bind(c, name="KIM_SUPPORT_STATUS_required") & |
| 97 |
:: KIM_SUPPORT_STATUS_REQUIRED |
| 98 |
|
| 99 |
!> \brief \copybrief KIM::SUPPORT_STATUS::optional |
| 100 |
!! |
| 101 |
!! \sa KIM::SUPPORT_STATUS::optional, KIM_SUPPORT_STATUS_optional |
| 102 |
!! |
| 103 |
!! \since 2.0 |
| 104 |
type(kim_support_status_type), protected, save, & |
| 105 |
bind(c, name="KIM_SUPPORT_STATUS_optional") & |
| 106 |
:: KIM_SUPPORT_STATUS_OPTIONAL |
| 107 |
|
| 108 |
!> \brief \copybrief KIM::SupportStatus::Known |
| 109 |
!! |
| 110 |
!! \sa KIM::SupportStatus::Known, KIM_SupportStatus_Known |
| 111 |
!! |
| 112 |
!! \since 2.0 |
| 113 |
interface kim_known |
| 114 |
module procedure kim_support_status_known |
| 115 |
end interface kim_known |
| 116 |
|
| 117 |
!> \brief \copybrief KIM::SupportStatus::operator==() |
| 118 |
!! |
| 119 |
!! \sa KIM::SupportStatus::operator==(), KIM_SupportStatus_Equal |
| 120 |
!! |
| 121 |
!! \since 2.0 |
| 122 |
interface operator(.eq.) |
| 123 |
module procedure kim_support_status_equal |
| 124 |
end interface operator(.eq.) |
| 125 |
|
| 126 |
!> \brief \copybrief KIM::SupportStatus::operator!=() |
| 127 |
!! |
| 128 |
!! \sa KIM::SupportStatus::operator!=(), KIM_SupportStatus_NotEqual |
| 129 |
!! |
| 130 |
!! \since 2.0 |
| 131 |
interface operator(.ne.) |
| 132 |
module procedure kim_support_status_not_equal |
| 133 |
end interface operator(.ne.) |
| 134 |
|
| 135 |
!> \brief \copybrief KIM::SupportStatus::SupportStatus(std::string const &) |
| 136 |
!! |
| 137 |
!! \sa KIM::SupportStatus::SupportStatus(std::string const &), |
| 138 |
!! KIM_SupportStatus_FromString |
| 139 |
!! |
| 140 |
!! \since 2.0 |
| 141 |
interface kim_from_string |
| 142 |
module procedure kim_support_status_from_string |
| 143 |
end interface kim_from_string |
| 144 |
|
| 145 |
!> \brief \copybrief KIM::SupportStatus::ToString |
| 146 |
!! |
| 147 |
!! \sa KIM::SupportStatus::ToString, KIM_SupportStatus_ToString |
| 148 |
!! |
| 149 |
!! \since 2.0 |
| 150 |
interface kim_to_string |
| 151 |
module procedure kim_support_status_to_string |
| 152 |
end interface kim_to_string |
| 153 |
|
| 154 |
contains |
| 155 |
!> \brief \copybrief KIM::SupportStatus::Known |
| 156 |
!! |
| 157 |
!! \sa KIM::SupportStatus::Known, KIM_SupportStatus_Known |
| 158 |
!! |
| 159 |
!! \since 2.0 |
| 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 |
|
| 176 |
!> \brief \copybrief KIM::SupportStatus::operator==() |
| 177 |
!! |
| 178 |
!! \sa KIM::SupportStatus::operator==(), KIM_SupportStatus_Equal |
| 179 |
!! |
| 180 |
!! \since 2.0 |
| 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 |
|
| 190 |
!> \brief \copybrief KIM::SupportStatus::operator!=() |
| 191 |
!! |
| 192 |
!! \sa KIM::SupportStatus::operator!=(), KIM_SupportStatus_NotEqual |
| 193 |
!! |
| 194 |
!! \since 2.0 |
| 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 |
|
| 203 |
!> \brief \copybrief KIM::SupportStatus::SupportStatus(std::string const &) |
| 204 |
!! |
| 205 |
!! \sa KIM::SupportStatus::SupportStatus(std::string const &), |
| 206 |
!! KIM_SupportStatus_FromString |
| 207 |
!! |
| 208 |
!! \since 2.0 |
| 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 |
|
| 226 |
!> \brief \copybrief KIM::SupportStatus::ToString |
| 227 |
!! |
| 228 |
!! \sa KIM::SupportStatus::ToString, KIM_SupportStatus_ToString |
| 229 |
!! |
| 230 |
!! \since 2.0 |
| 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 |
|
| 252 |
!> \brief \copybrief KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses |
| 253 |
!! |
| 254 |
!! \sa KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses, |
| 255 |
!! KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses |
| 256 |
!! |
| 257 |
!! \since 2.0 |
| 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) |
| 273 |
end subroutine kim_get_number_of_support_statuses |
| 274 |
|
| 275 |
!> \brief \copybrief KIM::SUPPORT_STATUS::GetSupportStatus |
| 276 |
!! |
| 277 |
!! \sa KIM::SUPPORT_STATUS::GetSupportStatus, |
| 278 |
!! KIM_SUPPORT_STATUS_GetSupportStatus |
| 279 |
!! |
| 280 |
!! \since 2.0 |
| 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 |