kim-api  2.3.0+v2.3.0.GNU.GNU.
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
kim_collections_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
42  kim_collections_handle_type, &
43  ! Constants
45  ! Routines
46  operator(.eq.), &
47  operator(.ne.), &
50  kim_get_item_type, &
51  kim_get_item_library_file_name_and_collection, &
52  kim_cache_list_of_item_metadata_files, &
53  kim_get_item_metadata_file_length, &
54  kim_get_item_metadata_file_values, &
55  kim_cache_list_of_item_names_by_type, &
56  kim_get_item_name_by_type, &
57  kim_cache_list_of_item_names_by_collection_and_type, &
58  kim_get_item_name_by_collection_and_type, &
59  kim_get_item_library_file_name_by_collection_and_type, &
60  kim_cache_list_of_item_metadata_files_by_collection_and_type, &
61  kim_get_item_metadata_file_length_by_collection_and_type, &
62  kim_get_item_metadata_file_values_by_collection_and_type, &
63  kim_get_project_name_and_sem_ver, &
64  kim_get_environment_variable_name, &
65  kim_get_configuration_file_environment_variable, &
66  kim_get_configuration_file_name, &
67  kim_cache_list_of_directory_names, &
68  kim_get_directory_name, &
69  kim_set_log_id, &
70  kim_push_log_verbosity, &
71  kim_pop_log_verbosity
72 
78  type, bind(c) :: kim_collections_handle_type
79  type(c_ptr) :: p = c_null_ptr
80  end type kim_collections_handle_type
81 
85  type(kim_collections_handle_type), protected, save &
87 
91  interface operator(.eq.)
92  module procedure kim_collections_handle_equal
93  end interface operator(.eq.)
94 
98  interface operator(.ne.)
99  module procedure kim_collections_handle_not_equal
100  end interface operator(.ne.)
101 
107  interface kim_get_item_type
108  module procedure kim_collections_get_item_type
109  end interface kim_get_item_type
110 
117  interface kim_get_item_library_file_name_and_collection
119  end interface kim_get_item_library_file_name_and_collection
120 
127  interface kim_cache_list_of_item_metadata_files
129  end interface kim_cache_list_of_item_metadata_files
130 
138  interface kim_get_item_metadata_file_length
140  end interface kim_get_item_metadata_file_length
141 
148  interface kim_get_item_metadata_file_values
150  end interface kim_get_item_metadata_file_values
151 
158  interface kim_cache_list_of_item_names_by_type
160  end interface kim_cache_list_of_item_names_by_type
161 
167  interface kim_get_item_name_by_type
169  end interface kim_get_item_name_by_type
170 
177  interface kim_cache_list_of_item_names_by_collection_and_type
178  module procedure &
180  end interface kim_cache_list_of_item_names_by_collection_and_type
181 
188  interface kim_get_item_name_by_collection_and_type
190  end interface kim_get_item_name_by_collection_and_type
191 
199  interface kim_get_item_library_file_name_by_collection_and_type
200  module procedure &
202  end interface kim_get_item_library_file_name_by_collection_and_type
203 
211  interface kim_cache_list_of_item_metadata_files_by_collection_and_type
212  module procedure &
214  end interface kim_cache_list_of_item_metadata_files_by_collection_and_type
215 
223  interface kim_get_item_metadata_file_length_by_collection_and_type
224  module procedure &
226  end interface kim_get_item_metadata_file_length_by_collection_and_type
227 
234  interface kim_get_item_metadata_file_values_by_collection_and_type
235  module procedure &
237  end interface kim_get_item_metadata_file_values_by_collection_and_type
238 
245  interface kim_get_project_name_and_sem_ver
247  end interface kim_get_project_name_and_sem_ver
248 
255  interface kim_get_environment_variable_name
257  end interface kim_get_environment_variable_name
258 
265  interface kim_get_configuration_file_environment_variable
267  end interface kim_get_configuration_file_environment_variable
268 
275  interface kim_get_configuration_file_name
277  end interface kim_get_configuration_file_name
278 
285  interface kim_cache_list_of_directory_names
287  end interface kim_cache_list_of_directory_names
288 
294  interface kim_get_directory_name
295  module procedure kim_collections_get_directory_name
296  end interface kim_get_directory_name
297 
303  interface kim_set_log_id
304  module procedure kim_collections_set_log_id
305  end interface kim_set_log_id
306 
312  interface kim_push_log_verbosity
313  module procedure kim_collections_push_log_verbosity
314  end interface kim_push_log_verbosity
315 
321  interface kim_pop_log_verbosity
322  module procedure kim_collections_pop_log_verbosity
323  end interface kim_pop_log_verbosity
324 
325 contains
329  logical recursive function kim_collections_handle_equal(lhs, rhs)
330  implicit none
331  type(kim_collections_handle_type), intent(in) :: lhs
332  type(kim_collections_handle_type), intent(in) :: rhs
333 
334  if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then
335  kim_collections_handle_equal = .true.
336  else
337  kim_collections_handle_equal = c_associated(lhs%p, rhs%p)
338  end if
339  end function kim_collections_handle_equal
340 
344  logical recursive function kim_collections_handle_not_equal(lhs, rhs)
345  implicit none
346  type(kim_collections_handle_type), intent(in) :: lhs
347  type(kim_collections_handle_type), intent(in) :: rhs
348 
349  kim_collections_handle_not_equal = .not. (lhs == rhs)
350  end function kim_collections_handle_not_equal
351 
357  recursive subroutine kim_collections_create(collections_handle, ierr)
358  implicit none
359  interface
360  integer(c_int) recursive function create(collections) &
361  bind(c, name="KIM_Collections_Create")
362  use, intrinsic :: iso_c_binding
363  implicit none
364  type(c_ptr), intent(out) :: collections
365  end function create
366  end interface
367  type(kim_collections_handle_type), intent(out) :: collections_handle
368  integer(c_int), intent(out) :: ierr
369 
370  type(c_ptr) :: pcollections
371 
372  ierr = create(pcollections)
373  collections_handle%p = pcollections
374  end subroutine kim_collections_create
375 
381  recursive subroutine kim_collections_destroy(collections_handle)
382  implicit none
383  interface
384  recursive subroutine destroy(collections) &
385  bind(c, name="KIM_Collections_Destroy")
386  use, intrinsic :: iso_c_binding
387  implicit none
388  type(c_ptr), intent(inout) :: collections
389  end subroutine destroy
390  end interface
391  type(kim_collections_handle_type), intent(inout) :: collections_handle
392 
393  type(c_ptr) :: pcollections
394  pcollections = collections_handle%p
395  call destroy(pcollections)
396  collections_handle%p = c_null_ptr
397  end subroutine kim_collections_destroy
398 
404  recursive subroutine kim_collections_get_item_type(collections_handle, &
405  item_name, item_type, ierr)
406  use kim_interoperable_types_module, only: kim_collections_type
407  use kim_collection_item_type_module, only: kim_collection_item_type_type
408  implicit none
409  interface
410  integer(c_int) recursive function get_item_type( &
411  collections, item_name, item_type) &
412  bind(c, name="KIM_Collections_GetItemType")
413  use, intrinsic :: iso_c_binding
414  use kim_interoperable_types_module, only: kim_collections_type
416  kim_collection_item_type_type
417  implicit none
418  type(kim_collections_type), intent(in) :: collections
419  character(c_char), intent(in) :: item_name(*)
420  type(kim_collection_item_type_type), intent(out) :: item_type
421  end function get_item_type
422  end interface
423  type(kim_collections_handle_type), intent(in) :: collections_handle
424  character(len=*, kind=c_char), intent(in) :: item_name
425  type(kim_collection_item_type_type), intent(out) :: item_type
426  integer(c_int), intent(out) :: ierr
427  type(kim_collections_type), pointer :: collections
428 
429  call c_f_pointer(collections_handle%p, collections)
430  ierr = get_item_type(collections, trim(item_name)//c_null_char, item_type)
431  end subroutine kim_collections_get_item_type
432 
439  recursive subroutine &
441  collections_handle, item_type, item_name, file_name, collection, ierr)
442  use kim_interoperable_types_module, only: kim_collections_type
443  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
444  use kim_collection_module, only: kim_collection_type
445  use kim_collection_item_type_module, only: kim_collection_item_type_type
446  implicit none
447  interface
448  integer(c_int) recursive function &
449  get_item_library_file_name_and_collection( &
450  collections, item_type, item_name, file_name, collection) &
451  bind(c, name="KIM_Collections_GetItemLibraryFileNameAndCollection")
452  use, intrinsic :: iso_c_binding
453  use kim_interoperable_types_module, only: kim_collections_type
454  use kim_collection_module, only: kim_collection_type
456  kim_collection_item_type_type
457  implicit none
458  type(kim_collections_type), intent(in) :: collections
459  type(kim_collection_item_type_type), intent(in), value :: item_type
460  character(c_char), intent(in) :: item_name(*)
461  type(c_ptr), intent(out) :: file_name
462  type(kim_collection_type), intent(out) :: collection
463  end function get_item_library_file_name_and_collection
464  end interface
465  type(kim_collections_handle_type), intent(in) :: collections_handle
466  type(kim_collection_item_type_type), intent(in) :: item_type
467  character(len=*, kind=c_char), intent(in) :: item_name
468  character(len=*, kind=c_char), intent(out) :: file_name
469  type(kim_collection_type), intent(out) :: collection
470  integer(c_int), intent(out) :: ierr
471  type(kim_collections_type), pointer :: collections
472 
473  type(c_ptr) :: pfile_name
474 
475  call c_f_pointer(collections_handle%p, collections)
476  ierr = get_item_library_file_name_and_collection( &
477  collections, &
478  item_type, &
479  trim(item_name)//c_null_char, &
480  pfile_name, &
481  collection)
482  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
484 
492  collections_handle, item_type, item_name, extent, ierr)
493  use kim_interoperable_types_module, only: kim_collections_type
494  use kim_collection_item_type_module, only: kim_collection_item_type_type
495  implicit none
496  interface
497  integer(c_int) recursive function cache_list_of_item_metadata_files( &
498  collections, item_type, item_name, extent) &
499  bind(c, name="KIM_Collections_CacheListOfItemMetadataFiles")
500  use, intrinsic :: iso_c_binding
501  use kim_interoperable_types_module, only: kim_collections_type
503  kim_collection_item_type_type
504  implicit none
505  type(kim_collections_type), intent(in) :: collections
506  type(kim_collection_item_type_type), intent(in), value :: item_type
507  character(c_char), intent(in) :: item_name(*)
508  integer(c_int), intent(out) :: extent
509  end function cache_list_of_item_metadata_files
510  end interface
511  type(kim_collections_handle_type), intent(in) :: collections_handle
512  type(kim_collection_item_type_type), intent(in) :: item_type
513  character(len=*, kind=c_char), intent(in) :: item_name
514  integer(c_int), intent(out) :: extent
515  integer(c_int), intent(out) :: ierr
516  type(kim_collections_type), pointer :: collections
517 
518  call c_f_pointer(collections_handle%p, collections)
519  ierr = cache_list_of_item_metadata_files(collections, item_type, &
520  trim(item_name)//c_null_char, &
521  extent)
523 
531  recursive subroutine kim_collections_get_item_metadata_file_length( &
532  collections_handle, index, file_length, available_as_string, ierr)
533  use kim_interoperable_types_module, only: kim_collections_type
534  implicit none
535  interface
536  integer(c_int) recursive function get_item_metadata_file( &
537  collections, index, file_name, file_length, file_raw_data, &
538  available_as_string, file_string) &
539  bind(c, name="KIM_Collections_GetItemMetadataFile_fortran")
540  use, intrinsic :: iso_c_binding
541  use kim_interoperable_types_module, only: kim_collections_type
542  implicit none
543  type(kim_collections_type), intent(in) :: collections
544  integer(c_int), intent(in), value :: index
545  type(c_ptr), intent(out) :: file_name
546  integer(c_long), intent(out) :: file_length
547  type(c_ptr), intent(out) :: file_raw_data
548  integer(c_int), intent(out) :: available_as_string
549  type(c_ptr), intent(out) :: file_string
550  end function get_item_metadata_file
551  end interface
552  type(kim_collections_handle_type), intent(in) :: collections_handle
553  integer(c_int), intent(in) :: index
554  integer(c_long), intent(out) :: file_length
555  integer(c_int), intent(out) :: available_as_string
556  integer(c_int), intent(out) :: ierr
557  type(kim_collections_type), pointer :: collections
558 
559  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
560 
561  call c_f_pointer(collections_handle%p, collections)
562  ierr = get_item_metadata_file(collections, &
563  index - 1, &
564  pfile_name, &
565  file_length, &
566  pfile_raw_data, &
567  available_as_string, &
568  pfile_string)
570 
577  recursive subroutine kim_collections_get_item_metadata_file_values( &
578  collections_handle, index, file_name, file_raw_data, file_string, ierr)
579  use kim_interoperable_types_module, only: kim_collections_type
580  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
581  implicit none
582  interface
583  integer(c_int) recursive function get_item_metadata_file( &
584  collections, index, file_name, file_length, file_raw_data, &
585  available_as_string, file_string) &
586  bind(c, name="KIM_Collections_GetItemMetadataFile_fortran")
587  use, intrinsic :: iso_c_binding
588  use kim_interoperable_types_module, only: kim_collections_type
589  implicit none
590  type(kim_collections_type), intent(in) :: collections
591  integer(c_int), intent(in), value :: index
592  type(c_ptr), intent(out) :: file_name
593  integer(c_long), intent(out) :: file_length
594  type(c_ptr), intent(out) :: file_raw_data
595  integer(c_int), intent(out) :: available_as_string
596  type(c_ptr), intent(out) :: file_string
597  end function get_item_metadata_file
598  end interface
599  type(kim_collections_handle_type), intent(in) :: collections_handle
600  integer(c_int), intent(in) :: index
601  character(len=*, kind=c_char), intent(out) :: file_name
602  integer(c_signed_char), intent(out) :: file_raw_data(:)
603  character(len=*, kind=c_char), intent(out) :: file_string
604  integer(c_int), intent(out) :: ierr
605  type(kim_collections_type), pointer :: collections
606 
607  integer(c_long) file_length
608  integer(c_int) available_as_string
609  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
610  integer(c_signed_char), pointer :: file_raw_data_fpointer(:)
611 
612  call c_f_pointer(collections_handle%p, collections)
613  ierr = get_item_metadata_file(collections, &
614  index - 1, &
615  pfile_name, &
616  file_length, &
617  pfile_raw_data, &
618  available_as_string, &
619  pfile_string)
620  if (ierr == 0) then
621  if (size(file_raw_data) < file_length) then
622  ierr = 1
623  return
624  end if
625  if (available_as_string == 1) then
626  if (len(file_string) < file_length) then
627  ierr = 1
628  return
629  end if
630  end if
631 
632  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
633  if (c_associated(pfile_raw_data)) then
634  call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length])
635  else
636  nullify (file_raw_data_fpointer)
637  end if
638  file_raw_data = file_raw_data_fpointer(1:file_length)
639 
640  if (available_as_string == 1) then
641  call kim_convert_c_char_ptr_to_string(pfile_string, file_string)
642  end if
643  end if
645 
653  collections_handle, item_type, extent, ierr)
654  use kim_interoperable_types_module, only: kim_collections_type
655  use kim_collection_item_type_module, only: kim_collection_item_type_type
656  implicit none
657  interface
658  integer(c_int) recursive function cache_list_of_item_names_by_type( &
659  collections, item_type, extent) &
660  bind(c, name="KIM_Collections_CacheListOfItemNamesByType")
661  use, intrinsic :: iso_c_binding
662  use kim_interoperable_types_module, only: kim_collections_type
664  kim_collection_item_type_type
665  implicit none
666  type(kim_collections_type), intent(in) :: collections
667  type(kim_collection_item_type_type), intent(in), value :: item_type
668  integer(c_int), intent(out) :: extent
669  end function cache_list_of_item_names_by_type
670  end interface
671  type(kim_collections_handle_type), intent(in) :: collections_handle
672  type(kim_collection_item_type_type), intent(in) :: item_type
673  integer(c_int), intent(out) :: extent
674  integer(c_int), intent(out) :: ierr
675  type(kim_collections_type), pointer :: collections
676 
677  call c_f_pointer(collections_handle%p, collections)
678  ierr = cache_list_of_item_names_by_type(collections, item_type, extent)
680 
686  recursive subroutine kim_collections_get_item_name_by_type( &
687  collections_handle, index, item_name, ierr)
688  use kim_interoperable_types_module, only: kim_collections_type
689  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
690  implicit none
691  interface
692  integer(c_int) recursive function get_item_name_by_type( &
693  collections, index, item_name) &
694  bind(c, name="KIM_Collections_GetItemNameByType")
695  use, intrinsic :: iso_c_binding
696  use kim_interoperable_types_module, only: kim_collections_type
697  implicit none
698  type(kim_collections_type), intent(in) :: collections
699  integer(c_int), intent(in), value :: index
700  type(c_ptr), intent(out) :: item_name
701  end function get_item_name_by_type
702  end interface
703  type(kim_collections_handle_type), intent(in) :: collections_handle
704  integer(c_int), intent(in) :: index
705  character(len=*, kind=c_char), intent(out) :: item_name
706  integer(c_int), intent(out) :: ierr
707  type(kim_collections_type), pointer :: collections
708 
709  type(c_ptr) pitem_name
710 
711  call c_f_pointer(collections_handle%p, collections)
712  ierr = get_item_name_by_type(collections, index - 1, pitem_name)
713  call kim_convert_c_char_ptr_to_string(pitem_name, item_name)
715 
722  recursive subroutine &
724  collections_handle, collection, item_type, extent, ierr)
725  use kim_interoperable_types_module, only: kim_collections_type
726  use kim_collection_module, only: kim_collection_type
727  use kim_collection_item_type_module, only: kim_collection_item_type_type
728  implicit none
729  interface
730  integer(c_int) recursive function &
731  cache_list_of_item_names_by_collection_and_type( &
732  collections, collection, item_type, extent) &
733  bind(c, name="KIM_Collections_CacheListOfItemNamesByCollectionAndType")
734  use, intrinsic :: iso_c_binding
735  use kim_interoperable_types_module, only: kim_collections_type
736  use kim_collection_module, only: kim_collection_type
738  kim_collection_item_type_type
739  implicit none
740  type(kim_collections_type), intent(in) :: collections
741  type(kim_collection_type), intent(in), value :: collection
742  type(kim_collection_item_type_type), intent(in), value :: item_type
743  integer(c_int), intent(out) :: extent
744  end function cache_list_of_item_names_by_collection_and_type
745  end interface
746  type(kim_collections_handle_type), intent(in) :: collections_handle
747  type(kim_collection_type), intent(in) :: collection
748  type(kim_collection_item_type_type), intent(in) :: item_type
749  integer(c_int), intent(out) :: extent
750  integer(c_int), intent(out) :: ierr
751  type(kim_collections_type), pointer :: collections
752 
753  call c_f_pointer(collections_handle%p, collections)
754  ierr = cache_list_of_item_names_by_collection_and_type(collections, &
755  collection, &
756  item_type, &
757  extent)
759 
767  collections_handle, index, item_name, ierr)
768  use kim_interoperable_types_module, only: kim_collections_type
769  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
770  implicit none
771  interface
772  integer(c_int) recursive function get_item_name_by_collection_and_type( &
773  collections, index, item_name) &
774  bind(c, name="KIM_Collections_GetItemNameByCollectionAndType")
775  use, intrinsic :: iso_c_binding
776  use kim_interoperable_types_module, only: kim_collections_type
777  implicit none
778  type(kim_collections_type), intent(in) :: collections
779  integer(c_int), intent(in), value :: index
780  type(c_ptr), intent(out) :: item_name
781  end function get_item_name_by_collection_and_type
782  end interface
783  type(kim_collections_handle_type), intent(in) :: collections_handle
784  integer(c_int), intent(in) :: index
785  character(len=*, kind=c_char), intent(out) :: item_name
786  integer(c_int), intent(out) :: ierr
787  type(kim_collections_type), pointer :: collections
788 
789  type(c_ptr) pitem_name
790 
791  call c_f_pointer(collections_handle%p, collections)
792  ierr = get_item_name_by_collection_and_type(collections, index - 1, &
793  pitem_name)
794  call kim_convert_c_char_ptr_to_string(pitem_name, item_name)
796 
804  recursive subroutine &
806  collections_handle, collection, item_type, item_name, file_name, ierr)
807  use kim_interoperable_types_module, only: kim_collections_type
808  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
809  use kim_collection_module, only: kim_collection_type
810  use kim_collection_item_type_module, only: kim_collection_item_type_type
811  implicit none
812  interface
813  integer(c_int) recursive function &
814  get_item_library_file_name_by_coll_and_type( &
815  collections, collection, item_type, item_name, file_name) &
816  bind(c, &
817  name="KIM_Collections_GetItemLibraryFileNameByCollectionAndType")
818  use, intrinsic :: iso_c_binding
819  use kim_interoperable_types_module, only: kim_collections_type
820  use kim_collection_module, only: kim_collection_type
822  kim_collection_item_type_type
823  implicit none
824  type(kim_collections_type), intent(in) :: collections
825  type(kim_collection_type), intent(in), value :: collection
826  type(kim_collection_item_type_type), intent(in), value :: item_type
827  character(c_char), intent(in) :: item_name(*)
828  type(c_ptr), intent(out) :: file_name
829  end function get_item_library_file_name_by_coll_and_type
830  end interface
831  type(kim_collections_handle_type), intent(in) :: collections_handle
832  type(kim_collection_type), intent(in) :: collection
833  type(kim_collection_item_type_type), intent(in) :: item_type
834  character(len=*, kind=c_char), intent(in) :: item_name
835  character(len=*, kind=c_char), intent(out) :: file_name
836  integer(c_int), intent(out) :: ierr
837  type(kim_collections_type), pointer :: collections
838 
839  type(c_ptr) pfile_name
840 
841  call c_f_pointer(collections_handle%p, collections)
842  ierr = get_item_library_file_name_by_coll_and_type( &
843  collections, &
844  collection, &
845  item_type, &
846  trim(item_name)//c_null_char, &
847  pfile_name)
848  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
850 
858  recursive subroutine &
860  collections_handle, collection, item_type, item_name, extent, ierr)
861  use kim_interoperable_types_module, only: kim_collections_type
862  use kim_collection_module, only: kim_collection_type
863  use kim_collection_item_type_module, only: kim_collection_item_type_type
864  implicit none
865  interface
866  integer(c_int) recursive function &
867  cache_list_of_item_metadata_files_by_coll_and_type( &
868  collections, collection, item_type, item_name, extent) &
869  bind(c, &
870  name= &
871  "KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType")
872  use, intrinsic :: iso_c_binding
873  use kim_interoperable_types_module, only: kim_collections_type
874  use kim_collection_module, only: kim_collection_type
876  kim_collection_item_type_type
877  implicit none
878  type(kim_collections_type), intent(in) :: collections
879  type(kim_collection_type), intent(in), value :: collection
880  type(kim_collection_item_type_type), intent(in), value :: item_type
881  character(c_char), intent(in) :: item_name(*)
882  integer(c_int), intent(out) :: extent
883  end function cache_list_of_item_metadata_files_by_coll_and_type
884  end interface
885  type(kim_collections_handle_type), intent(in) :: collections_handle
886  type(kim_collection_type), intent(in) :: collection
887  type(kim_collection_item_type_type), intent(in) :: item_type
888  character(len=*, kind=c_char), intent(in) :: item_name
889  integer(c_int), intent(out) :: extent
890  integer(c_int), intent(out) :: ierr
891  type(kim_collections_type), pointer :: collections
892 
893  call c_f_pointer(collections_handle%p, collections)
894  ierr = cache_list_of_item_metadata_files_by_coll_and_type( &
895  collections, &
896  collection, &
897  item_type, &
898  trim(item_name)//c_null_char, &
899  extent)
901 
908  recursive subroutine &
910  collections_handle, index, file_length, available_as_string, ierr)
911  use kim_interoperable_types_module, only: kim_collections_type
912  implicit none
913  interface
914  integer(c_int) recursive function &
915  get_item_metadata_file_by_coll_and_type( &
916  collections, index, &
917  file_name, &
918  file_length, &
919  file_raw_data, &
920  available_as_string, &
921  file_string) &
922  bind(c, &
923  name= &
924  "KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran")
925  use, intrinsic :: iso_c_binding
926  use kim_interoperable_types_module, only: kim_collections_type
927  implicit none
928  type(kim_collections_type), intent(in) :: collections
929  integer(c_int), intent(in), value :: index
930  type(c_ptr), intent(out) :: file_name
931  integer(c_long), intent(out) :: file_length
932  type(c_ptr), intent(out) :: file_raw_data
933  integer(c_int), intent(out) :: available_as_string
934  type(c_ptr), intent(out) :: file_string
935  end function get_item_metadata_file_by_coll_and_type
936  end interface
937  type(kim_collections_handle_type), intent(in) :: collections_handle
938  integer(c_int), intent(in), value :: index
939  integer(c_long), intent(out) :: file_length
940  integer(c_int), intent(out) :: available_as_string
941  integer(c_int), intent(out) :: ierr
942  type(kim_collections_type), pointer :: collections
943 
944  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
945 
946  call c_f_pointer(collections_handle%p, collections)
947  ierr = get_item_metadata_file_by_coll_and_type(collections, &
948  index - 1, &
949  pfile_name, &
950  file_length, &
951  pfile_raw_data, &
952  available_as_string, &
953  pfile_string)
955 
962  recursive subroutine &
964  collections_handle, index, file_name, file_raw_data, file_string, ierr)
965  use kim_interoperable_types_module, only: kim_collections_type
966  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
967  implicit none
968  interface
969  integer(c_int) recursive function &
970  get_item_metadata_file_by_coll_and_type(collections, &
971  index, &
972  file_name, &
973  file_length, &
974  file_raw_data, &
975  available_as_string, &
976  file_string) &
977  bind(c, &
978  name= &
979  "KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran")
980  use, intrinsic :: iso_c_binding
981  use kim_interoperable_types_module, only: kim_collections_type
982  implicit none
983  type(kim_collections_type), intent(in) :: collections
984  integer(c_int), intent(in), value :: index
985  type(c_ptr), intent(out) :: file_name
986  integer(c_long), intent(out) :: file_length
987  type(c_ptr), intent(out) :: file_raw_data
988  integer(c_int), intent(out) :: available_as_string
989  type(c_ptr), intent(out) :: file_string
990  end function get_item_metadata_file_by_coll_and_type
991  end interface
992  type(kim_collections_handle_type), intent(in) :: collections_handle
993  integer(c_int), intent(in) :: index
994  character(len=*, kind=c_char), intent(out) :: file_name
995  integer(c_signed_char), intent(out) :: file_raw_data(:)
996  character(len=*, kind=c_char), intent(out) :: file_string
997  integer(c_int), intent(out) :: ierr
998  type(kim_collections_type), pointer :: collections
999 
1000  integer(c_long) file_length
1001  integer(c_int) available_as_string
1002  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
1003  integer(c_signed_char), pointer :: file_raw_data_fpointer(:)
1004 
1005  call c_f_pointer(collections_handle%p, collections)
1006  ierr = get_item_metadata_file_by_coll_and_type(collections, &
1007  index - 1, &
1008  pfile_name, &
1009  file_length, &
1010  pfile_raw_data, &
1011  available_as_string, &
1012  pfile_string)
1013  if (ierr == 0) then
1014  if (size(file_raw_data) < file_length) then
1015  ierr = 1
1016  return
1017  end if
1018  if (available_as_string == 1) then
1019  if (len(file_string) < file_length) then
1020  ierr = 1
1021  return
1022  end if
1023  end if
1024 
1025  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
1026  if (c_associated(pfile_raw_data)) then
1027  call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length])
1028  else
1029  nullify (file_raw_data_fpointer)
1030  end if
1031  file_raw_data = file_raw_data_fpointer(1:file_length)
1032 
1033  if (available_as_string == 1) then
1034  call kim_convert_c_char_ptr_to_string(pfile_string, file_string)
1035  end if
1036  end if
1038 
1045  recursive subroutine kim_collections_get_project_name_and_sem_ver( &
1046  collections_handle, project_name, sem_ver)
1047  use kim_interoperable_types_module, only: kim_collections_type
1048  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
1049  implicit none
1050  interface
1051  recursive subroutine get_project_name_and_sem_ver(collections, &
1052  project_name, sem_ver) &
1053  bind(c, name="KIM_Collections_GetProjectNameAndSemVer")
1054  use, intrinsic :: iso_c_binding
1055  use kim_interoperable_types_module, only: kim_collections_type
1056  implicit none
1057  type(kim_collections_type), intent(in) :: collections
1058  type(c_ptr), intent(out) :: project_name
1059  type(c_ptr), intent(out) :: sem_ver
1060  end subroutine get_project_name_and_sem_ver
1061  end interface
1062  type(kim_collections_handle_type), intent(in) :: collections_handle
1063  character(len=*, kind=c_char), intent(out) :: project_name
1064  character(len=*, kind=c_char), intent(out) :: sem_ver
1065  type(kim_collections_type), pointer :: collections
1066 
1067  type(c_ptr) pproject_name, psem_ver
1068 
1069  call c_f_pointer(collections_handle%p, collections)
1070  call get_project_name_and_sem_ver(collections, pproject_name, psem_ver)
1071  call kim_convert_c_char_ptr_to_string(pproject_name, project_name)
1072  call kim_convert_c_char_ptr_to_string(psem_ver, sem_ver)
1074 
1081  recursive subroutine kim_collections_get_environment_variable_name( &
1082  collections_handle, item_type, name, ierr)
1083  use kim_interoperable_types_module, only: kim_collections_type
1084  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
1085  use kim_collection_item_type_module, only: kim_collection_item_type_type
1086  implicit none
1087  interface
1088  integer(c_int) recursive function get_environment_variable_name( &
1089  collections, item_type, name) &
1090  bind(c, name="KIM_Collections_GetEnvironmentVariableName")
1091  use, intrinsic :: iso_c_binding
1092  use kim_interoperable_types_module, only: kim_collections_type
1093  use kim_collection_item_type_module, only: &
1094  kim_collection_item_type_type
1095  implicit none
1096  type(kim_collections_type), intent(in) :: collections
1097  type(kim_collection_item_type_type), intent(in), value :: item_type
1098  type(c_ptr), intent(out) :: name
1099  end function get_environment_variable_name
1100  end interface
1101  type(kim_collections_handle_type), intent(in) :: collections_handle
1102  type(kim_collection_item_type_type), intent(in) :: item_type
1103  character(len=*, kind=c_char), intent(out) :: name
1104  integer(c_int), intent(out) :: ierr
1105  type(kim_collections_type), pointer :: collections
1106 
1107  type(c_ptr) pname
1108 
1109  call c_f_pointer(collections_handle%p, collections)
1110  ierr = get_environment_variable_name(collections, item_type, pname)
1111  call kim_convert_c_char_ptr_to_string(pname, name)
1113 
1120  recursive subroutine &
1122  collections_handle, name, value)
1123  use kim_interoperable_types_module, only: kim_collections_type
1124  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
1125  implicit none
1126  interface
1127  recursive subroutine get_configuration_file_environment_variable( &
1128  collections, name, value) &
1129  bind(c, name="KIM_Collections_GetConfigurationFileEnvironmentVariable")
1130  use, intrinsic :: iso_c_binding
1131  use kim_interoperable_types_module, only: kim_collections_type
1132  implicit none
1133  type(kim_collections_type), intent(in) :: collections
1134  type(c_ptr), intent(out) :: name
1135  type(c_ptr), intent(out) :: value
1136  end subroutine get_configuration_file_environment_variable
1137  end interface
1138  type(kim_collections_handle_type), intent(in) :: collections_handle
1139  character(len=*, kind=c_char), intent(out) :: name
1140  character(len=*, kind=c_char), intent(out) :: value
1141  type(kim_collections_type), pointer :: collections
1142 
1143  type(c_ptr) pname, pvalue
1144 
1145  call c_f_pointer(collections_handle%p, collections)
1146  call get_configuration_file_environment_variable(collections, pname, pvalue)
1147  call kim_convert_c_char_ptr_to_string(pname, name)
1148  call kim_convert_c_char_ptr_to_string(pvalue, value)
1150 
1157  recursive subroutine kim_collections_get_configuration_file_name( &
1158  collections_handle, file_name)
1159  use kim_interoperable_types_module, only: kim_collections_type
1160  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
1161  implicit none
1162  interface
1163  recursive subroutine get_configuration_file_name(collections, file_name) &
1164  bind(c, name="KIM_Collections_GetConfigurationFileName")
1165  use, intrinsic :: iso_c_binding
1166  use kim_interoperable_types_module, only: kim_collections_type
1167  implicit none
1168  type(kim_collections_type), intent(in) :: collections
1169  type(c_ptr), intent(out) :: file_name
1170  end subroutine get_configuration_file_name
1171  end interface
1172  type(kim_collections_handle_type), intent(in) :: collections_handle
1173  character(len=*, kind=c_char), intent(out) :: file_name
1174  type(kim_collections_type), pointer :: collections
1175 
1176  type(c_ptr) pfile_name
1177 
1178  call c_f_pointer(collections_handle%p, collections)
1179  call get_configuration_file_name(collections, pfile_name)
1180  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
1182 
1189  recursive subroutine kim_collections_cache_list_of_directory_names( &
1190  collections_handle, collection, item_type, extent, ierr)
1191  use kim_interoperable_types_module, only: kim_collections_type
1192  use kim_collection_module, only: kim_collection_type
1193  use kim_collection_item_type_module, only: kim_collection_item_type_type
1194  implicit none
1195  interface
1196  integer(c_int) recursive function cache_list_of_directory_names( &
1197  collections, collection, item_type, extent) &
1198  bind(c, name="KIM_Collections_CacheListOfDirectoryNames")
1199  use, intrinsic :: iso_c_binding
1200  use kim_interoperable_types_module, only: kim_collections_type
1201  use kim_collection_module, only: kim_collection_type
1202  use kim_collection_item_type_module, only: &
1203  kim_collection_item_type_type
1204  implicit none
1205  type(kim_collections_type), intent(in) :: collections
1206  type(kim_collection_type), intent(in), value :: collection
1207  type(kim_collection_item_type_type), intent(in), value :: item_type
1208  integer(c_int), intent(out) :: extent
1209  end function cache_list_of_directory_names
1210  end interface
1211  type(kim_collections_handle_type), intent(in) :: collections_handle
1212  type(kim_collection_type), intent(in) :: collection
1213  type(kim_collection_item_type_type), intent(in) :: item_type
1214  integer(c_int), intent(out) :: extent
1215  integer(c_int), intent(out) :: ierr
1216  type(kim_collections_type), pointer :: collections
1217 
1218  call c_f_pointer(collections_handle%p, collections)
1219  ierr = cache_list_of_directory_names(collections, collection, item_type, &
1220  extent)
1222 
1228  recursive subroutine kim_collections_get_directory_name(collections_handle, &
1229  index, &
1230  directory_name, &
1231  ierr)
1232  use kim_interoperable_types_module, only: kim_collections_type
1233  use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string
1234  implicit none
1235  interface
1236  integer(c_int) recursive function get_directory_name(collections, index, &
1237  directory_name) &
1238  bind(c, name="KIM_Collections_GetDirectoryName")
1239  use, intrinsic :: iso_c_binding
1240  use kim_interoperable_types_module, only: kim_collections_type
1241  implicit none
1242  type(kim_collections_type), intent(in) :: collections
1243  integer(c_int), intent(in), value :: index
1244  type(c_ptr), intent(out) :: directory_name
1245  end function get_directory_name
1246  end interface
1247  type(kim_collections_handle_type), intent(in) :: collections_handle
1248  integer(c_int), intent(in) :: index
1249  character(len=*, kind=c_char), intent(out) :: directory_name
1250  integer(c_int), intent(out) :: ierr
1251  type(kim_collections_type), pointer :: collections
1252 
1253  type(c_ptr) pdirectory_name
1254 
1255  call c_f_pointer(collections_handle%p, collections)
1256  ierr = get_directory_name(collections, index - 1, pdirectory_name)
1257  call kim_convert_c_char_ptr_to_string(pdirectory_name, directory_name)
1258  end subroutine kim_collections_get_directory_name
1259 
1265  recursive subroutine kim_collections_set_log_id(collections_handle, log_id)
1266  use kim_interoperable_types_module, only: kim_collections_type
1267  implicit none
1268  interface
1269  recursive subroutine set_log_id(collections, log_id) &
1270  bind(c, name="KIM_Collections_SetLogID")
1271  use, intrinsic :: iso_c_binding
1272  use kim_interoperable_types_module, only: kim_collections_type
1273  implicit none
1274  type(kim_collections_type), intent(in) :: collections
1275  character(c_char), intent(in) :: log_id(*)
1276  end subroutine set_log_id
1277  end interface
1278  type(kim_collections_handle_type), intent(in) :: collections_handle
1279  character(len=*, kind=c_char), intent(in) :: log_id
1280  type(kim_collections_type), pointer :: collections
1281 
1282  call c_f_pointer(collections_handle%p, collections)
1283  call set_log_id(collections, trim(log_id)//c_null_char)
1284  end subroutine kim_collections_set_log_id
1285 
1291  recursive subroutine kim_collections_push_log_verbosity(collections_handle, &
1292  log_verbosity)
1293  use kim_log_verbosity_module, only: kim_log_verbosity_type
1294  use kim_interoperable_types_module, only: kim_collections_type
1295  implicit none
1296  interface
1297  recursive subroutine push_log_verbosity(collections, log_verbosity) &
1298  bind(c, name="KIM_Collections_PushLogVerbosity")
1299  use, intrinsic :: iso_c_binding
1300  use kim_log_verbosity_module, only: kim_log_verbosity_type
1301  use kim_interoperable_types_module, only: kim_collections_type
1302  implicit none
1303  type(kim_collections_type), intent(in) :: collections
1304  type(kim_log_verbosity_type), intent(in), value :: log_verbosity
1305  end subroutine push_log_verbosity
1306  end interface
1307  type(kim_collections_handle_type), intent(in) :: collections_handle
1308  type(kim_log_verbosity_type), intent(in) :: log_verbosity
1309  type(kim_collections_type), pointer :: collections
1310 
1311  call c_f_pointer(collections_handle%p, collections)
1312  call push_log_verbosity(collections, log_verbosity)
1313  end subroutine kim_collections_push_log_verbosity
1314 
1320  recursive subroutine kim_collections_pop_log_verbosity(collections_handle)
1321  use kim_log_verbosity_module, only: kim_log_verbosity_type
1322  use kim_interoperable_types_module, only: kim_collections_type
1323  implicit none
1324  interface
1325  recursive subroutine pop_log_verbosity(collections) &
1326  bind(c, name="KIM_Collections_PopLogVerbosity")
1327  use, intrinsic :: iso_c_binding
1328  use kim_log_verbosity_module, only: kim_log_verbosity_type
1329  use kim_interoperable_types_module, only: kim_collections_type
1330  implicit none
1331  type(kim_collections_type), intent(in) :: collections
1332  end subroutine pop_log_verbosity
1333  end interface
1334  type(kim_collections_handle_type), intent(in) :: collections_handle
1335  type(kim_collections_type), pointer :: collections
1336 
1337  call c_f_pointer(collections_handle%p, collections)
1338  call pop_log_verbosity(collections)
1339  end subroutine kim_collections_pop_log_verbosity
1340 end module kim_collections_module
recursive subroutine kim_collections_get_item_metadata_file_length_by_coll_and_type(collections_handle, index, file_length, available_as_string, ierr)
Get the name and content of one of an item&#39;s metadata files.
recursive subroutine kim_collections_get_item_library_file_name_by_coll_and_type(collections_handle, collection, item_type, item_name, file_name, ierr)
Get the item&#39;s library file name.
An Extensible Enumeration for the CollectionItemType&#39;s supported by the KIM API.
recursive subroutine kim_collections_set_log_id(collections_handle, log_id)
Set the identity of the Log object associated with the Collections object.
recursive subroutine, public kim_collections_create(collections_handle, ierr)
Create a new KIM API Collections object.
Provides the interface to the KIM API Collections and is meant to be used by simulators.
recursive subroutine kim_collections_get_item_name_by_type(collections_handle, index, item_name, ierr)
Get the name of an item from the cached list.
recursive subroutine kim_collections_cache_list_of_item_names_by_collection_and_type(collections_handle, collection, item_type, extent, ierr)
Cache a list of all item names of a specific type in a specific collection.
recursive subroutine kim_collections_get_environment_variable_name(collections_handle, item_type, name, ierr)
Get the names of environment variables that store configuration settings for the KIM::COLLECTION::env...
recursive subroutine kim_collections_push_log_verbosity(collections_handle, log_verbosity)
Push a new LogVerbosity onto the Collections object&#39;s Log object verbosity stack. ...
recursive subroutine kim_collections_get_directory_name(collections_handle, index, directory_name, ierr)
Get the name of a directory from the cached list.
recursive subroutine kim_collections_get_item_metadata_file_length(collections_handle, index, file_length, available_as_string, ierr)
Get item metadata file length and determine if the file is available as a string. ...
type(kim_collections_handle_type), save, public, protected kim_collections_null_handle
NULL handle for use in comparisons.
recursive subroutine kim_collections_get_item_metadata_file_values_by_coll_and_type(collections_handle, index, file_name, file_raw_data, file_string, ierr)
Get the item&#39;s metadata file values.
recursive subroutine kim_collections_get_item_name_by_collection_and_type(collections_handle, index, item_name, ierr)
Get the name of an item from the cached list.
recursive subroutine kim_colls_cache_list_of_item_metadata_files_by_coll_and_type(collections_handle, collection, item_type, item_name, extent, ierr)
Cache a list of an item&#39;s metadata files.
recursive subroutine kim_collections_get_configuration_file_environment_variable(collections_handle, name, value)
Get the name and value of the environment variable that stores the name of the KIM API user configura...
recursive subroutine kim_collections_cache_list_of_item_names_by_type(collections_handle, item_type, extent, ierr)
Cache a list of all item names of a specific type in the KIM API collections.
recursive subroutine kim_collections_cache_list_of_directory_names(collections_handle, collection, item_type, extent, ierr)
Cache a list of directory names where a specific KIM API collection stores library files for a specif...
recursive subroutine kim_collections_get_configuration_file_name(collections_handle, file_name)
Get the absolute file and path name of the KIM API user configuration file.
recursive subroutine kim_collections_get_item_library_file_name_and_collection(collections_handle, item_type, item_name, file_name, collection, ierr)
Get the item&#39;s library file name and its KIM::Collection.
recursive subroutine kim_collections_cache_list_of_item_metadata_files(collections_handle, item_type, item_name, extent, ierr)
Cache a list of an item&#39;s metadata files.
recursive subroutine kim_collections_get_project_name_and_sem_ver(collections_handle, project_name, sem_ver)
Get the KIM API project name and full Semantic Version string.
An Extensible Enumeration for the Collection&#39;s supported by the KIM API.
recursive subroutine kim_collections_get_item_metadata_file_values(collections_handle, index, file_name, file_raw_data, file_string, ierr)
Get the item&#39;s metadata file values.
An Extensible Enumeration for the LogVerbosity&#39;s supported by the KIM API.
recursive subroutine kim_collections_pop_log_verbosity(collections_handle)
Pop a LogVerbosity from the Collections object&#39;s Log object verbosity stack.
recursive subroutine, public kim_collections_destroy(collections_handle)
Destroy a previously Collections::Create&#39;d object.