| 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::ModelRoutineName |
| 31 |
!! |
| 32 |
!! \sa KIM::ModelRoutineName, KIM_ModelRoutineName |
| 33 |
!! |
| 34 |
!! \since 2.0 |
| 35 |
module kim_model_routine_name_module |
| 36 |
use, intrinsic :: iso_c_binding |
| 37 |
implicit none |
| 38 |
private |
| 39 |
|
| 40 |
public & |
| 41 |
! Derived types |
| 42 |
kim_model_routine_name_type, & |
| 43 |
! Constants |
| 44 |
KIM_MODEL_ROUTINE_NAME_CREATE, & |
| 45 |
KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE, & |
| 46 |
KIM_MODEL_ROUTINE_NAME_COMPUTE, & |
| 47 |
KIM_MODEL_ROUTINE_NAME_EXTENSION, & |
| 48 |
KIM_MODEL_ROUTINE_NAME_REFRESH, & |
| 49 |
KIM_MODEL_ROUTINE_NAME_WRITE_PARAMETERIZED_MODEL, & |
| 50 |
KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY, & |
| 51 |
KIM_MODEL_ROUTINE_NAME_DESTROY, & |
| 52 |
! Routines |
| 53 |
kim_known, & |
| 54 |
operator(.eq.), & |
| 55 |
operator(.ne.), & |
| 56 |
kim_from_string, & |
| 57 |
kim_to_string, & |
| 58 |
kim_get_number_of_model_routine_names, & |
| 59 |
kim_get_model_routine_name |
| 60 |
|
| 61 |
!> \brief \copybrief KIM::ModelRoutineName |
| 62 |
!! |
| 63 |
!! \sa KIM::ModelRoutineName, KIM_ModelRoutineName |
| 64 |
!! |
| 65 |
!! \since 2.0 |
| 66 |
type, bind(c) :: kim_model_routine_name_type |
| 67 |
!> \brief \copybrief KIM::ModelRoutineName::modelRoutineNameID |
| 68 |
!! |
| 69 |
!! \sa KIM::ModelRoutineName::modelRoutineNameID, |
| 70 |
!! KIM_ModelRoutineName::modelRoutineNameID |
| 71 |
!! |
| 72 |
!! \since 2.0 |
| 73 |
integer(c_int) model_routine_name_id |
| 74 |
end type kim_model_routine_name_type |
| 75 |
|
| 76 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Create |
| 77 |
!! |
| 78 |
!! \sa KIM::MODEL_ROUTINE_NAME::Create, KIM_MODEL_ROUTINE_NAME_Create |
| 79 |
!! |
| 80 |
!! \since 2.0 |
| 81 |
type(kim_model_routine_name_type), protected, save, & |
| 82 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_Create") & |
| 83 |
:: KIM_MODEL_ROUTINE_NAME_CREATE |
| 84 |
|
| 85 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate |
| 86 |
!! |
| 87 |
!! \sa KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate, |
| 88 |
!! KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate |
| 89 |
!! |
| 90 |
!! \since 2.0 |
| 91 |
type(kim_model_routine_name_type), protected, save, & |
| 92 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate") & |
| 93 |
:: KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE |
| 94 |
|
| 95 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Compute |
| 96 |
!! |
| 97 |
!! \sa KIM::MODEL_ROUTINE_NAME::Compute, KIM_MODEL_ROUTINE_NAME_Compute |
| 98 |
!! |
| 99 |
!! \since 2.0 |
| 100 |
type(kim_model_routine_name_type), protected, save, & |
| 101 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_Compute") & |
| 102 |
:: KIM_MODEL_ROUTINE_NAME_COMPUTE |
| 103 |
|
| 104 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Extension |
| 105 |
!! |
| 106 |
!! \sa KIM::MODEL_ROUTINE_NAME::Extension, KIM_MODEL_ROUTINE_NAME_Extension |
| 107 |
!! |
| 108 |
!! \since 2.0 |
| 109 |
type(kim_model_routine_name_type), protected, save, & |
| 110 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_Extension") & |
| 111 |
:: KIM_MODEL_ROUTINE_NAME_EXTENSION |
| 112 |
|
| 113 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Refresh |
| 114 |
!! |
| 115 |
!! \sa KIM::MODEL_ROUTINE_NAME::Refresh, KIM_MODEL_ROUTINE_NAME_Refresh |
| 116 |
!! |
| 117 |
!! \since 2.0 |
| 118 |
type(kim_model_routine_name_type), protected, save, & |
| 119 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_Refresh") & |
| 120 |
:: KIM_MODEL_ROUTINE_NAME_REFRESH |
| 121 |
|
| 122 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel |
| 123 |
!! |
| 124 |
!! \sa KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel, |
| 125 |
!! KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel |
| 126 |
!! |
| 127 |
!! \since 2.0 |
| 128 |
type(kim_model_routine_name_type), protected, save, & |
| 129 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel") & |
| 130 |
:: KIM_MODEL_ROUTINE_NAME_WRITE_PARAMETERIZED_MODEL |
| 131 |
|
| 132 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy |
| 133 |
!! |
| 134 |
!! \sa KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy, |
| 135 |
!! KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy |
| 136 |
!! |
| 137 |
!! \since 2.0 |
| 138 |
type(kim_model_routine_name_type), protected, save, & |
| 139 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy") & |
| 140 |
:: KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY |
| 141 |
|
| 142 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Destroy |
| 143 |
!! |
| 144 |
!! \sa KIM::MODEL_ROUTINE_NAME::Destroy, KIM_MODEL_ROUTINE_NAME_Destroy |
| 145 |
!! |
| 146 |
!! \since 2.0 |
| 147 |
type(kim_model_routine_name_type), protected, save, & |
| 148 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_Destroy") & |
| 149 |
:: KIM_MODEL_ROUTINE_NAME_DESTROY |
| 150 |
|
| 151 |
!> \brief \copybrief KIM::ModelRoutineName::Known |
| 152 |
!! |
| 153 |
!! \sa KIM::ModelRoutineName::Known, KIM_ModelRoutineName_Known |
| 154 |
!! |
| 155 |
!! \since 2.0 |
| 156 |
interface kim_known |
| 157 |
module procedure kim_model_routine_name_known |
| 158 |
end interface kim_known |
| 159 |
|
| 160 |
!> \brief \copybrief KIM::ModelRoutineName::operator==() |
| 161 |
!! |
| 162 |
!! \sa KIM::ModelRoutineName::operator==(), KIM_ModelRoutineName_Equal |
| 163 |
!! |
| 164 |
!! \since 2.0 |
| 165 |
interface operator(.eq.) |
| 166 |
module procedure kim_model_routine_name_equal |
| 167 |
end interface operator(.eq.) |
| 168 |
|
| 169 |
!> \brief \copybrief KIM::ModelRoutineName::operator!=() |
| 170 |
!! |
| 171 |
!! \sa KIM::ModelRoutineName::operator!=(), KIM_ModelRoutineName_NotEqual |
| 172 |
!! |
| 173 |
!! \since 2.0 |
| 174 |
interface operator(.ne.) |
| 175 |
module procedure kim_model_routine_name_not_equal |
| 176 |
end interface operator(.ne.) |
| 177 |
|
| 178 |
!> \brief \copybrief KIM::ModelRoutineName::<!-- |
| 179 |
!! -->ModelRoutineName(std::string const &) |
| 180 |
!! |
| 181 |
!! \sa KIM::ModelRoutineName::ModelRoutineName(std::string const &), |
| 182 |
!! KIM_ModelRoutineName_FromString |
| 183 |
!! |
| 184 |
!! \since 2.0 |
| 185 |
interface kim_from_string |
| 186 |
module procedure kim_model_routine_name_from_string |
| 187 |
end interface kim_from_string |
| 188 |
|
| 189 |
!> \brief \copybrief KIM::ModelRoutineName::ToString |
| 190 |
!! |
| 191 |
!! \sa KIM::ModelRoutineName::ToString, KIM_ModelRoutineName_ToString |
| 192 |
!! |
| 193 |
!! \since 2.0 |
| 194 |
interface kim_to_string |
| 195 |
module procedure kim_model_routine_name_to_string |
| 196 |
end interface kim_to_string |
| 197 |
|
| 198 |
contains |
| 199 |
!> \brief \copybrief KIM::ModelRoutineName::Known |
| 200 |
!! |
| 201 |
!! \sa KIM::ModelRoutineName::Known, KIM_ModelRoutineName_Known |
| 202 |
!! |
| 203 |
!! \since 2.0 |
| 204 |
logical recursive function kim_model_routine_name_known(model_routine_name) |
| 205 |
implicit none |
| 206 |
interface |
| 207 |
integer(c_int) recursive function known(model_routine_name) & |
| 208 |
bind(c, name="KIM_ModelRoutineName_Known") |
| 209 |
use, intrinsic :: iso_c_binding |
| 210 |
import kim_model_routine_name_type |
| 211 |
implicit none |
| 212 |
type(kim_model_routine_name_type), intent(in), value :: & |
| 213 |
model_routine_name |
| 214 |
end function known |
| 215 |
end interface |
| 216 |
type(kim_model_routine_name_type), intent(in) :: model_routine_name |
| 217 |
|
| 218 |
kim_model_routine_name_known = (known(model_routine_name) /= 0) |
| 219 |
end function kim_model_routine_name_known |
| 220 |
|
| 221 |
!> \brief \copybrief KIM::ModelRoutineName::operator==() |
| 222 |
!! |
| 223 |
!! \sa KIM::ModelRoutineName::operator==(), KIM_ModelRoutineName_Equal |
| 224 |
!! |
| 225 |
!! \since 2.0 |
| 226 |
logical recursive function kim_model_routine_name_equal(lhs, rhs) |
| 227 |
implicit none |
| 228 |
type(kim_model_routine_name_type), intent(in) :: lhs |
| 229 |
type(kim_model_routine_name_type), intent(in) :: rhs |
| 230 |
|
| 231 |
kim_model_routine_name_equal & |
| 232 |
= (lhs%model_routine_name_id == rhs%model_routine_name_id) |
| 233 |
end function kim_model_routine_name_equal |
| 234 |
|
| 235 |
!> \brief \copybrief KIM::ModelRoutineName::operator!=() |
| 236 |
!! |
| 237 |
!! \sa KIM::ModelRoutineName::operator!=(), KIM_ModelRoutineName_NotEqual |
| 238 |
!! |
| 239 |
!! \since 2.0 |
| 240 |
logical recursive function kim_model_routine_name_not_equal(lhs, rhs) |
| 241 |
implicit none |
| 242 |
type(kim_model_routine_name_type), intent(in) :: lhs |
| 243 |
type(kim_model_routine_name_type), intent(in) :: rhs |
| 244 |
|
| 245 |
kim_model_routine_name_not_equal = .not. (lhs == rhs) |
| 246 |
end function kim_model_routine_name_not_equal |
| 247 |
|
| 248 |
!> \brief \copybrief KIM::ModelRoutineName::<!-- |
| 249 |
!! -->ModelRoutineName(std::string const &) |
| 250 |
!! |
| 251 |
!! \sa KIM::ModelRoutineName::ModelRoutineName(std::string const &), |
| 252 |
!! KIM_ModelRoutineName_FromString |
| 253 |
!! |
| 254 |
!! \since 2.0 |
| 255 |
recursive subroutine kim_model_routine_name_from_string(string, & |
| 256 |
model_routine_name) |
| 257 |
implicit none |
| 258 |
interface |
| 259 |
type(kim_model_routine_name_type) recursive function from_string(string) & |
| 260 |
bind(c, name="KIM_ModelRoutineName_FromString") |
| 261 |
use, intrinsic :: iso_c_binding |
| 262 |
import kim_model_routine_name_type |
| 263 |
implicit none |
| 264 |
character(c_char), intent(in) :: string(*) |
| 265 |
end function from_string |
| 266 |
end interface |
| 267 |
character(len=*, kind=c_char), intent(in) :: string |
| 268 |
type(kim_model_routine_name_type), intent(out) :: model_routine_name |
| 269 |
|
| 270 |
model_routine_name = from_string(trim(string)//c_null_char) |
| 271 |
end subroutine kim_model_routine_name_from_string |
| 272 |
|
| 273 |
!> \brief \copybrief KIM::ModelRoutineName::ToString |
| 274 |
!! |
| 275 |
!! \sa KIM::ModelRoutineName::ToString, KIM_ModelRoutineName_ToString |
| 276 |
!! |
| 277 |
!! \since 2.0 |
| 278 |
recursive subroutine kim_model_routine_name_to_string(model_routine_name, & |
| 279 |
string) |
| 280 |
use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string |
| 281 |
implicit none |
| 282 |
interface |
| 283 |
type(c_ptr) recursive function get_string(model_routine_name) & |
| 284 |
bind(c, name="KIM_ModelRoutineName_ToString") |
| 285 |
use, intrinsic :: iso_c_binding |
| 286 |
import kim_model_routine_name_type |
| 287 |
implicit none |
| 288 |
type(kim_model_routine_name_type), intent(in), value :: & |
| 289 |
model_routine_name |
| 290 |
end function get_string |
| 291 |
end interface |
| 292 |
type(kim_model_routine_name_type), intent(in) :: & |
| 293 |
model_routine_name |
| 294 |
character(len=*, kind=c_char), intent(out) :: string |
| 295 |
|
| 296 |
type(c_ptr) :: p |
| 297 |
|
| 298 |
p = get_string(model_routine_name) |
| 299 |
call kim_convert_c_char_ptr_to_string(p, string) |
| 300 |
end subroutine kim_model_routine_name_to_string |
| 301 |
|
| 302 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames |
| 303 |
!! |
| 304 |
!! \sa KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames, |
| 305 |
!! KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames |
| 306 |
!! |
| 307 |
!! \since 2.0 |
| 308 |
recursive subroutine kim_get_number_of_model_routine_names( & |
| 309 |
number_of_model_routine_names) |
| 310 |
implicit none |
| 311 |
interface |
| 312 |
recursive subroutine get_number_of_model_routine_names( & |
| 313 |
number_of_model_routine_names) & |
| 314 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames") |
| 315 |
use, intrinsic :: iso_c_binding |
| 316 |
integer(c_int), intent(out) :: number_of_model_routine_names |
| 317 |
end subroutine get_number_of_model_routine_names |
| 318 |
end interface |
| 319 |
integer(c_int), intent(out) :: number_of_model_routine_names |
| 320 |
|
| 321 |
call get_number_of_model_routine_names(number_of_model_routine_names) |
| 322 |
end subroutine kim_get_number_of_model_routine_names |
| 323 |
|
| 324 |
!> \brief \copybrief KIM::MODEL_ROUTINE_NAME::GetModelRoutineName |
| 325 |
!! |
| 326 |
!! \sa KIM::MODEL_ROUTINE_NAME::GetModelRoutineName, |
| 327 |
!! KIM_MODEL_ROUTINE_NAME_GetModelRoutineName |
| 328 |
!! |
| 329 |
!! \since 2.0 |
| 330 |
recursive subroutine kim_get_model_routine_name(index, & |
| 331 |
model_routine_name, ierr) |
| 332 |
implicit none |
| 333 |
interface |
| 334 |
integer(c_int) recursive function get_model_routine_name( & |
| 335 |
index, model_routine_name) & |
| 336 |
bind(c, name="KIM_MODEL_ROUTINE_NAME_GetModelRoutineName") |
| 337 |
use, intrinsic :: iso_c_binding |
| 338 |
import kim_model_routine_name_type |
| 339 |
implicit none |
| 340 |
integer(c_int), intent(in), value :: index |
| 341 |
type(kim_model_routine_name_type), intent(out) :: & |
| 342 |
model_routine_name |
| 343 |
end function get_model_routine_name |
| 344 |
end interface |
| 345 |
integer(c_int), intent(in) :: index |
| 346 |
type(kim_model_routine_name_type), intent(out) :: model_routine_name |
| 347 |
integer(c_int), intent(out) :: ierr |
| 348 |
|
| 349 |
ierr = get_model_routine_name(index - 1, model_routine_name) |
| 350 |
end subroutine kim_get_model_routine_name |
| 351 |
end module kim_model_routine_name_module |