summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarbara Jones <bljones@hdfgroup.org>2001-03-08 16:31:09 (GMT)
committerBarbara Jones <bljones@hdfgroup.org>2001-03-08 16:31:09 (GMT)
commit70cc09f8b6825bd1b5caeca22b9a1e42661410ea (patch)
tree7cb077f72b20f52680bb11474bd07dcc65de5988
parent33466ac3cf6c8583893a833ba0247dd5c0d9584a (diff)
downloadhdf5-70cc09f8b6825bd1b5caeca22b9a1e42661410ea.zip
hdf5-70cc09f8b6825bd1b5caeca22b9a1e42661410ea.tar.gz
hdf5-70cc09f8b6825bd1b5caeca22b9a1e42661410ea.tar.bz2
[svn-r3561] add to tutorial
Purpose: [is this a bug fix? feature? ...] Description: [describe the bug, or describe the new feature, etc] Solution: [details about the changes, algorithm, etc...] [Please as detail as you can since your own explanation is better than others guessing it from the code.] Platforms tested: [machines you have tested the changed version. This is absolute important. Test it out on at least two or three different platforms such as Big-endian-32bit (SUN/IRIX), little-endian-32(LINUX) and 64-bit (IRIX64/UNICOS/DEC-ALPHA) would be good.]
-rw-r--r--doc/html/Tutor/examples/grpdsetexample.f90136
-rw-r--r--doc/html/Tutor/examples/grpit.f90194
-rw-r--r--doc/html/Tutor/examples/grpsexample.f9068
-rw-r--r--doc/html/Tutor/examples/hyperslab.f90199
-rw-r--r--doc/html/Tutor/examples/mountexample.f90187
-rw-r--r--doc/html/Tutor/examples/refobjexample.f90142
-rw-r--r--doc/html/Tutor/examples/refregexample.f90162
-rw-r--r--doc/html/Tutor/examples/rwdsetexample.f9078
-rw-r--r--doc/html/Tutor/examples/selectele.f90282
9 files changed, 1448 insertions, 0 deletions
diff --git a/doc/html/Tutor/examples/grpdsetexample.f90 b/doc/html/Tutor/examples/grpdsetexample.f90
new file mode 100644
index 0000000..ceb2fe9
--- /dev/null
+++ b/doc/html/Tutor/examples/grpdsetexample.f90
@@ -0,0 +1,136 @@
+!
+! This example shows how to create a dataset in a particular group.
+! It opens the file created in the previous example and creates two datasets.
+! Absolute and relative dataset names are used.
+!
+
+
+ PROGRAM GRPDSETEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=10), PARAMETER :: filename = "groupsf.h5" ! File name
+ CHARACTER(LEN=15), PARAMETER :: groupname = "MyGroup/Group_A" ! Group name
+ CHARACTER(LEN=13), PARAMETER :: dsetname1 = "MyGroup/dset1" ! Dataset name
+ CHARACTER(LEN=5), PARAMETER :: dsetname2 = "dset2" ! dataset name
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: group_id ! Group identifier
+ INTEGER(HID_T) :: dataset_id ! Dataset identifier
+ INTEGER(HID_T) :: dataspace_id ! Data space identifier
+
+ INTEGER :: i, j
+ INTEGER :: error ! Error flag
+
+ INTEGER, DIMENSION(3,3) :: dset1_data ! Data arrays
+ INTEGER, DIMENSION(2,10) :: dset2_data !
+
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims1 = (/3,3/) ! Datasets dimensions
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims2 = (/2,10/)!
+
+ INTEGER :: rank = 2 ! Datasets rank
+
+ !
+ !Initialize dset1_data array
+ !
+ do i = 1, 3
+ do j = 1, 3
+ dset1_data(i,j) = j;
+ end do
+ end do
+
+
+ !
+ !Initialize dset2_data array
+ !
+ do i = 1, 2
+ do j = 1, 10
+ dset2_data(i,j) = j;
+ end do
+ end do
+
+ !
+ ! Initialize FORTRAN predefined datatypes.
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Open an existing file.
+ !
+ CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error)
+
+ !
+ ! Create the data space for the first dataset.
+ !
+ CALL h5screate_simple_f(rank, dims1, dataspace_id, error)
+
+ !
+ ! Create a dataset in group "MyGroup" with default properties.
+ !
+ CALL h5dcreate_f(file_id, dsetname1, H5T_NATIVE_INTEGER, dataspace_id, &
+ dataset_id, error)
+
+ !
+ ! Write the first dataset.
+ !
+ CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset1_data, error)
+
+ !
+ ! Close the dataspace for the first dataset.
+ !
+ CALL h5sclose_f(dataspace_id, error)
+
+ !
+ ! Close the first dataset.
+ !
+ CALL h5dclose_f(dataset_id, error)
+
+ !
+ ! Open an existing group in the specified file.
+ !
+ CALL h5gopen_f(file_id, groupname, group_id, error)
+
+ !
+ !Create the data space for the second dataset.
+ !
+ CALL h5screate_simple_f(rank, dims2, dataspace_id, error)
+
+ !
+ ! Create the second dataset in group "Group_A" with default properties.
+ !
+ CALL h5dcreate_f(group_id, dsetname2, H5T_NATIVE_INTEGER, dataspace_id, &
+ dataset_id, error)
+
+ !
+ ! Write the second dataset.
+ !
+ CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset2_data, error)
+
+ !
+ ! Close the dataspace for the second dataset.
+ !
+ CALL h5sclose_f(dataspace_id, error)
+
+ !
+ ! Close the second dataset.
+ !
+ CALL h5dclose_f(dataset_id, error)
+
+ !
+ ! Close the group.
+ !
+ CALL h5gclose_f(group_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN predefined datatypes.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM GRPDSETEXAMPLE
diff --git a/doc/html/Tutor/examples/grpit.f90 b/doc/html/Tutor/examples/grpit.f90
new file mode 100644
index 0000000..3aff2ad
--- /dev/null
+++ b/doc/html/Tutor/examples/grpit.f90
@@ -0,0 +1,194 @@
+!
+! In this example we iterate through the members of the groups.
+!
+
+
+ PROGRAM GRPITEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=11), PARAMETER :: filename = "iteratef.h5" ! File name
+ CHARACTER(LEN=7), PARAMETER :: groupname1 = "MyGroup" ! Group name
+ CHARACTER(LEN=15), PARAMETER :: groupname2 = "Group_A" ! Group name
+ CHARACTER(LEN=13), PARAMETER :: dsetname1 = "dset1" ! Dataset name
+ CHARACTER(LEN=5), PARAMETER :: dsetname2 = "dset2" !
+
+ CHARACTER(LEN=20) :: name_buffer ! Buffer to hold object's name
+ INTEGER :: type ! Type of the object
+ INTEGER :: nmembers ! Number of group members
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: dataset1_id ! Dataset1 identifier
+ INTEGER(HID_T) :: dataset2_id ! Dataset2 identifier
+ INTEGER(HID_T) :: dataspace1_id ! Data space identifier
+ INTEGER(HID_T) :: dataspace2_id ! Data space identifier
+ INTEGER(HID_T) :: group1_id, group2_id ! Group identifiers
+
+ INTEGER :: i, j
+
+ INTEGER :: error ! Error flag
+
+ INTEGER, DIMENSION(3,3) :: dset1_data ! Arrays to hold data
+ INTEGER, DIMENSION(2,10) :: dset2_data !
+
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims1 = (/3,3/) ! Dataset dimensions
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims2 = (/2,10/)!
+ INTEGER :: rank = 2 ! Datasets rank
+
+ !
+ ! Initialize dset1_data array.
+ !
+ do i = 1, 3
+ do j = 1, 3
+ dset1_data(i,j) = j;
+ end do
+ end do
+
+
+ !
+ ! Initialize dset2_data array.
+ !
+ do i = 1, 2
+ do j = 1, 10
+ dset2_data(i,j) = j;
+ end do
+ end do
+
+ !
+ ! Initialize FORTRAN interface.
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Create a new file using default properties.
+ !
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+
+ !
+ ! Create group "MyGroup" in the root group using absolute name.
+ !
+ CALL h5gcreate_f(file_id, groupname1, group1_id, error)
+
+ !
+ ! Create group "Group_A" in group "MyGroup" using relative name.
+ !
+ CALL h5gcreate_f(group1_id, groupname2, group2_id, error)
+
+ !
+ ! Create the data space for the first dataset.
+ !
+ CALL h5screate_simple_f(rank, dims1, dataspace1_id, error)
+
+ !
+ ! Create a dataset in group "MyGroup" with default properties.
+ !
+ CALL h5dcreate_f(group1_id, dsetname1, H5T_NATIVE_INTEGER, dataspace1_id, &
+ dataset1_id, error)
+
+ !
+ ! Write the first dataset.
+ !
+ CALL h5dwrite_f(dataset1_id, H5T_NATIVE_INTEGER, dset1_data, error)
+
+ !
+ ! Create the data space for the second dataset.
+ !
+ CALL h5screate_simple_f(rank, dims2, dataspace2_id, error)
+
+ !
+ ! Create the second dataset in group "Group_A" with default properties
+ !
+ CALL h5dcreate_f(group2_id, dsetname2, H5T_NATIVE_INTEGER, dataspace2_id, &
+ dataset2_id, error)
+
+ !
+ ! Write the second dataset
+ !
+ CALL h5dwrite_f(dataset2_id, H5T_NATIVE_INTEGER, dset2_data, error)
+
+ !
+ ! Get number of members in the root group.
+ !
+ CALL h5gn_members_f(file_id, "/", nmembers, error)
+ write(*,*) "Number of root group member is " , nmembers
+
+ !
+ ! Print each group member's name and type.
+ !
+ do i = 0, nmembers - 1
+ CALL h5gget_obj_info_idx_f(file_id, "/", i, name_buffer, type, &
+ error)
+ write(*,*) name_buffer, type
+ end do
+
+ !
+ ! Get number of members in MyGroup.
+ !
+ CALL h5gn_members_f(file_id, "MyGroup", nmembers, error)
+ write(*,*) "Number of group MyGroup member is ", nmembers
+
+ !
+ ! Print each group member's name and type in "MyGroup" group.
+ !
+ do i = 0, nmembers - 1
+ CALL h5gget_obj_info_idx_f(file_id, groupname1, i, name_buffer, type, &
+ error)
+ write(*,*) name_buffer, type
+ end do
+
+
+ !
+ ! Get number of members in MyGroup/Group_A.
+ !
+ CALL h5gn_members_f(file_id, "MyGroup/Group_A", nmembers, error)
+ write(*,*) "Number of group MyGroup/Group_A member is ", nmembers
+
+ !
+ ! Print each group member's name and type in "MyGroup/Group_A" group.
+ !
+ do i = 0, nmembers - 1
+ CALL h5gget_obj_info_idx_f(file_id,"MyGroup/Group_A" , i, name_buffer, type, &
+ error)
+ write(*,*) name_buffer, type
+ end do
+
+ !
+ ! Close the dataspace for the first dataset.
+ !
+ CALL h5sclose_f(dataspace1_id, error)
+
+ !
+ ! Close the first dataset.
+ !
+ CALL h5dclose_f(dataset1_id, error)
+
+ !
+ ! Close the dataspace for the second dataset.
+ !
+ CALL h5sclose_f(dataspace2_id, error)
+
+ !
+ ! Close the second dataset.
+ !
+ CALL h5dclose_f(dataset2_id, error)
+
+ !
+ ! Close the groups.
+ !
+ CALL h5gclose_f(group1_id, error)
+
+ CALL h5gclose_f(group2_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM GRPITEXAMPLE
diff --git a/doc/html/Tutor/examples/grpsexample.f90 b/doc/html/Tutor/examples/grpsexample.f90
new file mode 100644
index 0000000..4b53bf0
--- /dev/null
+++ b/doc/html/Tutor/examples/grpsexample.f90
@@ -0,0 +1,68 @@
+!
+! The following example code shows how to create groups
+! using absolute and relative names. It creates three groups:
+! the first two groups are created using the file identifier and
+! the group absolute names, and the third group is created using
+! a group identifier and the name relative to the specified group.
+!
+
+
+ PROGRAM GRPSEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=10), PARAMETER :: filename = "groupsf.h5" ! File name
+ CHARACTER(LEN=8), PARAMETER :: groupname1 = "/MyGroup" ! Group name
+ CHARACTER(LEN=16), PARAMETER :: groupname2 = "/MyGroup/Group_A"
+ ! Group name
+ CHARACTER(LEN=7), PARAMETER :: groupname3 = "Group_B" ! Group name
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: group1_id, group2_id, group3_id ! Group identifiers
+
+ INTEGER :: error ! Error flag
+ !
+ ! Initialize FORTRAN interface.
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Create a new file using default properties.
+ !
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+
+ !
+ ! Create group "MyGroup" in the root group using absolute name.
+ !
+ CALL h5gcreate_f(file_id, groupname1, group1_id, error)
+
+ !
+ ! Create group "Group_A" in group "MyGroup" using absolute name.
+ !
+ CALL h5gcreate_f(file_id, groupname2, group2_id, error)
+
+ !
+ ! Create group "Group_B" in group "MyGroup" using relative name.
+ !
+ CALL h5gcreate_f(group1_id, groupname3, group3_id, error)
+
+ !
+ ! Close the groups.
+ !
+ CALL h5gclose_f(group1_id, error)
+ CALL h5gclose_f(group2_id, error)
+ CALL h5gclose_f(group3_id, error)
+
+ !
+ ! Terminate access to the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM GRPSEXAMPLE
diff --git a/doc/html/Tutor/examples/hyperslab.f90 b/doc/html/Tutor/examples/hyperslab.f90
new file mode 100644
index 0000000..e49f18b
--- /dev/null
+++ b/doc/html/Tutor/examples/hyperslab.f90
@@ -0,0 +1,199 @@
+!
+! This example shows how to write and read a hyperslab.
+!
+
+ PROGRAM SELECTEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=7), PARAMETER :: filename = "sdsf.h5" ! File name
+ CHARACTER(LEN=8), PARAMETER :: dsetname = "IntArray" ! Dataset name
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: dset_id ! Dataset identifier
+ INTEGER(HID_T) :: dataspace ! Dataspace identifier
+ INTEGER(HID_T) :: memspace ! memspace identifier
+
+ INTEGER(HSIZE_T), DIMENSION(3) :: dimsm = (/7,7,3/) ! Dataset dimensions
+ ! in memory
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims_out ! Buffer to read in dataset
+ ! dimesions
+ INTEGER(HSIZE_T), DIMENSION(2) :: dimsf = (/5,6/) ! Dataset dimensions.
+
+ INTEGER(HSIZE_T), DIMENSION(2) :: count = (/3,4/)
+ ! Size of the hyperslab in the file
+ INTEGER(HSIZE_T), DIMENSION(2) :: offset = (/1,2/)
+ !hyperslab offset in the file
+ INTEGER(HSIZE_T), DIMENSION(3) :: count_out = (/3,4,1/)
+ !Size of the hyperslab in memory
+ INTEGER(HSIZE_T), DIMENSION(3) :: offset_out = (/3,0,0/)
+ !hyperslab offset in memory
+ INTEGER, DIMENSION(5,6) :: data ! Data to write
+ INTEGER, DIMENSION(7,7,3) :: data_out ! Output buffer
+ INTEGER :: dsetrank = 2 ! Dataset rank ( in file )
+ INTEGER :: memrank = 3 ! Dataset rank ( in memory )
+ INTEGER :: rank
+ INTEGER :: i, j, k
+
+ INTEGER :: error, error_n ! Error flags
+
+
+ !
+ ! Write data to the HDF5 file.
+ !
+
+ !
+ ! Data initialization.
+ !
+ do i = 1, 5
+ do j = 1, 6
+ data(i,j) = (i-1) + (j-1);
+ end do
+ end do
+ !
+ ! 0, 1, 2, 3, 4, 5
+ ! 1, 2, 3, 4, 5, 6
+ ! 2, 3, 4, 5, 6, 7
+ ! 3, 4, 5, 6, 7, 8
+ ! 4, 5, 6, 7, 8, 9
+ !
+
+ !
+ ! Initialize FORTRAN predefined datatypes
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Create a new file using default properties.
+ !
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+
+ !
+ ! Create the data space for the dataset.
+ !
+ CALL h5screate_simple_f(dsetrank, dimsf, dataspace, error)
+
+ !
+ ! Create the dataset with default properties.
+ !
+ CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dataspace, &
+ dset_id, error)
+
+ !
+ ! Write the dataset.
+ !
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, error)
+
+ !
+ ! Close the dataspace for the dataset.
+ !
+ CALL h5sclose_f(dataspace, error)
+
+ !
+ ! Close the dataset.
+ !
+ CALL h5dclose_f(dset_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! This part of the code reads the hyperslab from the sds.h5 file just
+ ! created, into a 2-dimensional plane of the 3-dimensional dataset.
+ !
+
+ !
+ ! Initialize data_out array.
+ !
+ do i = 1, 7
+ do j = 1, 7
+ do k = 1,3
+ data_out(i,j,k) = 0;
+ end do
+ end do
+ end do
+
+ !
+ ! Open the file.
+ !
+ CALL h5fopen_f (filename, H5F_ACC_RDONLY_F, file_id, error)
+
+ !
+ ! Open the dataset.
+ !
+ CALL h5dopen_f(file_id, dsetname, dset_id, error)
+
+ !
+ ! Get dataset's dataspace identifier.
+ !
+ CALL h5dget_space_f(dset_id, dataspace, error)
+
+ !
+ ! Select hyperslab in the dataset.
+ !
+ CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, &
+ offset, count, error)
+ !
+ ! Create memory dataspace.
+ !
+ CALL h5screate_simple_f(memrank, dimsm, memspace, error)
+
+ !
+ ! Select hyperslab in memory.
+ !
+ CALL h5sselect_hyperslab_f(memspace, H5S_SELECT_SET_F, &
+ offset_out, count_out, error)
+
+ !
+ ! Read data from hyperslab in the file into the hyperslab in
+ ! memory and display.
+ !
+ CALL H5Dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, error, &
+ memspace, dataspace)
+
+ !
+ ! Display data_out array
+ !
+ do i = 1, 7
+ print *, (data_out(i,j,1), j = 1,7)
+ end do
+
+ ! 0 0 0 0 0 0 0
+ ! 0 0 0 0 0 0 0
+ ! 0 0 0 0 0 0 0
+ ! 3 4 5 6 0 0 0
+ ! 4 5 6 7 0 0 0
+ ! 5 6 7 8 0 0 0
+ ! 0 0 0 0 0 0 0
+ !
+
+ !
+ ! Close the dataspace for the dataset.
+ !
+ CALL h5sclose_f(dataspace, error)
+
+ !
+ ! Close the memoryspace.
+ !
+ CALL h5sclose_f(memspace, error)
+
+ !
+ ! Close the dataset.
+ !
+ CALL h5dclose_f(dset_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN predefined datatypes.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM SELECTEXAMPLE
diff --git a/doc/html/Tutor/examples/mountexample.f90 b/doc/html/Tutor/examples/mountexample.f90
new file mode 100644
index 0000000..f4341b2
--- /dev/null
+++ b/doc/html/Tutor/examples/mountexample.f90
@@ -0,0 +1,187 @@
+!
+!In the following example we create one file with a group in it,
+!and another file with a dataset. Mounting is used to
+!access the dataset from the second file as a member of a group
+!in the first file.
+!
+
+ PROGRAM MOUNTEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ !
+ ! Filenames are "mount1.h5" and "mount2.h5"
+ !
+ CHARACTER(LEN=9), PARAMETER :: filename1 = "mount1.h5"
+ CHARACTER(LEN=9), PARAMETER :: filename2 = "mount2.h5"
+
+ !
+ !data space rank and dimensions
+ !
+ INTEGER, PARAMETER :: RANK = 2
+ INTEGER, PARAMETER :: NX = 4
+ INTEGER, PARAMETER :: NY = 5
+
+ !
+ ! File identifiers
+ !
+ INTEGER(HID_T) :: file1_id, file2_id
+
+ !
+ ! Group identifier
+ !
+ INTEGER(HID_T) :: gid
+
+ !
+ ! Dataset identifier
+ !
+ INTEGER(HID_T) :: dset_id
+
+ !
+ ! Data space identifier
+ !
+ INTEGER(HID_T) :: dataspace
+
+ !
+ ! Data type identifier
+ !
+ INTEGER(HID_T) :: dtype_id
+
+ !
+ ! The dimensions for the dataset.
+ !
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/NX,NY/)
+
+ !
+ ! Flag to check operation success
+ !
+ INTEGER :: error
+
+ !
+ ! General purpose integer
+ !
+ INTEGER :: i, j
+
+ !
+ ! Data buffers
+ !
+ INTEGER, DIMENSION(NX,NY) :: data_in, data_out
+
+ !
+ ! Initialize FORTRAN interface.
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Initialize data_in buffer
+ !
+ do i = 1, NX
+ do j = 1, NY
+ data_in(i,j) = (i-1) + (j-1)
+ end do
+ end do
+
+ !
+ ! Create first file "mount1.h5" using default properties.
+ !
+ CALL h5fcreate_f(filename1, H5F_ACC_TRUNC_F, file1_id, error)
+
+ !
+ ! Create group "/G" inside file "mount1.h5".
+ !
+ CALL h5gcreate_f(file1_id, "/G", gid, error)
+
+ !
+ ! Close file and group identifiers.
+ !
+ CALL h5gclose_f(gid, error)
+ CALL h5fclose_f(file1_id, error)
+
+ !
+ ! Create second file "mount2.h5" using default properties.
+ !
+ CALL h5fcreate_f(filename2, H5F_ACC_TRUNC_F, file2_id, error)
+
+ !
+ ! Create data space for the dataset.
+ !
+ CALL h5screate_simple_f(RANK, dims, dataspace, error)
+
+ !
+ ! Create dataset "/D" inside file "mount2.h5".
+ !
+ CALL h5dcreate_f(file2_id, "/D", H5T_NATIVE_INTEGER, dataspace, &
+ dset_id, error)
+
+ !
+ ! Write data_in to the dataset
+ !
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data_in, error)
+
+ !
+ ! Close file, dataset and dataspace identifiers.
+ !
+ CALL h5sclose_f(dataspace, error)
+ CALL h5dclose_f(dset_id, error)
+ CALL h5fclose_f(file2_id, error)
+
+ !
+ ! Reopen both files.
+ !
+ CALL h5fopen_f (filename1, H5F_ACC_RDWR_F, file1_id, error)
+ CALL h5fopen_f (filename2, H5F_ACC_RDWR_F, file2_id, error)
+
+ !
+ ! Mount the second file under the first file's "/G" group.
+ !
+ CALL h5fmount_f (file1_id, "/G", file2_id, error)
+
+
+ !
+ ! Access dataset D in the first file under /G/D name.
+ !
+ CALL h5dopen_f(file1_id, "/G/D", dset_id, error)
+
+ !
+ ! Get dataset's data type.
+ !
+ CALL h5dget_type_f(dset_id, dtype_id, error)
+
+ !
+ ! Read the dataset.
+ !
+ CALL h5dread_f(dset_id, dtype_id, data_out, error)
+
+ !
+ ! Print out the data.
+ !
+ do i = 1, NX
+ print *, (data_out(i,j), j = 1, NY)
+ end do
+
+
+ !
+ !Close dset_id and dtype_id.
+ !
+ CALL h5dclose_f(dset_id, error)
+ CALL h5tclose_f(dtype_id, error)
+
+ !
+ ! Unmount the second file.
+ !
+ CALL h5funmount_f(file1_id, "/G", error);
+
+ !
+ ! Close both files.
+ !
+ CALL h5fclose_f(file1_id, error)
+ CALL h5fclose_f(file2_id, error)
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM MOUNTEXAMPLE
+
diff --git a/doc/html/Tutor/examples/refobjexample.f90 b/doc/html/Tutor/examples/refobjexample.f90
new file mode 100644
index 0000000..fdbb26d
--- /dev/null
+++ b/doc/html/Tutor/examples/refobjexample.f90
@@ -0,0 +1,142 @@
+!
+! This program shows how to create and store references to the objects.
+! Program creates a file, two groups, a dataset to store integer data and
+! a dataset to store references to the objects.
+! Stored references are used to open the objects they are point to.
+! Data is written to the dereferenced dataset, and class type is displayed for
+! the shared datatype.
+!
+ PROGRAM OBJ_REFERENCES
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+ CHARACTER(LEN=10), PARAMETER :: filename = "FORTRAN.h5" ! File
+ CHARACTER(LEN=8), PARAMETER :: dsetnamei = "INTEGERS" ! Dataset with the integer data
+ CHARACTER(LEN=17), PARAMETER :: dsetnamer = "OBJECT_REFERENCES" ! Dataset wtih object
+ ! references
+ CHARACTER(LEN=6), PARAMETER :: groupname1 = "GROUP1" ! Groups in the file
+ CHARACTER(LEN=6), PARAMETER :: groupname2 = "GROUP2" !
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: grp1_id ! Group identifiers
+ INTEGER(HID_T) :: grp2_id !
+ INTEGER(HID_T) :: dset_id ! Dataset identifiers
+ INTEGER(HID_T) :: dsetr_id !
+ INTEGER(HID_T) :: type_id ! Type identifier
+ INTEGER(HID_T) :: space_id ! Dataspace identifiers
+ INTEGER(HID_T) :: spacer_id !
+ INTEGER :: error
+ INTEGER(HSIZE_T), DIMENSION(1) :: dims = (/5/)
+ INTEGER(HSIZE_T), DIMENSION(1) :: dimsr= (/4/)
+ INTEGER(HSIZE_T), DIMENSION(1) :: my_maxdims = (/5/)
+ INTEGER :: rank = 1
+ INTEGER :: rankr = 1
+ TYPE(hobj_ref_t_f), DIMENSION(4) :: ref
+ TYPE(hobj_ref_t_f), DIMENSION(4) :: ref_out
+ INTEGER, DIMENSION(5) :: data = (/1, 2, 3, 4, 5/)
+ INTEGER :: class, ref_size
+ !
+ ! Initialize FORTRAN interface.
+ !
+ CALL h5open_f(error)
+ !
+ ! Create a file
+ !
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+ ! Default file access and file creation
+ ! properties are used.
+ !
+ ! Create a group in the file
+ !
+ CALL h5gcreate_f(file_id, groupname1, grp1_id, error)
+ !
+ ! Create a group inside the created gorup
+ !
+ CALL h5gcreate_f(grp1_id, groupname2, grp2_id, error)
+ !
+ ! Create dataspaces for datasets
+ !
+ CALL h5screate_simple_f(rank, dims, space_id, error, maxdims=my_maxdims)
+ CALL h5screate_simple_f(rankr, dimsr, spacer_id, error)
+ !
+ ! Create integer dataset
+ !
+ CALL h5dcreate_f(file_id, dsetnamei, H5T_NATIVE_INTEGER, space_id, &
+ dset_id, error)
+ !
+ ! Create dataset to store references to the objects
+ !
+ CALL h5dcreate_f(file_id, dsetnamer, H5T_STD_REF_OBJ, spacer_id, &
+ dsetr_id, error)
+ !
+ ! Create a datatype and store in the file
+ !
+ CALL h5tcopy_f(H5T_NATIVE_REAL, type_id, error)
+ CALL h5tcommit_f(file_id, "MyType", type_id, error)
+ !
+ ! Close dataspaces, groups and integer dataset
+ !
+ CALL h5sclose_f(space_id, error)
+ CALL h5sclose_f(spacer_id, error)
+ CALL h5tclose_f(type_id, error)
+ CALL h5dclose_f(dset_id, error)
+ CALL h5gclose_f(grp1_id, error)
+ CALL h5gclose_f(grp2_id, error)
+ !
+ ! Create references to two groups, integer dataset and shared datatype
+ ! and write it to the dataset in the file
+ !
+ CALL h5rcreate_f(file_id, groupname1, ref(1), error)
+ CALL h5rcreate_f(file_id, "/GROUP1/GROUP2", ref(2), error)
+ CALL h5rcreate_f(file_id, dsetnamei, ref(3), error)
+ CALL h5rcreate_f(file_id, "MyType", ref(4), error)
+ ref_size = size(ref)
+ CALL h5dwrite_f(dsetr_id, H5T_STD_REF_OBJ, ref, ref_size, error)
+ !
+ ! Close the dataset
+ !
+ CALL h5dclose_f(dsetr_id, error)
+ !
+ ! Reopen the dataset with object references and read references to the buffer
+ !
+ CALL h5dopen_f(file_id, dsetnamer,dsetr_id,error)
+ ref_size = size(ref_out)
+ CALL h5dread_f(dsetr_id, H5T_STD_REF_OBJ, ref_out, ref_size, error)
+ !
+ ! Dereference the third reference. We know that it is a dataset. On practice
+ ! one should use h5rget_object_type_f function to find out
+ ! the type of an object the reference points to.
+ !
+ CALL h5rdereference_f(dsetr_id, ref(3), dset_id, error)
+ !
+ ! Write data to the dataset.
+ !
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, error)
+ if (error .eq. 0) write(*,*) "Data has been successfully written to the dataset "
+ !
+ ! Dereference the fourth reference. We know that it is a datatype. On practice
+ ! one should use h5rget_object_type_f function to find out
+ ! the type of an object the reference points to.
+ !
+ CALL h5rdereference_f(dsetr_id, ref(4), type_id, error)
+ !
+ ! Get datatype class and display it if it is of a FLOAT class.
+ !
+ CALL h5tget_class_f(type_id, class, error)
+ if(class .eq. H5T_FLOAT_F) write(*,*) "Stored datatype is of a FLOAT class"
+ !
+ ! Close all objects.
+ !
+ CALL h5dclose_f(dset_id, error)
+ CALL h5tclose_f(type_id, error)
+ CALL h5dclose_f(dsetr_id, error)
+ CALL h5fclose_f(file_id, error)
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM OBJ_REFERENCES
+
+
diff --git a/doc/html/Tutor/examples/refregexample.f90 b/doc/html/Tutor/examples/refregexample.f90
new file mode 100644
index 0000000..05fcf3f
--- /dev/null
+++ b/doc/html/Tutor/examples/refregexample.f90
@@ -0,0 +1,162 @@
+!
+! This program shows how to create, store and dereference references
+! to the dataset regions.
+! Program creates a file and writes two dimensional integer dataset
+! to it. Then program creates and stores references to the hyperslab
+! and 3 points selected in the integer dataset, in the second dataset.
+! Program reopens the second dataset, reads and dereferences region
+! references, and then reads and displays selected data from the
+! integer dataset.
+!
+ PROGRAM REG_REFERENCE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+ CHARACTER(LEN=10), PARAMETER :: filename = "FORTRAN.h5"
+ CHARACTER(LEN=6), PARAMETER :: dsetnamev = "MATRIX"
+ CHARACTER(LEN=17), PARAMETER :: dsetnamer = "REGION_REFERENCES"
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: space_id ! Dataspace identifier
+ INTEGER(HID_T) :: spacer_id ! Dataspace identifier
+ INTEGER(HID_T) :: dsetv_id ! Dataset identifier
+ INTEGER(HID_T) :: dsetr_id ! Dataset identifier
+ INTEGER :: error
+ TYPE(hdset_reg_ref_t_f) , DIMENSION(2) :: ref ! Buffers to store references
+ TYPE(hdset_reg_ref_t_f) , DIMENSION(2) :: ref_out !
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/2,9/) ! Datasets dimensions
+ INTEGER(HSIZE_T), DIMENSION(1) :: dimsr = (/2/) !
+ INTEGER(HSSIZE_T), DIMENSION(2) :: start
+ INTEGER(HSIZE_T), DIMENSION(2) :: count
+ INTEGER :: rankr = 1
+ INTEGER :: rank = 2
+ INTEGER , DIMENSION(2,9) :: data
+ INTEGER , DIMENSION(2,9) :: data_out = 0
+ INTEGER(HSSIZE_T) , DIMENSION(2,3) :: coord
+ INTEGER(SIZE_T) ::num_points = 3 ! Number of selected points
+ INTEGER :: i, j
+ INTEGER :: ref_size
+ coord = reshape((/1,1,2,7,1,9/), (/2,3/)) ! Coordinates of selected points
+ data = reshape ((/1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6/), (/2,9/))
+ !
+ ! Initialize FORTRAN interface.
+ !
+ CALL h5open_f(error)
+ !
+ ! Create a new file.
+ !
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+ ! Default file access and file creation
+ ! properties are used.
+ !
+ ! Create dataspaces:
+ !
+ ! for dataset with references to dataset regions
+ !
+ CALL h5screate_simple_f(rankr, dimsr, spacer_id, error)
+ !
+ ! for integer dataset
+ !
+ CALL h5screate_simple_f(rank, dims, space_id, error)
+ !
+ ! Create and write datasets:
+ !
+ ! Integer dataset
+ !
+ CALL h5dcreate_f(file_id, dsetnamev, H5T_NATIVE_INTEGER, space_id, &
+ dsetv_id, error)
+ CALL h5dwrite_f(dsetv_id, H5T_NATIVE_INTEGER, data, error)
+ CALL h5dclose_f(dsetv_id, error)
+ !
+ ! Dataset with references
+ !
+ CALL h5dcreate_f(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, &
+ dsetr_id, error)
+ !
+ ! Create a reference to the hyperslab selection.
+ !
+ start(1) = 0
+ start(2) = 3
+ count(1) = 2
+ count(2) = 3
+ CALL h5sselect_hyperslab_f(space_id, H5S_SELECT_SET_F, &
+ start, count, error)
+ CALL h5rcreate_f(file_id, dsetnamev, space_id, ref(1), error)
+ !
+ ! Create a reference to elements selection.
+ !
+ CALL h5sselect_none_f(space_id, error)
+ CALL h5sselect_elements_f(space_id, H5S_SELECT_SET_F, rank, num_points,&
+ coord, error)
+ CALL h5rcreate_f(file_id, dsetnamev, space_id, ref(2), error)
+ !
+ ! Write dataset with the references.
+ !
+ ref_size = size(ref)
+ CALL h5dwrite_f(dsetr_id, H5T_STD_REF_DSETREG, ref, ref_size, error)
+ !
+ ! Close all objects.
+ !
+ CALL h5sclose_f(space_id, error)
+ CALL h5sclose_f(spacer_id, error)
+ CALL h5dclose_f(dsetr_id, error)
+ CALL h5fclose_f(file_id, error)
+ !
+ ! Reopen the file to test selections.
+ !
+ CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error)
+ CALL h5dopen_f(file_id, dsetnamer, dsetr_id, error)
+ !
+ ! Read references to the dataset regions.
+ !
+ ref_size = size(ref_out)
+ CALL h5dread_f(dsetr_id, H5T_STD_REF_DSETREG, ref_out, ref_size, error)
+ !
+ ! Dereference the first reference.
+ !
+ CALL H5rdereference_f(dsetr_id, ref_out(1), dsetv_id, error)
+ CALL H5rget_region_f(dsetr_id, ref_out(1), space_id, error)
+ !
+ ! Read selected data from the dataset.
+ !
+ CALL h5dread_f(dsetv_id, H5T_NATIVE_INTEGER, data_out, error, &
+ mem_space_id = space_id, file_space_id = space_id)
+ write(*,*) "Hypeslab selection"
+ write(*,*)
+ do i = 1,2
+ write(*,*) (data_out (i,j), j = 1,9)
+ enddo
+ write(*,*)
+ CALL h5sclose_f(space_id, error)
+ CALL h5dclose_f(dsetv_id, error)
+ data_out = 0
+ !
+ ! Dereference the second reference.
+ !
+ CALL H5rdereference_f(dsetr_id, ref_out(2), dsetv_id, error)
+ CALL H5rget_region_f(dsetr_id, ref_out(2), space_id, error)
+ !
+ ! Read selected data from the dataset.
+ !
+ CALL h5dread_f(dsetv_id, H5T_NATIVE_INTEGER, data_out, error, &
+ mem_space_id = space_id, file_space_id = space_id)
+ write(*,*) "Point selection"
+ write(*,*)
+ do i = 1,2
+ write(*,*) (data_out (i,j), j = 1,9)
+ enddo
+ !
+ ! Close all objects
+ !
+ CALL h5sclose_f(space_id, error)
+ CALL h5dclose_f(dsetv_id, error)
+ CALL h5dclose_f(dsetr_id, error)
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM REG_REFERENCE
+
+
diff --git a/doc/html/Tutor/examples/rwdsetexample.f90 b/doc/html/Tutor/examples/rwdsetexample.f90
new file mode 100644
index 0000000..729e84d
--- /dev/null
+++ b/doc/html/Tutor/examples/rwdsetexample.f90
@@ -0,0 +1,78 @@
+!
+! The following example shows how to write and read to/from an existing dataset.
+! It opens the file created in the previous example, obtains the dataset
+! identifier, writes the data to the dataset in the file,
+! then reads the dataset to memory.
+!
+
+
+ PROGRAM RWDSETEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name
+ CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: dset_id ! Dataset identifier
+
+ INTEGER :: error ! Error flag
+ INTEGER :: i, j
+
+ INTEGER, DIMENSION(4,6) :: dset_data, data_out ! Data buffers
+
+ !
+ ! Initialize the dset_data array.
+ !
+ do i = 1, 4
+ do j = 1, 6
+ dset_data(i,j) = (i-1)*6 + j;
+ end do
+ end do
+
+ !
+ ! Initialize FORTRAN predefined datatypes
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Open an existing file.
+ !
+ CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error)
+
+ !
+ ! Open an existing dataset.
+ !
+ CALL h5dopen_f(file_id, dsetname, dset_id, error)
+
+ !
+ ! Write the dataset.
+ !
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, error)
+
+ !
+ ! Read the dataset.
+ !
+ CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, error)
+
+ !
+ ! Close the dataset.
+ !
+ CALL h5dclose_f(dset_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN predefined datatypes.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM RWDSETEXAMPLE
+
+
+
diff --git a/doc/html/Tutor/examples/selectele.f90 b/doc/html/Tutor/examples/selectele.f90
new file mode 100644
index 0000000..4bb8929
--- /dev/null
+++ b/doc/html/Tutor/examples/selectele.f90
@@ -0,0 +1,282 @@
+!
+! This program creates two files, copy1.h5, and copy2.h5.
+! In copy1.h5, it creates a 3x4 dataset called 'Copy1',
+! and write 0's to this dataset.
+! In copy2.h5, it create a 3x4 dataset called 'Copy2',
+! and write 1's to this dataset.
+! It closes both files, reopens both files, selects two
+! points in copy1.h5 and writes values to them. Then it
+! uses an H5Scopy to write the same selection to copy2.h5.
+! Program reopens the files, and reads and prints the contents of
+! the two datasets.
+!
+
+ PROGRAM SELECTEXAMPLE
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=8), PARAMETER :: filename1 = "copy1.h5" ! File name
+ CHARACTER(LEN=8), PARAMETER :: filename2 = "copy2.h5" !
+ CHARACTER(LEN=5), PARAMETER :: dsetname1 = "Copy1" ! Dataset name
+ CHARACTER(LEN=5), PARAMETER :: dsetname2 = "Copy2" !
+
+ INTEGER, PARAMETER :: RANK = 2 ! Dataset rank
+
+ INTEGER, PARAMETER :: NUMP = 2 ! Number of points selected
+
+ INTEGER(HID_T) :: file1_id ! File1 identifier
+ INTEGER(HID_T) :: file2_id ! File2 identifier
+ INTEGER(HID_T) :: dset1_id ! Dataset1 identifier
+ INTEGER(HID_T) :: dset2_id ! Dataset2 identifier
+ INTEGER(HID_T) :: dataspace1 ! Dataspace identifier
+ INTEGER(HID_T) :: dataspace2 ! Dataspace identifier
+ INTEGER(HID_T) :: memspace ! memspace identifier
+
+ INTEGER(HSIZE_T), DIMENSION(1) :: dimsm = (/2/)
+ ! Memory dataspace dimensions
+ INTEGER(HSIZE_T), DIMENSION(2) :: dimsf = (/3,4/)
+ ! File dataspace dimensions
+ INTEGER(HSSIZE_T), DIMENSION(RANK,NUMP) :: coord ! Elements coordinates
+ ! in the file
+
+ INTEGER, DIMENSION(3,4) :: buf1, buf2, bufnew ! Data buffers
+ INTEGER, DIMENSION(2) :: val = (/53, 59/) ! Values to write
+
+ INTEGER :: memrank = 1 ! Rank of the dataset in memory
+
+ INTEGER :: i, j
+
+ INTEGER :: error ! Error flag
+ LOGICAL :: status
+
+
+ !
+ ! Create two files containing identical datasets. Write 0's to one
+ ! and 1's to the other.
+ !
+
+ !
+ ! Data initialization.
+ !
+ do i = 1, 3
+ do j = 1, 4
+ buf1(i,j) = 0;
+ end do
+ end do
+
+ do i = 1, 3
+ do j = 1, 4
+ buf2(i,j) = 1;
+ end do
+ end do
+
+ !
+ ! Initialize FORTRAN predefined datatypes
+ !
+ CALL h5open_f(error)
+
+ !
+ ! Create file1, file2 using default properties.
+ !
+ CALL h5fcreate_f(filename1, H5F_ACC_TRUNC_F, file1_id, error)
+
+ CALL h5fcreate_f(filename2, H5F_ACC_TRUNC_F, file2_id, error)
+
+ !
+ ! Create the data space for the datasets.
+ !
+ CALL h5screate_simple_f(RANK, dimsf, dataspace1, error)
+
+ CALL h5screate_simple_f(RANK, dimsf, dataspace2, error)
+
+ !
+ ! Create the datasets with default properties.
+ !
+ CALL h5dcreate_f(file1_id, dsetname1, H5T_NATIVE_INTEGER, dataspace1, &
+ dset1_id, error)
+
+ CALL h5dcreate_f(file2_id, dsetname2, H5T_NATIVE_INTEGER, dataspace2, &
+ dset2_id, error)
+
+ !
+ ! Write the datasets.
+ !
+ CALL h5dwrite_f(dset1_id, H5T_NATIVE_INTEGER, buf1, error)
+
+ CALL h5dwrite_f(dset2_id, H5T_NATIVE_INTEGER, buf2, error)
+
+ !
+ ! Close the dataspace for the datasets.
+ !
+ CALL h5sclose_f(dataspace1, error)
+
+ CALL h5sclose_f(dataspace2, error)
+
+ !
+ ! Close the datasets.
+ !
+ CALL h5dclose_f(dset1_id, error)
+
+ CALL h5dclose_f(dset2_id, error)
+
+ !
+ ! Close the files.
+ !
+ CALL h5fclose_f(file1_id, error)
+
+ CALL h5fclose_f(file2_id, error)
+
+ !
+ ! Open the two files. Select two points in one file, write values to
+ ! those point locations, then do H5Scopy and write the values to the
+ ! other file. Close files.
+ !
+
+ !
+ ! Open the files.
+ !
+ CALL h5fopen_f (filename1, H5F_ACC_RDWR_F, file1_id, error)
+
+ CALL h5fopen_f (filename2, H5F_ACC_RDWR_F, file2_id, error)
+
+ !
+ ! Open the datasets.
+ !
+ CALL h5dopen_f(file1_id, dsetname1, dset1_id, error)
+
+ CALL h5dopen_f(file2_id, dsetname2, dset2_id, error)
+
+ !
+ ! Get dataset1's dataspace identifier.
+ !
+ CALL h5dget_space_f(dset1_id, dataspace1, error)
+
+ !
+ ! Create memory dataspace.
+ !
+ CALL h5screate_simple_f(memrank, dimsm, memspace, error)
+
+ !
+ ! Set the selected point positions. Because Fortran array index starts
+ ! from 1, so add one to the actual select points in C.
+ !
+ coord(1,1) = 1
+ coord(2,1) = 2
+ coord(1,2) = 1
+ coord(2,2) = 4
+
+ !
+ ! Select the elements in file space.
+ !
+ CALL h5sselect_elements_f(dataspace1, H5S_SELECT_SET_F, RANK, NUMP,&
+ coord, error)
+
+ !
+ ! Write value into the selected points in dataset1.
+ !
+ CALL H5dwrite_f(dset1_id, H5T_NATIVE_INTEGER, val, error, &
+ mem_space_id=memspace, file_space_id=dataspace1)
+
+ !
+ ! Copy the daspace1 into dataspace2.
+ !
+ CALL h5scopy_f(dataspace1, dataspace2, error)
+
+ !
+ ! Write value into the selected points in dataset2.
+ !
+ CALL H5dwrite_f(dset2_id, H5T_NATIVE_INTEGER, val, error, &
+ mem_space_id=memspace, file_space_id=dataspace2)
+
+ !
+ ! Close the dataspace for the datasets.
+ !
+ CALL h5sclose_f(dataspace1, error)
+
+ CALL h5sclose_f(dataspace2, error)
+
+ !
+ ! Close the memoryspace.
+ !
+ CALL h5sclose_f(memspace, error)
+
+ !
+ ! Close the datasets.
+ !
+ CALL h5dclose_f(dset1_id, error)
+
+ CALL h5dclose_f(dset2_id, error)
+
+ !
+ ! Close the files.
+ !
+ CALL h5fclose_f(file1_id, error)
+
+ CALL h5fclose_f(file2_id, error)
+
+ !
+ ! Open both files and print the contents of the datasets.
+ !
+
+ !
+ ! Open the files.
+ !
+ CALL h5fopen_f (filename1, H5F_ACC_RDWR_F, file1_id, error)
+
+ CALL h5fopen_f (filename2, H5F_ACC_RDWR_F, file2_id, error)
+
+ !
+ ! Open the datasets.
+ !
+ CALL h5dopen_f(file1_id, dsetname1, dset1_id, error)
+
+ CALL h5dopen_f(file2_id, dsetname2, dset2_id, error)
+
+ !
+ ! Read dataset from the first file.
+ !
+ CALL h5dread_f(dset1_id, H5T_NATIVE_INTEGER, bufnew, error)
+
+ !
+ ! Display the data read from dataset "Copy1"
+ !
+ write(*,*) "The data in dataset Copy1 is: "
+ do i = 1, 3
+ print *, (bufnew(i,j), j = 1,4)
+ end do
+
+ !
+ ! Read dataset from the second file.
+ !
+ CALL h5dread_f(dset2_id, H5T_NATIVE_INTEGER, bufnew, error)
+
+ !
+ ! Display the data read from dataset "Copy2"
+ !
+ write(*,*) "The data in dataset Copy2 is: "
+ do i = 1, 3
+ print *, (bufnew(i,j), j = 1,4)
+ end do
+
+ !
+ ! Close datasets.
+ !
+ CALL h5dclose_f(dset1_id, error)
+
+ CALL h5dclose_f(dset2_id, error)
+
+ !
+ ! Close files.
+ !
+ CALL h5fclose_f(file1_id, error)
+
+ CALL h5fclose_f(file2_id, error)
+
+ !
+ ! Close FORTRAN predefined datatypes.
+ !
+ CALL h5close_f(error)
+
+ END PROGRAM SELECTEXAMPLE