summaryrefslogtreecommitdiffstats
path: root/java/examples/groups
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2016-02-29 02:43:00 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2016-02-29 02:43:00 (GMT)
commit63249be0e10a8726acb5a7cf64491319eaa46227 (patch)
treeebb2b75ece8852e8a58804631c0004f06a9bba9f /java/examples/groups
parenta1617b7cdbe14173fcf690b4627059fa4528c19b (diff)
downloadhdf5-63249be0e10a8726acb5a7cf64491319eaa46227.zip
hdf5-63249be0e10a8726acb5a7cf64491319eaa46227.tar.gz
hdf5-63249be0e10a8726acb5a7cf64491319eaa46227.tar.bz2
[svn-r29226] HDFFV-9552: merge in java code.
Diffstat (limited to 'java/examples/groups')
-rw-r--r--java/examples/groups/CMakeLists.txt138
-rw-r--r--java/examples/groups/H5Ex_G_Compact.java266
-rw-r--r--java/examples/groups/H5Ex_G_Corder.java121
-rw-r--r--java/examples/groups/H5Ex_G_Create.java94
-rw-r--r--java/examples/groups/H5Ex_G_Intermediate.java125
-rw-r--r--java/examples/groups/H5Ex_G_Iterate.java119
-rw-r--r--java/examples/groups/H5Ex_G_Phase.java241
-rw-r--r--java/examples/groups/H5Ex_G_Traverse.java167
-rw-r--r--java/examples/groups/H5Ex_G_Visit.java152
-rw-r--r--java/examples/groups/Makefile.am68
-rw-r--r--java/examples/groups/h5ex_g_iterate.h5bin0 -> 2928 bytes
-rw-r--r--java/examples/groups/h5ex_g_visit.h5bin0 -> 6312 bytes
-rw-r--r--java/examples/groups/runExample.sh.in349
13 files changed, 1840 insertions, 0 deletions
diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt
new file mode 100644
index 0000000..0849f0c
--- /dev/null
+++ b/java/examples/groups/CMakeLists.txt
@@ -0,0 +1,138 @@
+cmake_minimum_required (VERSION 3.1.0)
+PROJECT (HDFJAVA_EXAMPLES_GROUPS Java)
+
+set (CMAKE_VERBOSE_MAKEFILE 1)
+
+INCLUDE_DIRECTORIES (
+ ${HDF5_JAVA_JNI_BINARY_DIR}
+ ${HDF5_JAVA_HDF5_LIB_DIR}
+)
+
+set (HDF_JAVA_EXAMPLES
+ H5Ex_G_Create
+ H5Ex_G_Iterate
+ H5Ex_G_Compact
+ H5Ex_G_Corder
+ H5Ex_G_Intermediate
+ H5Ex_G_Phase
+ H5Ex_G_Visit
+)
+
+if (WIN32)
+ set (CMAKE_JAVA_INCLUDE_FLAG_SEP ";")
+else (WIN32)
+ set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":")
+endif (WIN32)
+
+set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS}")
+
+set (CMAKE_JAVA_CLASSPATH ".")
+foreach (CMAKE_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH})
+ set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${CMAKE_INCLUDE_PATH}")
+endforeach (CMAKE_INCLUDE_PATH)
+
+foreach (example ${HDF_JAVA_EXAMPLES})
+ file (WRITE ${PROJECT_BINARY_DIR}/${example}_Manifest.txt
+ "Main-Class: examples.groups.${example}
+"
+ )
+ add_jar (${example} MANIFEST ${PROJECT_BINARY_DIR}/${example}_Manifest.txt ${example}.java)
+ get_target_property (${example}_JAR_FILE ${example} JAR_FILE)
+# install_jar (${example} ${HJAVA_INSTALL_DATA_DIR}/examples examples)
+ get_target_property (${example}_CLASSPATH ${example} CLASSDIR)
+ add_dependencies (${example} ${HDF5_JAVA_HDF5_LIB_TARGET})
+endforeach (example ${HDF_JAVA_EXAMPLES})
+
+set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_NOP_JAR}")
+
+set (CMAKE_JAVA_CLASSPATH ".")
+foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH})
+ set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${HDFJAVA_JAR}")
+endforeach (HDFJAVA_JAR)
+
+set (HDF_JAVA_TEST_FILES
+ h5ex_g_iterate.h5
+ h5ex_g_visit.h5
+)
+
+foreach (h5_file ${HDF_JAVA_TEST_FILES})
+ set (dest "${PROJECT_BINARY_DIR}/${h5_file}")
+ #message (STATUS " Copying ${h5_file}")
+ add_custom_command (
+ TARGET H5Ex_G_Visit
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/${h5_file} ${dest}
+ )
+endforeach (h5_file ${HDF_JAVA_TEST_FILES})
+
+MACRO (ADD_H5_TEST resultfile resultcode)
+ add_test (
+ NAME JAVA_groups-${resultfile}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}"
+ -D "TEST_PROGRAM=examples.groups.${resultfile}"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${resultfile}_JAR_FILE}"
+ -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}"
+ -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}"
+ -D "TEST_OUTPUT=groups/${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=groups/${resultfile}.txt"
+ -P "${HDF_RESOURCES_DIR}/jrunTest.cmake"
+ )
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (JAVA_groups-${resultfile} PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "JAVA_groups-${resultfile}")
+ENDMACRO (ADD_H5_TEST file)
+
+if (BUILD_TESTING)
+ foreach (example ${HDF_JAVA_EXAMPLES})
+ add_test (
+ NAME JAVA_groups-${example}-clearall-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ ${example}.out
+ ${example}.out.err
+ )
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (JAVA_groups-${example}-clearall-objects PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "JAVA_groups-${example}-clearall-objects")
+ if (NOT ${example} STREQUAL "H5Ex_G_Iterate" AND NOT ${example} STREQUAL "H5Ex_G_Visit")
+ if (${example} STREQUAL "H5Ex_G_Compact")
+ add_test (
+ NAME JAVA_groups-${example}-clearall-h5s
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}1.h5
+ ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}2.h5
+ )
+ else (${example} STREQUAL "H5Ex_G_Compact")
+ add_test (
+ NAME JAVA_groups-${example}-clearall-h5s
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5
+ )
+ endif (${example} STREQUAL "H5Ex_G_Compact")
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (JAVA_groups-${example}-clearall-h5s PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "JAVA_groups-${example}-clearall-h5s")
+ endif (NOT ${example} STREQUAL "H5Ex_G_Iterate" AND NOT ${example} STREQUAL "H5Ex_G_Visit")
+ add_test (
+ NAME JAVA_groups-${example}-copy-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E copy_if_different
+ ${HDFJAVA_EXAMPLES_SOURCE_DIR}/testfiles/examples.groups.${example}.txt
+ ${HDFJAVA_EXAMPLES_GROUPS_BINARY_DIR}/${example}.txt
+ )
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (JAVA_groups-${example}-copy-objects PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "JAVA_groups-${example}-copy-objects")
+ ADD_H5_TEST (${example} 0)
+ endforeach (example ${HDF_JAVA_EXAMPLES})
+endif (BUILD_TESTING)
diff --git a/java/examples/groups/H5Ex_G_Compact.java b/java/examples/groups/H5Ex_G_Compact.java
new file mode 100644
index 0000000..ca9b6c8
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Compact.java
@@ -0,0 +1,266 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/************************************************************
+ Creating a file and print the storage layout.
+ ************************************************************/
+
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.structs.H5G_info_t;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+public class H5Ex_G_Compact {
+
+ private static final String FILE1 = "H5Ex_G_Compact1.h5";
+ private static final String FILE2 = "H5Ex_G_Compact2.h5";
+ private static final String GROUP = "G1";
+
+ enum H5G_storage {
+ H5G_STORAGE_TYPE_UNKNOWN(-1),
+ H5G_STORAGE_TYPE_SYMBOL_TABLE(0),
+ H5G_STORAGE_TYPE_COMPACT(1),
+ H5G_STORAGE_TYPE_DENSE(2);
+
+ private static final Map<Integer, H5G_storage> lookup = new HashMap<Integer, H5G_storage>();
+
+ static {
+ for (H5G_storage s : EnumSet.allOf(H5G_storage.class))
+ lookup.put(s.getCode(), s);
+ }
+
+ private int code;
+
+ H5G_storage(int layout_type) {
+ this.code = layout_type;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static H5G_storage get(int code) {
+ return lookup.get(code);
+ }
+ }
+
+ public static void CreateGroup() {
+ long file_id = -1;
+ long group_id = -1;
+ long fapl_id = -1;
+ H5G_info_t ginfo;
+ long size;
+
+ // Create file 1. This file will use original format groups.
+ try {
+ file_id = H5.H5Fcreate (FILE1, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ // Create a group in the file1.
+ try {
+ if(file_id >= 0)
+ group_id = H5.H5Gcreate(file_id, GROUP, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Obtain the group info and print the group storage type.
+ try {
+ if(group_id >= 0) {
+ ginfo = H5.H5Gget_info(group_id);
+ System.out.print("Group storage type for " + FILE1 + " is: ");
+ switch (H5G_storage.get(ginfo.storage_type)) {
+ case H5G_STORAGE_TYPE_COMPACT:
+ System.out.println("H5G_STORAGE_TYPE_COMPACT"); // New compact format
+ break;
+ case H5G_STORAGE_TYPE_DENSE:
+ System.out.println("H5G_STORAGE_TYPE_DENSE"); // New dense (indexed) format
+ break;
+ case H5G_STORAGE_TYPE_SYMBOL_TABLE:
+ System.out.println("H5G_STORAGE_TYPE_SYMBOL_TABLE"); // Original format
+ break;
+ case H5G_STORAGE_TYPE_UNKNOWN:
+ System.out.println("H5G_STORAGE_TYPE_UNKNOWN");
+ break;
+ default:
+ System.out.println("Storage Type Invalid");
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the group.
+ try {
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // close the file 1.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Re-open file 1. Need to get the correct file size.
+ try {
+ file_id = H5.H5Fopen(FILE1, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Obtain and print the file size.
+ try {
+ if (file_id >= 0) {
+ size = H5.H5Fget_filesize(file_id);
+ System.out.println("File size for " + FILE1 + " is: " + size + " bytes");
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close FILE1.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Set file access property list to allow the latest file format.
+ // This will allow the library to create new compact format groups.
+ try {
+ fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);
+ if (fapl_id >= 0)
+ H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println();
+ // Create file 2 using the new file access property list.
+ try {
+ file_id = H5.H5Fcreate(FILE2, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, fapl_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ // Create group in file2.
+ try {
+ if(file_id >= 0)
+ group_id = H5.H5Gcreate(file_id, GROUP, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Obtain the group info and print the group storage type.
+ try {
+ if (group_id >= 0) {
+ ginfo = H5.H5Gget_info(group_id);
+ System.out.print("Group storage type for " + FILE2 + " is: ");
+ switch (H5G_storage.get(ginfo.storage_type)) {
+ case H5G_STORAGE_TYPE_COMPACT:
+ System.out.println("H5G_STORAGE_TYPE_COMPACT"); // New compact format
+ break;
+ case H5G_STORAGE_TYPE_DENSE:
+ System.out.println("H5G_STORAGE_TYPE_DENSE"); // New dense (indexed) format
+ break;
+ case H5G_STORAGE_TYPE_SYMBOL_TABLE:
+ System.out.println("H5G_STORAGE_TYPE_SYMBOL_TABLE"); // Original format
+ break;
+ case H5G_STORAGE_TYPE_UNKNOWN:
+ System.out.println("H5G_STORAGE_TYPE_UNKNOWN");
+ break;
+ default:
+ System.out.println("Storage Type Invalid");
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the group.
+ try {
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // close the file 2.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Re-open file 2. Needed to get the correct file size.
+ try {
+ file_id = H5.H5Fopen(FILE2, HDF5Constants.H5F_ACC_RDONLY, fapl_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Obtain and print the file size.
+ try {
+ if (file_id >= 0) {
+ size = H5.H5Fget_filesize(file_id);
+ System.out.println("File size for " + FILE2 + " is: " + size + " bytes");
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close FILE2.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ H5Ex_G_Compact.CreateGroup();
+ }
+}
diff --git a/java/examples/groups/H5Ex_G_Corder.java b/java/examples/groups/H5Ex_G_Corder.java
new file mode 100644
index 0000000..95790bf
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Corder.java
@@ -0,0 +1,121 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/************************************************************
+ Creating a file with creation properties and traverse the
+ groups in alpabetical and creation order.
+ ************************************************************/
+
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.structs.H5G_info_t;
+
+public class H5Ex_G_Corder {
+ private static String FILE = "H5Ex_G_Corder.h5";
+
+ private static void CreateGroup() throws Exception {
+ long file_id = -1;
+ long group_id = -1;
+ long subgroup_id = -1;
+ long gcpl_id = -1;
+ int status;
+ H5G_info_t ginfo;
+ int i;
+ String name;
+
+ try {
+ // Create a new file using default properties.
+ file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+
+ // Create group creation property list and enable link creation order tracking.
+ gcpl_id = H5.H5Pcreate(HDF5Constants.H5P_GROUP_CREATE);
+ status = H5.H5Pset_link_creation_order(gcpl_id, HDF5Constants.H5P_CRT_ORDER_TRACKED
+ + HDF5Constants.H5P_CRT_ORDER_INDEXED);
+
+ // Create primary group using the property list.
+ if (status >= 0)
+ group_id = H5.H5Gcreate(file_id, "index_group", HDF5Constants.H5P_DEFAULT, gcpl_id,
+ HDF5Constants.H5P_DEFAULT);
+
+ try {
+ /*
+ * Create subgroups in the primary group. These will be tracked by creation order. Note that these
+ * groups do not have to have the creation order tracking property set.
+ */
+ subgroup_id = H5.H5Gcreate(group_id, "H", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ status = H5.H5Gclose(subgroup_id);
+ subgroup_id = H5.H5Gcreate(group_id, "D", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ status = H5.H5Gclose(subgroup_id);
+ subgroup_id = H5.H5Gcreate(group_id, "F", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ status = H5.H5Gclose(subgroup_id);
+ subgroup_id = H5.H5Gcreate(group_id, "5", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ status = H5.H5Gclose(subgroup_id);
+
+ // Get group info.
+ ginfo = H5.H5Gget_info(group_id);
+
+ // Traverse links in the primary group using alphabetical indices (H5_INDEX_NAME).
+ System.out.println("Traversing group using alphabetical indices:");
+ for (i = 0; i < ginfo.nlinks; i++) {
+ // Retrieve the name of the ith link in a group
+ name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_INC,
+ i, HDF5Constants.H5P_DEFAULT);
+ System.out.println("Index " + i + ": " + name);
+ }
+
+ // Traverse links in the primary group by creation order (H5_INDEX_CRT_ORDER).
+ System.out.println("Traversing group using creation order indices:");
+ for (i = 0; i < ginfo.nlinks; i++) {
+ // Retrieve the name of the ith link in a group
+ name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_CRT_ORDER,
+ HDF5Constants.H5_ITER_INC, i, HDF5Constants.H5P_DEFAULT);
+ System.out.println("Index " + i + ": " + name);
+ }
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ // Close and release resources.
+ if (gcpl_id >= 0)
+ H5.H5Pclose(gcpl_id);
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ H5Ex_G_Corder.CreateGroup();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/java/examples/groups/H5Ex_G_Create.java b/java/examples/groups/H5Ex_G_Create.java
new file mode 100644
index 0000000..1902d86
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Create.java
@@ -0,0 +1,94 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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, open, and close a group.
+ ************************************************************/
+
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+
+public class H5Ex_G_Create {
+ private static String FILENAME = "H5Ex_G_Create.h5";
+ private static String GROUPNAME = "G1";
+
+ private static void CreateGroup() {
+ long file_id = -1;
+ long group_id = -1;
+
+ // Create a new file using default properties.
+ try {
+ file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Create a group in the file.
+ try {
+ if (file_id >= 0)
+ group_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the group. The handle "group" can no longer be used.
+ try {
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Re-open the group, obtaining a new handle.
+ try {
+ if (file_id >= 0)
+ group_id = H5.H5Gopen(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the group.
+ try {
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the file.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public static void main(String[] args) {
+ H5Ex_G_Create.CreateGroup();
+ }
+
+}
diff --git a/java/examples/groups/H5Ex_G_Intermediate.java b/java/examples/groups/H5Ex_G_Intermediate.java
new file mode 100644
index 0000000..a3d620b
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Intermediate.java
@@ -0,0 +1,125 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 intermediate groups with
+ a single call to H5Gcreate.
+ ************************************************************/
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.callbacks.H5O_iterate_cb;
+import hdf.hdf5lib.callbacks.H5O_iterate_t;
+import hdf.hdf5lib.structs.H5O_info_t;
+
+import java.util.ArrayList;
+
+public class H5Ex_G_Intermediate {
+
+ private static String FILE = "H5Ex_G_Intermediate.h5";
+
+ private void CreateGroup() throws Exception {
+
+ long file_id = -1;
+ long group_id = -1;
+ long gcpl_id = -1;
+
+ try {
+ // Create a new file_id using the default properties.
+ file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+
+ // Create group_id creation property list and set it to allow creation of intermediate group_ids.
+ gcpl_id = H5.H5Pcreate(HDF5Constants.H5P_LINK_CREATE);
+ H5.H5Pset_create_intermediate_group(gcpl_id, true);
+
+ /*
+ * Create the group_id /G1/G2/G3. Note that /G1 and /G1/G2 do not exist yet. This call would cause an error
+ * if we did not use the previously created property list.
+ */
+ group_id = H5
+ .H5Gcreate(file_id, "/G1/G2/G3", gcpl_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ // Print all the objects in the file_ids to show that intermediate group_ids have been created.
+ System.out.println("Objects in the file_id:");
+
+ // H5O_iterate_t iter_data = null;
+ H5O_iterate_t iter_data = new H5O_iter_data();
+ H5O_iterate_cb iter_cb = new H5O_iter_callback();
+
+ H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb, iter_data);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ // Close and release resources.
+ if (gcpl_id >= 0)
+ H5.H5Pclose(gcpl_id);
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ (new H5Ex_G_Intermediate()).CreateGroup();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private class idata {
+ public String link_name = null;
+ public int link_type = -1;
+
+ idata(String name, int type) {
+ this.link_name = name;
+ this.link_type = type;
+ }
+ }
+
+ private class H5O_iter_data implements H5O_iterate_t {
+ public ArrayList<idata> iterdata = new ArrayList<idata>();
+ }
+
+ private class H5O_iter_callback implements H5O_iterate_cb {
+ public int callback(long group, String name, H5O_info_t info, H5O_iterate_t op_data) {
+ idata id = new idata(name, info.type);
+ ((H5O_iter_data) op_data).iterdata.add(id);
+
+ System.out.print("/"); /* Print root group in object path */
+
+ // Check if the current object is the root group, and if not print the full path name and type.
+
+ if (name.charAt(0) == '.') /* Root group, do not print '.' */
+ System.out.println(" (Group)");
+ else if (info.type == HDF5Constants.H5O_TYPE_GROUP)
+ System.out.println(name + " (Group)");
+ else if (info.type == HDF5Constants.H5O_TYPE_DATASET)
+ System.out.println(name + " (Dataset)");
+ else if (info.type == HDF5Constants.H5O_TYPE_NAMED_DATATYPE)
+ System.out.println(name + " (Datatype)");
+ else
+ System.out.println(name + " (Unknown)");
+
+ return 0;
+ }
+ }
+
+}
diff --git a/java/examples/groups/H5Ex_G_Iterate.java b/java/examples/groups/H5Ex_G_Iterate.java
new file mode 100644
index 0000000..d0b4ea4
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Iterate.java
@@ -0,0 +1,119 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 iterate over group members using
+ H5Gget_obj_info_all.
+ ************************************************************/
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+public class H5Ex_G_Iterate {
+ private static String FILENAME = "groups/h5ex_g_iterate.h5";
+ private static String DATASETNAME = "/";
+
+ enum H5O_type {
+ H5O_TYPE_UNKNOWN(-1), // Unknown object type
+ H5O_TYPE_GROUP(0), // Object is a group
+ H5O_TYPE_DATASET(1), // Object is a dataset
+ H5O_TYPE_NAMED_DATATYPE(2), // Object is a named data type
+ H5O_TYPE_NTYPES(3); // Number of different object types
+ private static final Map<Integer, H5O_type> lookup = new HashMap<Integer, H5O_type>();
+
+ static {
+ for (H5O_type s : EnumSet.allOf(H5O_type.class))
+ lookup.put(s.getCode(), s);
+ }
+
+ private int code;
+
+ H5O_type(int layout_type) {
+ this.code = layout_type;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static H5O_type get(int code) {
+ return lookup.get(code);
+ }
+ }
+
+ private static void do_iterate() {
+ long file_id = -1;
+
+ // Open a file using default properties.
+ try {
+ file_id = H5.H5Fopen(FILENAME, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Begin iteration.
+ System.out.println("Objects in root group:");
+ try {
+ if (file_id >= 0) {
+ int count = (int) H5.H5Gn_members(file_id, DATASETNAME);
+ String[] oname = new String[count];
+ int[] otype = new int[count];
+ int[] ltype = new int[count];
+ long[] orefs = new long[count];
+ H5.H5Gget_obj_info_all(file_id, DATASETNAME, oname, otype, ltype, orefs, HDF5Constants.H5_INDEX_NAME);
+
+ // Get type of the object and display its name and type.
+ for (int indx = 0; indx < otype.length; indx++) {
+ switch (H5O_type.get(otype[indx])) {
+ case H5O_TYPE_GROUP:
+ System.out.println(" Group: " + oname[indx]);
+ break;
+ case H5O_TYPE_DATASET:
+ System.out.println(" Dataset: " + oname[indx]);
+ break;
+ case H5O_TYPE_NAMED_DATATYPE:
+ System.out.println(" Datatype: " + oname[indx]);
+ break;
+ default:
+ System.out.println(" Unknown: " + oname[indx]);
+ }
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the file.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ H5Ex_G_Iterate.do_iterate();
+ }
+
+}
diff --git a/java/examples/groups/H5Ex_G_Phase.java b/java/examples/groups/H5Ex_G_Phase.java
new file mode 100644
index 0000000..f23d6f2
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Phase.java
@@ -0,0 +1,241 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 set the conditions for
+ conversion between compact and dense (indexed) groups.
+ ************************************************************/
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.structs.H5G_info_t;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+public class H5Ex_G_Phase {
+ private static String FILE = "H5Ex_G_Phase.h5";
+ private static int MAX_GROUPS = 7;
+ private static int MAX_COMPACT = 5;
+ private static int MIN_DENSE = 3;
+
+ enum H5G_storage {
+ H5G_STORAGE_TYPE_UNKNOWN(-1),
+ H5G_STORAGE_TYPE_SYMBOL_TABLE(0),
+ H5G_STORAGE_TYPE_COMPACT(1),
+ H5G_STORAGE_TYPE_DENSE(2);
+
+ private static final Map<Integer, H5G_storage> lookup = new HashMap<Integer, H5G_storage>();
+
+ static {
+ for (H5G_storage s : EnumSet.allOf(H5G_storage.class))
+ lookup.put(s.getCode(), s);
+ }
+
+ private int code;
+
+ H5G_storage(int layout_type) {
+ this.code = layout_type;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static H5G_storage get(int code) {
+ return lookup.get(code);
+ }
+ }
+
+ private static void CreateGroup() {
+ long file_id = -1;
+ long group_id = -1;
+ long subgroup_id = -1;
+ long fapl_id = -1;
+ long gcpl_id = -1;
+ H5G_info_t ginfo;
+ String name = "G0"; // Name of subgroup_id
+ int i;
+
+ // Set file access property list to allow the latest file format.This will allow the library to create new
+ // format groups.
+ try {
+ fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);
+ if (fapl_id >= 0)
+ H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Create group access property list and set the phase change conditions.
+ try {
+ gcpl_id = H5.H5Pcreate(HDF5Constants.H5P_GROUP_CREATE);
+ if (gcpl_id >= 0)
+ H5.H5Pset_link_phase_change(gcpl_id, MAX_COMPACT, MIN_DENSE);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Create a new file using the default properties.
+ try {
+ if (fapl_id >= 0)
+ file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, fapl_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Create primary group.
+ try {
+ if ((file_id >= 0) && (gcpl_id >= 0))
+ group_id = H5.H5Gcreate(file_id, name, HDF5Constants.H5P_DEFAULT, gcpl_id, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Add subgroups to "group" one at a time, print the storage type for "group" after each subgroup is created.
+ for (i = 1; i <= MAX_GROUPS; i++) {
+ // Define the subgroup name and create the subgroup.
+ char append = (char) (((char) i) + '0');
+ name = name + append; /* G1, G2, G3 etc. */
+ try {
+ if (group_id >= 0) {
+ subgroup_id = H5.H5Gcreate(group_id, name, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ H5.H5Gclose(subgroup_id);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Obtain the group info and print the group storage type
+ try {
+ if (group_id >= 0) {
+ ginfo = H5.H5Gget_info(group_id);
+ System.out.print(ginfo.nlinks + " Group" + (ginfo.nlinks == 1 ? " " : "s") + ": Storage type is ");
+ switch (H5G_storage.get(ginfo.storage_type)) {
+ case H5G_STORAGE_TYPE_COMPACT:
+ System.out.println("H5G_STORAGE_TYPE_COMPACT"); // New compact format
+ break;
+ case H5G_STORAGE_TYPE_DENSE:
+ System.out.println("H5G_STORAGE_TYPE_DENSE"); // New dense (indexed) format
+ break;
+ case H5G_STORAGE_TYPE_SYMBOL_TABLE:
+ System.out.println("H5G_STORAGE_TYPE_SYMBOL_TABLE"); // Original format
+ break;
+ case H5G_STORAGE_TYPE_UNKNOWN:
+ System.out.println("H5G_STORAGE_TYPE_UNKNOWN");
+ break;
+ default:
+ System.out.println("Storage Type Invalid");
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ System.out.println();
+
+ // Delete subgroups one at a time, print the storage type for "group" after each subgroup is deleted.
+ for (i = MAX_GROUPS; i >= 1; i--) {
+ // Define the subgroup name and delete the subgroup.
+ try {
+ H5.H5Ldelete(group_id, name, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ name = name.substring(0, i + 1);
+
+ // Obtain the group info and print the group storage type
+ try {
+ if (group_id >= 0) {
+ ginfo = H5.H5Gget_info(group_id);
+ System.out.print(ginfo.nlinks + " Group" + (ginfo.nlinks == 1 ? " " : "s") + ": Storage type is ");
+ switch (H5G_storage.get(ginfo.storage_type)) {
+ case H5G_STORAGE_TYPE_COMPACT:
+ System.out.println("H5G_STORAGE_TYPE_COMPACT"); // New compact format
+ break;
+ case H5G_STORAGE_TYPE_DENSE:
+ System.out.println("H5G_STORAGE_TYPE_DENSE"); // New dense (indexed) format
+ break;
+ case H5G_STORAGE_TYPE_SYMBOL_TABLE:
+ System.out.println("H5G_STORAGE_TYPE_SYMBOL_TABLE"); // Original format
+ break;
+ case H5G_STORAGE_TYPE_UNKNOWN:
+ System.out.println("H5G_STORAGE_TYPE_UNKNOWN");
+ break;
+ default:
+ System.out.println("Storage Type Invalid");
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // Close and release resources
+ try {
+ if (fapl_id >= 0)
+ H5.H5Pclose(fapl_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ try {
+ if (gcpl_id >= 0)
+ H5.H5Pclose(gcpl_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the group
+ try {
+ if (group_id >= 0)
+ H5.H5Gclose(group_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close the file
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public static void main(String[] args) {
+ H5Ex_G_Phase.CreateGroup();
+ }
+
+}
diff --git a/java/examples/groups/H5Ex_G_Traverse.java b/java/examples/groups/H5Ex_G_Traverse.java
new file mode 100644
index 0000000..b00fe97
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Traverse.java
@@ -0,0 +1,167 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 a way to recursively traverse the file
+using H5Literate. The method shown here guarantees that
+the recursion will not enter an infinite loop, but does
+not prevent objects from being visited more than once.
+The program prints the directory structure of the file
+specified in FILE. The default file used by this example
+implements the structure described in the User's Guide,
+chapter 4, figure 26.
+ ************************************************************/
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.callbacks.H5L_iterate_cb;
+import hdf.hdf5lib.callbacks.H5L_iterate_t;
+import hdf.hdf5lib.structs.H5L_info_t;
+import hdf.hdf5lib.structs.H5O_info_t;
+import examples.groups.H5Ex_G_Iterate.H5O_type;
+
+class opdata implements H5L_iterate_t {
+ int recurs;
+ opdata prev;
+ long addr;
+}
+
+public class H5Ex_G_Traverse {
+
+ private static String FILE = "h5ex_g_traverse.h5";
+ public static H5L_iterate_cb iter_cb = new H5L_iter_callbackT();
+
+ private static void OpenGroup() {
+ long file_id = -1;
+ H5O_info_t infobuf;
+ opdata od = new opdata();
+
+ // Open file and initialize the operator data structure.
+ try {
+ file_id = H5.H5Fopen(FILE, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
+ if (file_id >= 0) {
+ infobuf = H5.H5Oget_info(file_id);
+ od.recurs = 0;
+ od.prev = null;
+ od.addr = infobuf.addr;
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Print the root group and formatting, begin iteration.
+ try {
+ System.out.println("/ {");
+ // H5L_iterate_cb iter_cb = new H5L_iter_callbackT();
+ H5.H5Literate(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb, od);
+ System.out.println("}");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Close and release resources.
+ try {
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ H5Ex_G_Traverse.OpenGroup();
+ }
+}
+
+class H5L_iter_callbackT implements H5L_iterate_cb {
+ public int callback(long group, String name, H5L_info_t info, H5L_iterate_t op_data) {
+
+ H5O_info_t infobuf;
+ int return_val = 0;
+ opdata od = (opdata) op_data; // Type conversion
+ int spaces = 2 * (od.recurs + 1); // Number of white spaces to prepend to output.
+
+ // Get type of the object and display its name and type.
+ // The name of the object is passed to this function by the Library.
+ try {
+ infobuf = H5.H5Oget_info_by_name(group, name, HDF5Constants.H5P_DEFAULT);
+
+ for (int i = 0; i < spaces; i++)
+ System.out.print(" "); // Format output.
+ switch (H5O_type.get(infobuf.type)) {
+ case H5O_TYPE_GROUP:
+ System.out.println("Group: " + name + " { ");
+ // Check group address against linked list of operator
+ // data structures. We will always run the check, as the
+ // reference count cannot be relied upon if there are
+ // symbolic links, and H5Oget_info_by_name always follows
+ // symbolic links. Alternatively we could use H5Lget_info
+ // and never recurse on groups discovered by symbolic
+ // links, however it could still fail if an object's
+ // reference count was manually manipulated with
+ // H5Odecr_refcount.
+ if (group_check(od, infobuf.addr)) {
+ for (int i = 0; i < spaces; i++)
+ System.out.print(" ");
+ System.out.println(" Warning: Loop detected!");
+ }
+ else {
+ // Initialize new object of type opdata and begin
+ // recursive iteration on the discovered
+ // group. The new opdata is given a pointer to the
+ // current one.
+ opdata nextod = new opdata();
+ nextod.recurs = od.recurs + 1;
+ nextod.prev = od;
+ nextod.addr = infobuf.addr;
+ H5L_iterate_cb iter_cb2 = new H5L_iter_callbackT();
+ return_val = H5.H5Literate_by_name(group, name, HDF5Constants.H5_INDEX_NAME,
+ HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb2, nextod, HDF5Constants.H5P_DEFAULT);
+ }
+ for (int i = 0; i < spaces; i++)
+ System.out.print(" ");
+ System.out.println("}");
+ break;
+ case H5O_TYPE_DATASET:
+ System.out.println("Dataset: " + name);
+ break;
+ case H5O_TYPE_NAMED_DATATYPE:
+ System.out.println("Datatype: " + name);
+ break;
+ default:
+ System.out.println("Unknown: " + name);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return return_val;
+ }
+
+ public boolean group_check(opdata od, long target_addr) {
+ if (od.addr == target_addr)
+ return true; // Addresses match
+ else if (od.recurs == 0)
+ return false; // Root group reached with no matches
+ else
+ return group_check(od.prev, target_addr); // Recursively examine the next node
+ }
+
+}
diff --git a/java/examples/groups/H5Ex_G_Visit.java b/java/examples/groups/H5Ex_G_Visit.java
new file mode 100644
index 0000000..c2367a6
--- /dev/null
+++ b/java/examples/groups/H5Ex_G_Visit.java
@@ -0,0 +1,152 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 recursively traverse a file
+ using H5Ovisit and H5Lvisit. The program prints all of
+ the objects in the file specified in FILE, then prints all
+ of the links in that file. The default file used by this
+ example implements the structure described in the User's
+ Guide, chapter 4, figure 26.
+ ************************************************************/
+package examples.groups;
+
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.callbacks.H5L_iterate_cb;
+import hdf.hdf5lib.callbacks.H5L_iterate_t;
+import hdf.hdf5lib.callbacks.H5O_iterate_cb;
+import hdf.hdf5lib.callbacks.H5O_iterate_t;
+import hdf.hdf5lib.structs.H5L_info_t;
+import hdf.hdf5lib.structs.H5O_info_t;
+
+import java.util.ArrayList;
+
+public class H5Ex_G_Visit {
+
+ private static String FILE = "groups/h5ex_g_visit.h5";
+
+ public static void main(String[] args) {
+ try {
+ (new H5Ex_G_Visit()).VisitGroup();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void VisitGroup() throws Exception {
+
+ long file_id = -1;
+
+ try {
+ // Open file
+ file_id = H5.H5Fopen(FILE, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
+
+ // Begin iteration using H5Ovisit
+ System.out.println("Objects in the file:");
+ H5O_iterate_t iter_data = new H5O_iter_data();
+ H5O_iterate_cb iter_cb = new H5O_iter_callback();
+ H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb, iter_data);
+ System.out.println();
+ // Repeat the same process using H5Lvisit
+ H5L_iterate_t iter_data2 = new H5L_iter_data();
+ H5L_iterate_cb iter_cb2 = new H5L_iter_callback();
+ System.out.println("Links in the file:");
+ H5.H5Lvisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb2, iter_data2);
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ // Close and release resources.
+ if (file_id >= 0)
+ H5.H5Fclose(file_id);
+ }
+ }
+
+ /************************************************************
+ * Operator function for H5Lvisit. This function simply retrieves the info for the object the current link points
+ * to, and calls the operator function for H5Ovisit.
+ ************************************************************/
+
+ private class idata {
+ public String link_name = null;
+ public int link_type = -1;
+
+ idata(String name, int type) {
+ this.link_name = name;
+ this.link_type = type;
+ }
+ }
+
+ private class H5L_iter_data implements H5L_iterate_t {
+ public ArrayList<idata> iterdata = new ArrayList<idata>();
+ }
+
+ private class H5L_iter_callback implements H5L_iterate_cb {
+ public int callback(long group, String name, H5L_info_t info, H5L_iterate_t op_data) {
+
+ idata id = new idata(name, info.type);
+ ((H5L_iter_data) op_data).iterdata.add(id);
+
+ H5O_info_t infobuf;
+ int ret = 0;
+ try {
+ // Get type of the object and display its name and type. The name of the object is passed to this
+ // function by the Library.
+ infobuf = H5.H5Oget_info_by_name(group, name, HDF5Constants.H5P_DEFAULT);
+ H5O_iterate_cb iter_cbO = new H5O_iter_callback();
+ H5O_iterate_t iter_dataO = new H5O_iter_data();
+ ret = iter_cbO.callback(group, name, infobuf, iter_dataO);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return ret;
+ }
+ }
+
+ private class H5O_iter_data implements H5O_iterate_t {
+ public ArrayList<idata> iterdata = new ArrayList<idata>();
+ }
+
+ private class H5O_iter_callback implements H5O_iterate_cb {
+ public int callback(long group, String name, H5O_info_t info, H5O_iterate_t op_data) {
+ idata id = new idata(name, info.type);
+ ((H5O_iter_data) op_data).iterdata.add(id);
+
+ System.out.print("/"); /* Print root group in object path */
+
+ // Check if the current object is the root group, and if not print the full path name and type.
+
+ if (name.charAt(0) == '.') /* Root group, do not print '.' */
+ System.out.println(" (Group)");
+ else if (info.type == HDF5Constants.H5O_TYPE_GROUP)
+ System.out.println(name + " (Group)");
+ else if (info.type == HDF5Constants.H5O_TYPE_DATASET)
+ System.out.println(name + " (Dataset)");
+ else if (info.type == HDF5Constants.H5O_TYPE_NAMED_DATATYPE)
+ System.out.println(name + " (Datatype)");
+ else
+ System.out.println(name + " (Unknown)");
+
+ return 0;
+ }
+ }
+
+}
diff --git a/java/examples/groups/Makefile.am b/java/examples/groups/Makefile.am
new file mode 100644
index 0000000..802e2b0
--- /dev/null
+++ b/java/examples/groups/Makefile.am
@@ -0,0 +1,68 @@
+#
+# 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.
+##
+## Makefile.am
+## Run automake to generate a Makefile.in from this file.
+##
+#
+# HDF5 Java Library Examples Makefile(.in)
+
+include $(top_srcdir)/config/commence.am
+
+# Mark this directory as part of the JNI API
+JAVA_API=yes
+
+JAVAROOT = .classes
+
+classes:
+ $(MKDIR_P) $(@D)/$(JAVAROOT)
+
+pkgpath = examples/groups
+hdfjarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar
+CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.5.jar:$$CLASSPATH
+
+jarfile = jar$(PACKAGE_TARNAME)groups.jar
+
+AM_JAVACFLAGS = $(H5_JAVACFLAGS) -deprecation
+
+TESTPACKAGE =
+
+noinst_JAVA = \
+ H5Ex_G_Create.java \
+ H5Ex_G_Iterate.java \
+ H5Ex_G_Compact.java \
+ H5Ex_G_Corder.java \
+ H5Ex_G_Intermediate.java \
+ H5Ex_G_Phase.java \
+ H5Ex_G_Visit.java
+
+
+$(jarfile): classnoinst.stamp classes
+ $(JAR) cvf $@ -C $(JAVAROOT)/ $(pkgpath)
+
+noinst_DATA = $(jarfile)
+
+.PHONY: classes
+
+check_SCRIPTS = runExample.sh
+TEST_SCRIPT = $(check_SCRIPTS)
+
+CLEANFILES = classnoinst.stamp $(jarfile) $(JAVAROOT)/$(pkgpath)/*.class runExample.sh
+
+clean:
+ rm -rf $(JAVAROOT)
+ rm -f $(jarfile)
+ rm -f classnoinst.stamp
+
+include $(top_srcdir)/config/conclude.am
diff --git a/java/examples/groups/h5ex_g_iterate.h5 b/java/examples/groups/h5ex_g_iterate.h5
new file mode 100644
index 0000000..e462703
--- /dev/null
+++ b/java/examples/groups/h5ex_g_iterate.h5
Binary files differ
diff --git a/java/examples/groups/h5ex_g_visit.h5 b/java/examples/groups/h5ex_g_visit.h5
new file mode 100644
index 0000000..d8267b1
--- /dev/null
+++ b/java/examples/groups/h5ex_g_visit.h5
Binary files differ
diff --git a/java/examples/groups/runExample.sh.in b/java/examples/groups/runExample.sh.in
new file mode 100644
index 0000000..a59a894
--- /dev/null
+++ b/java/examples/groups/runExample.sh.in
@@ -0,0 +1,349 @@
+#! /bin/sh
+#
+# 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.
+#
+
+top_builddir=@top_builddir@
+top_srcdir=@top_srcdir@
+srcdir=@srcdir@
+
+TESTNAME=EX_Groups
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+# Set up default variable values if not supplied by the user.
+RM='rm -rf'
+CMP='cmp'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+nerrors=0
+
+# where the libs exist
+HDFLIB_HOME="$top_srcdir/java/lib"
+BLDLIBDIR="./lib"
+BLDREFDIR="./groups"
+BLDDIR="."
+HDFTEST_HOME="$top_srcdir/java/examples/groups"
+JARFILE=jar@PACKAGE_TARNAME@-@PACKAGE_VERSION@.jar
+TESTJARFILE=jar@PACKAGE_TARNAME@groups.jar
+test -d $BLDLIBDIR || mkdir -p $BLDLIBDIR
+test -d $BLDREFDIR || mkdir -p $BLDREFDIR
+
+######################################################################
+# library files
+# --------------------------------------------------------------------
+# All the library files copy from source directory to test directory
+# NOTE: Keep this framework to add/remove test files.
+# This list are also used for checking exist.
+# Comment '#' without space can be used.
+# --------------------------------------------------------------------
+LIST_LIBRARY_FILES="
+$HDFLIB_HOME/slf4j-api-1.7.5.jar
+$HDFLIB_HOME/ext/slf4j-simple-1.7.5.jar
+$top_builddir/src/.libs/libhdf5.*
+$top_builddir/java/src/jni/.libs/libhdf5_java.*
+$top_builddir/java/src/$JARFILE
+"
+LIST_REF_FILES="
+$HDFTEST_HOME/h5ex_g_iterate.h5
+$HDFTEST_HOME/h5ex_g_visit.h5
+"
+LIST_DATA_FILES="
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Create.txt
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Iterate.txt
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Compact.txt
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Corder.txt
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Intermediate.txt
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Phase.txt
+$HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Visit.txt
+"
+
+#
+# copy files from source dirs to test dir
+#
+COPY_LIBFILES="$LIST_LIBRARY_FILES"
+
+COPY_LIBFILES_TO_BLDLIBDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_LIBFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $BLDLIBDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_LIBFILES_AND_BLDLIBDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $BLDLIBDIR
+ fi
+}
+
+COPY_DATAFILES="$LIST_DATA_FILES"
+
+COPY_DATAFILES_TO_BLDDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_DATAFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $BLDDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_DATAFILES_AND_BLDDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $BLDDIR/*.txt
+ $RM $BLDDIR/*.out
+ fi
+}
+
+COPY_REFFILES="$LIST_REF_FILES"
+
+COPY_REFFILES_TO_BLDREFDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_REFFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $BLDREFDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_REFFILES_AND_BLDREFDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $BLDREFDIR
+ fi
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+#
+TESTING() {
+ SPACES=" "
+ echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# where Java is installed (requires jdk1.7.x)
+JAVAEXE=@JAVA@
+JAVAEXEFLAGS=@H5_JAVAFLAGS@
+
+###############################################################################
+# DO NOT MODIFY BELOW THIS LINE
+###############################################################################
+
+# prepare for test
+COPY_LIBFILES_TO_BLDLIBDIR
+COPY_DATAFILES_TO_BLDDIR
+COPY_REFFILES_TO_BLDREFDIR
+
+CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.5.jar:"$BLDLIBDIR"/slf4j-simple-1.7.5.jar:"$TESTJARFILE""
+
+TEST=/usr/bin/test
+if [ ! -x /usr/bin/test ]
+then
+TEST=`which test`
+fi
+
+if $TEST -z "$CLASSPATH"; then
+ CLASSPATH=""
+fi
+CLASSPATH=$CPATH":"$CLASSPATH
+export CLASSPATH
+
+if $TEST -n "$JAVAPATH" ; then
+ PATH=$JAVAPATH":"$PATH
+ export PATH
+fi
+
+if $TEST -e /bin/uname; then
+ os_name=`/bin/uname -s`
+elif $TEST -e /usr/bin/uname; then
+ os_name=`/usr/bin/uname -s`
+else
+ os_name=unknown
+fi
+
+if $TEST -z "$LD_LIBRARY_PATH" ; then
+ LD_LIBRARY_PATH=""
+fi
+
+case $os_name in
+ Darwin)
+ DYLD_LIBRARY_PATH=$BLDLIBDIR:$DYLD_LIBRARY_PATH
+ export DYLD_LIBRARY_PATH
+ LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
+ ;;
+ *)
+ LD_LIBRARY_PATH=$BLDLIBDIR:$LD_LIBRARY_PATH
+ ;;
+esac
+
+export LD_LIBRARY_PATH
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Create"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Create > H5Ex_G_Create.out)
+if diff H5Ex_G_Create.out examples.groups.H5Ex_G_Create.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Create"
+else
+ echo "**FAILED** groups.H5Ex_G_Create"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Iterate"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Iterate > H5Ex_G_Iterate.out)
+if diff H5Ex_G_Iterate.out examples.groups.H5Ex_G_Iterate.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Iterate"
+else
+ echo "**FAILED** groups.H5Ex_G_Iterate"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Compact"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Compact > H5Ex_G_Compact.out)
+if diff H5Ex_G_Compact.out examples.groups.H5Ex_G_Compact.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Compact"
+else
+ echo "**FAILED** groups.H5Ex_G_Compact"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Corder"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Corder > H5Ex_G_Corder.out)
+if diff H5Ex_G_Corder.out examples.groups.H5Ex_G_Corder.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Corder"
+else
+ echo "**FAILED** groups.H5Ex_G_Corder"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Intermediate"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Intermediate > H5Ex_G_Intermediate.out)
+if diff H5Ex_G_Intermediate.out examples.groups.H5Ex_G_Intermediate.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Intermediate"
+else
+ echo "**FAILED** groups.H5Ex_G_Intermediate"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Phase"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Phase > H5Ex_G_Phase.out)
+if diff H5Ex_G_Phase.out examples.groups.H5Ex_G_Phase.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Phase"
+else
+ echo "**FAILED** groups.H5Ex_G_Phase"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Visit"
+($JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH examples.groups.H5Ex_G_Visit > H5Ex_G_Visit.out)
+if diff H5Ex_G_Visit.out examples.groups.H5Ex_G_Visit.txt > /dev/null; then
+ echo " PASSED groups.H5Ex_G_Visit"
+else
+ echo "**FAILED** groups.H5Ex_G_Visit"
+ nerrors="`expr $nerrors + 1`"
+fi
+
+# Clean up temporary files/directories
+CLEAN_LIBFILES_AND_BLDLIBDIR
+CLEAN_DATAFILES_AND_BLDDIR
+CLEAN_REFFILES_AND_BLDREFDIR
+
+# Report test results and exit
+if test $nerrors -eq 0 ; then
+ echo "All $TESTNAME tests passed."
+ exit $EXIT_SUCCESS
+else
+ echo "$TESTNAME tests failed with $nerrors errors."
+ exit $EXIT_FAILURE
+fi