summaryrefslogtreecommitdiffstats
path: root/fortran/examples
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2013-03-15 05:08:29 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2013-03-15 05:08:29 (GMT)
commitc129390dfe2438988f4b43fc1d93b91989116731 (patch)
tree4617b95bafbfa14a55a6046bd27d666534e9d6bc /fortran/examples
parentf0769763b565784a959c855311c58933110c66ba (diff)
downloadhdf5-c129390dfe2438988f4b43fc1d93b91989116731.zip
hdf5-c129390dfe2438988f4b43fc1d93b91989116731.tar.gz
hdf5-c129390dfe2438988f4b43fc1d93b91989116731.tar.bz2
[svn-r23352] merged -r22826:23050 and -r23060:23351 from trunk into branch.
Tested: jam (gnu, intel)
Diffstat (limited to 'fortran/examples')
-rw-r--r--fortran/examples/CMakeLists.txt21
-rw-r--r--fortran/examples/Makefile.am41
-rw-r--r--fortran/examples/Makefile.in43
-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/grpit.f90215
-rw-r--r--fortran/examples/grpsexample.f9083
-rw-r--r--fortran/examples/h5_cmprss.f90131
-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.f90184
-rw-r--r--fortran/examples/run-fortran-ex.sh.in32
-rw-r--r--fortran/examples/rwdsetexample.f9096
20 files changed, 1180 insertions, 900 deletions
diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt
index 2d35f89..0536183 100644
--- a/fortran/examples/CMakeLists.txt
+++ b/fortran/examples/CMakeLists.txt
@@ -14,16 +14,17 @@ INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${HDF5_F90_BINARY_DIR} ${
# Define Sources
#-----------------------------------------------------------------------------
SET (examples
- dsetexample
- fileexample
- rwdsetexample
- attrexample
- groupexample
- grpsexample
- grpdsetexample
+ h5_cmprss
+ h5_crtdat
+ h5_rdwt
+ h5_crtatt
+ h5_crtgrp
+ h5_crtgrpar
+ h5_crtgrpd
+ h5_extend
+ h5_subset
hyperslab
selectele
- grpit
refobjexample
refregexample
mountexample
@@ -64,7 +65,7 @@ FOREACH (example ${examples})
ENDFOREACH (example ${examples})
-IF (FORTRAN_HAVE_ISO_C_BINDING AND HDF5_ENABLE_F2003)
+IF (HDF5_ENABLE_F2003)
FOREACH (example ${F2003_examples})
ADD_EXECUTABLE (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
TARGET_NAMING (f03_ex_${example} ${LIB_TYPE})
@@ -89,7 +90,7 @@ IF (FORTRAN_HAVE_ISO_C_BINDING AND HDF5_ENABLE_F2003)
SET (last_test "f03_ex_${example}")
ENDIF (BUILD_TESTING)
ENDFOREACH (example ${F2003_examples})
-ENDIF (FORTRAN_HAVE_ISO_C_BINDING AND HDF5_ENABLE_F2003)
+ENDIF (HDF5_ENABLE_F2003)
IF (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
ADD_EXECUTABLE (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90)
diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am
index 4fb4180..e994d4e 100644
--- a/fortran/examples/Makefile.am
+++ b/fortran/examples/Makefile.am
@@ -32,15 +32,15 @@ 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 grpit refobjexample \
- refregexample mountexample compound
+EXAMPLE_PROG=h5_crtdat h5_rdwt h5_crtatt h5_crtgrp \
+ h5_crtgrpar h5_crtgrpd h5_extend h5_subset h5_cmprss 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 grpit.f90 refobjexample.f90 \
- refregexample.f90 mountexample.f90 compound.f90 ph5example.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 h5_cmprss.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,16 +84,17 @@ 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
+h5_cmprss: h5_cmprss.f90
hyperslab: hyperslab.f90
selectele: selectele.f90
-grpit: grpit.f90
refobjexample: refobjexample.f90
refregexample: refregexample.f90
mountexample: mountexample.f90
diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in
index 1170797..93a2af1 100644
--- a/fortran/examples/Makefile.in
+++ b/fortran/examples/Makefile.in
@@ -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 \
- grpit refobjexample refregexample mountexample compound \
+EXAMPLE_PROG = h5_crtdat h5_rdwt h5_crtatt h5_crtgrp h5_crtgrpar \
+ h5_crtgrpd h5_extend h5_subset h5_cmprss 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 grpit.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 \
+ h5_cmprss.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,16 +688,17 @@ 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
+h5_cmprss: h5_cmprss.f90
hyperslab: hyperslab.f90
selectele: selectele.f90
-grpit: grpit.f90
refobjexample: refobjexample.f90
refregexample: refregexample.f90
mountexample: mountexample.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/grpit.f90 b/fortran/examples/grpit.f90
deleted file mode 100644
index 9361b17..0000000
--- a/fortran/examples/grpit.f90
+++ /dev/null
@@ -1,215 +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. *
-! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-!
-!
-! 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
- INTEGER(HSIZE_T), DIMENSION(2) :: data_dims
-
- !
- ! 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.
- !
- data_dims(1) = 3
- data_dims(2) = 3
- CALL h5dwrite_f(dataset1_id, H5T_NATIVE_INTEGER, dset1_data, data_dims, 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
- !
- data_dims(1) = 2
- data_dims(2) = 10
- CALL h5dwrite_f(dataset2_id, H5T_NATIVE_INTEGER, dset2_data, data_dims, 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/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_cmprss.f90 b/fortran/examples/h5_cmprss.f90
new file mode 100644
index 0000000..847a922
--- /dev/null
+++ b/fortran/examples/h5_cmprss.f90
@@ -0,0 +1,131 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! 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 illustrates how to create a compressed dataset.
+! It is used in the HDF5 Tutorial.
+!
+PROGRAM h5_cmprss
+
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+ !
+ ! The dataset is stored in file "h5_cmprss.h5"
+ !
+ CHARACTER(LEN=12), PARAMETER :: filename = "h5_cmprss.h5"
+ INTEGER, PARAMETER :: rank = 2 ! Rank of the data set
+ INTEGER, PARAMETER :: dim0 = 100 ! Data set sizes
+ INTEGER, PARAMETER :: dim1 = 20
+
+ INTEGER(hid_t) :: file_id, dataset_id, dataspace_id ! Identifiers
+ INTEGER(hid_t) :: plist_id ! Property list identifier
+
+ INTEGER :: error
+ INTEGER(hsize_t), DIMENSION(1:rank) :: dims ! dimensions of data
+ INTEGER(hsize_t), DIMENSION(1:rank) :: cdims ! sizes of chunked data
+
+ INTEGER :: i,j, numfilt
+ INTEGER, DIMENSION(1:dim0,1:dim1) :: buf ! write buffer
+ INTEGER, DIMENSION(1:dim0,1:dim1) :: rbuf ! read buffer
+ INTEGER(HSIZE_T), DIMENSION(1:rank) :: data_dims ! dimensions of data buffers
+
+ INTEGER, DIMENSION(1:1) :: cd_values ! Auxiliary data for the filter
+ INTEGER(size_t) :: nelmts ! Number of elements in cd_values
+ INTEGER :: flags ! Bit vector specifying certain general properties of the filter
+ INTEGER(SIZE_T) :: namelen = 180 ! Anticipated number of characters in name
+ CHARACTER(LEN=180) :: name ! Name of the filter
+ INTEGER :: filter_id ! Filter identification number
+
+ ! Uncomment these variables to use SZIP compression
+ !INTEGER :: szip_options_mask
+ !INTEGER :: szip_pixels_per_block
+
+ !
+ !Initialize FORTRAN predifined datatypes
+ !
+ CALL h5open_f(error)
+ !
+ ! Create a file
+ CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
+ !
+ ! Create dataset "Compressed Data" in the group using absolute name.
+ dims(1:2) = (/dim0, dim1/)
+ CALL h5screate_simple_f(rank, dims, dataspace_id, error)
+ CALL h5pcreate_f(H5P_DATASET_CREATE_F, plist_id, error)
+ !
+ ! Dataset must be chunked for compression
+ cdims(1:2) = 20
+ CALL h5pset_chunk_f(plist_id, 2, cdims, error)
+
+ ! Set ZLIB / DEFLATE Compression using compression level 6.
+ ! To use SZIP Compression comment out these lines.
+ CALL h5pset_deflate_f(plist_id, 6, error)
+
+ ! Uncomment these lines to set SZIP Compression
+ !szip_options_mask = H5_SZIP_NN_OM_F
+ !szip_pixels_per_block = 16
+ !CALL H5Pset_szip_f(plist_id, szip_options_mask, szip_pixels_per_block, error)
+
+ ! Create data set
+ CALL h5dcreate_f(file_id, "Compressed_Data", H5T_NATIVE_INTEGER, dataspace_id, &
+ dataset_id, error, dcpl_id=plist_id)
+
+ DO j = 1, dim1
+ DO i = 1, dim0
+ buf(i,j) = i+j
+ ENDDO
+ ENDDO
+
+ data_dims(1:2) = (/dim0,dim1/)
+ CALL h5dwrite_f(dataset_id, H5T_NATIVE_INTEGER, buf, data_dims, error)
+
+ ! Close resources
+ CALL h5sclose_f(dataspace_id, error)
+ CALL h5pclose_f(plist_id, error)
+ CALL h5dclose_f(dataset_id, error)
+ CALL h5fclose_f(file_id, error)
+
+ ! Now reopen the file and dataset in the file.
+ CALL h5fopen_f(filename, H5F_ACC_RDONLY_F, file_id, error)
+ CALL h5dopen_f(file_id, "Compressed_Data", dataset_id, error)
+
+ ! Retrieve filter information.
+ CALL h5dget_create_plist_f(dataset_id, plist_id, error)
+
+ CALL h5pget_nfilters_f(plist_id, numfilt, error)
+ WRITE(*,'(A, I0)') "Number of filters associated with dataset: ", numfilt
+
+ DO i = 1, numfilt
+ nelmts = 1
+ CALL h5pget_filter_f(plist_id, 0, flags, nelmts, cd_values, &
+ namelen, name, filter_id, error)
+
+ WRITE(*,'(30X,A)', ADVANCE='NO')"Filter Type: "
+ IF(filter_id.EQ.H5Z_FILTER_DEFLATE_F)THEN
+ WRITE(*,'(A)') "H5Z_FILTER_DEFLATE"
+ ELSEIF (filter_id.EQ.H5Z_FILTER_SZIP_F)THEN
+ WRITE(*,'(A)') "H5Z_FILTER_SZIP"
+ ELSE
+ WRITE(*,'(A)') "Other filter type included"
+ ENDIF
+ ENDDO
+ data_dims(1:2) = (/dim0,dim1/)
+ CALL h5dread_f(dataset_id, H5T_NATIVE_INTEGER, rbuf, data_dims, error)
+
+ CALL h5dclose_f(dataset_id, error)
+ CALL h5pclose_f(plist_id, error)
+ CALL h5fclose_f(file_id, error)
+
+END PROGRAM h5_cmprss
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..1316281
--- /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 h5dset_extent_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)
+
+ WRITE(*,'(A)') "Dataset:"
+ DO i = 1, dimsr(1)
+ WRITE(*,'(100(I0,1X))') 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..6cb8f7a
--- /dev/null
+++ b/fortran/examples/h5_subset.f90
@@ -0,0 +1,184 @@
+! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+! 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
+ !
+ WRITE(*,'(/,A)') "Original Data Written to File:"
+ DO i = 1, dim0
+ WRITE(*,'(100(1X,I0,1X))') DATA(i,1:dim1)
+ END DO
+
+ !
+ !
+ ! 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)
+
+ WRITE(*,'(/,A)') "Write subset to file specifying:"
+ WRITE(*,'(A,/)') " offset=2x1 stride=1x1 count=4x3 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)
+
+ !
+ ! Read entire dataset back
+ !
+ WRITE(*,'(A)') "Data in File after Subset Written:"
+ DO i = 1, dim0
+ WRITE(*,'(100(1X,I0,1X))') 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..c5c379e 100644
--- a/fortran/examples/run-fortran-ex.sh.in
+++ b/fortran/examples/run-fortran-ex.sh.in
@@ -70,20 +70,24 @@ 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_cmprss &&\
+ rm h5_cmprss &&\
+ 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
-
-
-