hdf5/test/extend.c
Robb Matzke 7bdea74ca9 [svn-r303] Changes since 19980228
----------------------

./html/Dataspaces.html
./html/Errors.html
./html/Files.html
./html/H5.api.html
./html/review1.html
./src/H5private.h
./src/H5public.h
./test/dsets.c
./test/dtypes.c
	Removed all the types like `int32' and `intn' into private
	headers since they violate the naming scheme and pollute
	application name space.  Besides, our test files only use them
	in a handful of places and it's probably useless to export
	them to the app.  The app is always written in terms of
	standard numeric types or its own numeric types and probably
	never in terms of HDF5 numeric types.  If it were, then the
	user would have to copy from their type to hdf5 type for
	almost every hdf5 API function call!  Same goes for return
	values.  I also removed SUCCEED/FAIL from the API since apps
	should be checking against zero anyway.

	       if (FAIL==(space=H5Screate_simple(...))) /*wrong*/
	       if ((space=H5Fcreate_simple(...)<0))     /*right*/


./src/H5.c
	Changed arguments of H5version() from `uintn' to `unsigned'.

./src/H5Tpublic.h
./src/H5T.c
	Changed return type of H5Tget_nmembers() from `intn' to `int'


./src/H5A.c
./src/H5Aprivate.h
./src/H5Apublic.h
	Changed `H5Asearch_func_t' to `H5A_search_func_t' and moved
	its definition from the public to the private header file.


./html/H5.format.html
	Documented changes made to the external file list (H5O_EFL)
	message.

./src/H5D.c
./src/H5Dprivate.h
./src/H5E.c
./src/H5Epublic.h
./src/H5O.c
./src/H5Oefl.c
./src/H5Oprivate.h
./src/H5P.c
./src/H5Ppublic.h
	Added partial support for external raw data files.  HDF5 can
	now describe external raw data files by listing the file
	names, offsets, and size for a dataset. However, we will
	restrict a dataset to be stored "contiguously" when the
	external file list is viewed as a single address space. The
	current implementation is unable to read/write to external
	files--that will come later this week as will documentation.
	For now, take a look at ./test/external.c, particularly the
	calls to H5Pset_external().

./test/Makefile.in
./test/external.c		[NEW]
./MANIFEST
	Added tests for external storage.  Note: the read test is
	supposed to fail at this point since reading external datasets
	is not implemented yet.  There is no write test.

./src/H5S.c
./src/H5Sprivate.h
./src/H5Ssimp.c
	Added H5S_get_npoints_max() to return the maximum possible
	number of data points in a data space.

	Added an extra argument to H5S_get_dims() which returns the
	maximum dims.

./src/H5F.c
./src/H5Fprivate.h
./src/H5Fpublic.h
./src/H5M.c			[DEPRICATED]
./src/H5Mpublic.h		[DEPRICATED]
	Changed `template' to `property list' in lots of places.

./src/H5Osdspace.c
	Removed an extra `\n' from a print statement.

./src/H5S_public.h
	Changed H5S_UNLIMITED to the maximum size_t value.

./test/extend.c
	"Extendable" is spelled "extendible".

./src/H5Farray.c
./src/H5V.c
./src/H5Vprivate.h
./test/hyperslab.c
	Strides are now type ssize_t instead of int.  These have
	nothing to do with the sample granularity arguments for
	hyperslabs, which are also called "strides" in the code.

./test/tstab.c
	Changed assumptions about default address and length sizes.
1998-03-04 11:20:23 -05:00

132 lines
3.2 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (C) 1998 Spizella Software
* All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
* Friday, January 30, 1998
*
* Purpose: Tests extendible datasets.
*/
#include <assert.h>
#include <hdf5.h>
#define NX 100 /* USE AN EVEN NUMBER!*/
#define NY 100 /* USE AN EVEN NUMBER!*/
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests extendible datasets
*
* Return: Success: exit(0)
*
* Failure: exit(non-zero)
*
* Programmer: Robb Matzke
* Friday, January 30, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
main (void)
{
hid_t file, dataset, mem_space, file_space, cparms;
herr_t status;
int i, j, k, m;
static int buf1[NY][NX], buf2[NX/2][NY/2];
static const size_t dims[2] = {NX, NY};
static const size_t half_dims[2] = {NX/2, NY/2};
static const size_t chunk_dims[2] = {NX/2, NY/2};
static size_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
static size_t size[2];
int offset[2];
/* Initialize buffer and space */
for (i=0; i<NX; i++) {
for (j=0; j<NY; j++) {
buf1[i][j] = i*NY+j;
}
}
mem_space = H5Screate_simple (2, dims, maxdims);
assert (mem_space>=0);
/* Create the file */
file = H5Fcreate ("extend.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
assert (file>=0);
/* Create the dataset which is originally NX by NY */
cparms = H5Pcreate (H5P_DATASET_CREATE);
assert (cparms>=0);
status = H5Pset_chunk (cparms, 2, chunk_dims);
assert (status>=0);
dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space, cparms);
assert (dataset>=0);
/* Write the data */
for (i=0; i<5; i++) {
for (j=0; j<5; j++) {
/* Extend the dataset */
offset[0] = i * NX;
offset[1] = j * NY;
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
status = H5Dextend (dataset, size);
assert (status>=0);
/* Select a hyperslab */
file_space = H5Dget_space (dataset);
assert (file_space>=0);
status = H5Sset_hyperslab (file_space, offset, dims, NULL);
assert (status>=0);
/* Write to the hyperslab */
status = H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf1);
assert (status>=0);
H5Sclose (file_space);
}
}
H5Sclose (mem_space);
/* Read the data */
mem_space = H5Screate_simple (2, half_dims, NULL);
file_space = H5Dget_space (dataset);
for (i=0; i<10; i++) {
for (j=0; j<10; j++) {
/* Select a hyperslab */
offset[0] = i * NX/2;
offset[1] = j * NY/2;
assert (file_space>=0);
status = H5Sset_hyperslab (file_space, offset, half_dims, NULL);
assert (status>=0);
/* Read */
status = H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf2);
assert (status>=0);
/* Compare */
for (k=0; k<NX/2; k++) {
for (m=0; m<NY/2; m++) {
assert (buf2[k][m]==buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]);
}
}
}
}
H5Dclose (dataset);
H5Fclose (file);
return 0;
}