| 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::ComputeArgumentName |
| 31 |
!! |
| 32 |
!! \sa KIM::ComputeArgumentName, KIM_ComputeArgumentName |
| 33 |
!! |
| 34 |
!! \since 2.0 |
| 35 |
module kim_compute_argument_name_module |
| 36 |
use, intrinsic :: iso_c_binding |
| 37 |
implicit none |
| 38 |
private |
| 39 |
|
| 40 |
public & |
| 41 |
! Derived types |
| 42 |
kim_compute_argument_name_type, & |
| 43 |
! Constants |
| 44 |
KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, & |
| 45 |
KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, & |
| 46 |
KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, & |
| 47 |
KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, & |
| 48 |
KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, & |
| 49 |
KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & |
| 50 |
KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & |
| 51 |
KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, & |
| 52 |
KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_VIRIAL, & |
| 53 |
! Routines |
| 54 |
kim_known, & |
| 55 |
operator(.eq.), & |
| 56 |
operator(.ne.), & |
| 57 |
kim_from_string, & |
| 58 |
kim_to_string, & |
| 59 |
kim_get_number_of_compute_argument_names, & |
| 60 |
kim_get_compute_argument_name, & |
| 61 |
kim_get_compute_argument_data_type |
| 62 |
|
| 63 |
!> \brief \copybrief KIM::ComputeArgumentName |
| 64 |
!! |
| 65 |
!! \sa KIM::ComputeArgumentName, KIM_ComputeArgumentName |
| 66 |
!! |
| 67 |
!! \since 2.0 |
| 68 |
type, bind(c) :: kim_compute_argument_name_type |
| 69 |
!> \brief \copybrief KIM::ComputeArgumentName::computeArgumentNameID |
| 70 |
!! |
| 71 |
!! \sa KIM::ComputeArgumentName::computeArgumentNameID, |
| 72 |
!! KIM_ComputeArgumentName::computeArgumentNameID |
| 73 |
!! |
| 74 |
!! \since 2.0 |
| 75 |
integer(c_int) compute_argument_name_id |
| 76 |
end type kim_compute_argument_name_type |
| 77 |
|
| 78 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles |
| 79 |
!! |
| 80 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles, |
| 81 |
!! KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles |
| 82 |
!! |
| 83 |
!! \since 2.0 |
| 84 |
type(kim_compute_argument_name_type), protected, save, & |
| 85 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles") & |
| 86 |
:: KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES |
| 87 |
|
| 88 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes |
| 89 |
!! |
| 90 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes, |
| 91 |
!! KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes |
| 92 |
!! |
| 93 |
!! \since 2.0 |
| 94 |
type(kim_compute_argument_name_type), protected, save, & |
| 95 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes") & |
| 96 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES |
| 97 |
|
| 98 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::particleContributing |
| 99 |
!! |
| 100 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::particleContributing, |
| 101 |
!! KIM_COMPUTE_ARGUMENT_NAME_particleContributing |
| 102 |
!! |
| 103 |
!! \since 2.0 |
| 104 |
type(kim_compute_argument_name_type), protected, save, & |
| 105 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_particleContributing") & |
| 106 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING |
| 107 |
|
| 108 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::coordinates |
| 109 |
!! |
| 110 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::coordinates, |
| 111 |
!! KIM_COMPUTE_ARGUMENT_NAME_coordinates |
| 112 |
!! |
| 113 |
!! \since 2.0 |
| 114 |
type(kim_compute_argument_name_type), protected, save, & |
| 115 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_coordinates") & |
| 116 |
:: KIM_COMPUTE_ARGUMENT_NAME_COORDINATES |
| 117 |
|
| 118 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialEnergy |
| 119 |
!! |
| 120 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, |
| 121 |
!! KIM_COMPUTE_ARGUMENT_NAME_partialEnergy |
| 122 |
!! |
| 123 |
!! \since 2.0 |
| 124 |
type(kim_compute_argument_name_type), protected, save, & |
| 125 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialEnergy") & |
| 126 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY |
| 127 |
|
| 128 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialForces |
| 129 |
!! |
| 130 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::partialForces, |
| 131 |
!! KIM_COMPUTE_ARGUMENT_NAME_partialForces |
| 132 |
!! |
| 133 |
!! \since 2.0 |
| 134 |
type(kim_compute_argument_name_type), protected, save, & |
| 135 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialForces") & |
| 136 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES |
| 137 |
|
| 138 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy |
| 139 |
!! |
| 140 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy, |
| 141 |
!! KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy |
| 142 |
!! |
| 143 |
!! \since 2.0 |
| 144 |
type(kim_compute_argument_name_type), protected, save, & |
| 145 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy") & |
| 146 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY |
| 147 |
|
| 148 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialVirial |
| 149 |
!! |
| 150 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::partialVirial, |
| 151 |
!! KIM_COMPUTE_ARGUMENT_NAME_partialVirial |
| 152 |
!! |
| 153 |
!! \since 2.0 |
| 154 |
type(kim_compute_argument_name_type), protected, save, & |
| 155 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialVirial") & |
| 156 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL |
| 157 |
|
| 158 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial |
| 159 |
!! |
| 160 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial, |
| 161 |
!! KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial |
| 162 |
!! |
| 163 |
!! \since 2.0 |
| 164 |
type(kim_compute_argument_name_type), protected, save, & |
| 165 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial") & |
| 166 |
:: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_VIRIAL |
| 167 |
|
| 168 |
!> \brief \copybrief KIM::ComputeArgumentName::Known |
| 169 |
!! |
| 170 |
!! \sa KIM::ComputeArgumentName::Known, KIM_ComputeArgumentName_Known |
| 171 |
!! |
| 172 |
!! \since 2.0 |
| 173 |
interface kim_known |
| 174 |
module procedure kim_compute_argument_name_known |
| 175 |
end interface kim_known |
| 176 |
|
| 177 |
!> \brief \copybrief KIM::ComputeArgumentName::operator==() |
| 178 |
!! |
| 179 |
!! \sa KIM::ComputeArgumentName::operator==(), KIM_ComputeArgumentName_Equal |
| 180 |
!! |
| 181 |
!! \since 2.0 |
| 182 |
interface operator(.eq.) |
| 183 |
module procedure kim_compute_argument_name_equal |
| 184 |
end interface operator(.eq.) |
| 185 |
|
| 186 |
!> \brief \copybrief KIM::ComputeArgumentName::operator!=() |
| 187 |
!! |
| 188 |
!! \sa KIM::ComputeArgumentName::operator!=(), |
| 189 |
!! KIM_ComputeArgumentName_NotEqual |
| 190 |
!! |
| 191 |
!! \since 2.0 |
| 192 |
interface operator(.ne.) |
| 193 |
module procedure kim_compute_argument_name_not_equal |
| 194 |
end interface operator(.ne.) |
| 195 |
|
| 196 |
!> \brief \copybrief KIM::ComputeArgumentName::<!-- |
| 197 |
!! -->ComputeArgumentName(std::string const &) |
| 198 |
!! |
| 199 |
!! \sa KIM::ComputeArgumentName::ComputeArgumentName(std::string const &), |
| 200 |
!! KIM_ComputeArgumentName_FromString |
| 201 |
!! |
| 202 |
!! \since 2.0 |
| 203 |
interface kim_from_string |
| 204 |
module procedure kim_compute_argument_name_from_string |
| 205 |
end interface kim_from_string |
| 206 |
|
| 207 |
!> \brief \copybrief KIM::ComputeArgumentName::ToString |
| 208 |
!! |
| 209 |
!! \sa KIM::ComputeArgumentName::ToString, KIM_ComputeArgumentName_ToString |
| 210 |
!! |
| 211 |
!! \since 2.0 |
| 212 |
interface kim_to_string |
| 213 |
module procedure kim_compute_argument_name_to_string |
| 214 |
end interface kim_to_string |
| 215 |
|
| 216 |
contains |
| 217 |
!> \brief \copybrief KIM::ComputeArgumentName::Known |
| 218 |
!! |
| 219 |
!! \sa KIM::ComputeArgumentName::Known, KIM_ComputeArgumentName_Known |
| 220 |
!! |
| 221 |
!! \since 2.0 |
| 222 |
logical recursive function kim_compute_argument_name_known( & |
| 223 |
compute_argument_name) |
| 224 |
implicit none |
| 225 |
interface |
| 226 |
integer(c_int) recursive function known(compute_argument_name) & |
| 227 |
bind(c, name="KIM_ComputeArgumentName_Known") |
| 228 |
use, intrinsic :: iso_c_binding |
| 229 |
import kim_compute_argument_name_type |
| 230 |
implicit none |
| 231 |
type(kim_compute_argument_name_type), intent(in), value :: & |
| 232 |
compute_argument_name |
| 233 |
end function known |
| 234 |
end interface |
| 235 |
type(kim_compute_argument_name_type), intent(in) :: compute_argument_name |
| 236 |
|
| 237 |
kim_compute_argument_name_known = (known(compute_argument_name) /= 0) |
| 238 |
end function kim_compute_argument_name_known |
| 239 |
|
| 240 |
!> \brief \copybrief KIM::ComputeArgumentName::operator==() |
| 241 |
!! |
| 242 |
!! \sa KIM::ComputeArgumentName::operator==(), KIM_ComputeArgumentName_Equal |
| 243 |
!! |
| 244 |
!! \since 2.0 |
| 245 |
logical recursive function kim_compute_argument_name_equal(lhs, rhs) |
| 246 |
implicit none |
| 247 |
type(kim_compute_argument_name_type), intent(in) :: lhs |
| 248 |
type(kim_compute_argument_name_type), intent(in) :: rhs |
| 249 |
|
| 250 |
kim_compute_argument_name_equal & |
| 251 |
= (lhs%compute_argument_name_id == rhs%compute_argument_name_id) |
| 252 |
end function kim_compute_argument_name_equal |
| 253 |
|
| 254 |
!> \brief \copybrief KIM::ComputeArgumentName::operator!=() |
| 255 |
!! |
| 256 |
!! \sa KIM::ComputeArgumentName::operator!=(), |
| 257 |
!! KIM_ComputeArgumentName_NotEqual |
| 258 |
!! |
| 259 |
!! \since 2.0 |
| 260 |
logical recursive function kim_compute_argument_name_not_equal(lhs, rhs) |
| 261 |
implicit none |
| 262 |
type(kim_compute_argument_name_type), intent(in) :: lhs |
| 263 |
type(kim_compute_argument_name_type), intent(in) :: rhs |
| 264 |
|
| 265 |
kim_compute_argument_name_not_equal = .not. (lhs == rhs) |
| 266 |
end function kim_compute_argument_name_not_equal |
| 267 |
|
| 268 |
!> \brief \copybrief KIM::ComputeArgumentName::<!-- |
| 269 |
!! -->ComputeArgumentName(std::string const &) |
| 270 |
!! |
| 271 |
!! \sa KIM::ComputeArgumentName::ComputeArgumentName(std::string const &), |
| 272 |
!! KIM_ComputeArgumentName_FromString |
| 273 |
!! |
| 274 |
!! \since 2.0 |
| 275 |
recursive subroutine kim_compute_argument_name_from_string( & |
| 276 |
string, compute_argument_name) |
| 277 |
implicit none |
| 278 |
interface |
| 279 |
type(kim_compute_argument_name_type) recursive function from_string( & |
| 280 |
string) bind(c, name="KIM_ComputeArgumentName_FromString") |
| 281 |
use, intrinsic :: iso_c_binding |
| 282 |
import kim_compute_argument_name_type |
| 283 |
implicit none |
| 284 |
character(c_char), intent(in) :: string(*) |
| 285 |
end function from_string |
| 286 |
end interface |
| 287 |
character(len=*, kind=c_char), intent(in) :: string |
| 288 |
type(kim_compute_argument_name_type), intent(out) :: compute_argument_name |
| 289 |
|
| 290 |
compute_argument_name = from_string(trim(string)//c_null_char) |
| 291 |
end subroutine kim_compute_argument_name_from_string |
| 292 |
|
| 293 |
!> \brief \copybrief KIM::ComputeArgumentName::ToString |
| 294 |
!! |
| 295 |
!! \sa KIM::ComputeArgumentName::ToString, KIM_ComputeArgumentName_ToString |
| 296 |
!! |
| 297 |
!! \since 2.0 |
| 298 |
recursive subroutine kim_compute_argument_name_to_string( & |
| 299 |
compute_argument_name, string) |
| 300 |
use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string |
| 301 |
implicit none |
| 302 |
interface |
| 303 |
type(c_ptr) recursive function get_string(compute_argument_name) & |
| 304 |
bind(c, name="KIM_ComputeArgumentName_ToString") |
| 305 |
use, intrinsic :: iso_c_binding |
| 306 |
import kim_compute_argument_name_type |
| 307 |
implicit none |
| 308 |
type(kim_compute_argument_name_type), intent(in), value :: & |
| 309 |
compute_argument_name |
| 310 |
end function get_string |
| 311 |
end interface |
| 312 |
type(kim_compute_argument_name_type), intent(in) :: & |
| 313 |
compute_argument_name |
| 314 |
character(len=*, kind=c_char), intent(out) :: string |
| 315 |
|
| 316 |
type(c_ptr) :: p |
| 317 |
|
| 318 |
p = get_string(compute_argument_name) |
| 319 |
call kim_convert_c_char_ptr_to_string(p, string) |
| 320 |
end subroutine kim_compute_argument_name_to_string |
| 321 |
|
| 322 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::<!-- |
| 323 |
!! -->GetNumberOfComputeArgumentNames |
| 324 |
!! |
| 325 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames, |
| 326 |
!! KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames |
| 327 |
!! |
| 328 |
!! \since 2.0 |
| 329 |
recursive subroutine kim_get_number_of_compute_argument_names( & |
| 330 |
number_of_compute_argument_names) |
| 331 |
implicit none |
| 332 |
interface |
| 333 |
recursive subroutine get_number_of_compute_argument_names( & |
| 334 |
number_of_compute_argument_names) & |
| 335 |
bind(c, & |
| 336 |
name="KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames") |
| 337 |
use, intrinsic :: iso_c_binding |
| 338 |
integer(c_int), intent(out) :: number_of_compute_argument_names |
| 339 |
end subroutine get_number_of_compute_argument_names |
| 340 |
end interface |
| 341 |
integer(c_int), intent(out) :: number_of_compute_argument_names |
| 342 |
|
| 343 |
call get_number_of_compute_argument_names(number_of_compute_argument_names) |
| 344 |
end subroutine kim_get_number_of_compute_argument_names |
| 345 |
|
| 346 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::<!-- |
| 347 |
!! -->GetComputeArgumentName |
| 348 |
!! |
| 349 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName, |
| 350 |
!! KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName |
| 351 |
!! |
| 352 |
!! \since 2.0 |
| 353 |
recursive subroutine kim_get_compute_argument_name( & |
| 354 |
index, compute_argument_name, ierr) |
| 355 |
implicit none |
| 356 |
interface |
| 357 |
integer(c_int) recursive function get_compute_argument_name( & |
| 358 |
index, compute_argument_name) & |
| 359 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName") |
| 360 |
use, intrinsic :: iso_c_binding |
| 361 |
import kim_compute_argument_name_type |
| 362 |
implicit none |
| 363 |
integer(c_int), intent(in), value :: index |
| 364 |
type(kim_compute_argument_name_type), intent(out) :: & |
| 365 |
compute_argument_name |
| 366 |
end function get_compute_argument_name |
| 367 |
end interface |
| 368 |
integer(c_int), intent(in) :: index |
| 369 |
type(kim_compute_argument_name_type), intent(out) :: compute_argument_name |
| 370 |
integer(c_int), intent(out) :: ierr |
| 371 |
|
| 372 |
ierr = get_compute_argument_name(index - 1, compute_argument_name) |
| 373 |
end subroutine kim_get_compute_argument_name |
| 374 |
|
| 375 |
!> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::<!-- |
| 376 |
!! -->GetComputeArgumentDataType |
| 377 |
!! |
| 378 |
!! \sa KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType, |
| 379 |
!! KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType |
| 380 |
!! |
| 381 |
!! \since 2.0 |
| 382 |
recursive subroutine kim_get_compute_argument_data_type( & |
| 383 |
compute_argument_name, & |
| 384 |
data_type, ierr) |
| 385 |
use kim_data_type_module, only: kim_data_type_type |
| 386 |
implicit none |
| 387 |
interface |
| 388 |
integer(c_int) recursive function get_compute_argument_data_type( & |
| 389 |
compute_argument_name, data_type) & |
| 390 |
bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType") |
| 391 |
use, intrinsic :: iso_c_binding |
| 392 |
use kim_data_type_module, only: kim_data_type_type |
| 393 |
import kim_compute_argument_name_type |
| 394 |
implicit none |
| 395 |
type(kim_compute_argument_name_type), intent(in), value :: & |
| 396 |
compute_argument_name |
| 397 |
type(kim_data_type_type), intent(out) :: data_type |
| 398 |
end function get_compute_argument_data_type |
| 399 |
end interface |
| 400 |
type(kim_compute_argument_name_type), intent(in) :: & |
| 401 |
compute_argument_name |
| 402 |
type(kim_data_type_type), intent(out) :: data_type |
| 403 |
integer(c_int), intent(out) :: ierr |
| 404 |
|
| 405 |
ierr = get_compute_argument_data_type(compute_argument_name, data_type) |
| 406 |
end subroutine kim_get_compute_argument_data_type |
| 407 |
end module kim_compute_argument_name_module |