| 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::ComputeCallbackName |
| 31 |
!! |
| 32 |
!! \sa KIM::ComputeCallbackName, KIM_ComputeCallbackName |
| 33 |
!! |
| 34 |
!! \since 2.0 |
| 35 |
module kim_compute_callback_name_module |
| 36 |
use, intrinsic :: iso_c_binding |
| 37 |
implicit none |
| 38 |
private |
| 39 |
|
| 40 |
public & |
| 41 |
! Derived types |
| 42 |
kim_compute_callback_name_type, & |
| 43 |
! Constants |
| 44 |
KIM_COMPUTE_CALLBACK_NAME_GET_NEIGHBOR_LIST, & |
| 45 |
KIM_COMPUTE_CALLBACK_NAME_PROCESS_DEDR_TERM, & |
| 46 |
KIM_COMPUTE_CALLBACK_NAME_PROCESS_D2EDR2_TERM, & |
| 47 |
! Routines |
| 48 |
kim_known, & |
| 49 |
operator(.eq.), & |
| 50 |
operator(.ne.), & |
| 51 |
kim_from_string, & |
| 52 |
kim_to_string, & |
| 53 |
kim_get_number_of_compute_callback_names, & |
| 54 |
kim_get_compute_callback_name |
| 55 |
|
| 56 |
!> \brief \copybrief KIM::ComputeCallbackName |
| 57 |
!! |
| 58 |
!! \sa KIM::ComputeCallbackName, KIM_ComputeCallbackName |
| 59 |
!! |
| 60 |
!! \since 2.0 |
| 61 |
type, bind(c) :: kim_compute_callback_name_type |
| 62 |
!> \brief \copybrief KIM::ComputeCallbackName::computeCallbackNameID |
| 63 |
!! |
| 64 |
!! \sa KIM::ComputeCallbackName::computeCallbackNameID, |
| 65 |
!! KIM_ComputeCallbackName::computeCallbackNameID |
| 66 |
!! |
| 67 |
!! \since 2.0 |
| 68 |
integer(c_int) compute_callback_name_id |
| 69 |
end type kim_compute_callback_name_type |
| 70 |
|
| 71 |
!> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::GetNeighborList |
| 72 |
!! |
| 73 |
!! \sa KIM::COMPUTE_CALLBACK_NAME::GetNeighborList, |
| 74 |
!! KIM_COMPUTE_CALLBACK_NAME_GetNeighborList |
| 75 |
!! |
| 76 |
!! \since 2.0 |
| 77 |
type(kim_compute_callback_name_type), protected, save, & |
| 78 |
bind(c, name="KIM_COMPUTE_CALLBACK_NAME_GetNeighborList") & |
| 79 |
:: KIM_COMPUTE_CALLBACK_NAME_GET_NEIGHBOR_LIST |
| 80 |
|
| 81 |
!> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm |
| 82 |
!! |
| 83 |
!! \sa KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm, |
| 84 |
!! KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm |
| 85 |
!! |
| 86 |
!! \since 2.0 |
| 87 |
type(kim_compute_callback_name_type), protected, save, & |
| 88 |
bind(c, name="KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm") & |
| 89 |
:: KIM_COMPUTE_CALLBACK_NAME_PROCESS_DEDR_TERM |
| 90 |
|
| 91 |
!> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term |
| 92 |
!! |
| 93 |
!! \sa KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term, |
| 94 |
!! KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term |
| 95 |
!! |
| 96 |
!! \since 2.0 |
| 97 |
type(kim_compute_callback_name_type), protected, save, & |
| 98 |
bind(c, name="KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term") & |
| 99 |
:: KIM_COMPUTE_CALLBACK_NAME_PROCESS_D2EDR2_TERM |
| 100 |
|
| 101 |
!> \brief \copybrief KIM::ComputeCallbackName::Known |
| 102 |
!! |
| 103 |
!! \sa KIM::ComputeCallbackName::Known, KIM_ComputeCallbackName_Known |
| 104 |
!! |
| 105 |
!! \since 2.0 |
| 106 |
interface kim_known |
| 107 |
module procedure kim_compute_callback_name_known |
| 108 |
end interface kim_known |
| 109 |
|
| 110 |
!> \brief \copybrief KIM::ComputeCallbackName::operator==() |
| 111 |
!! |
| 112 |
!! \sa KIM::ComputeCallbackName::operator==(), KIM_ComputeCallbackName_Equal |
| 113 |
!! |
| 114 |
!! \since 2.0 |
| 115 |
interface operator(.eq.) |
| 116 |
module procedure kim_compute_callback_name_equal |
| 117 |
end interface operator(.eq.) |
| 118 |
|
| 119 |
!> \brief \copybrief KIM::ComputeCallbackName::operator!=() |
| 120 |
!! |
| 121 |
!! \sa KIM::ComputeCallbackName::operator!=(), |
| 122 |
!! KIM_ComputeCallbackName_NotEqual |
| 123 |
!! |
| 124 |
!! \since 2.0 |
| 125 |
interface operator(.ne.) |
| 126 |
module procedure kim_compute_callback_name_not_equal |
| 127 |
end interface operator(.ne.) |
| 128 |
|
| 129 |
!> \brief \copybrief KIM::ComputeCallbackName::<!-- |
| 130 |
!! -->ComputeCallbackName(std::string const &) |
| 131 |
!! |
| 132 |
!! \sa KIM::ComputeCallbackName::ComputeCallbackName(std::string const &), |
| 133 |
!! KIM_ComputeCallbackName_FromString |
| 134 |
!! |
| 135 |
!! \since 2.0 |
| 136 |
interface kim_from_string |
| 137 |
module procedure kim_compute_callback_name_from_string |
| 138 |
end interface kim_from_string |
| 139 |
|
| 140 |
!> \brief \copybrief KIM::ComputeCallbackName::ToString |
| 141 |
!! |
| 142 |
!! \sa KIM::ComputeCallbackName::ToString, KIM_ComputeCallbackName_ToString |
| 143 |
!! |
| 144 |
!! \since 2.0 |
| 145 |
interface kim_to_string |
| 146 |
module procedure kim_compute_callback_name_to_string |
| 147 |
end interface kim_to_string |
| 148 |
|
| 149 |
contains |
| 150 |
!> \brief \copybrief KIM::ComputeCallbackName::Known |
| 151 |
!! |
| 152 |
!! \sa KIM::ComputeCallbackName::Known, KIM_ComputeCallbackName_Known |
| 153 |
!! |
| 154 |
!! \since 2.0 |
| 155 |
logical recursive function kim_compute_callback_name_known( & |
| 156 |
compute_callback_name) |
| 157 |
implicit none |
| 158 |
interface |
| 159 |
integer(c_int) recursive function known(compute_callback_name) & |
| 160 |
bind(c, name="KIM_ComputeCallbackName_Known") |
| 161 |
use, intrinsic :: iso_c_binding |
| 162 |
import kim_compute_callback_name_type |
| 163 |
implicit none |
| 164 |
type(kim_compute_callback_name_type), intent(in), value :: & |
| 165 |
compute_callback_name |
| 166 |
end function known |
| 167 |
end interface |
| 168 |
type(kim_compute_callback_name_type), intent(in) :: compute_callback_name |
| 169 |
|
| 170 |
kim_compute_callback_name_known = (known(compute_callback_name) /= 0) |
| 171 |
end function kim_compute_callback_name_known |
| 172 |
|
| 173 |
!> \brief \copybrief KIM::ComputeCallbackName::operator==() |
| 174 |
!! |
| 175 |
!! \sa KIM::ComputeCallbackName::operator==(), KIM_ComputeCallbackName_Equal |
| 176 |
!! |
| 177 |
!! \since 2.0 |
| 178 |
logical recursive function kim_compute_callback_name_equal(lhs, rhs) |
| 179 |
implicit none |
| 180 |
type(kim_compute_callback_name_type), intent(in) :: lhs |
| 181 |
type(kim_compute_callback_name_type), intent(in) :: rhs |
| 182 |
|
| 183 |
kim_compute_callback_name_equal & |
| 184 |
= (lhs%compute_callback_name_id == rhs%compute_callback_name_id) |
| 185 |
end function kim_compute_callback_name_equal |
| 186 |
|
| 187 |
!> \brief \copybrief KIM::ComputeCallbackName::operator!=() |
| 188 |
!! |
| 189 |
!! \sa KIM::ComputeCallbackName::operator!=(), |
| 190 |
!! KIM_ComputeCallbackName_NotEqual |
| 191 |
!! |
| 192 |
!! \since 2.0 |
| 193 |
logical recursive function kim_compute_callback_name_not_equal(lhs, rhs) |
| 194 |
implicit none |
| 195 |
type(kim_compute_callback_name_type), intent(in) :: lhs |
| 196 |
type(kim_compute_callback_name_type), intent(in) :: rhs |
| 197 |
|
| 198 |
kim_compute_callback_name_not_equal = .not. (lhs == rhs) |
| 199 |
end function kim_compute_callback_name_not_equal |
| 200 |
|
| 201 |
!> \brief \copybrief KIM::ComputeCallbackName::<!-- |
| 202 |
!! -->ComputeCallbackName(std::string const &) |
| 203 |
!! |
| 204 |
!! \sa KIM::ComputeCallbackName::ComputeCallbackName(std::string const &), |
| 205 |
!! KIM_ComputeCallbackName_FromString |
| 206 |
!! |
| 207 |
!! \since 2.0 |
| 208 |
recursive subroutine kim_compute_callback_name_from_string( & |
| 209 |
string, compute_callback_name) |
| 210 |
implicit none |
| 211 |
interface |
| 212 |
type(kim_compute_callback_name_type) recursive function from_string( & |
| 213 |
string) bind(c, name="KIM_ComputeCallbackName_FromString") |
| 214 |
use, intrinsic :: iso_c_binding |
| 215 |
import kim_compute_callback_name_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_compute_callback_name_type), intent(out) :: compute_callback_name |
| 222 |
|
| 223 |
compute_callback_name = from_string(trim(string)//c_null_char) |
| 224 |
end subroutine kim_compute_callback_name_from_string |
| 225 |
|
| 226 |
!> \brief \copybrief KIM::ComputeCallbackName::ToString |
| 227 |
!! |
| 228 |
!! \sa KIM::ComputeCallbackName::ToString, KIM_ComputeCallbackName_ToString |
| 229 |
!! |
| 230 |
!! \since 2.0 |
| 231 |
recursive subroutine kim_compute_callback_name_to_string( & |
| 232 |
compute_callback_name, string) |
| 233 |
use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string |
| 234 |
implicit none |
| 235 |
interface |
| 236 |
type(c_ptr) recursive function get_string(compute_callback_name) & |
| 237 |
bind(c, name="KIM_ComputeCallbackName_ToString") |
| 238 |
use, intrinsic :: iso_c_binding |
| 239 |
import kim_compute_callback_name_type |
| 240 |
implicit none |
| 241 |
type(kim_compute_callback_name_type), intent(in), value :: & |
| 242 |
compute_callback_name |
| 243 |
end function get_string |
| 244 |
end interface |
| 245 |
type(kim_compute_callback_name_type), intent(in) :: & |
| 246 |
compute_callback_name |
| 247 |
character(len=*, kind=c_char), intent(out) :: string |
| 248 |
|
| 249 |
type(c_ptr) :: p |
| 250 |
|
| 251 |
p = get_string(compute_callback_name) |
| 252 |
call kim_convert_c_char_ptr_to_string(p, string) |
| 253 |
end subroutine kim_compute_callback_name_to_string |
| 254 |
|
| 255 |
!> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::<!-- |
| 256 |
!! -->GetNumberOfComputeCallbackNames |
| 257 |
!! |
| 258 |
!! \sa KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames, |
| 259 |
!! KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames |
| 260 |
!! |
| 261 |
!! \since 2.0 |
| 262 |
recursive subroutine kim_get_number_of_compute_callback_names( & |
| 263 |
number_of_compute_callback_names) |
| 264 |
implicit none |
| 265 |
interface |
| 266 |
recursive subroutine get_number_of_compute_callback_names( & |
| 267 |
number_of_compute_callback_names) & |
| 268 |
bind(c, & |
| 269 |
name="KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames") |
| 270 |
use, intrinsic :: iso_c_binding |
| 271 |
integer(c_int), intent(out) :: number_of_compute_callback_names |
| 272 |
end subroutine get_number_of_compute_callback_names |
| 273 |
end interface |
| 274 |
integer(c_int), intent(out) :: number_of_compute_callback_names |
| 275 |
|
| 276 |
call get_number_of_compute_callback_names(number_of_compute_callback_names) |
| 277 |
end subroutine kim_get_number_of_compute_callback_names |
| 278 |
|
| 279 |
!> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName |
| 280 |
!! |
| 281 |
!! \sa KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName, |
| 282 |
!! KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName |
| 283 |
!! |
| 284 |
!! \since 2.0 |
| 285 |
recursive subroutine kim_get_compute_callback_name(index, & |
| 286 |
compute_callback_name, & |
| 287 |
ierr) |
| 288 |
implicit none |
| 289 |
interface |
| 290 |
integer(c_int) recursive function get_compute_callback_name( & |
| 291 |
index, compute_callback_name) & |
| 292 |
bind(c, name="KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName") |
| 293 |
use, intrinsic :: iso_c_binding |
| 294 |
import kim_compute_callback_name_type |
| 295 |
implicit none |
| 296 |
integer(c_int), intent(in), value :: index |
| 297 |
type(kim_compute_callback_name_type), intent(out) :: & |
| 298 |
compute_callback_name |
| 299 |
end function get_compute_callback_name |
| 300 |
end interface |
| 301 |
integer(c_int), intent(in) :: index |
| 302 |
type(kim_compute_callback_name_type), intent(out) :: compute_callback_name |
| 303 |
integer(c_int), intent(out) :: ierr |
| 304 |
|
| 305 |
ierr = get_compute_callback_name(index - 1, compute_callback_name) |
| 306 |
end subroutine kim_get_compute_callback_name |
| 307 |
end module kim_compute_callback_name_module |