1998-03-25 07:18:34 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 1998 NCSA
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Monday, March 23, 1998
|
|
|
|
|
*/
|
|
|
|
|
#include <hdf5.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
1998-04-09 05:43:02 +08:00
|
|
|
|
#include <string.h>
|
1998-03-25 07:18:34 +08:00
|
|
|
|
|
[svn-r339] Changes since 19980408
----------------------
./src/H5Osdspace.c
./html/H5.format.html
In the past we were allowed to have >2GB files on a 32-bit
machine as long as no dataset within the file was larger than
4GB (or whatever sizeof(size_t) is). That's been fixed now.
All dataset size calculations are done with `hsize_t' which is
normally defined as `unsigned long long'.
./src/H5F.c
./src/H5Ffamily.c
./src/H5Fprivate.h
./src/H5P.c
./src/H5Ppublic.h
The file family member size can now be set/queried. The
default is still 64MB, but it can be set to 1GB by saying:
H5Pset_family (plist, 30, H5P_DEFAULT);
When opening an existing file family the specified
bits-per-member is ignored and the first member of the family
determines the bits-per-member, which can be retrieved with
H5Pget_family().
./acconfig.h
./configure.in
./src/H5config.h
./src/H5public.h
Added `--disable-hsizet' so that those with old GCC compilers
(<2.8.1) can still compile the code.
./src/H5.c
./src/H5private.h
Added HDfprintf() which works just like fprintf() except you
can give `H' as a size modifier for the integer conversions
and supply an `hsize_t' or `hssize_t' argument without casting
it. For instance:
hsize_t npoints = H5Sget_npoints(space);
HDfprintf(stdout,"Dataset has %Hd (%#018Hx) points\n",
npoints, npoints);
You can now give `%a' as a format to print an address, but all
formating flags are ignored and it causes the return value of
HDfprintf() to not include the characters in the address (but
who uses the return value anyway :-). Example:
H5G_t *grp;
HDfprintf(stdout, "Group object header at %a\n",
&(grp->ent.header));
Added HDstrtoll() which works exactly like [HD]strtol() except
the result is an int64.
./src/debug.c
Large addresses can now be entered from the command-line. Use
either decimal, octal (leading `0') or hexadecimal (leading
`0x') when giving the address.
./src/h5ls.c
The printf format for dataset dimensions was changed to `%Hu'
to support large datasets.
./test/big.c [NEW]
A test for big datasets on 32-bit machines. This test is not
run by default. Don't try to run it on an nfs-mounted file
system or other file system that doesn't support holes because
it creates two 32GB datasets of all zero.
1998-04-10 04:22:11 +08:00
|
|
|
|
#include <H5private.h>
|
1998-04-07 23:34:16 +08:00
|
|
|
|
#ifndef HAVE_ATTRIBUTE
|
|
|
|
|
# undef __attribute__
|
|
|
|
|
# define __attribute__(X) /*void*/
|
1998-04-09 05:43:02 +08:00
|
|
|
|
# define __unused__ /*void*/
|
|
|
|
|
#else
|
|
|
|
|
# define __unused__ __attribute__((unused))
|
1998-04-07 23:34:16 +08:00
|
|
|
|
#endif
|
1998-03-25 07:18:34 +08:00
|
|
|
|
|
1998-05-14 01:58:24 +08:00
|
|
|
|
static void
|
|
|
|
|
usage (const char *progname)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "usage: %s FILE [GROUP]\n", progname);
|
|
|
|
|
fprintf (stderr, " The file name may contain a printf integer format "
|
|
|
|
|
"to open a file family.\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-06 05:03:49 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: list_attr
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Prints information about attributes.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Friday, June 5, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
|
|
|
|
list_attr (hid_t obj, const char *attr_name, void __unused__ *op_data)
|
|
|
|
|
{
|
|
|
|
|
hid_t attr;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
printf ("%*s%s", 26, "", attr_name);
|
|
|
|
|
if ((attr = H5Aopen_name (obj, attr_name))) {
|
|
|
|
|
hid_t space = H5Aget_space (attr);
|
|
|
|
|
hsize_t size[64];
|
1998-07-15 05:14:22 +08:00
|
|
|
|
int ndims = H5Sextent_dims (space, size, NULL);
|
1998-06-06 05:03:49 +08:00
|
|
|
|
H5Sclose (space);
|
|
|
|
|
printf (" {");
|
|
|
|
|
for (i=0; i<ndims; i++) {
|
|
|
|
|
HDfprintf (stdout, "%s%Hu", i?", ":"", size[i]);
|
|
|
|
|
}
|
|
|
|
|
putchar ('}');
|
|
|
|
|
H5Aclose (attr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putchar ('\n');
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1998-05-14 01:58:24 +08:00
|
|
|
|
|
1998-03-25 07:18:34 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: list
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Prints the group member name.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Monday, March 23, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
1998-04-09 05:43:02 +08:00
|
|
|
|
list (hid_t group, const char *name, void __unused__ *op_data)
|
1998-03-25 07:18:34 +08:00
|
|
|
|
{
|
|
|
|
|
hid_t obj;
|
|
|
|
|
hid_t (*func)(void*);
|
|
|
|
|
void *edata;
|
|
|
|
|
int i;
|
1998-04-18 05:29:43 +08:00
|
|
|
|
char buf[512];
|
1998-04-15 00:44:46 +08:00
|
|
|
|
H5G_stat_t statbuf;
|
|
|
|
|
|
1998-03-25 07:18:34 +08:00
|
|
|
|
/* Disable error reporting */
|
|
|
|
|
H5Eget_auto (&func, &edata);
|
|
|
|
|
H5Eset_auto (NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* Print info about each name */
|
1998-04-18 05:29:43 +08:00
|
|
|
|
printf ("%-25s ", name);
|
1998-04-15 00:44:46 +08:00
|
|
|
|
|
|
|
|
|
if (H5Gstat (group, name, TRUE, &statbuf)>=0) {
|
1998-04-18 05:29:43 +08:00
|
|
|
|
sprintf (buf, "%lu:%lu:%lu:%lu",
|
|
|
|
|
statbuf.fileno[1], statbuf.fileno[0],
|
|
|
|
|
statbuf.objno[1], statbuf.objno[0]);
|
|
|
|
|
printf ("%-20s ", buf);
|
1998-04-15 00:44:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
1998-03-25 07:18:34 +08:00
|
|
|
|
if ((obj=H5Dopen (group, name))>=0) {
|
1998-04-09 05:43:02 +08:00
|
|
|
|
hsize_t size[64];
|
1998-06-19 23:26:36 +08:00
|
|
|
|
hsize_t maxsize[64];
|
1998-03-25 07:18:34 +08:00
|
|
|
|
hid_t space = H5Dget_space (obj);
|
1998-07-15 05:14:22 +08:00
|
|
|
|
int ndims = H5Sextent_dims(space, size, maxsize);
|
1998-04-18 05:29:43 +08:00
|
|
|
|
printf ("Dataset {");
|
1998-03-25 07:18:34 +08:00
|
|
|
|
for (i=0; i<ndims; i++) {
|
1998-06-19 23:26:36 +08:00
|
|
|
|
HDfprintf (stdout, "%s%Hu", i?", ":"", size[i]);
|
|
|
|
|
if (maxsize[i]==H5S_UNLIMITED)
|
|
|
|
|
HDfprintf (stdout, "/%s", "Inf");
|
|
|
|
|
else
|
|
|
|
|
HDfprintf (stdout, "/%Hu", maxsize[i]);
|
1998-03-25 07:18:34 +08:00
|
|
|
|
}
|
|
|
|
|
printf ("}\n");
|
|
|
|
|
H5Dclose (space);
|
1998-06-06 05:03:49 +08:00
|
|
|
|
H5Aiterate (obj, NULL, list_attr, NULL);
|
1998-03-25 07:18:34 +08:00
|
|
|
|
H5Dclose (obj);
|
|
|
|
|
} else if ((obj=H5Gopen (group, name))>=0) {
|
1998-04-18 05:29:43 +08:00
|
|
|
|
printf ("Group\n");
|
1998-06-06 05:03:49 +08:00
|
|
|
|
H5Aiterate (obj, NULL, list_attr, NULL);
|
1998-03-25 07:18:34 +08:00
|
|
|
|
H5Gclose (obj);
|
1998-04-18 05:29:43 +08:00
|
|
|
|
} else if (H5Gget_linkval (group, name, sizeof(buf), buf)>=0) {
|
|
|
|
|
if (NULL==HDmemchr (buf, 0, sizeof(buf))) {
|
|
|
|
|
strcpy (buf+sizeof(buf)-4, "...");
|
1998-04-15 00:44:46 +08:00
|
|
|
|
}
|
1998-04-18 05:29:43 +08:00
|
|
|
|
printf (" -> %s\n", buf);
|
1998-06-05 06:27:11 +08:00
|
|
|
|
} else if ((obj=H5Topen (group, name))>=0) {
|
|
|
|
|
printf ("Data type\n");
|
1998-06-06 05:03:49 +08:00
|
|
|
|
H5Aiterate (obj, NULL, list_attr, NULL);
|
1998-06-05 06:27:11 +08:00
|
|
|
|
H5Tclose (obj);
|
1998-03-25 07:18:34 +08:00
|
|
|
|
} else {
|
1998-04-18 05:29:43 +08:00
|
|
|
|
printf ("Unknown Type\n");
|
1998-03-25 07:18:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Restore error reporting */
|
|
|
|
|
H5Eset_auto (func, edata);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: main
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Opens a file and lists the specified group
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: 1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Monday, March 23, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
|
{
|
1998-04-09 05:43:02 +08:00
|
|
|
|
hid_t file, plist=H5P_DEFAULT;
|
|
|
|
|
const char *fname = NULL;
|
|
|
|
|
const char *gname = "/";
|
1998-05-14 01:58:24 +08:00
|
|
|
|
const char *progname;
|
|
|
|
|
|
|
|
|
|
/* Arguments */
|
|
|
|
|
if ((progname=strrchr (argv[0], '/'))) progname++;
|
|
|
|
|
else progname = argv[0];
|
|
|
|
|
if (argc<2 || argc>3) usage (progname);
|
1998-04-09 05:43:02 +08:00
|
|
|
|
fname = argv[1];
|
|
|
|
|
if (argc>=3) gname = argv[2];
|
1998-03-25 07:18:34 +08:00
|
|
|
|
|
1998-04-09 05:43:02 +08:00
|
|
|
|
/*
|
|
|
|
|
* Open the file. If the file name contains a `%' then assume that a
|
|
|
|
|
* file family is being opened.
|
|
|
|
|
*/
|
|
|
|
|
if (strchr (fname, '%')) {
|
|
|
|
|
plist = H5Pcreate (H5P_FILE_ACCESS);
|
[svn-r339] Changes since 19980408
----------------------
./src/H5Osdspace.c
./html/H5.format.html
In the past we were allowed to have >2GB files on a 32-bit
machine as long as no dataset within the file was larger than
4GB (or whatever sizeof(size_t) is). That's been fixed now.
All dataset size calculations are done with `hsize_t' which is
normally defined as `unsigned long long'.
./src/H5F.c
./src/H5Ffamily.c
./src/H5Fprivate.h
./src/H5P.c
./src/H5Ppublic.h
The file family member size can now be set/queried. The
default is still 64MB, but it can be set to 1GB by saying:
H5Pset_family (plist, 30, H5P_DEFAULT);
When opening an existing file family the specified
bits-per-member is ignored and the first member of the family
determines the bits-per-member, which can be retrieved with
H5Pget_family().
./acconfig.h
./configure.in
./src/H5config.h
./src/H5public.h
Added `--disable-hsizet' so that those with old GCC compilers
(<2.8.1) can still compile the code.
./src/H5.c
./src/H5private.h
Added HDfprintf() which works just like fprintf() except you
can give `H' as a size modifier for the integer conversions
and supply an `hsize_t' or `hssize_t' argument without casting
it. For instance:
hsize_t npoints = H5Sget_npoints(space);
HDfprintf(stdout,"Dataset has %Hd (%#018Hx) points\n",
npoints, npoints);
You can now give `%a' as a format to print an address, but all
formating flags are ignored and it causes the return value of
HDfprintf() to not include the characters in the address (but
who uses the return value anyway :-). Example:
H5G_t *grp;
HDfprintf(stdout, "Group object header at %a\n",
&(grp->ent.header));
Added HDstrtoll() which works exactly like [HD]strtol() except
the result is an int64.
./src/debug.c
Large addresses can now be entered from the command-line. Use
either decimal, octal (leading `0') or hexadecimal (leading
`0x') when giving the address.
./src/h5ls.c
The printf format for dataset dimensions was changed to `%Hu'
to support large datasets.
./test/big.c [NEW]
A test for big datasets on 32-bit machines. This test is not
run by default. Don't try to run it on an nfs-mounted file
system or other file system that doesn't support holes because
it creates two 32GB datasets of all zero.
1998-04-10 04:22:11 +08:00
|
|
|
|
H5Pset_family (plist, 0, H5P_DEFAULT);
|
1998-04-09 05:43:02 +08:00
|
|
|
|
}
|
1998-05-14 01:58:24 +08:00
|
|
|
|
if ((file = H5Fopen (fname, H5F_ACC_RDONLY, plist))<0) exit (1);
|
|
|
|
|
if (H5Giterate (file, gname, NULL, list, NULL)<0) exit (1);
|
|
|
|
|
if (H5Fclose (file)<0) exit (1);
|
1998-03-25 07:18:34 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|