summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>2003-04-03 20:10:25 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>2003-04-03 20:10:25 (GMT)
commit78c2c38d986aace5ea06cc8cfeafd155374f1b98 (patch)
treecce80472ded9da77bca9e62ae05e562f6a3327b2 /tools
parent1d76391f63d43242f47fc487bfcdca1cf2299858 (diff)
downloadhdf5-78c2c38d986aace5ea06cc8cfeafd155374f1b98.zip
hdf5-78c2c38d986aace5ea06cc8cfeafd155374f1b98.tar.gz
hdf5-78c2c38d986aace5ea06cc8cfeafd155374f1b98.tar.bz2
[svn-r6584]
Purpose: Maintenance Description: There was an old h5import (h5import.c) tool in the misc directory. The tool created 8-bit integer datasets , it was never tested and/or supported. Solution: We decided to rename old h5import.c to h5createU8.c. The new name reflects what actually old tool does. New executable h5createU8 is built in the misc directory. h5import.c file (old one) is still in the misc directory, but h5import executable is not built. (Sorry if I confused you!) Platforms tested: vebena, arabica, modi4 were tested Misc. update:
Diffstat (limited to 'tools')
-rw-r--r--tools/misc/Makefile.in22
-rw-r--r--tools/misc/h5createU8.c141
2 files changed, 148 insertions, 15 deletions
diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in
index 6b228b9..5ea8aaa 100644
--- a/tools/misc/Makefile.in
+++ b/tools/misc/Makefile.in
@@ -1,17 +1,9 @@
## HDF5 Library Makefile(.in)
##
-## 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have
-## access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu.
+## Copyright (C) 2001 National Center for Supercomputing Applications.
+## All rights reserved.
##
+##
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
@@ -34,7 +26,7 @@ TEST_SCRIPTS=
LIBTOOLS=../lib/libh5tools.la
LIBHDF5=$(top_builddir)/src/libhdf5.la
-PUB_PROGS=h5cc h5debug h5import h5redeploy h5repart @PDB2HDF@
+PUB_PROGS=h5cc h5debug h5createU8 h5redeploy h5repart @PDB2HDF@
PROGS=$(PUB_PROGS) $(TEST_PROGS)
## Source and object files for the library; do not install
@@ -45,7 +37,7 @@ PUB_LIB=
## Source and object files for programs...
##
-PROG_SRC=h5debug.c h5import.c h5repart.c pdb2hdf.c
+PROG_SRC=h5debug.c h5createU8.c h5repart.c pdb2hdf.c
PROG_OBJ=$(PROG_SRC:.c=.lo)
PRIVATE_HDR=
@@ -70,8 +62,8 @@ h5cc: h5cc.in
h5debug: h5debug.lo
@$(LT_LINK_EXE) $(CFLAGS) -o $@ h5debug.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
-h5import: h5import.lo
- @$(LT_LINK_EXE) $(CFLAGS) -o $@ h5import.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+h5createU8: h5createU8.lo
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ h5createU8.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
h5redeploy: h5redeploy.in
$(CP) $(srcdir)/$@.in $@
diff --git a/tools/misc/h5createU8.c b/tools/misc/h5createU8.c
new file mode 100644
index 0000000..b669259
--- /dev/null
+++ b/tools/misc/h5createU8.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Thursday, June 11, 1998
+ *
+ * Purpose: Create an hdf5 file with a 1d dataset of uint8.
+ */
+
+/* See H5private.h for how to include system headers */
+#include <hdf5.h>
+#ifdef H5_STDC_HEADERS
+# include <fcntl.h>
+# include <string.h>
+# include <stdlib.h>
+# include <stdio.h>
+#endif
+
+#ifdef H5_HAVE_UNISTD_H
+# include <sys/types.h>
+# include <unistd.h>
+#endif
+
+#ifdef H5_HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#ifdef WIN32
+# include <io.h>
+#endif
+
+
+/*-------------------------------------------------------------------------
+ * Function: usage
+ *
+ * Purpose: Print a usage message and exit with non-zero status
+ *
+ * Return: never returns
+ *
+ * Programmer: Robb Matzke
+ * Thursday, June 11, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+usage (const char *argv0)
+{
+ fprintf (stderr, "Usage: %s -f HDF5-FILE FILES...\n", argv0);
+ exit (1);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Robb Matzke
+ * Thursday, June 11, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main (int argc, char *argv[])
+{
+ hid_t file, space=-1, dset=-1;
+ const char *output_name, *dset_name;
+ int argno, fd=-1;
+ hsize_t size[1];
+ struct stat sb;
+
+ /* Parse arguments */
+ if (argc<4) usage (argv[0]);
+ if (strcmp (argv[1], "-f")) usage (argv[0]);
+ output_name = argv[2];
+
+ /* create the file */
+ H5E_BEGIN_TRY {
+ if ((file = H5Fcreate (output_name, H5F_ACC_EXCL,
+ H5P_DEFAULT, H5P_DEFAULT))<0 &&
+ (file = H5Fopen (output_name, H5F_ACC_RDWR, H5P_DEFAULT)<0)) {
+ fprintf (stderr, "%s: unable to create or open hdf5 file\n",
+ output_name);
+ exit (1);
+ }
+ } H5E_END_TRY;
+
+ /* process files from command-line */
+ for (argno=3; argno<argc; argno++) {
+
+ /* Open the file */
+ if ((dset_name=strrchr (argv[argno], '/'))) dset_name++;
+ else dset_name = argv[argno];
+ fprintf (stderr, "%s\n", dset_name);
+ if ((fd=open (argv[argno], O_RDONLY))<0) {
+ perror (argv[argno]);
+ goto next;
+ }
+ if (fstat (fd, &sb)<0) {
+ perror (argv[argno]);
+ goto next;
+ }
+
+ /* Data space */
+ size[0] = sb.st_size;
+ if ((space = H5Screate_simple (1, size, size))<0) goto next;
+
+ /* Dataset */
+ if ((dset=H5Dcreate (file, dset_name, H5T_NATIVE_SCHAR,
+ space, H5P_DEFAULT))<0) goto next;
+
+
+
+ next:
+ if (fd>=0) close (fd);
+ fd = -1;
+ H5E_BEGIN_TRY {
+ if (space>=0) {
+ H5Sclose (space);
+ space = -1;
+ }
+ if (dset>=0) {
+ H5Dclose (dset);
+ dset = -1;
+ }
+ } H5E_END_TRY;
+ }
+
+ /* Close the file */
+ H5Fclose (file);
+ return 0;
+}