summaryrefslogtreecommitdiffstats
path: root/examples/h5_extend_write.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-08-31 19:21:23 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-08-31 19:21:23 (GMT)
commit2ab2e14bb59d6ae7013bba9458e9f5a3b5cc2d1a (patch)
treec23cdadb45857e5e8549bb14fd057db63cce7c26 /examples/h5_extend_write.c
parent473452205dcc08055486d29b6dc5f36670c3ceb5 (diff)
downloadhdf5-2ab2e14bb59d6ae7013bba9458e9f5a3b5cc2d1a.zip
hdf5-2ab2e14bb59d6ae7013bba9458e9f5a3b5cc2d1a.tar.gz
hdf5-2ab2e14bb59d6ae7013bba9458e9f5a3b5cc2d1a.tar.bz2
[svn-r635] Changes since 19980831
---------------------- ./Makefile.in Running `make distclean' will not fail if one of the subdirectories has already been cleaned. ./config/BlankForm ./config/irix5.3 Cleaned it up more. Added better support/documentation for systems that have more than one compiler. ./config/alpha-dec-osf4.0 [NEW] Added a new config file as a result of testing on Jim Reus's machine. ./test/chunk.c Scaled down the testing range so we can actually run it interactively. ./tools/h5import.c Included <unistd.h> to get rid of warning for close(). ./src/H5detect.c Seg-faults on Linux for some reason when NDEBUG is defined, so I just undef it at the top of the source. ./test/big.c Added a fflush(). ./tools/h5ls.c The `-d' flag now works even when `-v' isn't specified. ./examples/h5_chunk_read.c ./examples/h5_compound.c ./examples/h5_extend_write.c ./examples/h5_group.c ./examples/h5_read.c ./examples/h5_write.c Indented according to hdf5 standards. Fixed compiler warnings
Diffstat (limited to 'examples/h5_extend_write.c')
-rw-r--r--examples/h5_extend_write.c304
1 files changed, 154 insertions, 150 deletions
diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c
index 6b20a1e..af061bc 100644
--- a/examples/h5_extend_write.c
+++ b/examples/h5_extend_write.c
@@ -13,155 +13,159 @@
#define NX 10
#define NY 5
-main ()
+int
+main (void)
{
- hid_t file; /* handles */
- hid_t datatype, dataspace, dataset;
- hid_t filespace;
- hid_t cparms;
- hsize_t dims[2] = { 3, 3}; /* dataset dimensions
- at the creation time */
- hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */
- hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */
- hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */
-
- hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={2, 5};
- hsize_t size[2];
- hssize_t offset[2];
-
- herr_t status;
-
- int data1[3][3] = { 1, 1, 1, /* data to write */
- 1, 1, 1,
- 1, 1, 1 };
-
- int data2[7] = { 2, 2, 2, 2, 2, 2, 2};
-
- int data3[2][2] = { 3, 3,
- 3, 3};
-
-/*
- * Create the data space with ulimited dimensions.
- */
-dataspace = H5Screate_simple(RANK, dims, maxdims);
-
-/*
- * Create a new file. If file exists its contents will be overwritten.
- */
-file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
-/*
- * Modify dataset creation properties, i.e. enable chunking.
- */
-cparms = H5Pcreate (H5P_DATASET_CREATE);
-status = H5Pset_chunk( cparms, RANK, chunk_dims);
-
-/*
- * Create a new dataset within the file using cparms
- * creation properties.
- */
-dataset = H5Dcreate(file, DATASETNAME, H5T_NATIVE_INT, dataspace,
- cparms);
-
-/*
- * Extend the dataset. This call assures that dataset is at least 3 x 3.
- */
-size[0] = 3;
-size[1] = 3;
-status = H5Dextend (dataset, size);
-
-/*
- * Select a hyperslab.
- */
-filespace = H5Dget_space (dataset);
-offset[0] = 0;
-offset[1] = 0;
-status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims1, NULL);
-
-/*
- * Write the data to the hyperslab.
- */
-status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
- H5P_DEFAULT, data1);
-
-/*
- * Extend the dataset. Dataset becomes 10 x 3.
- */
-dims[0] = dims1[0] + dims2[0];
-size[0] = dims[0];
-size[1] = dims[1];
-status = H5Dextend (dataset, size);
-
-/*
- * Select a hyperslab.
- */
-filespace = H5Dget_space (dataset);
-offset[0] = 3;
-offset[1] = 0;
-status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims2, NULL);
-
-/*
- * Define memory space
- */
-dataspace = H5Screate_simple(RANK, dims2, NULL);
-
-/*
- * Write the data to the hyperslab.
- */
-status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
- H5P_DEFAULT, data2);
-
-/*
- * Extend the dataset. Dataset becomes 10 x 5.
- */
-dims[1] = dims1[1] + dims3[1];
-size[0] = dims[0];
-size[1] = dims[1];
-status = H5Dextend (dataset, size);
-
-/*
- * Select a hyperslab
- */
-filespace = H5Dget_space (dataset);
-offset[0] = 0;
-offset[1] = 3;
-status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims3, NULL);
-
-/*
- * Define memory space.
- */
-dataspace = H5Screate_simple(RANK, dims3, NULL);
-
-/*
- * Write the data to the hyperslab.
- */
-status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
- H5P_DEFAULT, data3);
-
-/*
- * Resulting dataset
- *
- 3 3 3 2 2
- 3 3 3 2 2
- 3 3 3 0 0
- 2 0 0 0 0
- 2 0 0 0 0
- 2 0 0 0 0
- 2 0 0 0 0
- 2 0 0 0 0
- 2 0 0 0 0
- 2 0 0 0 0
- */
-/*
- * Close/release resources.
- */
-H5Dclose(dataset);
-H5Sclose(dataspace);
-H5Sclose(filespace);
-H5Fclose(file);
-
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t filespace;
+ hid_t cparms;
+ hsize_t dims[2] = { 3, 3}; /*
+ * dataset dimensions
+ * at the creation time
+ */
+ hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */
+ hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */
+ hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */
+
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] ={2, 5};
+ hsize_t size[2];
+ hssize_t offset[2];
+
+ herr_t status;
+
+ int data1[3][3] = { {1, 1, 1}, /* data to write */
+ {1, 1, 1},
+ {1, 1, 1} };
+
+ int data2[7] = { 2, 2, 2, 2, 2, 2, 2};
+
+ int data3[2][2] = { {3, 3},
+ {3, 3} };
+
+ /*
+ * Create the data space with ulimited dimensions.
+ */
+ dataspace = H5Screate_simple(RANK, dims, maxdims);
+
+ /*
+ * Create a new file. If file exists its contents will be overwritten.
+ */
+ file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Modify dataset creation properties, i.e. enable chunking.
+ */
+ cparms = H5Pcreate (H5P_DATASET_CREATE);
+ status = H5Pset_chunk( cparms, RANK, chunk_dims);
+
+ /*
+ * Create a new dataset within the file using cparms
+ * creation properties.
+ */
+ dataset = H5Dcreate(file, DATASETNAME, H5T_NATIVE_INT, dataspace,
+ cparms);
+
+ /*
+ * Extend the dataset. This call assures that dataset is at least 3 x 3.
+ */
+ size[0] = 3;
+ size[1] = 3;
+ status = H5Dextend (dataset, size);
+
+ /*
+ * Select a hyperslab.
+ */
+ filespace = H5Dget_space (dataset);
+ offset[0] = 0;
+ offset[1] = 0;
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
+ dims1, NULL);
+
+ /*
+ * Write the data to the hyperslab.
+ */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
+ H5P_DEFAULT, data1);
+
+ /*
+ * Extend the dataset. Dataset becomes 10 x 3.
+ */
+ dims[0] = dims1[0] + dims2[0];
+ size[0] = dims[0];
+ size[1] = dims[1];
+ status = H5Dextend (dataset, size);
+
+ /*
+ * Select a hyperslab.
+ */
+ filespace = H5Dget_space (dataset);
+ offset[0] = 3;
+ offset[1] = 0;
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
+ dims2, NULL);
+
+ /*
+ * Define memory space
+ */
+ dataspace = H5Screate_simple(RANK, dims2, NULL);
+
+ /*
+ * Write the data to the hyperslab.
+ */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
+ H5P_DEFAULT, data2);
+
+ /*
+ * Extend the dataset. Dataset becomes 10 x 5.
+ */
+ dims[1] = dims1[1] + dims3[1];
+ size[0] = dims[0];
+ size[1] = dims[1];
+ status = H5Dextend (dataset, size);
+
+ /*
+ * Select a hyperslab
+ */
+ filespace = H5Dget_space (dataset);
+ offset[0] = 0;
+ offset[1] = 3;
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
+ dims3, NULL);
+
+ /*
+ * Define memory space.
+ */
+ dataspace = H5Screate_simple(RANK, dims3, NULL);
+
+ /*
+ * Write the data to the hyperslab.
+ */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,
+ H5P_DEFAULT, data3);
+
+ /*
+ * Resulting dataset
+ *
+ * 3 3 3 2 2
+ * 3 3 3 2 2
+ * 3 3 3 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ */
+ /*
+ * Close/release resources.
+ */
+ H5Dclose(dataset);
+ H5Sclose(dataspace);
+ H5Sclose(filespace);
+ H5Fclose(file);
+
+ return 0;
}