2004-12-29 22:26:20 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2004-12-29 22:26:20 +08:00
|
|
|
* 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 *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:04 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2004-12-29 22:26:20 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
2020-08-01 02:40:29 +08:00
|
|
|
* Programmer: Quincey Koziol
|
2004-12-29 22:26:20 +08:00
|
|
|
* Saturday, April 17, 2004
|
|
|
|
*
|
|
|
|
* Purpose: Create a dataset with a null dataspace and an attribute
|
|
|
|
* with a null dataspace.
|
|
|
|
* This program is used to create the test file `tnullspace.h5' which
|
|
|
|
* has dataspaces stored in the newer (version 2) style in the object headers.
|
|
|
|
* To build the test file, this program MUST be compiled and linked with
|
|
|
|
* the hdf5-1.7+ series of libraries and the generated test file must be
|
|
|
|
* put into the 'test' directory in the 1.6.x branch of the library.
|
|
|
|
*/
|
|
|
|
|
2020-08-01 02:40:29 +08:00
|
|
|
#include "h5test.h"
|
2004-12-29 22:26:20 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
#define NULLFILE "tnullspace.h5"
|
|
|
|
#define NULLDATASET "null_dataset"
|
|
|
|
#define NULLATTR "null_attribute"
|
2004-12-29 22:26:20 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t fid; /* File ID */
|
|
|
|
hid_t gid; /* Group ID */
|
|
|
|
hid_t sid; /* Dataspace ID */
|
|
|
|
hid_t did; /* Dataset ID */
|
|
|
|
hid_t attr; /* Attribute ID */
|
|
|
|
herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +08:00
|
|
|
/* Create the file */
|
|
|
|
fid = H5Fcreate(NULLFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(fid > 0);
|
2004-12-29 22:26:20 +08:00
|
|
|
|
|
|
|
sid = H5Screate(H5S_NULL);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(sid > 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +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
|
|
|
did = H5Dcreate2(fid, NULLDATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(did > 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +08:00
|
|
|
/* Close the dataset */
|
|
|
|
ret = H5Dclose(did);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(ret >= 0);
|
2004-12-29 22:26:20 +08:00
|
|
|
|
|
|
|
/* Open the root group */
|
2007-08-28 23:02:54 +08:00
|
|
|
gid = H5Gopen2(fid, "/", H5P_DEFAULT);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(gid > 0);
|
2004-12-29 22:26:20 +08:00
|
|
|
|
|
|
|
/* Create an attribute for the group */
|
[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 = H5Acreate2(gid, NULLATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(attr > 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +08:00
|
|
|
/* Close attribute */
|
[svn-r14187] Description:
Put H5Acreate() under API versioning, with all internal usage shifted
to H5Acreate2().
Add regression tests for H5Acreate1().
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-05 06:19:07 +08:00
|
|
|
ret = H5Aclose(attr);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(ret >= 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +08:00
|
|
|
/* Close the group */
|
|
|
|
ret = H5Gclose(gid);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(ret >= 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +08:00
|
|
|
/* Close the dataspace */
|
|
|
|
ret = H5Sclose(sid);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(ret >= 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-12-29 22:26:20 +08:00
|
|
|
/* Close the file */
|
|
|
|
ret = H5Fclose(fid);
|
2020-08-01 02:40:29 +08:00
|
|
|
HDassert(ret >= 0);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2020-08-01 02:40:29 +08:00
|
|
|
return EXIT_SUCCESS;
|
2004-12-29 22:26:20 +08:00
|
|
|
}
|