diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-10-02 02:08:59 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-10-02 02:08:59 (GMT) |
commit | 37ec6dc75e85ebd7f9fb9b32fe978e47ab3fe918 (patch) | |
tree | 387658306d99e60d807c2eb8b3888a12aca4a75f /test/gen_filespace.c | |
parent | 006071f2338faa14f2784562279cb78b4341bce0 (diff) | |
download | hdf5-37ec6dc75e85ebd7f9fb9b32fe978e47ab3fe918.zip hdf5-37ec6dc75e85ebd7f9fb9b32fe978e47ab3fe918.tar.gz hdf5-37ec6dc75e85ebd7f9fb9b32fe978e47ab3fe918.tar.bz2 |
[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
Diffstat (limited to 'test/gen_filespace.c')
-rw-r--r-- | test/gen_filespace.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/gen_filespace.c b/test/gen_filespace.c new file mode 100644 index 0000000..e9dee1c --- /dev/null +++ b/test/gen_filespace.c @@ -0,0 +1,81 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "hdf5.h" + +#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ +#define TEST_THRESHOLD2 2 /* Free space section threshold */ + +const char *FILENAMES[] = { + "filespace_persist.h5", /* H5F_FILE_SPACE_ALL_PERSIST */ + "filespace_default.h5", /* H5F_FILE_SPACE_ALL */ + "filespace_aggr_vfd.h5", /* H5F_FILE_SPACE_AGGR_VFD */ + "filespace_vfd.h5", /* H5F_FILE_SPACE_VFD */ + "filespace_threshold.h5" /* H5F_FILE_SPACE_ALL, non-default threshold */ +}; + +#define DATASET "dset" +#define NUM_ELMTS 100 + +/* + * Compile and run this program in file-space branch to generate + * HDF5 files with different kinds of file space strategies + * Move the HDF5 files to the 1.6 and 1.8 branch for compatibility + * testing:test_filespace_compatible() will use the files + */ +static void gen_file(void) +{ + hid_t fid; + hid_t fcpl; + hid_t dataset, space; + hsize_t dim[1]; + int data[NUM_ELMTS]; + unsigned i, j; /* Local index variable */ + H5F_file_space_type_t fs_type; /* File space handling strategy */ + + for(j = 0, fs_type = H5F_FILE_SPACE_ALL_PERSIST; j < NELMTS(FILENAMES); j++, (H5F_file_space_type_t)(fs_type)++) { + /* Get a copy of the default file creation property */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + + if(fs_type == H5F_FILE_SPACE_NTYPES) /* last file */ + /* Set default strategy but non-default threshold */ + H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL, (hsize_t)TEST_THRESHOLD2); + else + /* Set specified file space strategy and free space section threshold */ + H5Pset_file_space(fcpl, fs_type, (hsize_t)0); + + /* Create the file with the file space info */ + fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); + + dim[0] = NUM_ELMTS; + space = H5Screate_simple(1, dim, NULL); + dataset = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + for(i = 0; i < NUM_ELMTS; i++) + data[i] = i; + + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + H5Dclose(dataset); + H5Sclose(space); + H5Fclose(fid); + } +} + +int main(void) +{ + gen_file(); + + return 0; +} |