diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/h5_cmprss.c | 250 | ||||
-rw-r--r-- | examples/h5_crtatt.c | 126 | ||||
-rw-r--r-- | examples/h5_crtdat.c | 102 | ||||
-rw-r--r-- | examples/h5_crtgrp.c | 80 | ||||
-rw-r--r-- | examples/h5_crtgrpar.c | 96 | ||||
-rw-r--r-- | examples/h5_crtgrpd.c | 182 | ||||
-rw-r--r-- | examples/h5_rdwt.c | 106 |
7 files changed, 471 insertions, 471 deletions
diff --git a/examples/h5_cmprss.c b/examples/h5_cmprss.c index 4a2f982..8d365a3 100644 --- a/examples/h5_cmprss.c +++ b/examples/h5_cmprss.c @@ -1,125 +1,125 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates how to create a compressed dataset.
- * It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-
-#define FILE "cmprss.h5"
-#define RANK 2
-#define DIM0 100
-#define DIM1 20
-
-int main () {
-
- hid_t file_id, dataset_id, dataspace_id; /* identifiers */
- hid_t plist_id;
-
- size_t nelmts;
- unsigned flags, filter_info;
- H5Z_filter_t filter_type;
-
- herr_t status;
- hsize_t dims[2];
- hsize_t cdims[2];
-
- int idx;
- int i,j, numfilt;
- int buf[DIM0][DIM1];
- int rbuf [DIM0][DIM1];
-
- /* Uncomment these variables to use SZIP compression
- unsigned szip_options_mask;
- unsigned szip_pixels_per_block;
- */
-
- /* Create a file. */
- file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
-
- /* Create dataset "Compressed Data" in the group using absolute name. */
- dims[0] = DIM0;
- dims[1] = DIM1;
- dataspace_id = H5Screate_simple (RANK, dims, NULL);
-
- plist_id = H5Pcreate (H5P_DATASET_CREATE);
-
- /* Dataset must be chunked for compression */
- cdims[0] = 20;
- cdims[1] = 20;
- status = H5Pset_chunk (plist_id, 2, cdims);
-
- /* Set ZLIB / DEFLATE Compression using compression level 6.
- * To use SZIP Compression comment out these lines.
- */
- status = H5Pset_deflate (plist_id, 6);
-
- /* Uncomment these lines to set SZIP Compression
- szip_options_mask = H5_SZIP_NN_OPTION_MASK;
- szip_pixels_per_block = 16;
- status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block);
- */
-
- dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE,
- dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT);
-
- for (i = 0; i< DIM0; i++)
- for (j=0; j<DIM1; j++)
- buf[i][j] = i+j;
-
- status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
-
- status = H5Sclose (dataspace_id);
- status = H5Dclose (dataset_id);
- status = H5Pclose (plist_id);
- status = H5Fclose (file_id);
-
- /* Now reopen the file and dataset in the file. */
- file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- dataset_id = H5Dopen2 (file_id, "Compressed_Data", H5P_DEFAULT);
-
- /* Retrieve filter information. */
- plist_id = H5Dget_create_plist (dataset_id);
-
- numfilt = H5Pget_nfilters (plist_id);
- printf ("Number of filters associated with dataset: %i\n", numfilt);
-
- for (i=0; i<numfilt; i++) {
- nelmts = 0;
- filter_type = H5Pget_filter2 (plist_id, 0, &flags, &nelmts, NULL, 0, NULL,
- &filter_info);
- printf ("Filter Type: ");
- switch (filter_type) {
- case H5Z_FILTER_DEFLATE:
- printf ("H5Z_FILTER_DEFLATE\n");
- break;
- case H5Z_FILTER_SZIP:
- printf ("H5Z_FILTER_SZIP\n");
- break;
- default:
- printf ("Other filter type included.\n");
- }
- }
-
- status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, rbuf);
-
- status = H5Dclose (dataset_id);
- status = H5Pclose (plist_id);
- status = H5Fclose (file_id);
-}
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates how to create a compressed dataset. + * It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" + +#define FILE "cmprss.h5" +#define RANK 2 +#define DIM0 100 +#define DIM1 20 + +int main () { + + hid_t file_id, dataset_id, dataspace_id; /* identifiers */ + hid_t plist_id; + + size_t nelmts; + unsigned flags, filter_info; + H5Z_filter_t filter_type; + + herr_t status; + hsize_t dims[2]; + hsize_t cdims[2]; + + int idx; + int i,j, numfilt; + int buf[DIM0][DIM1]; + int rbuf [DIM0][DIM1]; + + /* Uncomment these variables to use SZIP compression + unsigned szip_options_mask; + unsigned szip_pixels_per_block; + */ + + /* Create a file. */ + file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + + /* Create dataset "Compressed Data" in the group using absolute name. */ + dims[0] = DIM0; + dims[1] = DIM1; + dataspace_id = H5Screate_simple (RANK, dims, NULL); + + plist_id = H5Pcreate (H5P_DATASET_CREATE); + + /* Dataset must be chunked for compression */ + cdims[0] = 20; + cdims[1] = 20; + status = H5Pset_chunk (plist_id, 2, cdims); + + /* Set ZLIB / DEFLATE Compression using compression level 6. + * To use SZIP Compression comment out these lines. + */ + status = H5Pset_deflate (plist_id, 6); + + /* Uncomment these lines to set SZIP Compression + szip_options_mask = H5_SZIP_NN_OPTION_MASK; + szip_pixels_per_block = 16; + status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block); + */ + + dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE, + dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT); + + for (i = 0; i< DIM0; i++) + for (j=0; j<DIM1; j++) + buf[i][j] = i+j; + + status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + + status = H5Sclose (dataspace_id); + status = H5Dclose (dataset_id); + status = H5Pclose (plist_id); + status = H5Fclose (file_id); + + /* Now reopen the file and dataset in the file. */ + file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT); + dataset_id = H5Dopen2 (file_id, "Compressed_Data", H5P_DEFAULT); + + /* Retrieve filter information. */ + plist_id = H5Dget_create_plist (dataset_id); + + numfilt = H5Pget_nfilters (plist_id); + printf ("Number of filters associated with dataset: %i\n", numfilt); + + for (i=0; i<numfilt; i++) { + nelmts = 0; + filter_type = H5Pget_filter2 (plist_id, 0, &flags, &nelmts, NULL, 0, NULL, + &filter_info); + printf ("Filter Type: "); + switch (filter_type) { + case H5Z_FILTER_DEFLATE: + printf ("H5Z_FILTER_DEFLATE\n"); + break; + case H5Z_FILTER_SZIP: + printf ("H5Z_FILTER_SZIP\n"); + break; + default: + printf ("Other filter type included.\n"); + } + } + + status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, rbuf); + + status = H5Dclose (dataset_id); + status = H5Pclose (plist_id); + status = H5Fclose (file_id); +} diff --git a/examples/h5_crtatt.c b/examples/h5_crtatt.c index 416839f..5e1378c 100644 --- a/examples/h5_crtatt.c +++ b/examples/h5_crtatt.c @@ -1,63 +1,63 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates how to create an attribute attached to a
- * dataset. It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-#define FILE "dset.h5"
-
-int main() {
-
- hid_t file_id, dataset_id, attribute_id, dataspace_id; /* identifiers */
- hsize_t dims;
- int attr_data[2];
- herr_t status;
-
- /* Initialize the attribute data. */
- attr_data[0] = 100;
- attr_data[1] = 200;
-
- /* Open an existing file. */
- file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
-
- /* Open an existing dataset. */
- dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
-
- /* Create the data space for the attribute. */
- dims = 2;
- dataspace_id = H5Screate_simple(1, &dims, NULL);
-
- /* Create a dataset attribute. */
- attribute_id = H5Acreate2 (dataset_id, "Units", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT);
-
- /* Write the attribute data. */
- status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data);
-
- /* Close the attribute. */
- status = H5Aclose(attribute_id);
-
- /* Close the dataspace. */
- status = H5Sclose(dataspace_id);
-
- /* Close to the dataset. */
- status = H5Dclose(dataset_id);
-
- /* Close the file. */
- status = H5Fclose(file_id);
-}
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates how to create an attribute attached to a + * dataset. It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" +#define FILE "dset.h5" + +int main() { + + hid_t file_id, dataset_id, attribute_id, dataspace_id; /* identifiers */ + hsize_t dims; + int attr_data[2]; + herr_t status; + + /* Initialize the attribute data. */ + attr_data[0] = 100; + attr_data[1] = 200; + + /* Open an existing file. */ + file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); + + /* Open an existing dataset. */ + dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT); + + /* Create the data space for the attribute. */ + dims = 2; + dataspace_id = H5Screate_simple(1, &dims, NULL); + + /* Create a dataset attribute. */ + attribute_id = H5Acreate2 (dataset_id, "Units", H5T_STD_I32BE, dataspace_id, + H5P_DEFAULT, H5P_DEFAULT); + + /* Write the attribute data. */ + status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data); + + /* Close the attribute. */ + status = H5Aclose(attribute_id); + + /* Close the dataspace. */ + status = H5Sclose(dataspace_id); + + /* Close to the dataset. */ + status = H5Dclose(dataset_id); + + /* Close the file. */ + status = H5Fclose(file_id); +} diff --git a/examples/h5_crtdat.c b/examples/h5_crtdat.c index bbb29b2..f9327e7 100644 --- a/examples/h5_crtdat.c +++ b/examples/h5_crtdat.c @@ -1,51 +1,51 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates how to create a dataset that is a 4 x 6
- * array. It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-#define FILE "dset.h5"
-
-int main() {
-
- hid_t file_id, dataset_id, dataspace_id; /* identifiers */
- hsize_t dims[2];
- herr_t status;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create the data space for the dataset. */
- dims[0] = 4;
- dims[1] = 6;
- dataspace_id = H5Screate_simple(2, dims, NULL);
-
- /* Create the dataset. */
- dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* End access to the dataset and release resources used by it. */
- status = H5Dclose(dataset_id);
-
- /* Terminate access to the data space. */
- status = H5Sclose(dataspace_id);
-
- /* Close the file. */
- status = H5Fclose(file_id);
-}
-
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates how to create a dataset that is a 4 x 6 + * array. It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" +#define FILE "dset.h5" + +int main() { + + hid_t file_id, dataset_id, dataspace_id; /* identifiers */ + hsize_t dims[2]; + herr_t status; + + /* Create a new file using default properties. */ + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create the data space for the dataset. */ + dims[0] = 4; + dims[1] = 6; + dataspace_id = H5Screate_simple(2, dims, NULL); + + /* Create the dataset. */ + dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* End access to the dataset and release resources used by it. */ + status = H5Dclose(dataset_id); + + /* Terminate access to the data space. */ + status = H5Sclose(dataspace_id); + + /* Close the file. */ + status = H5Fclose(file_id); +} + diff --git a/examples/h5_crtgrp.c b/examples/h5_crtgrp.c index 3a94a8f..a626ed8 100644 --- a/examples/h5_crtgrp.c +++ b/examples/h5_crtgrp.c @@ -1,40 +1,40 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates how to create and close a group.
- * It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-#define FILE "group.h5"
-
-int main() {
-
- hid_t file_id, group_id; /* identifiers */
- herr_t status;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create a group named "/MyGroup" in the file. */
- group_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Close the group. */
- status = H5Gclose(group_id);
-
- /* Terminate access to the file. */
- status = H5Fclose(file_id);
-}
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates how to create and close a group. + * It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" +#define FILE "group.h5" + +int main() { + + hid_t file_id, group_id; /* identifiers */ + herr_t status; + + /* Create a new file using default properties. */ + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create a group named "/MyGroup" in the file. */ + group_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Close the group. */ + status = H5Gclose(group_id); + + /* Terminate access to the file. */ + status = H5Fclose(file_id); +} diff --git a/examples/h5_crtgrpar.c b/examples/h5_crtgrpar.c index 9e6fc40..e8cf7c3 100644 --- a/examples/h5_crtgrpar.c +++ b/examples/h5_crtgrpar.c @@ -1,48 +1,48 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates the creation of groups using absolute and
- * relative names. It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-#define FILE "groups.h5"
-
-int main() {
-
- hid_t file_id, group1_id, group2_id, group3_id; /* identifiers */
- herr_t status;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create group "MyGroup" in the root group using absolute name. */
- group1_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create group "Group_A" in group "MyGroup" using absolute name. */
- group2_id = H5Gcreate2(file_id, "/MyGroup/Group_A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create group "Group_B" in group "MyGroup" using relative name. */
- group3_id = H5Gcreate2(group1_id, "Group_B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Close groups. */
- status = H5Gclose(group1_id);
- status = H5Gclose(group2_id);
- status = H5Gclose(group3_id);
-
- /* Close the file. */
- status = H5Fclose(file_id);
-}
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates the creation of groups using absolute and + * relative names. It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" +#define FILE "groups.h5" + +int main() { + + hid_t file_id, group1_id, group2_id, group3_id; /* identifiers */ + herr_t status; + + /* Create a new file using default properties. */ + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create group "MyGroup" in the root group using absolute name. */ + group1_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Create group "Group_A" in group "MyGroup" using absolute name. */ + group2_id = H5Gcreate2(file_id, "/MyGroup/Group_A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Create group "Group_B" in group "MyGroup" using relative name. */ + group3_id = H5Gcreate2(group1_id, "Group_B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Close groups. */ + status = H5Gclose(group1_id); + status = H5Gclose(group2_id); + status = H5Gclose(group3_id); + + /* Close the file. */ + status = H5Fclose(file_id); +} diff --git a/examples/h5_crtgrpd.c b/examples/h5_crtgrpd.c index 9c45928..d6a320b 100644 --- a/examples/h5_crtgrpd.c +++ b/examples/h5_crtgrpd.c @@ -1,91 +1,91 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates how to create a dataset in a group.
- * It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-#define FILE "groups.h5"
-
-int main() {
-
- hid_t file_id, group_id, dataset_id, dataspace_id; /* identifiers */
- hsize_t dims[2];
- herr_t status;
- int i, j, dset1_data[3][3], dset2_data[2][10];
-
- /* Initialize the first dataset. */
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- dset1_data[i][j] = j + 1;
-
- /* Initialize the second dataset. */
- for (i = 0; i < 2; i++)
- for (j = 0; j < 10; j++)
- dset2_data[i][j] = j + 1;
-
- /* Open an existing file. */
- file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
-
- /* Create the data space for the first dataset. */
- dims[0] = 3;
- dims[1] = 3;
- dataspace_id = H5Screate_simple(2, dims, NULL);
-
- /* Create a dataset in group "MyGroup". */
- dataset_id = H5Dcreate2(file_id, "/MyGroup/dset1", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Write the first dataset. */
- status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset1_data);
-
- /* Close the data space for the first dataset. */
- status = H5Sclose(dataspace_id);
-
- /* Close the first dataset. */
- status = H5Dclose(dataset_id);
-
- /* Open an existing group of the specified file. */
- group_id = H5Gopen2(file_id, "/MyGroup/Group_A", H5P_DEFAULT);
-
- /* Create the data space for the second dataset. */
- dims[0] = 2;
- dims[1] = 10;
- dataspace_id = H5Screate_simple(2, dims, NULL);
-
- /* Create the second dataset in group "Group_A". */
- dataset_id = H5Dcreate2(group_id, "dset2", H5T_STD_I32BE, dataspace_id,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Write the second dataset. */
- status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset2_data);
-
- /* Close the data space for the second dataset. */
- status = H5Sclose(dataspace_id);
-
- /* Close the second dataset */
- status = H5Dclose(dataset_id);
-
- /* Close the group. */
- status = H5Gclose(group_id);
-
- /* Close the file. */
- status = H5Fclose(file_id);
-}
-
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates how to create a dataset in a group. + * It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" +#define FILE "groups.h5" + +int main() { + + hid_t file_id, group_id, dataset_id, dataspace_id; /* identifiers */ + hsize_t dims[2]; + herr_t status; + int i, j, dset1_data[3][3], dset2_data[2][10]; + + /* Initialize the first dataset. */ + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j++) + dset1_data[i][j] = j + 1; + + /* Initialize the second dataset. */ + for (i = 0; i < 2; i++) + for (j = 0; j < 10; j++) + dset2_data[i][j] = j + 1; + + /* Open an existing file. */ + file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); + + /* Create the data space for the first dataset. */ + dims[0] = 3; + dims[1] = 3; + dataspace_id = H5Screate_simple(2, dims, NULL); + + /* Create a dataset in group "MyGroup". */ + dataset_id = H5Dcreate2(file_id, "/MyGroup/dset1", H5T_STD_I32BE, dataspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Write the first dataset. */ + status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + dset1_data); + + /* Close the data space for the first dataset. */ + status = H5Sclose(dataspace_id); + + /* Close the first dataset. */ + status = H5Dclose(dataset_id); + + /* Open an existing group of the specified file. */ + group_id = H5Gopen2(file_id, "/MyGroup/Group_A", H5P_DEFAULT); + + /* Create the data space for the second dataset. */ + dims[0] = 2; + dims[1] = 10; + dataspace_id = H5Screate_simple(2, dims, NULL); + + /* Create the second dataset in group "Group_A". */ + dataset_id = H5Dcreate2(group_id, "dset2", H5T_STD_I32BE, dataspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Write the second dataset. */ + status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + dset2_data); + + /* Close the data space for the second dataset. */ + status = H5Sclose(dataspace_id); + + /* Close the second dataset */ + status = H5Dclose(dataset_id); + + /* Close the group. */ + status = H5Gclose(group_id); + + /* Close the file. */ + status = H5Fclose(file_id); +} + diff --git a/examples/h5_rdwt.c b/examples/h5_rdwt.c index d5444e0..0e290ca 100644 --- a/examples/h5_rdwt.c +++ b/examples/h5_rdwt.c @@ -1,53 +1,53 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This example illustrates how to write and read data in an existing
- * dataset. It is used in the HDF5 Tutorial.
- */
-
-#include "hdf5.h"
-#define FILE "dset.h5"
-
-int main() {
-
- hid_t file_id, dataset_id; /* identifiers */
- herr_t status;
- int i, j, dset_data[4][6];
-
- /* Initialize the dataset. */
- for (i = 0; i < 4; i++)
- for (j = 0; j < 6; j++)
- dset_data[i][j] = i * 6 + j + 1;
-
- /* Open an existing file. */
- file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
-
- /* Open an existing dataset. */
- dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
-
- /* Write the dataset. */
- status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset_data);
-
- status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- dset_data);
-
- /* Close the dataset. */
- status = H5Dclose(dataset_id);
-
- /* Close the file. */
- status = H5Fclose(file_id);
-}
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example illustrates how to write and read data in an existing + * dataset. It is used in the HDF5 Tutorial. + */ + +#include "hdf5.h" +#define FILE "dset.h5" + +int main() { + + hid_t file_id, dataset_id; /* identifiers */ + herr_t status; + int i, j, dset_data[4][6]; + + /* Initialize the dataset. */ + for (i = 0; i < 4; i++) + for (j = 0; j < 6; j++) + dset_data[i][j] = i * 6 + j + 1; + + /* Open an existing file. */ + file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); + + /* Open an existing dataset. */ + dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT); + + /* Write the dataset. */ + status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + dset_data); + + status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + dset_data); + + /* Close the dataset. */ + status = H5Dclose(dataset_id); + + /* Close the file. */ + status = H5Fclose(file_id); +} |