kim-api 2.3.0+AppleClang.AppleClang.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
Loading...
Searching...
No Matches
kim_model_extension_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-2.3.0 package.
28!
29
36 use, intrinsic :: iso_c_binding
37 implicit none
38 private
39
40 public &
41 ! Derived types
43 ! Constants
45 ! Routines
46 operator(.eq.), &
47 operator(.ne.), &
65
71 type, bind(c) :: kim_model_extension_handle_type
72 type(c_ptr) :: p = c_null_ptr
74
78 type(kim_model_extension_handle_type), protected, save &
80
84 interface operator(.eq.)
85 module procedure kim_model_extension_handle_equal
86 end interface operator(.eq.)
87
91 interface operator(.ne.)
92 module procedure kim_model_extension_handle_not_equal
93 end interface operator(.ne.)
94
101 module procedure kim_model_extension_get_extension_id
102 end interface kim_get_extension_id
103
109 interface kim_to_model
110 module procedure kim_model_extension_to_model
111 end interface kim_to_model
112
120 end interface kim_to_model_compute
121
129 end interface kim_to_model_create
130
138 end interface kim_to_model_destroy
139
148 end interface kim_to_model_driver_create
149
157 end interface kim_to_model_refresh
158
168
178
188
198
204 end interface kim_c_char_array_to_string
205
211 end interface kim_c_char_ptr_to_string
212
218 end interface kim_string_to_c_char_array
219
228 end interface kim_get_model_buffer_pointer
229
236 module procedure kim_model_extension_log_entry
237 end interface kim_log_entry
238
245 module procedure kim_model_extension_to_string
246 end interface kim_to_string
247
248contains
252 logical recursive function kim_model_extension_handle_equal(lhs, rhs)
253 implicit none
254 type(kim_model_extension_handle_type), intent(in) :: lhs
255 type(kim_model_extension_handle_type), intent(in) :: rhs
256
257 if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then
258 kim_model_extension_handle_equal = .true.
259 else
260 kim_model_extension_handle_equal = c_associated(lhs%p, rhs%p)
261 end if
262 end function kim_model_extension_handle_equal
263
267 logical recursive function kim_model_extension_handle_not_equal(lhs, rhs)
268 implicit none
269 type(kim_model_extension_handle_type), intent(in) :: lhs
270 type(kim_model_extension_handle_type), intent(in) :: rhs
271
272 kim_model_extension_handle_not_equal = .not. (lhs == rhs)
273 end function kim_model_extension_handle_not_equal
274
280 recursive subroutine kim_model_extension_get_extension_id( &
281 model_extension_handle, extension_id)
282 use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
283 use kim_interoperable_types_module, only: kim_model_extension_type
284 implicit none
285 interface
286 recursive subroutine get_extension_id(model_extension, extension_id) &
287 bind(c, name="KIM_ModelExtension_GetExtensionID")
288 use, intrinsic :: iso_c_binding
289 use kim_interoperable_types_module, only: kim_model_extension_type
290 implicit none
291 type(kim_model_extension_type), intent(in) :: model_extension
292 type(c_ptr), intent(out) :: extension_id
293 end subroutine get_extension_id
294 end interface
295 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
296 character(len=*, kind=c_char), intent(out) :: extension_id
297 type(kim_model_extension_type), pointer :: model_extension
298
299 type(c_ptr) :: p
300
301 call c_f_pointer(model_extension_handle%p, model_extension)
302 call get_extension_id(model_extension, p)
303 call kim_convert_c_char_ptr_to_string(p, extension_id)
304 end subroutine kim_model_extension_get_extension_id
305
311 recursive subroutine kim_model_extension_to_model(model_extension_handle, &
312 model_handle)
314 implicit none
315 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
316 type(kim_model_handle_type), intent(out) :: model_handle
317
318 model_handle%p = model_extension_handle%p
319 end subroutine kim_model_extension_to_model
320
327 model_extension_handle, model_compute_handle)
329 implicit none
330 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
331 type(kim_model_compute_handle_type), intent(out) :: model_compute_handle
332
333 model_compute_handle%p = model_extension_handle%p
335
342 model_extension_handle, model_create_handle)
344 implicit none
345 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
346 type(kim_model_create_handle_type), intent(out) :: model_create_handle
347
348 model_create_handle%p = model_extension_handle%p
350
357 model_extension_handle, model_destroy_handle)
359 implicit none
360 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
361 type(kim_model_destroy_handle_type), intent(out) :: model_destroy_handle
362
363 model_destroy_handle%p = model_extension_handle%p
365
373 model_extension_handle, model_driver_create_handle)
375 implicit none
376 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
377 type(kim_model_driver_create_handle_type), intent(out) &
378 :: model_driver_create_handle
379
380 model_driver_create_handle%p = model_extension_handle%p
382
389 model_extension_handle, model_refresh_handle)
391 implicit none
392 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
393 type(kim_model_refresh_handle_type), intent(out) :: model_refresh_handle
394
395 model_refresh_handle%p = model_extension_handle%p
397
405 model_extension_handle, model_write_parameterized_model_handle)
407 implicit none
408 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
410 :: model_write_parameterized_model_handle
411
412 model_write_parameterized_model_handle%p = model_extension_handle%p
414
422 model_extension_handle, compute_arguments_c_ptr, &
423 model_compute_arguments_handle)
425 implicit none
426 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
427 type(c_ptr), intent(in) :: compute_arguments_c_ptr
428 type(kim_model_compute_arguments_handle_type), intent(out) &
429 :: model_compute_arguments_handle
430
431 ! avoid unused dummy argument warnings
432 if (model_extension_handle == kim_model_extension_null_handle) continue
433
434 model_compute_arguments_handle%p = compute_arguments_c_ptr
436
444 model_extension_handle, compute_arguments_c_ptr, &
445 model_compute_arguments_create_handle)
447 implicit none
448 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
449 type(c_ptr), intent(in) :: compute_arguments_c_ptr
451 :: model_compute_arguments_create_handle
452
453 ! avoid unused dummy argument warnings
454 if (model_extension_handle == kim_model_extension_null_handle) continue
455
456 model_compute_arguments_create_handle%p = compute_arguments_c_ptr
458
466 model_extension_handle, compute_arguments_c_ptr, &
467 model_compute_arguments_destroy_handle)
469 implicit none
470 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
471 type(c_ptr), intent(in) :: compute_arguments_c_ptr
473 :: model_compute_arguments_destroy_handle
474
475 ! avoid unused dummy argument warnings
476 if (model_extension_handle == kim_model_extension_null_handle) continue
477
478 model_compute_arguments_destroy_handle%p = compute_arguments_c_ptr
480
485 c_char_array, string)
486 use kim_convert_string_module, only: kim_convert_c_char_array_to_string
487 implicit none
488 character(len=1, kind=c_char), intent(in) :: c_char_array(:)
489 character(len=*, kind=c_char), intent(out) :: string
490
491 call kim_convert_c_char_array_to_string(c_char_array, string)
493
498 c_char_ptr, string)
499 use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
500 implicit none
501 type(c_ptr), intent(in) :: c_char_ptr
502 character(len=*, kind=c_char), intent(out) :: string
503
504 call kim_convert_c_char_ptr_to_string(c_char_ptr, string)
506
511 string, c_char_array)
512 use kim_convert_string_module, only: kim_convert_string_to_c_char_array
513 implicit none
514 character(len=*, kind=c_char), intent(in) :: string
515 character(len=1, kind=c_char), intent(out) :: c_char_array(:)
516
517 call kim_convert_string_to_c_char_array(string, c_char_array)
519
527 model_extension_handle, ptr)
528 use kim_interoperable_types_module, only: kim_model_extension_type
529 implicit none
530 interface
531 recursive subroutine get_model_buffer_pointer(model_extension, ptr) &
532 bind(c, name="KIM_ModelExtension_GetModelBufferPointer")
533 use, intrinsic :: iso_c_binding
534 use kim_interoperable_types_module, only: kim_model_extension_type
535 implicit none
536 type(kim_model_extension_type), intent(in) :: model_extension
537 type(c_ptr), intent(out) :: ptr
538 end subroutine get_model_buffer_pointer
539 end interface
540 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
541 type(c_ptr), intent(out) :: ptr
542 type(kim_model_extension_type), pointer :: model_extension
543
544 call c_f_pointer(model_extension_handle%p, model_extension)
547
553 recursive subroutine kim_model_extension_log_entry(model_extension_handle, &
554 log_verbosity, message)
556 use kim_interoperable_types_module, only: kim_model_extension_type
557 implicit none
558 interface
559 recursive subroutine log_entry( &
560 model_extension, log_verbosity, message, line_number, file_name) &
561 bind(c, name="KIM_ModelExtension_LogEntry")
562 use, intrinsic :: iso_c_binding
564 use kim_interoperable_types_module, only: kim_model_extension_type
565 implicit none
566 type(kim_model_extension_type), intent(in) :: model_extension
567 type(kim_log_verbosity_type), intent(in), value :: log_verbosity
568 character(c_char), intent(in) :: message(*)
569 integer(c_int), intent(in), value :: line_number
570 character(c_char), intent(in) :: file_name(*)
571 end subroutine log_entry
572 end interface
573 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
574 type(kim_log_verbosity_type), intent(in) :: log_verbosity
575 character(len=*, kind=c_char), intent(in) :: message
576 type(kim_model_extension_type), pointer :: model_extension
577
578 call c_f_pointer(model_extension_handle%p, model_extension)
579 call log_entry(model_extension, log_verbosity, trim(message)//c_null_char, &
580 0, ""//c_null_char)
581 end subroutine kim_model_extension_log_entry
582
588 recursive subroutine kim_model_extension_to_string(model_extension_handle, &
589 string)
590 use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
591 use kim_interoperable_types_module, only: kim_model_extension_type
592 implicit none
593 interface
594 type(c_ptr) recursive function model_extension_string(model_extension) &
595 bind(c, name="KIM_ModelExtension_ToString")
596 use, intrinsic :: iso_c_binding
597 use kim_interoperable_types_module, only: kim_model_extension_type
598 implicit none
599 type(kim_model_extension_type), intent(in) :: model_extension
600 end function model_extension_string
601 end interface
602 type(kim_model_extension_handle_type), intent(in) :: model_extension_handle
603 character(len=*, kind=c_char), intent(out) :: string
604 type(kim_model_extension_type), pointer :: model_extension
605
606 type(c_ptr) :: p
607
608 call c_f_pointer(model_extension_handle%p, model_extension)
610 call kim_convert_c_char_ptr_to_string(p, string)
611 end subroutine kim_model_extension_to_string
static int model_extension(KIM_ModelExtension *const modelExtension, void *const extensionStructure)
Get the Model's buffer pointer within the Model object.
Write a log entry into the log file.
Convert the ModelExtension interface to the Model object to a ModelComputeArgumentsCreate interface.
Convert the ModelExtension interface to the Model object to a ModelComputeArgumentsDestroy interface.
Convert the ModelExtension interface to the Model object to a ModelComputeArguments interface.
Convert the ModelExtension interface to the Model object to a ModelCompute interface.
Convert the ModelExtension interface to the Model object to a ModelCompute interface.
Convert the ModelExtension interface to the Model object to a ModelDestroy interface.
Convert the ModelExtension interface to the Model object to a ModelDriverCreate interface.
Convert the ModelExtension interface to the Model object to a ModelRefresh interface.
Convert the ModelExtension interface to the Model object to a ModelWriteParameterizedModel interface.
Convert the ModelExtension interface to the Model object to a Model interface.
Get a string representing the internal state of the Model object.
An Extensible Enumeration for the LogVerbosity's supported by the KIM API.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::D...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::E...
recursive subroutine kim_model_extension_to_model_write_parameterized_model(model_extension_handle, model_write_parameterized_model_handle)
Convert the ModelExtension interface to the Model object to a ModelWriteParameterizedModel interface.
recursive subroutine kim_model_extension_to_model_destroy(model_extension_handle, model_destroy_handle)
Convert the ModelExtension interface to the Model object to a ModelDestroy interface.
recursive subroutine kim_model_extension_convert_c_char_ptr_to_string(c_char_ptr, string)
Copy C character pointer to Fortran string.
recursive subroutine kim_model_extension_to_model_compute_arguments_create(model_extension_handle, compute_arguments_c_ptr, model_compute_arguments_create_handle)
Convert the ModelExtension interface to the Model object to a ModelComputeArgumentsCreate interface.
recursive subroutine kim_model_extension_to_model_compute(model_extension_handle, model_compute_handle)
Convert the ModelExtension interface to the Model object to a ModelCompute interface.
recursive subroutine kim_model_extension_to_model_compute_arguments(model_extension_handle, compute_arguments_c_ptr, model_compute_arguments_handle)
Convert the ModelExtension interface to the Model object to a ModelComputeArguments interface.
recursive subroutine kim_model_extension_to_model_refresh(model_extension_handle, model_refresh_handle)
Convert the ModelExtension interface to the Model object to a ModelRefresh interface.
recursive subroutine kim_model_extension_to_model(model_extension_handle, model_handle)
Convert the ModelExtension interface to the Model object to a Model interface.
recursive subroutine kim_model_extension_to_model_create(model_extension_handle, model_create_handle)
Convert the ModelExtension interface to the Model object to a ModelCompute interface.
recursive subroutine kim_model_extension_to_string(model_extension_handle, string)
Get a string representing the internal state of the Model object.
recursive subroutine kim_model_extension_convert_c_char_array_to_string(c_char_array, string)
Copy C character array to Fortran string.
recursive subroutine kim_model_extension_convert_string_to_c_char_array(string, c_char_array)
Convert Fortran string to C character array.
recursive subroutine kim_model_extension_to_model_driver_create(model_extension_handle, model_driver_create_handle)
Convert the ModelExtension interface to the Model object to a ModelDriverCreate interface.
type(kim_model_extension_handle_type), save, public, protected kim_model_extension_null_handle
NULL handle for use in comparisons.
recursive subroutine kim_model_extension_log_entry(model_extension_handle, log_verbosity, message)
Write a log entry into the log file.
recursive subroutine kim_model_extension_to_model_compute_arguments_destroy(model_extension_handle, compute_arguments_c_ptr, model_compute_arguments_destroy_handle)
Convert the ModelExtension interface to the Model object to a ModelComputeArgumentsDestroy interface.
recursive subroutine kim_model_extension_get_model_buffer_pointer(model_extension_handle, ptr)
Get the Model's buffer pointer within the Model object.
Provides the primary interface to a KIM API Model object and is meant to be used by simulators.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::R...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::W...
An Extensible Enumeration for the LogVerbosity's supported by the KIM API.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::D...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::E...
Provides the primary interface to a KIM API Model object and is meant to be used by simulators.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::R...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::W...