kim-api  2.1.0+v2.1.0.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.0 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_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, item_type) &
418  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  type(kim_collection_item_type_type), intent(out) :: item_type
426  end function get_item_type
427  end interface
428  type(kim_collections_handle_type), intent(in) :: collections_handle
429  type(kim_collection_item_type_type), intent(out) :: item_type
430  integer(c_int), intent(out) :: ierr
431  type(kim_collections_type), pointer :: collections
432 
433  call c_f_pointer(collections_handle%p, collections)
434  ierr = get_item_type(collections, item_type)
435  end subroutine kim_collections_get_item_type
436 
443  recursive subroutine &
445  collections_handle, item_name, file_name, collection, ierr)
446  use kim_interoperable_types_module, only : kim_collections_type
447  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
448  use kim_collection_module, only : kim_collection_type
449  implicit none
450  interface
451  integer(c_int) recursive function &
452  get_item_library_file_name_and_collection(collections, item_name, &
453  file_name, collection) &
454  bind(c, name="KIM_Collections_GetItemLibraryFileNameAndCollection")
455  use, intrinsic :: iso_c_binding
456  use kim_interoperable_types_module, only : kim_collections_type
457  use kim_collection_module, only : kim_collection_type
458  implicit none
459  type(kim_collections_type), intent(in) :: collections
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  character(len=*, kind=c_char), intent(in) :: item_name
467  character(len=*, kind=c_char), intent(out) :: file_name
468  type(kim_collection_type), intent(out) :: collection
469  integer(c_int), intent(out) :: ierr
470  type(kim_collections_type), pointer :: collections
471 
472  type(c_ptr) :: pfile_name
473 
474  call c_f_pointer(collections_handle%p, collections)
475  ierr = get_item_library_file_name_and_collection(collections, &
476  trim(item_name)//c_null_char, pfile_name, collection)
477  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
479 
487  collections_handle, item_type, item_name, extent, ierr)
488  use kim_interoperable_types_module, only : kim_collections_type
489  use kim_collection_item_type_module, only : kim_collection_item_type_type
490  implicit none
491  interface
492  integer(c_int) recursive function cache_list_of_item_metadata_files( &
493  collections, item_type, item_name, extent) &
494  bind(c, name="KIM_Collections_CacheListOfItemMetadataFiles")
495  use, intrinsic :: iso_c_binding
496  use kim_interoperable_types_module, only : kim_collections_type
497  use kim_collection_item_type_module, only : &
498  kim_collection_item_type_type
499  implicit none
500  type(kim_collections_type), intent(in) :: collections
501  type(kim_collection_item_type_type), intent(in), value :: item_type
502  character(c_char), intent(in) :: item_name(*)
503  integer(c_int), intent(out) :: extent
504  end function cache_list_of_item_metadata_files
505  end interface
506  type(kim_collections_handle_type), intent(in) :: collections_handle
507  type(kim_collection_item_type_type), intent(in) :: item_type
508  character(len=*, kind=c_char), intent(in) :: item_name
509  integer(c_int), intent(out) :: extent
510  integer(c_int), intent(out) :: ierr
511  type(kim_collections_type), pointer :: collections
512 
513  call c_f_pointer(collections_handle%p, collections)
514  ierr = cache_list_of_item_metadata_files(collections, item_type, &
515  trim(item_name)//c_null_char, extent)
517 
525  recursive subroutine kim_collections_get_item_metadata_file_length( &
526  collections_handle, index, file_length, available_as_string, ierr)
527  use kim_interoperable_types_module, only : kim_collections_type
528  implicit none
529  interface
530  integer(c_int) recursive function get_item_metadata_file_length( &
531  collections, index, file_name, file_length, file_raw_data, &
532  available_as_string, file_string) &
533  bind(c, name="KIM_Collections_GetItemMetadataFile")
534  use, intrinsic :: iso_c_binding
535  use kim_interoperable_types_module, only : kim_collections_type
536  implicit none
537  type(kim_collections_type), intent(in) :: collections
538  integer(c_int), intent(in), value :: index
539  type(c_ptr), intent(out) :: file_name
540  integer(c_int), intent(out) :: file_length
541  type(c_ptr), intent(out) :: file_raw_data
542  integer(c_int), intent(out) :: available_as_string
543  type(c_ptr), intent(out) :: file_string
544  end function get_item_metadata_file_length
545  end interface
546  type(kim_collections_handle_type), intent(in) :: collections_handle
547  integer(c_int), intent(in) :: index
548  integer(c_long), intent(out) :: file_length
549  integer(c_int), intent(out) :: available_as_string
550  integer(c_int), intent(out) :: ierr
551  type(kim_collections_type), pointer :: collections
552 
553  integer(c_int) dfile_length
554  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
555 
556  call c_f_pointer(collections_handle%p, collections)
557  ierr = get_item_metadata_file_length(collections, index-1, pfile_name, &
558  dfile_length, pfile_raw_data, available_as_string, pfile_string)
559  if (ierr .eq. 0) then
560  if (dfile_length < 0) then
561  file_length = 2*(2147483648_c_long) + int(dfile_length, c_long)
562  else
563  file_length = int(dfile_length, c_long)
564  end if
565  end if
567 
574  recursive subroutine kim_collections_get_item_metadata_file_values( &
575  collections_handle, index, file_name, file_raw_data, file_string, ierr)
576  use kim_interoperable_types_module, only : kim_collections_type
577  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
578  implicit none
579  interface
580  integer(c_int) recursive function get_item_metadata_file_values( &
581  collections, index, file_name, file_length, file_raw_data, &
582  available_as_string, file_string) &
583  bind(c, name="KIM_Collections_GetItemMetadataFile")
584  use, intrinsic :: iso_c_binding
585  use kim_interoperable_types_module, only : kim_collections_type
586  implicit none
587  type(kim_collections_type), intent(in) :: collections
588  integer(c_int), intent(in), value :: index
589  type(c_ptr), intent(out) :: file_name
590  integer(c_int), intent(out) :: file_length
591  type(c_ptr), intent(out) :: file_raw_data
592  integer(c_int), intent(out) :: available_as_string
593  type(c_ptr), intent(out) :: file_string
594  end function get_item_metadata_file_values
595  end interface
596  type(kim_collections_handle_type), intent(in) :: collections_handle
597  integer(c_int), intent(in) :: index
598  character(len=*, kind=c_char), intent(out) :: file_name
599  integer(c_signed_char), intent(out) :: file_raw_data(:)
600  character(len=*, kind=c_char), intent(out) :: file_string
601  integer(c_int), intent(out) :: ierr
602  type(kim_collections_type), pointer :: collections
603 
604  integer(c_int) dfile_length
605  integer(c_long) file_length
606  integer(c_int) available_as_string
607  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
608  integer(c_signed_char), pointer :: file_raw_data_fpointer(:)
609 
610  call c_f_pointer(collections_handle%p, collections)
611  ierr = get_item_metadata_file_values(collections, index-1, pfile_name, &
612  dfile_length, pfile_raw_data, available_as_string, pfile_string)
613  if (ierr .eq. 0) then
614  if (dfile_length < 0) then
615  file_length = 2*(2147483648_c_long) + int(dfile_length, c_long)
616  else
617  file_length = int(dfile_length, c_long)
618  end if
619  if (size(file_raw_data) < file_length) then
620  ierr = 1
621  return
622  end if
623  if (available_as_string .eq. 1) then
624  if (len(file_string) < file_length) then
625  ierr = 1
626  return
627  end if
628  end if
629 
630  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
631  if (c_associated(pfile_raw_data)) then
632  call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length])
633  else
634  nullify(file_raw_data_fpointer)
635  end if
636  file_raw_data = file_raw_data_fpointer(1:file_length)
637 
638  if (available_as_string .eq. 1) then
639  call kim_convert_c_char_ptr_to_string(pfile_string, file_string)
640  end if
641  end if
643 
651  collections_handle, item_type, extent, ierr)
652  use kim_interoperable_types_module, only : kim_collections_type
653  use kim_collection_item_type_module, only : kim_collection_item_type_type
654  implicit none
655  interface
656  integer(c_int) recursive function cache_list_of_item_names_by_type( &
657  collections, item_type, extent) &
658  bind(c, name="KIM_Collections_CacheListOfItemNamesByType")
659  use, intrinsic :: iso_c_binding
660  use kim_interoperable_types_module, only : kim_collections_type
661  use kim_collection_item_type_module, only : &
662  kim_collection_item_type_type
663  implicit none
664  type(kim_collections_type), intent(in) :: collections
665  type(kim_collection_item_type_type), intent(in), value :: item_type
666  integer(c_int), intent(out) :: extent
667  end function cache_list_of_item_names_by_type
668  end interface
669  type(kim_collections_handle_type), intent(in) :: collections_handle
670  type(kim_collection_item_type_type), intent(in) :: item_type
671  integer(c_int), intent(out) :: extent
672  integer(c_int), intent(out) :: ierr
673  type(kim_collections_type), pointer :: collections
674 
675  call c_f_pointer(collections_handle%p, collections)
676  ierr = cache_list_of_item_names_by_type(collections, item_type, extent)
678 
684  recursive subroutine kim_collections_get_item_name_by_type( &
685  collections_handle, index, item_name, ierr)
686  use kim_interoperable_types_module, only : kim_collections_type
687  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
688  implicit none
689  interface
690  integer(c_int) recursive function get_item_name_by_type(collections, &
691  index, item_name) bind(c, name="KIM_Collections_GetItemNameByType")
692  use, intrinsic :: iso_c_binding
693  use kim_interoperable_types_module, only : kim_collections_type
694  implicit none
695  type(kim_collections_type), intent(in) :: collections
696  integer(c_int), intent(in), value :: index
697  type(c_ptr), intent(out) :: item_name
698  end function get_item_name_by_type
699  end interface
700  type(kim_collections_handle_type), intent(in) :: collections_handle
701  integer(c_int), intent(in) :: index
702  character(len=*, kind=c_char), intent(out) :: item_name
703  integer(c_int), intent(out) :: ierr
704  type(kim_collections_type), pointer :: collections
705 
706  type(c_ptr) pitem_name
707 
708  call c_f_pointer(collections_handle%p, collections)
709  ierr = get_item_name_by_type(collections, index-1, pitem_name)
710  call kim_convert_c_char_ptr_to_string(pitem_name, item_name)
712 
719  recursive subroutine &
721  collections_handle, collection, item_type, extent, ierr)
722  use kim_interoperable_types_module, only : kim_collections_type
723  use kim_collection_module, only : kim_collection_type
724  use kim_collection_item_type_module, only : kim_collection_item_type_type
725  implicit none
726  interface
727  integer(c_int) recursive function &
728  cache_list_of_item_names_by_collection_and_type(collections, &
729  collection, item_type, extent) &
730  bind(c, name="KIM_Collections_CacheListOfItemNamesByCollectionAndType")
731  use, intrinsic :: iso_c_binding
732  use kim_interoperable_types_module, only : kim_collections_type
733  use kim_collection_module, only : kim_collection_type
734  use kim_collection_item_type_module, only : &
735  kim_collection_item_type_type
736  implicit none
737  type(kim_collections_type), intent(in) :: collections
738  type(kim_collection_type), intent(in), value :: collection
739  type(kim_collection_item_type_type), intent(in), value :: item_type
740  integer(c_int), intent(out) :: extent
741  end function cache_list_of_item_names_by_collection_and_type
742  end interface
743  type(kim_collections_handle_type), intent(in) :: collections_handle
744  type(kim_collection_type), intent(in) :: collection
745  type(kim_collection_item_type_type), intent(in) :: item_type
746  integer(c_int), intent(out) :: extent
747  integer(c_int), intent(out) :: ierr
748  type(kim_collections_type), pointer :: collections
749 
750  call c_f_pointer(collections_handle%p, collections)
751  ierr = cache_list_of_item_names_by_collection_and_type(collections, &
752  collection, item_type, extent)
754 
762  collections_handle, index, item_name, ierr)
763  use kim_interoperable_types_module, only : kim_collections_type
764  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
765  implicit none
766  interface
767  integer(c_int) recursive function get_item_name_by_collection_and_type( &
768  collections, index, item_name) &
769  bind(c, name="KIM_Collections_GetItemNameByCollectionAndType")
770  use, intrinsic :: iso_c_binding
771  use kim_interoperable_types_module, only : kim_collections_type
772  implicit none
773  type(kim_collections_type), intent(in) :: collections
774  integer(c_int), intent(in), value :: index
775  type(c_ptr), intent(out) :: item_name
776  end function get_item_name_by_collection_and_type
777  end interface
778  type(kim_collections_handle_type), intent(in) :: collections_handle
779  integer(c_int), intent(in) :: index
780  character(len=*, kind=c_char), intent(out) :: item_name
781  integer(c_int), intent(out) :: ierr
782  type(kim_collections_type), pointer :: collections
783 
784  type(c_ptr) pitem_name
785 
786  call c_f_pointer(collections_handle%p, collections)
787  ierr = get_item_name_by_collection_and_type(collections, index-1, &
788  pitem_name)
789  call kim_convert_c_char_ptr_to_string(pitem_name, item_name)
791 
799  recursive subroutine &
801  collections_handle, collection, item_type, item_name, file_name, ierr)
802  use kim_interoperable_types_module, only : kim_collections_type
803  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
804  use kim_collection_module, only : kim_collection_type
805  use kim_collection_item_type_module, only : kim_collection_item_type_type
806  implicit none
807  interface
808  integer(c_int) recursive function &
809  get_item_library_file_name_by_coll_and_type(collections, collection, &
810  item_type, item_name, file_name) bind(c, &
811  name="KIM_Collections_GetItemLibraryFileNameByCollectionAndType")
812  use, intrinsic :: iso_c_binding
813  use kim_interoperable_types_module, only : kim_collections_type
814  use kim_collection_module, only : kim_collection_type
815  use kim_collection_item_type_module, only : &
816  kim_collection_item_type_type
817  implicit none
818  type(kim_collections_type), intent(in) :: collections
819  type(kim_collection_type), intent(in), value :: collection
820  type(kim_collection_item_type_type), intent(in), value :: item_type
821  character(c_char), intent(in) :: item_name(*)
822  type(c_ptr), intent(out) :: file_name
823  end function get_item_library_file_name_by_coll_and_type
824  end interface
825  type(kim_collections_handle_type), intent(in) :: collections_handle
826  type(kim_collection_type), intent(in) :: collection
827  type(kim_collection_item_type_type), intent(in) :: item_type
828  character(len=*, kind=c_char), intent(in) :: item_name
829  character(len=*, kind=c_char), intent(out) :: file_name
830  integer(c_int), intent(out) :: ierr
831  type(kim_collections_type), pointer :: collections
832 
833  type(c_ptr) pfile_name
834 
835  call c_f_pointer(collections_handle%p, collections)
836  ierr = get_item_library_file_name_by_coll_and_type(collections, &
837  collection, item_type, trim(item_name)//c_null_char, pfile_name)
838  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
840 
848  recursive subroutine &
850  collections_handle, collection, item_type, item_name, extent, ierr)
851  use kim_interoperable_types_module, only : kim_collections_type
852  use kim_collection_module, only : kim_collection_type
853  use kim_collection_item_type_module, only : kim_collection_item_type_type
854  implicit none
855  interface
856  integer(c_int) recursive function &
857  cache_list_of_item_metadata_files_by_coll_and_type(collections, &
858  collection, item_type, item_name, extent) bind(c, &
859  name="KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType")
860  use, intrinsic :: iso_c_binding
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 : &
864  kim_collection_item_type_type
865  implicit none
866  type(kim_collections_type), intent(in) :: collections
867  type(kim_collection_type), intent(in), value :: collection
868  type(kim_collection_item_type_type), intent(in), value :: item_type
869  character(c_char), intent(in) :: item_name(*)
870  integer(c_int), intent(out) :: extent
871  end function cache_list_of_item_metadata_files_by_coll_and_type
872  end interface
873  type(kim_collections_handle_type), intent(in) :: collections_handle
874  type(kim_collection_type), intent(in) :: collection
875  type(kim_collection_item_type_type), intent(in) :: item_type
876  character(len=*, kind=c_char), intent(in) :: item_name
877  integer(c_int), intent(out) :: extent
878  integer(c_int), intent(out) :: ierr
879  type(kim_collections_type), pointer :: collections
880 
881  call c_f_pointer(collections_handle%p, collections)
882  ierr = cache_list_of_item_metadata_files_by_coll_and_type(collections, &
883  collection, item_type, trim(item_name)//c_null_char, extent)
885 
892  recursive subroutine &
894  collections_handle, index, file_length, available_as_string, ierr)
895  use kim_interoperable_types_module, only : kim_collections_type
896  implicit none
897  interface
898  integer(c_int) recursive function &
899  get_item_metadata_file_length_by_coll_and_type(collections, index, &
900  file_name, file_length, file_raw_data, available_as_string, &
901  file_string) &
902  bind(c, name="KIM_Collections_GetItemMetadataFileByCollectionAndType")
903  use, intrinsic :: iso_c_binding
904  use kim_interoperable_types_module, only : kim_collections_type
905  implicit none
906  type(kim_collections_type), intent(in) :: collections
907  integer(c_int), intent(in), value :: index
908  type(c_ptr), intent(out) :: file_name
909  integer(c_int), intent(out) :: file_length
910  type(c_ptr), intent(out) :: file_raw_data
911  integer(c_int), intent(out) :: available_as_string
912  type(c_ptr), intent(out) :: file_string
913  end function get_item_metadata_file_length_by_coll_and_type
914  end interface
915  type(kim_collections_handle_type), intent(in) :: collections_handle
916  integer(c_int), intent(in), value :: index
917  integer(c_long), intent(out) :: file_length
918  integer(c_int), intent(out) :: available_as_string
919  integer(c_int), intent(out) :: ierr
920  type(kim_collections_type), pointer :: collections
921 
922  integer(c_int) dfile_length
923  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
924 
925  call c_f_pointer(collections_handle%p, collections)
926  ierr = get_item_metadata_file_length_by_coll_and_type(collections, &
927  index-1, pfile_name, dfile_length, pfile_raw_data, available_as_string, &
928  pfile_string)
929  if (ierr .eq. 0) then
930  if (dfile_length < 0) then
931  file_length = 2*(2147483648_c_long) + int(dfile_length, c_long)
932  else
933  file_length = int(dfile_length, c_long)
934  end if
935  end if
937 
944  recursive subroutine &
946  collections_handle, index, file_name, file_raw_data, file_string, ierr)
947  use kim_interoperable_types_module, only : kim_collections_type
948  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
949  implicit none
950  interface
951  integer(c_int) recursive function &
952  get_item_metadata_file_values_by_coll_and_type(collections, index, &
953  file_name, file_length, file_raw_data, available_as_string, &
954  file_string) &
955  bind(c, name="KIM_Collections_GetItemMetadataFileByCollectionAndType")
956  use, intrinsic :: iso_c_binding
957  use kim_interoperable_types_module, only : kim_collections_type
958  implicit none
959  type(kim_collections_type), intent(in) :: collections
960  integer(c_int), intent(in), value :: index
961  type(c_ptr), intent(out) :: file_name
962  integer(c_int), intent(out) :: file_length
963  type(c_ptr), intent(out) :: file_raw_data
964  integer(c_int), intent(out) :: available_as_string
965  type(c_ptr), intent(out) :: file_string
966  end function get_item_metadata_file_values_by_coll_and_type
967  end interface
968  type(kim_collections_handle_type), intent(in) :: collections_handle
969  integer(c_int), intent(in) :: index
970  character(len=*, kind=c_char), intent(out) :: file_name
971  integer(c_signed_char), intent(out) :: file_raw_data(:)
972  character(len=*, kind=c_char), intent(out) :: file_string
973  integer(c_int), intent(out) :: ierr
974  type(kim_collections_type), pointer :: collections
975 
976  integer(c_int) dfile_length
977  integer(c_long) file_length
978  integer(c_int) available_as_string
979  type(c_ptr) pfile_name, pfile_raw_data, pfile_string
980  integer(c_signed_char), pointer :: file_raw_data_fpointer(:)
981 
982  call c_f_pointer(collections_handle%p, collections)
983  ierr = get_item_metadata_file_values_by_coll_and_type(collections, &
984  index-1, pfile_name, dfile_length, pfile_raw_data, available_as_string, &
985  pfile_string)
986  if (ierr .eq. 0) then
987  if (dfile_length < 0) then
988  file_length = 2*(2147483648_c_long) + int(dfile_length, c_long)
989  else
990  file_length = int(dfile_length, c_long)
991  end if
992  if (size(file_raw_data) < file_length) then
993  ierr = 1
994  return
995  end if
996  if (available_as_string .eq. 1) then
997  if (len(file_string) < file_length) then
998  ierr = 1
999  return
1000  end if
1001  end if
1002 
1003  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
1004  if (c_associated(pfile_raw_data)) then
1005  call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length])
1006  else
1007  nullify(file_raw_data_fpointer)
1008  end if
1009  file_raw_data = file_raw_data_fpointer(1:file_length)
1010 
1011  if (available_as_string .eq. 1) then
1012  call kim_convert_c_char_ptr_to_string(pfile_string, file_string)
1013  end if
1014  end if
1016 
1023  recursive subroutine kim_collections_get_project_name_and_sem_ver( &
1024  collections_handle, project_name, sem_ver)
1025  use kim_interoperable_types_module, only : kim_collections_type
1026  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1027  implicit none
1028  interface
1029  recursive subroutine get_project_name_and_sem_ver(collections, &
1030  project_name, sem_ver) &
1031  bind(c, name="KIM_Collections_GetProjectNameAndSemVer")
1032  use, intrinsic :: iso_c_binding
1033  use kim_interoperable_types_module, only : kim_collections_type
1034  implicit none
1035  type(kim_collections_type), intent(in) :: collections
1036  type(c_ptr), intent(out) :: project_name
1037  type(c_ptr), intent(out) :: sem_ver
1038  end subroutine get_project_name_and_sem_ver
1039  end interface
1040  type(kim_collections_handle_type), intent(in) :: collections_handle
1041  character(len=*, kind=c_char), intent(out) :: project_name
1042  character(len=*, kind=c_char), intent(out) :: sem_ver
1043  type(kim_collections_type), pointer :: collections
1044 
1045  type(c_ptr) pproject_name, psem_ver
1046 
1047  call c_f_pointer(collections_handle%p, collections)
1048  call get_project_name_and_sem_ver(collections, pproject_name, psem_ver)
1049  call kim_convert_c_char_ptr_to_string(pproject_name, project_name)
1050  call kim_convert_c_char_ptr_to_string(psem_ver, sem_ver)
1052 
1059  recursive subroutine kim_collections_get_environment_variable_name( &
1060  collections_handle, item_type, name, ierr)
1061  use kim_interoperable_types_module, only : kim_collections_type
1062  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1063  use kim_collection_item_type_module, only : kim_collection_item_type_type
1064  implicit none
1065  interface
1066  integer(c_int) recursive function get_environment_variable_name( &
1067  collections, item_type, name) &
1068  bind(c, name="KIM_Collections_GetEnvironmentVariableName")
1069  use, intrinsic :: iso_c_binding
1070  use kim_interoperable_types_module, only : kim_collections_type
1071  use kim_collection_item_type_module, only : &
1072  kim_collection_item_type_type
1073  implicit none
1074  type(kim_collections_type), intent(in) :: collections
1075  type(kim_collection_item_type_type), intent(in), value :: item_type
1076  type(c_ptr), intent(out) :: name
1077  end function get_environment_variable_name
1078  end interface
1079  type(kim_collections_handle_type), intent(in) :: collections_handle
1080  type(kim_collection_item_type_type), intent(in) :: item_type
1081  character(len=*, kind=c_char), intent(out) :: name
1082  integer(c_int), intent(out) :: ierr
1083  type(kim_collections_type), pointer :: collections
1084 
1085  type(c_ptr) pname
1086 
1087  call c_f_pointer(collections_handle%p, collections)
1088  ierr = get_environment_variable_name(collections, item_type, pname)
1089  call kim_convert_c_char_ptr_to_string(pname, name)
1091 
1098  recursive subroutine &
1100  collections_handle, name, value)
1101  use kim_interoperable_types_module, only : kim_collections_type
1102  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1103  implicit none
1104  interface
1105  recursive subroutine get_configuration_file_environment_variable( &
1106  collections, name, value) &
1107  bind(c, name="KIM_Collections_GetConfigurationFileEnvironmentVariable")
1108  use, intrinsic :: iso_c_binding
1109  use kim_interoperable_types_module, only : kim_collections_type
1110  implicit none
1111  type(kim_collections_type), intent(in) :: collections
1112  type(c_ptr), intent(out) :: name
1113  type(c_ptr), intent(out) :: value
1114  end subroutine get_configuration_file_environment_variable
1115  end interface
1116  type(kim_collections_handle_type), intent(in) :: collections_handle
1117  character(len=*, kind=c_char), intent(out) :: name
1118  character(len=*, kind=c_char), intent(out) :: value
1119  type(kim_collections_type), pointer :: collections
1120 
1121  type(c_ptr) pname, pvalue
1122 
1123  call c_f_pointer(collections_handle%p, collections)
1124  call get_configuration_file_environment_variable(collections, pname, pvalue)
1125  call kim_convert_c_char_ptr_to_string(pname, name)
1126  call kim_convert_c_char_ptr_to_string(pvalue, value)
1128 
1135  recursive subroutine kim_collections_get_configuration_file_name( &
1136  collections_handle, file_name)
1137  use kim_interoperable_types_module, only : kim_collections_type
1138  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1139  implicit none
1140  interface
1141  recursive subroutine get_configuration_file_name(collections, file_name) &
1142  bind(c, name="KIM_Collections_GetConfigurationFileName")
1143  use, intrinsic :: iso_c_binding
1144  use kim_interoperable_types_module, only : kim_collections_type
1145  implicit none
1146  type(kim_collections_type), intent(in) :: collections
1147  type(c_ptr), intent(out) :: file_name
1148  end subroutine get_configuration_file_name
1149  end interface
1150  type(kim_collections_handle_type), intent(in) :: collections_handle
1151  character(len=*, kind=c_char), intent(out) :: file_name
1152  type(kim_collections_type), pointer :: collections
1153 
1154  type(c_ptr) pfile_name
1155 
1156  call c_f_pointer(collections_handle%p, collections)
1157  call get_configuration_file_name(collections, pfile_name)
1158  call kim_convert_c_char_ptr_to_string(pfile_name, file_name)
1160 
1167  recursive subroutine kim_collections_cache_list_of_directory_names( &
1168  collections_handle, collection, item_type, extent, ierr)
1169  use kim_interoperable_types_module, only : kim_collections_type
1170  use kim_collection_module, only : kim_collection_type
1171  use kim_collection_item_type_module, only : kim_collection_item_type_type
1172  implicit none
1173  interface
1174  integer(c_int) recursive function cache_list_of_directory_names( &
1175  collections, collection, item_type, extent) &
1176  bind(c, name="KIM_Collections_CacheListOfDirectoryNames")
1177  use, intrinsic :: iso_c_binding
1178  use kim_interoperable_types_module, only : kim_collections_type
1179  use kim_collection_module, only : kim_collection_type
1180  use kim_collection_item_type_module, only : &
1181  kim_collection_item_type_type
1182  implicit none
1183  type(kim_collections_type), intent(in) :: collections
1184  type(kim_collection_type), intent(in), value :: collection
1185  type(kim_collection_item_type_type), intent(in), value :: item_type
1186  integer(c_int), intent(out) :: extent
1187  end function cache_list_of_directory_names
1188  end interface
1189  type(kim_collections_handle_type), intent(in) :: collections_handle
1190  type(kim_collection_type), intent(in) :: collection
1191  type(kim_collection_item_type_type), intent(in) :: item_type
1192  integer(c_int), intent(out) :: extent
1193  integer(c_int), intent(out) :: ierr
1194  type(kim_collections_type), pointer :: collections
1195 
1196  call c_f_pointer(collections_handle%p, collections)
1197  ierr = cache_list_of_directory_names(collections, collection, item_type, &
1198  extent)
1200 
1206  recursive subroutine kim_collections_get_directory_name(collections_handle, &
1207  index, directory_name, ierr)
1208  use kim_interoperable_types_module, only : kim_collections_type
1209  use kim_convert_string_module, only : kim_convert_c_char_ptr_to_string
1210  implicit none
1211  interface
1212  integer(c_int) recursive function get_directory_name(collections, index, &
1213  directory_name) &
1214  bind(c, name="KIM_Collections_GetDirectoryName")
1215  use, intrinsic :: iso_c_binding
1216  use kim_interoperable_types_module, only : kim_collections_type
1217  implicit none
1218  type(kim_collections_type), intent(in) :: collections
1219  integer(c_int), intent(in), value :: index
1220  type(c_ptr), intent(out) :: directory_name
1221  end function get_directory_name
1222  end interface
1223  type(kim_collections_handle_type), intent(in) :: collections_handle
1224  integer(c_int), intent(in) :: index
1225  character(len=*, kind=c_char), intent(out) :: directory_name
1226  integer(c_int), intent(out) :: ierr
1227  type(kim_collections_type), pointer :: collections
1228 
1229  type(c_ptr) pdirectory_name
1230 
1231  call c_f_pointer(collections_handle%p, collections)
1232  ierr = get_directory_name(collections, index-1, pdirectory_name)
1233  call kim_convert_c_char_ptr_to_string(pdirectory_name, directory_name)
1234  end subroutine kim_collections_get_directory_name
1235 
1241  recursive subroutine kim_collections_set_log_id(collections_handle, log_id)
1242  use kim_interoperable_types_module, only : kim_collections_type
1243  implicit none
1244  interface
1245  recursive subroutine set_log_id(collections, log_id) &
1246  bind(c, name="KIM_Collections_SetLogID")
1247  use, intrinsic :: iso_c_binding
1248  use kim_interoperable_types_module, only : kim_collections_type
1249  implicit none
1250  type(kim_collections_type), intent(in) :: collections
1251  character(c_char), intent(in) :: log_id(*)
1252  end subroutine set_log_id
1253  end interface
1254  type(kim_collections_handle_type), intent(in) :: collections_handle
1255  character(len=*, kind=c_char), intent(in) :: log_id
1256  type(kim_collections_type), pointer :: collections
1257 
1258  call c_f_pointer(collections_handle%p, collections)
1259  call set_log_id(collections, trim(log_id)//c_null_char)
1260  end subroutine kim_collections_set_log_id
1261 
1267  recursive subroutine kim_collections_push_log_verbosity(collections_handle, &
1268  log_verbosity)
1269  use kim_log_verbosity_module, only : kim_log_verbosity_type
1270  use kim_interoperable_types_module, only : kim_collections_type
1271  implicit none
1272  interface
1273  recursive subroutine push_log_verbosity(collections, log_verbosity) &
1274  bind(c, name="KIM_Collections_PushLogVerbosity")
1275  use, intrinsic :: iso_c_binding
1276  use kim_log_verbosity_module, only : kim_log_verbosity_type
1277  use kim_interoperable_types_module, only : kim_collections_type
1278  implicit none
1279  type(kim_collections_type), intent(in) :: collections
1280  type(kim_log_verbosity_type), intent(in), value :: log_verbosity
1281  end subroutine push_log_verbosity
1282  end interface
1283  type(kim_collections_handle_type), intent(in) :: collections_handle
1284  type(kim_log_verbosity_type), intent(in) :: log_verbosity
1285  type(kim_collections_type), pointer :: collections
1286 
1287  call c_f_pointer(collections_handle%p, collections)
1288  call push_log_verbosity(collections, log_verbosity)
1289  end subroutine kim_collections_push_log_verbosity
1290 
1296  recursive subroutine kim_collections_pop_log_verbosity(collections_handle)
1297  use kim_log_verbosity_module, only : kim_log_verbosity_type
1298  use kim_interoperable_types_module, only : kim_collections_type
1299  implicit none
1300  interface
1301  recursive subroutine pop_log_verbosity(collections) &
1302  bind(c, name="KIM_Collections_PopLogVerbosity")
1303  use, intrinsic :: iso_c_binding
1304  use kim_log_verbosity_module, only : kim_log_verbosity_type
1305  use kim_interoperable_types_module, only : kim_collections_type
1306  implicit none
1307  type(kim_collections_type), intent(in) :: collections
1308  end subroutine pop_log_verbosity
1309  end interface
1310  type(kim_collections_handle_type), intent(in) :: collections_handle
1311  type(kim_collections_type), pointer :: collections
1312 
1313  call c_f_pointer(collections_handle%p, collections)
1314  call pop_log_verbosity(collections)
1315  end subroutine kim_collections_pop_log_verbosity
1316 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_and_collection(collections_handle, item_name, file_name, collection, ierr)
Get the item&#39;s library file name and its KIM::Collection.
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_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.