hdf5/test/extend.c
Robb Matzke cc89b8a605 [svn-r1572] Changes since 19990810
----------------------

./MANIFEST
./src/H5FDmulti.c		[NEW]
./src/H5FDmulti.h		[NEW]
./src/Makefile.in
./src/hdf5.h
	The split driver was reimplemented as a more general "multi"
	driver which is capable of splitting data into multiple files
	like the family driver except the partioning is done by memory
	usage type instead of address. The H5Pset_fapl_split()
	function just calls H5Pset_fapl_multi() with arguments which
	prepare to split the address space into two files: meta and
	raw data.

	This is the first version. I plan to allow the open() call to
	relax a bit which would allow one to open an hdf5 file when
	only the meta-data file is present. This would allow a very
	large file to be split and stored on tape and the relatively
	small meta file to be mirrored on disk to allow limited
	browsing of the file (any request for raw data would fail).

./src/H5private.h
./src/H5F.c
./src/H5FD.c
./src/H5FDprivate.h
./src/H5FDpublic.h
./src/H5FDcore.c
./src/H5FDfamily.c
./src/H5FDmpio.c
./src/H5FDsec2.c
	Added the ability for a file driver to store information in
	the superblock which would be needed if the file were opened
	again later for reading.  The format is driver-defined which
	allows users to extend it however they like.

./doc/html/H5.format.html
	Added information about the new driver information block of
	the superblock. This is where file drivers store information
	they need in order to reopen the file later.


./src/H5F.c
./src/H5Fprivate.h
./src/H5FD.c
./src/H5FDprivate.h
./src/H5FDpublic.h
./src/H5FDcore.c
./src/H5FDfamily.c
./src/H5FDmpio.c
./src/H5FDsec2.c
./src/H5Fistore.c
./src/H5R.c
	The file access properties and the file access property list
	were decoupled, which allows the property list to more cleanly
	contain properties for various levels of the file and which
	allows the property list to be modified more cleanly when
	opening files.

./src/H5.c
./src/H5FDpublic.h
	Removed H5FD_MEM_META and H5FD_MEM_GROUP since they're never
	used.

./src/H5D.c
	Changed the way we detect the MPIO driver in all these special
	cases.

./src/H5F.c
./src/H5Rpublic.h
./test/tfile.c
	The default file sizeof(offset) was changed to be a function
	of haddr_t instead of hsize_t.

	THE H5RPUBLIC.H DEFINITIONS WILL HAVE PROBLEMS IF THE USER
	CREATES A FILE WITH NON-DEFAULT OFFSET AND SIZE SIZES!

./src/H5F.c
	Fixed an uninitialized memory access bug in file closing
	related to the VFL.

./src/H5T.c
./src/H5Tpublic.h
	Added an H5T_NATIVE_HADDR predefined datatype which
	corresponds to the `haddr_t' type.

./test/Makefile.in
	Reformatted long lines.

./test/big.c
./test/cmpd_dset.c
./test/dsets.c
./test/dtypes.c
./test/extend.c
./test/external.c
	Removed the H5F_ACC_DEBUG flag from file creation/open calls.

./test/big.c
	Plugged a memory leak.

./test/h5test.c
	Added support for the `multi' driver.

	Removed #warning about not having the stdio driver. Plans are
	to not implement it since the sec2 driver serves the same
	purpose and testing didn't show any difference in execution
	times between the two.
1999-08-17 14:12:59 -05:00

144 lines
3.7 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 <h5test.h>
const char *FILENAME[] = {
"extend",
NULL
};
#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;
hid_t fapl;
int i, j, k, m;
static int buf1[NY][NX], buf2[NX/2][NY/2];
static const hsize_t dims[2] = {NX, NY};
static const hsize_t half_dims[2] = {NX/2, NY/2};
static const hsize_t chunk_dims[2] = {NX/2, NY/2};
static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
static hsize_t size[2];
hssize_t offset[2];
char filename[1024];
h5_reset();
fapl = h5_fileaccess();
TESTING("dataset extend");
/* Initialize buffer and space */
for (i=0; i<NX; i++) {
for (j=0; j<NY; j++) {
buf1[i][j] = i*NY+j;
}
}
if ((mem_space = H5Screate_simple (2, dims, maxdims))<0) goto error;
/* Create the file */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) {
goto error;
}
/* Create the dataset which is originally NX by NY */
if ((cparms = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_chunk (cparms, 2, chunk_dims)<0) goto error;
if ((dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space,
cparms))<0) goto error;
if (H5Pclose (cparms)<0) goto error;
/* 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;
if (H5Dextend (dataset, size)<0) goto error;
/* Select a hyperslab */
if ((file_space = H5Dget_space (dataset))<0) goto error;
if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
NULL, dims, NULL)<0) goto error;
/* Write to the hyperslab */
if (H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf1)<0) goto error;
if (H5Sclose (file_space)<0) goto error;
}
}
if (H5Sclose (mem_space)<0) goto error;
/* Read the data */
if ((mem_space = H5Screate_simple (2, half_dims, NULL))<0) goto error;
if ((file_space = H5Dget_space (dataset))<0) goto error;
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;
if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
NULL, half_dims, NULL)<0) goto error;
/* Read */
if (H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf2)<0) goto error;
/* Compare */
for (k=0; k<NX/2; k++) {
for (m=0; m<NY/2; m++) {
if (buf2[k][m]!=buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]) {
FAILED();
printf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m);
goto error;
}
}
}
}
}
if (H5Dclose (dataset)<0) goto error;
if (H5Fclose (file)<0) goto error;
PASSED();
printf("All extend tests passed.\n");
h5_cleanup(fapl);
return 0;
error:
printf("*** One or more extend tests failed ***\n");
return 1;
}