summaryrefslogtreecommitdiffstats
path: root/fortran/examples
diff options
context:
space:
mode:
Diffstat (limited to 'fortran/examples')
-rw-r--r--fortran/examples/Makefile.am37
-rw-r--r--fortran/examples/Makefile.in41
-rw-r--r--fortran/examples/attrexample.f90117
-rw-r--r--fortran/examples/dsetexample.f9085
-rw-r--r--fortran/examples/fileexample.f9049
-rw-r--r--fortran/examples/grpdsetexample.f90156
-rw-r--r--fortran/examples/grpsexample.f9083
-rw-r--r--fortran/examples/h5_crtatt.f90106
-rw-r--r--fortran/examples/h5_crtdat.f9086
-rw-r--r--fortran/examples/h5_crtgrp.f90 (renamed from fortran/examples/groupexample.f90)68
-rw-r--r--fortran/examples/h5_crtgrpar.f9083
-rw-r--r--fortran/examples/h5_crtgrpd.f90155
-rw-r--r--fortran/examples/h5_extend.f90233
-rw-r--r--fortran/examples/h5_rdwt.f9096
-rw-r--r--fortran/examples/h5_subset.f90186
-rw-r--r--fortran/examples/run-fortran-ex.sh.in30
-rw-r--r--fortran/examples/rwdsetexample.f9096
17 files changed, 1035 insertions, 672 deletions
diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am
index 310c4e2..867d891 100644
--- a/fortran/examples/Makefile.am
+++ b/fortran/examples/Makefile.am
@@ -32,14 +32,14 @@ endif
# We don't tell automake about these programs so that it doesn't try to
# compile them with the regular fortran compiler.
-EXAMPLE_PROG=dsetexample fileexample rwdsetexample attrexample groupexample \
- grpsexample grpdsetexample hyperslab selectele refobjexample \
- refregexample mountexample compound
+EXAMPLE_PROG=h5_crtdat h5_rdwt h5_crtatt h5_crtgrp \
+ h5_crtgrpar h5_crtgrpd h5_extend h5_subset hyperslab selectele \
+ refobjexample refregexample mountexample compound
# List files to be installed here
-INSTALL_FILES=dsetexample.f90 fileexample.f90 rwdsetexample.f90 \
- attrexample.f90 groupexample.f90 grpsexample.f90 grpdsetexample.f90 \
- hyperslab.f90 selectele.f90 refobjexample.f90 \
+INSTALL_FILES=h5_crtdat.f90 h5_rdwt.f90 \
+ h5_crtatt.f90 h5_crtgrp.f90 h5_crtgrpar.f90 h5_crtgrpd.f90 \
+ h5_extend.f90 h5_subset.f90 hyperslab.f90 selectele.f90 refobjexample.f90 \
refregexample.f90 mountexample.f90 compound.f90 ph5example.f90
INSTALL_SCRIPT_FILES = run-fortran-ex.sh
@@ -57,12 +57,12 @@ TEST_SCRIPT=testh5fc.sh
FORTRAN_API=yes
# Some examples depend on files created by other examples.
-grpdsetexample.chkexe_: grpsexample.chkexe_
+h5_crtgrpd.chkexe_: h5_crtgrpar.chkexe_
refregexample.chkexe_: refobjexample.chkexe_
-# rwdsetexample and attrexample both modify the same file created by
-# dsetexample. Serialize them.
-rwdsetexample.chkexe_: dsetexample.chkexe_
-attrexample.chkexe_: rwdsetexample.chkexe_
+# h5_rdwt and h5_crtatt both modify the same file created by
+# h5_crtdat. Serialize them.
+h5_rdwt.chkexe_: h5_crtdat.chkexe_
+h5_crtatt.chkexe_: h5_rdwt.chkexe_
# Tell automake how to build examples using h5fc
# Additional dependencies for the examples are listed below
@@ -84,13 +84,14 @@ EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/fortran
# an inelegant way of solving the problem.
# All programs share the same build rule and a dependency on the main hdf5
# and fortran libraries above.
-dsetexample: dsetexample.f90
-fileexample: fileexample.f90
-rwdsetexample: rwdsetexample.f90
-attrexample: attrexample.f90
-groupexample: groupexample.f90
-grpsexample: grpsexample.f90
-grpdsetexample: grpdsetexample.f90
+h5_crtdat: h5_crtdat.f90
+h5_extend: h5_extend.f90
+h5_subset: h5_subset.f90
+h5_rdwt: h5_rdwt.f90
+h5_crtatt: h5_crtatt.f90
+h5_crtgrp: h5_crtgrp.f90
+h5_crtgrpar: h5_crtgrpar.f90
+h5_crtgrpd: h5_crtgrpd.f90
hyperslab: hyperslab.f90
selectele: selectele.f90
refobjexample: refobjexample.f90
diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in
index 21adf62..a0eb2c4 100644
--- a/fortran/examples/Makefile.in
+++ b/fortran/examples/Makefile.in
@@ -70,7 +70,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/run-fortran-ex.sh.in $(srcdir)/testh5fc.sh.in \
$(top_srcdir)/bin/mkinstalldirs \
$(top_srcdir)/config/commence.am \
@@ -405,17 +405,17 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5
# be run.
# We don't tell automake about these programs so that it doesn't try to
# compile them with the regular fortran compiler.
-EXAMPLE_PROG = dsetexample fileexample rwdsetexample attrexample \
- groupexample grpsexample grpdsetexample hyperslab selectele \
+EXAMPLE_PROG = h5_crtdat h5_rdwt h5_crtatt h5_crtgrp h5_crtgrpar \
+ h5_crtgrpd h5_extend h5_subset hyperslab selectele \
refobjexample refregexample mountexample compound \
$(am__append_1)
# List files to be installed here
-INSTALL_FILES = dsetexample.f90 fileexample.f90 rwdsetexample.f90 \
- attrexample.f90 groupexample.f90 grpsexample.f90 \
- grpdsetexample.f90 hyperslab.f90 selectele.f90 \
- refobjexample.f90 refregexample.f90 mountexample.f90 \
- compound.f90 ph5example.f90 $(am__append_2)
+INSTALL_FILES = h5_crtdat.f90 h5_rdwt.f90 h5_crtatt.f90 h5_crtgrp.f90 \
+ h5_crtgrpar.f90 h5_crtgrpd.f90 h5_extend.f90 h5_subset.f90 \
+ hyperslab.f90 selectele.f90 refobjexample.f90 \
+ refregexample.f90 mountexample.f90 compound.f90 ph5example.f90 \
+ $(am__append_2)
INSTALL_SCRIPT_FILES = run-fortran-ex.sh
TEST_SCRIPT = testh5fc.sh
@@ -668,12 +668,12 @@ help:
@$(top_srcdir)/bin/makehelp
# Some examples depend on files created by other examples.
-grpdsetexample.chkexe_: grpsexample.chkexe_
+h5_crtgrpd.chkexe_: h5_crtgrpar.chkexe_
refregexample.chkexe_: refobjexample.chkexe_
-# rwdsetexample and attrexample both modify the same file created by
-# dsetexample. Serialize them.
-rwdsetexample.chkexe_: dsetexample.chkexe_
-attrexample.chkexe_: rwdsetexample.chkexe_
+# h5_rdwt and h5_crtatt both modify the same file created by
+# h5_crtdat. Serialize them.
+h5_rdwt.chkexe_: h5_crtdat.chkexe_
+h5_crtatt.chkexe_: h5_rdwt.chkexe_
# Tell automake how to build examples using h5fc
# Additional dependencies for the examples are listed below
@@ -688,13 +688,14 @@ attrexample.chkexe_: rwdsetexample.chkexe_
# an inelegant way of solving the problem.
# All programs share the same build rule and a dependency on the main hdf5
# and fortran libraries above.
-dsetexample: dsetexample.f90
-fileexample: fileexample.f90
-rwdsetexample: rwdsetexample.f90
-attrexample: attrexample.f90
-groupexample: groupexample.f90
-grpsexample: grpsexample.f90
-grpdsetexample: grpdsetexample.f90
+h5_crtdat: h5_crtdat.f90
+h5_extend: h5_extend.f90
+h5_subset: h5_subset.f90
+h5_rdwt: h5_rdwt.f90
+h5_crtatt: h5_crtatt.f90
+h5_crtgrp: h5_crtgrp.f90
+h5_crtgrpar: h5_crtgrpar.f90
+h5_crtgrpd: h5_crtgrpd.f90
hyperslab: hyperslab.f90
selectele: selectele.f90
refobjexample: refobjexample.f90
diff --git a/fortran/examples/attrexample.f90 b/fortran/examples/attrexample.f90
deleted file mode 100644
index ffbeabe..0000000
--- a/fortran/examples/attrexample.f90
+++ /dev/null
@@ -1,117 +0,0 @@
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-! Copyright by The HDF Group. *
-! Copyright by the Board of Trustees of the University of Illinois. *
-! All rights reserved. *
-! *
-! This file is part of HDF5. The full HDF5 copyright notice, including *
-! terms governing use, modification, and redistribution, is contained in *
-! the files COPYING and Copyright.html. COPYING can be found at the root *
-! of the source code distribution tree; Copyright.html can be found at the *
-! root level of an installed copy of the electronic HDF5 document set and *
-! is linked from the top-level documents page. It can also be found at *
-! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-! access to either file, you may request a copy from help@hdfgroup.org. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-! This example shows how to create and write a dataset attribute.
-! It opens the existing file 'dset.h5', obtains the identifier of
-! the dataset "/dset", defines attribute's dataspace,
-! creates dataset attribute, writes the attribute, and then closes
-! the attribute's dataspace, attribute, dataset, and file.
-
- PROGRAM ATTREXAMPLE
-
-
- 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
- CHARACTER(LEN=9), PARAMETER :: aname = "attr_long" ! Attribute name
-
- INTEGER(HID_T) :: file_id ! File identifier
- INTEGER(HID_T) :: dset_id ! Dataset identifier
- INTEGER(HID_T) :: attr_id ! Attribute identifier
- INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier
- INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier
- INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/2/) ! Attribute dimension
- INTEGER :: arank = 1 ! Attribure rank
- INTEGER(SIZE_T) :: attrlen ! Length of the attribute string
-
- CHARACTER(LEN=80), DIMENSION(2) :: attr_data ! Attribute data
-
- INTEGER :: error ! Error flag
- INTEGER(HSIZE_T), DIMENSION(1) :: data_dims
-
-
- !
- ! Initialize attribute's data
- !
- attr_data(1) = "Dataset character attribute"
- attr_data(2) = "Some other string here "
- attrlen = 80
- !
- ! Initialize FORTRAN interface.
- !
- 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)
-
- !
- ! Create scalar data space for the attribute.
- !
- CALL h5screate_simple_f(arank, adims, aspace_id, error)
- !
- ! Create datatype for the attribute.
- !
- CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, error)
- CALL h5tset_size_f(atype_id, attrlen, error)
-
- !
- ! Create dataset attribute.
- !
- CALL h5acreate_f(dset_id, aname, atype_id, aspace_id, &
- attr_id, error)
-
- !
- ! Write the attribute data.
- !
- data_dims(1) = 2
- CALL h5awrite_f(attr_id, atype_id, attr_data, data_dims, error)
-
- !
- ! Close the attribute.
- !
- CALL h5aclose_f(attr_id, error)
-
- !
- ! Terminate access to the data space.
- !
- CALL h5sclose_f(aspace_id, error)
-
- !
- ! End access to the dataset and release resources used by it.
- !
- CALL h5dclose_f(dset_id, error)
-
- !
- ! Close the file.
- !
- CALL h5fclose_f(file_id, error)
-
- !
- ! Close FORTRAN interface.
- !
- CALL h5close_f(error)
-
- END PROGRAM ATTREXAMPLE
-
diff --git a/fortran/examples/dsetexample.f90 b/fortran/examples/dsetexample.f90
deleted file mode 100644
index 209a516..0000000
--- a/fortran/examples/dsetexample.f90
+++ /dev/null
@@ -1,85 +0,0 @@
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-! Copyright by The HDF Group. *
-! Copyright by the Board of Trustees of the University of Illinois. *
-! All rights reserved. *
-! *
-! This file is part of HDF5. The full HDF5 copyright notice, including *
-! terms governing use, modification, and redistribution, is contained in *
-! the files COPYING and Copyright.html. COPYING can be found at the root *
-! of the source code distribution tree; Copyright.html can be found at the *
-! root level of an installed copy of the electronic HDF5 document set and *
-! is linked from the top-level documents page. It can also be found at *
-! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-! access to either file, you may request a copy from help@hdfgroup.org. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-!
-! The following example shows how to create an empty dataset.
-! It creates a file called 'dsetf.h5', defines the
-! dataset dataspace, creates a dataset which is a 4x6 integer array,
-! and then closes the dataspace, the dataset, and the file.
-!
-
- PROGRAM DSETEXAMPLE
-
- 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(HID_T) :: dspace_id ! Dataspace identifier
-
-
- INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions
- INTEGER :: rank = 2 ! Dataset rank
-
- 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 the dataspace.
- !
- CALL h5screate_simple_f(rank, dims, dspace_id, error)
-
- !
- ! Create the dataset with default properties.
- !
- CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, &
- dset_id, error)
-
- !
- ! End access to the dataset and release resources used by it.
- !
- CALL h5dclose_f(dset_id, error)
-
- !
- ! Terminate access to the data space.
- !
- CALL h5sclose_f(dspace_id, error)
-
- !
- ! Close the file.
- !
- CALL h5fclose_f(file_id, error)
-
- !
- ! Close FORTRAN interface.
- !
- CALL h5close_f(error)
-
- END PROGRAM DSETEXAMPLE
-
-
diff --git a/fortran/examples/fileexample.f90 b/fortran/examples/fileexample.f90
deleted file mode 100644
index 87119d2..0000000
--- a/fortran/examples/fileexample.f90
+++ /dev/null
@@ -1,49 +0,0 @@
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-! Copyright by The HDF Group. *
-! Copyright by the Board of Trustees of the University of Illinois. *
-! All rights reserved. *
-! *
-! This file is part of HDF5. The full HDF5 copyright notice, including *
-! terms governing use, modification, and redistribution, is contained in *
-! the files COPYING and Copyright.html. COPYING can be found at the root *
-! of the source code distribution tree; Copyright.html can be found at the *
-! root level of an installed copy of the electronic HDF5 document set and *
-! is linked from the top-level documents page. It can also be found at *
-! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-! access to either file, you may request a copy from help@hdfgroup.org. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-!
-! The following example demonstrates how to create and close an HDF5 file.
-! It creates a file called 'file.h5', and then closes the file.
-!
-
- PROGRAM FILEEXAMPLE
-
- USE HDF5 ! This module contains all necessary modules
-
- IMPLICIT NONE
-
- CHARACTER(LEN=8), PARAMETER :: filename = "filef.h5" ! File name
- INTEGER(HID_T) :: file_id ! File identifier
-
- 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)
-
- !
- ! Terminate access to the file.
- !
- CALL h5fclose_f(file_id, error)
-!
-! Close FORTRAN interface.
-!
- CALL h5close_f(error)
- END PROGRAM FILEEXAMPLE
diff --git a/fortran/examples/grpdsetexample.f90 b/fortran/examples/grpdsetexample.f90
deleted file mode 100644
index 19fc660..0000000
--- a/fortran/examples/grpdsetexample.f90
+++ /dev/null
@@ -1,156 +0,0 @@
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-! Copyright by The HDF Group. *
-! Copyright by the Board of Trustees of the University of Illinois. *
-! All rights reserved. *
-! *
-! This file is part of HDF5. The full HDF5 copyright notice, including *
-! terms governing use, modification, and redistribution, is contained in *
-! the files COPYING and Copyright.html. COPYING can be found at the root *
-! of the source code distribution tree; Copyright.html can be found at the *
-! root level of an installed copy of the electronic HDF5 document set and *
-! is linked from the top-level documents page. It can also be found at *
-! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-! access to either file, you may request a copy from help@hdfgroup.org. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-!
-! 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(HSIZE_T), DIMENSION(2) :: data_dims
-
- 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)
-
- !
- ! 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.
- !
- data_dims(1) = 3
- data_dims(2) = 3
- CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset1_data, data_dims, 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.
- !
- data_dims(1) = 2
- data_dims(1) = 10
- CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset2_data, data_dims, 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 interface.
- !
- CALL h5close_f(error)
-
- END PROGRAM GRPDSETEXAMPLE
diff --git a/fortran/examples/grpsexample.f90 b/fortran/examples/grpsexample.f90
deleted file mode 100644
index 0f694e9..0000000
--- a/fortran/examples/grpsexample.f90
+++ /dev/null
@@ -1,83 +0,0 @@
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-! Copyright by The HDF Group. *
-! Copyright by the Board of Trustees of the University of Illinois. *
-! All rights reserved. *
-! *
-! This file is part of HDF5. The full HDF5 copyright notice, including *
-! terms governing use, modification, and redistribution, is contained in *
-! the files COPYING and Copyright.html. COPYING can be found at the root *
-! of the source code distribution tree; Copyright.html can be found at the *
-! root level of an installed copy of the electronic HDF5 document set and *
-! is linked from the top-level documents page. It can also be found at *
-! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-! access to either file, you may request a copy from help@hdfgroup.org. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-!
-! 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/fortran/examples/h5_crtatt.f90 b/fortran/examples/h5_crtatt.f90
new file mode 100644
index 0000000..79bc576
--- /dev/null
+++ b/fortran/examples/h5_crtatt.f90
@@ -0,0 +1,106 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+! This example shows how to create and write a dataset attribute.
+! It opens the existing file 'dset.h5', obtains the identifier of
+! the dataset "/dset", defines attribute's dataspace,
+! creates dataset attribute, writes the attribute, and then closes
+! the attribute's dataspace, attribute, dataset, and file.
+!
+! This example is used in the HDF5 Tutorial.
+
+PROGRAM H5_CRTATT
+
+ 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
+ CHARACTER(LEN=9), PARAMETER :: aname = "attr_long" ! Attribute name
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: dset_id ! Dataset identifier
+ INTEGER(HID_T) :: attr_id ! Attribute identifier
+ INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier
+ INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier
+ INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/2/) ! Attribute dimension
+ INTEGER :: arank = 1 ! Attribure rank
+ INTEGER(SIZE_T) :: attrlen ! Length of the attribute string
+
+ CHARACTER(LEN=80), DIMENSION(2) :: attr_data ! Attribute data
+
+ INTEGER :: error ! Error flag
+ INTEGER(HSIZE_T), DIMENSION(1) :: data_dims
+
+ !
+ ! Initialize attribute's data
+ !
+ attr_data(1) = "Dataset character attribute"
+ attr_data(2) = "Some other string here "
+ attrlen = 80
+ !
+ ! Initialize FORTRAN interface.
+ !
+ 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)
+ !
+ ! Create scalar data space for the attribute.
+ !
+ CALL h5screate_simple_f(arank, adims, aspace_id, error)
+ !
+ ! Create datatype for the attribute.
+ !
+ CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, error)
+ CALL h5tset_size_f(atype_id, attrlen, error)
+ !
+ ! Create dataset attribute.
+ !
+ CALL h5acreate_f(dset_id, aname, atype_id, aspace_id, attr_id, error)
+ !
+ ! Write the attribute data.
+ !
+ data_dims(1) = 2
+ CALL h5awrite_f(attr_id, atype_id, attr_data, data_dims, error)
+ !
+ ! Close the attribute.
+ !
+ CALL h5aclose_f(attr_id, error)
+ !
+ ! Terminate access to the data space.
+ !
+ CALL h5sclose_f(aspace_id, error)
+ !
+ ! End access to the dataset and release resources used by it.
+ !
+ CALL h5dclose_f(dset_id, error)
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+END PROGRAM H5_CRTATT
+
diff --git a/fortran/examples/h5_crtdat.f90 b/fortran/examples/h5_crtdat.f90
new file mode 100644
index 0000000..6e4c3a4
--- /dev/null
+++ b/fortran/examples/h5_crtdat.f90
@@ -0,0 +1,86 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+!
+! The following example shows how to create an empty dataset.
+! It creates a file called 'dsetf.h5', defines the
+! dataset dataspace, creates a dataset which is a 4x6 integer array,
+! and then closes the dataspace, the dataset, and the file.
+!
+! This example is used in the HDF5 Tutorial.
+
+PROGRAM H5_CRTDAT
+
+ 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(HID_T) :: dspace_id ! Dataspace identifier
+
+
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions
+ INTEGER :: rank = 2 ! Dataset rank
+
+ 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 the dataspace.
+ !
+ CALL h5screate_simple_f(rank, dims, dspace_id, error)
+
+ !
+ ! Create the dataset with default properties.
+ !
+ CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, &
+ dset_id, error)
+
+ !
+ ! End access to the dataset and release resources used by it.
+ !
+ CALL h5dclose_f(dset_id, error)
+
+ !
+ ! Terminate access to the data space.
+ !
+ CALL h5sclose_f(dspace_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+END PROGRAM H5_CRTDAT
+
+
diff --git a/fortran/examples/groupexample.f90 b/fortran/examples/h5_crtgrp.f90
index 91ebc50..278d175 100644
--- a/fortran/examples/groupexample.f90
+++ b/fortran/examples/h5_crtgrp.f90
@@ -18,47 +18,47 @@
! It creates a file called 'group.h5', creates a group
! called MyGroup in the root group, and then closes the group and file.
!
+! This example is used in the HDF5 Tutorial.
+PROGRAM H5_CRTGRP
- PROGRAM GROUPEXAMPLE
+ USE HDF5 ! This module contains all necessary modules
- USE HDF5 ! This module contains all necessary modules
+ IMPLICIT NONE
- IMPLICIT NONE
+ CHARACTER(LEN=9), PARAMETER :: filename = "groupf.h5" ! File name
+ CHARACTER(LEN=7), PARAMETER :: groupname = "MyGroup" ! Group name
- CHARACTER(LEN=9), PARAMETER :: filename = "groupf.h5" ! File name
- CHARACTER(LEN=7), PARAMETER :: groupname = "MyGroup" ! Group name
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: group_id ! Group identifier
- INTEGER(HID_T) :: file_id ! File identifier
- INTEGER(HID_T) :: group_id ! Group identifier
+ 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)
- 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 a group named "/MyGroup" in the file.
- !
- CALL h5gcreate_f(file_id, groupname, group_id, error)
+ !
+ ! Create a group named "/MyGroup" in the file.
+ !
+ CALL h5gcreate_f(file_id, groupname, group_id, error)
- !
- ! Close the group.
- !
- CALL h5gclose_f(group_id, error)
+ !
+ ! Close the group.
+ !
+ CALL h5gclose_f(group_id, error)
- !
- ! Terminate access to the file.
- !
- CALL h5fclose_f(file_id, error)
-!
-! Close FORTRAN interface.
-!
- CALL h5close_f(error)
+ !
+ ! Terminate access to the file.
+ !
+ CALL h5fclose_f(file_id, error)
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
- END PROGRAM GROUPEXAMPLE
+END PROGRAM H5_CRTGRP
diff --git a/fortran/examples/h5_crtgrpar.f90 b/fortran/examples/h5_crtgrpar.f90
new file mode 100644
index 0000000..4ef008a
--- /dev/null
+++ b/fortran/examples/h5_crtgrpar.f90
@@ -0,0 +1,83 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+!
+! 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.
+!
+! This example is used in the HDF5 Tutorial.
+
+PROGRAM H5_CRTGRPAR
+
+ 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 H5_CRTGRPAR
diff --git a/fortran/examples/h5_crtgrpd.f90 b/fortran/examples/h5_crtgrpd.f90
new file mode 100644
index 0000000..d35f03d
--- /dev/null
+++ b/fortran/examples/h5_crtgrpd.f90
@@ -0,0 +1,155 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+!
+! 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.
+!
+! This example is used in the HDF5 Tutorial.
+
+PROGRAM H5_CRTGRPD
+
+ 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(HSIZE_T), DIMENSION(2) :: data_dims
+
+ 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)
+
+ !
+ ! 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.
+ !
+ data_dims(1) = 3
+ data_dims(2) = 3
+ CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset1_data, data_dims, 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.
+ !
+ data_dims(1) = 2
+ data_dims(1) = 10
+ CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, dset2_data, data_dims, 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 interface.
+ !
+ CALL h5close_f(error)
+
+END PROGRAM H5_CRTGRPD
diff --git a/fortran/examples/h5_extend.f90 b/fortran/examples/h5_extend.f90
new file mode 100644
index 0000000..306d837
--- /dev/null
+++ b/fortran/examples/h5_extend.f90
@@ -0,0 +1,233 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+! This example extends an HDF5 dataset. It is used in the HDF5 Tutorial.
+
+PROGRAM H5_EXTEND
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ !
+ !the dataset is stored in file "extend.h5"
+ !
+ CHARACTER(LEN=9), PARAMETER :: filename = "extend.h5"
+
+ !
+ !dataset rank is 2 and name is "ExtendibleArray"
+ !
+ CHARACTER(LEN=15), PARAMETER :: dsetname = "ExtendibleArray"
+ INTEGER :: RANK = 2
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: dset_id ! Dataset identifier
+ INTEGER(HID_T) :: dataspace ! Dataspace identifier
+ INTEGER(HID_T) :: memspace ! Memory dataspace identifier
+ INTEGER(HID_T) :: crp_list ! Dataset creation property identifier
+
+ !
+ !dataset dimensions at creation time
+ !
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: dims = (/3,3/)
+
+ !
+ !data dimensions
+ !
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsc = (/2,5/)
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsm = (/3,7/)
+
+ !
+ !Maximum dimensions
+ !
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: maxdims
+
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: offset
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: count
+
+ !
+ ! Variables for reading and writing
+ !
+ INTEGER, DIMENSION(1:3,1:3) :: data1
+ INTEGER, DIMENSION(1:21) :: data2 = &
+ (/2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4/)
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: data_dims
+
+ !
+ !Size of data in the file
+ !
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: size
+
+ !
+ !general purpose integer
+ !
+ INTEGER :: i, j
+
+ !
+ !flag to check operation success
+ !
+ INTEGER :: error
+
+ !
+ !Variables used in reading data back
+ !
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsr, maxdimsr
+ INTEGER :: rankr
+ INTEGER, DIMENSION(1:3,1:10) :: rdata
+
+ !
+ !Initialize FORTRAN predifined 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 with unlimited dimensions.
+ !
+ maxdims = (/H5S_UNLIMITED_F, H5S_UNLIMITED_F/)
+
+ CALL h5screate_simple_f(RANK, dims, dataspace, error, maxdims)
+
+ !
+ !Modify dataset creation properties, i.e. enable chunking
+ !
+ CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error)
+
+ CALL h5pset_chunk_f(crp_list, RANK, dimsc, error)
+
+ !
+ !Create a dataset with 3X3 dimensions using cparms creation propertie .
+ !
+ CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dataspace, &
+ dset_id, error, crp_list )
+ CALL h5sclose_f(dataspace, error)
+
+ !
+ !Fill data array with 1's
+ !
+ DO i = 1, dims(1)
+ DO j = 1, dims(2)
+ data1(i,j) = 1
+ END DO
+ END DO
+
+ !
+ !Write data array to dataset
+ !
+ data_dims(1:2) = (/3,3/)
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data1, data_dims, error)
+
+ !
+ !Extend the dataset. Dataset becomes 10 x 3.
+ !
+ size(1:2) = (/3,10/)
+ CALL h5dextend_f(dset_id, size, error)
+
+ offset(1:2) = (/0,3/)
+ count(1:2) = (/3,7/)
+
+ CALL h5screate_simple_f (2, dimsm, memspace, error)
+
+ !
+ !Write to 3x7 extended part of dataset
+ !
+ CALL h5dget_space_f(dset_id, dataspace, error)
+ CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, &
+ offset, count, error)
+
+ data_dims(1:2) = (/3,7/)
+ CALL H5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data2, data_dims, error, &
+ memspace, dataspace)
+
+ !
+ !Close the objects that were opened.
+ !
+ CALL h5sclose_f(dataspace, error)
+ CALL h5pclose_f(crp_list, error)
+ CALL h5dclose_f(dset_id, error)
+ CALL h5fclose_f(file_id, error)
+
+ !
+ !read the data back
+ !
+ !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 handle.
+ !
+ CALL h5dget_space_f(dset_id, dataspace, error)
+
+ !
+ !Get dataspace's rank.
+ !
+ CALL h5sget_simple_extent_ndims_f(dataspace, rankr, error)
+
+ !
+ !Get dataspace's dimensions.
+ !
+ CALL h5sget_simple_extent_dims_f(dataspace, dimsr, maxdimsr, error)
+
+ !
+ !Get creation property list.
+ !
+ CALL h5dget_create_plist_f(dset_id, crp_list, error)
+
+ !
+ ! Fill read buffer with zeroes
+ !
+ rdata(1:dimsr(1),1:dimsr(2)) = 0
+
+ !
+ !create memory dataspace
+ !
+ CALL h5screate_simple_f(rankr, dimsr, memspace, error)
+
+ !
+ !Read data
+ !
+ data_dims(1:2) = (/3,10/)
+ CALL H5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, data_dims, &
+ error, memspace, dataspace)
+
+ PRINT *,"Dataset:"
+ DO i = 1, dimsr(1)
+ PRINT *, rdata(i,1:dimsr(2))
+ END DO
+
+ !
+ !Close the objects that were opened.
+ !
+ CALL h5sclose_f(dataspace, error)
+ CALL h5sclose_f(memspace, error)
+ CALL h5pclose_f(crp_list, error)
+ CALL h5dclose_f(dset_id, error)
+ CALL h5fclose_f(file_id, error)
+
+ !Close FORTRAN predefined datatypes
+ !
+ CALL h5close_f(error)
+
+END PROGRAM H5_EXTEND
diff --git a/fortran/examples/h5_rdwt.f90 b/fortran/examples/h5_rdwt.f90
new file mode 100644
index 0000000..ba05b2f
--- /dev/null
+++ b/fortran/examples/h5_rdwt.f90
@@ -0,0 +1,96 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+!
+! 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.
+!
+! This example is used in the HDF5 Tutorial.
+
+PROGRAM H5_RDWT
+
+ 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
+ INTEGER(HSIZE_T), DIMENSION(2) :: data_dims
+
+ !
+ ! 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 interface.
+ !
+ 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.
+ !
+ data_dims(1) = 4
+ data_dims(2) = 6
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, data_dims, error)
+
+ !
+ ! Read the dataset.
+ !
+ CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error)
+
+ !
+ ! Close the dataset.
+ !
+ CALL h5dclose_f(dset_id, error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+END PROGRAM H5_RDWT
+
+
+
diff --git a/fortran/examples/h5_subset.f90 b/fortran/examples/h5_subset.f90
new file mode 100644
index 0000000..a1203d4
--- /dev/null
+++ b/fortran/examples/h5_subset.f90
@@ -0,0 +1,186 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! Copyright by The HDF Group. *
+! Copyright by the Board of Trustees of the University of Illinois. *
+! All rights reserved. *
+! *
+! This file is part of HDF5. The full HDF5 copyright notice, including *
+! terms governing use, modification, and redistribution, is contained in *
+! the files COPYING and Copyright.html. COPYING can be found at the root *
+! of the source code distribution tree; Copyright.html can be found at the *
+! root level of an installed copy of the electronic HDF5 document set and *
+! is linked from the top-level documents page. It can also be found at *
+! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+! access to either file, you may request a copy from help@hdfgroup.org. *
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+!
+! This example shows how to write and read a hyperslab.
+! It is used in the HDF5 Tutorial.
+!
+
+PROGRAM H5_SUBSET
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+
+ CHARACTER(LEN=9), PARAMETER :: filename = "subset.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
+
+ !
+ ! To change the subset size, modify size of dimsm, sdata, dim0_sub,
+ ! dim1_sub, and count
+ !
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsm = (/4,3/) ! Dataset dimensions
+ INTEGER, DIMENSION(1:4,1:3) :: sdata ! Subset buffer
+ INTEGER :: dim0_sub = 4
+ INTEGER :: dim1_sub = 3
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: count = (/4,3/) ! Size of hyperslab
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: offset = (/2,1/) ! Hyperslab offset
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: stride = (/1,1/) ! Hyperslab stride
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: block = (/1,1/) ! Hyperslab block size
+
+ INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsf = (/10,8/) ! Dataset dimensions
+
+
+ INTEGER, DIMENSION(1:10,1:8) :: data ! Data to write
+ INTEGER, DIMENSION(1:10,1:8) :: rdata ! Data to read
+
+ INTEGER :: rank = 2 ! Dataset rank ( in file )
+ INTEGER :: dim0 = 10 ! Dataset size in file
+ INTEGER :: dim1 = 8
+
+ INTEGER :: i, j
+
+ INTEGER :: error ! Error flag
+ INTEGER(HSIZE_T), DIMENSION(2) :: data_dims
+
+ !
+ ! Write data to the HDF5 file.
+ !
+
+ !
+ ! Data initialization.
+ !
+ DO i = 1, dim0
+ DO j = 1, dim1
+ IF (i .LE. (dim0 / 2)) THEN
+ data(i,j) = 1
+ ELSE
+ data(i,j) = 2
+ END IF
+ 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 the data space for the dataset.
+ !
+ CALL h5screate_simple_f(rank, 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.
+ !
+ data_dims(1) = dim0
+ data_dims(2) = dim1
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, data_dims, error)
+
+ !
+ ! Data Written to File
+ !
+ PRINT*, "Original Data Written to File:"
+ DO i = 1, dim0
+ PRINT*, DATA(i,1:dim1)
+ END DO
+ PRINT*, " "
+
+ !
+ !
+ ! Close the dataspace, dataset, and file.
+ !
+ CALL h5sclose_f(dataspace, error)
+ CALL h5dclose_f(dset_id, error)
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Initialize subset data array.
+ !
+ sdata(1:dim0_sub,1:dim1_sub) = 5
+
+ !
+ ! Open the file.
+ !
+ CALL h5fopen_f(filename, H5F_ACC_RDWR_F, file_id, error)
+
+ !
+ ! Open the dataset.
+ !
+ CALL h5dopen_f(file_id, dsetname, dset_id, error)
+
+ !
+ ! Get dataset's dataspace identifier and select subset.
+ !
+ CALL h5dget_space_f(dset_id, dataspace, error)
+ CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, &
+ offset, count, error, stride, BLOCK)
+ !
+ ! Create memory dataspace.
+ !
+ CALL h5screate_simple_f(rank, dimsm, memspace, error)
+
+ PRINT *,"Write subset to file specifying:"
+ PRINT *, " offset=1x2 stride=1x1 count=3x4 block=1x1"
+
+ !
+ ! Write subset to dataset
+ !
+ data_dims(1:2) = (/dim0_sub, dim1_sub/)
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, sdata, data_dims, error, &
+ memspace, dataspace)
+
+ data_dims(1:2) = (/dim0, dim1/)
+ CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, data_dims, error, &
+ H5S_ALL_F, H5S_ALL_F)
+
+ !
+ ! Read entire dataset back
+ !
+ PRINT *,"Data in File after Subset Written:"
+ DO i = 1, dim0
+ PRINT *,rdata(i,1:dim1)
+ END DO
+ PRINT *, " "
+
+ !
+ ! Close everything opened.
+ !
+ CALL h5sclose_f(dataspace, error)
+ CALL h5sclose_f(memspace, error)
+ CALL h5dclose_f(dset_id, error)
+ CALL h5fclose_f(file_id, error)
+
+ !
+ ! Close FORTRAN interface.
+ !
+ CALL h5close_f(error)
+
+END PROGRAM H5_SUBSET
diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in
index 873669f..23c2266 100644
--- a/fortran/examples/run-fortran-ex.sh.in
+++ b/fortran/examples/run-fortran-ex.sh.in
@@ -70,20 +70,22 @@ RunTest()
# Run tests
if [ $? -eq 0 ]
then
- if (RunTest dsetexample &&\
- rm dsetexample &&\
- RunTest fileexample &&\
- rm fileexample &&\
- RunTest rwdsetexample &&\
- rm rwdsetexample &&\
- RunTest attrexample &&\
- rm attrexample &&\
- RunTest groupexample &&\
- rm groupexample &&\
- RunTest grpsexample &&\
- rm grpsexample &&\
- RunTest grpdsetexample &&\
- rm grpdsetexample &&\
+ if (RunTest h5_crtdat &&\
+ rm h5_crtdat &&\
+ RunTest h5_extend &&\
+ rm h5_extend &&\
+ RunTest h5_rdwt &&\
+ rm h5_rdwt &&\
+ RunTest h5_crtatt &&\
+ rm h5_crtatt &&\
+ RunTest h5_crtgrp &&\
+ rm h5_crtgrp &&\
+ RunTest h5_crtgrpar &&\
+ rm h5_crtgrpar &&\
+ RunTest h5_crtgrpd &&\
+ rm h5_crtgrpd &&\
+ RunTest h5_subset &&\
+ rm h5_subset &&\
RunTest hyperslab &&\
rm hyperslab &&\
RunTest selectele &&\
diff --git a/fortran/examples/rwdsetexample.f90 b/fortran/examples/rwdsetexample.f90
deleted file mode 100644
index 1e84e23..0000000
--- a/fortran/examples/rwdsetexample.f90
+++ /dev/null
@@ -1,96 +0,0 @@
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-! Copyright by The HDF Group. *
-! Copyright by the Board of Trustees of the University of Illinois. *
-! All rights reserved. *
-! *
-! This file is part of HDF5. The full HDF5 copyright notice, including *
-! terms governing use, modification, and redistribution, is contained in *
-! the files COPYING and Copyright.html. COPYING can be found at the root *
-! of the source code distribution tree; Copyright.html can be found at the *
-! root level of an installed copy of the electronic HDF5 document set and *
-! is linked from the top-level documents page. It can also be found at *
-! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-! access to either file, you may request a copy from help@hdfgroup.org. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-!
-! 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
- INTEGER(HSIZE_T), DIMENSION(2) :: data_dims
-
- !
- ! 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 interface.
- !
- 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.
- !
- data_dims(1) = 4
- data_dims(2) = 6
- CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, data_dims, error)
-
- !
- ! Read the dataset.
- !
- CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error)
-
- !
- ! Close the dataset.
- !
- CALL h5dclose_f(dset_id, error)
-
- !
- ! Close the file.
- !
- CALL h5fclose_f(file_id, error)
-
- !
- ! Close FORTRAN interface.
- !
- CALL h5close_f(error)
-
- END PROGRAM RWDSETEXAMPLE
-
-
-