2007-07-14 05:17:44 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* 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. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generate the binary hdf5 files for the h5stat tests.
|
|
|
|
* Usage: just execute the program without any arguments will
|
|
|
|
* generate all the binary hdf5 files in the ./testfiles directory.
|
|
|
|
*
|
|
|
|
* If you regenerate the test files (e.g., changing some code,
|
|
|
|
* trying it on a new platform, ...), you need to verify the correctness
|
|
|
|
* of the expected output and update the corresponding *.ddl files.
|
|
|
|
*/
|
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
#include <assert.h>
|
2007-07-14 05:17:44 +08:00
|
|
|
#include "hdf5.h"
|
|
|
|
|
|
|
|
#define FILE "h5stat_newgrat.h5"
|
|
|
|
#define DATASET_NAME "DATASET_NAME"
|
|
|
|
#define GROUP_NAME "GROUP"
|
|
|
|
#define ATTR_NAME "ATTR"
|
2008-05-01 03:51:13 +08:00
|
|
|
#define NUM_GRPS 35000
|
2007-07-14 05:17:44 +08:00
|
|
|
#define NUM_ATTRS 100
|
|
|
|
|
2008-09-16 23:52:51 +08:00
|
|
|
/*
|
2007-07-14 05:17:44 +08:00
|
|
|
* Generate 1.8 HDF5 file
|
|
|
|
* with NUM_GRPS groups
|
2007-08-24 04:25:25 +08:00
|
|
|
* with NUM_ATTRS attributes on the dataset
|
2007-07-14 05:17:44 +08:00
|
|
|
*/
|
|
|
|
static void gen_file(void)
|
|
|
|
{
|
[svn-r17582] Description:
Bring changes from file free space branch back to the trunk. *yay!*
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-02 10:08:59 +08:00
|
|
|
hid_t fcpl; /* File creation property */
|
|
|
|
hid_t fapl; /* File access property */
|
|
|
|
hid_t file; /* File id */
|
|
|
|
hid_t gid; /* Group id */
|
|
|
|
hid_t type_id; /* Datatype id */
|
|
|
|
hid_t space_id; /* Dataspace id */
|
|
|
|
hid_t attr_id; /* Attribute id */
|
|
|
|
hid_t dset_id; /* Dataset id */
|
|
|
|
char name[30]; /* Group name */
|
|
|
|
char attrname[30]; /* Attribute name */
|
|
|
|
int ret; /* Return value */
|
|
|
|
int i; /* Local index variable */
|
2007-07-14 05:17:44 +08:00
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
fapl = H5Pcreate(H5P_FILE_ACCESS);
|
[svn-r14413] Description:
Change H5P[gs]et_format_bounds() => H5P[gs]et_libver_bounds() and also
enumerated values H5F_FORMAT_{EARLIEST, LATEST} => H5F_LIBVER_{EARLIEST, LATEST}
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-01-15 07:49:12 +08:00
|
|
|
ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
|
[svn-r17582] Description:
Bring changes from file free space branch back to the trunk. *yay!*
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-02 10:08:59 +08:00
|
|
|
assert(ret >= 0);
|
|
|
|
|
|
|
|
/* Set file space handling strategy */
|
|
|
|
fcpl = H5Pcreate(H5P_FILE_CREATE);
|
2009-11-17 10:43:53 +08:00
|
|
|
ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0);
|
2009-03-11 03:00:39 +08:00
|
|
|
assert(ret >= 0);
|
2007-07-14 05:17:44 +08:00
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
/* Create dataset */
|
[svn-r17582] Description:
Bring changes from file free space branch back to the trunk. *yay!*
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-02 10:08:59 +08:00
|
|
|
file = H5Fcreate(FILE, H5F_ACC_TRUNC, fcpl, fapl);
|
2007-08-24 04:25:25 +08:00
|
|
|
for(i = 1; i <= NUM_GRPS; i++) {
|
|
|
|
sprintf(name, "%s%d", GROUP_NAME,i);
|
|
|
|
gid = H5Gcreate2(file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
H5Gclose(gid);
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
} /* end for */
|
2007-07-14 05:17:44 +08:00
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
/* Create a datatype to commit and use */
|
|
|
|
type_id = H5Tcopy(H5T_NATIVE_INT);
|
2007-07-14 05:17:44 +08:00
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
/* Create dataspace for dataset */
|
|
|
|
space_id = H5Screate(H5S_SCALAR);
|
2007-07-14 05:17:44 +08:00
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
/* Create dataset */
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
dset_id = H5Dcreate2(file, DATASET_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
2007-08-24 04:25:25 +08:00
|
|
|
for(i = 1; i <= NUM_ATTRS; i++) {
|
|
|
|
sprintf(attrname, "%s%d", ATTR_NAME,i);
|
[svn-r14218] Description:
Changed H5Acreate2 -> H5Acreate_by_name, to be more consistent with
other new API routines.
Re-added simpler form of H5Acreate2, which creates attributes directly
on an object.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-31 02:13:48 +08:00
|
|
|
attr_id = H5Acreate2(dset_id, attrname, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
|
2007-08-24 04:25:25 +08:00
|
|
|
ret = H5Aclose(attr_id);
|
2009-03-11 03:00:39 +08:00
|
|
|
assert(ret >= 0);
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
} /* end for */
|
2007-07-14 05:17:44 +08:00
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
ret = H5Dclose(dset_id);
|
2009-03-11 03:00:39 +08:00
|
|
|
assert(ret >= 0);
|
2007-08-24 04:25:25 +08:00
|
|
|
ret = H5Sclose(space_id);
|
2009-03-11 03:00:39 +08:00
|
|
|
assert(ret >= 0);
|
2007-08-24 04:25:25 +08:00
|
|
|
ret = H5Tclose(type_id);
|
2009-03-11 03:00:39 +08:00
|
|
|
assert(ret >= 0);
|
2007-08-24 04:25:25 +08:00
|
|
|
ret = H5Fclose(file);
|
2009-03-11 03:00:39 +08:00
|
|
|
assert(ret >= 0);
|
2007-07-14 05:17:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
gen_file();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-08-24 04:25:25 +08:00
|
|
|
|