kim-api  2.1.2+v2.1.2.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 ! CDDL HEADER START
3 !
4 ! The contents of this file are subject to the terms of the Common Development
5 ! and Distribution License Version 1.0 (the "License").
6 !
7 ! You can obtain a copy of the license at
8 ! http://www.opensource.org/licenses/CDDL-1.0. See the License for the
9 ! specific language governing permissions and limitations under the License.
10 !
11 ! When distributing Covered Code, include this CDDL HEADER in each file and
12 ! include the License file in a prominent location with the name LICENSE.CDDL.
13 ! If applicable, add the following below this CDDL HEADER, with the fields
14 ! enclosed by brackets "[]" replaced with your own identifying information:
15 !
16 ! Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
17 !
18 ! CDDL HEADER END
19 !
20 
21 !
22 ! Copyright (c) 2016--2019, Regents of the University of Minnesota.
23 ! All rights reserved.
24 !
25 ! Contributors:
26 ! Ryan S. Elliott
27 !
28 
29 !
30 ! Release: This file is part of the kim-api-2.1.2 package.
31 !
32 
33 
40  use, intrinsic :: iso_c_binding
41  implicit none
42  private
43 
44  public &
45  ! Derived types
46  kim_collections_handle_type, &
47 
48  ! Constants
50 
51  ! Routines
52  operator (.eq.), &
53  operator (.ne.), &
56  kim_get_item_type, &
57  kim_get_item_library_file_name_and_collection, &
58  kim_cache_list_of_item_metadata_files, &
59  kim_get_item_metadata_file_length, &
60  kim_get_item_metadata_file_values, &
61  kim_cache_list_of_item_names_by_type, &
62  kim_get_item_name_by_type, &
63  kim_cache_list_of_item_names_by_collection_and_type, &
64  kim_get_item_name_by_collection_and_type, &
65  kim_get_item_library_file_name_by_collection_and_type, &
66  kim_cache_list_of_item_metadata_files_by_collection_and_type, &
67  kim_get_item_metadata_file_length_by_collection_and_type, &
68  kim_get_item_metadata_file_values_by_collection_and_type, &
69  kim_get_project_name_and_sem_ver, &
70  kim_get_environment_variable_name, &
71  kim_get_configuration_file_environment_variable, &
72  kim_get_configuration_file_name, &
73  kim_cache_list_of_directory_names, &
74  kim_get_directory_name, &
75  kim_set_log_id, &
76  kim_push_log_verbosity, &
77  kim_pop_log_verbosity
78 
79 
85  type, bind(c) :: kim_collections_handle_type
86  type(c_ptr) :: p = c_null_ptr
87  end type kim_collections_handle_type
88 
92  type(kim_collections_handle_type), protected, save &
94 
98  interface operator (.eq.)
99  module procedure kim_collections_handle_equal
100  end interface operator (.eq.)
101 
105  interface operator (.ne.)
106  module procedure kim_collections_handle_not_equal
107  end interface operator (.ne.)
108 
114  interface kim_get_item_type
115  module procedure kim_collections_get_item_type
116  end interface kim_get_item_type
117 
124  interface kim_get_item_library_file_name_and_collection
126  end interface kim_get_item_library_file_name_and_collection
127 
134  interface kim_cache_list_of_item_metadata_files
136  end interface kim_cache_list_of_item_metadata_files
137 
145  interface kim_get_item_metadata_file_length
147  end interface kim_get_item_metadata_file_length
148 
155  interface kim_get_item_metadata_file_values
157  end interface kim_get_item_metadata_file_values
158 
165  interface kim_cache_list_of_item_names_by_type
167  end interface kim_cache_list_of_item_names_by_type
168 
174  interface kim_get_item_name_by_type
176  end interface kim_get_item_name_by_type
177 
184  interface kim_cache_list_of_item_names_by_collection_and_type
185  module procedure &
187  end interface kim_cache_list_of_item_names_by_collection_and_type
188 
195  interface kim_get_item_name_by_collection_and_type
197  end interface kim_get_item_name_by_collection_and_type
198 
206  interface kim_get_item_library_file_name_by_collection_and_type
207  module procedure &
209  end interface kim_get_item_library_file_name_by_collection_and_type
210 
218  interface kim_cache_list_of_item_metadata_files_by_collection_and_type
219  module procedure &
221  end interface kim_cache_list_of_item_metadata_files_by_collection_and_type
222 
230  interface kim_get_item_metadata_file_length_by_collection_and_type
231  module procedure &
233  end interface kim_get_item_metadata_file_length_by_collection_and_type
234 
241  interface kim_get_item_metadata_file_values_by_collection_and_type
242  module procedure &
244  end interface kim_get_item_metadata_file_values_by_collection_and_type
245 
252  interface kim_get_project_name_and_sem_ver
254  end interface kim_get_project_name_and_sem_ver
255 
262  interface kim_get_environment_variable_name
264  end interface kim_get_environment_variable_name
265 
272  interface kim_get_configuration_file_environment_variable
274  end interface kim_get_configuration_file_environment_variable
275 
282  interface kim_get_configuration_file_name
284  end interface kim_get_configuration_file_name
285 
292  interface kim_cache_list_of_directory_names
294  end interface kim_cache_list_of_directory_names
295 
301  interface kim_get_directory_name
302  module procedure kim_collections_get_directory_name
303  end interface kim_get_directory_name
304 
310  interface kim_set_log_id
311  module procedure kim_collections_set_log_id
312  end interface kim_set_log_id
313 
319  interface kim_push_log_verbosity
320  module procedure kim_collections_push_log_verbosity
321  end interface kim_push_log_verbosity
322 
328  interface kim_pop_log_verbosity
329  module procedure kim_collections_pop_log_verbosity
330  end interface kim_pop_log_verbosity
331 
332 contains
336  logical recursive function kim_collections_handle_equal(lhs, rhs)
337  implicit none
338  type(kim_collections_handle_type), intent(in) :: lhs
339  type(kim_collections_handle_type), intent(in) :: rhs
340 
341  if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then
342  kim_collections_handle_equal = .true.
343  else
344  kim_collections_handle_equal = c_associated(lhs%p, rhs%p)
345  end if
346  end function kim_collections_handle_equal
347 
351  logical recursive function kim_collections_handle_not_equal(lhs, rhs)
352  implicit none
353  type(kim_collections_handle_type), intent(in) :: lhs
354  type(kim_collections_handle_type), intent(in) :: rhs
355 
356  kim_collections_handle_not_equal = .not. (lhs .eq. rhs)
357  end function kim_collections_handle_not_equal
358 
364  recursive subroutine kim_collections_create(collections_handle, ierr)
365  implicit none
366  interface
367  integer(c_int) recursive function create(collections) &
368  bind(c, name="KIM_Collections_Create")
369  use, intrinsic :: iso_c_binding
370  implicit none
371  type(c_ptr), intent(out) :: collections
372  end function create
373  end interface
374  type(kim_collections_handle_type), intent(out) :: collections_handle
375  integer(c_int), intent(out) :: ierr
376 
377  type(c_ptr) :: pcollections
378 
379  ierr = create(pcollections)
380  collections_handle%p = pcollections
381  end subroutine kim_collections_create
382 
388  recursive subroutine kim_collections_destroy(collections_handle)
389  implicit none
390  interface
391  recursive subroutine destroy(collections) &
392  bind(c, name="KIM_Collections_Destroy")
393  use, intrinsic :: iso_c_binding
394  implicit none
395  type(c_ptr), intent(inout) :: collections
396  end subroutine destroy
397  end interface
398  type(kim_collections_handle_type), intent(inout) :: collections_handle
399 
400  type(c_ptr) :: pcollections
401  pcollections = collections_handle%p
402  call destroy(pcollections)
403  collections_handle%p = c_null_ptr
404  end subroutine kim_collections_destroy
405 
411  recursive subroutine kim_collections_get_item_type(collections_handle, &
412  item_name, item_type, ierr)
413  use kim_interoperable_types_module, only : kim_collections_type
414  use kim_collection_item_type_module, only : kim_collection_item_type_type
415  implicit none
416  interface
417  integer(c_int) recursive function get_item_type(collections, &
418  item_name, item_type) bind(c, name="KIM_Collections_GetItemType")
419  use, intrinsic :: iso_c_binding
420  use kim_interoperable_types_module, only : kim_collections_type
421  use kim_collection_item_type_module, only : &
422  kim_collection_item_type_type
423  implicit none
424  type(kim_collections_type), intent(in) :: collections
425  character(c_char), intent(in) :: item_name(*)
426  type(kim_collection_item_type_type), intent(out) :: item_type
427  end function get_item_type
428  end interface
429  type(kim_collections_handle_type), intent(in) :: collections_handle
430  character(len=*, kind=c_char), intent(in) :: item_name
431  type(kim_collection_item_type_type), intent(out) :: item_type
432  integer(c_int), intent(out) :: ierr
433  type(kim_collections_type), pointer :: collections
434 
435  call c_f_pointer(collections_handle%p, collections)
436  ierr = get_item_type(collections, trim(item_name)//c_null_char, item_type)
437  end subroutine kim_collections_get_item_type
438 
445  recursive subroutine &
447  collections_handle, item_type, item_name, file_name, collection, ierr)
448  use kim_interoperable_types_module, only : kim_collections_type
449  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
450  use kim_collection_module, only : kim_collection_type
451  use kim_collection_item_type_module, only : kim_collection_item_type_type
452  implicit none
453  interface
454  integer(c_int) recursive function &
455  get_item_library_file_name_and_collection(collections, item_type, &
456  item_name, file_name, collection) &
457  bind(c, name="KIM_Collections_GetItemLibraryFileNameAndCollection")
458  use, intrinsic :: iso_c_binding
459  use kim_interoperable_types_module, only : kim_collections_type
460  use kim_collection_module, only : kim_collection_type
461  use kim_collection_item_type_module, only : &
462  kim_collection_item_type_type
463  implicit none
464  type(kim_collections_type), intent(in) :: collections
465  type(kim_collection_item_type_type), intent(in), value :: item_type
466  character(c_char), intent(in) :: item_name(*)
467  type(c_ptr), intent(out) :: file_name
468  type(kim_collection_type), intent(out) :: collection
469  end function get_item_library_file_name_and_collection
470  end interface
471  type(kim_collections_handle_type), intent(in) :: collections_handle
472  type(kim_collection_item_type_type), intent(in) :: item_type
473  character(len=*, kind=c_char), intent(in) :: item_name
474  character(len=*, kind=c_char), intent(out) :: file_name
475  type(kim_collection_type), intent(out) :: collection
476  integer(c_int), intent(out) :: ierr
477  type(kim_collections_type), pointer :: collections
478 
479  type(c_ptr) :: pfile_name
480 
481  call c_f_pointer(collections_handle%p, collections)
482  ierr = get_item_library_file_name_and_collection(collections, item_type, &
483  trim(item_name)//c_null_char, pfile_name, collection)
484  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
486 
494  collections_handle, item_type, item_name, extent, ierr)
495  use kim_interoperable_types_module, only : kim_collections_type
496  use kim_collection_item_type_module, only : kim_collection_item_type_type
497  implicit none
498  interface
499  integer(c_int) recursive function cache_list_of_item_metadata_files( &
500  collections, item_type, item_name, extent) &
501  bind(c, name="KIM_Collections_CacheListOfItemMetadataFiles")
502  use, intrinsic :: iso_c_binding
503  use kim_interoperable_types_module, only : kim_collections_type
504  use kim_collection_item_type_module, only : &
505  kim_collection_item_type_type
506  implicit none
507  type(kim_collections_type), intent(in) :: collections
508  type(kim_collection_item_type_type), intent(in), value :: item_type
509  character(c_char), intent(in) :: item_name(*)
510  integer(c_int), intent(out) :: extent
511  end function cache_list_of_item_metadata_files
512  end interface
513  type(kim_collections_handle_type), intent(in) :: collections_handle
514  type(kim_collection_item_type_type), intent(in) :: item_type
515  character(len=*, kind=c_char), intent(in) :: item_name
516  integer(c_int), intent(out) :: extent
517  integer(c_int), intent(out) :: ierr
518  type(kim_collections_type), pointer :: collections
519 
520  call c_f_pointer(collections_handle%p, collections)
521  ierr = cache_list_of_item_metadata_files(collections, item_type, &
522  trim(item_name)//c_null_char, extent)
524 
532  recursive subroutine kim_collections_get_item_metadata_file_length( &
533  collections_handle, index, file_length, available_as_string, ierr)
534  use kim_interoperable_types_module, only : kim_collections_type
535  implicit none
536  interface
537  integer(c_int) recursive function get_item_metadata_file_length( &
538  collections, index, file_name, file_length, file_raw_data, &
539  available_as_string, file_string) &
540  bind(c, name="KIM_Collections_GetItemMetadataFile_fortran")
541  use, intrinsic :: iso_c_binding
542  use kim_interoperable_types_module, only : kim_collections_type
543  implicit none
544  type(kim_collections_type), intent(in) :: collections
545  integer(c_int), intent(in), value :: index
546  type(c_ptr), intent(out) :: file_name
547  integer(c_long), intent(out) :: file_length
548  type(c_ptr), intent(out) :: file_raw_data
549  integer(c_int), intent(out) :: available_as_string
550  type(c_ptr), intent(out) :: file_string
551  end function get_item_metadata_file_length
552  end interface
553  type(kim_collections_handle_type), intent(in) :: collections_handle
554  integer(c_int), intent(in) :: index
555  integer(c_long), intent(out) :: file_length
556  integer(c_int), intent(out) :: available_as_string
557  integer(c_int), intent(out) :: ierr
558  type(kim_collections_type), pointer :: collections
559 
560  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
561 
562  call c_f_pointer(collections_handle%p, collections)
563  ierr = get_item_metadata_file_length(collections, index-1, pfile_name, &
564  file_length, pfile_raw_data, available_as_string, pfile_string)
566 
573  recursive subroutine kim_collections_get_item_metadata_file_values( &
574  collections_handle, index, file_name, file_raw_data, file_string, ierr)
575  use kim_interoperable_types_module, only : kim_collections_type
576  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
577  implicit none
578  interface
579  integer(c_int) recursive function get_item_metadata_file_values( &
580  collections, index, file_name, file_length, file_raw_data, &
581  available_as_string, file_string) &
582  bind(c, name="KIM_Collections_GetItemMetadataFile_fortran")
583  use, intrinsic :: iso_c_binding
584  use kim_interoperable_types_module, only : kim_collections_type
585  implicit none
586  type(kim_collections_type), intent(in) :: collections
587  integer(c_int), intent(in), value :: index
588  type(c_ptr), intent(out) :: file_name
589  integer(c_long), intent(out) :: file_length
590  type(c_ptr), intent(out) :: file_raw_data
591  integer(c_int), intent(out) :: available_as_string
592  type(c_ptr), intent(out) :: file_string
593  end function get_item_metadata_file_values
594  end interface
595  type(kim_collections_handle_type), intent(in) :: collections_handle
596  integer(c_int), intent(in) :: index
597  character(len=*, kind=c_char), intent(out) :: file_name
598  integer(c_signed_char), intent(out) :: file_raw_data(:)
599  character(len=*, kind=c_char), intent(out) :: file_string
600  integer(c_int), intent(out) :: ierr
601  type(kim_collections_type), pointer :: collections
602 
603  integer(c_long) file_length
604  integer(c_int) available_as_string
605  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
606  integer(c_signed_char), pointer :: file_raw_data_fpointer(:)
607 
608  call c_f_pointer(collections_handle%p, collections)
609  ierr = get_item_metadata_file_values(collections, index-1, pfile_name, &
610  file_length, pfile_raw_data, available_as_string, pfile_string)
611  if (ierr .eq. 0) then
612  if (size(file_raw_data) < file_length) then
613  ierr = 1
614  return
615  end if
616  if (available_as_string .eq. 1) then
617  if (len(file_string) < file_length) then
618  ierr = 1
619  return
620  end if
621  end if
622 
623  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
624  if (c_associated(pfile_raw_data)) then
625  call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length])
626  else
627  nullify(file_raw_data_fpointer)
628  end if
629  file_raw_data = file_raw_data_fpointer(1:file_length)
630 
631  if (available_as_string .eq. 1) then
632  call kim_convert_c_char_ptr_to_string(pfile_string, file_string)
633  end if
634  end if
636 
644  collections_handle, item_type, extent, ierr)
645  use kim_interoperable_types_module, only : kim_collections_type
646  use kim_collection_item_type_module, only : kim_collection_item_type_type
647  implicit none
648  interface
649  integer(c_int) recursive function cache_list_of_item_names_by_type( &
650  collections, item_type, extent) &
651  bind(c, name="KIM_Collections_CacheListOfItemNamesByType")
652  use, intrinsic :: iso_c_binding
653  use kim_interoperable_types_module, only : kim_collections_type
654  use kim_collection_item_type_module, only : &
655  kim_collection_item_type_type
656  implicit none
657  type(kim_collections_type), intent(in) :: collections
658  type(kim_collection_item_type_type), intent(in), value :: item_type
659  integer(c_int), intent(out) :: extent
660  end function cache_list_of_item_names_by_type
661  end interface
662  type(kim_collections_handle_type), intent(in) :: collections_handle
663  type(kim_collection_item_type_type), intent(in) :: item_type
664  integer(c_int), intent(out) :: extent
665  integer(c_int), intent(out) :: ierr
666  type(kim_collections_type), pointer :: collections
667 
668  call c_f_pointer(collections_handle%p, collections)
669  ierr = cache_list_of_item_names_by_type(collections, item_type, extent)
671 
677  recursive subroutine kim_collections_get_item_name_by_type( &
678  collections_handle, index, item_name, ierr)
679  use kim_interoperable_types_module, only : kim_collections_type
680  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
681  implicit none
682  interface
683  integer(c_int) recursive function get_item_name_by_type(collections, &
684  index, item_name) bind(c, name="KIM_Collections_GetItemNameByType")
685  use, intrinsic :: iso_c_binding
686  use kim_interoperable_types_module, only : kim_collections_type
687  implicit none
688  type(kim_collections_type), intent(in) :: collections
689  integer(c_int), intent(in), value :: index
690  type(c_ptr), intent(out) :: item_name
691  end function get_item_name_by_type
692  end interface
693  type(kim_collections_handle_type), intent(in) :: collections_handle
694  integer(c_int), intent(in) :: index
695  character(len=*, kind=c_char), intent(out) :: item_name
696  integer(c_int), intent(out) :: ierr
697  type(kim_collections_type), pointer :: collections
698 
699  type(c_ptr) pitem_name
700 
701  call c_f_pointer(collections_handle%p, collections)
702  ierr = get_item_name_by_type(collections, index-1, pitem_name)
703  call kim_convert_c_char_ptr_to_string(pitem_name, item_name)
705 
712  recursive subroutine &
714  collections_handle, collection, item_type, extent, ierr)
715  use kim_interoperable_types_module, only : kim_collections_type
716  use kim_collection_module, only : kim_collection_type
717  use kim_collection_item_type_module, only : kim_collection_item_type_type
718  implicit none
719  interface
720  integer(c_int) recursive function &
721  cache_list_of_item_names_by_collection_and_type(collections, &
722  collection, item_type, extent) &
723  bind(c, name="KIM_Collections_CacheListOfItemNamesByCollectionAndType")
724  use, intrinsic :: iso_c_binding
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 : &
728  kim_collection_item_type_type
729  implicit none
730  type(kim_collections_type), intent(in) :: collections
731  type(kim_collection_type), intent(in), value :: collection
732  type(kim_collection_item_type_type), intent(in), value :: item_type
733  integer(c_int), intent(out) :: extent
734  end function cache_list_of_item_names_by_collection_and_type
735  end interface
736  type(kim_collections_handle_type), intent(in) :: collections_handle
737  type(kim_collection_type), intent(in) :: collection
738  type(kim_collection_item_type_type), intent(in) :: item_type
739  integer(c_int), intent(out) :: extent
740  integer(c_int), intent(out) :: ierr
741  type(kim_collections_type), pointer :: collections
742 
743  call c_f_pointer(collections_handle%p, collections)
744  ierr = cache_list_of_item_names_by_collection_and_type(collections, &
745  collection, item_type, extent)
747 
755  collections_handle, index, item_name, ierr)
756  use kim_interoperable_types_module, only : kim_collections_type
757  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
758  implicit none
759  interface
760  integer(c_int) recursive function get_item_name_by_collection_and_type( &
761  collections, index, item_name) &
762  bind(c, name="KIM_Collections_GetItemNameByCollectionAndType")
763  use, intrinsic :: iso_c_binding
764  use kim_interoperable_types_module, only : kim_collections_type
765  implicit none
766  type(kim_collections_type), intent(in) :: collections
767  integer(c_int), intent(in), value :: index
768  type(c_ptr), intent(out) :: item_name
769  end function get_item_name_by_collection_and_type
770  end interface
771  type(kim_collections_handle_type), intent(in) :: collections_handle
772  integer(c_int), intent(in) :: index
773  character(len=*, kind=c_char), intent(out) :: item_name
774  integer(c_int), intent(out) :: ierr
775  type(kim_collections_type), pointer :: collections
776 
777  type(c_ptr) pitem_name
778 
779  call c_f_pointer(collections_handle%p, collections)
780  ierr = get_item_name_by_collection_and_type(collections, index-1, &
781  pitem_name)
782  call kim_convert_c_char_ptr_to_string(pitem_name, item_name)
784 
792  recursive subroutine &
794  collections_handle, collection, item_type, item_name, file_name, ierr)
795  use kim_interoperable_types_module, only : kim_collections_type
796  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
797  use kim_collection_module, only : kim_collection_type
798  use kim_collection_item_type_module, only : kim_collection_item_type_type
799  implicit none
800  interface
801  integer(c_int) recursive function &
802  get_item_library_file_name_by_coll_and_type(collections, collection, &
803  item_type, item_name, file_name) bind(c, &
804  name="KIM_Collections_GetItemLibraryFileNameByCollectionAndType")
805  use, intrinsic :: iso_c_binding
806  use kim_interoperable_types_module, only : kim_collections_type
807  use kim_collection_module, only : kim_collection_type
808  use kim_collection_item_type_module, only : &
809  kim_collection_item_type_type
810  implicit none
811  type(kim_collections_type), intent(in) :: collections
812  type(kim_collection_type), intent(in), value :: collection
813  type(kim_collection_item_type_type), intent(in), value :: item_type
814  character(c_char), intent(in) :: item_name(*)
815  type(c_ptr), intent(out) :: file_name
816  end function get_item_library_file_name_by_coll_and_type
817  end interface
818  type(kim_collections_handle_type), intent(in) :: collections_handle
819  type(kim_collection_type), intent(in) :: collection
820  type(kim_collection_item_type_type), intent(in) :: item_type
821  character(len=*, kind=c_char), intent(in) :: item_name
822  character(len=*, kind=c_char), intent(out) :: file_name
823  integer(c_int), intent(out) :: ierr
824  type(kim_collections_type), pointer :: collections
825 
826  type(c_ptr) pfile_name
827 
828  call c_f_pointer(collections_handle%p, collections)
829  ierr = get_item_library_file_name_by_coll_and_type(collections, &
830  collection, item_type, trim(item_name)//c_null_char, pfile_name)
831  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
833 
841  recursive subroutine &
843  collections_handle, collection, item_type, item_name, extent, ierr)
844  use kim_interoperable_types_module, only : kim_collections_type
845  use kim_collection_module, only : kim_collection_type
846  use kim_collection_item_type_module, only : kim_collection_item_type_type
847  implicit none
848  interface
849  integer(c_int) recursive function &
850  cache_list_of_item_metadata_files_by_coll_and_type(collections, &
851  collection, item_type, item_name, extent) bind(c, &
852  name="KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType")
853  use, intrinsic :: iso_c_binding
854  use kim_interoperable_types_module, only : kim_collections_type
855  use kim_collection_module, only : kim_collection_type
856  use kim_collection_item_type_module, only : &
857  kim_collection_item_type_type
858  implicit none
859  type(kim_collections_type), intent(in) :: collections
860  type(kim_collection_type), intent(in), value :: collection
861  type(kim_collection_item_type_type), intent(in), value :: item_type
862  character(c_char), intent(in) :: item_name(*)
863  integer(c_int), intent(out) :: extent
864  end function cache_list_of_item_metadata_files_by_coll_and_type
865  end interface
866  type(kim_collections_handle_type), intent(in) :: collections_handle
867  type(kim_collection_type), intent(in) :: collection
868  type(kim_collection_item_type_type), intent(in) :: item_type
869  character(len=*, kind=c_char), intent(in) :: item_name
870  integer(c_int), intent(out) :: extent
871  integer(c_int), intent(out) :: ierr
872  type(kim_collections_type), pointer :: collections
873 
874  call c_f_pointer(collections_handle%p, collections)
875  ierr = cache_list_of_item_metadata_files_by_coll_and_type(collections, &
876  collection, item_type, trim(item_name)//c_null_char, extent)
878 
885  recursive subroutine &
887  collections_handle, index, file_length, available_as_string, ierr)
888  use kim_interoperable_types_module, only : kim_collections_type
889  implicit none
890  interface
891  integer(c_int) recursive function &
892  get_item_metadata_file_length_by_coll_and_type(collections, index, &
893  file_name, file_length, file_raw_data, available_as_string, &
894  file_string) &
895  bind(c, &
896  name="KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran")
897  use, intrinsic :: iso_c_binding
898  use kim_interoperable_types_module, only : kim_collections_type
899  implicit none
900  type(kim_collections_type), intent(in) :: collections
901  integer(c_int), intent(in), value :: index
902  type(c_ptr), intent(out) :: file_name
903  integer(c_long), intent(out) :: file_length
904  type(c_ptr), intent(out) :: file_raw_data
905  integer(c_int), intent(out) :: available_as_string
906  type(c_ptr), intent(out) :: file_string
907  end function get_item_metadata_file_length_by_coll_and_type
908  end interface
909  type(kim_collections_handle_type), intent(in) :: collections_handle
910  integer(c_int), intent(in), value :: index
911  integer(c_long), intent(out) :: file_length
912  integer(c_int), intent(out) :: available_as_string
913  integer(c_int), intent(out) :: ierr
914  type(kim_collections_type), pointer :: collections
915 
916  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
917 
918  call c_f_pointer(collections_handle%p, collections)
919  ierr = get_item_metadata_file_length_by_coll_and_type(collections, &
920  index-1, pfile_name, file_length, pfile_raw_data, available_as_string, &
921  pfile_string)
923 
930  recursive subroutine &
932  collections_handle, index, file_name, file_raw_data, file_string, ierr)
933  use kim_interoperable_types_module, only : kim_collections_type
934  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
935  implicit none
936  interface
937  integer(c_int) recursive function &
938  get_item_metadata_file_values_by_coll_and_type(collections, index, &
939  file_name, file_length, file_raw_data, available_as_string, &
940  file_string) &
941  bind(c, &
942  name="KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran")
943  use, intrinsic :: iso_c_binding
944  use kim_interoperable_types_module, only : kim_collections_type
945  implicit none
946  type(kim_collections_type), intent(in) :: collections
947  integer(c_int), intent(in), value :: index
948  type(c_ptr), intent(out) :: file_name
949  integer(c_long), intent(out) :: file_length
950  type(c_ptr), intent(out) :: file_raw_data
951  integer(c_int), intent(out) :: available_as_string
952  type(c_ptr), intent(out) :: file_string
953  end function get_item_metadata_file_values_by_coll_and_type
954  end interface
955  type(kim_collections_handle_type), intent(in) :: collections_handle
956  integer(c_int), intent(in) :: index
957  character(len=*, kind=c_char), intent(out) :: file_name
958  integer(c_signed_char), intent(out) :: file_raw_data(:)
959  character(len=*, kind=c_char), intent(out) :: file_string
960  integer(c_int), intent(out) :: ierr
961  type(kim_collections_type), pointer :: collections
962 
963  integer(c_long) file_length
964  integer(c_int) available_as_string
965  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
966  integer(c_signed_char), pointer :: file_raw_data_fpointer(:)
967 
968  call c_f_pointer(collections_handle%p, collections)
969  ierr = get_item_metadata_file_values_by_coll_and_type(collections, &
970  index-1, pfile_name, file_length, pfile_raw_data, available_as_string, &
971  pfile_string)
972  if (ierr .eq. 0) then
973  if (size(file_raw_data) < file_length) then
974  ierr = 1
975  return
976  end if
977  if (available_as_string .eq. 1) then
978  if (len(file_string) < file_length) then
979  ierr = 1
980  return
981  end if
982  end if
983 
984  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
985  if (c_associated(pfile_raw_data)) then
986  call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length])
987  else
988  nullify(file_raw_data_fpointer)
989  end if
990  file_raw_data = file_raw_data_fpointer(1:file_length)
991 
992  if (available_as_string .eq. 1) then
993  call kim_convert_c_char_ptr_to_string(pfile_string, file_string)
994  end if
995  end if
997 
1004  recursive subroutine kim_collections_get_project_name_and_sem_ver( &
1005  collections_handle, project_name, sem_ver)
1006  use kim_interoperable_types_module, only : kim_collections_type
1007  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1008  implicit none
1009  interface
1010  recursive subroutine get_project_name_and_sem_ver(collections, &
1011  project_name, sem_ver) &
1012  bind(c, name="KIM_Collections_GetProjectNameAndSemVer")
1013  use, intrinsic :: iso_c_binding
1014  use kim_interoperable_types_module, only : kim_collections_type
1015  implicit none
1016  type(kim_collections_type), intent(in) :: collections
1017  type(c_ptr), intent(out) :: project_name
1018  type(c_ptr), intent(out) :: sem_ver
1019  end subroutine get_project_name_and_sem_ver
1020  end interface
1021  type(kim_collections_handle_type), intent(in) :: collections_handle
1022  character(len=*, kind=c_char), intent(out) :: project_name
1023  character(len=*, kind=c_char), intent(out) :: sem_ver
1024  type(kim_collections_type), pointer :: collections
1025 
1026  type(c_ptr) pproject_name, psem_ver
1027 
1028  call c_f_pointer(collections_handle%p, collections)
1029  call get_project_name_and_sem_ver(collections, pproject_name, psem_ver)
1030  call kim_convert_c_char_ptr_to_string(pproject_name, project_name)
1031  call kim_convert_c_char_ptr_to_string(psem_ver, sem_ver)
1033 
1040  recursive subroutine kim_collections_get_environment_variable_name( &
1041  collections_handle, item_type, name, ierr)
1042  use kim_interoperable_types_module, only : kim_collections_type
1043  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1044  use kim_collection_item_type_module, only : kim_collection_item_type_type
1045  implicit none
1046  interface
1047  integer(c_int) recursive function get_environment_variable_name( &
1048  collections, item_type, name) &
1049  bind(c, name="KIM_Collections_GetEnvironmentVariableName")
1050  use, intrinsic :: iso_c_binding
1051  use kim_interoperable_types_module, only : kim_collections_type
1052  use kim_collection_item_type_module, only : &
1053  kim_collection_item_type_type
1054  implicit none
1055  type(kim_collections_type), intent(in) :: collections
1056  type(kim_collection_item_type_type), intent(in), value :: item_type
1057  type(c_ptr), intent(out) :: name
1058  end function get_environment_variable_name
1059  end interface
1060  type(kim_collections_handle_type), intent(in) :: collections_handle
1061  type(kim_collection_item_type_type), intent(in) :: item_type
1062  character(len=*, kind=c_char), intent(out) :: name
1063  integer(c_int), intent(out) :: ierr
1064  type(kim_collections_type), pointer :: collections
1065 
1066  type(c_ptr) pname
1067 
1068  call c_f_pointer(collections_handle%p, collections)
1069  ierr = get_environment_variable_name(collections, item_type, pname)
1070  call kim_convert_c_char_ptr_to_string(pname, name)
1072 
1079  recursive subroutine &
1081  collections_handle, name, value)
1082  use kim_interoperable_types_module, only : kim_collections_type
1083  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1084  implicit none
1085  interface
1086  recursive subroutine get_configuration_file_environment_variable( &
1087  collections, name, value) &
1088  bind(c, name="KIM_Collections_GetConfigurationFileEnvironmentVariable")
1089  use, intrinsic :: iso_c_binding
1090  use kim_interoperable_types_module, only : kim_collections_type
1091  implicit none
1092  type(kim_collections_type), intent(in) :: collections
1093  type(c_ptr), intent(out) :: name
1094  type(c_ptr), intent(out) :: value
1095  end subroutine get_configuration_file_environment_variable
1096  end interface
1097  type(kim_collections_handle_type), intent(in) :: collections_handle
1098  character(len=*, kind=c_char), intent(out) :: name
1099  character(len=*, kind=c_char), intent(out) :: value
1100  type(kim_collections_type), pointer :: collections
1101 
1102  type(c_ptr) pname, pvalue
1103 
1104  call c_f_pointer(collections_handle%p, collections)
1105  call get_configuration_file_environment_variable(collections, pname, pvalue)
1106  call kim_convert_c_char_ptr_to_string(pname, name)
1107  call kim_convert_c_char_ptr_to_string(pvalue, value)
1109 
1116  recursive subroutine kim_collections_get_configuration_file_name( &
1117  collections_handle, file_name)
1118  use kim_interoperable_types_module, only : kim_collections_type
1119  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1120  implicit none
1121  interface
1122  recursive subroutine get_configuration_file_name(collections, file_name) &
1123  bind(c, name="KIM_Collections_GetConfigurationFileName")
1124  use, intrinsic :: iso_c_binding
1125  use kim_interoperable_types_module, only : kim_collections_type
1126  implicit none
1127  type(kim_collections_type), intent(in) :: collections
1128  type(c_ptr), intent(out) :: file_name
1129  end subroutine get_configuration_file_name
1130  end interface
1131  type(kim_collections_handle_type), intent(in) :: collections_handle
1132  character(len=*, kind=c_char), intent(out) :: file_name
1133  type(kim_collections_type), pointer :: collections
1134 
1135  type(c_ptr) pfile_name
1136 
1137  call c_f_pointer(collections_handle%p, collections)
1138  call get_configuration_file_name(collections, pfile_name)
1139  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
1141 
1148  recursive subroutine kim_collections_cache_list_of_directory_names( &
1149  collections_handle, collection, item_type, extent, ierr)
1150  use kim_interoperable_types_module, only : kim_collections_type
1151  use kim_collection_module, only : kim_collection_type
1152  use kim_collection_item_type_module, only : kim_collection_item_type_type
1153  implicit none
1154  interface
1155  integer(c_int) recursive function cache_list_of_directory_names( &
1156  collections, collection, item_type, extent) &
1157  bind(c, name="KIM_Collections_CacheListOfDirectoryNames")
1158  use, intrinsic :: iso_c_binding
1159  use kim_interoperable_types_module, only : kim_collections_type
1160  use kim_collection_module, only : kim_collection_type
1161  use kim_collection_item_type_module, only : &
1162  kim_collection_item_type_type
1163  implicit none
1164  type(kim_collections_type), intent(in) :: collections
1165  type(kim_collection_type), intent(in), value :: collection
1166  type(kim_collection_item_type_type), intent(in), value :: item_type
1167  integer(c_int), intent(out) :: extent
1168  end function cache_list_of_directory_names
1169  end interface
1170  type(kim_collections_handle_type), intent(in) :: collections_handle
1171  type(kim_collection_type), intent(in) :: collection
1172  type(kim_collection_item_type_type), intent(in) :: item_type
1173  integer(c_int), intent(out) :: extent
1174  integer(c_int), intent(out) :: ierr
1175  type(kim_collections_type), pointer :: collections
1176 
1177  call c_f_pointer(collections_handle%p, collections)
1178  ierr = cache_list_of_directory_names(collections, collection, item_type, &
1179  extent)
1181 
1187  recursive subroutine kim_collections_get_directory_name(collections_handle, &
1188  index, directory_name, ierr)
1189  use kim_interoperable_types_module, only : kim_collections_type
1190  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1191  implicit none
1192  interface
1193  integer(c_int) recursive function get_directory_name(collections, index, &
1194  directory_name) &
1195  bind(c, name="KIM_Collections_GetDirectoryName")
1196  use, intrinsic :: iso_c_binding
1197  use kim_interoperable_types_module, only : kim_collections_type
1198  implicit none
1199  type(kim_collections_type), intent(in) :: collections
1200  integer(c_int), intent(in), value :: index
1201  type(c_ptr), intent(out) :: directory_name
1202  end function get_directory_name
1203  end interface
1204  type(kim_collections_handle_type), intent(in) :: collections_handle
1205  integer(c_int), intent(in) :: index
1206  character(len=*, kind=c_char), intent(out) :: directory_name
1207  integer(c_int), intent(out) :: ierr
1208  type(kim_collections_type), pointer :: collections
1209 
1210  type(c_ptr) pdirectory_name
1211 
1212  call c_f_pointer(collections_handle%p, collections)
1213  ierr = get_directory_name(collections, index-1, pdirectory_name)
1214  call kim_convert_c_char_ptr_to_string(pdirectory_name, directory_name)
1215  end subroutine kim_collections_get_directory_name
1216 
1222  recursive subroutine kim_collections_set_log_id(collections_handle, log_id)
1223  use kim_interoperable_types_module, only : kim_collections_type
1224  implicit none
1225  interface
1226  recursive subroutine set_log_id(collections, log_id) &
1227  bind(c, name="KIM_Collections_SetLogID")
1228  use, intrinsic :: iso_c_binding
1229  use kim_interoperable_types_module, only : kim_collections_type
1230  implicit none
1231  type(kim_collections_type), intent(in) :: collections
1232  character(c_char), intent(in) :: log_id(*)
1233  end subroutine set_log_id
1234  end interface
1235  type(kim_collections_handle_type), intent(in) :: collections_handle
1236  character(len=*, kind=c_char), intent(in) :: log_id
1237  type(kim_collections_type), pointer :: collections
1238 
1239  call c_f_pointer(collections_handle%p, collections)
1240  call set_log_id(collections, trim(log_id)//c_null_char)
1241  end subroutine kim_collections_set_log_id
1242 
1248  recursive subroutine kim_collections_push_log_verbosity(collections_handle, &
1249  log_verbosity)
1250  use kim_log_verbosity_module, only : kim_log_verbosity_type
1251  use kim_interoperable_types_module, only : kim_collections_type
1252  implicit none
1253  interface
1254  recursive subroutine push_log_verbosity(collections, log_verbosity) &
1255  bind(c, name="KIM_Collections_PushLogVerbosity")
1256  use, intrinsic :: iso_c_binding
1257  use kim_log_verbosity_module, only : kim_log_verbosity_type
1258  use kim_interoperable_types_module, only : kim_collections_type
1259  implicit none
1260  type(kim_collections_type), intent(in) :: collections
1261  type(kim_log_verbosity_type), intent(in), value :: log_verbosity
1262  end subroutine push_log_verbosity
1263  end interface
1264  type(kim_collections_handle_type), intent(in) :: collections_handle
1265  type(kim_log_verbosity_type), intent(in) :: log_verbosity
1266  type(kim_collections_type), pointer :: collections
1267 
1268  call c_f_pointer(collections_handle%p, collections)
1269  call push_log_verbosity(collections, log_verbosity)
1270  end subroutine kim_collections_push_log_verbosity
1271 
1277  recursive subroutine kim_collections_pop_log_verbosity(collections_handle)
1278  use kim_log_verbosity_module, only : kim_log_verbosity_type
1279  use kim_interoperable_types_module, only : kim_collections_type
1280  implicit none
1281  interface
1282  recursive subroutine pop_log_verbosity(collections) &
1283  bind(c, name="KIM_Collections_PopLogVerbosity")
1284  use, intrinsic :: iso_c_binding
1285  use kim_log_verbosity_module, only : kim_log_verbosity_type
1286  use kim_interoperable_types_module, only : kim_collections_type
1287  implicit none
1288  type(kim_collections_type), intent(in) :: collections
1289  end subroutine pop_log_verbosity
1290  end interface
1291  type(kim_collections_handle_type), intent(in) :: collections_handle
1292  type(kim_collections_type), pointer :: collections
1293 
1294  call c_f_pointer(collections_handle%p, collections)
1295  call pop_log_verbosity(collections)
1296  end subroutine kim_collections_pop_log_verbosity
1297 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.