-
-
Notifications
You must be signed in to change notification settings - Fork 234
/
h5ex_g_phase.F90
113 lines (108 loc) · 4.18 KB
/
h5ex_g_phase.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
!************************************************************
!
! This example shows how to set the conditions for
! conversion between compact and dense (indexed) groups.
!
! This file is intended for use with HDF5 Library version 1.8
!
!************************************************************
PROGRAM main
USE HDF5
IMPLICIT NONE
CHARACTER(LEN=15), PARAMETER :: filename = "h5ex_g_phase.h5"
INTEGER, PARAMETER :: MAX_GROUPS = 7
INTEGER, PARAMETER :: MAX_COMPACT = 5
INTEGER, PARAMETER :: MIN_DENSE = 3
INTEGER(HID_T) :: file, group, subgroup, fapl, gcpl ! handles
INTEGER :: hdferr
INTEGER :: storage_type ! Type of storage for links in group:
! H5G_STORAGE_TYPE_COMPACT_F: Compact storage
! H5G_STORAGE_TYPE_DENSE_F: Indexed storage
! H5G_STORAGE_TYPE_SYMBOL_TABLE_F: Symbol tables
INTEGER :: nlinks ! Number of links in group
INTEGER :: max_corder ! Current maximum creation order value for group
CHARACTER(LEN=2) :: name = "G0" ! Name of subgroup
INTEGER :: i
!
! Initialize FORTRAN interface.
!
CALL h5open_f(hdferr)
!
! Set file access property list to allow the latest file format.
! This will allow the library to create new format groups.
!
CALL h5pcreate_f (H5P_FILE_ACCESS_F, fapl, hdferr)
CALL h5pset_libver_bounds_f (fapl, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, hdferr)
!
! Create group access property list and set the phase change
! conditions. In this example we lowered the conversion threshold
! to simplify the output, though this may not be optimal.
!
CALL h5pcreate_f (H5P_GROUP_CREATE_F, gcpl, hdferr)
CALL h5pset_link_phase_change_f (gcpl, MAX_COMPACT, MIN_DENSE, hdferr)
!
! Create a new file using the default properties.
!
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file, hdferr, access_prp=fapl )
!
! Create primary group.
!
CALL h5gcreate_f(file, name, group, hdferr, gcpl_id=gcpl)
!
! Add subgroups to "group" one at a time, print the storage type
! for "group" after each subgroup is created.
!
DO i = 1, MAX_GROUPS
!
! Define the subgroup name and create the subgroup.
!
WRITE(name,'(A,I1)') "G",i ! G1, G2, G3 etc.
CALL h5gcreate_f(group, name, subgroup, hdferr)
CALL h5gclose_f(subgroup, hdferr)
!
! Obtain the group info and print the group storage type
!
CALL H5Gget_info_f(group, storage_type, nlinks, max_corder, hdferr)
WRITE(*,'(I1," Groups: Storage type is ")', ADVANCE='NO') nlinks
IF(storage_type.EQ. H5G_STORAGE_TYPE_COMPACT_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_COMPACT_F")') ! New compact format
ELSE IF(storage_type.EQ.H5G_STORAGE_TYPE_DENSE_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_DENSE_F")') ! New dense (indexed) format
ELSE IF(storage_type.EQ.H5G_STORAGE_TYPE_SYMBOL_TABLE_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_SYMBOL_TABLE")') ! Original format
ELSE IF(storage_type.EQ.H5G_STORAGE_TYPE_UNKNOWN_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_UNKNOWN_F")') ! Unknown format
END IF
ENDDO
WRITE(*,'()')
!
! Delete subgroups one at a time, print the storage type for
!"group" after each subgroup is deleted.
!
DO i = MAX_GROUPS,1, -1
!
! Define the subgroup name and delete the subgroup.
!
WRITE(name,'(A,I1)') "G",i ! G1, G2, G3 etc.
CALL h5ldelete_f(group, name, hdferr)
!
! Obtain the group info and print the group storage type
!
CALL H5Gget_info_f(group, storage_type, nlinks, max_corder, hdferr)
WRITE(*,'(I1," Groups: Storage type is ")', ADVANCE='NO') nlinks
IF(storage_type.EQ. H5G_STORAGE_TYPE_COMPACT_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_COMPACT_F")') ! New compact format
ELSE IF(storage_type.EQ.H5G_STORAGE_TYPE_DENSE_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_DENSE_F")') ! New dense (indexed) format
ELSE IF(storage_type.EQ.H5G_STORAGE_TYPE_SYMBOL_TABLE_F)THEN
WRITE(*,'("H5G_STORAGE_TYPE_SYMBOL_TABLE")') ! Original format
END IF
ENDDO
!
! Close and release resources.
!
CALL h5pclose_f(fapl, hdferr)
CALL h5pclose_f(gcpl, hdferr)
CALL h5gclose_f(group, hdferr)
CALL h5fclose_f(file, hdferr)
END PROGRAM main