1 | program hdf5_test |
---|
2 | use HDF5 |
---|
3 | |
---|
4 | implicit none |
---|
5 | |
---|
6 | character(len=8), parameter :: filename = 'dsetf.h5' ! File name |
---|
7 | character(len=4), parameter :: dsetname = 'dset' ! Dataset name |
---|
8 | |
---|
9 | integer(HID_T) :: file_id ! File identifier |
---|
10 | integer(HID_T) :: dset_id ! Dataset identifier |
---|
11 | integer(HID_T) :: dspace_id ! Dataspace identifier |
---|
12 | |
---|
13 | integer(HSIZE_T), dimension(2) :: dims = (/4,6/) ! Dataset dimensions |
---|
14 | integer :: rank = 2 ! Dataset rank |
---|
15 | |
---|
16 | integer :: error ! Error flag |
---|
17 | |
---|
18 | call h5open_f(error) ! Initialize FORTRAN interface. |
---|
19 | call h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) ! Create new file, define file id |
---|
20 | call h5screate_simple_f(rank, dims, dspace_id, error) ! Create dataspace |
---|
21 | call h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, dset_id, error)! Create dataset |
---|
22 | ! Could write to dataset here if we wanted |
---|
23 | call h5dclose_f(dset_id, error) ! Close dataset |
---|
24 | call h5sclose_f(dspace_id, error) ! Close dataspace |
---|
25 | call h5fclose_f(file_id, error) ! Close file. |
---|
26 | call h5close_f(error)! Close Fortran interface |
---|
27 | |
---|
28 | end program hdf5_test |
---|